Browse Source

修改只要非绿灯就插入

master
shenzhouyu 4 weeks ago
parent
commit
e697b2bbd3
  1. 34
      threecolor-modbus-collector/src/main/java/com/xujie/modbus/service/impl/ModbusCollectServiceImpl.java

34
threecolor-modbus-collector/src/main/java/com/xujie/modbus/service/impl/ModbusCollectServiceImpl.java

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

Loading…
Cancel
Save