Browse Source

ckp逻辑修改

master
shenzhouyu 1 month ago
parent
commit
bc1671e3fe
  1. 1
      threecolor-modbus-collector/src/main/java/com/xujie/modbus/entity/Resource.java
  2. 6
      threecolor-modbus-collector/src/main/java/com/xujie/modbus/entity/SfdcTimeHist.java
  3. 50
      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

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

6
threecolor-modbus-collector/src/main/java/com/xujie/modbus/entity/SfdcTimeHist.java

@ -1,8 +1,6 @@
package com.xujie.modbus.entity; package com.xujie.modbus.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
@ -39,10 +37,12 @@ public class SfdcTimeHist {
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@TableField(updateStrategy = FieldStrategy.IGNORED)
private Date tillTime; private Date tillTime;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@TableField(updateStrategy = FieldStrategy.IGNORED)
private Date tillenteredTime; private Date tillenteredTime;
private String tillenteredBy; private String tillenteredBy;

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

@ -184,6 +184,7 @@ public class ModbusCollectServiceImpl
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; Integer failureTime = folderLocation.getFailureTime() != null ? folderLocation.getFailureTime() : 5;
Integer runTime = folderLocation.getRunTime() != null ? folderLocation.getRunTime() : 4;
String cuttingSymbol = folderLocation.getCuttingSymbol(); String cuttingSymbol = folderLocation.getCuttingSymbol();
if (StringUtils.isNotBlank(cuttingSymbol)) { if (StringUtils.isNotBlank(cuttingSymbol)) {
try { try {
@ -237,11 +238,60 @@ public class ModbusCollectServiceImpl
//site+equipmentNo查询前failureTime分钟如果failureTime条都是001就往sfdc_time_hist插入数据先要确认中间表有工单号 //site+equipmentNo查询前failureTime分钟如果failureTime条都是001就往sfdc_time_hist插入数据先要确认中间表有工单号
//获取前几条数据默认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<ResourceScheduled> resourceScheduleds = resourceScheduledMapper.selectResourceScheduledAndResourceList(folderLocation.getSite(), folderLocation.getResourceId()); List<ResourceScheduled> resourceScheduleds = resourceScheduledMapper.selectResourceScheduledAndResourceList(folderLocation.getSite(), folderLocation.getResourceId());
//不为空并大于0往mes表插数据 //不为空并大于0往mes表插数据
if (resourceScheduleds != null && resourceScheduleds.size()>0){ if (resourceScheduleds != null && resourceScheduleds.size()>0){
for(ResourceScheduled resourceScheduled:resourceScheduleds){ for(ResourceScheduled resourceScheduled:resourceScheduleds){
//runtime时间未到要去清空
if(!(1 == registerData.get(0) && 0 == registerData.get(1) && 0 == registerData.get(2))){
boolean greenInsertHist = false;
if (colorLampLisByTimeGreen != null && colorLampLisByTimeGreen.size() > 0) {
// 只取最近 failureTime 条记录做判断
for (ThreeColorLamp lamp3 : colorLampLisByTimeGreen) {
boolean isGreen = ("1".equals(lamp3.getGreen())) &&
("0".equals(lamp3.getOrange())) &&
("0".equals(lamp3.getRed()));
if (!isGreen) {
greenInsertHist = true;
break;
}
}
}
boolean isLastGreen = false;
ThreeColorLamp lastGreenColorLamp = threeColorLampMapper.selectThreeColorLastByResourceId(folderLocation.getSite(),resourceScheduled.getResourceId());
if(lastGreenColorLamp != null){
if("1".equals(lastGreenColorLamp.getGreen()) && "0".equals(lastGreenColorLamp.getOrange())&& "0".equals(lastGreenColorLamp.getRed())){
isLastGreen = true;
}
}
if(greenInsertHist && isLastGreen){
SfdcTimeHist sfdcTimeHistByGreen = sfdcTimeHistMapper.selectSfdcTimeHistByNew(folderLocation.getSite(), resourceScheduled.getSeqNo(), "自动停机");
if(sfdcTimeHistByGreen != null){
sfdcTimeHistByGreen.setTillTime(null);
sfdcTimeHistByGreen.setTillenteredTime(null);
sfdcTimeHistByGreen.setCompletedFlag("N");
int i = sfdcTimeHistMapper.updateById(sfdcTimeHistByGreen);
if(i>0){
UpdateWrapper<ResourceScheduled> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("site", folderLocation.getSite());
updateWrapper.eq("resource_id", folderLocation.getResourceId());
updateWrapper.eq("seq_no", sfdcTimeHistByGreen.getSeqNo());
updateWrapper.set("issend", "Y");
updateWrapper.set("sfdcid",sfdcTimeHistByGreen.getId());
resourceScheduledMapper.update(updateWrapper);
logger.info("停机恢复后正常运行时间未到指定时间,sfdcid变为之前的,id:{}",sfdcTimeHistByGreen.getId());
}
}
}
}
logger.info("获取前几条灯数据: {}", colorLampLisByTime); logger.info("获取前几条灯数据: {}", colorLampLisByTime);
// site+equipmentNo 查询前 failureTime 分钟如果 **failureTime 条记录全部为 0,0,1**才插入 sfdc_time_hist // site+equipmentNo 查询前 failureTime 分钟如果 **failureTime 条记录全部为 0,0,1**才插入 sfdc_time_hist
boolean shouldInsertHist = false; boolean shouldInsertHist = false;

Loading…
Cancel
Save