diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesTemplateService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesTemplateService.java index 114e632..8decb81 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesTemplateService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesTemplateService.java @@ -1,8 +1,12 @@ package cn.estsh.i3plus.ext.mes.pcn.api.base; import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplate; +import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplateFieldValue; import io.swagger.annotations.ApiOperation; +import java.util.List; +import java.util.Map; + public interface IMesTemplateService { /** @@ -16,4 +20,6 @@ public interface IMesTemplateService { @ApiOperation(value = "按条件查询", notes = "按条件查询") MesLabelTemplate getLabelTemplate(String templateCode, String organizeCode); + + Map queryMesLabelTemplateParamPartValue(String partNo, String labelTemplate, String organizeCode); } diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesInputDefectRecordService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesInputDefectRecordService.java index 3f93913..6a1b4d1 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesInputDefectRecordService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesInputDefectRecordService.java @@ -4,7 +4,6 @@ import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionInputModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionViewModel; import cn.estsh.i3plus.pojo.mes.bean.MesPartTypeDefect; import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn; -import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspectionDetail; import io.swagger.annotations.ApiOperation; import java.util.List; @@ -20,14 +19,14 @@ public interface IMesInputDefectRecordService { @ApiOperation(value = "查询页面信息") - MesPartInspectionViewModel queryPartInspection(MesPartInspectionInputModel model, String org); + MesPartInspectionViewModel queryPartInspection(MesPartInspectionInputModel model); @ApiOperation(value = "零件类型缺陷类型对应关系信息") List queryPartTypeDefect(String serialNumber, String defectLocation, boolean flg, Integer frontBack, String org); @ApiOperation(value = "完成质检") - void savePartInspection(MesPartInspectionInputModel model, String org); + void savePartInspection(MesPartInspectionInputModel model); @ApiOperation(value = "客退品") MesProduceSn customerBack(String organizeCode, String sn, String userName); 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 8472b8e..93df197 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 @@ -20,21 +20,19 @@ import java.util.List; **/ public interface IMesNcProcessingService { - @ApiOperation(value = "查询NC-零件检测-单据") - public ListPager queryPartInspectionByPager(MesPartInspection partInspection, Pager pager); + ListPager queryPartInspectionByPager(MesPartInspection partInspection, Pager pager); @ApiOperation(value = "查询NC-零件检测-单据") - public MesNcProcessingModel queryPartInspection(MesPartInspection partInspection); + MesNcProcessingModel queryPartInspection(MesPartInspection partInspection); @ApiOperation(value = "查询责任人") - public List queryPerson(String org); + List queryPerson(String org); @ApiOperation(value = "查询标记不良的物料及批次") - public ListPager queryPartLot(String partNo, String lot, String org, Pager pager); + ListPager queryPartLot(String partNo, String lot, String org, Pager pager); @ApiOperation(value = "NC处理") - public void saveNc(MesNcProcessingInputModel model, String org, boolean isOrder); - + void saveNc(MesNcProcessingInputModel model, String org, boolean isOrder); } diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesPartShippingGroupService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesPartShippingGroupService.java index 6d65c8e..332c804 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesPartShippingGroupService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesPartShippingGroupService.java @@ -5,6 +5,7 @@ import cn.estsh.i3plus.pojo.mes.bean.MesPartShippingGroup; import cn.estsh.i3plus.pojo.mes.bean.MesPartShippingGroupDetail; import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement; import cn.estsh.i3plus.pojo.mes.model.MesShippingOrderManagementModel; +import cn.estsh.impp.framework.boot.util.ResultBean; import io.swagger.annotations.ApiOperation; import java.util.List; @@ -24,7 +25,7 @@ public interface IMesPartShippingGroupService { MesPartShippingGroup getMesPartShippingGroup(String organizeCode,String shippingGroupCode); @ApiOperation(value = "打印发运单数据") - List doMesMesShippingOrderManagementPrint(MesShippingOrderManagement model); + ResultBean doMesMesShippingOrderManagementPrint(MesShippingOrderManagement model); @ApiOperation(value = "发运组明细") MesPartShippingGroupDetail getMesPartShippingGroupDetail(String organizeCode, String shippingGroupCode, String partNo, String custPartNo); diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesPrintedSnLogService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesPrintedSnLogService.java index a4b153e..99c9830 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesPrintedSnLogService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesPrintedSnLogService.java @@ -4,6 +4,8 @@ import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintDataModel; import cn.estsh.i3plus.pojo.mes.bean.MesPrintedSnLog; import io.swagger.annotations.ApiOperation; +import java.util.Map; + /** * @Description : 条码打印记录表 * @Reference : @@ -16,6 +18,9 @@ public interface IMesPrintedSnLogService { @ApiOperation(value = "条码打印记录表") MesPrintedSnLog getMesPrintedSnLog(String userName, String organizeCode, MesProduceSnPrintDataModel printDataModel); + @ApiOperation(value = "条码打印记录表") + MesPrintedSnLog getMesCustomPrintedSnLog(String userName, String organizeCode, MesProduceSnPrintDataModel printDataModel, Map printContext); + @ApiOperation(value = "写入条码打印记录表") void insertMesPrintedSnLog(MesPrintedSnLog mesPrintedSnLog,String userName); } diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesPullingOrderInfoService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesPullingOrderInfoService.java index 641acc0..6443ef6 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesPullingOrderInfoService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesPullingOrderInfoService.java @@ -24,6 +24,8 @@ public interface IMesPullingOrderInfoService { List doMesPullingOrderInfoPrint(MesPullingOrderInfo mesPullingOrderInfo); + List doMesPullingOrderInfoPrintNew(MesPullingOrderInfo mesPullingOrderInfo); + ListPager queryMesPullingOrderPartInfoByPager(MesPullingOrderInfo mesPullingOrderInfo, Pager pager); List doMesPullingOrderInfoSend(List infoList, String userName); diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesWorkOrderCutService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesWorkOrderCutService.java index 85b7957..509bb1a 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesWorkOrderCutService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesWorkOrderCutService.java @@ -31,6 +31,10 @@ public interface IMesWorkOrderCutService { @ApiOperation(value = "查询裁片方案成品配置") List queryCutSchemeFgList(String cutCode, String organizeCode); + @ApiOperation(value = "查询裁片方案成品配置") + List queryCutOrderMaterialList(String cutWorkOrder, String organizeCode); + + @ApiOperation(value = "查询裁片方案设备信息") MesCutSchemeEquipment getCutSchemeEquipment(String cutCode, String equipmentCode, String organizeCode); diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesWorkOrderService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesWorkOrderService.java index 96b4e50..664facd 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesWorkOrderService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesWorkOrderService.java @@ -1,5 +1,6 @@ package cn.estsh.i3plus.ext.mes.pcn.api.busi; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesWorkOrderExtModel; import cn.estsh.i3plus.pojo.base.bean.ListPager; import cn.estsh.i3plus.pojo.base.common.Pager; import cn.estsh.i3plus.pojo.mes.bean.*; @@ -56,7 +57,7 @@ public interface IMesWorkOrderService { List getUnReportHasOrderMesProduceSn(String organizeCode); @ApiOperation(value = "生产报工") - void doProductReport(MesWorkOrder mesWorkOrder,String userName); + void doProductReport(MesWorkOrderExtModel mesWorkOrder, String userName); @ApiOperation(value = "报工调整") void doProductReportReversal(MesWorkOrder mesWorkOrder,MesProductVersion mesProductVersion,String userName); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/base/MesWhiteController.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/base/MesWhiteController.java index c75ac3b..6957dcb 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/base/MesWhiteController.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/base/MesWhiteController.java @@ -1,20 +1,32 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.base; +import cn.estsh.i3plus.ext.mes.pcn.apiservice.model.MesPictureModel; +import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.MesConfigService; import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.MesProduceSnExtService; import cn.estsh.impp.framework.boot.util.ResultBean; +import cn.hutool.json.JSONUtil; +import io.swagger.annotations.Api; +import jodd.util.Base64; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.io.*; +import java.nio.file.Files; @RestController @RequestMapping("/white") +@Api(tags = "白名单") +@Slf4j public class MesWhiteController { @Autowired private MesProduceSnExtService mesProduceSnExtService; + @Autowired + private MesConfigService mesConfigService; + @GetMapping("/mesPartSap/{productSn}/{organizeCode}") public ResultBean getPartNo(@PathVariable String productSn,@PathVariable String organizeCode){ @@ -27,4 +39,24 @@ public class MesWhiteController { return ResultBean.success("查询成功").setResultObject(partNo); } + + @PostMapping("/picture") + public ResultBean savePicture(@RequestBody MesPictureModel model){ + + String localUrl = mesConfigService.getCfgValue(model.getOrganizeCode(), "LOCAL_PICTURE_ABS_URL"); + File file = new File(localUrl+model.getFileName()); + byte[] decode = Base64.decode(model.getFile()); + OutputStream outputStream; + try { + outputStream = Files.newOutputStream(file.toPath()); + outputStream.write(decode); + outputStream.close(); + } catch (IOException e) { + log.error("保存图片出错:{}",e.getMessage()); + log.error("入参为:{}", model); + } + return ResultBean.success("查询成功"); + + } + } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesInputDefectRecordController.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesInputDefectRecordController.java index 2d41c6f..6891cd8 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesInputDefectRecordController.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesInputDefectRecordController.java @@ -7,7 +7,6 @@ import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionInputModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionViewModel; import cn.estsh.i3plus.platform.common.tool.MathOperation; import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn; -import cn.estsh.impp.framework.boot.auth.AuthUtil; import cn.estsh.impp.framework.boot.exception.ImppBusiException; import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder; import cn.estsh.impp.framework.boot.util.ResultBean; @@ -35,8 +34,8 @@ public class MesInputDefectRecordController { public ResultBean queryPartInspection(@RequestBody MesPartInspectionInputModel model) { try { - String organizeCode = !StringUtils.isEmpty(model.getOrganizeCode()) ? model.getOrganizeCode() : AuthUtil.getOrganize().getOrganizeCode(); - MesPartInspectionViewModel result = inputDefectRecordService.queryPartInspection(model, organizeCode); + ValidatorBean.checkNotNull(model.getOrganizeCode(), "工厂不能为空"); + MesPartInspectionViewModel result = inputDefectRecordService.queryPartInspection(model); String msg = "查询成功"; if (!StringUtils.isEmpty(model.getFrontBack()) && model.getFrontBack().compareTo(10) == 0 && (Objects.isNull(result.getPartTypePicture()) || StringUtils.isEmpty(result.getPartTypePicture().getFrontPictureName()))) msg = "A面图片未维护"; if (!StringUtils.isEmpty(model.getFrontBack()) && model.getFrontBack().compareTo(20) == 0 && (Objects.isNull(result.getPartTypePicture()) || StringUtils.isEmpty(result.getPartTypePicture().getBackPictureName()))) msg = "B面图片未维护"; @@ -50,16 +49,14 @@ public class MesInputDefectRecordController { @GetMapping("/query-part-type-defect") @ApiOperation(value = "查询零件类型缺陷类型对应关系") - public ResultBean queryPartTypeDefect(String partNo, String defectLocation, boolean flg, Integer frontBack,String organizeCode) { + public ResultBean queryPartTypeDefect(String partNo, String defectLocation, boolean flg, Integer frontBack, String organizeCode) { try { - // 数据校验 ValidatorBean.checkNotNull(partNo, "物料号不能为空"); ValidatorBean.checkNotNull(defectLocation, "位置不能为空"); ValidatorBean.checkNotNull(frontBack, "正反面不能为空"); - -// return ResultBean.success("查询成功").setResultList(inputDefectRecordService.queryPartTypeDefect(partNo, defectLocationCode, flg, frontBack, "2031")); - return ResultBean.success("查询成功").setResultList(inputDefectRecordService.queryPartTypeDefect(partNo, defectLocation, flg, frontBack,!StringUtils.isEmpty(organizeCode)?organizeCode:AuthUtil.getOrganizeCode())); + ValidatorBean.checkNotNull(organizeCode, "工厂不能为空"); + return ResultBean.success("查询成功").setResultList(inputDefectRecordService.queryPartTypeDefect(partNo, defectLocation, flg, frontBack, organizeCode)); } catch (ImppBusiException imppException) { return ResultBean.fail(imppException); } catch (Exception e) { @@ -72,15 +69,14 @@ public class MesInputDefectRecordController { public ResultBean savePartInspection(@RequestBody MesPartInspectionInputModel model) { try { - + ValidatorBean.checkNotNull(model.getOrganizeCode(), "工厂不能为空"); + ValidatorBean.checkNotNull(model.getUserInfo(), "操作人不能为空"); if (StringUtils.isEmpty(model.getSn()) && (StringUtils.isEmpty(model.getPartNo()) || StringUtils.isEmpty(model.getLotNo()) || StringUtils.isEmpty(model.getQty()) || MathOperation.compareTo(model.getQty(), new Double(0)) == 0)) { - throw new ImppBusiException("条码为空或零件号+批次+数量为空"); } -// inputDefectRecordService.savePartInspection(model, "CK01"); - inputDefectRecordService.savePartInspection(model, !StringUtils.isEmpty(model.getOrganizeCode())?model.getOrganizeCode():AuthUtil.getOrganizeCode()); + inputDefectRecordService.savePartInspection(model); return ResultBean.success("质检已完成,请继续"); } catch (ImppBusiException imppException) { return ResultBean.fail(imppException); @@ -94,7 +90,6 @@ public class MesInputDefectRecordController { public ResultBean customerBack(@RequestBody MesPartInspectionInputModel model) { try { -// inputDefectRecordService.savePartInspection(model, "CK01"); MesProduceSn mesProduceSn = inputDefectRecordService.customerBack(model.getOrganizeCode(), model.getSn(), model.getUserInfo()); return ResultBean.success("客退品已完成,请继续").setResultObject(mesProduceSn); } catch (ImppBusiException imppException) { @@ -109,7 +104,6 @@ public class MesInputDefectRecordController { public ResultBean customerBackCommit(@RequestBody MesPartInspectionInputModel model) { try { -// inputDefectRecordService.savePartInspection(model, "CK01"); inputDefectRecordService.customerBackCommit(model.getOrganizeCode(), model.getSn(), model.getUserInfo()); return ResultBean.success("客退品提交已完成,请继续"); } catch (ImppBusiException imppException) { 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 cdf87d5..6e6d121 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 @@ -8,7 +8,6 @@ import cn.estsh.i3plus.pojo.base.bean.ListPager; import cn.estsh.i3plus.pojo.base.common.Pager; import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspection; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; -import cn.estsh.impp.framework.boot.auth.AuthUtil; import cn.estsh.impp.framework.boot.exception.ImppBusiException; import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder; import cn.estsh.impp.framework.boot.util.ResultBean; @@ -36,7 +35,7 @@ public class MesNcProcessingController { public ResultBean queryPartInspectionByPager(MesPartInspection partInspection, Pager pager) { try { - + ValidatorBean.checkNotNull(partInspection.getOrganizeCode(), "工厂不能为空"); partInspection.setOrganizeCode(partInspection.getOrganizeCode()); ListPager partInspectionListPager = ncProcessingService.queryPartInspectionByPager(partInspection, pager); return ResultBean.success("查询成功").setListPager(partInspectionListPager); @@ -52,8 +51,7 @@ public class MesNcProcessingController { public ResultBean queryPartInspection(MesPartInspection partInspection) { try { - - partInspection.setOrganizeCode(!StringUtils.isEmpty(partInspection.getOrganizeCode())?partInspection.getOrganizeCode():AuthUtil.getOrganizeCode()); + ValidatorBean.checkNotNull(partInspection.getOrganizeCode(), "工厂不能为空"); return ResultBean.success("查询成功").setResultObject(ncProcessingService.queryPartInspection(partInspection)); } catch (ImppBusiException imppException) { return ResultBean.fail(imppException); @@ -67,8 +65,8 @@ public class MesNcProcessingController { public ResultBean queryPerson(String organizeCode) { try { - - return ResultBean.success("查询成功").setResultList(ncProcessingService.queryPerson(!StringUtils.isEmpty(organizeCode)?organizeCode:AuthUtil.getOrganizeCode())); + ValidatorBean.checkNotNull(organizeCode, "工厂不能为空"); + return ResultBean.success("查询成功").setResultList(ncProcessingService.queryPerson(organizeCode)); } catch (ImppBusiException imppException) { return ResultBean.fail(imppException); } catch (Exception e) { @@ -82,7 +80,8 @@ public class MesNcProcessingController { public ResultBean saveNc(@RequestBody MesNcProcessingInputModel model) { try { - // 数据校验 + ValidatorBean.checkNotNull(model.getOrganizeCode(), "工厂不能为空"); + ValidatorBean.checkNotNull(model.getUserName(), "操作人不能为空"); ValidatorBean.checkNotNull(model.getPartInspection(), "单据不能为空"); ValidatorBean.checkNotNull(model.getPartInspectionDetailList(), "单据明细不能为空"); if (model.getType() == MesExtEnumUtil.NC_TYPE.REWORK.getValue() @@ -102,7 +101,7 @@ public class MesNcProcessingController { if (CollectionUtils.isEmpty(model.getPartInspectionDetailList())) { throw new ImppBusiException("不存在可疑信息,请检查数据"); } - ncProcessingService.saveNc(model, !StringUtils.isEmpty(model.getOrganizeCode())? model.getOrganizeCode() : AuthUtil.getOrganizeCode(), false); + ncProcessingService.saveNc(model, model.getOrganizeCode(), false); return ResultBean.success("NC处理成功"); } catch (ImppBusiException imppException) { return ResultBean.fail(imppException); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesPartShippingGroupController.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesPartShippingGroupController.java index a298ad4..0f6c1b9 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesPartShippingGroupController.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesPartShippingGroupController.java @@ -60,10 +60,7 @@ public class MesPartShippingGroupController { try { // 数据校验 ValidatorBean.checkNotNull(model.getShippingGroupCode(), "发运组代码不能为空"); - List shippingOrderManagementList = shippingGroupService.doMesMesShippingOrderManagementPrint(model); - return ResultBean.success("发运单打印成功") - .setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()) - .setResultList(shippingOrderManagementList); + return shippingGroupService.doMesMesShippingOrderManagementPrint(model); } catch (ImppBusiException e) { return ResultBean.fail(e).build(); } catch (Exception e) { diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesPullingOrderInfoController.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesPullingOrderInfoController.java index ecc9636..9ff660f 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesPullingOrderInfoController.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesPullingOrderInfoController.java @@ -113,6 +113,46 @@ public class MesPullingOrderInfoController { return ResultBean.fail(e); } } + @PostMapping(value = "/new/doPrint") + @ApiOperation(value = "打印未打印拉动单后修改状态--带类型") + public ResultBean doMesPullingOrderInfoNewPrint(@RequestBody MesPullingOrderInfo mesPullingOrderInfo) { + try { + + if (StringUtils.isEmpty(mesPullingOrderInfo.getOrganizeCode())) { + throw new ImppBusiException("工厂不能为空"); + } + + if (StringUtils.isEmpty(mesPullingOrderInfo.getWorkCenterCode())) { + throw new ImppBusiException("产线不能为空"); + } + + if (StringUtils.isEmpty(mesPullingOrderInfo.getPullCode())) { + throw new ImppBusiException("拉动组不能为空"); + } + + if (StringUtils.isEmpty(mesPullingOrderInfo.getModifyUser())) { + throw new ImppBusiException("操作人不能为空"); + } + + String moduleKey = new StringJoiner(MesPcnExtConstWords.COLON) + .add(mesPullingOrderInfo.getOrganizeCode()) + .add("PRINT_PULLING_ORDER_INFO") + .add(mesPullingOrderInfo.getWorkCenterCode()).add(mesPullingOrderInfo.getPullCode()).toString(); + + synchronized (moduleKey.intern()) { + + List pullingOrderInfos = mesPullingOrderInfoService.doMesPullingOrderInfoPrint(mesPullingOrderInfo); + + return ResultBean.success(CollectionUtils.isEmpty(pullingOrderInfos) ? "查询暂无可打印数据!!!" : "打印队列查询成功!!!").setResultList(pullingOrderInfos); + + } + + } catch (ImppBusiException e) { + return ResultBean.fail(e).build(); + } catch (Exception e) { + return ResultBean.fail(e); + } + } @GetMapping("/template") @ApiOperation(value = "查询打印模板和明细") public ResultBean queryMesLabelTemplate(MesLabelTemplate labelTemplate ) { diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesWorkOrderController.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesWorkOrderController.java index 22bec65..2f0311f 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesWorkOrderController.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesWorkOrderController.java @@ -2,6 +2,7 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.busi; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesWorkOrderService; import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesWorkOrderExtModel; import cn.estsh.i3plus.pojo.base.common.Pager; import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil; import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder; @@ -64,9 +65,9 @@ public class MesWorkOrderController { @PostMapping(value = "/doProductReport") @ApiOperation(value = "生产报工") - public ResultBean doProductReport(MesWorkOrder mesWorkOrder) { + public ResultBean doProductReport(MesWorkOrderExtModel mesWorkOrder) { try { - workOrderService.doProductReport(mesWorkOrder, !StringUtils.isEmpty(mesWorkOrder.getModifyUser())?mesWorkOrder.getModifyUser():AuthUtil.getSessionUser().getUserName()); + workOrderService.doProductReport(mesWorkOrder, !StringUtils.isEmpty(mesWorkOrder.getModifyUser()) ? mesWorkOrder.getModifyUser() : AuthUtil.getSessionUser().getUserName()); return ResultBean.success("报工成功") .setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()); } catch (ImppBusiException e) { diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/model/MesPictureModel.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/model/MesPictureModel.java new file mode 100644 index 0000000..64d3d49 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/model/MesPictureModel.java @@ -0,0 +1,10 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.model; + +import lombok.Data; + +@Data +public class MesPictureModel { + private String file; + private String fileName; + private String organizeCode; +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/schedulejob/MesReportWorkByPreDayJob.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/schedulejob/MesReportWorkByPreDayJob.java index 0b3e4fa..cd1f37d 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/schedulejob/MesReportWorkByPreDayJob.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/schedulejob/MesReportWorkByPreDayJob.java @@ -27,8 +27,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; +import java.util.Date; import java.util.List; import java.util.stream.Collectors; @@ -79,44 +81,55 @@ public class MesReportWorkByPreDayJob extends BaseMesScheduleJob { if (CollectionUtils.isEmpty(mesProductionRecordList)) { continue; } - LOGGER.info("产线:{}报工mesProductionRecordList:{}", workCenterCode, mesProductionRecordList.size()); - //3.插入生产工单表 - List mesWorkOrders = workOrderService.insertMesWorkOrder(mesProductionRecordList, mesShiftList, wmsJobParamModel.getOrganizeCode(), userName); - if (CollectionUtils.isEmpty(mesWorkOrders)) { - continue; - } - LOGGER.info("产线:{}报工mesWorkOrders:{}", workCenterCode, mesWorkOrders.size()); - //4.根据产线+物料产生的工单报工 try { + LOGGER.info("产线:{}报工mesProductionRecordList:{}", workCenterCode, mesProductionRecordList.size()); + //3.插入生产工单表 + List mesWorkOrders = workOrderService.insertMesWorkOrder(mesProductionRecordList, mesShiftList, wmsJobParamModel.getOrganizeCode(), userName); + if (CollectionUtils.isEmpty(mesWorkOrders)) { + continue; + } + LOGGER.info("产线:{}报工mesWorkOrders:{}", workCenterCode, mesWorkOrders.size()); + //4.根据产线+物料产生的工单报工 for (MesWorkOrder mesWorkOrder : mesWorkOrders) { - List mesProductionRecords = mesProductionRecordList.stream().filter( + List mesProductionRecords = new ArrayList<>(); + try { + mesProductionRecords = mesProductionRecordList.stream().filter( w -> w.getWorkCenterCode().equalsIgnoreCase(mesWorkOrder.getWorkCenterCode()) && w.getPartNo().equalsIgnoreCase(mesWorkOrder.getPartNo())).collect(Collectors.toList()); workOrderService.doPcnJobProductReport(mesProductionRecords, mesShiftList, wmsJobParamModel.getOrganizeCode(), userName, mesWorkOrder); for (MesProductionRecord mesProductionRecord : mesProductionRecords) { - try { - if (StringUtil.isEmpty(mesProductionRecord.getWorkOrderNo())) { - List collect = mesWorkOrders.stream().filter(w -> w.getWorkCenterCode().equalsIgnoreCase(mesProductionRecord.getWorkCenterCode()) - && w.getPartNo().equalsIgnoreCase(mesProductionRecord.getPartNo())).collect(Collectors.toList()); - if (!CollectionUtils.isEmpty(collect)) { - mesProductionRecord.setWorkOrderNo(collect.get(0).getWorkOrderNo()); - } + + if (StringUtil.isEmpty(mesProductionRecord.getWorkOrderNo())) { + List collect = mesWorkOrders.stream().filter(w -> w.getWorkCenterCode().equalsIgnoreCase(mesProductionRecord.getWorkCenterCode()) + && w.getPartNo().equalsIgnoreCase(mesProductionRecord.getPartNo())).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(collect)) { + mesProductionRecord.setWorkOrderNo(collect.get(0).getWorkOrderNo()); } - mesProductionRecord.setReportStatus(MesExtEnumUtil.REPORT_STATUS.REPORT_STATUS_20.getValue()); - mesProductionRecord.setSystemSyncStatus(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()); - ConvertBean.serviceModelUpdate(mesProductionRecord, userName); - } catch (ImppBusiException e) { - String errorMsg = StringUtil.isEmpty(e.getErrorDetail()) ? e.getErrorMsg(): e.getErrorDetail(); - LOGGER.error("条码:{}报工失败,{}", mesProductionRecord.getProductSn(), errorMsg); - productionRecordService.updateProductionRecord(mesProductionRecord.getOrganizeCode(), userName, mesProductionRecord.getId(), errorMsg); - continue; } + mesProductionRecord.setReportStatus(MesExtEnumUtil.REPORT_STATUS.REPORT_STATUS_20.getValue()); + mesProductionRecord.setSystemSyncStatus(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()); + ConvertBean.serviceModelUpdate(mesProductionRecord, userName); + mesProductionRecord.setModifyDatetime((new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS")).format(new Date())); + } productionRecordRao.saveAll(mesProductionRecords); + } catch (ImppBusiException e) { + List snList = mesProductionRecords.stream().map(MesProductionRecord::getProductSn).collect(Collectors.toList()); + String errorMsg = StringUtil.isEmpty(e.getErrorDetail()) ? e.getErrorMsg() : e.getErrorDetail(); + LOGGER.info("条码:{}报工失败,{}", snList, errorMsg); + for (MesProductionRecord mesProductionRecord : mesProductionRecords) { + productionRecordService.updateProductionRecord(mesProductionRecord.getOrganizeCode(), userName, mesProductionRecord.getId(), errorMsg); + } + } } } catch (ImppBusiException e) { - LOGGER.error("产线:{}报工失败:{}", workCenterCode, e.getErrorDetail()); + List snList = mesProductionRecordList.stream().map(MesProductionRecord::getProductSn).collect(Collectors.toList()); + String errorMsg = StringUtil.isEmpty(e.getErrorDetail()) ? e.getErrorMsg() : e.getErrorDetail(); + LOGGER.info("条码:{}报工失败,{}", snList, errorMsg); + for (MesProductionRecord mesProductionRecord : mesProductionRecordList) { + productionRecordService.updateProductionRecord(mesProductionRecord.getOrganizeCode(), userName, mesProductionRecord.getId(), errorMsg); + } } } } 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 ea8f679..b463e6a 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 @@ -10,6 +10,7 @@ import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblyContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblyNosortContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblySortContext; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesReworkTaskModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesReworkTaskRequestModel; @@ -142,6 +143,18 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService { @Autowired private MesProductVersionRepository productVersionRepository; + @Autowired + private MesProductionRecordRepository productionRecordRepository; + + @Autowired + private IMesMoveRuleRepository mesMoveRuleRepository; + + @Autowired + private MesWorkOrderPartRepository workOrderPartRepository; + + @Autowired + private MesPartProdGroupRepository mesPartProdGroupRao; + @Override public ListPager queryReworkTask(MesReworkTask mesReworkTask, Pager pager) { String organizeCode = !StringUtils.isEmpty(mesReworkTask.getOrganizeCode())?mesReworkTask.getOrganizeCode():AuthUtil.getOrganizeCode(); @@ -297,6 +310,65 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService { // ConvertBean.serviceModelUpdate(mesPartInspection, requestModel.getUserName()); mesPartInspectionRepository.update(mesPartInspection); } + // 是否头零件模式 + boolean headModel = true; + if (!StringUtil.isEmpty(requestModel.getSn())) { + // 判断是头零件还是散件 查询加工记录 + DdlPackBean productionPackBean = DdlPackBean.getDdlPackBean(mesReworkTask.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(requestModel.getSn(), "productSn", productionPackBean); + DdlPreparedPack.getNumNOEqualPack(MesExtEnumUtil.REPORT_STATUS.REPORT_STATUS_30.getValue(), "reportStatus", productionPackBean); + DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.MES_REPORT_TYPE.CUSTOMER_SUPPLY_MOVE.getValue(), "reportType", productionPackBean); + MesProductionRecord record = productionRecordRepository.getByProperty(productionPackBean); + if (record != null) { + headModel = false; + } + } + // 如果是散件模式,需要查询出对应明细 + List mesPartModels = new ArrayList<>(); + if (!headModel) { + DdlPackBean partPackBean = DdlPackBean.getDdlPackBean(mesReworkTask.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(requestModel.getSn(), "workOrderNo", partPackBean); + List workOrderParts = workOrderPartRepository.findByHqlWhere(partPackBean); + if (!CollectionUtils.isEmpty(workOrderParts)) { + DdlPackBean partProdBean = DdlPackBean.getDdlPackBean(mesReworkTask.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(mesPartInspection.getWorkCenterCode(), "workCenterCode", partProdBean); + List mesPartProdGroupList = mesPartProdGroupRao.findByHqlTopWhere(partProdBean, 1); + for (MesWorkOrderPart workOrderPart : workOrderParts) { + MesPart partInfo = mesPartService.getMesPartByPartNo(workOrderPart.getPartNo(), mesReworkTask.getOrganizeCode()); + String esd = partInfo.getEsd(); + + // 查询移库规则 + DdlPackBean movePackBean = DdlPackBean.getDdlPackBean(mesReworkTask.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(esd, "srcType", movePackBean); + DdlPreparedPack.getStringEqualPack(mesPartProdGroupList.get(0).getPartProdGroupCode(), "code", movePackBean); + List moveRules = mesMoveRuleRepository.findByHqlWhere(movePackBean); + if (!CollectionUtils.isEmpty(moveRules)) { + MesPartModel mesPartModel = new MesPartModel(); + mesPartModel.setPartNo(workOrderPart.getPartNo()); + mesPartModel.setLocateNo(moveRules.get(0).getErpDestLocateNo()); + mesPartModels.add(mesPartModel); + } + } + } + } + + + + String target = mesConfigService.getCfgValue(requestModel.getOrganizeCode(), "UMLGO"); + String workCenterCode = ""; + if (mesPartInspection != null) { + workCenterCode = mesPartInspection.getWorkCenterCode(); + } + if (MesExtEnumUtil.NC_TYPE.REWORK.getValue() == requestModel.getType()) { + if (!headModel && !CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) { + String destLocateNo = getDestLocateNo(requestModel.getOrganizeCode(), mesPartInspection.getId()); + for (MesPartModel mesPartModel : mesPartModels) { + doCreateReworkMove(requestModel,destLocateNo, target, workCenterCode, mesPartModel.getPartNo(), mesPartInspection.getId()); + } + } else { + doCreateReworkMove(requestModel, getDestLocateNo(requestModel.getOrganizeCode(), mesPartInspection.getId()), target, workCenterCode, mesReworkTask.getPartNo(), mesPartInspection.getId()); + } + } } if (MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.LOT.getValue() == mesReworkTask.getType()) { mesReworkTask.setReworkedQty(requestModel.getReworkedQty()); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesTemplateServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesTemplateServiceImpl.java index 86eaeb7..992c00c 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesTemplateServiceImpl.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesTemplateServiceImpl.java @@ -7,15 +7,25 @@ import cn.estsh.i3plus.platform.common.util.MesPcnConstWords; 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.MesLabelTemplate; +import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplateFieldInfo; +import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplateFieldValue; import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplateParam; +import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateFieldInfoRepository; +import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateFieldValueRepository; import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateParamRepository; import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateRepository; +import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; +import cn.hutool.core.util.ObjectUtil; import org.apache.shiro.util.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.TreeMap; /** * @Description : 打印模板 @@ -33,6 +43,12 @@ public class MesTemplateServiceImpl implements IMesTemplateService { @Autowired private MesLabelTemplateParamRepository mesLabelTemplateParamRDao; + @Autowired + private MesLabelTemplateFieldInfoRepository labelTemplateFieldInfoRDao; + + @Autowired + private MesLabelTemplateFieldValueRepository labelTemplateFieldValueRDao; + @Override public MesLabelTemplate getMesLabelTemplate(String templateCode,String organizeCode) { // 根据标签模板代码,查询【MES_标签模板表】,获取对应的方法代码 @@ -70,4 +86,43 @@ public class MesTemplateServiceImpl implements IMesTemplateService { } return mesLabelTemplate; } + + @Override + public Map queryMesLabelTemplateParamPartValue(String partNo, String labelTemplate, String organizeCode) { + if (StringUtil.isEmpty(labelTemplate)) { + MesPcnException.throwMesBusiException("零件号【%s】未维护\"零件条码匹配模板\"字段值", partNo); + } + + Map result = new HashMap<>(); + List templateFieldInfos = labelTemplateFieldInfoRDao.findByProperty( + new String[]{"templateCode", "templateFieldType", MesPcnConstWords.IS_VALID, MesPcnConstWords.IS_DELETED, MesPcnConstWords.ORGANIZE_CODE}, + new Object[]{labelTemplate, MesExtEnumUtil.LABEL_TEMPLATE_FIELD_TYPE.CUSTOM.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), + CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), organizeCode}); + Map templateFieldInfoMap = new TreeMap<>(); + for (MesLabelTemplateFieldInfo info : templateFieldInfos) { + templateFieldInfoMap.putIfAbsent(info.getTemplateParam(), info); + } + + List fieldValueList = labelTemplateFieldValueRDao.findByProperty( + new String[]{"partNo", "templateCode", MesPcnConstWords.IS_VALID, MesPcnConstWords.IS_DELETED, MesPcnConstWords.ORGANIZE_CODE}, + new Object[]{partNo, labelTemplate, CommonEnumUtil.IS_VAILD.VAILD.getValue(), + CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), organizeCode}); + if (!CollectionUtils.isEmpty(fieldValueList)) { + for (MesLabelTemplateFieldValue fieldValue : fieldValueList) { + if (StringUtil.isEmpty(fieldValue.getTemplateParam())) { + continue; + } + MesLabelTemplateFieldInfo templateFieldInfo = templateFieldInfoMap.remove(fieldValue.getTemplateParam()); + if (templateFieldInfo != null) { + result.put(templateFieldInfo.getTemplateParam(), ObjectUtil.clone(fieldValue.getFieldValue())); + } + } + } + + for (Map.Entry entry : templateFieldInfoMap.entrySet()) { + MesLabelTemplateFieldInfo fieldInfo = entry.getValue(); + result.put(fieldInfo.getTemplateParam(), null); + } + return result; + } } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesCutRawErrorProofingService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesCutRawErrorProofingService.java index b4d70f5..02bf40c 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesCutRawErrorProofingService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesCutRawErrorProofingService.java @@ -172,6 +172,7 @@ public class MesCutRawErrorProofingService implements IMesCutRawErrorProofingSer modifyRawLengthRecord.setLength(materialSnDb.getLength()); modifyRawLengthRecord.setSubLength(materialSnDb.getSurplusLength()); modifyRawLengthRecord.setSn(model.getSn()); + modifyRawLengthRecord.setPartNo(materialSnDb.getPartNo()); modifyRawLengthRecord.setCutWorkOrderNo(model.getCutWorkOrderNo()); modifyRawLengthRecord.setType(MesExtEnumUtil.CUT_RAW_LENGTH_TYPE.ORDER.getValue()); modifyRawLengthRecord.setOrganizeCode(model.getOrganizeCode()); @@ -234,6 +235,7 @@ public class MesCutRawErrorProofingService implements IMesCutRawErrorProofingSer modifyRawLengthRecord.setModifyReason(model.getModifyReason()); modifyRawLengthRecord.setType(MesExtEnumUtil.CUT_RAW_LENGTH_TYPE.OTHER.getValue()); modifyRawLengthRecord.setOrganizeCode(model.getOrganizeCode()); + modifyRawLengthRecord.setPartNo(model.getPartNo()); cutModifyRawLengthRecordRepository.save(modifyRawLengthRecord); } 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 a3ccafe..665dd30 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 @@ -10,6 +10,7 @@ import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException; import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionInputModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionViewModel; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService; import cn.estsh.i3plus.platform.common.convert.ConvertBean; @@ -27,7 +28,6 @@ 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; -import cn.estsh.impp.framework.boot.auth.AuthUtil; import cn.estsh.impp.framework.boot.exception.ImppBusiException; import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder; import cn.estsh.impp.framework.boot.util.ResultBean; @@ -42,7 +42,6 @@ import org.springframework.util.StringUtils; import java.util.*; import java.util.stream.Collectors; -import java.util.stream.Stream; /** * @Description : @@ -117,55 +116,67 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService @Autowired private MesWorkCenterPartRelationRepository workCenterPartRelationRepository; + @Autowired + private MesProductionRecordRepository productionRecordRepository; + + @Autowired + private IMesMoveRuleRepository mesMoveRuleRepository; + + @Autowired + private MesWorkOrderPartRepository workOrderPartRepository; + + @Autowired + private MesPartProdGroupRepository mesPartProdGroupRao; + @Override - public MesPartInspectionViewModel queryPartInspection(MesPartInspectionInputModel inputModel, String org) { + public MesPartInspectionViewModel queryPartInspection(MesPartInspectionInputModel model) { //检查物料 MesPart part; //获取NC-零件检测-单据 MesPartInspection partInspection = null; - Integer sourceType = null; - if (!StringUtils.isEmpty(inputModel.getSn())) { + Integer sourceType; + if (!StringUtils.isEmpty(model.getSn())) { // 数据校验 - ValidatorBean.checkNotNull(inputModel.getFrontBack(), "正反面不能为空"); + ValidatorBean.checkNotNull(model.getFrontBack(), "正反面不能为空"); //检查条码 - MesProduceSn produceSn = checkProduceSn(inputModel.getSn(), org); + MesProduceSn produceSn = checkProduceSn(model.getSn(), model.getOrganizeCode()); //获取NC-零件检测-单据 - partInspection = getPartInspection(produceSn,inputModel, org); + partInspection = getPartInspection(produceSn, model, model.getOrganizeCode()); //检查物料 - part = checkPart(produceSn, org); + part = checkPart(produceSn, model.getOrganizeCode()); sourceType = MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue(); } else { // 数据校验 - ValidatorBean.checkNotNull(inputModel.getPartNo(), "物料不能为空"); - ValidatorBean.checkNotNull(inputModel.getLotNo(), "批次不能为空"); - ValidatorBean.checkNotNull(inputModel.getFrontBack(), "正反面不能为空"); - ValidatorBean.checkNotNull(inputModel.getQty(), "数量不能为空"); + ValidatorBean.checkNotNull(model.getPartNo(), "物料不能为空"); + ValidatorBean.checkNotNull(model.getLotNo(), "批次不能为空"); + ValidatorBean.checkNotNull(model.getFrontBack(), "正反面不能为空"); + ValidatorBean.checkNotNull(model.getQty(), "数量不能为空"); //检查物料 - part = checkPartByPartNo(inputModel.getPartNo(), org); + part = checkPartByPartNo(model.getPartNo(), model.getOrganizeCode()); //获取NC-零件检测-单据 - if(!Objects.isNull(inputModel.getId())){ - partInspection = getPartInspectionByPartAndLot(inputModel, org); + if(!Objects.isNull(model.getId())){ + partInspection = getPartInspectionByPartAndLot(model, model.getOrganizeCode()); } sourceType = MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.LOT.getValue(); } //检查零件类型与图片对应关系 - MesPartTypePicture partTypePicture = checkPartTypePicture(part, org); + MesPartTypePicture partTypePicture = checkPartTypePicture(part, model.getOrganizeCode()); //构造返回信息 - MesPartInspectionViewModel model = getModel(partInspection, part, partTypePicture, inputModel, sourceType, org); - model.setSourceType(sourceType); - model.setTransferFlg(inputModel.isTransferFlg()); + MesPartInspectionViewModel result = getModel(partInspection, part, partTypePicture, model, sourceType); + result.setSourceType(sourceType); + result.setTransferFlg(model.isTransferFlg()); - return model; + return result; } /** @@ -222,12 +233,11 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService * 完成质检-保存不良记录 * * @param model - * @param org */ @Override - public void savePartInspection(MesPartInspectionInputModel model, String org) { + public void savePartInspection(MesPartInspectionInputModel model) { - MesProduceSn produceSn = getProduceSn(model.getSn(), org); + MesProduceSn produceSn = getProduceSn(model.getSn(), model.getOrganizeCode()); if (null != produceSn && StringUtils.isEmpty(model.getPartNo())) model.setPartNo(produceSn.getPartNo()); //武汉 会输入客户条码 boolean isWorkOrderQcStatus=false; @@ -235,7 +245,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService model.setCustSn(produceSn.getCustSn()); model.setSn(produceSn.getProductSn()); //排序产线 更新工单的 qcStatus - MesWorkCenter centerDb = prodOrgExtService.getWorkCenterDb(org, produceSn.getWorkCenterCode()); + MesWorkCenter centerDb = prodOrgExtService.getWorkCenterDb(model.getOrganizeCode(), produceSn.getWorkCenterCode()); if (!StringUtil.isEmpty(centerDb)){ isWorkOrderQcStatus= centerDb.getCenterType() == MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue(); } @@ -245,8 +255,52 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService model.getPartInspection().setQmsSync(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()); } if(!Objects.isNull(model.getPart())){ - model.setPart(mesPartService.getMesPartSapByPartNo(model.getPart().getPartNo(), org)); + model.setPart(mesPartService.getMesPartSapByPartNo(model.getPart().getPartNo(), model.getOrganizeCode())); + } + + // 是否头零件模式 + boolean headModel = true; + if (!StringUtil.isEmpty(model.getSn())) { + // 判断是头零件还是散件 查询加工记录 + DdlPackBean productionPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(model.getSn(), "productSn", productionPackBean); + DdlPreparedPack.getNumNOEqualPack(MesExtEnumUtil.REPORT_STATUS.REPORT_STATUS_30.getValue(), "reportStatus", productionPackBean); + DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.MES_REPORT_TYPE.CUSTOMER_SUPPLY_MOVE.getValue(), "reportType", productionPackBean); + MesProductionRecord record = productionRecordRepository.getByProperty(productionPackBean); + if (record != null) { + headModel = false; + } + } + // 如果是散件模式,需要查询出对应明细 + List mesPartModels = new ArrayList<>(); + if (!headModel) { + DdlPackBean partPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(model.getSn(), "workOrderNo", partPackBean); + List workOrderParts = workOrderPartRepository.findByHqlWhere(partPackBean); + if (!CollectionUtils.isEmpty(workOrderParts)) { + DdlPackBean partProdBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(produceSn.getWorkCenterCode(), "workCenterCode", partProdBean); + List mesPartProdGroupList = mesPartProdGroupRao.findByHqlTopWhere(partProdBean, 1); + for (MesWorkOrderPart workOrderPart : workOrderParts) { + MesPart partInfo = mesPartService.getMesPartByPartNo(workOrderPart.getPartNo(), model.getOrganizeCode()); + String esd = partInfo.getEsd(); + + // 查询移库规则 + DdlPackBean movePackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(esd, "srcType", movePackBean); + DdlPreparedPack.getStringEqualPack(mesPartProdGroupList.get(0).getPartProdGroupCode(), "code", movePackBean); + List moveRules = mesMoveRuleRepository.findByHqlWhere(movePackBean); + if (!CollectionUtils.isEmpty(moveRules)) { + MesPartModel mesPartModel = new MesPartModel(); + mesPartModel.setPartNo(workOrderPart.getPartNo()); + mesPartModel.setLocateNo(moveRules.get(0).getErpDestLocateNo()); + mesPartModels.add(mesPartModel); + } + } + } } + + //零件检测详情为空,则代表本次校验为合格。 if (CollectionUtils.isEmpty(model.getPartInspectionDetailList())) { MesPartInspection partInspection = null; @@ -257,23 +311,45 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService //若检验单为空,则生成新的单据并合格 if (StringUtils.isEmpty(model.getPartInspection())) { - partInspection = createPartInspection(model, MesExtEnumUtil.PART_INSPECTION_STATUS.QUALIFIED.getValue(), org); + partInspection = createPartInspection(model, MesExtEnumUtil.PART_INSPECTION_STATUS.QUALIFIED.getValue(), model.getOrganizeCode()); if (model.getOptType() != null && model.getOptType() == 2) { partInspection.setRefundFlag(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()); } partInspection = partInspectionRepository.save(partInspection); if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) { + //已创建返修单 + DdlPackBean reworkPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(model.getSn(), "sn", reworkPackBean); + DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.REWORK_TASK_STATUS.FINISH.getValue(), "status", reworkPackBean); + + DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, reworkPackBean); + int count = reworkTaskRepository.findByHqlWhereCount(reworkPackBean); + if (count > 0) { + // 如果是批次还需要移库 + DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(model.getPartNo(), "partNo", ddlPackBean); + MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean); + String srcNo = configService.getCfgValue(model.getOrganizeCode(), "LGORT"); + if (version != null) { + srcNo = version.getReceiveInventoryPoint(); + } + String destLocateNo = getDestLocateNo(model, model.getOrganizeCode()); + if(!model.isTransferFlg() && !Objects.equals(srcNo, destLocateNo)) { + throw new ImppBusiException(String.format("【%s】该条码需要完成质检,再重新录入电子化检验", model.getSn())); + } + } + checkProduceSn(produceSn, model.getSn()); produceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue()); - ConvertBean.serviceModelInitialize(produceSn, AuthUtil.getSessionUser().getUserName()); + ConvertBean.serviceModelInitialize(produceSn, model.getUserInfo()); produceSnExtService.update(produceSn); //更新工单对应qcStatus if(isWorkOrderQcStatus){ - MesWorkOrder workOrder = getWorkOrder(org,produceSn.getWorkOrderNo()); + MesWorkOrder workOrder = getWorkOrder(model.getOrganizeCode(), produceSn.getWorkOrderNo()); if (!StringUtil.isEmpty(workOrder)){ workOrder.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue()); - ConvertBean.serviceModelUpdate(workOrder, AuthUtil.getSessionUser().getUserName()); + ConvertBean.serviceModelUpdate(workOrder, model.getUserInfo()); workOrderRepository.update(workOrder); } } @@ -284,7 +360,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService //原单据不合格 现合格 if (model.getPartInspection().getInspectionStatus() == MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue()) { model.getPartInspection().setInspectionStatus(MesExtEnumUtil.PART_INSPECTION_STATUS.QUALIFIED.getValue()); - ConvertBean.serviceModelUpdate(model.getPartInspection(), AuthUtil.getSessionUser().getUserName()); + ConvertBean.serviceModelUpdate(model.getPartInspection(), model.getUserInfo()); if (model.getOptType() != null && model.getOptType() == 2) { model.getPartInspection().setRefundFlag(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()); @@ -292,13 +368,13 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService partInspectionRepository.save(model.getPartInspection()); //查询当前单据明细 - List resultDetailList = queryResultDetailList(model, org); + List resultDetailList = queryResultDetailList(model, model.getOrganizeCode()); List defectTypeNoExitList = new ArrayList<>(); for (MesPartInspectionDetail detail : model.getPartInspectionDetailList()) { //根据页面上选择的位置 查询位置,若不存在则提示 位置不存在,请检查数据 - DdlPackBean packBean = DdlPackBean.getDdlPackBean(org); + DdlPackBean packBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode()); DdlPreparedPack.getStringEqualPack(detail.getDefectLocation(), "defectTypeCode", packBean); DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.DEFECT_CATEGORY.POSITION.getValue(), "defectType", packBean); MesDefectType defectType = defectTypeRepository.getByProperty(packBean); @@ -310,10 +386,10 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService detail.setDefectTypeId(defectType.getId()); detail.setId(null); - detail.setOrganizeCode(org); + detail.setOrganizeCode(model.getOrganizeCode()); detail.setPid(model.getPartInspection().getId()); setSystemSyncStatus(detail); - ConvertBean.serviceModelInitialize(detail, AuthUtil.getSessionUser().getUserName()); + ConvertBean.serviceModelInitialize(detail, model.getUserInfo()); } if (!CollectionUtils.isEmpty(defectTypeNoExitList)) { @@ -326,38 +402,48 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) { checkProduceSn(produceSn, model.getSn()); produceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue()); - ConvertBean.serviceModelInitialize(produceSn, AuthUtil.getSessionUser().getUserName()); + ConvertBean.serviceModelInitialize(produceSn, model.getUserInfo()); produceSnExtService.update(produceSn); //更新工单对应qcStatus if(isWorkOrderQcStatus){ - MesWorkOrder workOrder = getWorkOrder(org,produceSn.getWorkOrderNo()); + MesWorkOrder workOrder = getWorkOrder(model.getOrganizeCode(), produceSn.getWorkOrderNo()); if (!StringUtil.isEmpty(workOrder)){ workOrder.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue()); - ConvertBean.serviceModelUpdate(workOrder, AuthUtil.getSessionUser().getUserName()); + ConvertBean.serviceModelUpdate(workOrder, model.getUserInfo()); workOrderRepository.update(workOrder); } } } //移库 String srcLocate; - MesMove mesMove = getMesMove(model, org); + MesMove mesMove = getMesMove(model, model.getOrganizeCode()); if(!Objects.isNull(mesMove)){ srcLocate = mesMove.getUmlgo(); }else{ - srcLocate= configService.getCfgValue(org, "UMLGO"); + srcLocate= configService.getCfgValue(model.getOrganizeCode(), "UMLGO"); } if (model.getOptType() != 2) { - //移库 - MesMove move = createMove(model, srcLocate, configService.getCfgValue(org, "LGORT"), org, null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode()); - moveRepository.save(move); + + if (!headModel && !CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) { + for (MesPartModel mesPartModel : mesPartModels) { + //移库 + MesMove move = createMove(model, srcLocate, mesPartModel.getLocateNo(), model.getOrganizeCode(), null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode(),mesPartModel.getPartNo()); + moveRepository.save(move); + } + } else { + //移库 + MesMove move = createMove(model, srcLocate, configService.getCfgValue(model.getOrganizeCode(), "LGORT"), model.getOrganizeCode(), null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode()); + moveRepository.save(move); + } + } } } if (model.isTransferFlg() && model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) { //电子化检验 - String target = configService.getCfgValue(org, "LGORT"); + String target = configService.getCfgValue(model.getOrganizeCode(), "LGORT"); - DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(org); + DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode()); DdlPreparedPack.getStringEqualPack(model.getPartNo(), "partNo", ddlPackBean); MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean); @@ -368,9 +454,16 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService if (partInspection != null) { model.setPartInspection(partInspection); } - MesMove move = createMove(model, getDestLocateNo(model, org), target, org, null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode()); - moveRepository.save(move); - + if (!headModel && !CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) { + String locateNo = getDestLocateNo(model, model.getOrganizeCode()); + for (MesPartModel mesPartModel : mesPartModels) { + MesMove move = createMove(model,locateNo , mesPartModel.getLocateNo(), model.getOrganizeCode(), null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode(), mesPartModel.getPartNo()); + moveRepository.save(move); + } + } else { + MesMove move = createMove(model, getDestLocateNo(model, model.getOrganizeCode()), target, model.getOrganizeCode(), null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode()); + moveRepository.save(move); + } } } else { //零件检测详情不为空,则代表本次校验为不合格。 @@ -380,7 +473,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService if (StringUtils.isEmpty(model.getPartInspection())) { - partInspection = createPartInspection(model, MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue(), org); + partInspection = createPartInspection(model, MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue(), model.getOrganizeCode()); if (model.getOptType() != null && model.getOptType() == 2) { partInspection.setRefundFlag(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()); @@ -392,7 +485,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService for (MesPartInspectionDetail detail : model.getPartInspectionDetailList()) { //根据页面上选择的位置 查询位置,若不存在则提示 位置不存在,请检查数据 - DdlPackBean packBean = DdlPackBean.getDdlPackBean(org); + DdlPackBean packBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode()); DdlPreparedPack.getStringEqualPack(detail.getDefectLocation(), "defectTypeCode", packBean); DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.DEFECT_CATEGORY.POSITION.getValue(), "defectType", packBean); MesDefectType defectType = defectTypeRepository.getByProperty(packBean); @@ -404,10 +497,10 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService detail.setDefectTypeId(defectType.getId()); detail.setId(null); - detail.setOrganizeCode(org); + detail.setOrganizeCode(model.getOrganizeCode()); detail.setPid(partInspection.getId()); setSystemSyncStatus(detail); - ConvertBean.serviceModelInitialize(detail, AuthUtil.getSessionUser().getUserName()); + ConvertBean.serviceModelInitialize(detail, model.getUserInfo()); } if (!CollectionUtils.isEmpty(defectTypeNoExitList)) { @@ -420,26 +513,40 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService //若是扫描条码 则判定条码可疑 if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) { //已创建返修单 - DdlPackBean reworkPackBean = DdlPackBean.getDdlPackBean(org); + DdlPackBean reworkPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode()); DdlPreparedPack.getStringEqualPack(model.getSn(), "sn", reworkPackBean); DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.REWORK_TASK_STATUS.FINISH.getValue(), "status", reworkPackBean); DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, reworkPackBean); int count = reworkTaskRepository.findByHqlWhereCount(reworkPackBean); if (count > 0) { - throw new ImppBusiException(String.format("【%s】该条码需要完成质检,再重新录入电子化检验", model.getSn())); + // 如果是批次还需要移库 + DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(model.getPartNo(), "partNo", ddlPackBean); + MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean); + String srcNo = configService.getCfgValue(model.getOrganizeCode(), "LGORT"); + if (version != null) { + srcNo = version.getReceiveInventoryPoint(); + } + if (!headModel) { + srcNo = mesPartModels.get(0).getLocateNo(); + } + String destLocateNo = getDestLocateNo(model, model.getOrganizeCode()); + if(!Objects.equals(srcNo, destLocateNo)) { + throw new ImppBusiException(String.format("【%s】该条码需要完成质检,再重新录入电子化检验", model.getSn())); + } } checkProduceSn(produceSn, model.getSn()); produceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue()); - ConvertBean.serviceModelInitialize(produceSn, AuthUtil.getSessionUser().getUserName()); + ConvertBean.serviceModelInitialize(produceSn, model.getUserInfo()); produceSnExtService.update(produceSn); //更新工单对应qcStatus if(isWorkOrderQcStatus){ - MesWorkOrder workOrder = getWorkOrder(org,produceSn.getWorkOrderNo()); + MesWorkOrder workOrder = getWorkOrder(model.getOrganizeCode(), produceSn.getWorkOrderNo()); if (!StringUtil.isEmpty(workOrder)){ workOrder.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue()); - ConvertBean.serviceModelUpdate(workOrder, AuthUtil.getSessionUser().getUserName()); + ConvertBean.serviceModelUpdate(workOrder, model.getUserInfo()); workOrderRepository.update(workOrder); } } @@ -448,9 +555,9 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService // srcLocateNo = getDestLocateNo(model, org); } if (Objects.isNull(srcLocateNo)) { - srcLocateNo = configService.getCfgValue(org, "LGORT"); + srcLocateNo = configService.getCfgValue(model.getOrganizeCode(), "LGORT"); - DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(org); + DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode()); DdlPreparedPack.getStringEqualPack(model.getPartNo(), "partNo", ddlPackBean); MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean); @@ -461,7 +568,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService String workCenterCode; if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) { if (null == produceSn || StringUtils.isEmpty(produceSn.getProcessCode())) { - List workCenterPartRelationList = getWorkCenterPartRelation(org, model.getPartNo()); + List workCenterPartRelationList = getWorkCenterPartRelation(model.getOrganizeCode(), model.getPartNo()); if (CollectionUtils.isEmpty(workCenterPartRelationList) || workCenterPartRelationList.size() > 1 || StringUtils.isEmpty(workCenterPartRelationList.get(0).getWorkCenterCode())) { throw new ImppBusiException(String.format("条码[%s]未查询到有效的来源库位!", model.getSn())); } @@ -473,7 +580,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService workCenterCode = model.getWorkCenterCode(); } - MesWorkCenter workCenter = prodOrgExtService.getWorkCenterDb(org, workCenterCode); + MesWorkCenter workCenter = prodOrgExtService.getWorkCenterDb(model.getOrganizeCode(), workCenterCode); if (null == workCenter) throw new ImppBusiException(String.format("条码[%s]查询来源库位时获取的生产线代码[%s]信息不存在!", model.getSn(), workCenterCode)); if (StringUtils.isEmpty(workCenter.getRawLocate())) throw new ImppBusiException(String.format("条码[%s]查询来源库位时获取的生产线代码[%s]信息未维护[材料库位]!", model.getSn(), workCenterCode)); srcLocateNo = workCenter.getRawLocate(); @@ -483,33 +590,41 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService if (model.getOptType() != 2) { //移库 //移库 - String dest = configService.getCfgValue(org, "UMLGO"); + String dest = configService.getCfgValue(model.getOrganizeCode(), "UMLGO"); if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()){ - String destLocateNo = getDestLocateNo(model, org); + String destLocateNo = getDestLocateNo(model, model.getOrganizeCode()); if (!StringUtils.isEmpty(destLocateNo) && Objects.equals(dest, destLocateNo)) { return; } } - MesMove move = createMove(model, srcLocateNo, dest, org, null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode()); - moveRepository.save(move); + if (!headModel && !CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) { + for (MesPartModel mesPartModel : mesPartModels) { + MesMove move = createMove(model, mesPartModel.getLocateNo(), dest, model.getOrganizeCode(), null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode(), mesPartModel.getPartNo()); + moveRepository.save(move); + } + } else{ + MesMove move = createMove(model, srcLocateNo, dest, model.getOrganizeCode(), null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode()); + moveRepository.save(move); + } + } } else { model.getPartInspection().setInspectionStatus(MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue()); - ConvertBean.serviceModelUpdate(model.getPartInspection(), AuthUtil.getSessionUser().getUserName()); + ConvertBean.serviceModelUpdate(model.getPartInspection(), model.getUserInfo()); if (model.getOptType() != null && model.getOptType() == 2) { model.getPartInspection().setRefundFlag(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()); } partInspectionRepository.save(model.getPartInspection()); //查询当前单据明细 - List resultDetailList = queryResultDetailList(model, org); + List resultDetailList = queryResultDetailList(model, model.getOrganizeCode()); List defectTypeNoExitList = new ArrayList<>(); for (MesPartInspectionDetail detail : model.getPartInspectionDetailList()) { //根据页面上选择的位置 查询位置,若不存在则提示 位置不存在,请检查数据 - DdlPackBean packBean = DdlPackBean.getDdlPackBean(org); + DdlPackBean packBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode()); DdlPreparedPack.getStringEqualPack(detail.getDefectLocation(), "defectTypeCode", packBean); DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.DEFECT_CATEGORY.POSITION.getValue(), "defectType", packBean); MesDefectType defectType = defectTypeRepository.getByProperty(packBean); @@ -521,10 +636,10 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService detail.setDefectTypeId(defectType.getId()); detail.setId(null); - detail.setOrganizeCode(org); + detail.setOrganizeCode(model.getOrganizeCode()); detail.setPid(model.getPartInspection().getId()); setSystemSyncStatus(detail); - ConvertBean.serviceModelInitialize(detail, AuthUtil.getSessionUser().getUserName()); + ConvertBean.serviceModelInitialize(detail, model.getUserInfo()); } if (!CollectionUtils.isEmpty(defectTypeNoExitList)) { @@ -535,26 +650,37 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) { //已创建返修单 - DdlPackBean reworkPackBean = DdlPackBean.getDdlPackBean(org); + DdlPackBean reworkPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode()); DdlPreparedPack.getStringEqualPack(model.getSn(), "sn", reworkPackBean); DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.REWORK_TASK_STATUS.FINISH.getValue(), "status", reworkPackBean); DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, reworkPackBean); int count = reworkTaskRepository.findByHqlWhereCount(reworkPackBean); if (count > 0) { - throw new ImppBusiException(String.format("【%s】该条码需要完成质检,再重新录入电子化检验", model.getSn())); + // 如果是批次还需要移库 + DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(model.getPartNo(), "partNo", ddlPackBean); + MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean); + String srcNo = configService.getCfgValue(model.getOrganizeCode(), "LGORT"); + if (version != null) { + srcNo = version.getReceiveInventoryPoint(); + } + String destLocateNo = getDestLocateNo(model, model.getOrganizeCode()); + if (!Objects.equals(srcNo, destLocateNo)) { + throw new ImppBusiException(String.format("【%s】该条码需要完成质检,再重新录入电子化检验", model.getSn())); + } } checkProduceSn(produceSn, model.getSn()); produceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue()); - ConvertBean.serviceModelInitialize(produceSn, AuthUtil.getSessionUser().getUserName()); + ConvertBean.serviceModelInitialize(produceSn, model.getUserInfo()); produceSnExtService.update(produceSn); //更新工单对应qcStatus if(isWorkOrderQcStatus){ - MesWorkOrder workOrder = getWorkOrder(org,produceSn.getWorkOrderNo()); + MesWorkOrder workOrder = getWorkOrder(model.getOrganizeCode(), produceSn.getWorkOrderNo()); if (!StringUtil.isEmpty(workOrder)){ workOrder.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue()); - ConvertBean.serviceModelUpdate(workOrder, AuthUtil.getSessionUser().getUserName()); + ConvertBean.serviceModelUpdate(workOrder, model.getUserInfo()); workOrderRepository.update(workOrder); } } @@ -564,9 +690,9 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService //移库 if (model.getOptType() != 2) { - String srcLocateNo = configService.getCfgValue(org, "LGORT"); + String srcLocateNo = configService.getCfgValue(model.getOrganizeCode(), "LGORT"); - DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(org); + DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode()); DdlPreparedPack.getStringEqualPack(model.getPartNo(), "partNo", ddlPackBean); MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean); @@ -574,15 +700,24 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService srcLocateNo = version.getReceiveInventoryPoint(); } //移库 - String dest = configService.getCfgValue(org, "UMLGO"); + String dest = configService.getCfgValue(model.getOrganizeCode(), "UMLGO"); if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()){ - String destLocateNo = getDestLocateNo(model, org); + String destLocateNo = getDestLocateNo(model, model.getOrganizeCode()); if (!StringUtils.isEmpty(destLocateNo) && Objects.equals(dest, destLocateNo)) { return; } } - MesMove move = createMove(model, srcLocateNo, dest, org, null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode()); - moveRepository.save(move); + if (!headModel && !CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) { + for (MesPartModel mesPartModel : mesPartModels) { + //移库 + MesMove move = createMove(model, mesPartModel.getLocateNo(), dest, model.getOrganizeCode(), null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode(),mesPartModel.getPartNo()); + moveRepository.save(move); + } + } else{ + MesMove move = createMove(model, srcLocateNo, dest, model.getOrganizeCode(), null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode()); + moveRepository.save(move); + } + } } @@ -684,7 +819,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService resultDetailList.forEach(k -> { k.setIsDeleted(MesCommonConstant.TRUE_INTEGER); setSystemSyncStatus(k); - ConvertBean.serviceModelUpdate(model.getPartInspection(), AuthUtil.getSessionUser().getUserName()); + ConvertBean.serviceModelUpdate(model.getPartInspection(), model.getUserInfo()); }); return resultDetailList; @@ -831,10 +966,9 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService partInspection.setWorkCenterCode(model.getWorkCenterCode()); partInspection.setShiftCode(model.getShiftCode()); partInspection.setSourceType(model.getSourceType()); -// ConvertBean.serviceModelInitialize(partInspection, AuthUtil.getSessionUser().getUserName()); //42984 初检创建时修改人和修改时间不能赋值 partInspection.setCreateDatetime(TimeTool.getNowTime(true)); - partInspection.setCreateUser(AuthUtil.getSessionUser().getUserName()); + partInspection.setCreateUser(model.getUserInfo()); partInspection.setIsValid(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()); partInspection.setIsDeleted(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()); return partInspection; @@ -878,6 +1012,43 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService return move; } + /** + * 移库 + * + * @param model + * @param source 来源 + * @param target 目标 + * @param org + * @return + */ + private MesMove createMove(MesPartInspectionInputModel model, String source, String target, String org, String workCenterCode, String partNo) { + if (StringUtils.isEmpty(model.getUserInfo())) model.setUserInfo("系统"); + GenSerialNoModel serialNoModel = new GenSerialNoModel("INPUT_DEFECT_ZRSUM"); + serialNoModel.setPartNo(partNo); + ResultBean rb = syncFuncService.syncSerialNo(serialNoModel, model.getUserInfo(), org, 1); + String zrsum = ""; + if (null != rb && !CollectionUtils.isEmpty(rb.getResultList())) { + zrsum = (rb.getResultList().get(0)).toString(); + } + + MesMove move = new MesMove(); + move.setMatnr(partNo); + move.setOrganizeCode(org); + move.setFactoryCode(org); + move.setLgort(source); + move.setUmlgo(target); + move.setMenge(model.getQty()); + move.setMeins(model.getPart().getUnit()); + move.setZrsum(zrsum); + move.setPostDate(TimeTool.getToday()); + move.setPostTime(TimeTool.getTimeShortWithColon()); + move.setPartInspectionId(Objects.isNull(model.getPartInspection()) ? 0 : model.getPartInspection().getId()); + move.setMoveType(MesExtEnumUtil.MOVE_TYPE.SUSPICIOUS_MOVE.getValue()); + move.setProductSn(model.getSn()); + move.setWorkCenter(prodOrgExtService.getErpWorkCenterCode(org, workCenterCode)); + ConvertBean.serviceModelInitialize(move, model.getUserInfo()); + return move; + } private MesPart checkPart(MesProduceSn produceSn, String org) { DdlPackBean packBean = DdlPackBean.getDdlPackBean(org); @@ -973,29 +1144,28 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService return alarmConfigList; } - private MesPartInspectionViewModel getModel(MesPartInspection partInspection, MesPart part,MesPartTypePicture partTypePicture, MesPartInspectionInputModel inputModel , - Integer sourceType, String org) { + private MesPartInspectionViewModel getModel(MesPartInspection partInspection, MesPart part, MesPartTypePicture partTypePicture, MesPartInspectionInputModel model, Integer sourceType) { - Integer frontBack = inputModel.getFrontBack(); + Integer frontBack = model.getFrontBack(); List detailList = new ArrayList<>(); if (!StringUtils.isEmpty(partInspection) && partInspection.getInspectionStatus() != MesExtEnumUtil.PART_INSPECTION_STATUS.QUALIFIED.getValue()) { - detailList = checkPartInspectionDetail(partInspection, org); + detailList = checkPartInspectionDetail(partInspection, model.getOrganizeCode()); if(!CollectionUtils.isEmpty(detailList)){ //判断是否返工完成 - checkReworkFinished(org, detailList); + checkReworkFinished(model.getOrganizeCode(), detailList); } } //位置 - List locationConfigList = checkLocationConfig(org); + List locationConfigList = checkLocationConfig(model.getOrganizeCode()); List locationCodeList = locationConfigList.stream().map(k -> k.getDefectLocation()).collect(Collectors.toList()); //查询零件类型缺陷类型对应关系 - List partTypeDefectList = checkPartTypeDefect(part, org); + List partTypeDefectList = checkPartTypeDefect(part, model.getOrganizeCode()); List partTypeDefectCodeList = partTypeDefectList.stream().map(k -> k.getDefectTypeCode()).collect(Collectors.toList()); //查询预警数量 - List alarmConfigList = queryDefectAlarmConfigByLocationCodeList(part, frontBack, locationCodeList, partTypeDefectCodeList, org); + List alarmConfigList = queryDefectAlarmConfigByLocationCodeList(part, frontBack, locationCodeList, partTypeDefectCodeList, model.getOrganizeCode()); //根据不良类型+位置 若有数据,则表示需要标黄 Map> alarmConfigMap = alarmConfigList.stream().collect(Collectors.groupingBy(MesDefectWarnConfig::getDefectLocation)); @@ -1017,17 +1187,17 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService } }); - MesPartInspectionViewModel model = new MesPartInspectionViewModel(); - model.setPart(part); + MesPartInspectionViewModel result = new MesPartInspectionViewModel(); + result.setPart(part); if (!StringUtils.isEmpty(partInspection) && partInspection.getInspectionStatus() == MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue() && partInspection.getNcStatus() == MesExtEnumUtil.PART_INSPECTION_NC_STATUS.CREATE.getValue()) { - model.setPartInspectionDetailList(detailList); - model.setPartInspection(partInspection); + result.setPartInspectionDetailList(detailList); + result.setPartInspection(partInspection); } - model.setPartTypePicture(partTypePicture); - model.setLocationConfigList(locationConfigList); - model.setMesDefectWarnConfigList(alarmConfigList); - return model; + result.setPartTypePicture(partTypePicture); + result.setLocationConfigList(locationConfigList); + result.setMesDefectWarnConfigList(alarmConfigList); + return result; } @@ -1109,7 +1279,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService version = productVersionRepository.getByProperty(ddlPackBean); if (version != null) { - source = version.getShipInventoryPoint(); + source = version.getReceiveInventoryPoint(); } } @@ -1119,9 +1289,64 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService if (null != workCenter && !StringUtils.isEmpty(workCenter.getRawLocate())) source = workCenter.getRawLocate(); } - if (StringUtils.isEmpty(source)) MesPcnException.throwBusiException("未找到来源库位!"); - MesMove move = createMove(model, source, target, org, model.getWorkCenterCode()); - moveRepository.insert(move); + + // 是否头零件模式 + boolean headModel = true; + if (!StringUtil.isEmpty(model.getSn())) { + + // 判断是头零件还是散件 查询加工记录 + DdlPackBean productionPackBean = DdlPackBean.getDdlPackBean(org); + DdlPreparedPack.getStringEqualPack(model.getSn(), "productSn", productionPackBean); + DdlPreparedPack.getNumNOEqualPack(MesExtEnumUtil.REPORT_STATUS.REPORT_STATUS_30.getValue(), "reportStatus", productionPackBean); + DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.MES_REPORT_TYPE.CUSTOMER_SUPPLY_MOVE.getValue(), "reportType", productionPackBean); + MesProductionRecord record = productionRecordRepository.getByProperty(productionPackBean); + if (record != null) { + headModel = false; + } + } + // 如果是散件模式,需要查询出对应明细 + List mesPartModels = new ArrayList<>(); + if (!headModel) { + MesProduceSn produceSn = getProduceSn(model.getSn(), org); + + DdlPackBean partPackBean = DdlPackBean.getDdlPackBean(org); + DdlPreparedPack.getStringEqualPack(model.getSn(), "workOrderNo", partPackBean); + List workOrderParts = workOrderPartRepository.findByHqlWhere(partPackBean); + if (!CollectionUtils.isEmpty(workOrderParts)) { + DdlPackBean partProdBean = DdlPackBean.getDdlPackBean(org); + DdlPreparedPack.getStringEqualPack(produceSn.getWorkCenterCode(), "workCenterCode", partProdBean); + List mesPartProdGroupList = mesPartProdGroupRao.findByHqlTopWhere(partProdBean, 1); + for (MesWorkOrderPart workOrderPart : workOrderParts) { + MesPart partInfo = mesPartService.getMesPartByPartNo(workOrderPart.getPartNo(), org); + String esd = partInfo.getEsd(); + + // 查询移库规则 + DdlPackBean movePackBean = DdlPackBean.getDdlPackBean(org); + DdlPreparedPack.getStringEqualPack(esd, "srcType", movePackBean); + DdlPreparedPack.getStringEqualPack(mesPartProdGroupList.get(0).getPartProdGroupCode(), "code", movePackBean); + List moveRules = mesMoveRuleRepository.findByHqlWhere(movePackBean); + if (!CollectionUtils.isEmpty(moveRules)) { + MesPartModel mesPartModel = new MesPartModel(); + mesPartModel.setPartNo(workOrderPart.getPartNo()); + mesPartModel.setLocateNo(moveRules.get(0).getErpDestLocateNo()); + mesPartModels.add(mesPartModel); + } + } + } + } + + if (!headModel && !CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) { + for (MesPartModel mesPartModel : mesPartModels) { + //移库 + MesMove move = createMove(model, mesPartModel.getLocateNo(),target, org, model.getWorkCenterCode()); + moveRepository.save(move); + } + } else { + //移库 + if (StringUtils.isEmpty(source)) MesPcnException.throwBusiException("未找到来源库位!"); + MesMove move = createMove(model, source, target, org, model.getWorkCenterCode()); + moveRepository.save(move); + } } @ApiOperation(value = "客退品查询") 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 624991e..e754a9f 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 @@ -2,14 +2,12 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi; 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.IMesConfigService; -import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesNcProcessingService; -import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProduceSnExtService; -import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesWorkOrderExtService; +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.pojo.model.MesNcProcessingInputModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingPartAndLotModel; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService; import cn.estsh.i3plus.platform.common.convert.ConvertBean; @@ -115,7 +113,20 @@ public class MesNcProcessingService implements IMesNcProcessingService { private MesWorkOrderRepository workOrderRepository; @Autowired + private MesWorkOrderPartRepository workOrderPartRepository; + + @Autowired + private MesPartProdGroupRepository mesPartProdGroupRao; + + @Autowired + private MesProductionRecordRepository productionRecordRepository; + + @Autowired private IMesPartService mesPartService; + + @Autowired + private IMesMoveRuleRepository mesMoveRuleRepository; + @Override public ListPager queryPartInspectionByPager(MesPartInspection partInspection, Pager pager) { @@ -351,7 +362,48 @@ public class MesNcProcessingService implements IMesNcProcessingService { isWorkOrderQcStatus= centerDb.getCenterType() == MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue(); } } + // 是否头零件模式 + boolean headModel = true; + if (!StringUtil.isEmpty(model.getSn())) { + // 判断是头零件还是散件 查询加工记录 + DdlPackBean productionPackBean = DdlPackBean.getDdlPackBean(org); + DdlPreparedPack.getStringEqualPack(model.getSn(), "productSn", productionPackBean); + DdlPreparedPack.getNumNOEqualPack(MesExtEnumUtil.REPORT_STATUS.REPORT_STATUS_30.getValue(), "reportStatus", productionPackBean); + DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.MES_REPORT_TYPE.CUSTOMER_SUPPLY_MOVE.getValue(), "reportType", productionPackBean); + MesProductionRecord record = productionRecordRepository.getByProperty(productionPackBean); + if (record != null) { + headModel = false; + } + } + // 如果是散件模式,需要查询出对应明细 + List mesPartModels = new ArrayList<>(); + if (!headModel) { + DdlPackBean partPackBean = DdlPackBean.getDdlPackBean(org); + DdlPreparedPack.getStringEqualPack(model.getSn(), "workOrderNo", partPackBean); + List workOrderParts = workOrderPartRepository.findByHqlWhere(partPackBean); + if (!CollectionUtils.isEmpty(workOrderParts)) { + DdlPackBean partProdBean = DdlPackBean.getDdlPackBean(org); + DdlPreparedPack.getStringEqualPack(sn.getWorkCenterCode(), "workCenterCode", partProdBean); + List mesPartProdGroupList = mesPartProdGroupRao.findByHqlTopWhere(partProdBean, 1); + for (MesWorkOrderPart workOrderPart : workOrderParts) { + MesPart partInfo = mesPartService.getMesPartByPartNo(workOrderPart.getPartNo(), org); + String esd = partInfo.getEsd(); + + // 查询移库规则 + DdlPackBean movePackBean = DdlPackBean.getDdlPackBean(org); + DdlPreparedPack.getStringEqualPack(esd, "srcType", movePackBean); + DdlPreparedPack.getStringEqualPack(mesPartProdGroupList.get(0).getPartProdGroupCode(), "code", movePackBean); + List moveRules = mesMoveRuleRepository.findByHqlWhere(movePackBean); + if (!CollectionUtils.isEmpty(moveRules)) { + MesPartModel mesPartModel = new MesPartModel(); + mesPartModel.setPartNo(workOrderPart.getPartNo()); + mesPartModel.setLocateNo(moveRules.get(0).getErpDestLocateNo()); + mesPartModels.add(mesPartModel); + } + } + } + } String source = configService.getCfgValue(org, "LGORT"); String refundSource = configService.getCfgValue(org, "REFUND"); if (!StringUtils.isEmpty(model.getProductVersion())) { @@ -411,10 +463,24 @@ public class MesNcProcessingService implements IMesNcProcessingService { target = version.getReceiveInventoryPoint(); } - //移库 转正常、放行:8000移至2000 - MesMove move = createMove(model, sourceValue, target, org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.NORMAL_MOVE); - ConvertBean.serviceModelInitialize(move,model.getUserName()); - moveRepository.save(move); + + + if (!headModel && !CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) { + List moveList = new ArrayList<>(); + for (MesPartModel mesPartModel : mesPartModels) { + //移库 转正常、放行:8000移至2000 + MesMove move = createMove(model, sourceValue, mesPartModel.getLocateNo(), org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.NORMAL_MOVE, mesPartModel.getPartNo()); + ConvertBean.serviceModelInitialize(move, model.getUserName()); + moveList.add(move); + } + moveRepository.saveAll(moveList); + + } else { + //移库 转正常、放行:8000移至2000 + MesMove move = createMove(model, sourceValue, target, org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.NORMAL_MOVE); + ConvertBean.serviceModelInitialize(move, model.getUserName()); + moveRepository.save(move); + } } else if (type == MesExtEnumUtil.NC_TYPE.REWORK.getValue()) { @@ -471,11 +537,19 @@ public class MesNcProcessingService implements IMesNcProcessingService { } partInspectionRepository.save(model.getPartInspection()); - - - MesMove move = createMove(model, sourceValue, areaCode, org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.RETURN_MOVE); - ConvertBean.serviceModelInitialize(move,model.getUserName()); - moveRepository.save(move); + if (!headModel && !CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) { + List moveList = new ArrayList<>(); + for (MesPartModel mesPartModel : mesPartModels) { + MesMove move = createMove(model, sourceValue, areaCode, org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.RETURN_MOVE, mesPartModel.getPartNo()); + ConvertBean.serviceModelInitialize(move, model.getUserName()); + moveList.add(move); + } + moveRepository.saveAll(moveList); + } else { + MesMove move = createMove(model, sourceValue, areaCode, org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.RETURN_MOVE); + ConvertBean.serviceModelInitialize(move, model.getUserName()); + moveRepository.save(move); + } } else if (type == MesExtEnumUtil.NC_TYPE.SCRAP.getValue()) { //批次不需要校验条码 @@ -518,18 +592,45 @@ public class MesNcProcessingService implements IMesNcProcessingService { sourceValue = refundSource; } - MesMove move = createMove(model, sourceValue, configService.getCfgValue(org, "SCRAP"), org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.SCRAP_MOVE); - ConvertBean.serviceModelInitialize(move,model.getUserName()); - moveRepository.save(move); + if (!headModel && !CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) { + List moveList = new ArrayList<>(); + + for (MesPartModel mesPartModel : mesPartModels) { + MesMove move = createMove(model, sourceValue, configService.getCfgValue(org, "SCRAP"), org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.SCRAP_MOVE,mesPartModel.getPartNo()); + ConvertBean.serviceModelInitialize(move,model.getUserName()); + moveList.add(move); + } + moveRepository.saveAll(moveList); + } else { + MesMove move = createMove(model, sourceValue, configService.getCfgValue(org, "SCRAP"), org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.SCRAP_MOVE); + ConvertBean.serviceModelInitialize(move,model.getUserName()); + moveRepository.save(move); + } + } else { String sourceValue = configService.getCfgValue(org, "UMLGO"); if (model.getOptType() == 2) { sourceValue = refundSource; } - //移库 转报废 根据责任方库区对应关系的主数据,选择哪个责任方,就移动到哪个库区(8000移至8002/8003) - MesMove move = createMove(model, sourceValue, areaCode, org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.SCRAP_MOVE); - ConvertBean.serviceModelInitialize(move,model.getUserName()); - moveRepository.save(move); + if (!headModel) { + if (!CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) { + List moveList = new ArrayList<>(); + + for (MesPartModel mesPartModel : mesPartModels) { + //移库 转报废 根据责任方库区对应关系的主数据,选择哪个责任方,就移动到哪个库区(8000移至8002/8003) + MesMove move = createMove(model, sourceValue, areaCode, org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.SCRAP_MOVE, mesPartModel.getPartNo()); + ConvertBean.serviceModelInitialize(move,model.getUserName()); + moveList.add(move); + } + moveRepository.saveAll(moveList); + + } + } else { + //移库 转报废 根据责任方库区对应关系的主数据,选择哪个责任方,就移动到哪个库区(8000移至8002/8003) + MesMove move = createMove(model, sourceValue, areaCode, org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.SCRAP_MOVE); + ConvertBean.serviceModelInitialize(move,model.getUserName()); + moveRepository.save(move); + } } } else if (type == MesExtEnumUtil.NC_TYPE.RELEASE.getValue()) { @@ -576,13 +677,24 @@ public class MesNcProcessingService implements IMesNcProcessingService { target = version.getReceiveInventoryPoint(); } - //移库 转正常、放行:8000移至2000 - MesMove move = createMove(model, sourceValue, target, org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.NORMAL_MOVE); - ConvertBean.serviceModelInitialize(move,model.getUserName()); - moveRepository.save(move); + if (!headModel && !CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) { + List moveList = new ArrayList<>(); - } + for (MesPartModel mesPartModel : mesPartModels) { + //移库 转正常、放行:8000移至2000 + MesMove move = createMove(model, sourceValue, mesPartModel.getLocateNo(), org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.NORMAL_MOVE, mesPartModel.getPartNo()); + ConvertBean.serviceModelInitialize(move, model.getUserName()); + moveList.add(move); + } + moveRepository.saveAll(moveList); + } else { + //移库 转正常、放行:8000移至2000 + MesMove move = createMove(model, sourceValue, target, org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.NORMAL_MOVE); + ConvertBean.serviceModelInitialize(move, model.getUserName()); + moveRepository.save(move); + } + } } public MesWorkOrder getWorkOrder(String organizeCode, String workOrderNo) { if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(workOrderNo)) return null; @@ -674,4 +786,31 @@ public class MesNcProcessingService implements IMesNcProcessingService { move.setWorkCenter(prodOrgExtService.getErpWorkCenterCode(org, workCenterCode)); return move; } + + private MesMove createMove(MesNcProcessingInputModel model, String source, String target, String org, String workCenterCode, MesExtEnumUtil.MOVE_TYPE moveType, String partNo) { + GenSerialNoModel serialNoModel = new GenSerialNoModel("INPUT_DEFECT_ZRSUM"); + serialNoModel.setPartNo(partNo); + ResultBean rb = syncFuncService.syncSerialNo(serialNoModel, model.getPartInspection().getModifyUser(), org, 1); + String zrsum = ""; + if (null != rb && !CollectionUtils.isEmpty(rb.getResultList())) { + zrsum = (rb.getResultList().get(0)).toString(); + } + + MesMove move = new MesMove(); + move.setMatnr(partNo); + move.setOrganizeCode(org); + move.setFactoryCode(org); + move.setLgort(source); + move.setUmlgo(target); + move.setMenge(model.getPartInspection().getQty()); + move.setMeins(model.getPart().getUnit()); + move.setZrsum(zrsum); + move.setPostDate(TimeTool.getToday()); + move.setPostTime(TimeTool.getTimeShortWithColon()); + move.setMoveType(moveType.getValue()); + move.setPartInspectionId(model.getPartInspection().getId()); + move.setProductSn(model.getSn()); + move.setWorkCenter(prodOrgExtService.getErpWorkCenterCode(org, workCenterCode)); + return move; + } } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesPartShippingGroupService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesPartShippingGroupService.java index bbf8f01..09b9b3b 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesPartShippingGroupService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesPartShippingGroupService.java @@ -5,26 +5,31 @@ import cn.estsh.i3plus.platform.common.convert.ConvertBean; import cn.estsh.i3plus.platform.common.tool.TimeTool; import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; 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.MesConfig; +import cn.estsh.i3plus.pojo.mes.bean.MesCustomerPart; import cn.estsh.i3plus.pojo.mes.bean.MesPartShippingGroup; import cn.estsh.i3plus.pojo.mes.bean.MesPartShippingGroupDetail; import cn.estsh.i3plus.pojo.mes.bean.edi.wuhu.MesCimCheryOrder; import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement; import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagementDetail; import cn.estsh.i3plus.pojo.mes.model.MesShippingOrderManagementDetailModel; +import cn.estsh.i3plus.pojo.mes.model.MesShippingOrderManagementDetailModelForLiJia; import cn.estsh.i3plus.pojo.mes.model.MesShippingOrderManagementModel; +import cn.estsh.i3plus.pojo.mes.model.MesShippingOrderManagementModelForLiJia; import cn.estsh.i3plus.pojo.mes.repository.*; +import cn.estsh.impp.framework.boot.util.ResultBean; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; import java.util.*; -import java.util.function.Function; -import java.util.logging.Handler; import java.util.stream.Collectors; +import java.util.stream.IntStream; @Service @Slf4j @@ -49,6 +54,9 @@ public class MesPartShippingGroupService implements IMesPartShippingGroupService @Autowired private MesConfigRepository mesConfigRao; + @Autowired + private MesCustomerPartRepository mesCustomerPartRepository; + public List findAll(DdlPackBean packBean) { return shippingGroupRepository.findByHqlWhere(packBean); } @@ -62,7 +70,7 @@ public class MesPartShippingGroupService implements IMesPartShippingGroupService } @Override - public List doMesMesShippingOrderManagementPrint(MesShippingOrderManagement bean) { + public ResultBean doMesMesShippingOrderManagementPrint(MesShippingOrderManagement bean) { DdlPackBean configPackBean = DdlPackBean.getDdlPackBean(bean.getOrganizeCode()); DdlPreparedPack.getStringEqualPack("WU_HU_SUPPLIER","cfgKey", configPackBean); List configList = mesConfigRao.findByHqlWhere(configPackBean); @@ -70,82 +78,142 @@ public class MesPartShippingGroupService implements IMesPartShippingGroupService if (configList != null && !configList.isEmpty()) { supplierNo = configList.get(0).getCfgValue(); } - - List modelList = new ArrayList<>(); DdlPackBean packBean = DdlPackBean.getDdlPackBean(bean.getOrganizeCode()); //多选 if (!StringUtil.isEmpty(bean.getShippingGroupCode())) { DdlPreparedPack.getInPackList(Arrays.asList(bean.getShippingGroupCode().split(",")), "shippingGroupCode", packBean); } - DdlPreparedPack.getStringEqualPack(bean.getShippingCode(), "shippingCode", packBean); DdlPreparedPack.getIsNull("lastPrintTime", packBean); DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.ASC.getValue()}, new String[]{"createDatetime"}, packBean); List pullingOrderInfos = shippingOrderManagementRepository.findByHqlTopWhere(packBean,10); + log.info("doMesMesShippingOrderManagementPrint-pullingOrderInfos" + pullingOrderInfos.size()); if (!CollectionUtils.isEmpty(pullingOrderInfos)) { - //把查出来的发运单打印并修改打印状态为已打印 - for (MesShippingOrderManagement shippingOrder : pullingOrderInfos) { - MesShippingOrderManagementModel model = new MesShippingOrderManagementModel(); - String shippingCodePrefix = shippingOrder.getShippingCode().substring(0, shippingOrder.getShippingCode().length() - 3); - String shippingCodeSuffix = shippingOrder.getShippingCode().substring(shippingOrder.getShippingCode().length() - 3); - model.setShippingCode(shippingCodePrefix); - model.setShippingCodeAfter3(shippingCodeSuffix); - model.setShippingCodeWhole(shippingOrder.getShippingCode()); - - //查询原始报文 - List cheryOrderList = getCheryOrder(shippingOrder.getOrganizeCode(), shippingOrder.getShippingCode()); - Map> cheryOrderMap = new HashMap<>(); - if (cheryOrderList != null && !cheryOrderList.isEmpty()) { - MesCimCheryOrder cheryOrder = cheryOrderList.get(0); - model.setPlantName(cheryOrder.getPlantName()); - model.setPartkitName(cheryOrder.getPartkitName()); - model.setDeliverySendSequence(cheryOrder.getDeliverySendSequence()); - model.setReceiveDockName(cheryOrder.getReceiveDockNo()+"--"+cheryOrder.getReceiveDockName()); - model.setLastRecRequireTime(cheryOrder.getLastRecRequireTime()); - //根据cheryOrder的workshopNo获取对应的车间名称 - String workshopName = getWorkshopName(cheryOrder.getOrganizeCode(), cheryOrder.getWorkshopNo()); - model.setWorkShop(workshopName); - model.setCreateDateTime(cheryOrder.getCreateDatetime()); - model.setPrintDateTime(TimeTool.getNowTime(true)); - cheryOrderMap = cheryOrderList.stream().collect(Collectors.groupingBy(MesCimCheryOrder::getVin)); - } + //45527 礼嘉福特发运单打印(通过系统参数信息判断是否采用新的查询取值逻辑-礼嘉福特) + DdlPackBean configPackBeanTwo = DdlPackBean.getDdlPackBean(bean.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack("SORT_SHIPMENT_PRINTS_FLAG_FOR_LI_JIA","cfgKey", configPackBeanTwo); + MesConfig liJiaConfig = mesConfigRao.getByProperty(configPackBeanTwo); + log.info("doMesMesShippingOrderManagementPrint-liJiaConfig" + liJiaConfig); + if (Objects.isNull(liJiaConfig)) { + log.info("doMesMesShippingOrderManagementPrint-老逻辑"); + //未维护该参数,则继续执行原有逻辑 + List modelList = new ArrayList<>(); + //把查出来的发运单打印并修改打印状态为已打印- + for (MesShippingOrderManagement shippingOrder : pullingOrderInfos) { + MesShippingOrderManagementModel model = new MesShippingOrderManagementModel(); + String shippingCodePrefix = shippingOrder.getShippingCode().substring(0, shippingOrder.getShippingCode().length() - 3); + String shippingCodeSuffix = shippingOrder.getShippingCode().substring(shippingOrder.getShippingCode().length() - 3); + model.setShippingCode(shippingCodePrefix); + model.setShippingCodeAfter3(shippingCodeSuffix); + model.setShippingCodeWhole(shippingOrder.getShippingCode()); - //查询发运单明细 - DdlPackBean partPackBean = DdlPackBean.getDdlPackBean(shippingOrder.getOrganizeCode()); - DdlPreparedPack.getNumEqualPack(shippingOrder.getId(), "pid", partPackBean); - DdlPreparedPack.getOrderBy("boxNum",CommonEnumUtil.ASC_OR_DESC.ASC.getValue(), partPackBean); - List shipOrderPartInfos = shippingOrderManagementDetailRepository.findByHqlWhere(partPackBean); - if (!CollectionUtils.isEmpty(shipOrderPartInfos)) { - List detailList = new ArrayList<>(); - shipOrderPartInfos = shipOrderPartInfos.stream().sorted(Comparator.comparing(MesShippingOrderManagementDetail::getCustInfoSeq)).collect(Collectors.toList()); - for (MesShippingOrderManagementDetail shipOrderPartInfo : shipOrderPartInfos) { - MesShippingOrderManagementDetailModel detailModel = new MesShippingOrderManagementDetailModel(); - detailModel.setPartNo(shipOrderPartInfo.getPartNo()); - detailModel.setPartName(shipOrderPartInfo.getPartName()); - detailModel.setQty(shipOrderPartInfo.getPlanQty()); - detailModel.setBoxNo(shipOrderPartInfo.getCustInfoSeq()); - detailModel.setSupplierNo(supplierNo); - detailModel.setVin(shipOrderPartInfo.getVin().substring(shipOrderPartInfo.getVin().length()-8)); - MesCimCheryOrder order = cheryOrderMap.get(shipOrderPartInfo.getVin()).get(0); - if (order != null) { - detailModel.setWholePartNo(order.getMaterialNo()); + //查询原始报文 + List cheryOrderList = getCheryOrder(shippingOrder.getOrganizeCode(), shippingOrder.getShippingCode()); + Map> cheryOrderMap = new HashMap<>(); + if (cheryOrderList != null && !cheryOrderList.isEmpty()) { + MesCimCheryOrder cheryOrder = cheryOrderList.get(0); + model.setPlantName(cheryOrder.getPlantName()); + model.setPartkitName(cheryOrder.getPartkitName()); + model.setDeliverySendSequence(cheryOrder.getDeliverySendSequence()); + model.setReceiveDockName(cheryOrder.getReceiveDockNo()+"--"+cheryOrder.getReceiveDockName()); + model.setLastRecRequireTime(cheryOrder.getLastRecRequireTime()); + //根据cheryOrder的workshopNo获取对应的车间名称 + String workshopName = getWorkshopName(cheryOrder.getOrganizeCode(), cheryOrder.getWorkshopNo()); + model.setWorkShop(workshopName); + model.setCreateDateTime(cheryOrder.getCreateDatetime()); + model.setPrintDateTime(TimeTool.getNowTime(true)); + cheryOrderMap = cheryOrderList.stream().collect(Collectors.groupingBy(MesCimCheryOrder::getVin)); + } + + //查询发运单明细 + DdlPackBean partPackBean = DdlPackBean.getDdlPackBean(shippingOrder.getOrganizeCode()); + DdlPreparedPack.getNumEqualPack(shippingOrder.getId(), "pid", partPackBean); + DdlPreparedPack.getOrderBy("boxNum",CommonEnumUtil.ASC_OR_DESC.ASC.getValue(), partPackBean); + List shipOrderPartInfos = shippingOrderManagementDetailRepository.findByHqlWhere(partPackBean); + if (!CollectionUtils.isEmpty(shipOrderPartInfos)) { + List detailList = new ArrayList<>(); + shipOrderPartInfos = shipOrderPartInfos.stream().sorted(Comparator.comparing(MesShippingOrderManagementDetail::getCustInfoSeq)).collect(Collectors.toList()); + for (MesShippingOrderManagementDetail shipOrderPartInfo : shipOrderPartInfos) { + MesShippingOrderManagementDetailModel detailModel = new MesShippingOrderManagementDetailModel(); + detailModel.setPartNo(shipOrderPartInfo.getPartNo()); + detailModel.setPartName(shipOrderPartInfo.getPartName()); + detailModel.setQty(shipOrderPartInfo.getPlanQty()); + detailModel.setBoxNo(shipOrderPartInfo.getCustInfoSeq()); + detailModel.setSupplierNo(supplierNo); + detailModel.setVin(shipOrderPartInfo.getVin().substring(shipOrderPartInfo.getVin().length()-8)); + MesCimCheryOrder order = cheryOrderMap.get(shipOrderPartInfo.getVin()).get(0); + if (order != null) { + detailModel.setWholePartNo(order.getMaterialNo()); + } + detailList.add(detailModel); } - detailList.add(detailModel); + model.setShipOrderPartInfos(detailList); } - model.setShipOrderPartInfos(detailList); - } - //查询原有报文 根据shippingCode; - shippingOrder.setPrintCount(StringUtil.isEmpty(shippingOrder.getPrintCount())?1:shippingOrder.getPrintCount()+1); - shippingOrder.setLastPrintTime(TimeTool.getNowTime(true)); - shippingOrder.setLastPrintUser(bean.getUserInfo()); - ConvertBean.serviceModelUpdate(shippingOrder, bean.getUserInfo()); - modelList.add(model); + //查询原有报文 根据shippingCode; + shippingOrder.setPrintCount(StringUtil.isEmpty(shippingOrder.getPrintCount())?1:shippingOrder.getPrintCount()+1); + shippingOrder.setLastPrintTime(TimeTool.getNowTime(true)); + shippingOrder.setLastPrintUser(bean.getUserInfo()); + ConvertBean.serviceModelUpdate(shippingOrder, bean.getUserInfo()); + modelList.add(model); + } + shippingOrderManagementRepository.saveAll(pullingOrderInfos); + return ResultBean.success("发运单打印成功") + .setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()) + .setResultList(modelList); + }else { + log.info("doMesMesShippingOrderManagementPrint-新逻辑"); + //维护了该参数,则执行礼嘉的新逻辑 + List mainDataList = new ArrayList<>(); + /** + * 查询发运单明细信息 + */ + List pidList = pullingOrderInfos.stream().map(MesShippingOrderManagement::getId).collect(Collectors.toList()); + DdlPackBean liJIaPackBean = DdlPackBean.getDdlPackBean(bean.getOrganizeCode()); + DdlPreparedPack.getInPackList(pidList, "pid", liJIaPackBean); + List shippingOrderManagementDetailList = + shippingOrderManagementDetailRepository.findByHqlWhere(liJIaPackBean); + log.info("doMesMesShippingOrderManagementPrint-查询发运单明细信息" + shippingOrderManagementDetailList.size()); + Map> detailByPidMap = shippingOrderManagementDetailList + .stream().collect(Collectors.groupingBy(MesShippingOrderManagementDetail::getPid)); + log.info("doMesMesShippingOrderManagementPrint-查询发运单明细信息-detailByPidMap-" + detailByPidMap.size()); + //遍历处理每个发运单主表 + for (MesShippingOrderManagement pullingOrderInfo : pullingOrderInfos) { + //一张实体发运单包含三部分信息(顶部的通用数据、中部的第一份表格数据,底部的第二份表格数据) + //取出当前发运单的明细信息 + List details = detailByPidMap.get(pullingOrderInfo.getId()); + if (!CollectionUtils.isEmpty(details)) { + //将发运单明细按照 assyCode 分组 + //assyCode 的个数 / 2 代表会生成实体发运单的份数(一个 assyCode 就是一个表格,一份实体表单上可以放两个表格) + Map> detailByAssyCodeMap = + details.stream().collect(Collectors.groupingBy(MesShippingOrderManagementDetail::getAssyCode)); + List assyCodeList = new ArrayList<>(detailByAssyCodeMap.keySet()); + //将 assyCode 两两分组 + List> physicalOrderList = IntStream.range(0, assyCodeList.size()) + .filter(i -> i % 2 == 0) + .mapToObj(i -> assyCodeList.subList(i, Math.min(i + 2, assyCodeList.size()))) + .collect(Collectors.toList()); + for (List list : physicalOrderList) { + //生成一张实体发运单 + log.info("doMesMesShippingOrderManagementPrint-生成一张实体发运单-list-" + list); + mainDataList.add(createPhysicalOrder(pullingOrderInfo, list, detailByAssyCodeMap, details)); + } + } + pullingOrderInfo.setPrintCount(StringUtil.isEmpty(pullingOrderInfo.getPrintCount())? 1 : pullingOrderInfo.getPrintCount()+1); + pullingOrderInfo.setLastPrintTime(TimeTool.getNowTime(true)); + pullingOrderInfo.setLastPrintUser(bean.getUserInfo()); + ConvertBean.serviceModelUpdate(pullingOrderInfo, bean.getUserInfo()); + log.info("doMesMesShippingOrderManagementPrint-pullingOrderInfo更新"); + } + shippingOrderManagementRepository.saveAll(pullingOrderInfos); + log.info("doMesMesShippingOrderManagementPrint-结束"); + return ResultBean.success("发运单打印成功") + .setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()) + .setResultList(mainDataList); } - shippingOrderManagementRepository.saveAll(pullingOrderInfos); } -// return pullingOrderInfos; - return modelList; + return ResultBean.success("不存在需要打印的发运单") + .setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()); } private String getWorkshopName(String organizeCode, String workshopNo) { @@ -179,4 +247,58 @@ public class MesPartShippingGroupService implements IMesPartShippingGroupService DdlPreparedPack.getStringEqualPack(partNo, "partNo", packBean); return mesPartShippingGroupDetailRepository.getByProperty(packBean); } + + private MesShippingOrderManagementModelForLiJia createPhysicalOrder(MesShippingOrderManagement pullingOrderInfo, + List assyCodeList, + Map> detailByAssyCodeMap, + List details) { + MesShippingOrderManagementModelForLiJia model = new MesShippingOrderManagementModelForLiJia(); + //顶部的通用数据赋值 + model.setShippingGroupName(pullingOrderInfo.getShippingGroupName()); + model.setPrintDateTime(TimeTool.getNowTime(true)); + model.setShippingCode(pullingOrderInfo.getShippingCode()); + model.setDocumentNumber("YFVCQ-MS06-02-01"); + log.info("doMesMesShippingOrderManagementPrint-顶部的通用数据赋值" + model); + //中部表结构赋值 + model.setDetailModelsOne(createDetailList(assyCodeList.get(0), detailByAssyCodeMap, details, pullingOrderInfo.getRackNo())); + log.info("doMesMesShippingOrderManagementPrint-中部表结构赋值" + model); + //底部表结构赋值 + model.setDetailModelsTwo(createDetailList(assyCodeList.get(1), detailByAssyCodeMap, details, pullingOrderInfo.getRackNo())); + log.info("doMesMesShippingOrderManagementPrint-底部表结构赋值" + model); + return model; + } + + private List createDetailList( + String assyCode, Map> detailByAssyCodeMap, + List details, String rackNo) { + List dataList = new ArrayList<>(); + //取出符合条件的发运单明细数据 + List nowDetailList = detailByAssyCodeMap.get(assyCode); + log.info("doMesMesShippingOrderManagementPrint-createDetailList-nowDetailList" + nowDetailList.size()); + if (!CollectionUtils.isEmpty(nowDetailList)) { + //并按照 logic_seq 升序排列 + List collect = nowDetailList.stream().sorted( + Comparator.comparing(MesShippingOrderManagementDetail::getLogicSeq)).collect(Collectors.toList()); + Integer number = 1; + for (MesShippingOrderManagementDetail mesShippingOrderManagementDetail : collect) { + MesShippingOrderManagementDetailModelForLiJia detailModel = new MesShippingOrderManagementDetailModelForLiJia(); + detailModel.setNumber(number); + detailModel.setCustInfoSeq(mesShippingOrderManagementDetail.getCustInfoSeq()); + if (!StringUtils.isEmpty(mesShippingOrderManagementDetail.getVin())) { + detailModel.setVin(mesShippingOrderManagementDetail.getVin().substring( + mesShippingOrderManagementDetail.getVin().length() - 6)); + } + detailModel.setCarSerialCode(mesShippingOrderManagementDetail.getCarSerialCode()); + detailModel.setPartNo(mesShippingOrderManagementDetail.getPartNo()); + detailModel.setCustPartNo(mesShippingOrderManagementDetail.getCustPartNo()); + detailModel.setCustPartName(mesShippingOrderManagementDetail.getPartName()); + detailModel.setRackNo(rackNo); + dataList.add(detailModel); + number ++; + } + } + log.info("doMesMesShippingOrderManagementPrint-createDetailList-dataList" + dataList.size()); + return dataList; + } + } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesPrintedSnLogServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesPrintedSnLogServiceImpl.java index 0628087..cd69a60 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesPrintedSnLogServiceImpl.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesPrintedSnLogServiceImpl.java @@ -13,6 +13,8 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Map; + /** * @Description : 条码打印记录表 * @Reference : @@ -39,6 +41,18 @@ public class MesPrintedSnLogServiceImpl implements IMesPrintedSnLogService { } @Override + public MesPrintedSnLog getMesCustomPrintedSnLog(String userName, String organizeCode, MesProduceSnPrintDataModel printDataModel, Map printContext) { + MesPrintedSnLog snLog = new MesPrintedSnLog(); + BeanUtil.copyProperties(printDataModel, snLog); + snLog.setOrganizeCode(organizeCode); + snLog.setPrintContext(printContext); + snLog.setPrintData(JSONObject.toJSONString(printContext)); + snLog.setPrintType(MesExtEnumUtil.PRINT_LOG_TYPE.PRINT_LOG_TYPE_10.getValue()); + ConvertBean.serviceModelInitialize(snLog, userName); + return snLog; + } + + @Override public void insertMesPrintedSnLog(MesPrintedSnLog mesPrintedSnLog, String userName) { MesPrintedSnLog snLog = new MesPrintedSnLog(); BeanUtil.copyProperties(mesPrintedSnLog, snLog, MesPcnExtConstWords.BASE_BEAN_FIELDS); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesProduceSnPrintService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesProduceSnPrintService.java index e85f344..14703a9 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesProduceSnPrintService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesProduceSnPrintService.java @@ -225,8 +225,13 @@ public class MesProduceSnPrintService implements IMesProduceSnPrintService { } MesProduceSnPrintDataModel model = new MesProduceSnPrintDataModel(); BeanUtil.copyProperties(snLog, model); - model.setPrintDate(TimeTool.getNowTime(true)); - mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(model); + if (CollectionUtils.isEmpty(snLog.getPrintContext())) { + model.setPrintDate(TimeTool.getNowTime(true)); + mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(model); + } else { + snLog.getPrintContext().put(MesPcnExtConstWords.PRINT_DATE, TimeTool.getNowTime(true)); + mesProduceSnPrintModel.getPrintContextList().add(snLog.getPrintContext()); + } //记录打印日志 mesPrintedSnLogService.insertMesPrintedSnLog(snLog, model.getUserName()); return mesProduceSnPrintModel; diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesProductionRecordService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesProductionRecordService.java index 847d0d2..92dbe16 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesProductionRecordService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesProductionRecordService.java @@ -4,8 +4,6 @@ import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesProdOrgExtService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProduceSnExtService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionRecordService; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; -import cn.estsh.i3plus.platform.common.convert.ConvertBean; -import cn.estsh.i3plus.platform.common.tool.TimeTool; import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; @@ -60,6 +58,9 @@ public class MesProductionRecordService implements IMesProductionRecordService { @Autowired private MesWorkCellRepository mesWorkCellRepository; + @Autowired + private MesProductionRecordRepository productionRecordRao; + @Override public List findProductionRecordList(String organizeCode, String productSn) { if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(productSn)) return null; @@ -250,14 +251,14 @@ public class MesProductionRecordService implements IMesProductionRecordService { @Override public void updateProductionRecord(List recordList, String userName, Integer reportStatus, String msg) { + recordList.forEach(record->{ - record.setReportStatus(reportStatus); - record.setRemark(msg); - record.setSystemSyncStatus(CommonEnumUtil.FALSE); - record.setSystemSyncDatetime(MesPcnExtConstWords.EMPTY); - ConvertBean.serviceModelUpdate(record,userName); + DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(record.getOrganizeCode()); + DdlPreparedPack.getNumEqualPack(record.getId(), "id", ddlPackBean); + productionRecordRao.updateByPropertiesNoSync(new String[]{"modifyUser", "modifyDatetime", "reportStatus","remark","systemSyncStatus","systemSyncDatetime"}, + new Object[]{userName, DateUtil.format(new Date(), MesPcnExtConstWords.DATE_FORMAT_SSS), reportStatus,msg,CommonEnumUtil.FALSE,""}, ddlPackBean); + }); - productionRecordRepository.saveAll(recordList); } } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesPullingOrderInfoService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesPullingOrderInfoService.java index 3e6828a..a4f1f4d 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesPullingOrderInfoService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesPullingOrderInfoService.java @@ -30,6 +30,8 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -62,6 +64,9 @@ public class MesPullingOrderInfoService implements IMesPullingOrderInfoService { @Autowired private MesCustomerCarModelRepository carModelRepository; + @Autowired + private MesWorkOrderRepository workOrderRao; + @Override public ListPager queryMesPullingOrderInfoByPager(MesPullingOrderInfo bean, Pager pager) { @@ -109,7 +114,6 @@ public class MesPullingOrderInfoService implements IMesPullingOrderInfoService { DdlPreparedPack.getStringEqualPack(bean.getPullCode(), "pullCode", packBeanOne); DdlPreparedPack.getStringEqualPack(bean.getPullingOrderNo(), "pullingOrderNo", packBeanOne); DdlPreparedPack.getStringEqualPack(bean.getWorkCenterCode(), "workCenterCode", packBeanOne); -// DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PULL_ORDER_STATUS.PULL_ORDER_STATUS_10.getValue(), "pullOrderStatus", packBeanOne); MesPullingOrderInfo mesPullingOrderInfo = mesPullingOrderInfoRepository.getByProperty(packBeanOne); if (StringUtil.isEmpty(mesPullingOrderInfo)) { MesPcnException.throwMesBusiException("扫描拉动单号【%s】查询数据为空", bean.getPullingOrderNo()); @@ -129,9 +133,10 @@ public class MesPullingOrderInfoService implements IMesPullingOrderInfoService { //修改当前单号之前的为可强过 DdlPackBean packBeanPass = DdlPackBean.getDdlPackBean(bean.getOrganizeCode()); DdlPreparedPack.getStringEqualPack(bean.getPullCode(), "pullCode", packBeanPass); - DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PULL_ORDER_STATUS.PULL_ORDER_STATUS_10.getValue(), "pullOrderStatus", packBeanOne); + DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PULL_ORDER_STATUS.PULL_ORDER_STATUS_10.getValue(), "pullOrderStatus", packBeanPass); DdlPreparedPack.getStringSmallerNotEqualPack(bean.getPullingOrderNo(), "pullingOrderNo", packBeanPass); DdlPreparedPack.getStringEqualPack(bean.getWorkCenterCode(), "workCenterCode", packBeanPass); + DdlPreparedPack.getNumNOEqualPack(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(), "isPassCode", packBeanPass); List mesPullingOrderInfos = mesPullingOrderInfoRepository.findByHqlWhere(packBeanPass); if (!CollectionUtils.isEmpty(mesPullingOrderInfos)) { for (MesPullingOrderInfo pullingOrderInfo : mesPullingOrderInfos) { @@ -196,6 +201,16 @@ public class MesPullingOrderInfoService implements IMesPullingOrderInfoService { //把查出来的拉动单打印并修改打印状态为已打印 List snLogList = new ArrayList<>(); for (MesPullingOrderInfo pullingOrderInfo : pullingOrderInfos) { + //查询对应的工单 + DdlPackBean workOrderPackBean = DdlPackBean.getDdlPackBean(pullingOrderInfo.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(pullingOrderInfo.getWorkOrderNo(), MesPcnExtConstWords.WORK_ORDER_NO, workOrderPackBean); + List mesWorkOrders = workOrderRao.findByHqlTopWhere(workOrderPackBean, 1); + MesWorkOrder mesWorkOrder; + if (!CollectionUtils.isEmpty(mesWorkOrders)) { + mesWorkOrder = mesWorkOrders.get(0); + }else { + mesWorkOrder = new MesWorkOrder(); + } //查询拉动组明细 DdlPackBean partPackBean = DdlPackBean.getDdlPackBean(pullingOrderInfo.getOrganizeCode()); DdlPreparedPack.getStringEqualPack(pullingOrderInfo.getPullingOrderNo(), MesPcnExtConstWords.PULLING_ORDER_NO, partPackBean); @@ -206,12 +221,97 @@ public class MesPullingOrderInfoService implements IMesPullingOrderInfoService { if(!StringUtil.isEmpty(item.getLocation()) && item.getLocation().contains(MesPcnExtConstWords.COMMA)){ item.setLocatAddr(item.getLocation().split(MesPcnExtConstWords.COMMA)[0]); item.setLightAddr(item.getLocation().split(MesPcnExtConstWords.COMMA)[1]); - } + }; + item.setAssemblyPartNo(pullingOrderInfo.getPartNo()); + }); + pullingOrderInfo.setPullingOrderPartInfos(pullingOrderPartInfos); + } + pullingOrderInfo.setWorkOrderNoLast(!StringUtil.isEmpty(pullingOrderInfo.getWorkOrderNo())?pullingOrderInfo.getWorkOrderNo().substring(pullingOrderInfo.getWorkOrderNo().length() - MesPcnExtConstWords.FOUR):""); + pullingOrderInfo.setWorkOrderNoPre(!StringUtil.isEmpty(pullingOrderInfo.getWorkOrderNo())?pullingOrderInfo.getWorkOrderNo().substring(MesPcnExtConstWords.ZERO,pullingOrderInfo.getWorkOrderNo().length() - MesPcnExtConstWords.FOUR):""); + pullingOrderInfo.setCustOrderNoLast(!StringUtil.isEmpty(pullingOrderInfo.getCustOrderNo())?pullingOrderInfo.getCustOrderNo().substring(pullingOrderInfo.getCustOrderNo().length() - MesPcnExtConstWords.FOUR):""); + pullingOrderInfo.setCarModelName((Objects.isNull(mesCustomerCarModelMap) || StringUtil.isEmpty(pullingOrderInfo.getCarModelCode()) || !mesCustomerCarModelMap.containsKey(pullingOrderInfo.getCarModelCode()) ? "" : mesCustomerCarModelMap.get(pullingOrderInfo.getCarModelCode()).iterator().next().getCarModelName())); + + pullingOrderInfo.setPrintTime(TimeTool.getNowTime(true)); + pullingOrderInfo.setPrintStatus(MesExtEnumUtil.PRINT_STATUS.PRINTED.getValue()); + pullingOrderInfo.setIsPrint(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()); + pullingOrderInfo.setShiftName(mesWorkOrder.getShiftName()); + pullingOrderInfo.setSummaryQty(mesWorkOrder.getQty()); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + try { + pullingOrderInfo.setPlanStartDate(sdf.format(sdf.parse(mesWorkOrder.getPlanStartTime()))); + } catch (ParseException e) { + log.error("格式化时间错误e:{}", e.getMessage()); + } + pullingOrderInfo.setPlanStartTime(mesWorkOrder.getPlanStartTime()); + pullingOrderInfo.setShiftName(mesWorkOrder.getShiftName()); + pullingOrderInfo.setCarModelCode(mesWorkOrder.getCarModelCode()); + pullingOrderInfo.setCustOrderNo(mesWorkOrder.getCustOrderNo()); + ConvertBean.serviceModelUpdate(pullingOrderInfo, bean.getModifyUser()); + + //10-12 打印补打拉动单新增log表 + MesPrintedSnLog snLog = new MesPrintedSnLog(); + snLog.setBarcode(pullingOrderInfo.getPullingOrderNo()); + snLog.setCustPartNo(pullingOrderInfo.getCustPartNo()); + snLog.setWorkOrderNo(pullingOrderInfo.getWorkOrderNo()); + snLog.setPartNo(pullingOrderInfo.getPartNo()); + snLog.setPartName(pullingOrderInfo.getPartName()); + ConvertBean.serviceModelInitialize(snLog, bean.getModifyUser()); + snLog.setOrganizeCode(bean.getOrganizeCode()); + snLogList.add(snLog); + + } + mesPullingOrderInfoRepository.saveAll(pullingOrderInfos); + //保存打印条码记录 + snLogRao.saveAll(snLogList); + } + return pullingOrderInfos; + } + + @Override + public List doMesPullingOrderInfoPrintNew(MesPullingOrderInfo bean) { + DdlPackBean packBean = DdlPackBean.getDdlPackBean(bean.getOrganizeCode()); + + List pullCodeList = Arrays.asList(bean.getPullCode().split(MesPcnExtConstWords.COMMA)); + List workCenterCodeList = Arrays.asList(bean.getWorkCenterCode().split(MesPcnExtConstWords.COMMA)); + + if (pullCodeList.size() == 1) DdlPreparedPack.getStringEqualPack(pullCodeList.get(0), MesPcnExtConstWords.PULL_CODE, packBean); + else DdlPreparedPack.getInPackList(pullCodeList, MesPcnExtConstWords.PULL_CODE, packBean); + + if (workCenterCodeList.size() == 1) DdlPreparedPack.getStringEqualPack(workCenterCodeList.get(0), MesPcnExtConstWords.WORK_CENTER_CODE, packBean); + else DdlPreparedPack.getInPackList(workCenterCodeList, MesPcnExtConstWords.WORK_CENTER_CODE, packBean); + + DdlPreparedPack.getNumEqualPack(bean.getPullOrderType(),"pullOrderType",packBean); + DdlPreparedPack.getStringEqualPack(bean.getPullingOrderNo(), MesPcnExtConstWords.PULLING_ORDER_NO, packBean); + DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PRINT_STATUS.UNPRINT.getValue(), MesPcnExtConstWords.PRINT_STATUS, packBean); + DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.ASC.getValue()}, new String[]{MesPcnExtConstWords.CUST_ORDER_NO}, packBean); + + List pullingOrderInfos = mesPullingOrderInfoRepository.findByHqlTopWhere(packBean, MesPcnExtConstWords.THREE); + + log.info("打印队列查询 --- 拉动单 --- 查询到打印数据: {} ---", CollectionUtils.isEmpty(pullingOrderInfos) ? "[]" : + pullingOrderInfos.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getWorkOrderNo()))).map(MesPullingOrderInfo::getWorkOrderNo).collect(Collectors.toList()).toString()); + + if (!CollectionUtils.isEmpty(pullingOrderInfos)) { + //根据车型代码查询车型信息 + Map> mesCustomerCarModelMap = getMesCustomerCarModelMap(bean.getOrganizeCode(), pullingOrderInfos.stream().map(MesPullingOrderInfo::getCarModelCode).distinct().collect(Collectors.toList())); + //把查出来的拉动单打印并修改打印状态为已打印 + List snLogList = new ArrayList<>(); + for (MesPullingOrderInfo pullingOrderInfo : pullingOrderInfos) { + //查询拉动组明细 + DdlPackBean partPackBean = DdlPackBean.getDdlPackBean(pullingOrderInfo.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(pullingOrderInfo.getPullingOrderNo(), MesPcnExtConstWords.PULLING_ORDER_NO, partPackBean); + List pullingOrderPartInfos = mesPullingOrderPartInfoRepository.findByHqlWhere(partPackBean); + if (!CollectionUtils.isEmpty(pullingOrderPartInfos)) { + pullingOrderInfo.setPartCount(pullingOrderPartInfos.size()); + pullingOrderPartInfos.forEach(item->{ + String[] locationArr = StringUtils.isEmpty(item.getLocation()) ? null : item.getLocation().split(MesPcnExtConstWords.COMMA); + item.setLocatAddr((null != locationArr && locationArr.length >= 1 ? locationArr[0] : MesPcnExtConstWords.ZERO_STR)); + item.setLightAddr((null != locationArr && locationArr.length >= 2 ? locationArr[1] : MesPcnExtConstWords.EMPTY)); }); + pullingOrderPartInfos = pullingOrderPartInfos.stream().filter(o -> null != o).sorted(Comparator.comparing(MesPullingOrderPartInfo::getLocatAddr)).collect(Collectors.toList()); pullingOrderInfo.setPullingOrderPartInfos(pullingOrderPartInfos); } - pullingOrderInfo.setWorkOrderNoLast(!StringUtil.isEmpty(pullingOrderInfo.getWorkOrderNo())?pullingOrderInfo.getWorkOrderNo().substring(pullingOrderInfo.getWorkOrderNo().length() - MesPcnExtConstWords.THREE):""); - pullingOrderInfo.setWorkOrderNoPre(!StringUtil.isEmpty(pullingOrderInfo.getWorkOrderNo())?pullingOrderInfo.getWorkOrderNo().substring(MesPcnExtConstWords.ZERO,pullingOrderInfo.getWorkOrderNo().length() - MesPcnExtConstWords.THREE):""); + pullingOrderInfo.setWorkOrderNoLast(!StringUtil.isEmpty(pullingOrderInfo.getWorkOrderNo())?pullingOrderInfo.getWorkOrderNo().substring(pullingOrderInfo.getWorkOrderNo().length() - MesPcnExtConstWords.FOUR):""); + pullingOrderInfo.setWorkOrderNoPre(!StringUtil.isEmpty(pullingOrderInfo.getWorkOrderNo())?pullingOrderInfo.getWorkOrderNo().substring(MesPcnExtConstWords.ZERO,pullingOrderInfo.getWorkOrderNo().length() - MesPcnExtConstWords.FOUR):""); pullingOrderInfo.setCustOrderNoLast(!StringUtil.isEmpty(pullingOrderInfo.getCustOrderNo())?pullingOrderInfo.getCustOrderNo().substring(pullingOrderInfo.getCustOrderNo().length() - MesPcnExtConstWords.FOUR):""); pullingOrderInfo.setCarModelName("车型:" + (Objects.isNull(mesCustomerCarModelMap) || StringUtil.isEmpty(pullingOrderInfo.getCarModelCode()) || !mesCustomerCarModelMap.containsKey(pullingOrderInfo.getCarModelCode()) ? "" : mesCustomerCarModelMap.get(pullingOrderInfo.getCarModelCode()).iterator().next().getCarModelName())); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesSortShippingCheckService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesSortShippingCheckService.java index 24d0fa2..2848e7a 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesSortShippingCheckService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesSortShippingCheckService.java @@ -700,6 +700,7 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService if (CollectionUtils.isEmpty(shippingOrderManagementDetails)) { DdlPackBean detailPackBean = DdlPackBean.getDdlPackBean(mesShippingOrderManagement.getOrganizeCode()); DdlPreparedPack.getNumEqualPack(mesShippingOrderManagement.getId(), "pid", detailPackBean); + DdlPreparedPack.getNumberSmallerPack(MesExtEnumUtil.SHIPPING_ORDER_DETAIL_SHIPPING_STATUS.SKIP.getValue(), "status", detailPackBean); shippingOrderManagementDetails = shippingOrderManagementDetailRepository.findByHqlWhere(detailPackBean); } //当前装车单所有发运单明细 需要报工的数据 diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderCutService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderCutService.java index 86467bd..4dd1772 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderCutService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderCutService.java @@ -30,6 +30,9 @@ public class MesWorkOrderCutService implements IMesWorkOrderCutService { private MesWorkOrderCutDetailRepository workOrderCutDetailRepository; @Autowired + private MesWorkOrderCutMaterialRepository workOrderCutMaterialRepository; + + @Autowired private MesCutSchemeRepository cutSchemeRepository; @Autowired @@ -77,6 +80,16 @@ public class MesWorkOrderCutService implements IMesWorkOrderCutService { } @Override + public List queryCutOrderMaterialList(String cutWorkOrder, String organizeCode) { + + if (StringUtils.isEmpty(organizeCode)) return Collections.emptyList(); + + return workOrderCutMaterialRepository.findByProperty( + new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.CUT_WORK_ORDER_NO}, + new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), cutWorkOrder}); + } + + @Override public MesCutSchemeEquipment getCutSchemeEquipment(String cutCode, String equipmentCode, String organizeCode) { return cutSchemeEquipmentRepository.getByProperty( diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java index 93081e8..4522235 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java @@ -8,6 +8,7 @@ import cn.estsh.i3plus.ext.mes.pcn.apiservice.dao.IMesProdRuleSortCfgDao; import cn.estsh.i3plus.ext.mes.pcn.apiservice.dao.IMesProductionRecordDao; import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException; import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesWorkOrderExtModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesWorkOrderSortReportModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService; @@ -135,6 +136,9 @@ public class MesWorkOrderService implements IMesWorkOrderService { @Autowired private IMesProdRuleSortCfgDao mesProdRuleSortCfgDao; + @Autowired + private MesPartProdGroupRepository mesPartProdGroupRao; + @Override public MesWorkOrder queryMesWorkOrder(MesWorkOrder workOrder) { @@ -220,9 +224,26 @@ public class MesWorkOrderService implements IMesWorkOrderService { MesPcnException.throwMesBusiException("产线【%s】不存在", mesWorkOrderDb.getWorkCenterCode()); } //获取生产版本 - MesProductVersion mesProductVersion = getMesProductVersion(mesWorkOrderDb); + MesProductVersion mesProductVersion = getProductVersion(mesWorkOrderDb.getOrganizeCode(), mesWorkOrderDb.getPartNo(), mesWorkOrderDb.getProductVersion()); + String bomVersion = mesProductVersion.getAlternativePartList(); + String partProdGroupCode = mesWorkOrderDb.getPartProdGroupCode(); + // partProdGroupCode 不为空,查询的数据不为空,查询数据中的获取bom方式不为空且枚举是 基于默认BOM ,才bomversion = null 否则都是通过生产版本找bom + if (!StringUtil.isEmpty(partProdGroupCode)) { + DdlPackBean partProdBean = DdlPackBean.getDdlPackBean(mesWorkOrderDb.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(partProdGroupCode, "partProdGroupCode", partProdBean); + List mesPartProdGroupList = mesPartProdGroupRao.findByHqlTopWhere(partProdBean, 1); + + // 没有零件生产组用默认找生产版本、有的话找获取bom方式枚举,枚举是基于默认BOM 则直接找 + if (!mesPartProdGroupList.isEmpty()) { + MesPartProdGroup mesPartProdGroup = mesPartProdGroupList.get(0); + if (mesPartProdGroup.getEnableBomVersion() != null && mesPartProdGroup.getEnableBomVersion() == MesExtEnumUtil.ENABLE_BOM_VERSION.ENABLE_BOM_VERSION_2.getValue()) { + log.info("基于默认BOM获取BOM"); + bomVersion = ""; + } + } + } //物料+生产版本获取bom信息 - List mesBoms = findBomList(mesPart.getOrganizeCode(), mesPart, mesProductVersion.getAlternativePartList()); + List mesBoms = findBomList(mesPart.getOrganizeCode(), mesPart, bomVersion); LOGGER.info("产线:{} 零件:{}更新工单", mesWorkOrderDb.getWorkCenterCode(), mesWorkOrderDb.getPartNo()); //更新工单 @@ -387,8 +408,7 @@ public class MesWorkOrderService implements IMesWorkOrderService { List mesBoms = mesBomRDao.findByHqlWhere(ddlPackBean); if (org.springframework.util.CollectionUtils.isEmpty(mesBoms)) { LOGGER.info("物料{}生产版本{}对应bom信息不存在", partNo, bomVersion ); - return mesBoms; -// MesPcnException.throwMesBusiException("物料【%s】生产版本【%s】对应bom信息不存在", partNo, bomVersion); + MesPcnException.throwMesBusiException("物料【%s】生产版本【%s】对应bom信息不存在", partNo, bomVersion); } MesBom next = mesBoms.iterator().next(); //如果存在多个bomCode取最新的一个 @@ -535,9 +555,26 @@ public class MesWorkOrderService implements IMesWorkOrderService { return; //throw new ImppBusiException(String.format("未找到匹配的加工单")); } - //获取生产版本 - MesProductVersion mesProductVersion = getProductVersion(organizeCode, productionRecord.getPartNo(), oldMesWorkOrder.getProductVersion()); + //获取生产版本 + MesProductVersion mesProductVersion = getProductVersion(oldMesWorkOrder.getOrganizeCode(), oldMesWorkOrder.getPartNo(), oldMesWorkOrder.getProductVersion()); + String bomVersion = mesProductVersion.getAlternativePartList(); + String partProdGroupCode = oldMesWorkOrder.getPartProdGroupCode(); + // partProdGroupCode 不为空,查询的数据不为空,查询数据中的获取bom方式不为空且枚举是 基于默认BOM ,才bomversion = null 否则都是通过生产版本找bom + if (!StringUtil.isEmpty(partProdGroupCode)) { + DdlPackBean partProdBean = DdlPackBean.getDdlPackBean(oldMesWorkOrder.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(partProdGroupCode, "partProdGroupCode", partProdBean); + List mesPartProdGroupList = mesPartProdGroupRao.findByHqlTopWhere(partProdBean, 1); + + // 没有零件生产组用默认找生产版本、有的话找获取bom方式枚举,枚举是基于默认BOM 则直接找 + if (!mesPartProdGroupList.isEmpty()) { + MesPartProdGroup mesPartProdGroup = mesPartProdGroupList.get(0); + if (mesPartProdGroup.getEnableBomVersion() != null && mesPartProdGroup.getEnableBomVersion() == MesExtEnumUtil.ENABLE_BOM_VERSION.ENABLE_BOM_VERSION_2.getValue()) { + log.info("基于默认BOM获取BOM"); + bomVersion = ""; + } + } + } //查询物料信息 DdlPackBean ddlPackBeanPart = DdlPackBean.getDdlPackBean(organizeCode); DdlPreparedPack.getStringEqualPack(productionRecord.getPartNo(), "partNo", ddlPackBeanPart); @@ -546,7 +583,7 @@ public class MesWorkOrderService implements IMesWorkOrderService { throw new ImppBusiException(String.format("物料【%s】信息不存在", productionRecord.getPartNo())); } - List mesBoms = findBomList(organizeCode, mesPart, mesProductVersion.getAlternativePartList()); + List mesBoms = findBomList(organizeCode, mesPart, bomVersion); if (CollectionUtils.isEmpty(mesBoms)) { @@ -572,7 +609,7 @@ public class MesWorkOrderService implements IMesWorkOrderService { if (StringUtil.isEmpty(productionRecord.getWorkOrderNo())) { //更新工单状态 - if (oldMesWorkOrder.getReportedQty() >= oldMesWorkOrder.getQty()) { + if (reportQty >= oldMesWorkOrder.getQty()) { propertyMap.put(MesPcnExtConstWords.WORK_ORDER_STATUS, MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue()); } else { @@ -1007,48 +1044,74 @@ public class MesWorkOrderService implements IMesWorkOrderService { } @Override - public void doProductReport(MesWorkOrder mesWorkOrder, String userName) { + public void doProductReport(MesWorkOrderExtModel mesWorkOrder, String userName) { DdlPackBean packBean = DdlPackBean.getDdlPackBean(mesWorkOrder.getOrganizeCode()); DdlPreparedPack.getNumEqualPack(mesWorkOrder.getId(),"id",packBean); MesWorkOrder mesWorkOrderDb = mesWorkOrderRDao.getByProperty(packBean); if (Objects.isNull(mesWorkOrderDb)) { MesPcnException.throwMesBusiException("工单id为【%s】工单信息不存在", mesWorkOrder.getId()); } - mesWorkOrderDb.setDescription(mesWorkOrder.getDescription()); + //查询物料信息 MesPart mesPart = iMesPartService.getMesPartByPartNo(mesWorkOrderDb.getPartNo(), mesWorkOrderDb.getOrganizeCode()); //查询产线信息 MesWorkCenter mesWorkCenter = getMesWorkCenter(mesWorkOrderDb); //获取生产版本 MesProductVersion mesProductVersion = getProductVersion(mesWorkOrderDb.getOrganizeCode(),mesWorkOrderDb.getPartNo(),mesWorkOrderDb.getProductVersion()); + String bomVersion = mesProductVersion.getAlternativePartList(); + String partProdGroupCode = mesWorkOrderDb.getPartProdGroupCode(); + // partProdGroupCode 不为空,查询的数据不为空,查询数据中的获取bom方式不为空且枚举是 基于默认BOM ,才bomversion = null 否则都是通过生产版本找bom + if (!StringUtil.isEmpty(partProdGroupCode)) { + DdlPackBean partProdBean = DdlPackBean.getDdlPackBean(mesWorkOrderDb.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(partProdGroupCode, "partProdGroupCode", partProdBean); + List mesPartProdGroupList = mesPartProdGroupRao.findByHqlTopWhere(partProdBean, 1); + + // 没有零件生产组用默认找生产版本、有的话找获取bom方式枚举,枚举是基于默认BOM 则直接找 + if (!mesPartProdGroupList.isEmpty()) { + MesPartProdGroup mesPartProdGroup = mesPartProdGroupList.get(0); + if (mesPartProdGroup.getEnableBomVersion() != null && mesPartProdGroup.getEnableBomVersion() == MesExtEnumUtil.ENABLE_BOM_VERSION.ENABLE_BOM_VERSION_2.getValue()) { + log.info("基于默认BOM获取BOM"); + bomVersion = ""; + } + } + } //物料+生产版本获取bom信息 - List mesBoms = findBomList(mesPart.getOrganizeCode(), mesPart, mesProductVersion.getAlternativePartList()); - mesWorkOrderDb.setReportedQty(MathOperation.add(mesWorkOrder.getNum(), mesWorkOrderDb.getReportedQty())); - //更新工单状态 + List mesBoms = findBomList(mesPart.getOrganizeCode(), mesPart, bomVersion); + + //汇报数量与未完成数量的修改 先给入参对象赋值, 下面没有报错的情况下再赋给工单DB对象 + mesWorkOrder.setReportedQty(MathOperation.add(mesWorkOrder.getNum(), mesWorkOrderDb.getReportedQty())); double unCompleteQty = MathOperation.sub(mesWorkOrderDb.getQty(), mesWorkOrderDb.getReportedQty()); - mesWorkOrderDb.setUnCompleteQty(unCompleteQty > 0 ? unCompleteQty : 0); - if (mesWorkOrderDb.getReportedQty() > mesWorkOrderDb.getQty()) { + mesWorkOrder.setUnCompleteQty(unCompleteQty > 0 ? unCompleteQty : 0); + + //更新工单状态 + if (mesWorkOrder.getReportedQty() > mesWorkOrderDb.getQty()) { // 以下则是超工单逻辑 // 如果产线中没有配置超工单,则直接阻断 if (!Objects.equals(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(), mesWorkCenter.getIsCheckOrderQty())) { - MesPcnException.throwMesBusiException("请检查工单数量,工单号[%s],工单数量[%s]报工数量[%s],且未配置超工单!", mesWorkOrder.getWorkOrderNo(), mesWorkOrder.getQty(), mesWorkOrder.getReportedQty()); + MesPcnException.throwMesBusiException("请检查工单数量,工单号[%s],工单数量[%s]报工数量[%s],且未配置超工单!", mesWorkOrderDb.getWorkOrderNo(), mesWorkOrderDb.getQty(), mesWorkOrderDb.getReportedQty()); } // 如果配置了超工单,且比例已经超过了配置的超工单比例,也需要阻断 - double rate = MathOperation.div((mesWorkOrderDb.getReportedQty() - mesWorkOrderDb.getQty()), mesWorkOrderDb.getQty()); + double rate = MathOperation.div((mesWorkOrder.getReportedQty() - mesWorkOrderDb.getQty()), mesWorkOrderDb.getQty()); if (rate > MathOperation.div(mesWorkCenter.getOrderRate(), 100)) { - MesPcnException.throwMesBusiException("请检查工单数量,工单号[%s],工单数量[%s]报工数量[%s],配置了超工单,但超过了比例[%s]!", mesWorkOrder.getWorkOrderNo(), mesWorkOrder.getQty(), mesWorkOrder.getReportedQty(), mesWorkCenter.getOrderRate()); + MesPcnException.throwMesBusiException("请检查工单数量,工单号[%s],工单数量[%s]报工数量[%s],配置了超工单,但超过了比例[%s]!", mesWorkOrderDb.getWorkOrderNo(), mesWorkOrderDb.getQty(), mesWorkOrderDb.getReportedQty(), mesWorkCenter.getOrderRate()); } - mesWorkOrder.setWorkOrderStatus(MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue()); - } else if (Objects.equals(mesWorkOrderDb.getReportedQty(), mesWorkOrderDb.getQty())) { + mesWorkOrderDb.setWorkOrderStatus(MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue()); + } else if (Objects.equals(mesWorkOrder.getReportedQty(), mesWorkOrderDb.getQty())) { mesWorkOrderDb.setWorkOrderStatus(MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue()); } else { mesWorkOrderDb.setWorkOrderStatus(MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue()); } - mesWorkOrderDb.setCompleteQty(mesWorkOrderDb.getReportedQty()); + + mesWorkOrderDb.setDescription(mesWorkOrder.getDescription()); + mesWorkOrderDb.setReportedQty(mesWorkOrder.getReportedQty()); + mesWorkOrderDb.setUnCompleteQty(mesWorkOrder.getUnCompleteQty()); mesWorkOrderDb.setRemark(mesWorkOrder.getRemark()); + + mesWorkOrderDb.setCompleteQty(mesWorkOrderDb.getReportedQty()); + String sn = getReportSn(mesWorkOrder.getOrganizeCode(), userName, mesPart); //更新工单 - updateMesWorkOrder(mesWorkOrderDb, userName,MesExtEnumUtil.WORK_ORDER_LOG_TYPE.REPORT,mesWorkOrder.getNum()); + updateMesWorkOrder(mesWorkOrderDb, userName, MesExtEnumUtil.WORK_ORDER_LOG_TYPE.REPORT, mesWorkOrder.getNum()); //记录条码表&加工记录表 //insertMesProductionRecord(insertMesProduceSn(mesPart, sn, userName, mesWorkOrder),mesWorkOrderDb); insertMesProduceSn(mesPart, sn, userName, mesWorkOrder); @@ -1056,9 +1119,9 @@ public class MesWorkOrderService implements IMesWorkOrderService { if (Objects.isNull(mesWorkOrderDb.getOrderFlag()) || !MesExtEnumUtil.ORDER_TYPE_IDENTIFICATION.P.getValue().equals(mesWorkOrderDb.getOrderFlag())) { //保存数据 List mesProductOffLineList = new ArrayList<>(); - String nowTime = StringUtil.isEmpty(mesWorkOrder.getDescription())?TimeTool.getNowTime(true):mesWorkOrder.getDescription(); + String nowTime = StringUtil.isEmpty(mesWorkOrder.getDescription()) ? TimeTool.getNowTime(true) : mesWorkOrder.getDescription(); for (MesBom mesBom : mesBoms) { - mesProductOffLineList.add(creatMesProductOffLine(mesWorkOrder, mesProductVersion, sn, mesBom, nowTime,mesBoms.size())); + mesProductOffLineList.add(creatMesProductOffLine(userName, mesWorkOrder, mesProductVersion, sn, mesBom, nowTime, mesBoms.size())); } mesProductOffLineRDao.saveAll(mesProductOffLineList); } @@ -1085,7 +1148,7 @@ public class MesWorkOrderService implements IMesWorkOrderService { List mesProductOffLineList = new ArrayList<>(); String nowTime = TimeTool.getNowTime(true); for (MesBom mesBom : mesBomList) { - mesProductOffLineList.add(creatMesProductOffLine(mesWorkOrder, mesProductVersion, sn, mesBom, nowTime, mesBomList.size())); + mesProductOffLineList.add(creatMesProductOffLine(userName, mesWorkOrder, mesProductVersion, sn, mesBom, nowTime, mesBomList.size())); } mesProductOffLineRDao.saveAll(mesProductOffLineList); } @@ -1241,8 +1304,7 @@ public class MesWorkOrderService implements IMesWorkOrderService { MesWorkCenter mesWorkCenter = mesWorkCenterRDao.getByProperty(ddlPackBean); if (Objects.isNull(mesWorkCenter)) { LOGGER.info("产线【%s】不存在:{}", workCenterCode ); - continue; -// MesPcnException.throwMesBusiException("产线【%s】不存在", workCenterCode); + MesPcnException.throwMesBusiException("产线【%s】不存在", workCenterCode); } MesWorkOrder item = new MesWorkOrder(); item.setOrganizeCode(organizeCode); @@ -1271,7 +1333,7 @@ public class MesWorkOrderService implements IMesWorkOrderService { DdlPreparedPack.getStringEqualPack(orderNo, "workOrderNo", orderPackBean); if (mesWorkOrderRDao.isExitByHql(orderPackBean)) { LOGGER.info("产线【%s】单号流水码生成重复:{}", workCenterCode ); - continue; + MesPcnException.throwMesBusiException("产线【%s】不存在", workCenterCode); } item.setWorkOrderNo(orderNo); item.setPartName(mesProductionRecord.getPartName()); @@ -1325,7 +1387,7 @@ public class MesWorkOrderService implements IMesWorkOrderService { MesProductVersion mesProductVersion = mesProductVersionRDao.getByProperty(ddlPackBean); if (Objects.isNull(mesProductVersion)) { LOGGER.info("物料{}产线{}生产版本{}信息不存在", item.getPartNo(), item.getWorkCenterCode(), item.getProductVersion() ); -// MesPcnException.throwMesBusiException("物料【%s】产线【%s】生产版本【%s】信息不存在", item.getPartNo(), item.getWorkCenterCode(), item.getProductVersion()); + MesPcnException.throwMesBusiException("物料【%s】产线【%s】生产版本【%s】信息不存在", item.getPartNo(), item.getWorkCenterCode(), item.getProductVersion()); } return mesProductVersion; } @@ -1338,7 +1400,7 @@ public class MesWorkOrderService implements IMesWorkOrderService { return syncFuncService.syncSerialNo(new GenSerialNoModel(MesCommonConstant.REPORT_SN).partSnParam(part.getPartSnParam()).organizeCode(organizeCode),userName, organizeCode, 1).getResultList().iterator().next().toString(); } - private MesProductOffLine creatMesProductOffLine(MesWorkOrder mesWorkOrder, MesProductVersion mesProductVersion, + private MesProductOffLine creatMesProductOffLine(String userName, MesWorkOrder mesWorkOrder, MesProductVersion mesProductVersion, String sn, MesBom mesBom, String nowTime,Integer bomTotalSize) { MesProductOffLine newMesProductOffLine; newMesProductOffLine = new MesProductOffLine(); @@ -1365,7 +1427,7 @@ public class MesWorkOrderService implements IMesWorkOrderService { newMesProductOffLine.setDescription(nowTime); newMesProductOffLine.setBomTotalSize(bomTotalSize); newMesProductOffLine.setBomCode(mesBom.getBomCode()); - ConvertBean.serviceModelInitialize(newMesProductOffLine, mesWorkOrder.getCreateUser()); + ConvertBean.serviceModelInitialize(newMesProductOffLine, userName); return newMesProductOffLine; } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/CustomFieldPrintStrategy.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/CustomFieldPrintStrategy.java new file mode 100644 index 0000000..18a8169 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/CustomFieldPrintStrategy.java @@ -0,0 +1,156 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.strategy; + +import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesCustomerPartService; +import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesPartService; +import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesTemplateService; +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesPrintedSnLogService; +import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintDataModel; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel; +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.DateUtil; +import cn.estsh.i3plus.platform.common.convert.ConvertBean; +import cn.estsh.i3plus.platform.common.tool.TimeTool; +import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker; +import cn.estsh.i3plus.pojo.mes.bean.MesCustomerPart; +import cn.estsh.i3plus.pojo.mes.bean.MesNumberRule; +import cn.estsh.i3plus.pojo.mes.bean.MesPart; +import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn; +import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel; +import cn.estsh.i3plus.pojo.mes.model.StationRequestBean; +import cn.estsh.i3plus.pojo.mes.model.StepResult; +import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.*; + +/** + * @Description :通用打印方式 + * @Reference : + * @Author : junsheng.li + * @CreateDate 2024/9/26 18:20 + * @Modify: + **/ +@Component +@Slf4j +public class CustomFieldPrintStrategy implements IPrintTemplateStrategyService { + @Autowired + private ISyncFuncService syncFuncService; + + @Autowired + private SnowflakeIdMaker snowflakeIdMaker; + + @Autowired + private IMesPartService mesPartService; + + @Autowired + private IMesPrintedSnLogService mesPrintedSnLogService; + + @Autowired + private IMesCustomerPartService mesCustomerPartService; + + @Autowired + private IMesTemplateService mesTemplateService; + + @Override + public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep) { + String organizeCode = mesProduceSnPrintModel.getOrganizeCode(); + //物料信息 + MesPart mesPart = mesPartService.getMesPartByPartNo(mesProduceSnPrintModel.getPartNo(), organizeCode); + MesCustomerPart customerPart = (!Objects.isNull(genSerialNoModel) && !CollectionUtils.isEmpty(genSerialNoModel.getDataMap()) && genSerialNoModel.getDataMap().containsKey(MesCustomerPart.class.getSimpleName())) ? (MesCustomerPart) genSerialNoModel.getDataMap().get(MesCustomerPart.class.getSimpleName()) : mesCustomerPartService.getMesCustomerPart(organizeCode,mesProduceSnPrintModel.getPartNo()); + Map customParamValue = mesTemplateService.queryMesLabelTemplateParamPartValue(mesPart.getPartNo(), mesPart.getProductLabelTemplate(), organizeCode); + if (!isStep){ + if (!Objects.isNull(customerPart)) { + genSerialNoModel.setCustPartNo(customerPart.getCustPartNo()); + } + for (int i = 0; i < mesProduceSnPrintModel.getPrintQty(); i++) { + //保存条码信息 + MesProduceSn produceSn = generateMesProduceSn(mesPart, syncFuncService.syncSerialNo(genSerialNoModel.partSnParam(mesPart.getPartSnParam()), mesProduceSnPrintModel.getUserName(), organizeCode, 1).getResultList().get(0).toString(), mesProduceSnPrintModel.getUserName(), mesProduceSnPrintModel.getQty()); + //封装打印信息 + MesProduceSnPrintDataModel printDataModel = getModel(produceSn, customerPart); + mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().clear(); + mesProduceSnPrintModel.getMesProduceSnList().add(produceSn); + Map printTemplateData = new HashMap<>(getPrintContextMap(produceSn, customerPart)); + printTemplateData.putAll(customParamValue); + mesProduceSnPrintModel.getPrintContextList().add(printTemplateData); + //保存打印记录 + mesProduceSnPrintModel.getMesPrintedSnLogList().add(mesPrintedSnLogService.getMesCustomPrintedSnLog(mesProduceSnPrintModel.getUserName(), organizeCode, printDataModel, printTemplateData)); + } + }else{ + MesProduceSn mesProduceSn = mesProduceSnPrintModel.getMesProduceSnList().get(0); + //封装打印信息 + MesProduceSnPrintDataModel printDataModel = getModel(mesProduceSn, customerPart); + mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().clear(); + Map printTemplateData = new HashMap<>(getPrintContextMap(mesProduceSn, customerPart)); + printTemplateData.putAll(customParamValue); + List> printDataMapList = new ArrayList<>(); + printDataMapList.add(printTemplateData); + mesProduceSnPrintModel.getPrintContextList().add(packResultMap(mesProduceSnPrintModel, printDataMapList)); + + //保存打印记录 + mesProduceSnPrintModel.getMesPrintedSnLogList().add(mesPrintedSnLogService.getMesCustomPrintedSnLog(mesProduceSnPrintModel.getUserName(), organizeCode, printDataModel, printTemplateData)); + } + return mesProduceSnPrintModel; + } + + private MesProduceSn generateMesProduceSn(MesPart mesPart, String sn, String userName, Double qty) { + MesProduceSn mesProduceSn = new MesProduceSn(); + mesProduceSn.setSerialNumber(snowflakeIdMaker.nextId() + ""); + mesProduceSn.setProductSn(sn); + mesProduceSn.setCustSn(sn); + mesProduceSn.setPartNo(mesPart.getPartNo()); + mesProduceSn.setPartName(mesPart.getPartName()); + mesProduceSn.setProcessLabelTemplate(mesPart.getProcessLabelTemplate()); + mesProduceSn.setCustLabelTemplate(mesPart.getCustLabelTemplate()); + mesProduceSn.setProdLabelTemplate(mesPart.getProductLabelTemplate()); + mesProduceSn.setQty(qty); + mesProduceSn.setSnStatus(MesExtEnumUtil.PRODUCE_SN_STATUS.CREATE.getValue()); + mesProduceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue()); + mesProduceSn.setLotNo(TimeTool.getToday()); + mesProduceSn.setPrintCount(MesPcnExtConstWords.ONE); + mesProduceSn.setPrintStatus(MesExtEnumUtil.PRINT_STATUS.PRINTED.getValue()); + mesProduceSn.setOrganizeCode(mesPart.getOrganizeCode()); + ConvertBean.serviceModelInitialize(mesProduceSn, userName); + return mesProduceSn; + } + + private MesProduceSnPrintDataModel getModel(MesProduceSn produceSn, MesCustomerPart customerPart) { + MesProduceSnPrintDataModel mesProduceSnPrintDataModel = new MesProduceSnPrintDataModel(); + mesProduceSnPrintDataModel.setPartNo(produceSn.getPartNo()); + mesProduceSnPrintDataModel.setPartName(produceSn.getPartName()); + if (!Objects.isNull(customerPart)) { + mesProduceSnPrintDataModel.setCustPartNo(customerPart.getCustPartNo()); + } + mesProduceSnPrintDataModel.setBarcode(produceSn.getProductSn()); + mesProduceSnPrintDataModel.setPrintDate(TimeTool.getNowTime(true)); + mesProduceSnPrintDataModel.setUserName(produceSn.getCreateUser()); + mesProduceSnPrintDataModel.setProductDate(TimeTool.parseStringFormat(produceSn.getLotNo(), DateUtil.SHORT_FORMAT, "yyyy/MM/dd")); + return mesProduceSnPrintDataModel; + } + + private Map getPrintContextMap(MesProduceSn produceSn, MesCustomerPart customerPart) { + Map result = new HashMap<>(); + result.put(MesPcnExtConstWords.PART_NO, produceSn.getPartNo()); + result.put(MesPcnExtConstWords.PART_NAME, produceSn.getPartName()); + if (!Objects.isNull(customerPart)) { + result.put(MesPcnExtConstWords.CUST_PART_NO, customerPart.getCustPartNo()); + } + result.put(MesPcnExtConstWords.PRINT_BAR_CODE, produceSn.getProductSn()); + result.put(MesPcnExtConstWords.PRINT_DATE, TimeTool.getNowTime(true)); + result.put(MesPcnExtConstWords.USER_NAME, produceSn.getCreateUser()); + return result; + } + + private Map packResultMap(MesProduceSnPrintModel printModel, List> printTemplateDateList) { + Map resultMap = new HashMap<>(); + resultMap.put(MesPcnExtConstWords.LABEL_TEMPLATE, printModel.getMesLabelTemplate()); + resultMap.put(MesPcnExtConstWords.TEMPLATE_DATA, printTemplateDateList); + resultMap.put(MesPcnExtConstWords.TEMPLATE_CODE, printModel.getMesLabelTemplate().getTemplateCode()); + resultMap.put(MesPcnExtConstWords.PRINTER, printModel.getPrinter()); + return resultMap; + } +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/station/function/MesFunctionDialogCutOrderPrintService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/station/function/MesFunctionDialogCutOrderPrintService.java index 156b399..360f404 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/station/function/MesFunctionDialogCutOrderPrintService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/station/function/MesFunctionDialogCutOrderPrintService.java @@ -1,28 +1,23 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.station.function; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService; -import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesWorkOrderCutService; -import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesEquipVariableCollectContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesWorkOrderCutDetailModel; import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseSwsService; import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.IShippingDispatchService; import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.function.IFsmModuleFunctionService; import cn.estsh.i3plus.platform.common.util.MesPcnConstWords; import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil; -import cn.estsh.i3plus.pojo.mes.bean.MesCutSchemeFg; import cn.estsh.i3plus.pojo.mes.model.ButtonDynamicModel; import cn.estsh.i3plus.pojo.mes.model.StationCustomDialogBean; import cn.estsh.i3plus.pojo.mes.model.StationRequestBean; import cn.estsh.i3plus.pojo.mes.model.StationResultBean; import com.alibaba.fastjson.JSONObject; 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 org.springframework.util.StringUtils; -import java.util.ArrayList; import java.util.List; /** @@ -38,9 +33,6 @@ public class MesFunctionDialogCutOrderPrintService extends BaseSwsService implem @Autowired private IShippingDispatchService shippingDispatchService; - @Autowired - private IMesWorkOrderCutService workOrderCutService; - @Override public Boolean doFunction(StationRequestBean reqBean, StationResultBean resultBean, ButtonDynamicModel buttonDynamicModel) { @@ -74,29 +66,6 @@ public class MesFunctionDialogCutOrderPrintService extends BaseSwsService implem List mesWorkOrderCutFgDataContextList = productionDispatchContextStepService.getMesWorkOrderCutFgDataContext(reqBean); - // 如果当前存在成品列表则直接返回 - if (CollectionUtils.isEmpty(mesWorkOrderCutFgDataContextList)) { - - //获取上下文生产扫/读信息:加工单 - List equipVariableCollectContextList = productionDispatchContextStepService.getScanWorkOrderNoContext(reqBean); - - String cutWorkOrderNo = equipVariableCollectContextList.get(0).getEquipVariableValue(); - - // 查成品列表 - List mesCutSchemeFgs = workOrderCutService.queryCutSchemeFgList(cutWorkOrderNo, reqBean.getOrganizeCode()); - - mesWorkOrderCutFgDataContextList = new ArrayList<>(); - - for (MesCutSchemeFg mesCutSchemeFg : mesCutSchemeFgs) { - MesWorkOrderCutDetailModel cutDetailModel = new MesWorkOrderCutDetailModel(); - BeanUtils.copyProperties(mesCutSchemeFg, cutDetailModel); - mesWorkOrderCutFgDataContextList.add(cutDetailModel); - } - - productionDispatchContextStepService.dispatchMesWorkOrderCutFgDataContext(reqBean, mesWorkOrderCutFgDataContextList); - - } - return CollectionUtils.isEmpty(mesWorkOrderCutFgDataContextList) ? dialogBean.unDialog() : dialogBean.obj(mesWorkOrderCutFgDataContextList); } } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyMatchSortStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyMatchSortStepService.java index 13604e6..b609510 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyMatchSortStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyMatchSortStepService.java @@ -67,6 +67,16 @@ public class MesAssemblyMatchSortStepService extends BaseStepService { //存储生产过程上下文对象 productionProcessContextStepService.dispatchProductionProcessContext(reqBean, productionProcessContext); + //获取加工结果 + String productResult = productionDispatchContextStepService.getProductResultContext(reqBean); + if (!StringUtils.isEmpty(productResult) && !productResult.equals(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue() + MesPcnExtConstWords.EMPTY) && + (StringUtils.isEmpty(productionProcessContext.getWorkCenter().getIsIgnoreQc()) + || productionProcessContext.getWorkCenter().getIsIgnoreQc().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) != 0)) { + return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, + String.format("加工单质量状态标记[%s],当前装配件清单默认跳过!", MesExtEnumUtil.PRODUCE_QC_STATUS.valueOfDescription(Integer.parseInt(productResult))), + MesPcnEnumUtil.PROMPT_SOUND.SUCCESS.getValue()); + } + //获取上下文产品加工规则数据信息集合 List prodRuleContextList = productionDispatchContextStepService.getProdRuleDataContext(reqBean); if (CollectionUtils.isEmpty(prodRuleContextList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前不存在非排序加工规则数据,请重置工序!"); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyScanStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyScanStepService.java index f4da625..75558a9 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyScanStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyScanStepService.java @@ -112,7 +112,7 @@ public class MesAssemblyScanStepService extends BaseStepService { productionCustomContextStepService.sendStepContextMessage(reqBean, scanInfo, MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN); //封装当前扫描的装配件信息 - List equipVariableCollectContextList = getAssemblySnJson(reqBean, scanInfo); + List equipVariableCollectContextList = getAssemblySnJson(reqBean, productionProcessContext, scanInfo); //从上下文中取出工位当前要使用的设备 MesCellEquipContext cellEquipContext = productionProcessContext.getCurCellEquip(); @@ -153,7 +153,17 @@ public class MesAssemblyScanStepService extends BaseStepService { productionDispatchContextStepService.dispatchScanAssemblySnContext(reqBean, equipVariableCollectContextList); //唯一加工规则场景 默认扫描一次 匹配一次 循环处理直到当前的加工规则全部匹配完毕 - if (busiType == BUSI_TYPE.ONE.value) return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.SCAN.getValue()).scanInfo(scanInfo), stepResult, String.format("当前扫描信息装配件条码[%s]!", scanInfo)); + if (busiType == BUSI_TYPE.ONE.value) { + //排序线可疑码场景下,该数据为空,验证生产线是否忽略质量状态 + if (CollectionUtils.isEmpty(equipVariableCollectContextList)) { + //保存上下文加工结果:可疑 + productionDispatchContextStepService.dispatchProductResultContext(reqBean, MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue() + MesPcnExtConstWords.EMPTY); + this.sendMessage(reqBean, new StationResultBean().writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.SCAN.getValue()).scanInfo(scanInfo), "当前扫描信息[排序线可疑码]!", MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT); + if (StringUtils.isEmpty(productionProcessContext.getWorkCenter().getIsIgnoreQc()) || productionProcessContext.getWorkCenter().getIsIgnoreQc().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) != 0) return stepResult; + else stepSendGuideAndThrowEx(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), "请扫描装配件条码!"); + } + return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.SCAN.getValue()).scanInfo(scanInfo), stepResult, String.format("当前扫描信息装配件条码[%s]!", scanInfo)); + } String suffix = repeatAssemblySnAmount == 0 ? MesPcnExtConstWords.EMPTY : String.format(",可复用个数[%s]", repeatAssemblySnAmount); @@ -265,7 +275,10 @@ public class MesAssemblyScanStepService extends BaseStepService { } //封装当前扫描的装配件信息 - private List getAssemblySnJson(StationRequestBean reqBean, String scanInfo) { + private List getAssemblySnJson(StationRequestBean reqBean, MesProductionProcessContext productionProcessContext, String scanInfo) { + + //排序线可疑码 + if (productionProcessContext.getWorkCenter().getCenterType().compareTo(MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue()) == 0 && scanInfo.equals(productionProcessContext.getSortSuspiciousCode())) return null; List equipVariableCollectContextList = new ArrayList<>(); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnPrintSortStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnPrintSortStepService.java index 5b6dc9e..d1820ad 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnPrintSortStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnPrintSortStepService.java @@ -4,9 +4,12 @@ import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesTemplateService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService; import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService; +import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdRuleContext; +import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblySortContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPartContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; +import cn.estsh.i3plus.mes.pcn.api.iservice.base.IConfigService; import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService; import cn.estsh.i3plus.platform.common.convert.ConvertBean; import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; @@ -30,6 +33,7 @@ import org.springframework.util.StringUtils; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.function.Function; import java.util.stream.Collectors; @@ -62,6 +66,9 @@ public class MesProductSnPrintSortStepService extends BaseStepService { @Autowired private IMesTemplateService mesTemplateService; + @Autowired + private IConfigService configService; + @Override public StepResult execute(StationRequestBean reqBean) { // /** @@ -83,6 +90,9 @@ public class MesProductSnPrintSortStepService extends BaseStepService { //1. 获取上下文中生成的主条码 List productionPartContextList = productionDispatchContextStepService.getProductionPartContext(reqBean); + //获取上下文产品加工规则数据信息集合 + List prodRuleContextList = productionDispatchContextStepService.getProdRuleDataContext(reqBean); + // 排除掉空腔的partContext数据 productionPartContextList = CollectionUtils.isEmpty(productionPartContextList) ? null :productionPartContextList.stream().filter(o -> o.getForeignKey() != null).collect(Collectors.toList()); @@ -97,53 +107,67 @@ public class MesProductSnPrintSortStepService extends BaseStepService { // 根据工单号分组 Map workOrderMap = getMesWorkOrderMap(reqBean, productionPartContextList); + //加工规则根据数据关联键分组 + Map prodRuleContextMap = prodRuleContextList.stream().filter(o -> null != o).collect(Collectors.toMap(MesProdRuleContext::getForeignKey, o -> o)); + // 获取零件信息上下文 Map partDataContext = productionProcessContextStepService.getPartDataContext(reqBean); + //默认客户条码编码规则配置代码 + String defaultCustMatchRule = getDefaultCustMatchRule(reqBean.getOrganizeCode()); + List snLogList = new ArrayList<>(); List> resultMap = new ArrayList<>(); - for (MesProductionPartContext sn : productionPartContextList) { + for (MesProductionPartContext productionPartContext : productionPartContextList) { // 根据工单号获取工单信息 - MesWorkOrder workOrder = workOrderMap.get(sn.getWorkOrderNo()); + MesWorkOrder workOrder = workOrderMap.get(productionPartContext.getWorkOrderNo()); - if (null == workOrder) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号:{}无效!", sn.getWorkOrderNo())); + if (null == workOrder) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号:{}无效!", productionPartContext.getWorkOrderNo())); if (CollectionUtils.isEmpty(partDataContext) || !partDataContext.containsKey(workOrder.getPartNo())) - stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]丢失零件信息缓存!", sn.getWorkOrderNo(), sn.getPartNo())); + stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]丢失零件信息缓存!", productionPartContext.getWorkOrderNo(), productionPartContext.getPartNo())); - MesPart mesPart = partDataContext.get(sn.getPartNo()); + MesPart mesPart = partDataContext.get(productionPartContext.getPartNo()); - String custMatchRule = StringUtils.isEmpty(mesPart.getCustMatchRule()) ? "WH_CUST_SN_RULE" : mesPart.getCustMatchRule(); + //验证是否配置客户条码编码规则信息 + String custMatchRule = !StringUtils.isEmpty(mesPart.getCustMatchRule()) ? mesPart.getCustMatchRule() : defaultCustMatchRule; + if (StringUtils.isEmpty(custMatchRule)) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]未维护客户条码编码规则!", productionPartContext.getWorkOrderNo(), productionPartContext.getPartNo())); DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); DdlPreparedPack.getStringEqualPack(custMatchRule, MesPcnExtConstWords.RULE_CODE, packBean); MesNumberRule numberRule = numberRuleRepository.getByProperty(packBean); + if (null == numberRule) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]客户条码编码规则[%s]无效!", productionPartContext.getWorkOrderNo(), productionPartContext.getPartNo(), custMatchRule)); - if (null == numberRule) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]客户条码编码规则[%s]无效!", sn.getWorkOrderNo(), sn.getPartNo(), custMatchRule)); - - // 从物料信息中获取标签模板 - String labelTemplateCode = partDataContext.get(sn.getPartNo()).getCustLabelTemplate(); + //获取零件表的打印模版和打印机 + String labelTemplateCode = mesPart.getCustLabelTemplate();; + String printer = mesPart.getProductPrinterCode(); + if (StringUtils.isEmpty(labelTemplateCode)) { + //获取工单装配件的打印模版和打印机 + MesProdRuleContext prodRuleContext = prodRuleContextMap.get(productionPartContext.getForeignKey()); + MesProductionAssemblySortContext productionAssemblySortContext = filterPrintInfo(prodRuleContext); + labelTemplateCode = null != productionAssemblySortContext ? productionAssemblySortContext.getPrintTemplate() : null; + printer = null != productionAssemblySortContext ? productionAssemblySortContext.getPrinter() : null; + } - if (null == labelTemplateCode) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]未在ERP物料信息维护打印模板,请检查并修改!", sn.getWorkOrderNo(), sn.getPartNo())); + if (null == labelTemplateCode) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]未在ERP物料信息维护打印模板,请检查并修改!", productionPartContext.getWorkOrderNo(), productionPartContext.getPartNo())); - MesProduceSnPrintModel mesProduceSnPrintModel = new MesProduceSnPrintModel(); // 查模板代码 MesLabelTemplate labelTemplate = mesTemplateService.getLabelTemplate(labelTemplateCode, organizeCode); + if (null == labelTemplate) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]的模板代码[%s]无效,请检查并修改!", productionPartContext.getWorkOrderNo(), productionPartContext.getPartNo(), labelTemplateCode)); - if (null == labelTemplate) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]的模板代码[%s]无效,请检查并修改!", sn.getWorkOrderNo(), sn.getPartNo(), labelTemplateCode)); - + MesProduceSnPrintModel mesProduceSnPrintModel = new MesProduceSnPrintModel(); mesProduceSnPrintModel.setMesLabelTemplate(labelTemplate); - mesProduceSnPrintModel.setPrinter(partDataContext.get(sn.getPartNo()).getProductPrinterCode()); - mesProduceSnPrintModel.setPartNo(sn.getPartNo()); + mesProduceSnPrintModel.setPrinter(printer); + mesProduceSnPrintModel.setPartNo(productionPartContext.getPartNo()); mesProduceSnPrintModel.setOrganizeCode(organizeCode); mesProduceSnPrintModel.setSourceData(workOrder); mesProduceSnPrintModel.setUserName(reqBean.getUserInfo()); //根据反射获取策略类--封装打印数据 String methodCode = labelTemplate.getMethodCode(); //模板信息丢失抛出异常 - if (StringUtils.isEmpty(methodCode)) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]的模板代码[%s]的反射类丢失,请配置!", sn.getWorkOrderNo(), sn.getPartNo(), labelTemplateCode)); + if (StringUtils.isEmpty(methodCode)) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]的模板代码[%s]的反射类丢失,请配置!", productionPartContext.getWorkOrderNo(), productionPartContext.getPartNo(), labelTemplateCode)); IPrintTemplateStrategyService strategyService = (IPrintTemplateStrategyService) SpringContextsUtil.getBean(methodCode); MesProduceSnPrintModel printModel = strategyService.execute(null, mesProduceSnPrintModel, numberRule, stepResult, reqBean, true); @@ -163,6 +187,12 @@ public class MesProductSnPrintSortStepService extends BaseStepService { return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "打印成功!"); } + //默认客户条码编码规则配置代码 + private String getDefaultCustMatchRule(String organizeCode) { + List configList = configService.doCachedConfigList(MesPcnExtConstWords.DEFAULT_CUST_MATCH_RULE, organizeCode); + return !CollectionUtils.isEmpty(configList) ? configList.get(0).getCfgValue() : null; + } + private MesPrintedSnLog getMesPrintedSnLog(StationRequestBean reqBean, MesWorkOrder workOrder,String printData) { MesPrintedSnLog snLog = new MesPrintedSnLog(); snLog.setBarcode(workOrder.getCustSn()); @@ -191,4 +221,13 @@ public class MesProductSnPrintSortStepService extends BaseStepService { return CollectionUtils.isEmpty(workOrderList) ? null : workOrderList.stream().collect(Collectors.toMap(MesWorkOrder::getWorkOrderNo, Function.identity(), (x, y) -> y)); } + + //过滤打印配置信息 + private MesProductionAssemblySortContext filterPrintInfo(MesProdRuleContext prodRuleContext) { + List productionAssemblySortContextList = prodRuleContext.getSortAssemblyDataContext(); + Optional optional = CollectionUtils.isEmpty(productionAssemblySortContextList) ? null : + productionAssemblySortContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getPrintTemplate()))).findFirst(); + return (null != optional && optional.isPresent()) ? optional.get() : null; + } + } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderCutCheckStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderCutCheckStepService.java index d3a2b90..59404dc 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderCutCheckStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderCutCheckStepService.java @@ -19,6 +19,7 @@ import cn.estsh.i3plus.pojo.mes.model.StationResultBean; import cn.estsh.i3plus.pojo.mes.model.StepResult; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; import cn.estsh.impp.framework.boot.util.SpringContextsUtil; +import com.google.common.base.Objects; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -253,6 +254,12 @@ public class MesWorkOrderCutCheckStepService extends BaseStepService { MesWorkOrderCutDetailModel workOrderCutDetailModel = new MesWorkOrderCutDetailModel(); BeanUtils.copyProperties(mesCutSchemeFg, workOrderCutDetailModel); + if (Objects.equal(cutScheme.getIsFree(), CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue())) { + Map> map = mesWorkOrderCutDetailList.stream().collect(Collectors.groupingBy(MesWorkOrderCutDetail::getPartNo)); + workOrderCutDetailModel.setQty(map.get(mesCutSchemeFg.getPartNo()).get(0).getQty()); + workOrderCutDetailModel.setPackageQty(map.get(mesCutSchemeFg.getPartNo()).get(0).getPackageQty()); + } + workOrderCutDetailModel.setCutWorkOrderNo(cutWorkOrderNo); MesCustomerPart customerPart = customerPartService.getMesCustomerPartByPartNo(mesCutSchemeFg.getPartNo(), mesPackingDefine.getCustCode(), reqBean.getOrganizeCode()); @@ -260,7 +267,7 @@ public class MesWorkOrderCutCheckStepService extends BaseStepService { MesLabelTemplate labelTemplate = mesTemplateService.getLabelTemplate(mesPackingDefine.getPackageTemplate(), reqBean.getOrganizeCode()); if (labelTemplate == null) - return stepResult.isCompleted(false).msg(String.format("请检查包装定义信息,零件号[%s]对应模板代码[%s]无效!", mesCutSchemeFg.getPartNo(), cutScheme.getCutCode())); + return stepResult.isCompleted(false).msg(String.format("请检查包装定义信息,零件号[%s]对应模板代码[%s]无效!", mesCutSchemeFg.getPartNo(), mesPackingDefine.getPackageTemplate())); MesPartContext mesPartContext = partDataExtContext.get(mesCutSchemeFg.getPartNo()); mesPartContext.setCopies(mesPackingDefine.getPrintCopies() == null ? 1 : mesPackingDefine.getPrintCopies()); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderSaveSortStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderSaveSortStepService.java index 763fdd0..b38176f 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderSaveSortStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderSaveSortStepService.java @@ -17,6 +17,7 @@ import cn.estsh.i3plus.pojo.mes.model.StationResultBean; import cn.estsh.i3plus.pojo.mes.model.StepResult; import cn.estsh.i3plus.pojo.mes.repository.MesWorkOrderRepository; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; +import com.alibaba.fastjson.JSONObject; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -26,7 +27,9 @@ import org.springframework.util.StringUtils; import javax.persistence.EntityManager; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * @Description : 保存加工单信息工步 【排序】 @@ -89,42 +92,68 @@ public class MesWorkOrderSaveSortStepService extends BaseStepService { private void doHandleWorkOrderData(StationRequestBean reqBean, StationResultBean resultBean, List productionPartContextList, MesWorkCell workCell) { + //获取上下文加工结果 + String productResult = productionDispatchContextStepService.getProductResultContext(reqBean); + + Map propertyMap; + for (MesProductionPartContext productionPartContext : productionPartContextList) { if (null == productionPartContext || StringUtils.isEmpty(productionPartContext.getForeignKey())) continue; + //判断是否末道工位 Boolean isEndWorkCell = (!StringUtils.isEmpty(workCell.getIsEndWorkCell()) && workCell.getIsEndWorkCell().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0) ? true : false; - if (!isEndWorkCell && productionPartContext.getWorkOrderStatus().compareTo(MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue()) == 0) continue; - - if (!isEndWorkCell) { - workOrderRepository.updateByPropertiesNoSync( - new String[]{MesPcnExtConstWords.ID, MesPcnExtConstWords.ORGANIZE_CODE}, - new Object[]{productionPartContext.getId(), reqBean.getOrganizeCode()}, - new String[]{MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME, - MesPcnExtConstWords.SYSTEM_SYNC_STATUS, MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME, - MesPcnExtConstWords.WORK_ORDER_STATUS, MesPcnExtConstWords.START_TIME, MesPcnExtConstWords.ONLINE_TIME}, - new Object[]{reqBean.getUserInfo(), (new SimpleDateFormat(MesPcnExtConstWords.DATE_FORMAT_SSS)).format(new Date()), - CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), MesPcnExtConstWords.EMPTY, - MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue(), productionPartContext.getOnlineTime(), productionPartContext.getOnlineTime()}); - } else { - productionPartContext.setOfflineTime(TimeTool.getNowTime(true)); - workOrderRepository.updateByPropertiesNoSync( - new String[]{MesPcnExtConstWords.ID, MesPcnExtConstWords.ORGANIZE_CODE}, - new Object[]{productionPartContext.getId(), reqBean.getOrganizeCode()}, - new String[]{MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME, - MesPcnExtConstWords.SYSTEM_SYNC_STATUS, MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME, - MesPcnExtConstWords.WORK_ORDER_STATUS, MesPcnExtConstWords.COMPLETE_QTY, MesPcnExtConstWords.UN_COMPLETE_QTY, - MesPcnExtConstWords.START_TIME, MesPcnExtConstWords.ONLINE_TIME, MesPcnExtConstWords.END_TIME, MesPcnExtConstWords.OFFLINE_TIME}, - new Object[]{reqBean.getUserInfo(), (new SimpleDateFormat(MesPcnExtConstWords.DATE_FORMAT_SSS)).format(new Date()), - CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), MesPcnExtConstWords.EMPTY, - MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue(), new Double(1), new Double(0), - productionPartContext.getOnlineTime(), productionPartContext.getOnlineTime(), productionPartContext.getOfflineTime(), productionPartContext.getOfflineTime()}); + propertyMap = new HashMap<>(); + + //质量非合格 + if (!StringUtils.isEmpty(productResult) && !productResult.equals(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue() + MesPcnExtConstWords.EMPTY)) { + propertyMap.put(MesPcnExtConstWords.QC_STATUS, Integer.valueOf(productResult)); } - log.info("工厂{}生产线{}工位{}:FSM STATE DISPATCHER --- DO STEP --- {} EXEC --- ORDER:{} --- UPDATE:[{}:{}]", - reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), - StringUtil.toLowerCaseFirst(this.getClass().getSimpleName()), productionPartContext.getWorkOrderNo(), MesPcnExtConstWords.WORK_ORDER_STATUS, !isEndWorkCell ? MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue() : MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue()); + //末工位 或者 非加工中 + if (isEndWorkCell || productionPartContext.getWorkOrderStatus().compareTo(MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue()) != 0) { + if (!isEndWorkCell) { + propertyMap.put(MesPcnExtConstWords.WORK_ORDER_STATUS, MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue()); + propertyMap.put(MesPcnExtConstWords.START_TIME, productionPartContext.getOnlineTime()); + propertyMap.put(MesPcnExtConstWords.ONLINE_TIME, productionPartContext.getOnlineTime()); + } else { + productionPartContext.setOfflineTime(TimeTool.getNowTime(true)); + propertyMap.put(MesPcnExtConstWords.WORK_ORDER_STATUS, MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue()); + propertyMap.put(MesPcnExtConstWords.START_TIME, productionPartContext.getOnlineTime()); + propertyMap.put(MesPcnExtConstWords.ONLINE_TIME, productionPartContext.getOnlineTime()); + propertyMap.put(MesPcnExtConstWords.END_TIME, productionPartContext.getOfflineTime()); + propertyMap.put(MesPcnExtConstWords.OFFLINE_TIME, productionPartContext.getOfflineTime()); + propertyMap.put(MesPcnExtConstWords.COMPLETE_QTY, new Double(1)); + propertyMap.put(MesPcnExtConstWords.UN_COMPLETE_QTY, new Double(0)); + } + } + + //当存在修改字段的情况下进行修改工单信息 + if (!CollectionUtils.isEmpty(propertyMap) && propertyMap.size() > 0) { + propertyMap.put(MesPcnExtConstWords.MODIFY_USER, reqBean.getUserInfo()); + propertyMap.put(MesPcnExtConstWords.MODIFY_DATE_TIME, (new SimpleDateFormat(MesPcnExtConstWords.DATE_FORMAT_SSS)).format(new Date())); + propertyMap.put(MesPcnExtConstWords.SYSTEM_SYNC_STATUS, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()); + propertyMap.put(MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME, MesPcnExtConstWords.EMPTY); + + String[] propertyName = new String[propertyMap.size()]; + Object[] propertyValue = new Object[propertyMap.size()]; + + Integer index = 0; + for (Map.Entry innerEntry : propertyMap.entrySet()) { + if (null == innerEntry) continue; + propertyName[index] = innerEntry.getKey(); + propertyValue[index] = innerEntry.getValue(); + index ++; + } + + workOrderRepository.updateByPropertiesNoSync(new String[]{MesPcnExtConstWords.ID, MesPcnExtConstWords.ORGANIZE_CODE}, new Object[]{productionPartContext.getId(), reqBean.getOrganizeCode()}, propertyName, propertyValue); + + log.info("工厂{}生产线{}工位{}:FSM STATE DISPATCHER --- DO STEP --- {} EXEC --- ORDER:{} --- UPDATE:{}", + reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), + StringUtil.toLowerCaseFirst(this.getClass().getSimpleName()), productionPartContext.getWorkOrderNo(), JSONObject.toJSONString(propertyMap)); + + } } } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/context/MesProductionProcessContextStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/context/MesProductionProcessContextStepService.java index eeb5810..12ff35e 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/context/MesProductionProcessContextStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/context/MesProductionProcessContextStepService.java @@ -114,7 +114,9 @@ public class MesProductionProcessContextStepService extends BaseStepService impl if (isCheckProcess && (StringUtils.isEmpty(productionProcessContext.getProcessCode()) || !productionProcessContext.getProcessCode().equals(reqBean.getProcessCode()))) processContext(reqBean, productionProcessContext); //生产过程上下文对象赋值生产过程控制全局密码 - if (StringUtils.isEmpty(productionProcessContext.getFinishCode()) || StringUtils.isEmpty(productionProcessContext.getCraftJumpCode()) || StringUtils.isEmpty(productionProcessContext.getAssemblySkipCode()) || StringUtils.isEmpty(productionProcessContext.getAssemblyCavitySkipCode())) productionPwdContext(reqBean, productionProcessContext); + if (StringUtils.isEmpty(productionProcessContext.getFinishCode()) || StringUtils.isEmpty(productionProcessContext.getCraftJumpCode()) || + StringUtils.isEmpty(productionProcessContext.getAssemblySkipCode()) || StringUtils.isEmpty(productionProcessContext.getAssemblyCavitySkipCode()) || + StringUtils.isEmpty(productionProcessContext.getSortSuspiciousCode())) productionPwdContext(reqBean, productionProcessContext); return productionProcessContext; @@ -152,7 +154,8 @@ public class MesProductionProcessContextStepService extends BaseStepService impl return productionProcessContext.finishCode((!CollectionUtils.isEmpty(cfgKeyMap) && cfgKeyMap.containsKey(MesPcnExtConstWords.CAVITY_FINISH_CODE)) ? cfgKeyMap.get(MesPcnExtConstWords.CAVITY_FINISH_CODE).get(0).getCfgValue() : MesPcnExtConstWords.CAVITY_FINISH_CODE) .craftJumpCode((!CollectionUtils.isEmpty(cfgKeyMap) && cfgKeyMap.containsKey(MesPcnExtConstWords.CRAFT_JUMP_CODE)) ? cfgKeyMap.get(MesPcnExtConstWords.CRAFT_JUMP_CODE).get(0).getCfgValue() : MesPcnExtConstWords.CRAFT_JUMP_CODE) .assemblySkipCode((!CollectionUtils.isEmpty(cfgKeyMap) && cfgKeyMap.containsKey(MesPcnExtConstWords.ASSEMBLY_SKIP_CODE)) ? cfgKeyMap.get(MesPcnExtConstWords.ASSEMBLY_SKIP_CODE).get(0).getCfgValue() : MesPcnExtConstWords.ASSEMBLY_SKIP_CODE) - .assemblyCavitySkipCode((!CollectionUtils.isEmpty(cfgKeyMap) && cfgKeyMap.containsKey(MesPcnExtConstWords.ASSEMBLY_CAVITY_SKIP_CODE)) ? cfgKeyMap.get(MesPcnExtConstWords.ASSEMBLY_CAVITY_SKIP_CODE).get(0).getCfgValue() : MesPcnExtConstWords.ASSEMBLY_CAVITY_SKIP_CODE); + .assemblyCavitySkipCode((!CollectionUtils.isEmpty(cfgKeyMap) && cfgKeyMap.containsKey(MesPcnExtConstWords.ASSEMBLY_CAVITY_SKIP_CODE)) ? cfgKeyMap.get(MesPcnExtConstWords.ASSEMBLY_CAVITY_SKIP_CODE).get(0).getCfgValue() : MesPcnExtConstWords.ASSEMBLY_CAVITY_SKIP_CODE) + .sortSuspiciousCode((!CollectionUtils.isEmpty(cfgKeyMap) && cfgKeyMap.containsKey(MesPcnExtConstWords.SORT_SUSPICIOUS_CODE)) ? cfgKeyMap.get(MesPcnExtConstWords.SORT_SUSPICIOUS_CODE).get(0).getCfgValue() : MesPcnExtConstWords.SORT_SUSPICIOUS_CODE); } //验证组织模型有效性 diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/context/MesProductionProcessContext.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/context/MesProductionProcessContext.java index c8ba4bb..643d047 100644 --- a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/context/MesProductionProcessContext.java +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/context/MesProductionProcessContext.java @@ -47,6 +47,9 @@ public class MesProductionProcessContext implements Serializable { @ApiParam("装配件整腔跳过码") private String assemblyCavitySkipCode; + @ApiParam("排序线可疑码") + private String sortSuspiciousCode; + @ApiParam("生产线信息([Json]MesWorkCenter)") private String workCenterJson; @@ -142,6 +145,12 @@ public class MesProductionProcessContext implements Serializable { return this.isNeedCache(); } + //排序线可疑码 + public MesProductionProcessContext sortSuspiciousCode(String sortSuspiciousCode) { + this.sortSuspiciousCode = sortSuspiciousCode; + return this.isNeedCache(); + } + //---------------------- 生产线对象 --------------------------------------- diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesPartModel.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesPartModel.java new file mode 100644 index 0000000..ae847db --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesPartModel.java @@ -0,0 +1,11 @@ +package cn.estsh.i3plus.ext.mes.pcn.pojo.model; + +import lombok.Data; + +@Data +public class MesPartModel { + + private String partNo; + + private String locateNo; +} diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesWorkOrderExtModel.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesWorkOrderExtModel.java new file mode 100644 index 0000000..e085211 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesWorkOrderExtModel.java @@ -0,0 +1,16 @@ +package cn.estsh.i3plus.ext.mes.pcn.pojo.model; + +import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder; +import lombok.Data; + +import java.io.Serializable; + +/** + * 继承工单表,工单MODEL + */ +@Data +public class MesWorkOrderExtModel extends MesWorkOrder implements Serializable { + + private static final long serialVersionUID = 610097769881711086L; + +} diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java index e0f9f30..994ad04 100644 --- a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java @@ -344,6 +344,9 @@ public class MesPcnExtConstWords { // 扩展字段 public static final String EXTEND = "extend"; + // 默认客户条码编码规则配置代码 + public static final String DEFAULT_CUST_MATCH_RULE = "DEFAULT_CUST_MATCH_RULE"; + // 用户缓存 public static final String USER_INFO_CONTEXT = "USER_INFO_CONTEXT"; // 装箱防错 @@ -386,6 +389,8 @@ public class MesPcnExtConstWords { public static final String ASSEMBLY_SKIP_CODE = "ASSEMBLY_SKIP_CODE"; // 装配件整腔跳过码 public static final String ASSEMBLY_CAVITY_SKIP_CODE = "ASSEMBLY_CAVITY_SKIP_CODE"; + // 排序线可疑码 + public static final String SORT_SUSPICIOUS_CODE = "SORT_SUSPICIOUS_CODE"; // 设备代码[工步参数] public static final String EQUIPMENT_CODE_UC = "EQUIPMENT_CODE"; // 模具号读一模多腔配置[工步参数] @@ -707,6 +712,8 @@ public class MesPcnExtConstWords { public static final String QR_CODE = "qrCode"; //条形码 public static final String BAR_CODE = "barCode"; + //打印条形码 + public static final String PRINT_BAR_CODE = "barcode"; //竖杠 public static final String VERTICAL_BAR = "|"; @@ -736,6 +743,8 @@ public class MesPcnExtConstWords { public static final String PARAM = "param"; //成品零件号 public static final String FG_PART_NO = "fgPartNo"; + // 打印日期 + public static final String PRINT_DATE = "printDate"; // 打印时间 public static final String PRINT_TIME = "printTime"; //替换数