Commit a73368ab authored by duanruiming's avatar duanruiming

[update] 优化时间告警状态同步任务

parent 7bc7adc0
......@@ -84,28 +84,6 @@ public class CommonEventWarnTask {
private JsonViewObject getSignalWarnData() {
List<CommonEventAlarmOutVo> results = new ArrayList<>();
// if (true) {
// CommonEventAlarmOutVo commonEventAlarmOutVo = new CommonEventAlarmOutVo();
// commonEventAlarmOutVo.setEventType(3);
// commonEventAlarmOutVo.setEventId("14Q3709IOR0");
// commonEventAlarmOutVo.setEventName("相融路与蠡太路交叉口");
// commonEventAlarmOutVo.setStatus("3");
// commonEventAlarmOutVo.setCoordinate("120.630807,31.422317");
//
// CommonEventAlarmOutVo commonEventAlarmOutVo1 = new CommonEventAlarmOutVo();
// commonEventAlarmOutVo1.setEventType(3);
// commonEventAlarmOutVo1.setEventId("8");
// commonEventAlarmOutVo1.setEventName("青龙港路与云集街交叉口");
// commonEventAlarmOutVo1.setStatus("3");
// commonEventAlarmOutVo1.setCoordinate("120.640305,31.418544");
// results.add(commonEventAlarmOutVo);
// LocalDateTime now = LocalDateTime.now();
// JsonViewObject jsonViewObject = JsonViewObject.newInstance();
// jsonViewObject.setTimestamp(now.toInstant(ZoneOffset.of("+8")).toEpochMilli());
// jsonViewObject.setContent(results);
// return jsonViewObject;
// }
JsonViewObject jsonViewObject = utcFeignClients.runningStatusAlarm();
if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) {
return jsonViewObject.fail("信号机告警UTC服务调用异常!");
......@@ -135,8 +113,8 @@ public class CommonEventWarnTask {
CommonEventAlarmOutVo commonEventAlarmOutVo = new CommonEventAlarmOutVo();
commonEventAlarmOutVo.setEventType(3);
commonEventAlarmOutVo.setEventId(signalId);
commonEventAlarmOutVo.setEventName("信号机故障");// todo 信号机厂商
commonEventAlarmOutVo.setEventDesc("信号机故障");
commonEventAlarmOutVo.setEventName("信号机告警");
commonEventAlarmOutVo.setEventDesc("信号机告警");
commonEventAlarmOutVo.setStatus(String.valueOf(currentFaultType));
commonEventAlarmOutVo.setStartTime(formatNow);
commonEventAlarmOutVo.setCoordinate(coordinate);
......
......@@ -18,6 +18,7 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
......@@ -54,15 +55,16 @@ public class SignalStatusTask {
// 更新数据库状态
LambdaQueryWrapper<TDeviceStatusInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
if (StringUtils.isNotEmpty(signalId)) {
lambdaQueryWrapper.eq(TDeviceStatusInfo::getCode, signalId);
if (StringUtils.isNotEmpty(crossId)) {
lambdaQueryWrapper.eq(TDeviceStatusInfo::getCode, crossId);
TDeviceStatusInfo tDeviceStatusInfo = tDeviceStatusMapper.selectOne(lambdaQueryWrapper);
if (isExucuteUpdate(currentSignalStatus, currentFaultType, tDeviceStatusInfo)) {
tDeviceStatusInfo.setStatus(currentSignalStatus);
tDeviceStatusInfo.setFaultType(currentFaultType);
tDeviceStatusInfo.setGmtCreate(new Date()); // 实时数据,创建和修改时间一致
tDeviceStatusMapper.updateById(tDeviceStatusInfo);
insertDeviceStatusLog(signalStatusVO, crossId, currentSignalStatus, currentFaultType);
}
insertDeviceStatusLog(signalStatusVO, crossId, currentSignalStatus, currentFaultType);
}
insertControlHist(signalStatusVO);
});
......@@ -101,6 +103,7 @@ public class SignalStatusTask {
if (Objects.nonNull(tDeviceStatusLogInfoDB) || tDeviceStatusLogInfoDB.getFaultType() != 0 && currentFaultType == 0) {
tDeviceStatusLogInfoDB.setStatus(currentSignalStatus);
tDeviceStatusLogInfoDB.setFaultType(100);
tDeviceStatusLogInfoDB.setGmtCreate(new Date());
tDeviceStatusLogInfoDB.setId(null);
tDeviceStatusLogMapper.insert(tDeviceStatusLogInfoDB);
} else {
......@@ -110,6 +113,7 @@ public class SignalStatusTask {
tDeviceStatusLog.setType(1);
tDeviceStatusLog.setStatus(signalStatusVO.getStatus());
tDeviceStatusLog.setFaultType(currentFaultType);
tDeviceStatusLog.setGmtCreate(new Date());
tDeviceStatusLog.setId(null);
tDeviceStatusLogMapper.insert(tDeviceStatusLog);
}
......
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