diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/schedulejob/MesQmsScrapJob.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/schedulejob/MesQmsScrapJob.java index 33d761b..e48673c 100644 --- a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/schedulejob/MesQmsScrapJob.java +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/schedulejob/MesQmsScrapJob.java @@ -81,7 +81,7 @@ public class MesQmsScrapJob extends BaseMesScheduleJob { List mesPartInspectionList = partInspectionRepository.findByHqlWhere(packBean); if (!CollectionUtils.isEmpty(mesPartInspectionList)) { - qmsScrapService.doQmsScrapByPartInspection(mesPartInspectionList,organizeCode); + qmsScrapService.doQmsScrapByPartInspection(mesPartInspectionList, organizeCode); for (MesPartInspection mesPartInspection : mesPartInspectionList) { mesPartInspection.setSystemSyncStatus(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()); diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/schedulejob/MesQmsSuspiciousJob.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/schedulejob/MesQmsSuspiciousJob.java index d252011..9774280 100644 --- a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/schedulejob/MesQmsSuspiciousJob.java +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/schedulejob/MesQmsSuspiciousJob.java @@ -91,15 +91,24 @@ public class MesQmsSuspiciousJob extends BaseMesScheduleJob { if (!CollectionUtils.isEmpty(mesPartInspectionList)) { //过滤掉已经汇总的 List partInspectionList = new ArrayList<>(); - //排序取未同步的一条最早的 - Map> partMap = mesPartInspectionList.stream().collect(Collectors.groupingBy(p -> p.getSn() + "-" + p.getPartNo())); - for (Map.Entry> stringListEntry : partMap.entrySet()) { + //排序取单件逻辑未同步的一条最新的 + Map> partSnMap = mesPartInspectionList.stream() + .filter(p -> p.getSourceType() == 10) + .collect(Collectors.groupingBy(p -> p.getSn() + "-" + p.getPartNo())); + for (Map.Entry> stringListEntry : partSnMap.entrySet()) { List value = stringListEntry.getValue(); MesPartInspection next = value.stream().sorted(Comparator.comparing(MesPartInspection::getCreateDatetime).reversed()).iterator().next(); partInspectionList.add(next); } - LOGGER.info("MES可疑品汇总 ----- partInspectionList{}",partInspectionList.size()); + //批次逻辑的全部汇总数量 42692 MES:可疑品汇总逻辑更新 + Map> partMap = mesPartInspectionList.stream() + .filter(p -> p.getSourceType() == 20) + .collect(Collectors.groupingBy(MesPartInspection::getPartNo)); + for (Map.Entry> stringListEntry : partMap.entrySet()) { + partInspectionList.addAll(stringListEntry.getValue()); + } + LOGGER.info("MES可疑品汇总 ----- partInspectionList{}", partInspectionList.size()); qmsSuspiciousService.doQmsSuspiciousByPartInspection(partInspectionList, organizeCode); for (MesPartInspection mesPartInspection : mesPartInspectionList) { diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/base/MesQmsScrapService.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/base/MesQmsScrapService.java index 96b7a1c..d39b185 100644 --- a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/base/MesQmsScrapService.java +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/base/MesQmsScrapService.java @@ -29,6 +29,7 @@ import java.util.stream.Collectors; public class MesQmsScrapService extends BaseMesService implements IMesQmsScrapService { @Autowired private MesPartInspectionDetailRepository partInspectionDetailRDao; + @Override protected void setPackQueryBean(MesQmsScrap bean, DdlPackBean packBean) { DdlPreparedPack.getStringLikerPack(bean.getPartNo(), "partNo", packBean); @@ -49,7 +50,7 @@ public class MesQmsScrapService extends BaseMesService implements I String key = stringListEntry.getKey(); List mesPartInspections = stringListEntry.getValue(); MesPartInspection next = mesPartInspections.iterator().next(); - List mesPartInspectionDetails=new ArrayList<>(); + List mesPartInspectionDetails = new ArrayList<>(); for (MesPartInspection mesPartInspection : mesPartInspections) { mesPartInspectionDetails.addAll(idDetailListMap.get(mesPartInspection.getId())); } @@ -67,7 +68,7 @@ public class MesQmsScrapService extends BaseMesService implements I mesQmsScrap.setDefectTypeName(defectTypeName); mesQmsScrap.setReponsibilityId(next.getResponsibleParty()); mesQmsScrap.setNcJudger(next.getModifyUser()); - ConvertBean.serviceModelInitialize(mesQmsScrap,"MesScrapJob"); + ConvertBean.serviceModelInitialize(mesQmsScrap, "MesScrapJob"); baseRDao.insert(mesQmsScrap); } diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/base/MesQmsSuspiciousService.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/base/MesQmsSuspiciousService.java index 40f8c98..86aca2b 100644 --- a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/base/MesQmsSuspiciousService.java +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/base/MesQmsSuspiciousService.java @@ -75,14 +75,26 @@ public class MesQmsSuspiciousService extends BaseMesService im DdlPreparedPack.getStringEqualPack(partInspection.getSn(), "sn", packBeanNew); packBeanNew.setOrderByStr(" order by createDatetime "); MesPartInspection partInspectionDao = partInspectionRepository.getByProperty(packBeanNew); + //检验日期年月日可以根据创建日期截取,批次的不用取最早出现的 String qmsTime = partInspection.getCreateDatetime().substring(0, 13) + ":00:00"; - if (!StringUtil.isEmpty(partInspectionDao)) { + if (!StringUtil.isEmpty(partInspectionDao) && partInspection.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) { qmsTime = partInspectionDao.getCreateDatetime().substring(0, 13) + ":00:00"; } partInspectionNew.setInspectionDate(qmsTime); mesPartInspectionsListTime.add(partInspectionNew); } //根据时间分组发送 + // 批次的: + //A 2024-08-21 08:00 10 + //A 2024-08-21 08:00 10 + //B 2024-08-20 08:00 10 检验日期 2024-08-21 08:00 + //B 2024-08-21 08:00 10 检验日期 2024-08-21 08:00 + //单件的: + //A 2024-08-21 08:00 1 0 0 1 + // + //qms汇总表===== + //A 2024-08-21 08:00 21 0 0 1 + //B 2024-08-21 08:00 20 Map> mesPartInspectionsMap = mesPartInspectionsListTime.stream().collect(Collectors.groupingBy(MesPartInspection::getInspectionDate)); for (Map.Entry> partInspection : mesPartInspectionsMap.entrySet()) { List mesPartInspections = partInspection.getValue(); @@ -143,7 +155,7 @@ public class MesQmsSuspiciousService extends BaseMesService im mesQmsSuspicious.setReworkScrapped(0); mesQmsSuspicious.setPartNo(key); mesQmsSuspicious.setPartName(next.getPartName()); - //缺陷分类,缺陷数量JOSN格式: + //缺陷分类,缺陷数量JOSN格式:【批次&单件数量汇总时需要根据检验时间段合并】 //[{"Defect_Name":"缺陷01","Defect_Qty":1},{"Defect_Name":"缺陷02","Defect_Qty":2}] Map> listDefectMap = mesPartInspectionDetails.stream().collect(Collectors.groupingBy(MesPartInspectionDetail::getDefectTypeName)); List> defectsList = new ArrayList<>();