Commit 1f7be484 authored by duanruiming's avatar duanruiming

[add] 信控控制指令日志;排查锁定问题

parent 018866b7
...@@ -33,6 +33,7 @@ import org.springframework.stereotype.Service; ...@@ -33,6 +33,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -235,9 +236,9 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -235,9 +236,9 @@ public class ControlCommandServiceImpl implements ControlCommandService {
// boolean isOk = true; // boolean isOk = true;
if (isOk) { if (isOk) {
return jsonViewObject.fail("第 "+i+1+" 次相位步进失败,取消步进成功,路口号: " + code); return jsonViewObject.fail("第 "+ (i+1) +" 次相位步进失败,取消步进成功,路口号: " + code);
} else { } else {
return jsonViewObject.fail("第 "+i+1+" 次相位步进失败,取消步进失败,路口号: " + code); return jsonViewObject.fail("第 "+ (i+1) +" 次相位步进失败,取消步进失败,路口号: " + code);
} }
} }
//停顿10ms //停顿10ms
...@@ -252,9 +253,9 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -252,9 +253,9 @@ public class ControlCommandServiceImpl implements ControlCommandService {
// boolean isOk = true; // boolean isOk = true;
if (isOk) { if (isOk) {
return jsonViewObject.fail("第 "+i+1+" 次相位步进失败,但取消步进成功,路口号: " + code); return jsonViewObject.fail("第 "+(i+1)+" 次相位步进失败,但取消步进成功,路口号: " + code);
} else { } else {
return jsonViewObject.fail("第 "+i+1+" 次相位步进失败,取消步进失败,路口号: " + code); return jsonViewObject.fail("第 "+(i+1)+" 次相位步进失败,取消步进失败,路口号: " + code);
} }
} }
......
...@@ -262,8 +262,9 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy ...@@ -262,8 +262,9 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy
@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;
try {
String now = LocalDateTimeUtil.formatNow(LocalDateTimeUtil.TIMEFORMATTER);
try { try {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(crossId); String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(crossId);
if (StringUtils.equals(BasicEnum.ManufacturerEnum.HK.getCode(), manufacturerIdCode)) { if (StringUtils.equals(BasicEnum.ManufacturerEnum.HK.getCode(), manufacturerIdCode)) {
...@@ -280,6 +281,10 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy ...@@ -280,6 +281,10 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy
jsonObject.put("stepNum",stepNum); jsonObject.put("stepNum",stepNum);
//插入命令操作日志 //插入命令操作日志
insertCommandLog(now,jsonViewObject, jsonObject,1); insertCommandLog(now,jsonViewObject, jsonObject,1);
} catch (Exception e) {
log.error("stepControlStrategy步进控制远程服务调用异常:", e);
jsonViewObject = JsonViewObject.newInstance().fail("步进控制远程服务调用异常");
}
return jsonViewObject; return jsonViewObject;
} }
...@@ -290,7 +295,8 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy ...@@ -290,7 +295,8 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy
* @Param jsonObject 参数 * @Param jsonObject 参数
* @return void * @return void
**/ **/
public void insertCommandLog(String queryTime,JsonViewObject jsonViewObject, JSONObject jsonObject,int commandType){ public void insertCommandLog(String queryTime,JsonViewObject jsonViewObject, JSONObject jsonObject,int commandType) throws Exception{
try {
SignalCommandLogPO signalCommandLogPO = new SignalCommandLogPO(); SignalCommandLogPO signalCommandLogPO = new SignalCommandLogPO();
signalCommandLogPO.setCrossId(jsonObject.getString("crossId")); signalCommandLogPO.setCrossId(jsonObject.getString("crossId"));
signalCommandLogPO.setDataInfo(jsonObject.toJSONString()); signalCommandLogPO.setDataInfo(jsonObject.toJSONString());
...@@ -300,7 +306,7 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy ...@@ -300,7 +306,7 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String ip = IpAddressUtil.getIpAddress(request); String ip = IpAddressUtil.getIpAddress(request);
signalCommandLogPO.setIp(ip); signalCommandLogPO.setIp(ip);
log.info("服务器请求返回 信息jsonViewObject:{}",jsonViewObject); log.info("insertCommandLog服务器请求返回 信息jsonViewObject:{}",jsonViewObject);
int commandResult = 0; int commandResult = 0;
if (code == 200){ if (code == 200){
commandResult = 1; commandResult = 1;
...@@ -317,8 +323,6 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy ...@@ -317,8 +323,6 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy
LightsStatusVO2 lightsStatusVO2 = list.get(0); LightsStatusVO2 lightsStatusVO2 = list.get(0);
String runMode = lightsStatusVO2.getRunMode(); String runMode = lightsStatusVO2.getRunMode();
String lampTime = lightsStatusVO2.getTimeStamp(); String lampTime = lightsStatusVO2.getTimeStamp();
//时间转换
// lampTime = LocalDateTimeUtil.formatTimeStamp(Long.valueOf(lampTime), LocalDateTimeUtil.TIMEFORMATTER);
signalCommandLogPO.setRunMode(runMode); signalCommandLogPO.setRunMode(runMode);
signalCommandLogPO.setLampTime(lampTime); signalCommandLogPO.setLampTime(lampTime);
} }
...@@ -344,7 +348,7 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy ...@@ -344,7 +348,7 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy
}else { }else {
log.info("定时任务 插入t_signal_command失败,crossId = {},commandType = {},time = {},insert = {}", jsonObject.getString("crossId"), commandType, LocalDateTimeUtil.formatNow(LocalDateTimeUtil.TIMEFORMATTER),insert1); log.info("定时任务 插入t_signal_command失败,crossId = {},commandType = {},time = {},insert = {}", jsonObject.getString("crossId"), commandType, LocalDateTimeUtil.formatNow(LocalDateTimeUtil.TIMEFORMATTER),insert1);
} }
}else { } else {
//更新 //更新
SignalCommandPO signalCommandPO = signalCommandPOS.get(0); SignalCommandPO signalCommandPO = signalCommandPOS.get(0);
signalCommandPO.setDataInfo(jsonObject.toJSONString()); signalCommandPO.setDataInfo(jsonObject.toJSONString());
...@@ -362,6 +366,14 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy ...@@ -362,6 +366,14 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy
} }
} }
} }
LambdaQueryWrapper<SignalCommandPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(SignalCommandPO::getCrossId,jsonObject.getString("crossId"));
List<SignalCommandPO> signalCommandPOS = signalCommandPOMapper.selectList(lambdaQueryWrapper);
log.error("更新t_signal_command成功,数据库中查询结果集:{}", signalCommandPOS);
} catch (Exception e) {
log.error("insertCommandLog命令日志插入失败:", e);
throw new RuntimeException(e);
}
} }
@Override @Override
......
...@@ -52,10 +52,11 @@ public class CommandFaildTask { ...@@ -52,10 +52,11 @@ public class CommandFaildTask {
@Scheduled(cron = "0/5 * * * * ?") @Scheduled(cron = "0/5 * * * * ?")
public void commandFaildTask() throws Exception { public void commandFaildTask() throws Exception {
try {
LambdaQueryWrapper<SignalCommandPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SignalCommandPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(SignalCommandPO::getCommandResult, 2); lambdaQueryWrapper.eq(SignalCommandPO::getCommandResult, 2);
List<SignalCommandPO> crossInfoPOList = signalCommandPOMapper.selectList(lambdaQueryWrapper); List<SignalCommandPO> crossInfoPOList = signalCommandPOMapper.selectList(lambdaQueryWrapper);
log.info("定时任务恢复控制指令,需要执行恢复路口集合crossInfoPOList = {}", crossInfoPOList); log.info("定时任务恢复控制指令,需要执行恢复路口集合size:{}, crossInfoPOList = {}", crossInfoPOList.size(), crossInfoPOList);
if (ObjectUtil.isNotEmpty(crossInfoPOList)) { if (ObjectUtil.isNotEmpty(crossInfoPOList)) {
for (SignalCommandPO signalCommandPO : crossInfoPOList) { for (SignalCommandPO signalCommandPO : crossInfoPOList) {
String crossId = signalCommandPO.getCrossId(); String crossId = signalCommandPO.getCrossId();
...@@ -70,8 +71,13 @@ public class CommandFaildTask { ...@@ -70,8 +71,13 @@ public class CommandFaildTask {
handlerCommand(crossId, commandType, updateCount); handlerCommand(crossId, commandType, updateCount);
} catch (Exception e) { } catch (Exception e) {
log.error("定时任务自动恢复报错,crossId={},commandType={},updateCount={}", crossId, commandType, updateCount); log.error("定时任务自动恢复报错,crossId={},commandType={},updateCount={}", crossId, commandType, updateCount);
throw new Exception(e);
}
} }
} }
} catch (Exception e) {
log.error("commandFaildTask定时任务执行异常:", e);
throw new RuntimeException(e);
} }
} }
...@@ -254,6 +260,8 @@ public class CommandFaildTask { ...@@ -254,6 +260,8 @@ public class CommandFaildTask {
}else { }else {
log.info("定时任务 更新t_signal_command失败,crossId = {},commandType = {},time = {},update = {}", jsonObject.getString("crossId"), commandType, LocalDateTimeUtil.formatNow(LocalDateTimeUtil.TIMEFORMATTER),update); log.info("定时任务 更新t_signal_command失败,crossId = {},commandType = {},time = {},update = {}", jsonObject.getString("crossId"), commandType, LocalDateTimeUtil.formatNow(LocalDateTimeUtil.TIMEFORMATTER),update);
} }
List<SignalCommandPO> signalCommandPOS = signalCommandPOMapper.selectList(lambdaQueryWrapper);
log.error("定时任务 更新t_signal_command成功,数据库中查询结果集:{}", signalCommandPOS);
} }
} }
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