Commit 1f7be484 authored by duanruiming's avatar duanruiming

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

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