diff --git a/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/SystemConfigController.java b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/SystemConfigController.java new file mode 100644 index 0000000..242a818 --- /dev/null +++ b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/SystemConfigController.java @@ -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 getSystemConfig(@RequestParam("id") String id) { + ServiceBody 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()); + } + } + + + +} diff --git a/xymanager_admin/src/main/resources/application-test.yml b/xymanager_admin/src/main/resources/application-test.yml index 1ee936d..aed7cf1 100644 --- a/xymanager_admin/src/main/resources/application-test.yml +++ b/xymanager_admin/src/main/resources/application-test.yml @@ -170,6 +170,6 @@ cma: port: 6891 upload: # path: file:/usr/local/home/manager/download/ - path: C:\software\upload\ + path: http://47.96.238.157/usr/local/home/manager/download/ photo: address: http://47.96.238.157/photos/ diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/model/SystemConfigModel.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/SystemConfigModel.java new file mode 100644 index 0000000..28dbba8 --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/SystemConfigModel.java @@ -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; + + +} diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/util/ProcessExecUtils.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/util/ProcessExecUtils.java new file mode 100644 index 0000000..c4c8418 --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/util/ProcessExecUtils.java @@ -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; + } + + + +} diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/SystemConfigVo.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/SystemConfigVo.java new file mode 100644 index 0000000..ca5f523 --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/SystemConfigVo.java @@ -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; + + +} diff --git a/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/SystemConfigDao.java b/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/SystemConfigDao.java new file mode 100644 index 0000000..8c13f5d --- /dev/null +++ b/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/SystemConfigDao.java @@ -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); + +} \ No newline at end of file diff --git a/xymanager_dao/src/main/resources/mappers/SystemConfigDao.xml b/xymanager_dao/src/main/resources/mappers/SystemConfigDao.xml new file mode 100644 index 0000000..6b4fe1f --- /dev/null +++ b/xymanager_dao/src/main/resources/mappers/SystemConfigDao.xml @@ -0,0 +1,32 @@ + + + + + + + + + select + param_name as paramValue + from global_param + where param_name = #{key,jdbcType=VARCHAR} + + + + + + update `terminal_params` + + + heartbeat_time = #{heartBeatTime,jdbcType=VARCHAR}, + + + where id = #{termId} + + + \ No newline at end of file diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/SystemConfigServiceImpl.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/SystemConfigServiceImpl.java new file mode 100644 index 0000000..7fb271f --- /dev/null +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/SystemConfigServiceImpl.java @@ -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 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; + } +} diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalPhotoServiceImpl.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalPhotoServiceImpl.java index 75e929e..8c2dcd2 100644 --- a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalPhotoServiceImpl.java +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalPhotoServiceImpl.java @@ -3,7 +3,9 @@ package com.shxy.xymanager_service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DateTime; +import com.alibaba.fastjson.JSON; import com.github.pagehelper.PageInfo; +import com.google.common.collect.Lists; import com.shxy.xymanager_common.bean.ServiceBody; import com.shxy.xymanager_common.dto.TerminalPhotoScheduleDto; import com.shxy.xymanager_common.entity.TerminalPhoto; @@ -292,47 +294,38 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService { List dtoList = terminalPhotoDao.selectPhotoSchedule(vo); Map> map =dtoList.stream().collect(Collectors.groupingBy(TerminalPhotoScheduleDto :: getCmid)) ; map.forEach((key,value) ->{ - Short[] timeList = new Short[255]; + List timeList = Lists.newArrayList(); int i = 0 ; for(int j = 0; j 0) { - i++; - timeList[i]= (short)(span/60); - i++; - timeList[i]= (short)(span % 60); + timeList.add((short)(span/60)); + timeList.add((short)(span % 60)); }else if(span<60 ){ - i++; - timeList[i]= (short)0; - i++; - timeList[i]= span ; + timeList.add((short)0); + timeList.add(span); } - i++; - timeList[i]= 255 ; + timeList.add((short)255); }; - String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --port=6891 --act=updateSchedule[0xCA] --cmdid="+key +"\t" +"--channel="+ vo.getChannel() +"\t"+ "--scheduleData="+timeList; + String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --port=6891 --act=updateSchedule[0xCA] --cmdid="+key +"\t" +"--channel="+ vo.getChannel() +"\t"+ "--scheduleData="+ JSON.toJSONString(timeList); ProcessExecUtils.exec(cmd); }); diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/service/SystemConfigService.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/service/SystemConfigService.java new file mode 100644 index 0000000..bb3404b --- /dev/null +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/service/SystemConfigService.java @@ -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 getSystemConfig(String id); + + + /** + * 更新心跳时间 + * + * @return + */ + ServiceBody updateSystemConfig(SystemConfigVo vo); + +}