liuguijing 2 years ago
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());
}
}
}

@ -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/

@ -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;
}
}

@ -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<TerminalPhotoScheduleDto> dtoList = terminalPhotoDao.selectPhotoSchedule(vo);
Map<String,List<TerminalPhotoScheduleDto>> map =dtoList.stream().collect(Collectors.groupingBy(TerminalPhotoScheduleDto :: getCmid)) ;
map.forEach((key,value) ->{
Short[] timeList = new Short[255];
List<Short> timeList = Lists.newArrayList();
int i = 0 ;
for(int j = 0; j<value.size();j++){
Short span = value.get(j).getSpan();
Date startTime = value.get(j).getStartTime();
Short startHour = Short.parseShort(MyDateUtils.parseHourAndMinute(startTime).split("/")[0]);
Short startMin = Short.parseShort(MyDateUtils.parseHourAndMinute(startTime).split("/")[1]);
timeList.add(startHour);
timeList.add(startMin);
timeList.add((short)255);
timeList[i]= startHour;
i++;
timeList[i]= startMin;
i++;
timeList[i]= 255;
Date endTime = value.get(j).getStartTime();
Short endTimeHour = Short.parseShort(MyDateUtils.parseHourAndMinute(endTime).split("/")[0]);
Short endTimeMin = Short.parseShort(MyDateUtils.parseHourAndMinute(endTime).split("/")[1]);
i++;
timeList[i]= endTimeHour;
i++;
timeList[i]= endTimeMin;
i++;
timeList[i]= 255;
timeList.add(endTimeHour);
timeList.add(endTimeMin);
timeList.add((short)255);
String spanStr;
if(span/60 > 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);
});

@ -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…
Cancel
Save