From e697b2bbd3213970692d121632c894c8e7b0e4e2 Mon Sep 17 00:00:00 2001 From: shenzhouyu Date: Tue, 12 May 2026 17:43:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=AA=E8=A6=81=E9=9D=9E?= =?UTF-8?q?=E7=BB=BF=E7=81=AF=E5=B0=B1=E6=8F=92=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/ModbusCollectServiceImpl.java | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/threecolor-modbus-collector/src/main/java/com/xujie/modbus/service/impl/ModbusCollectServiceImpl.java b/threecolor-modbus-collector/src/main/java/com/xujie/modbus/service/impl/ModbusCollectServiceImpl.java index 664c64e..d06eae8 100644 --- a/threecolor-modbus-collector/src/main/java/com/xujie/modbus/service/impl/ModbusCollectServiceImpl.java +++ b/threecolor-modbus-collector/src/main/java/com/xujie/modbus/service/impl/ModbusCollectServiceImpl.java @@ -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 colorLampLisByTime = threeColorLampMapper.getThreeColorLampLisByTime(folderLocation.getSite(), folderLocation.getResourceId(), failureTime); List 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 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 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); - } + }*/ }