From a19b5b43b25a9f1d95ae2bf3d7073ee174a8cb8c Mon Sep 17 00:00:00 2001 From: "xiangwei.zhang" <752558143@qq.com> Date: Mon, 26 May 2025 21:28:24 +0800 Subject: [PATCH 1/3] =?UTF-8?q?47023=20PCN:=20NC=E6=8A=A5=E5=BA=9F?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E7=9B=B8=E5=85=B3=E4=BC=98=E5=8C=96=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E6=96=87=E6=A1=A3[DM202505140012]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mes/pcn/api/busi/IMesNcProcessingService.java | 2 + .../ext/mes/pcn/api/busi/IMesQmsScrapService.java | 30 +++ .../controller/busi/MesNcProcessingController.java | 15 ++ .../serviceimpl/base/MesReworkTaskServiceImpl.java | 6 + .../serviceimpl/busi/MesNcProcessingService.java | 99 ++++++++++ .../serviceimpl/busi/MesQmsScrapService.java | 210 +++++++++++++++++++++ .../mes/pcn/pojo/model/MesPartInspectionModel.java | 15 ++ 7 files changed, 377 insertions(+) create mode 100644 modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesQmsScrapService.java create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesQmsScrapService.java create mode 100644 modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesPartInspectionModel.java diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesNcProcessingService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesNcProcessingService.java index 137f32e..196b221 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesNcProcessingService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesNcProcessingService.java @@ -37,4 +37,6 @@ public interface IMesNcProcessingService { List queryPartInspectionCreateUser(String organizeCode); + void syncQmsScrap(String organizeCode); + } diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesQmsScrapService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesQmsScrapService.java new file mode 100644 index 0000000..2c4be84 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesQmsScrapService.java @@ -0,0 +1,30 @@ +package cn.estsh.i3plus.ext.mes.pcn.api.busi; + +import cn.estsh.i3plus.pojo.mes.bean.MesQmsScrap; +import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspection; +import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspectionPerson; + +import java.util.List; + +/** + * @Description :MES_QMS报废品汇总 + * @Reference : + * @Author : gsz + * @CreateDate 2024/7/3 10:28 + * @Modify: + **/ +public interface IMesQmsScrapService { + /** + * QMS报废品汇总 + * @param mesPartInspectionList + * @param organizeCode + */ + void doQmsScrapByPartInspectionNew(List mesPartInspectionList, List mesPartInspectionPersonList, String organizeCode); + /** + * QMS报废品汇总 + * @param mesPartInspectionList + * @param organizeCode + */ + void doQmsScrapByPartInspection(List mesPartInspectionList, String organizeCode); +} + diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesNcProcessingController.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesNcProcessingController.java index ba014c1..2f675c5 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesNcProcessingController.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesNcProcessingController.java @@ -155,4 +155,19 @@ public class MesNcProcessingController { } } + + @GetMapping("/sync-qms-scrap") + @ApiOperation(value = "同步到qms中间表") + public ResultBean syncQmsScrap(String organizeCode) { + try { + ValidatorBean.checkNotNull(organizeCode, "工厂不能为空"); + ncProcessingService.syncQmsScrap(organizeCode); + return ResultBean.success("同步成功"); + } catch (ImppBusiException imppException) { + return ResultBean.fail(imppException); + } catch (Exception e) { + return ImppExceptionBuilder.newInstance().buildExceptionResult(e); + } + } + } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesReworkTaskServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesReworkTaskServiceImpl.java index 170272e..fe5b86d 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesReworkTaskServiceImpl.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesReworkTaskServiceImpl.java @@ -1137,8 +1137,14 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService { } private void doCreateScrap(MesProductionAssemblyModel assemblyModel,String userName,String responsibleParty,String organizeCode) { + + MesProduceSn oldProduceSn = getMesProduceSn(organizeCode,assemblyModel.getAssemblySn()); + //新增一条数据到报废表中 MesQmsScrap mesQmsScrap = new MesQmsScrap(); + mesQmsScrap.setWorkCenterCode(oldProduceSn.getWorkCenterCode()); + mesQmsScrap.setWorkCellCode(oldProduceSn.getWorkCellCode()); + mesQmsScrap.setShiftGroup(oldProduceSn.getShiftGroup()); mesQmsScrap.setOrganizeCode(organizeCode); mesQmsScrap.setAsnNo(""); mesQmsScrap.setSource("MES"); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java index 61fe8ed..a9c8ece 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java @@ -33,6 +33,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; +import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -125,6 +126,11 @@ public class MesNcProcessingService implements IMesNcProcessingService { @Autowired private MesPartInspectionPersonRepository mesPartInspectionPersonRepository; + @Autowired + private MesPartInspectionPersonRepository partInspectionPersonRepository; + + @Autowired + private IMesQmsScrapService mesQmsScrapService; @Override public ListPager queryPartInspectionByPager(MesPartInspection partInspection, Pager pager) { @@ -1062,4 +1068,97 @@ public class MesNcProcessingService implements IMesNcProcessingService { move.setWorkCenter(prodOrgExtService.getErpWorkCenterCode(org, workCenterCode)); return move; } + + @Override + public void syncQmsScrap(String organizeCode) { + boolean isNew = false; + MesConfig mesConfig = configService.getCfgValueByCode(organizeCode, "MES_SCAP_IS_NEW_TYPE"); + if (mesConfig != null && Objects.equals(mesConfig.getCfgValue(), "1")) { + isNew = true; + } + if (isNew) { + sendToQmsNew(organizeCode); + } else { + sendToQms(organizeCode); + } + } + + private void sendToQmsNew(String organizeCode) { + + List mesPartInspectionAllList = new ArrayList<>(); + + + //获取前一天的所有ncStatus=40报废状态下可疑品缺陷 + DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); + //DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue(), "inspectionStatus", packBean); + DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PART_INSPECTION_NC_STATUS.SCRAP.getValue(), "ncStatus", packBean); + //查同步标识为3的数据,如果接口映射同步,则更新为1 + DdlPreparedPack.getNumNOEqualPack(1, "systemSyncStatus", packBean); + + List mesPartInspectionPersonList = partInspectionPersonRepository.findByHqlWhere(packBean); + + + if (!CollectionUtils.isEmpty(mesPartInspectionPersonList)) { + List inspectionIds = mesPartInspectionPersonList.stream().map(MesPartInspectionPerson::getPid).collect(Collectors.toList()); + + //获取前一天的所有ncStatus=40报废状态下可疑品缺陷 + DdlPackBean inspectionBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getInPackList(inspectionIds, "id", inspectionBean); + //DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue(), "inspectionStatus", packBean); + List mesPartInspectionList = partInspectionRepository.findByHqlWhere(inspectionBean); + log.info("一共需要汇总的批次加导入{}条报废数据2", mesPartInspectionList.size()); + + mesPartInspectionAllList.addAll(mesPartInspectionList); + } + //获取前一天的所有ncStatus=40报废状态下可疑品缺陷 + DdlPackBean singlePackBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue(), "inspectionStatus", packBean); + DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PART_INSPECTION_NC_STATUS.SCRAP.getValue(), "ncStatus", packBean); + DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue(), "sourceType", packBean); + + //查同步标识为3的数据,如果接口映射同步,则更新为1 + DdlPreparedPack.getNumNOEqualPack(1, "systemSyncStatus", packBean); + List mesPartInspectionSingleList = partInspectionRepository.findByHqlWhere(packBean); + if (!CollectionUtils.isEmpty(mesPartInspectionSingleList)) { + log.info("一共需要汇总的单件{}条报废数据2", mesPartInspectionSingleList.size()); + mesPartInspectionAllList.addAll(mesPartInspectionSingleList); + } + log.info("一共需要汇总{}条报废数据2", mesPartInspectionAllList.size()); + + mesQmsScrapService.doQmsScrapByPartInspectionNew(mesPartInspectionAllList,mesPartInspectionPersonList, organizeCode); + + for (MesPartInspection mesPartInspection : mesPartInspectionAllList) { + mesPartInspection.setSystemSyncStatus(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()); +// ConvertBean.serviceModelUpdate(mesPartInspection, MesExtConstWords.JOB); + } + for (MesPartInspectionPerson mesPartInspectionPerson : mesPartInspectionPersonList) { + mesPartInspectionPerson.setSystemSyncStatus(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()); + } + partInspectionRepository.saveAll(mesPartInspectionAllList); + partInspectionPersonRepository.saveAll(mesPartInspectionPersonList); + } + private void sendToQms(String organizeCode){ + //获取前一天的所有ncStatus=40报废状态下可疑品缺陷 + DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue(), "inspectionStatus", packBean); + DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PART_INSPECTION_NC_STATUS.SCRAP.getValue(), "ncStatus", packBean); + //查同步标识为3的数据,如果接口映射同步,则更新为1 + DdlPreparedPack.getNumNOEqualPack(1, "systemSyncStatus", packBean); + DdlPreparedPack.timeBuilder( + new SimpleDateFormat("yyyy-MM-dd").format(TimeTool.getDateBefore(new Date(), 1)) + " 00:00:00", + TimeTool.getToday() + " 00:00:00", "createDatetime", packBean, true); + + List mesPartInspectionList = partInspectionRepository.findByHqlWhere(packBean); + if (!CollectionUtils.isEmpty(mesPartInspectionList)) { + log.info("一共需要汇总{}条报废数据2", mesPartInspectionList.size()); + + mesQmsScrapService.doQmsScrapByPartInspection(mesPartInspectionList, organizeCode); + + for (MesPartInspection mesPartInspection : mesPartInspectionList) { + mesPartInspection.setSystemSyncStatus(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()); +// ConvertBean.serviceModelUpdate(mesPartInspection, MesExtConstWords.JOB); + } + partInspectionRepository.saveAll(mesPartInspectionList); + } + } } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesQmsScrapService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesQmsScrapService.java new file mode 100644 index 0000000..553debf --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesQmsScrapService.java @@ -0,0 +1,210 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi; + + +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesQmsScrapService; +import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionModel; +import cn.estsh.i3plus.platform.common.convert.ConvertBean; +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.mes.bean.MesProduceSn; +import cn.estsh.i3plus.pojo.mes.bean.MesQmsScrap; +import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspection; +import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspectionDetail; +import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspectionPerson; +import cn.estsh.i3plus.pojo.mes.repository.MesPartInspectionDetailRepository; +import cn.estsh.i3plus.pojo.mes.repository.MesProduceSnRepository; +import cn.estsh.i3plus.pojo.mes.repository.MesQmsScrapRepository; +import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * @Description :MES_QMS报废品汇总 + * @Reference : + * @Author : gsz + * @CreateDate 2024/7/3 10:28 + * @Modify: + **/ +@Service +@Slf4j +public class MesQmsScrapService implements IMesQmsScrapService { + @Autowired + private MesPartInspectionDetailRepository partInspectionDetailRDao; + + @Autowired + private MesProduceSnRepository mesProduceSnRepository; + + @Autowired + private MesQmsScrapRepository mesQmsScrapRepository; + + @Override + public void doQmsScrapByPartInspectionNew(List mesPartInspectionLists, List mesPartInspectionPersonList, String organizeCode) { + + Map> map = mesPartInspectionLists.stream().collect(Collectors.groupingBy(MesPartInspection::getInspectionDate)); + + map.forEach((k,v) -> { + String inspectionDate = k; + List mesPartInspectionList = v; + + List idList = mesPartInspectionList.stream().map(MesPartInspection::getId).collect(Collectors.toList()); + DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getInPackList(idList, "pid", packBean); + List partInspectionDetails = partInspectionDetailRDao.findByHqlWhere(packBean); + Map> idDetailListMap = partInspectionDetails.stream().collect(Collectors.groupingBy(MesPartInspectionDetail::getPid)); + + List partInspectionModels = new ArrayList<>(); + for (MesPartInspection mesPartInspection : mesPartInspectionList) { + MesPartInspectionModel mesPartInspectionModel = new MesPartInspectionModel(); + BeanUtils.copyProperties(mesPartInspection, mesPartInspectionModel); + if (Objects.equals(mesPartInspection.getSourceType(), MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue())) { + // 根据条码查询条码信息 + DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getStringEqualPack(mesPartInspection.getSn(),"productSn", ddlPackBean); + DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, ddlPackBean); + MesProduceSn mesProduceSn = mesProduceSnRepository.getByProperty(ddlPackBean); + if (mesProduceSn == null) { + DdlPackBean custPackBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getStringEqualPack(mesPartInspection.getSn(),"custSn", custPackBean); + DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, custPackBean); + mesProduceSn = mesProduceSnRepository.getByProperty(custPackBean); + if (mesProduceSn == null) { + MesPcnException.throwBusiException(String.format("条码:【%s】不存在", mesPartInspection.getSn())); + } + } + mesPartInspectionModel.setWorkCenterCode(mesProduceSn.getWorkCenterCode()); + mesPartInspectionModel.setWorkCellCode(mesProduceSn.getWorkCellCode()); + mesPartInspectionModel.setShiftGroup(mesProduceSn.getShiftGroup()); + + partInspectionModels.add(mesPartInspectionModel); + } else { + mesPartInspectionModel.setWorkCenterCode(mesPartInspection.getWorkCenterCode()); + partInspectionModels.add(mesPartInspectionModel); + } + } + + //43326 电子化检验,发送给QMS的数据,按照零件号+责任人类型分组发送 + //Map> workOrderPartMap = mesPartInspectionList.stream().collect(Collectors.groupingBy(p -> p.getPartNo() +"="+p.getResponsibleParty())); + Map> workOrderPartMap = partInspectionModels.stream().collect(Collectors.groupingBy(p -> { + MesPartInspectionModel mesPartInspectionModel = new MesPartInspectionModel(); + mesPartInspectionModel.setWorkCenterCode(p.getWorkCenterCode()); + mesPartInspectionModel.setWorkCellCode(p.getWorkCellCode()); + mesPartInspectionModel.setShiftGroup(p.getShiftGroup()); + mesPartInspectionModel.setPartNo(p.getPartNo()); + mesPartInspectionModel.setResponsibleParty(p.getResponsibleParty()); + + return mesPartInspectionModel; + })); + //根据物料对可疑品分组 + List qmsScrapList = new ArrayList<>(); + log.info("一共需要汇总{}条报废数据2", workOrderPartMap.size()); + Map> personMap = mesPartInspectionPersonList.stream().collect(Collectors.groupingBy(MesPartInspectionPerson::getPid)); + + + for (Map.Entry> stringListEntry : workOrderPartMap.entrySet()) { + + MesPartInspectionModel mesPartInspectionModel = stringListEntry.getKey(); + String keyPartNo = mesPartInspectionModel.getPartNo(); + List mesPartInspections = stringListEntry.getValue(); + MesPartInspectionModel next = mesPartInspections.iterator().next(); + List mesPartInspectionDetails = new ArrayList<>(); + for (MesPartInspectionModel mesPartInspection : mesPartInspections) { + mesPartInspectionDetails.addAll(idDetailListMap.get(mesPartInspection.getId())); + } + + //新增一条数据到报废表中 + MesQmsScrap mesQmsScrap = new MesQmsScrap(); + mesQmsScrap.setWorkCenterCode(mesPartInspectionModel.getWorkCenterCode()); + mesQmsScrap.setWorkCellCode(mesPartInspectionModel.getWorkCellCode()); + mesQmsScrap.setShiftGroup(mesPartInspectionModel.getShiftGroup()); + mesQmsScrap.setOrganizeCode(organizeCode); + mesQmsScrap.setAsnNo(""); + mesQmsScrap.setSource("MES"); + double sum = 0.0; + for (MesPartInspection mesPartInspection : mesPartInspections) { + if (Objects.equals(mesPartInspection.getSourceType(), MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue())) { + sum += mesPartInspection.getRejectQty(); + } else { + List personList = personMap.get(mesPartInspection.getId()); + if (!CollectionUtils.isEmpty(personList)) { + double rejectQty = personList.stream().map(MesPartInspectionPerson::getQty).reduce((a, b) -> a + b).get(); + sum += rejectQty; + } + } + } + mesQmsScrap.setRejectQty(sum); + mesQmsScrap.setPartNo(keyPartNo); + mesQmsScrap.setPartName(next.getPartName()); + String defectTypeName = mesPartInspectionDetails.stream().map(MesPartInspectionDetail::getDefectTypeName).collect(Collectors.joining(";")); + mesQmsScrap.setDefectTypeName(defectTypeName); + mesQmsScrap.setReponsibilityId(next.getResponsibleParty()); + mesQmsScrap.setNcJudger(next.getModifyUser()); + ConvertBean.serviceModelInitialize(mesQmsScrap, "MesScrapJob"); + qmsScrapList.add(mesQmsScrap); + } + log.info("一共需要汇总{}条报废数据3", qmsScrapList.size()); + mesQmsScrapRepository.saveAll(qmsScrapList); + }); + } + + @Override + public void doQmsScrapByPartInspection(List mesPartInspectionLists, String organizeCode){ + + Map> map = mesPartInspectionLists.stream().collect(Collectors.groupingBy(MesPartInspection::getInspectionDate)); + + map.forEach((k,v) -> { + String inspectionDate = k; + List mesPartInspectionList = v; + + List idList = mesPartInspectionList.stream().map(MesPartInspection::getId).collect(Collectors.toList()); + DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getInPackList(idList, "pid", packBean); + List partInspectionDetails = partInspectionDetailRDao.findByHqlWhere(packBean); + Map> idDetailListMap = partInspectionDetails.stream().collect(Collectors.groupingBy(MesPartInspectionDetail::getPid)); + //43326 电子化检验,发送给QMS的数据,按照零件号+责任人类型分组发送 + Map> workOrderPartMap = mesPartInspectionList.stream().collect(Collectors.groupingBy(p -> p.getPartNo() + "=" + p.getResponsibleParty())); + //根据物料对可疑品分组 + List qmsScrapList = new ArrayList<>(); + log.info("一共需要汇总{}条报废数据2", workOrderPartMap.size()); + + for (Map.Entry> stringListEntry : workOrderPartMap.entrySet()) { + String keyPartNo = stringListEntry.getKey().split("=")[0]; + List mesPartInspections = stringListEntry.getValue(); + MesPartInspection next = mesPartInspections.iterator().next(); + List mesPartInspectionDetails = new ArrayList<>(); + for (MesPartInspection mesPartInspection : mesPartInspections) { + mesPartInspectionDetails.addAll(idDetailListMap.get(mesPartInspection.getId())); + } + + //新增一条数据到报废表中 + MesQmsScrap mesQmsScrap = new MesQmsScrap(); + mesQmsScrap.setOrganizeCode(organizeCode); + mesQmsScrap.setAsnNo(""); + mesQmsScrap.setSource("MES"); + double sum = mesPartInspections.stream().mapToDouble(MesPartInspection::getRejectQty).sum(); + mesQmsScrap.setRejectQty(sum); + mesQmsScrap.setPartNo(keyPartNo); + mesQmsScrap.setPartName(next.getPartName()); + String defectTypeName = mesPartInspectionDetails.stream().map(MesPartInspectionDetail::getDefectTypeName).collect(Collectors.joining(";")); + mesQmsScrap.setDefectTypeName(defectTypeName); + mesQmsScrap.setReponsibilityId(next.getResponsibleParty()); + mesQmsScrap.setNcJudger(next.getModifyUser()); + ConvertBean.serviceModelInitialize(mesQmsScrap, "MesScrapJob"); + qmsScrapList.add(mesQmsScrap); + } + log.info("一共需要汇总{}条报废数据3", qmsScrapList.size()); + mesQmsScrapRepository.saveAll(qmsScrapList); + }); + } + +} diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesPartInspectionModel.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesPartInspectionModel.java new file mode 100644 index 0000000..1fdb4fe --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesPartInspectionModel.java @@ -0,0 +1,15 @@ +package cn.estsh.i3plus.ext.mes.pcn.pojo.model; + +import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspection; +import lombok.Data; + +@Data +public class MesPartInspectionModel extends MesPartInspection { + // 产线 + private String workCenterCode; + // 工位 + private String workCellCode; + // 班组 + private String shiftGroup; + +} From 41d63d1bebe91e5f8b76c3eac760474f9b90e714 Mon Sep 17 00:00:00 2001 From: "xiangwei.zhang" <752558143@qq.com> Date: Tue, 27 May 2025 11:04:08 +0800 Subject: [PATCH 2/3] =?UTF-8?q?47023=20PCN:=20NC=E6=8A=A5=E5=BA=9F?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E7=9B=B8=E5=85=B3=E4=BC=98=E5=8C=96=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E6=96=87=E6=A1=A3[DM202505140012]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/busi/MesNcProcessingService.java | 52 +++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java index a9c8ece..33d48e9 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java @@ -4,16 +4,21 @@ import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesPartService; import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesProdOrgExtService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.*; import cn.estsh.i3plus.ext.mes.pcn.apiservice.dao.IMesNcProcessingDao; +import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.*; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService; +import cn.estsh.i3plus.mes.pcn.util.PcnHttpUtil; import cn.estsh.i3plus.platform.common.convert.ConvertBean; +import cn.estsh.i3plus.platform.common.tool.JsonUtilTool; import cn.estsh.i3plus.platform.common.tool.TimeTool; +import cn.estsh.i3plus.pojo.base.bean.BaseResultBean; import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; import cn.estsh.i3plus.pojo.base.bean.ListPager; import cn.estsh.i3plus.pojo.base.common.Pager; import cn.estsh.i3plus.pojo.base.common.PagerHelper; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; +import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil; import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; import cn.estsh.i3plus.pojo.base.util.StringUtil; import cn.estsh.i3plus.pojo.mes.bean.*; @@ -33,6 +38,8 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; +import javax.servlet.http.HttpServletRequest; +import java.io.UnsupportedEncodingException; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -1071,6 +1078,24 @@ public class MesNcProcessingService implements IMesNcProcessingService { @Override public void syncQmsScrap(String organizeCode) { + String url = ""; + MesConfig mesConfig = configService.getCfgValueByCode(organizeCode, "MES_SCRAP_URL"); + if (mesConfig == null) { + MesPcnException.throwBusiException("未配置系统参数:MES_SCRAP_URL"); + } + url = mesConfig.getCfgValue(); + Map map = new HashMap<>(); + map.put("organizeCode", organizeCode); + ResultBean resultBean = getModuleData(url, map); + + //校验平台登陆结果 + if (null != resultBean && resultBean.success == false) { + MesPcnException.throwBusiException("同步失败"); + } + } + + /* @Override + public void syncQmsScrap(String organizeCode) { boolean isNew = false; MesConfig mesConfig = configService.getCfgValueByCode(organizeCode, "MES_SCAP_IS_NEW_TYPE"); if (mesConfig != null && Objects.equals(mesConfig.getCfgValue(), "1")) { @@ -1081,7 +1106,7 @@ public class MesNcProcessingService implements IMesNcProcessingService { } else { sendToQms(organizeCode); } - } + }*/ private void sendToQmsNew(String organizeCode) { @@ -1161,4 +1186,29 @@ public class MesNcProcessingService implements IMesNcProcessingService { partInspectionRepository.saveAll(mesPartInspectionList); } } + /** + * http接口调用 + * @param url + * @param paramsMap + * @return + */ + private ResultBean getModuleData(String url, Map paramsMap) { + ResultBean resultBean = null; + //http接口调用 + String data = null; + try { + data = PcnHttpUtil.doGet(url, paramsMap); + if (!StringUtils.isEmpty(data)) { + resultBean = JsonUtilTool.decode(data, ResultBean.class); + } else { + log.error("HTTP调用mes接口失败"); + } + } catch (UnsupportedEncodingException e) { +// e.printStackTrace(); + log.error("执行异常:{}", e); + log.error("HTTP调用mes接口失败"); + } + + return resultBean; + } } From c2d9e2207e2b4da0025f847c51d1e6da785ef663 Mon Sep 17 00:00:00 2001 From: "xiangwei.zhang" <752558143@qq.com> Date: Tue, 27 May 2025 17:29:19 +0800 Subject: [PATCH 3/3] =?UTF-8?q?47023=20PCN:=20NC=E6=8A=A5=E5=BA=9F?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E7=9B=B8=E5=85=B3=E4=BC=98=E5=8C=96=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E6=96=87=E6=A1=A3[DM202505140012]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java index 33d48e9..2b993d3 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java @@ -1089,7 +1089,7 @@ public class MesNcProcessingService implements IMesNcProcessingService { ResultBean resultBean = getModuleData(url, map); //校验平台登陆结果 - if (null != resultBean && resultBean.success == false) { + if (null == resultBean || resultBean.success == false) { MesPcnException.throwBusiException("同步失败"); } }