|
|
|
@ -283,7 +283,7 @@ public class ModbusCollectServiceImpl |
|
|
|
//如果寄存器不为空 |
|
|
|
System.out.println("寄存器数据:"+ registerData); |
|
|
|
logger.info("寄存器数据: {}", registerData); |
|
|
|
//site+equipmentNo查询前failureTime分钟,如果failureTime条都是0,0,1,就往sfdc_time_hist插入数据,先要确认中间表有工单号 |
|
|
|
//site+equipmentNo查询前failureTime分钟内记录,若不存在绿灯1,0,0(100)则往sfdc_time_hist插入;存在100则不插入;先要确认中间表有工单号 |
|
|
|
//获取前几条数据,默认5 |
|
|
|
List<ThreeColorLamp> colorLampLisByTime = threeColorLampMapper.getThreeColorLampLisByTime(folderLocation.getSite(), folderLocation.getResourceId(), failureTime); |
|
|
|
List<ThreeColorLamp> colorLampLisByTimeGreen = threeColorLampMapper.getThreeColorLampLisByTime(folderLocation.getSite(), folderLocation.getResourceId(), runTime); |
|
|
|
@ -371,20 +371,19 @@ public class ModbusCollectServiceImpl |
|
|
|
|
|
|
|
|
|
|
|
logger.info("获取前几条灯数据: {}", colorLampLisByTime); |
|
|
|
// site+equipmentNo 查询前 failureTime 分钟,如果 **failureTime 条记录全部为 0,0,1**,才插入 sfdc_time_hist |
|
|
|
// site+equipmentNo 查询前 failureTime 分钟:查询结果中只要存在绿灯 1,0,0(100) 则不插入 sfdc_time_hist;不存在 100 则插入 |
|
|
|
boolean shouldInsertHist = false; |
|
|
|
if (colorLampLisByTime != null && colorLampLisByTime.size() > 0) { |
|
|
|
// 只取最近 failureTime 条记录做判断 |
|
|
|
shouldInsertHist = true; |
|
|
|
for (ThreeColorLamp lamp3 : colorLampLisByTime) { |
|
|
|
boolean isRed = ("0".equals(lamp3.getGreen())) && |
|
|
|
("0".equals(lamp3.getOrange())) && |
|
|
|
("1".equals(lamp3.getRed())); |
|
|
|
if (!isRed) { |
|
|
|
shouldInsertHist = false; |
|
|
|
break; |
|
|
|
} |
|
|
|
shouldInsertHist = true; |
|
|
|
for (ThreeColorLamp lamp3 : colorLampLisByTime) { |
|
|
|
boolean islampGreen = ("1".equals(lamp3.getGreen())) && |
|
|
|
("0".equals(lamp3.getOrange())) && |
|
|
|
("0".equals(lamp3.getRed())); |
|
|
|
if (islampGreen) { |
|
|
|
shouldInsertHist = false; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (shouldInsertHist){ |
|
|
|
@ -404,7 +403,7 @@ public class ModbusCollectServiceImpl |
|
|
|
sfdcTimeHist.setHistSeqno(histSeqno+1); |
|
|
|
Date currentTime = new Date(); |
|
|
|
Date fiveMinutesAgo = new Date(currentTime.getTime() - failureTime * 60 * 1000); |
|
|
|
/* sfdcTimeHist.setEventTime(fiveMinutesAgo);*/ |
|
|
|
//sfdcTimeHist.setEventTime(fiveMinutesAgo); |
|
|
|
ThreeColorLampDownlog sfdcTimeHistStartTime =threeColorLampDownlogMapper.selectThreeColorLampDownlogStartTime(folderLocation.getSite(), folderLocation.getResourceId(),resourceScheduled.getSeqNo()) ; |
|
|
|
sfdcTimeHist.setEventTime(sfdcTimeHistStartTime.getStartDate() == null?fiveMinutesAgo:sfdcTimeHistStartTime.getStartDate()); |
|
|
|
sfdcTimeHist.setEnteredBy(null); |
|
|
|
@ -461,7 +460,7 @@ public class ModbusCollectServiceImpl |
|
|
|
sfdcTimeHist.setHistSeqno(histSeqno+1); |
|
|
|
Date currentTime = new Date(); |
|
|
|
Date fiveMinutesAgo = new Date(currentTime.getTime() - failureTime * 60 * 1000); |
|
|
|
/* sfdcTimeHist.setEventTime(fiveMinutesAgo);*/ |
|
|
|
//sfdcTimeHist.setEventTime(fiveMinutesAgo); |
|
|
|
ThreeColorLampDownlog sfdcTimeHistStartTime =threeColorLampDownlogMapper.selectThreeColorLampDownlogStartTime(folderLocation.getSite(), folderLocation.getResourceId(),resourceScheduled.getSeqNo()) ; |
|
|
|
sfdcTimeHist.setEventTime(sfdcTimeHistStartTime.getStartDate() == null?fiveMinutesAgo:sfdcTimeHistStartTime.getStartDate()); |
|
|
|
sfdcTimeHist.setEnteredBy(null); |
|
|
|
@ -510,7 +509,7 @@ public class ModbusCollectServiceImpl |
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
// 不满足连续 failureTime 条 0,0,1 的条件时,保持原有行为:将中间表发送状态置为 Y |
|
|
|
// 无灯数据或时间窗口内存在绿灯 1,0,0(100) 时,将中间表发送状态置为 Y |
|
|
|
UpdateWrapper<ResourceScheduled> updateWrapper = new UpdateWrapper<>(); |
|
|
|
updateWrapper.eq("site", folderLocation.getSite()); |
|
|
|
updateWrapper.eq("resource_id", folderLocation.getResourceId()); |
|
|
|
@ -521,7 +520,7 @@ public class ModbusCollectServiceImpl |
|
|
|
} |
|
|
|
|
|
|
|
//011的情况 |
|
|
|
boolean yellowInsertHist = false; |
|
|
|
/*boolean yellowInsertHist = false; |
|
|
|
if (colorLampLisByTime != null && colorLampLisByTime.size() > 0) { |
|
|
|
// 只取最近 failureTime 条记录做判断 |
|
|
|
yellowInsertHist = true; |
|
|
|
@ -553,7 +552,7 @@ public class ModbusCollectServiceImpl |
|
|
|
sfdcTimeHist.setHistSeqno(histSeqno+1); |
|
|
|
Date currentTime = new Date(); |
|
|
|
Date fiveMinutesAgo = new Date(currentTime.getTime() - failureTime * 60 * 1000); |
|
|
|
/* sfdcTimeHist.setEventTime(fiveMinutesAgo);*/ |
|
|
|
//sfdcTimeHist.setEventTime(fiveMinutesAgo); |
|
|
|
ThreeColorLampDownlog sfdcTimeHistStartTime =threeColorLampDownlogMapper.selectThreeColorLampDownlogStartTime(folderLocation.getSite(), folderLocation.getResourceId(),resourceScheduled.getSeqNo()) ; |
|
|
|
sfdcTimeHist.setEventTime(sfdcTimeHistStartTime.getStartDate() == null?fiveMinutesAgo:sfdcTimeHistStartTime.getStartDate()); |
|
|
|
sfdcTimeHist.setEnteredBy(null); |
|
|
|
@ -610,7 +609,7 @@ public class ModbusCollectServiceImpl |
|
|
|
sfdcTimeHist.setHistSeqno(histSeqno+1); |
|
|
|
Date currentTime = new Date(); |
|
|
|
Date fiveMinutesAgo = new Date(currentTime.getTime() - failureTime * 60 * 1000); |
|
|
|
/* sfdcTimeHist.setEventTime(fiveMinutesAgo);*/ |
|
|
|
//sfdcTimeHist.setEventTime(fiveMinutesAgo); |
|
|
|
ThreeColorLampDownlog sfdcTimeHistStartTime =threeColorLampDownlogMapper.selectThreeColorLampDownlogStartTime(folderLocation.getSite(), folderLocation.getResourceId(),resourceScheduled.getSeqNo()) ; |
|
|
|
sfdcTimeHist.setEventTime(sfdcTimeHistStartTime.getStartDate() == null?fiveMinutesAgo:sfdcTimeHistStartTime.getStartDate()); |
|
|
|
sfdcTimeHist.setEnteredBy(null); |
|
|
|
@ -667,10 +666,10 @@ public class ModbusCollectServiceImpl |
|
|
|
updateWrapper.set("issend", "Y"); |
|
|
|
resourceScheduledMapper.update(updateWrapper); |
|
|
|
|
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
//000的情况 |
|
|
|
boolean whiteInsertHist = false; |
|
|
|
/*boolean whiteInsertHist = false; |
|
|
|
if (colorLampLisByTime != null && colorLampLisByTime.size() > 0) { |
|
|
|
// 只取最近 failureTime 条记录做判断 |
|
|
|
whiteInsertHist = true; |
|
|
|
@ -702,7 +701,7 @@ public class ModbusCollectServiceImpl |
|
|
|
sfdcTimeHist.setHistSeqno(histSeqno+1); |
|
|
|
Date currentTime = new Date(); |
|
|
|
Date fiveMinutesAgo = new Date(currentTime.getTime() - failureTime * 60 * 1000); |
|
|
|
/* sfdcTimeHist.setEventTime(fiveMinutesAgo);*/ |
|
|
|
//sfdcTimeHist.setEventTime(fiveMinutesAgo); |
|
|
|
ThreeColorLampDownlog sfdcTimeHistStartTime =threeColorLampDownlogMapper.selectThreeColorLampDownlogStartTime(folderLocation.getSite(), folderLocation.getResourceId(),resourceScheduled.getSeqNo()) ; |
|
|
|
sfdcTimeHist.setEventTime(sfdcTimeHistStartTime.getStartDate() == null?fiveMinutesAgo:sfdcTimeHistStartTime.getStartDate()); |
|
|
|
sfdcTimeHist.setEnteredBy(null); |
|
|
|
@ -759,7 +758,7 @@ public class ModbusCollectServiceImpl |
|
|
|
sfdcTimeHist.setHistSeqno(histSeqno+1); |
|
|
|
Date currentTime = new Date(); |
|
|
|
Date fiveMinutesAgo = new Date(currentTime.getTime() - failureTime * 60 * 1000); |
|
|
|
/* sfdcTimeHist.setEventTime(fiveMinutesAgo);*/ |
|
|
|
// sfdcTimeHist.setEventTime(fiveMinutesAgo); |
|
|
|
ThreeColorLampDownlog sfdcTimeHistStartTime =threeColorLampDownlogMapper.selectThreeColorLampDownlogStartTime(folderLocation.getSite(), folderLocation.getResourceId(),resourceScheduled.getSeqNo()) ; |
|
|
|
sfdcTimeHist.setEventTime(sfdcTimeHistStartTime.getStartDate() == null?fiveMinutesAgo:sfdcTimeHistStartTime.getStartDate()); |
|
|
|
sfdcTimeHist.setEnteredBy(null); |
|
|
|
@ -808,14 +807,13 @@ public class ModbusCollectServiceImpl |
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
// 不满足连续 failureTime 条 0,0,0 的条件时,保持原有行为:将中间表发送状态置为 Y |
|
|
|
UpdateWrapper<ResourceScheduled> updateWrapper = new UpdateWrapper<>(); |
|
|
|
updateWrapper.eq("site", folderLocation.getSite()); |
|
|
|
updateWrapper.eq("resource_id", folderLocation.getResourceId()); |
|
|
|
updateWrapper.eq("seq_no", resourceScheduled.getSeqNo()); |
|
|
|
updateWrapper.set("issend", "Y"); |
|
|
|
resourceScheduledMapper.update(updateWrapper); |
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|