diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/base/MesPartTransferDetailService.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/base/MesPartTransferDetailService.java index 457af13..6bb94ad 100644 --- a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/base/MesPartTransferDetailService.java +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/base/MesPartTransferDetailService.java @@ -5,15 +5,28 @@ import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum; import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; +import cn.estsh.i3plus.pojo.base.util.StringUtil; +import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentSpotCheck; +import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentSpotCheckPart; +import cn.estsh.i3plus.pojo.mes.bean.MesPartTransfer; import cn.estsh.i3plus.pojo.mes.bean.MesPartTransferDetail; +import cn.estsh.i3plus.pojo.mes.repository.MesPartTransferDetailRepository; +import cn.estsh.i3plus.pojo.mes.repository.MesPartTransferRepository; import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder; import cn.estsh.impp.framework.boot.util.ValidatorBean; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + @Service @Slf4j public class MesPartTransferDetailService extends BaseMesService implements IMesPartTransferDetailService { + + @Autowired + private MesPartTransferRepository partTransferRepository; + protected void setPackQueryBean(MesPartTransferDetail bean, DdlPackBean packBean) { DdlPreparedPack.getNumEqualPack(bean.getPid(),"pid",packBean); DdlPreparedPack.getStringEqualPack(bean.getCustCode(),"custCode",packBean); @@ -79,4 +92,36 @@ public class MesPartTransferDetailService extends BaseMesService validateReturnImport(List beanList) { + + for (MesPartTransferDetail item : beanList) { + // 数据校验 + if(StringUtil.isEmpty(item.getPid())){ + ValidatorBean.checkNotNull(item.getCustCode(), "客户代码不能为空"); + ValidatorBean.checkNotNull(item.getCustOrganizeCode(), "客户工厂代码不能为空"); + ValidatorBean.checkNotNull(item.getMessageNo(), "信息点代码不能为空"); + + + + DdlPackBean seriesPackBean = DdlPackBean.getDdlPackBean(item.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(item.getCustCode(), "custCode", seriesPackBean); + DdlPreparedPack.getStringEqualPack(item.getCustOrganizeCode(), "custOrganizeCode", seriesPackBean); + DdlPreparedPack.getStringEqualPack(item.getMessageNo(), "messageNo", seriesPackBean); + + + MesPartTransfer itemFlg = partTransferRepository.getByProperty(seriesPackBean); + if (StringUtil.isEmpty(itemFlg)) { + throw ImppExceptionBuilder.newInstance() + .setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode()) + .setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode()) + .setErrorDetail("【%s】客户代码,【%s】客户工厂代码,【%s】信息点代码请检查数据", item.getCustCode(),item.getCustOrganizeCode(), item.getMessageNo()) + .build(); + } + item.setPid(itemFlg.getId()); + } + } + return beanList; + } } diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/base/MesProductionRecordServiceImpl.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/base/MesProductionRecordServiceImpl.java index e6d74e7..aa2184f 100644 --- a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/base/MesProductionRecordServiceImpl.java +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/base/MesProductionRecordServiceImpl.java @@ -736,10 +736,10 @@ public class MesProductionRecordServiceImpl extends BaseMesService finishList = Stream.of("Product_finish","PART_OK","Part_Finish","Product_OK").collect(Collectors.toList()); List finishList = Stream.of("Product_finish","Part_Finish").collect(Collectors.toList()); String preReason = ""; + int errorCount = 0; for (MesProductRecordLog recordLog : recordLogs) { - int errorCount = 0; - if (recordLog.getId() ==1838536264741601280l) { + if (recordLog.getId() ==1846373460483817472l) { int a = 1; } if (Objects.equal(recordLog.getType(), "monitor") && recordLog.getMessage().contains("客户端下线")) { @@ -748,13 +748,24 @@ public class MesProductionRecordServiceImpl extends BaseMesService 0) { - reason += String.format(offlineReason, startTime, endTime, 1 + ""); + + if (errorCount > 0) { + reason += String.format(offlineReason, startTime, endTime, errorCount + ""); preReason = ""; result = 0; errorCount = 0; + } else { + if (result > 0) { + reason += String.format(offlineReason, startTime, endTime, 1 + ""); + preReason = ""; + result = 0; + errorCount = 0; + } } //result = 0; continue; @@ -772,14 +783,15 @@ public class MesProductionRecordServiceImpl extends BaseMesService 0) { - reason += preReason; + //reason += preReason; preReason = String.format(offlineReason, endTime, recordLog.getCreateDatetime(), errorCount + ""); endTime = recordLog.getCreateDatetime(); continue; - } else { + } + /*else { endTime = recordLog.getCreateDatetime(); preReason = String.format(offlineReason, startTime,endTime, errorCount + ""); - } + }*/ result++; continue ; } @@ -887,10 +899,10 @@ public class MesProductionRecordServiceImpl extends BaseMesService finishList = Stream.of("Product_finish","PART_OK","Part_Finish","Product_OK").collect(Collectors.toList()); List finishList = Stream.of("Product_finish","Part_Finish").collect(Collectors.toList()); String preReason = ""; + int errorCount = 0; for (MesProductRecordLog recordLog : recordLogs) { - int errorCount = 0; - if (recordLog.getId() ==1838551951325315072l) { + if (recordLog.getId() ==1296257140498948096l) { int a = 1; } if (Objects.equal(recordLog.getType(), "monitor") && recordLog.getMessage().contains("客户端下线")) { @@ -928,18 +940,28 @@ public class MesProductionRecordServiceImpl extends BaseMesService 0) { + //reason += preReason; + preReason = String.format(offlineReason, endTime, recordLog.getCreateDatetime(), errorCount + ""); + endTime = recordLog.getCreateDatetime(); + continue; + } + /*if (result > 0) { reason += String.format(offlineReason, startTime, startTime, errorCount + ""); continue; } else { endTime = recordLog.getCreateDatetime(); preReason = String.format(offlineReason, startTime,endTime, errorCount + ""); - } + }*/ result++; continue ; } if (Objects.equal(recordLog.getCategoryLevelTwo(), "BYPASS") && Objects.equal(recordLog.getEquipVariableValue(), "True")) { + if (offlineFlag) { + continue; + } // 如果有finish然后遇到bypass 需要预处理 if (result > 0) { reason += String.format(reasonBypass,startTime, 1 +""); @@ -953,6 +975,9 @@ public class MesProductionRecordServiceImpl extends BaseMesService