Browse Source

三色灯停机修改

master
shenzhouyu 2 months ago
parent
commit
94858f0f73
  1. 1
      threecolor-modbus-collector/src/main/java/com/xujie/modbus/entity/Resource.java
  2. 10
      threecolor-modbus-collector/src/main/java/com/xujie/modbus/service/impl/ModbusCollectServiceImpl.java

1
threecolor-modbus-collector/src/main/java/com/xujie/modbus/entity/Resource.java

@ -30,4 +30,5 @@ public class Resource {
private Integer registerPort; private Integer registerPort;
private Integer registerNum; private Integer registerNum;
private String cuttingSymbol; private String cuttingSymbol;
private Integer failureTime;
} }

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

@ -183,6 +183,7 @@ public class ModbusCollectServiceImpl
int port = folderLocation.getRegisterPort() != null ? folderLocation.getRegisterPort() : 502; int port = folderLocation.getRegisterPort() != null ? folderLocation.getRegisterPort() : 502;
int quantity = folderLocation.getRegisterNum() != null ? folderLocation.getRegisterNum() : 3; int quantity = folderLocation.getRegisterNum() != null ? folderLocation.getRegisterNum() : 3;
int offset = 0x00; int offset = 0x00;
Integer failureTime = folderLocation.getFailureTime() != null ? folderLocation.getFailureTime() : 5;
String cuttingSymbol = folderLocation.getCuttingSymbol(); String cuttingSymbol = folderLocation.getCuttingSymbol();
if (StringUtils.isNotBlank(cuttingSymbol)) { if (StringUtils.isNotBlank(cuttingSymbol)) {
try { try {
@ -234,7 +235,7 @@ public class ModbusCollectServiceImpl
System.out.println("寄存器数据:"+ registerData); System.out.println("寄存器数据:"+ registerData);
logger.info("寄存器数据: {}", registerData); logger.info("寄存器数据: {}", registerData);
//site+equipmentNo查询前5分钟如果5条都是001就往sfdc_time_hist插入数据先要确认中间表有工单号 //site+equipmentNo查询前5分钟如果5条都是001就往sfdc_time_hist插入数据先要确认中间表有工单号
List<ThreeColorLamp> colorLampLisByTime = threeColorLampMapper.getThreeColorLampLisByTime(folderLocation.getSite(), folderLocation.getResourceId(), 5);
List<ThreeColorLamp> colorLampLisByTime = threeColorLampMapper.getThreeColorLampLisByTime(folderLocation.getSite(), folderLocation.getResourceId(), failureTime);
QueryWrapper<ResourceScheduled> queryWrapper = new QueryWrapper<>(); QueryWrapper<ResourceScheduled> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("site", folderLocation.getSite()); queryWrapper.eq("site", folderLocation.getSite());
queryWrapper.eq("resource_id", folderLocation.getResourceId()); queryWrapper.eq("resource_id", folderLocation.getResourceId());
@ -280,7 +281,7 @@ public class ModbusCollectServiceImpl
sfdcTimeHist.setSeqNo(soscheduled.getSeqno()); sfdcTimeHist.setSeqNo(soscheduled.getSeqno());
sfdcTimeHist.setHistSeqno(histSeqno+1); sfdcTimeHist.setHistSeqno(histSeqno+1);
Date currentTime = new Date(); Date currentTime = new Date();
Date fiveMinutesAgo = new Date(currentTime.getTime() - 5 * 60 * 1000);
Date fiveMinutesAgo = new Date(currentTime.getTime() - failureTime * 60 * 1000);
sfdcTimeHist.setEventTime(fiveMinutesAgo); sfdcTimeHist.setEventTime(fiveMinutesAgo);
sfdcTimeHist.setEnteredBy(null); sfdcTimeHist.setEnteredBy(null);
sfdcTimeHist.setEventDesc(null); sfdcTimeHist.setEventDesc(null);
@ -334,6 +335,9 @@ public class ModbusCollectServiceImpl
if (resourceScheduleds != null && resourceScheduleds.size()>0){ if (resourceScheduleds != null && resourceScheduleds.size()>0){
for(ResourceScheduled resourceScheduled:resourceScheduleds){ for(ResourceScheduled resourceScheduled:resourceScheduleds){
ThreeColorLamp colorLamp = threeColorLampMapper.selectThreeColorLastByResourceId(folderLocation.getSite(),resourceScheduled.getResourceId()); ThreeColorLamp colorLamp = threeColorLampMapper.selectThreeColorLastByResourceId(folderLocation.getSite(),resourceScheduled.getResourceId());
if(colorLamp == null){
break;
}
ThreeColorLampDownlog downlogChangeLast = threeColorLampDownlogMapper.selectDownlogLast(folderLocation.getSite(),folderLocation.getResourceId()); ThreeColorLampDownlog downlogChangeLast = threeColorLampDownlogMapper.selectDownlogLast(folderLocation.getSite(),folderLocation.getResourceId());
if(!mapValueToString(registerData.get(0)).equals(colorLamp.getGreen()) || !mapValueToString(registerData.get(1)).equals(colorLamp.getOrange())|| !mapValueToString(registerData.get(2)).equals(colorLamp.getRed())){ if(!mapValueToString(registerData.get(0)).equals(colorLamp.getGreen()) || !mapValueToString(registerData.get(1)).equals(colorLamp.getOrange())|| !mapValueToString(registerData.get(2)).equals(colorLamp.getRed())){
if(downlogChangeLast != null){ if(downlogChangeLast != null){
@ -418,6 +422,7 @@ public class ModbusCollectServiceImpl
}else{ }else{
ThreeColorLamp colorLamp = threeColorLampMapper.selectThreeColorLastByResourceId(folderLocation.getSite(),folderLocation.getResourceId()); ThreeColorLamp colorLamp = threeColorLampMapper.selectThreeColorLastByResourceId(folderLocation.getSite(),folderLocation.getResourceId());
if(colorLamp != null){
ThreeColorLampDownlog downlogChangeLast = threeColorLampDownlogMapper.selectDownlogLast(folderLocation.getSite(),folderLocation.getResourceId()); ThreeColorLampDownlog downlogChangeLast = threeColorLampDownlogMapper.selectDownlogLast(folderLocation.getSite(),folderLocation.getResourceId());
if(!mapValueToString(registerData.get(0)).equals(colorLamp.getGreen()) || !mapValueToString(registerData.get(1)).equals(colorLamp.getOrange())|| !mapValueToString(registerData.get(2)).equals(colorLamp.getRed())){ if(!mapValueToString(registerData.get(0)).equals(colorLamp.getGreen()) || !mapValueToString(registerData.get(1)).equals(colorLamp.getOrange())|| !mapValueToString(registerData.get(2)).equals(colorLamp.getRed())){
if(downlogChangeLast != null){ if(downlogChangeLast != null){
@ -451,6 +456,7 @@ public class ModbusCollectServiceImpl
} }
} }
} }
}
ThreeColorLamp lamp = new ThreeColorLamp(); ThreeColorLamp lamp = new ThreeColorLamp();
lamp.setSite(folderLocation.getSite()); lamp.setSite(folderLocation.getSite());
lamp.setEquipmentNo(folderLocation.getResourceId()); lamp.setEquipmentNo(folderLocation.getResourceId());

Loading…
Cancel
Save