From cce62542f3c7ea6d9d6a893f7c4285d18dd7bc2c Mon Sep 17 00:00:00 2001 From: jun Date: Wed, 12 Jun 2024 17:50:47 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=BA=E9=99=B7=E5=BD=95=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/base/MesReworkTaskServiceImpl.java | 12 ++++-- .../busi/MesInputDefectRecordService.java | 49 +++++++++++++++++++--- .../pcn/pojo/model/MesPartInspectionViewModel.java | 4 ++ 3 files changed, 56 insertions(+), 9 deletions(-) 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 fc7b782..d758459 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 @@ -6,6 +6,7 @@ import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesReworkTaskModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesReworkTaskRequestModel; import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService; +import cn.estsh.i3plus.platform.common.convert.ConvertBean; import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum; import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; import cn.estsh.i3plus.pojo.base.bean.ListPager; @@ -140,12 +141,15 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService { DdlPackBean packBean = DdlPackBean.getDdlPackBean(AuthUtil.getOrganizeCode()); DdlPreparedPack.getNumEqualPack(detailId, "partInspectionDetailId", packBean); - MesReworkTaskDetail mesReworkTaskDetail = mesReworkTaskDetailRepository.getByProperty(packBean); - if (mesReworkTaskDetail == null) { + List mesReworkTaskDetailList = mesReworkTaskDetailRepository.findByHqlWhere(packBean); + if (CollectionUtils.isEmpty(mesReworkTaskDetailList)) { MesPcnException.throwFlowException("返工单详情不存在"); } - mesReworkTaskDetail.setStatus(MesExtEnumUtil.REWORK_TASK_DETAIL_STATUS.REWORK_TASK_DETAIL_STATUS_20.getValue()); - mesReworkTaskDetailRepository.save(mesReworkTaskDetail); + mesReworkTaskDetailList.forEach(mesReworkTaskDetail->{ + mesReworkTaskDetail.setStatus(MesExtEnumUtil.REWORK_TASK_DETAIL_STATUS.REWORK_TASK_DETAIL_STATUS_20.getValue()); + ConvertBean.serviceModelUpdate(mesReworkTaskDetail,AuthUtil.getSessionUser().getUserName()); + }); + mesReworkTaskDetailRepository.saveAll(mesReworkTaskDetailList); } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesInputDefectRecordService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesInputDefectRecordService.java index d1b42b7..dfb4d0a 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesInputDefectRecordService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesInputDefectRecordService.java @@ -1,5 +1,6 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi; +import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesReworkTaskService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesConfigService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesInputDefectRecordService; import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant; @@ -16,6 +17,7 @@ import cn.estsh.i3plus.pojo.mes.bean.*; 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.rework.MesReworkTask; +import cn.estsh.i3plus.pojo.mes.bean.rework.MesReworkTaskDetail; import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel; import cn.estsh.i3plus.pojo.mes.repository.*; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; @@ -83,6 +85,9 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService @Autowired private MesDefectTypeRepository defectTypeRepository; + @Autowired + private MesReworkTaskDetailRepository mesReworkTaskDetailRDao; + @Override public MesPartInspectionViewModel queryPartInspection(MesPartInspectionInputModel inputModel, String org) { @@ -125,7 +130,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService MesPartTypePicture partTypePicture = checkPartTypePicture(part, org); //构造返回信息 - MesPartInspectionViewModel model = getModel(partInspection, part, partTypePicture, inputModel.getFrontBack(), sourceType, org); + MesPartInspectionViewModel model = getModel(partInspection, part, partTypePicture, inputModel, sourceType, org); model.setSourceType(sourceType); model.setTransferFlg(inputModel.isTransferFlg()); @@ -488,7 +493,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService //返修单 进行返修 inputModel.setTransferFlg(true); } - + return partInspection; } } @@ -698,14 +703,18 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService return alarmConfigList; } - private MesPartInspectionViewModel getModel(MesPartInspection partInspection, MesPart part, MesPartTypePicture partTypePicture, Integer frontBack, + private MesPartInspectionViewModel getModel(MesPartInspection partInspection, MesPart part,MesPartTypePicture partTypePicture, MesPartInspectionInputModel inputModel , Integer sourceType, String org) { - + Integer frontBack = inputModel.getFrontBack(); List detailList = new ArrayList<>(); if (!StringUtils.isEmpty(partInspection) && partInspection.getInspectionStatus() != MesExtEnumUtil.PART_INSPECTION_STATUS.QUALIFIED.getValue()) { detailList = checkPartInspectionDetail(partInspection, org); + if(!CollectionUtils.isEmpty(detailList)){ + //判断是否返工完成 + checkReworkFinished(org, detailList); + } } //位置 List locationConfigList = checkLocationConfig(org); @@ -721,23 +730,53 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService //根据不良类型+位置 若有数据,则表示需要标黄 Map> alarmConfigMap = alarmConfigList.stream().collect(Collectors.groupingBy(MesDefectWarnConfig::getDefectLocation)); + //返修完成需要标记绿色 + Map> detailMap = detailList.stream().collect(Collectors.groupingBy(MesPartInspectionDetail::getDefectLocation)); + locationConfigList.forEach(k -> { k.setFrontBack(frontBack); if (alarmConfigMap.containsKey(k.getDefectLocation())) { k.setIsflg(true); + k.setColour(MesExtEnumUtil.COLOR.YELLOW.getValue()); + } + + if(detailMap.containsKey(k.getDefectLocation()) && + detailMap.get(k.getDefectLocation()).stream().allMatch(MesPartInspectionDetail::getReworkFinished)){ + k.setIsflg(true); + k.setColour(MesExtEnumUtil.COLOR.GREEN.getValue()); } }); MesPartInspectionViewModel model = new MesPartInspectionViewModel(); model.setPart(part); - model.setPartInspectionDetailList(detailList); + if (partInspection.getInspectionStatus() == MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue() + && partInspection.getNcStatus() == MesExtEnumUtil.PART_INSPECTION_NC_STATUS.CREATE.getValue()) { + model.setPartInspectionDetailList(detailList); + } model.setPartTypePicture(partTypePicture); model.setLocationConfigList(locationConfigList); model.setPartInspection(partInspection); + model.setMesDefectWarnConfigList(alarmConfigList); return model; } + private void checkReworkFinished(String org, List detailList) { + List idList = detailList.stream().map(MesPartInspectionDetail::getId).collect(Collectors.toList()); + DdlPackBean packBean = DdlPackBean.getDdlPackBean(org); + DdlPreparedPack.getInPackList(idList, "partInspectionDetailId", packBean); + List mesReworkTaskDetailList = mesReworkTaskDetailRDao.findByHqlWhere(packBean); + if (!CollectionUtils.isEmpty(mesReworkTaskDetailList)){ + Map> mesReworkTaskDetailMap = mesReworkTaskDetailList.stream().collect(Collectors.groupingBy(MesReworkTaskDetail::getPartInspectionDetailId)); + detailList.forEach(d->{ + if(mesReworkTaskDetailMap.containsKey(d.getId()) && + mesReworkTaskDetailMap.get(d.getId()).stream().allMatch(t->MesExtEnumUtil.REWORK_TASK_STATUS.FINISH.getValue() == t.getStatus())){ + d.setReworkFinished(true); + } + }); + } + } + private List checkPartInspectionDetail(MesPartInspection partInspection, String org) { DdlPackBean packBean = DdlPackBean.getDdlPackBean(org); DdlPreparedPack.getNumEqualPack(partInspection.getId(), "pid", packBean); diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesPartInspectionViewModel.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesPartInspectionViewModel.java index da8a848..62972bf 100644 --- a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesPartInspectionViewModel.java +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesPartInspectionViewModel.java @@ -1,5 +1,6 @@ package cn.estsh.i3plus.ext.mes.pcn.pojo.model; +import cn.estsh.i3plus.pojo.mes.bean.MesDefectWarnConfig; import cn.estsh.i3plus.pojo.mes.bean.MesLocationConfig; import cn.estsh.i3plus.pojo.mes.bean.MesPart; import cn.estsh.i3plus.pojo.mes.bean.MesPartTypePicture; @@ -31,6 +32,9 @@ public class MesPartInspectionViewModel { @ApiParam("NC-零件检测详情") private List partInspectionDetailList; + @ApiParam("缺陷告警配置") + private List mesDefectWarnConfigList; + @ApiParam("图片") private MesPartTypePicture partTypePicture;