Merge branch 'master' of https://gitee.com/xinyingpower/xymanagerbackend
commit
bbdc5a00d0
@ -0,0 +1,62 @@
|
||||
package com.shxy.xymanager_admin.controller;
|
||||
|
||||
import com.shxy.xymanager_common.annotation.Log;
|
||||
import com.shxy.xymanager_common.base.BaseController;
|
||||
import com.shxy.xymanager_common.base.ResponseReult;
|
||||
import com.shxy.xymanager_common.bean.ServiceBody;
|
||||
import com.shxy.xymanager_common.bean.ServiceStatus;
|
||||
import com.shxy.xymanager_common.model.LineListModel;
|
||||
import com.shxy.xymanager_common.model.SystemConfigModel;
|
||||
import com.shxy.xymanager_common.vo.*;
|
||||
import com.shxy.xymanager_service.service.LineService;
|
||||
import com.shxy.xymanager_service.service.SystemConfigService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
@Api(value = "全局参数设置", tags = "全局参数设置")
|
||||
@RestController
|
||||
@Slf4j
|
||||
public class SystemConfigController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
SystemConfigService configService;
|
||||
|
||||
@ApiOperation(value = "获取全局配置", notes = "获取全局配置表接口", httpMethod = "POST")
|
||||
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
|
||||
@RequestMapping("/getSystemConfig")
|
||||
@Log(title = "获取线路列表", type = "查询")
|
||||
public ResponseReult<SystemConfigModel> getSystemConfig(@RequestParam("id") String id) {
|
||||
ServiceBody<SystemConfigModel> serviceBody = configService.getSystemConfig(id);
|
||||
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
|
||||
return ResponseReult.success(serviceBody.getData());
|
||||
} else {
|
||||
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新配置", notes = "更新配置", httpMethod = "POST")
|
||||
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
|
||||
@RequestMapping("/updateSystemConfig")
|
||||
@Log(title = "更新配置", type = "查询")
|
||||
public ResponseReult updateSystemConfig(@RequestBody SystemConfigVo vo) {
|
||||
ServiceBody serviceBody = configService.updateSystemConfig(vo);
|
||||
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
|
||||
return ResponseReult.success(serviceBody.getData());
|
||||
} else {
|
||||
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.shxy.xymanager_common.model;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Time;
|
||||
|
||||
/**
|
||||
* 时间任务列表
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "配置信息", description = "获取配置信息")
|
||||
public class SystemConfigModel implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "配置ID", example = "123456")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "心跳间隔", example = "123456")
|
||||
private Integer heartBeatTime;
|
||||
|
||||
@ApiModelProperty(value = "全局心跳间隔", example = "213")
|
||||
private Integer globalTime;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package com.shxy.xymanager_common.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* 上传文件
|
||||
* @author cy
|
||||
*/
|
||||
@Slf4j
|
||||
public class ProcessExecUtils
|
||||
{
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*
|
||||
*/
|
||||
public static Integer exec(String cmd) {
|
||||
String line = "";
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String result = "";
|
||||
Integer sendToCode = -1;
|
||||
try {
|
||||
Process ps = Runtime.getRuntime().exec(cmd);
|
||||
log.info("传入cmd信息:{}",cmd);
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(ps.getInputStream()));
|
||||
sendToCode = ps.waitFor();
|
||||
log.info("进程返回结果:{}",sendToCode);
|
||||
while ((line = reader.readLine()) != null) {
|
||||
sb.append(line).append("\n");
|
||||
}
|
||||
if(StringUtils.isNotBlank(result)){
|
||||
log.info("查询最新结果:{}",result);
|
||||
}
|
||||
result = sb.toString();
|
||||
} catch (IOException e) {
|
||||
log.error("IOException",e);
|
||||
} catch (InterruptedException e) {
|
||||
log.error("InterruptedException",e);
|
||||
}
|
||||
return sendToCode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.shxy.xymanager_common.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "通道对象", description = "通道对象描述")
|
||||
public class SystemConfigVo {
|
||||
|
||||
@NotNull(message = "通道ID")
|
||||
@ApiModelProperty(value = "通道ID", example = "123455")
|
||||
private Integer termId;
|
||||
|
||||
@NotNull(message = "参数值")
|
||||
@ApiModelProperty(value = "参数值", example = "123455")
|
||||
private Integer heartBeatTime;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.shxy.xymanager_dao.dao;
|
||||
|
||||
import com.shxy.xymanager_common.dto.TerminalApkInfoDto;
|
||||
import com.shxy.xymanager_common.entity.TerminalParams;
|
||||
import com.shxy.xymanager_common.entity.TerminalUpload;
|
||||
import com.shxy.xymanager_common.vo.SystemConfigVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SystemConfigDao {
|
||||
|
||||
|
||||
Integer getTerminalParams(String id);
|
||||
|
||||
String getGlobalTime(String key);
|
||||
|
||||
void updateSystemConfig(TerminalParams vo);
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.shxy.xymanager_dao.dao.SystemConfigDao">
|
||||
|
||||
|
||||
|
||||
|
||||
<insert id="getTerminalParams" parameterType="java.lang.String">
|
||||
select
|
||||
param_name as paramValue
|
||||
from global_param
|
||||
where param_name = #{key,jdbcType=VARCHAR}
|
||||
</insert>
|
||||
|
||||
<select id="getGlobalTime" parameterType="java.lang.String">
|
||||
select
|
||||
heartbeat_time as heartbeatTime
|
||||
from terminal_params
|
||||
where term_id = #{id,jdbcType=INTEGER}
|
||||
</select>
|
||||
|
||||
<update id="updateSystemConfig" parameterType="com.shxy.xymanager_common.entity.TerminalParams">
|
||||
update `terminal_params`
|
||||
<set>
|
||||
<if test=" heartBeatTime!= null">
|
||||
heartbeat_time = #{heartBeatTime,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{termId}
|
||||
</update>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,44 @@
|
||||
package com.shxy.xymanager_service.impl;
|
||||
|
||||
import com.shxy.xymanager_common.bean.ServiceBody;
|
||||
import com.shxy.xymanager_common.constant.Constants;
|
||||
import com.shxy.xymanager_common.entity.TerminalParams;
|
||||
import com.shxy.xymanager_common.exception.Asserts;
|
||||
import com.shxy.xymanager_common.model.SystemConfigModel;
|
||||
import com.shxy.xymanager_common.vo.SystemConfigVo;
|
||||
import com.shxy.xymanager_dao.dao.SystemConfigDao;
|
||||
import com.shxy.xymanager_service.service.SystemConfigService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 装置图片实现层
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SystemConfigServiceImpl implements SystemConfigService {
|
||||
|
||||
|
||||
@Autowired
|
||||
SystemConfigDao systemConfigDao;
|
||||
|
||||
@Override
|
||||
public ServiceBody<SystemConfigModel> getSystemConfig(String id) {
|
||||
SystemConfigModel model = new SystemConfigModel();
|
||||
Integer beatHeartTime = systemConfigDao.getTerminalParams(id);
|
||||
model.setHeartBeatTime(beatHeartTime);
|
||||
String globalTime = systemConfigDao.getGlobalTime(Constants.GLOBAL_TIME);
|
||||
model.setGlobalTime(Integer.parseInt(globalTime));
|
||||
return Asserts.success(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceBody updateSystemConfig(SystemConfigVo vo) {
|
||||
TerminalParams param = new TerminalParams();
|
||||
param.setTermId(vo.getTermId());
|
||||
param.setHeartbeatTime(vo.getHeartBeatTime());
|
||||
systemConfigDao.updateSystemConfig(param);
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.shxy.xymanager_service.service;
|
||||
|
||||
import com.shxy.xymanager_common.bean.ServiceBody;
|
||||
import com.shxy.xymanager_common.model.SystemConfigModel;
|
||||
import com.shxy.xymanager_common.vo.SystemConfigVo;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author CY
|
||||
*/
|
||||
public interface SystemConfigService {
|
||||
|
||||
/**
|
||||
* 获取心跳时间
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
ServiceBody<SystemConfigModel> getSystemConfig(String id);
|
||||
|
||||
|
||||
/**
|
||||
* 更新心跳时间
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
ServiceBody updateSystemConfig(SystemConfigVo vo);
|
||||
|
||||
}
|
Loading…
Reference in New Issue