Commit 4f88f955 authored by zhouleilei's avatar zhouleilei

1、command操作日志记录2、Hisense系统logback存储优化3、utc返回优化,4、灯态runMode枚举值更新等

parent 85336f67
...@@ -15,15 +15,17 @@ import java.util.Objects; ...@@ -15,15 +15,17 @@ import java.util.Objects;
@AllArgsConstructor @AllArgsConstructor
@RequiredArgsConstructor @RequiredArgsConstructor
public enum DataBrainControlModeEnum { public enum DataBrainControlModeEnum {
//海信线协调控制是单个干线绿波,区域协调控制是多个干线绿波,到万集都是21,绿波协调
//对信号机来说都是绿波协调
LOCK(2, 52, "锁定"), LOCK(2, 52, "锁定"),
ALL_RED(3, 12, "全红"), ALL_RED(3, 12, "全红"),
YELLOW_FLASH(4, 13, "黄闪"), YELLOW_FLASH(4, 13, "黄闪"),
CLOSED_FLASH(5, 11, "关灯"), CLOSED_FLASH(5, 11, "关灯"),
STEP_CONTROL(9, 52, "步进"), STEP_CONTROL(9, 52, "步进"),
FIX_CYCLE(11, 21, "定周期"), FIX_CYCLE(11, 21, "定周期"),
SELF_ADAPTION(100, 23, "单点自适应控制"), SELF_ADAPTION(20, 23, "单点自适应控制"),
LINE_COORDINATE(100, 31, "线协调控制"), LINE_COORDINATE(21, 31, "线协调控制"),
REGION_COORDINATE(100, 41, "区域协调控制"), REGION_COORDINATE(21, 41, "区域协调控制"),
TEMP_PLAN(255, 53, "临时方案"); TEMP_PLAN(255, 53, "临时方案");
private Integer wjControl; private Integer wjControl;
......
...@@ -43,8 +43,8 @@ ...@@ -43,8 +43,8 @@
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--路径--> <!--路径-->
<fileNamePattern>${LOG_PATH}/hisense/%d{yyyy-MM-dd}/info.%d{yyyy-MM-dd}.%i.log</fileNamePattern> <fileNamePattern>${LOG_PATH}/hisense/%d{yyyy-MM-dd}/info.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<MaxHistory>30</MaxHistory> <MaxHistory>15</MaxHistory>
<totalSizeCap >10GB</totalSizeCap > <totalSizeCap >50GB</totalSizeCap >
<maxFileSize>200MB</maxFileSize> <maxFileSize>200MB</maxFileSize>
</rollingPolicy> </rollingPolicy>
</appender> </appender>
...@@ -62,8 +62,8 @@ ...@@ -62,8 +62,8 @@
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--路径--> <!--路径-->
<fileNamePattern>${LOG_PATH}/hisense/%d{yyyy-MM-dd}/error.%d{yyyy-MM-dd}.%i.log</fileNamePattern> <fileNamePattern>${LOG_PATH}/hisense/%d{yyyy-MM-dd}/error.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<MaxHistory>30</MaxHistory> <MaxHistory>15</MaxHistory>
<totalSizeCap >10GB</totalSizeCap > <totalSizeCap >50GB</totalSizeCap >
<maxFileSize>200MB</maxFileSize> <maxFileSize>200MB</maxFileSize>
</rollingPolicy> </rollingPolicy>
</appender> </appender>
......
package net.wanji.utc.service.control.impl; package net.wanji.utc.service.control.impl;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.rest.JsonViewObject; import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.common.utils.tool.IpAddressUtil;
import net.wanji.common.utils.tool.LocalDateTimeUtil;
import net.wanji.databus.dao.entity.*; import net.wanji.databus.dao.entity.*;
import net.wanji.databus.dao.mapper.*; import net.wanji.databus.dao.mapper.*;
import net.wanji.databus.dto.ExtendPhaseDTO; import net.wanji.databus.dto.ExtendPhaseDTO;
...@@ -19,20 +24,22 @@ import net.wanji.utc.common.typeenum.DateStyle; ...@@ -19,20 +24,22 @@ import net.wanji.utc.common.typeenum.DateStyle;
import net.wanji.utc.po.hk.request.DelBaseConfigPO; import net.wanji.utc.po.hk.request.DelBaseConfigPO;
import net.wanji.utc.service.control.ControlCommandService; import net.wanji.utc.service.control.ControlCommandService;
import net.wanji.utc.service.control.ControlCommandStrategyService; import net.wanji.utc.service.control.ControlCommandStrategyService;
import net.wanji.utc.task.SignalStatusTask;
import net.wanji.utc.util.StringUtils; import net.wanji.utc.util.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.*;
import java.util.Date; import java.util.concurrent.ConcurrentHashMap;
import java.util.List;
import java.util.Objects;
/** /**
* @author duanruiming * @author duanruiming
...@@ -57,6 +64,7 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy ...@@ -57,6 +64,7 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy
private final CrossInfoCache crossInfoCache; private final CrossInfoCache crossInfoCache;
private final CrossLightsMapper crossLightsMapper; private final CrossLightsMapper crossLightsMapper;
private final CrossPhaseLightsMapper crossPhaseLightsMapper; private final CrossPhaseLightsMapper crossPhaseLightsMapper;
private final SignalCommandLogPOMapper signalCommandLogPOMapper;
private final CrossPhaseDirTurnCache crossPhaseDirTurnCache; private final CrossPhaseDirTurnCache crossPhaseDirTurnCache;
private final CrossSchemePhaseTimeCountCache crossSchemePhaseTimeCountCache; private final CrossSchemePhaseTimeCountCache crossSchemePhaseTimeCountCache;
...@@ -230,28 +238,89 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy ...@@ -230,28 +238,89 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy
@Override @Override
public JsonViewObject lockControlStrategy(ControlCommandVO commandVO) throws Exception { public JsonViewObject lockControlStrategy(ControlCommandVO commandVO) throws Exception {
String now = LocalDateTimeUtil.formatNow(LocalDateTimeUtil.TIMEFORMATTER);
JsonViewObject jsonViewObject; JsonViewObject jsonViewObject;
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(commandVO.getCrossCode()); try {
if (StringUtils.equals(BasicEnum.ManufacturerEnum.HK.getCode(), manufacturerIdCode)) { String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(commandVO.getCrossCode());
jsonViewObject = hkControlCommandService.lockControl(commandVO); if (StringUtils.equals(BasicEnum.ManufacturerEnum.HK.getCode(), manufacturerIdCode)) {
} else { jsonViewObject = hkControlCommandService.lockControl(commandVO);
jsonViewObject = wanJiControlCommandService.lockControl(commandVO); } else {
jsonViewObject = wanJiControlCommandService.lockControl(commandVO);
}
} catch (Exception e) {
jsonViewObject = JsonViewObject.newInstance().fail(e.getMessage());
} }
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(commandVO));
jsonObject.put("crossId",commandVO.getCrossCode());
//插入命令操作日志
insertCommandLog(now,jsonViewObject, jsonObject,3);
return jsonViewObject; return jsonViewObject;
} }
@Override @Override
public JsonViewObject stepControlStrategy(String crossId, Integer command, Integer stepNum) throws Exception { public JsonViewObject stepControlStrategy(String crossId, Integer command, Integer stepNum) throws Exception {
String now = LocalDateTimeUtil.formatNow(LocalDateTimeUtil.TIMEFORMATTER);
JsonViewObject jsonViewObject; JsonViewObject jsonViewObject;
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(crossId); try {
if (StringUtils.equals(BasicEnum.ManufacturerEnum.HK.getCode(), manufacturerIdCode)) { String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(crossId);
jsonViewObject = hkControlCommandService.stepControl(crossId, command, stepNum); if (StringUtils.equals(BasicEnum.ManufacturerEnum.HK.getCode(), manufacturerIdCode)) {
} else { jsonViewObject = hkControlCommandService.stepControl(crossId, command, stepNum);
jsonViewObject = wanJiControlCommandService.stepControl(crossId, command, stepNum); } else {
jsonViewObject = wanJiControlCommandService.stepControl(crossId, command, stepNum);
}
} catch (Exception e) {
jsonViewObject = JsonViewObject.newInstance().fail(e.getMessage());
} }
JSONObject jsonObject = new JSONObject();
jsonObject.put("crossId",crossId);
jsonObject.put("command",command);
jsonObject.put("stepNum",stepNum);
//插入命令操作日志
insertCommandLog(now,jsonViewObject, jsonObject,1);
return jsonViewObject; return jsonViewObject;
} }
/**
* @Description 插入命令日志
* @Param nowTime 请求时间戳
* @Param jsonViewObject 操作结果
* @Param jsonObject 参数
* @return void
**/
public void insertCommandLog(String queryTime,JsonViewObject jsonViewObject, JSONObject jsonObject,int commandType){
SignalCommandLogPO signalCommandLogPO = new SignalCommandLogPO();
signalCommandLogPO.setCrossId(jsonObject.getString("crossId"));
signalCommandLogPO.setDataInfo(jsonObject.toJSONString());
signalCommandLogPO.setCommandType(commandType);
signalCommandLogPO.setQueryTime(queryTime);
Integer code = jsonViewObject.getCode();
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String ip = IpAddressUtil.getIpAddress(request);
signalCommandLogPO.setIp(ip);
if (code == 200){
signalCommandLogPO.setCommandResult(1);
}else {
signalCommandLogPO.setCommandResult(2);
}
signalCommandLogPO.setResultMessage(jsonViewObject.getMessage());
ConcurrentHashMap<String, List<LightsStatusVO2>> produceListMap = SignalStatusTask.produceListMap;
if (!produceListMap.isEmpty()) {
List<LightsStatusVO2> list = produceListMap.get(jsonObject.get("crossId"));
if (ObjectUtil.isNotEmpty(list)){
LightsStatusVO2 lightsStatusVO2 = list.get(0);
String runMode = lightsStatusVO2.getRunMode();
String lampTime = lightsStatusVO2.getTimeStamp();
//时间转换
lampTime = LocalDateTimeUtil.formatTimeStamp(Long.valueOf(lampTime), LocalDateTimeUtil.TIMEFORMATTER);
signalCommandLogPO.setRunMode(runMode);
signalCommandLogPO.setLampTime(lampTime);
}
}
signalCommandLogPOMapper.insert(signalCommandLogPO);
}
@Override @Override
public JsonViewObject setSignalControlStrategy(String crossId, Integer command, Integer commandType) throws Exception { public JsonViewObject setSignalControlStrategy(String crossId, Integer command, Integer commandType) throws Exception {
JsonViewObject jsonViewObject; JsonViewObject jsonViewObject;
...@@ -266,16 +335,15 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy ...@@ -266,16 +335,15 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy
@Override @Override
public JsonViewObject recoverScheduleStrategy(String crossId) throws Exception { public JsonViewObject recoverScheduleStrategy(String crossId) throws Exception {
String now = LocalDateTimeUtil.formatNow(LocalDateTimeUtil.TIMEFORMATTER);
JsonViewObject jsonViewObject = JsonViewObject.newInstance(); JsonViewObject jsonViewObject = JsonViewObject.newInstance();
if (StringUtils.isBlank(crossId)) { if (StringUtils.isBlank(crossId)) {
return jsonViewObject.fail("路口编号不能为空"); return jsonViewObject.fail("路口编号不能为空");
} }
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(crossId); JSONObject jsonObject = new JSONObject();
if (StringUtils.equals(BasicEnum.ManufacturerEnum.HK.getCode(), manufacturerIdCode)) { jsonObject.put("crossId",crossId);
jsonViewObject = hkControlCommandService.recoverSchedule(crossId); //插入命令操作日志
} else { insertCommandLog(now,jsonViewObject, jsonObject,2);
jsonViewObject = wanJiControlCommandService.recoverSchedule(crossId);
}
return jsonViewObject; return jsonViewObject;
} }
...@@ -358,12 +426,20 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy ...@@ -358,12 +426,20 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy
@Override @Override
public JsonViewObject tempSchemeDetail(TempSchemeSendVO tempSchemeSendVO) throws Exception { public JsonViewObject tempSchemeDetail(TempSchemeSendVO tempSchemeSendVO) throws Exception {
String manufacturerCode = crossInfoCache.getManufacturerCodeByCrossId(tempSchemeSendVO.getCrossId()); String now = LocalDateTimeUtil.formatNow(LocalDateTimeUtil.TIMEFORMATTER);
JsonViewObject jsonViewObject = JsonViewObject.newInstance(); JsonViewObject jsonViewObject = JsonViewObject.newInstance();
if (StringUtils.equals(BasicEnum.ManufacturerEnum.HK.getCode(), manufacturerCode)) { try {
} else { String manufacturerCode = crossInfoCache.getManufacturerCodeByCrossId(tempSchemeSendVO.getCrossId());
jsonViewObject = wanJiControlCommandService.tempSchemeDetail(tempSchemeSendVO); if (StringUtils.equals(BasicEnum.ManufacturerEnum.HK.getCode(), manufacturerCode)) {
} else {
jsonViewObject = wanJiControlCommandService.tempSchemeDetail(tempSchemeSendVO);
}
} catch (Exception e) {
jsonViewObject = JsonViewObject.newInstance().fail(e.getMessage());
} }
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(tempSchemeSendVO));
//插入命令操作日志
insertCommandLog(now,jsonViewObject, jsonObject,4);
return jsonViewObject; return jsonViewObject;
} }
......
...@@ -15,7 +15,6 @@ import net.wanji.utc.common.constant.Constants; ...@@ -15,7 +15,6 @@ import net.wanji.utc.common.constant.Constants;
import net.wanji.utc.po.hk.request.DelBaseConfigPO; import net.wanji.utc.po.hk.request.DelBaseConfigPO;
import net.wanji.utc.service.control.ControlCommandService; import net.wanji.utc.service.control.ControlCommandService;
import net.wanji.utc.util.HttpRestUtil; import net.wanji.utc.util.HttpRestUtil;
import net.wanji.utc.util.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -48,9 +47,9 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService { ...@@ -48,9 +47,9 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
public JsonViewObject schemeSend(SchemeSendVO schemeSendVO) throws Exception { public JsonViewObject schemeSend(SchemeSendVO schemeSendVO) throws Exception {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(schemeSendVO.getCrossCode()); String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(schemeSendVO.getCrossCode());
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).schemeSend(schemeSendVO); JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).schemeSend(schemeSendVO);
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) { /*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("万集标准协议下发方案成功!"); return jsonViewObject.success("万集标准协议下发方案成功!");
} }*/
return jsonViewObject; return jsonViewObject;
} }
...@@ -58,9 +57,9 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService { ...@@ -58,9 +57,9 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
public JsonViewObject planSend(PlanSendVO planSendVO) throws Exception { public JsonViewObject planSend(PlanSendVO planSendVO) throws Exception {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(planSendVO.getCrossCode()); String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(planSendVO.getCrossCode());
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).planSend(planSendVO); JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).planSend(planSendVO);
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) { /*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("万集标准协议下发计划成功!"); return jsonViewObject.success("万集标准协议下发计划成功!");
} }*/
return jsonViewObject; return jsonViewObject;
} }
...@@ -68,9 +67,9 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService { ...@@ -68,9 +67,9 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
public JsonViewObject scheduleSend(ScheduleSendVO scheduleSendVO) throws Exception { public JsonViewObject scheduleSend(ScheduleSendVO scheduleSendVO) throws Exception {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(scheduleSendVO.getCrossCode()); String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(scheduleSendVO.getCrossCode());
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).scheduleSend(scheduleSendVO); JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).scheduleSend(scheduleSendVO);
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) { /*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("万集标准协议下发时间表成功!"); return jsonViewObject.success("万集标准协议下发时间表成功!");
} }*/
return jsonViewObject; return jsonViewObject;
} }
...@@ -83,9 +82,9 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService { ...@@ -83,9 +82,9 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
lockControlVO.setDuration(commandVO.getDuration()); lockControlVO.setDuration(commandVO.getDuration());
lockControlVO.setPhaseList(commandVO.getPhaseList()); lockControlVO.setPhaseList(commandVO.getPhaseList());
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).lockControl(lockControlVO); JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).lockControl(lockControlVO);
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) { /*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("万集标准协议锁定控制成功!"); return jsonViewObject.success("万集标准协议锁定控制成功!");
} }*/
return jsonViewObject; return jsonViewObject;
} }
...@@ -93,9 +92,9 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService { ...@@ -93,9 +92,9 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
public JsonViewObject stepControl(String crossId, Integer command, Integer stepNum) throws Exception { public JsonViewObject stepControl(String crossId, Integer command, Integer stepNum) throws Exception {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(crossId); String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(crossId);
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).stepControl(crossId, command, stepNum); JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).stepControl(crossId, command, stepNum);
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) { /*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("万集标准协议步进控制成功!"); return jsonViewObject.success("万集标准协议步进控制成功!");
} }*/
return jsonViewObject; return jsonViewObject;
} }
...@@ -129,9 +128,9 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService { ...@@ -129,9 +128,9 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
controlCommandVO.setControlType(Constants.ALL_RED_CONTROL); controlCommandVO.setControlType(Constants.ALL_RED_CONTROL);
jsonViewObject = utcFeignClientService.closeLightControl(controlCommandVO); jsonViewObject = utcFeignClientService.closeLightControl(controlCommandVO);
} }
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) { /*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("万集标准协议设置信号机控制模式成功!"); return jsonViewObject.success("万集标准协议设置信号机控制模式成功!");
} }*/
return jsonViewObject; return jsonViewObject;
} }
...@@ -139,9 +138,9 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService { ...@@ -139,9 +138,9 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
public JsonViewObject recoverSchedule(String crossId) throws Exception { public JsonViewObject recoverSchedule(String crossId) throws Exception {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(crossId); String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(crossId);
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).recoverSchedule(crossId); JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).recoverSchedule(crossId);
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) { /*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("万集标准协议恢复时间表成功!"); return jsonViewObject.success("万集标准协议恢复时间表成功!");
} }*/
return jsonViewObject; return jsonViewObject;
} }
...@@ -149,9 +148,9 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService { ...@@ -149,9 +148,9 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
public JsonViewObject phaseTimingSend(PhaseTimingSendVO phaseTimingSendVO) throws Exception { public JsonViewObject phaseTimingSend(PhaseTimingSendVO phaseTimingSendVO) throws Exception {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(phaseTimingSendVO.getCrossCode()); String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(phaseTimingSendVO.getCrossCode());
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).recoverSchedule(phaseTimingSendVO.getCrossCode()); JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).recoverSchedule(phaseTimingSendVO.getCrossCode());
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) { /*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("万集标准协议下发相位配时成功!"); return jsonViewObject.success("万集标准协议下发相位配时成功!");
} }*/
return jsonViewObject; return jsonViewObject;
} }
...@@ -169,10 +168,11 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService { ...@@ -169,10 +168,11 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
public JsonViewObject timing(String crossCode, Date date) throws Exception { public JsonViewObject timing(String crossCode, Date date) throws Exception {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(crossCode); String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(crossCode);
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).signalTiming(crossCode, date); JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).signalTiming(crossCode, date);
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) { /*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("万集标准协议校时成功!"); return jsonViewObject.success("万集标准协议校时成功!");
} }
return jsonViewObject.fail("万集标准协议校时失败!"); return jsonViewObject.fail("万集标准协议校时失败!");*/
return jsonViewObject;
} }
@Override @Override
...@@ -187,10 +187,11 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService { ...@@ -187,10 +187,11 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
TempSchemeSendVO tempSchemeSendVO = getTempSchemeSendVO(schemeOptSendVO); TempSchemeSendVO tempSchemeSendVO = getTempSchemeSendVO(schemeOptSendVO);
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(tempSchemeSendVO.getCrossId()); String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(tempSchemeSendVO.getCrossId());
jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).tempSchemeDetail(tempSchemeSendVO); jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).tempSchemeDetail(tempSchemeSendVO);
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) { /*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("万集标准协议下发临时方案成功!"); return jsonViewObject.success("万集标准协议下发临时方案成功!");
} }
return jsonViewObject.fail("万集标准协议下发临时方案失败!"); return jsonViewObject.fail("万集标准协议下发临时方案失败!");*/
return jsonViewObject;
} }
/** /**
...@@ -262,10 +263,11 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService { ...@@ -262,10 +263,11 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
insertStageOptLog(jsonViewObject.getCode(),tempSchemeSendVO); insertStageOptLog(jsonViewObject.getCode(),tempSchemeSendVO);
} }
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) { /*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("下发临时方案成功!"); return jsonViewObject.success("下发临时方案成功!");
} }
return jsonViewObject.fail("下发临时方案失败!"); return jsonViewObject.fail("下发临时方案失败!");*/
return jsonViewObject;
} }
/** /**
...@@ -311,19 +313,21 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService { ...@@ -311,19 +313,21 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
public JsonViewObject extendPhase(ExtendPhaseDTO extendPhase) throws Exception { public JsonViewObject extendPhase(ExtendPhaseDTO extendPhase) throws Exception {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(extendPhase.getCrossId()); String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(extendPhase.getCrossId());
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).extendPhase(extendPhase); JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).extendPhase(extendPhase);
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) { /*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("海信-延长相位成功!"); return jsonViewObject.success("海信-延长相位成功!");
} }
return jsonViewObject.fail("海信-延长相位失败!"); return jsonViewObject.fail("海信-延长相位失败!");*/
return jsonViewObject;
} }
@Override @Override
public JsonViewObject stepingPhase(StepingPhaseDTO stepingPhaseDTO) throws Exception { public JsonViewObject stepingPhase(StepingPhaseDTO stepingPhaseDTO) throws Exception {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(stepingPhaseDTO.getCrossId()); String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(stepingPhaseDTO.getCrossId());
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).stepingPhase(stepingPhaseDTO); JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).stepingPhase(stepingPhaseDTO);
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) { /*if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("步进相位成功!"); return jsonViewObject.success("步进相位成功!");
} }
return jsonViewObject.fail("步进相位失败!"); return jsonViewObject.fail("步进相位失败!");*/
return jsonViewObject;
} }
} }
package net.wanji.utc.service.staticinfo.impl; package net.wanji.utc.service.staticinfo.impl;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
...@@ -9,6 +10,7 @@ import lombok.RequiredArgsConstructor; ...@@ -9,6 +10,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.rest.JsonViewObject; import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.common.utils.tool.JacksonUtils; import net.wanji.common.utils.tool.JacksonUtils;
import net.wanji.common.utils.tool.LocalDateTimeUtil;
import net.wanji.common.utils.tool.StringUtils; import net.wanji.common.utils.tool.StringUtils;
import net.wanji.databus.dao.entity.*; import net.wanji.databus.dao.entity.*;
import net.wanji.databus.dao.mapper.*; import net.wanji.databus.dao.mapper.*;
...@@ -24,6 +26,7 @@ import net.wanji.feign.service.common.FeignCommon; ...@@ -24,6 +26,7 @@ import net.wanji.feign.service.common.FeignCommon;
import net.wanji.utc.cache.CrossInfoCache; import net.wanji.utc.cache.CrossInfoCache;
import net.wanji.utc.cache.UtcFeignClientCache; import net.wanji.utc.cache.UtcFeignClientCache;
import net.wanji.utc.common.Result; import net.wanji.utc.common.Result;
import net.wanji.utc.service.control.impl.ControlCommandStrategyServiceImpl;
import net.wanji.utc.service.staticinfo.WanJiCommonStaticInfoService; import net.wanji.utc.service.staticinfo.WanJiCommonStaticInfoService;
import net.wanji.utc.util.HttpRestUtil; import net.wanji.utc.util.HttpRestUtil;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -59,6 +62,7 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe ...@@ -59,6 +62,7 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe
private final UtcFeignClientCache utcFeignClientCache; private final UtcFeignClientCache utcFeignClientCache;
private final BaseCrossSchemeMapper baseCrossSchemeMapper; private final BaseCrossSchemeMapper baseCrossSchemeMapper;
private final CrossSchemeStageOptLogMapper crossSchemeStageOptLogMapper; private final CrossSchemeStageOptLogMapper crossSchemeStageOptLogMapper;
private final ControlCommandStrategyServiceImpl controlCommandStrategyService;
@Override @Override
...@@ -209,23 +213,32 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe ...@@ -209,23 +213,32 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe
@Override @Override
public JsonViewObject crossSchemeRings(CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception { public JsonViewObject crossSchemeRings(CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception {
String now = LocalDateTimeUtil.formatNow(LocalDateTimeUtil.TIMEFORMATTER);
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(crossSchemeRingsDTO.getCrossId()); String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(crossSchemeRingsDTO.getCrossId());
JsonViewObject jsonViewObject = null; JsonViewObject jsonViewObject = null;
String crossId = crossSchemeRingsDTO.getCrossId(); String crossId = crossSchemeRingsDTO.getCrossId();
if ("HISENSE".equals(manufacturerIdCode)) { if ("HISENSE".equals(manufacturerIdCode)) {
FeignCommon utcFeignClientService = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode); FeignCommon utcFeignClientService = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode);
jsonViewObject = utcFeignClientService.crossSchemeRings(crossSchemeRingsDTO); jsonViewObject = utcFeignClientService.crossSchemeRings(crossSchemeRingsDTO);
log.info("方案环图请求,crossId:{},result:{}",crossId,jsonViewObject);
Integer code = jsonViewObject.getCode();
if (code != 200){
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(crossSchemeRingsDTO));
//插入命令操作日志
controlCommandStrategyService.insertCommandLog(now,jsonViewObject, jsonObject,10);
}
} else { } else {
CrossSchemeRings crossSchemeRings = getCrossSchemeRings(crossSchemeRingsDTO); CrossSchemeRings crossSchemeRings = getCrossSchemeRings(crossSchemeRingsDTO);
if (ObjectUtil.isNotEmpty(crossSchemeRings)) { if (ObjectUtil.isNotEmpty(crossSchemeRings)) {
jsonViewObject = JsonViewObject.newInstance().success(crossSchemeRings); jsonViewObject = JsonViewObject.newInstance().success(crossSchemeRings);
} else { } else {
jsonViewObject = JsonViewObject.newInstance().fail(); jsonViewObject = JsonViewObject.newInstance().fail("该方案信息未同步");
} }
} }
if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) { /*if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) {
throw new Exception("方案环图请求远程服务调用异常,异常信息" + jsonViewObject.getMessage()); throw new Exception("方案环图请求远程服务调用异常,异常信息" + jsonViewObject.getMessage());
} }*/
return jsonViewObject; return jsonViewObject;
} }
......
...@@ -84,7 +84,7 @@ public class SignalStatusTask { ...@@ -84,7 +84,7 @@ public class SignalStatusTask {
@Autowired @Autowired
private EHualuFeignClients eHualuFeignClients; private EHualuFeignClients eHualuFeignClients;
private static final ConcurrentHashMap<String, List<LightsStatusVO2>> produceListMap = new ConcurrentHashMap<>(); public static final ConcurrentHashMap<String, List<LightsStatusVO2>> produceListMap = new ConcurrentHashMap<>();
// 运行状态、告警,1分钟一次 // 运行状态、告警,1分钟一次
@Scheduled(fixedRate = 60 * 1000) @Scheduled(fixedRate = 60 * 1000)
......
package net.wanji.databus.dao.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.sql.Date;
/**
* @ClassName CrossSchemeOptLog
* @Description 命令操作日志
* @Author zhouleilei
* @Date 2024/12/23 15:23
*/
@Data
@TableName("t_signal_command_log")
public class SignalCommandLogPO {
@ApiModelProperty(value = "路口编号")
private String crossId;
@ApiModelProperty(value = "请求信息")
private String dataInfo;
@ApiModelProperty(value = "控制类型:1-步进控制/恢复(信控系统);2-恢复时间表(公用);3-相位锁定/解锁(公用);4-临时方案下发(公用);5-步进相位(神思);10-查询环图失败记录")
private Integer commandType;
@ApiModelProperty(value = "优化结果:1-成功 2-失败")
private Integer commandResult;
@ApiModelProperty(value = "返回信息")
private String resultMessage;
@ApiModelProperty(value = "运行模式 `2=手动锁定当前相位`,`3=手动全红`,`4=手动黄闪`,`5=手动关灯`,`6=全红闪控制`,`7=全黄控制`,`8=正常按计划运行`,`9=手动步进控制`,`10=自动步进控制`,`11=恢复时间表`,`255=临时控制方案`")
private String runMode;
@ApiModelProperty(value = "调用IP")
private String ip;
@ApiModelProperty(value = "请求时间")
private String queryTime;
@ApiModelProperty(value = "灯态时间")
private String lampTime;
@ApiModelProperty(value = "数据插入时间")
private Date insertTime;
}
package net.wanji.databus.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.wanji.databus.dao.entity.SignalCommandLogPO;
/**
* @ClassName SignalCommandLogPOMapper
* @Description SignalCommandLogPOMapper
* @Author zhouleilei
* @Date 2024/12/23 15:23
*/
public interface SignalCommandLogPOMapper extends BaseMapper<SignalCommandLogPO> {
}
...@@ -18,7 +18,7 @@ import java.util.List; ...@@ -18,7 +18,7 @@ import java.util.List;
@ApiModel(value = "LightsStatusVO2", description = "实时灯态信息实体版本2") @ApiModel(value = "LightsStatusVO2", description = "实时灯态信息实体版本2")
public class LightsStatusVO2 extends BaseCrossInfo { public class LightsStatusVO2 extends BaseCrossInfo {
@ApiModelProperty(value = "运行模式 `2=手动锁定当前相位`,`3=手动全红`,`4=手动黄闪`,`5=手动关灯`," + @ApiModelProperty(value = "运行模式 `2=手动锁定当前相位`,`3=手动全红`,`4=手动黄闪`,`5=手动关灯`," +
"`6=全红闪控制`,`7=全黄控制`,`8=正常按计划运行`,`9=手动步进控制`,`10=自动步进控制`,`11=恢复时间表`,`255=临时控制方案`") "`6=全红闪控制`,`7=全黄控制`,`8=正常按计划运行`,`9=手动步进控制`,`10=自动步进控制`,`11=恢复时间表`,`20=单点自适应控制`,`21=绿波协调`,`255=临时控制方案`")
private String runMode; private String runMode;
@ApiModelProperty(value = "控制模式") @ApiModelProperty(value = "控制模式")
private String controlMode; private String controlMode;
......
...@@ -241,7 +241,7 @@ ...@@ -241,7 +241,7 @@
AND schedules.`week` = #{week} AND schedules.`week` = #{week}
AND DATE_FORMAT( NOW(), '%H:%i' ) BETWEEN DATE_FORMAT( CAST( section.start_time AS TIME ), '%H:%i' ) AND DATE_FORMAT( NOW(), '%H:%i' ) BETWEEN DATE_FORMAT( CAST( section.start_time AS TIME ), '%H:%i' )
AND DATE_FORMAT( CAST( section.end_time AS TIME ), '%H:%i' ) AND DATE_FORMAT( CAST( section.end_time AS TIME ), '%H:%i' )
ORDER BY DATE_FORMAT( CAST( section.end_time AS TIME ), '%H:%i' ) ASC LIMIT 1 ORDER BY DATE_FORMAT( CAST( section.end_time AS TIME ), '%H:%i' ) DESC LIMIT 1
</select> </select>
<select id="selectSchemeByParams" resultType="net.wanji.databus.dao.entity.BaseCrossSchemePO"> <select id="selectSchemeByParams" resultType="net.wanji.databus.dao.entity.BaseCrossSchemePO">
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
AND schedules.`week` = #{week} AND schedules.`week` = #{week}
AND DATE_FORMAT( #{queryTime}, '%H:%i' ) BETWEEN DATE_FORMAT( CAST( section.start_time AS TIME ), '%H:%i' ) AND DATE_FORMAT( #{queryTime}, '%H:%i' ) BETWEEN DATE_FORMAT( CAST( section.start_time AS TIME ), '%H:%i' )
AND DATE_FORMAT( CAST( section.end_time AS TIME ), '%H:%i' ) AND DATE_FORMAT( CAST( section.end_time AS TIME ), '%H:%i' )
ORDER BY DATE_FORMAT( CAST( section.end_time AS TIME ), '%H:%i' ) ASC LIMIT 1 ORDER BY DATE_FORMAT( CAST( section.end_time AS TIME ), '%H:%i' ) DESC LIMIT 1
</select> </select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment