From ad5934cfd89ef1d23f121be155a3cc18afe5e19b Mon Sep 17 00:00:00 2001 From: gsz Date: Sun, 29 Sep 2024 09:45:13 +0800 Subject: [PATCH 1/8] =?UTF-8?q?43289=20SPS=E6=8B=89=E5=8A=A8=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E7=B3=BB=E7=BB=9F=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/busi/MesPullingOrderInfoService.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 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 3528b0a..839cd12 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 @@ -54,6 +54,7 @@ public class MesPullingOrderInfoService implements IMesPullingOrderInfoService { @Autowired private IMesConfigService configService; + @Override public ListPager queryMesPullingOrderInfoByPager(MesPullingOrderInfo bean, Pager pager) { DdlPackBean packBean = DdlPackBean.getDdlPackBean(bean.getOrganizeCode()); @@ -110,21 +111,21 @@ public class MesPullingOrderInfoService implements IMesPullingOrderInfoService { } //强过码 如果强过为true 不校验顺序 直接扫描完成修改状态为已扫描 - //扫完单号 扫强过码校验通过后 单号顺序之前的单子变成无序 都可扫描 + //扫完单号 扫强过码校验通过后 单号顺序之前的单子变成无序 都可扫描 43289 SPS拉动提示系统异常 // String spsPass = configService.getCfgValue(bean.getOrganizeCode(), MesPcnExtConstWords.SPS_STRONGER_PASS); - if (mesPullingOrderInfo.getIsPassCode()==CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue() - ||(!Objects.isNull(bean.getIsPass()) && CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()==bean.getIsPass())) { + if ((!Objects.isNull(mesPullingOrderInfo.getIsPassCode()) && mesPullingOrderInfo.getIsPassCode() == CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) + || (!Objects.isNull(bean.getIsPass()) && CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue() == bean.getIsPass())) { mesPullingOrderInfo.setPullOrderStatus(MesExtEnumUtil.PULL_ORDER_STATUS.JIS_PULL.getValue()); ConvertBean.serviceModelUpdate(mesPullingOrderInfo, userName); mesPullingOrderInfoRepository.update(mesPullingOrderInfo); //修改当前单号之前的为可强过 - DdlPackBean packBeanPass= DdlPackBean.getDdlPackBean(bean.getOrganizeCode()); + DdlPackBean packBeanPass = DdlPackBean.getDdlPackBean(bean.getOrganizeCode()); DdlPreparedPack.getStringEqualPack(bean.getPullCode(), "pullCode", packBeanPass); DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PULL_ORDER_STATUS.KITTING_PULL.getValue(), "pullOrderStatus", packBeanOne); DdlPreparedPack.getStringSmallerNotEqualPack(bean.getPullingOrderNo(), "pullingOrderNo", packBeanPass); DdlPreparedPack.getStringEqualPack(bean.getWorkCenterCode(), "workCenterCode", packBeanPass); List mesPullingOrderInfos = mesPullingOrderInfoRepository.findByHqlWhere(packBeanPass); - if (!CollectionUtils.isEmpty(mesPullingOrderInfos)){ + if (!CollectionUtils.isEmpty(mesPullingOrderInfos)) { for (MesPullingOrderInfo pullingOrderInfo : mesPullingOrderInfos) { pullingOrderInfo.setIsPassCode(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()); ConvertBean.serviceModelUpdate(pullingOrderInfo, userName); @@ -135,7 +136,7 @@ public class MesPullingOrderInfoService implements IMesPullingOrderInfoService { DdlPackBean packBean = DdlPackBean.getDdlPackBean(bean.getOrganizeCode()); DdlPreparedPack.getStringEqualPack(bean.getPullCode(), "pullCode", packBean); DdlPreparedPack.getStringEqualPack(bean.getWorkCenterCode(), "workCenterCode", packBean); - DdlPreparedPack.getNumEqualPack(bean.getPullOrderType(), "pullOrderType", packBean); + DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PART_PULL_ORDER_TYPE.SPS_PULL.getValue(), "pullOrderType", packBean); DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PULL_ORDER_STATUS.KITTING_PULL.getValue(), "pullOrderStatus", packBean); //顺序校验 根据未扫描单号 1 、2 、3,如果没有强过码 必须先扫1 再扫2 pullingOrderNo修改位workOrderNo @@ -222,7 +223,7 @@ public class MesPullingOrderInfoService implements IMesPullingOrderInfoService { partInfo.setRuleValidation(StringUtil.isEmpty(mesPartPullDetail.getRuleValidation()) ? "" : mesPartPullDetail.getRuleValidation()); if (mesPartPullDetail.getScanValidationType() == MesExtEnumUtil.PART_PULL_DETAIL_SCAN_VALIDATION_TYPE.UN_VALIDATE.getValue()) { partInfo.setColor(MesExtEnumUtil.PART_PULL_DETAIL_COLOR.WHITE.getCode()); - }else if (partInfo.getColor()==MesExtEnumUtil.PART_PULL_DETAIL_COLOR.WHITE.getCode()){ + } else if (partInfo.getColor() == MesExtEnumUtil.PART_PULL_DETAIL_COLOR.WHITE.getCode()) { partInfo.setColor(MesExtEnumUtil.PART_PULL_DETAIL_COLOR.RED.getCode()); } } @@ -252,7 +253,7 @@ public class MesPullingOrderInfoService implements IMesPullingOrderInfoService { ConvertBean.serviceModelUpdate(partInfo, userName); mesPullingOrderPartInfoRepository.update(partInfo); } else { - MesPcnException.throwMesBusiException("工单拉动组明细【%s】数据为空", mesPullingOrderInfo.getWorkOrderNo()); + MesPcnException.throwMesBusiException("工单拉动组明细【%s】校验规则失败", mesPullingOrderInfo.getWorkOrderNo()); } } else { MesPcnException.throwMesBusiException("工单拉动组明细【%s】数据为空", mesPullingOrderInfo.getWorkOrderNo()); From 44f72a56a685f9ef5920e02ce24c866f7acb6463 Mon Sep 17 00:00:00 2001 From: gsz Date: Sun, 29 Sep 2024 11:57:34 +0800 Subject: [PATCH 2/8] =?UTF-8?q?PCN=E5=8F=91=E8=BF=90=E5=8D=95=E6=89=93?= =?UTF-8?q?=E5=8D=B0=E9=A1=B5=E9=9D=A21?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pcn/api/busi/IMesPartShippingGroupService.java | 4 ++ .../busi/MesPartShippingGroupController.java | 26 ++++++++++-- .../busi/MesPartShippingGroupService.java | 47 ++++++++++++++++++++++ 3 files changed, 73 insertions(+), 4 deletions(-) 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 02f55c0..96f668e 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 @@ -2,6 +2,8 @@ package cn.estsh.i3plus.ext.mes.pcn.api.busi; import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; import cn.estsh.i3plus.pojo.mes.bean.MesPartShippingGroup; +import cn.estsh.i3plus.pojo.mes.bean.MesPullingOrderInfo; +import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement; import io.swagger.annotations.ApiOperation; import java.util.List; @@ -20,4 +22,6 @@ public interface IMesPartShippingGroupService { @ApiOperation(value = "查询发运组数据") MesPartShippingGroup getMesPartShippingGroup(String organizeCode,String shippingGroupCode); + @ApiOperation(value = "打印发运单数据") + List doMesMesShippingOrderManagementPrint(MesShippingOrderManagement model, String userName); } 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 ef62414..f9e92d7 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 @@ -3,18 +3,21 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.busi; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesPartShippingGroupService; import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant; import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; +import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil; import cn.estsh.i3plus.pojo.mes.bean.MesPartShippingGroup; +import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement; 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; +import cn.estsh.impp.framework.boot.util.ValidatorBean; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import java.util.List; /** * @Description : @@ -50,5 +53,20 @@ public class MesPartShippingGroupController { return ImppExceptionBuilder.newInstance().buildExceptionResult(e); } } - + @PostMapping(value = "/doPrint") + @ApiOperation(value = "打印未打印拉动单后修改状态") + public ResultBean doMesMesShippingOrderManagementPrint(@RequestBody MesShippingOrderManagement model) { + try { + // 数据校验 + ValidatorBean.checkNotNull(model.getShippingGroupCode(), "发运组代码不能为空"); + List shippingOrderManagementList = shippingGroupService.doMesMesShippingOrderManagementPrint(model, AuthUtil.getSessionUser().getUserName()); + return ResultBean.success("拉动单打印成功") + .setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()) + .setResultList(shippingOrderManagementList); + } catch (ImppBusiException e) { + return ResultBean.fail(e).build(); + } catch (Exception e) { + return ResultBean.fail(e); + } + } } 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 998b4f6..1fa5b6a 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 @@ -1,14 +1,24 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesPartShippingGroupService; +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; +import cn.estsh.i3plus.pojo.base.util.StringUtil; import cn.estsh.i3plus.pojo.mes.bean.MesPartShippingGroup; +import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement; +import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagementDetail; import cn.estsh.i3plus.pojo.mes.repository.MesPartShippingGroupRepository; +import cn.estsh.i3plus.pojo.mes.repository.MesShippingOrderManagementDetailRepository; +import cn.estsh.i3plus.pojo.mes.repository.MesShippingOrderManagementRepository; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import java.util.Arrays; import java.util.List; @Service @@ -19,6 +29,11 @@ public class MesPartShippingGroupService implements IMesPartShippingGroupService @Autowired private MesPartShippingGroupRepository shippingGroupRepository; + @Autowired + private MesShippingOrderManagementRepository shippingOrderManagementRepository; + + @Autowired + private MesShippingOrderManagementDetailRepository shippingOrderManagementDetailRepository; public List findAll( DdlPackBean packBean) { List detailDeleteList = shippingGroupRepository.findByHqlWhere(packBean); return detailDeleteList; @@ -31,4 +46,36 @@ public class MesPartShippingGroupService implements IMesPartShippingGroupService return shippingGroupRepository.getByProperty(packBean); } + @Override + public List doMesMesShippingOrderManagementPrint(MesShippingOrderManagement bean, String userName) { + 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.DESC.getValue()}, new String[]{"createDatetime"}, packBean); + List pullingOrderInfos = shippingOrderManagementRepository.findByHqlWhere(packBean); + if (!CollectionUtils.isEmpty(pullingOrderInfos)) { + //把查出来的拉动单打印并修改打印状态为已打印 + for (MesShippingOrderManagement pullingOrderInfo : pullingOrderInfos) { + //查询拉动组明细 + DdlPackBean partPackBean = DdlPackBean.getDdlPackBean(pullingOrderInfo.getOrganizeCode()); + DdlPreparedPack.getNumEqualPack(pullingOrderInfo.getId(), "pid", partPackBean); + List shipOrderPartInfos = shippingOrderManagementDetailRepository.findByHqlWhere(partPackBean); + if (!CollectionUtils.isEmpty(shipOrderPartInfos)) { + pullingOrderInfo.setShipOrderPartInfos(shipOrderPartInfos); + } + + pullingOrderInfo.setPrintCount(StringUtil.isEmpty(pullingOrderInfo.getPrintCount())?1:pullingOrderInfo.getPrintCount()+1); + pullingOrderInfo.setLastPrintTime(TimeTool.getNowTime(true)); + pullingOrderInfo.setLastPrintUser(userName); + ConvertBean.serviceModelUpdate(pullingOrderInfo, userName); + } + shippingOrderManagementRepository.saveAll(pullingOrderInfos); + } + return pullingOrderInfos; + } } From 5eaf01b0765639bbcb7a53b9cbb177871ec634a2 Mon Sep 17 00:00:00 2001 From: yxw Date: Sun, 29 Sep 2024 14:51:20 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E6=8E=92=E5=BA=8F=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E6=9F=A5=E8=AF=A2=E9=80=BB=E8=BE=91=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../station/MesProductionSortModuleService.java | 78 +++++++++++++--------- 1 file changed, 48 insertions(+), 30 deletions(-) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/station/MesProductionSortModuleService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/station/MesProductionSortModuleService.java index f742ed8..d2b9d71 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/station/MesProductionSortModuleService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/station/MesProductionSortModuleService.java @@ -6,6 +6,7 @@ import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepSer import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService; import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdShiftContext; +import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPartContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesQueueOrderModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; @@ -34,6 +35,8 @@ import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; /** * @Description : 展示组件:排序生产 @@ -63,14 +66,15 @@ public class MesProductionSortModuleService extends BaseModuleService { // 获取工单信息 List> moduleContentContext = productionDispatchContextStepService.getModuleContentContext(reqBean); - //获取上下文信息 - MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getEquipmentVariableList(reqBean, MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PRODUCTION.getValue()); - MesWorkCell mesWorkCell = productionProcessContext.getWorkCell(); + // 获取产成零件信息 + List productionPartContext = productionDispatchContextStepService.getProductionPartContext(reqBean); + // 排除掉空腔的产成零件 + productionPartContext = CollectionUtils.isEmpty(productionPartContext) ? null : productionPartContext.stream().filter(o -> o.getForeignKey() != null).collect(Collectors.toList()); //获取班次信息,先查询缓存,缓存没有在查询数据库 List prodShiftDataContext = getShiftRecordStationKvBeans(reqBean); - MesProdShiftContext mesProdShiftKvBean = productionCustomContextStepService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode()); + //MesProdShiftContext mesProdShiftKvBean = productionCustomContextStepService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode()); if (CollectionUtils.isEmpty(prodShiftDataContext)) { this.sendMessage(reqBean, new StationResultBean().writeDbLog(), "请先开班", MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT); @@ -81,7 +85,7 @@ public class MesProductionSortModuleService extends BaseModuleService { this.sendMessage(reqBean, resultBean); // 获取当前工位最新修改的完成状态的队列单据数据 并根据其零件生产组代码按生产序号倒序前50条 - resultBean = getStationResultBean(queryQueueOrderTopFiftyProduceSeq(getNewQueueOrder(reqBean))); + resultBean = getStationResultBean(queryQueueOrderTopFiftyProduceSeq(reqBean, getNewPartProdGroupCode(reqBean, productionPartContext))); this.sendMessage(reqBean, resultBean); //验证工位是否锁定 @@ -110,40 +114,54 @@ public class MesProductionSortModuleService extends BaseModuleService { return attrBeanList; } - private List queryQueueOrderTopFiftyProduceSeq(MesQueueOrder queueOrder) { + private List queryQueueOrderTopFiftyProduceSeq(StationRequestBean reqBean, List partProdGroupCodeList) { - if (queueOrder == null) return new ArrayList<>(); - - Pager pager = new Pager(); - pager.setStartRow(1); - pager.setCurrentPage(1); - pager.setPageSize(50); - DdlPackBean packBean = DdlPackBean.getDdlPackBean(queueOrder.getOrganizeCode()); - DdlPreparedPack.getStringEqualPack(queueOrder.getWorkCenterCode(), MesPcnExtConstWords.WORK_CENTER_CODE, packBean); - DdlPreparedPack.getStringEqualPack(queueOrder.getWorkCellCode(), MesPcnExtConstWords.WORK_CELL_CODE, packBean); - DdlPreparedPack.getStringEqualPack(queueOrder.getPartProdGroupCode(), MesPcnExtConstWords.PART_PROD_GROUP_CODE, packBean); - packBean.setOrderByStr(" order by produceSeq desc "); - List queueOrderList = queueOrderRepository.findByHqlWherePage(packBean, pager); + if (CollectionUtils.isEmpty(partProdGroupCodeList)) return new ArrayList<>(); List queueOrderModels = new ArrayList<>(); - if (!CollectionUtils.isEmpty(queueOrderList)) { - - boolean isComplete = false; - for (MesQueueOrder mesQueueOrder : queueOrderList) { - MesQueueOrderModel queueOrderModel = new MesQueueOrderModel(); - BeanUtils.copyProperties(mesQueueOrder, queueOrderModel); - String color = MesExtEnumUtil.COLOR.GREEN.getValue(); - if (queueOrderModel.getStatus() == MesExtEnumUtil.QUEUE_ORDER_STATUS.FINISH.getValue()) isComplete = true; - else if (!isComplete) color = MesExtEnumUtil.COLOR.WHITE.getValue(); - else if (isComplete && (queueOrderModel.getStatus() == MesExtEnumUtil.QUEUE_ORDER_STATUS.CREATE.getValue())) color = MesExtEnumUtil.COLOR.YELLOW.getValue(); - queueOrderModel.setColor(color); - queueOrderModels.add(queueOrderModel); + for (String partProdGroupCode : partProdGroupCodeList) { + Pager pager = new Pager(); + pager.setStartRow(1); + pager.setCurrentPage(1); + pager.setPageSize(50); + DdlPackBean packBean = DdlPackBean.getDdlPackBean(reqBean.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(reqBean.getWorkCenterCode(), MesPcnExtConstWords.WORK_CENTER_CODE, packBean); + DdlPreparedPack.getStringEqualPack(reqBean.getWorkCellCode(), MesPcnExtConstWords.WORK_CELL_CODE, packBean); + DdlPreparedPack.getStringEqualPack(partProdGroupCode, MesPcnExtConstWords.PART_PROD_GROUP_CODE, packBean); + packBean.setOrderByStr(" order by produceSeq desc "); + List queueOrderList = queueOrderRepository.findByHqlWherePage(packBean, pager); + + //List queueOrderModels = new ArrayList<>(); + if (!CollectionUtils.isEmpty(queueOrderList)) { + + boolean isComplete = false; + for (MesQueueOrder mesQueueOrder : queueOrderList) { + MesQueueOrderModel queueOrderModel = new MesQueueOrderModel(); + BeanUtils.copyProperties(mesQueueOrder, queueOrderModel); + String color = MesExtEnumUtil.COLOR.GREEN.getValue(); + if (queueOrderModel.getStatus() == MesExtEnumUtil.QUEUE_ORDER_STATUS.FINISH.getValue()) isComplete = true; + else if (!isComplete) color = MesExtEnumUtil.COLOR.WHITE.getValue(); + else if (isComplete && (queueOrderModel.getStatus() == MesExtEnumUtil.QUEUE_ORDER_STATUS.CREATE.getValue())) color = MesExtEnumUtil.COLOR.YELLOW.getValue(); + queueOrderModel.setColor(color); + queueOrderModels.add(queueOrderModel); + } } } return queueOrderModels; } + private List getNewPartProdGroupCode(StationRequestBean reqBean, List productionPartContext) { + + // 获取工单信息 + if (!CollectionUtils.isEmpty(productionPartContext)) { + return productionPartContext.stream().map(MesProductionPartContext::getPartProdGroupCode).distinct().collect(Collectors.toList()); + } + + MesQueueOrder queueOrder = getNewQueueOrder(reqBean); + return Stream.of(queueOrder.getPartProdGroupCode()).collect(Collectors.toList()); + } + private MesQueueOrder getNewQueueOrder(StationRequestBean reqBean) { DdlPackBean packBean = DdlPackBean.getDdlPackBean(reqBean.getOrganizeCode()); DdlPreparedPack.getStringEqualPack(reqBean.getWorkCenterCode(), MesPcnExtConstWords.WORK_CENTER_CODE, packBean); From f82c6626a1a4c8b2e2583b3e9f79c71d9acb5067 Mon Sep 17 00:00:00 2001 From: yxw Date: Sun, 29 Sep 2024 14:59:02 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E8=A3=85=E9=85=8D=E7=9B=AE=E8=A7=86?= =?UTF-8?q?=E5=8D=95=E6=89=93=E5=8D=B0=E7=AD=96=E7=95=A5=E7=B1=BB=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=BC=95=E7=94=A8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/print/strategy/AssemblyVisualListPrintStrategy.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/AssemblyVisualListPrintStrategy.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/AssemblyVisualListPrintStrategy.java index 4e1d79b..7747db6 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/AssemblyVisualListPrintStrategy.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/AssemblyVisualListPrintStrategy.java @@ -75,7 +75,7 @@ public class AssemblyVisualListPrintStrategy implements IPrintTemplateStrategySe // 客户零件号 resultMap.put(MesPcnExtConstWords.CUST_PART_NO, workOrder.getPartNo()); // 客户条码 - resultMap.put(MesPcnExtConstWords.SN, workOrder.getSn()); + resultMap.put(MesPcnExtConstWords.SN, workOrder.getCustSn()); // 车型名称 resultMap.put(MesPcnExtConstWords.REMARK, customerCarModel == null ? "" : customerCarModel.getRemark()); // 重打印 From b8cf5c7cfe8f4355fccb8fd1bd66342c769c1ded Mon Sep 17 00:00:00 2001 From: "jhforever.wang@estsh.com" Date: Sun, 29 Sep 2024 17:39:11 +0800 Subject: [PATCH 5/8] =?UTF-8?q?byd=20=E8=A3=85=E9=85=8D=E4=BB=B6=E7=AD=96?= =?UTF-8?q?=E7=95=A5=20=E6=88=AA=E5=8F=96=E5=8F=B3=E4=BE=A7=E6=B5=81?= =?UTF-8?q?=E6=B0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IMesProductionDispatchContextStepService.java | 21 +++ .../MesNumberRuleMatchSubstringSerialService.java | 81 +++++++++ .../rulematch/MesNumberRuleMatchVkmService.java | 3 +- .../step/MesProductSnGenerateStepService.java | 22 ++- .../step/MesProductSnPrintNosortStepService.java | 193 +++++++++++++++++++++ .../step/MesProductSnPrintStepService.java | 172 +----------------- .../MesProductionDispatchContextStepService.java | 49 +++++- .../pcn/pojo/context/MesProdTempDataContext.java | 41 +++++ .../MesProductionAssemblyNosortContext.java | 3 + .../ext/mes/pcn/pojo/util/MesPcnExtConstWords.java | 3 +- 10 files changed, 412 insertions(+), 176 deletions(-) create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/rulematch/MesNumberRuleMatchSubstringSerialService.java create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnPrintNosortStepService.java create mode 100644 modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/context/MesProdTempDataContext.java diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProductionDispatchContextStepService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProductionDispatchContextStepService.java index ce928da..6bd1a27 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProductionDispatchContextStepService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProductionDispatchContextStepService.java @@ -175,6 +175,9 @@ public interface IMesProductionDispatchContextStepService { @ApiOperation(value = "获取上下文产品加工规则数据信息集合") List getProdRuleDataContext(StationRequestBean reqBean); + @ApiOperation(value = "获取上下文产品加工规则数据信息集合") + List getProdRuleDataContext(String organizeCode, String workCenterCode, String workCellCode); + @ApiOperation(value = "验证上下文产品加工规则信息集合是否存在") Boolean checkProdRuleDataIsExistContext(StationRequestBean reqBean); @@ -229,4 +232,22 @@ public interface IMesProductionDispatchContextStepService { @ApiOperation(value = "删除进料可回用包装") Boolean removeProductionRecyclablePackageContext(StationRequestBean reqBean); + @ApiOperation(value = "获取上下文临时数据信息集合") + List getProdTempDataContext(StationRequestBean reqBean); + + @ApiOperation(value = "获取上下文临时数据信息集合") + List getProdTempDataContext(String organizeCode, String workCenterCode, String workCellCode); + + @ApiOperation(value = "保存上下文临时数据信息集合") + Boolean dispatchProdTempDataContext(StationRequestBean reqBean, List prodTempDataContextList); + + @ApiOperation(value = "保存上下文临时数据信息集合") + Boolean dispatchProdTempDataContext(String organizeCode, String workCenterCode, String workCellCode, List prodTempDataContextList); + + @ApiOperation(value = "删除上下文临时数据信息集合") + void removeProdTempDataContext(StationRequestBean reqBean); + + @ApiOperation(value = "删除上下文临时数据信息集合") + void removeProdTempDataContext(String organizeCode, String workCenterCode, String workCellCode); + } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/rulematch/MesNumberRuleMatchSubstringSerialService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/rulematch/MesNumberRuleMatchSubstringSerialService.java new file mode 100644 index 0000000..174a0cc --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/rulematch/MesNumberRuleMatchSubstringSerialService.java @@ -0,0 +1,81 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.rulematch; + +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesNumberRuleMatchDispatchService; +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService; +import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdTempDataContext; +import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblyNosortContext; +import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; +import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; +import cn.estsh.impp.framework.boot.util.SpringContextsUtil; +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.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** + * 规则并截取右侧流水 + */ +@Slf4j +@Service +public class MesNumberRuleMatchSubstringSerialService implements IMesNumberRuleMatchDispatchService { + + @Autowired + private IMesProductionDispatchContextStepService productionDispatchContextStepService; + + @Override + public Map matchNumberRule(String organizeCode, String sn, Object... params) { + // 校验正则表达式 + Map result = ((IMesNumberRuleMatchDispatchService) SpringContextsUtil.getBean(MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.MATCH_TYPE_20.getStrategyClass())).matchNumberRule(organizeCode, sn, params); + + if (!(Boolean) result.get(MesPcnExtConstWords.RESULT)) return result; + + MesProductionAssemblyNosortContext context = (MesProductionAssemblyNosortContext) params[0]; + + if (StringUtils.isEmpty(context.getSerialLength())) { + result.put(MesPcnExtConstWords.RESULT, false); + result.put(MesPcnExtConstWords.MESSAGE, String.format("装配件ID[%s]信息未维护[截取的流水号长度]!", context.getSourceId())); + return result; + } + + if (context.getSerialLength().compareTo(sn.length()) > 0 ) { + result.put(MesPcnExtConstWords.RESULT, false); + result.put(MesPcnExtConstWords.MESSAGE, String.format("装配件条码[%s]不匹配截取的流水号长度[%s]!", sn, context.getSerialLength())); + return result; + } + + //截取右侧流水, 生成零件条码工步需要使用此流水生成新的零件条码 + String serialNo = substringSerial(context.getAssemblySn(), context.getSerialLength()); + + //一腔如果存在两个这个规则的情况下,需要验证两次的流水号是否一直 + List prodTempDataContextList = productionDispatchContextStepService.getProdTempDataContext(organizeCode, context.getWorkCenterCode(), context.getWorkCellCode()); + Optional optional = CollectionUtils.isEmpty(prodTempDataContextList) ? null : + prodTempDataContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getForeignKey()) && o.getForeignKey().compareTo(context.getForeignKey()) == 0)).findFirst(); + if (null == optional || !optional.isPresent() || StringUtils.isEmpty(optional.get().getSerialNo())) { + if (CollectionUtils.isEmpty(prodTempDataContextList)) prodTempDataContextList = new ArrayList<>(); + prodTempDataContextList.add(new MesProdTempDataContext(organizeCode, context.getForeignKey()).serialNo(serialNo)); + productionDispatchContextStepService.dispatchProdTempDataContext(organizeCode, context.getWorkCenterCode(), context.getWorkCellCode(), prodTempDataContextList); + return result; + } + + if (!serialNo.equals(optional.get().getSerialNo())) { + result.put(MesPcnExtConstWords.RESULT, false); + result.put(MesPcnExtConstWords.MESSAGE, String.format("装配件条码[%s]的右侧流水号[%s]与首次扫描的流水号[%s]不一致!", sn, serialNo, optional.get().getSerialNo())); + return result; + } + + return result; + + } + + //截取右侧流水, 生成零件条码工步需要使用此流水生成新的零件条码 + private String substringSerial(String sn, Integer serialLength) { + return sn.substring(sn.length() - serialLength); + } + +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/rulematch/MesNumberRuleMatchVkmService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/rulematch/MesNumberRuleMatchVkmService.java index 4e9ad27..022f4f3 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/rulematch/MesNumberRuleMatchVkmService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/rulematch/MesNumberRuleMatchVkmService.java @@ -9,7 +9,6 @@ import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; import cn.estsh.i3plus.pojo.mes.bean.MesPartPackageRule; -import cn.estsh.i3plus.pojo.mes.model.StationRequestBean; import cn.estsh.i3plus.pojo.mes.repository.IMesPartPackageRuleDetailRepository; import cn.estsh.i3plus.pojo.mes.repository.IMesPartPackageRuleRepository; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; @@ -56,7 +55,7 @@ public class MesNumberRuleMatchVkmService implements IMesNumberRuleMatchDispatch //当前装配件清单信息 MesProductionAssemblyContext context = (MesProductionAssemblyContext) params[0]; //获取上下文产品加工规则数据信息集合 - List prodRuleContextList = productionDispatchContextStepService.getProdRuleDataContext(new StationRequestBean(organizeCode, context.getWorkCenterCode(), context.getWorkCellCode())); + List prodRuleContextList = productionDispatchContextStepService.getProdRuleDataContext(organizeCode, context.getWorkCenterCode(), context.getWorkCellCode()); if (CollectionUtils.isEmpty(prodRuleContextList)) { result.put(MesPcnExtConstWords.RESULT, false); result.put(MesPcnExtConstWords.MESSAGE, "当前不存在非排序加工规则数据,请重置工序!"); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnGenerateStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnGenerateStepService.java index 8a07dc2..ad476c5 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnGenerateStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnGenerateStepService.java @@ -166,11 +166,15 @@ public class MesProductSnGenerateStepService extends BaseStepService { else produceSn = new MesProduceSn(); if (StringUtils.isEmpty(produceSn.getProductSn())) { - produceSn.setProductSn((null != productionPsInContext && !StringUtils.isEmpty(productionPsInContext.getProductSn())) ? productionPsInContext.getProductSn() : doGererateSerialNo(reqBean, resultBean, getProduceSnNumberRule(reqBean, resultBean, part), part, prodShiftContext.getShiftCode())); + if (null != productionPsInContext && !StringUtils.isEmpty(productionPsInContext.getProductSn())) produceSn.setProductSn(productionPsInContext.getProductSn()); + else produceSn.setProductSn(doGererateSerialNo(reqBean, resultBean, + generateGenSerialNoModel(reqBean, resultBean, getProduceSnNumberRule(reqBean, resultBean, part), part).shiftCode(prodShiftContext.getShiftCode()).foreignKey(prodRuleContext.getForeignKey()))); produceSn.setCustSn(produceSn.getProductSn()); } - if (StringUtils.isEmpty(produceSn.getSerialNumber())) produceSn.setSerialNumber(doGererateSerialNo(reqBean, resultBean, MesPcnExtConstWords.DEFAULT_SERIAL_NUMBER_RULE, part, prodShiftContext.getShiftCode())); + if (StringUtils.isEmpty(produceSn.getSerialNumber())) + produceSn.setSerialNumber(doGererateSerialNo(reqBean, resultBean, + generateGenSerialNoModel(reqBean, resultBean, MesPcnExtConstWords.DEFAULT_SERIAL_NUMBER_RULE, part))); produceSn.setQty(new Double(1)); @@ -224,16 +228,18 @@ public class MesProductSnGenerateStepService extends BaseStepService { } - private String doGererateSerialNo(StationRequestBean reqBean, StationResultBean resultBean, String ruleCode, MesPart part, String shiftCode) { + private GenSerialNoModel generateGenSerialNoModel(StationRequestBean reqBean, StationResultBean resultBean, String ruleCode, MesPart part) { + return new GenSerialNoModel(ruleCode).prodLocation(reqBean.getWorkCenterCode()).partNo(part.getPartNo()) + .putDataMap(MesPart.class.getSimpleName(), part).basicInfo(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode()); + } + + private String doGererateSerialNo(StationRequestBean reqBean, StationResultBean resultBean, GenSerialNoModel serialNoModel) { try { - return syncFuncService.syncSerialNo( - new GenSerialNoModel(ruleCode).prodLocation(reqBean.getWorkCenterCode()).partNo(part.getPartNo()).shiftCode(shiftCode) - .putDataMap(MesPart.class.getSimpleName(), part).basicInfo(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode()), - reqBean.getUserInfo(), reqBean.getOrganizeCode(), 1).getResultList().get(0).toString(); + return syncFuncService.syncSerialNo(serialNoModel, reqBean.getUserInfo(), reqBean.getOrganizeCode(), 1).getResultList().get(0).toString(); } catch (ImppBusiException e) { stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), e.getErrorDetail()); } catch (Exception e) { - String webMsg = String.format("零件编码[%s]编码规则代码[%s]生成零件条码%s", part.getPartNo(), ruleCode, fsmRouteDataService.handleFsmCfgOrDefault(reqBean, MesPcnEnumUtil.FSM_CFG.FSM_EXCEPTION_MSG.getCode())); + String webMsg = String.format("零件编码[%s]编码规则代码[%s]生成零件条码%s", serialNoModel.getPartNo(), serialNoModel.getRuleCode(), fsmRouteDataService.handleFsmCfgOrDefault(reqBean, MesPcnEnumUtil.FSM_CFG.FSM_EXCEPTION_MSG.getCode())); this.sendMessage(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.ERROR.getValue()), webMsg, MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT); this.cacheException(reqBean, reqBean.getStepName(), webMsg, e, true); foundExThrowNoShowMsg(); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnPrintNosortStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnPrintNosortStepService.java new file mode 100644 index 0000000..e7f29ad --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnPrintNosortStepService.java @@ -0,0 +1,193 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step; + +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService; +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.MesProductionPsOutContext; +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.serviceimpl.fsm.BaseStepService; +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.MesPcnEnumUtil; +import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; +import cn.estsh.i3plus.pojo.mes.bean.*; +import cn.estsh.i3plus.pojo.mes.model.StationRequestBean; +import cn.estsh.i3plus.pojo.mes.model.StationResultBean; +import cn.estsh.i3plus.pojo.mes.model.StepResult; +import cn.estsh.i3plus.pojo.mes.repository.IMesPrintedSnLogRepository; +import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateParamRepository; +import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateRepository; +import cn.estsh.i3plus.pojo.mes.repository.MesProduceSnRepository; +import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; +import cn.estsh.impp.framework.boot.util.SpringContextsUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Description : 打印主条码 【非排序】 + * @Reference : + * @Author : Castle + * @CreateDate : 2024/6/6 13:39 + * @Modify: + **/ +@Service("mesProductSnPrintNosortStepService") +public class MesProductSnPrintNosortStepService extends BaseStepService { + + @Autowired + private IMesProductionDispatchContextStepService productionDispatchContextStepService; + + @Autowired + private MesLabelTemplateRepository labelTemplateRao; + + @Autowired + private MesLabelTemplateParamRepository labelTemplateParamRao; + + @Autowired + private IMesPrintedSnLogRepository snLogRao; + + @Autowired + private MesProduceSnRepository mesProduceSnRao; + + @Override + public StepResult execute(StationRequestBean reqBean) { +// /** +// * Map +// * valueList:List> +// * paramInfo:{ +// * templateContent:xxxx, +// * labelTemplateParamList: List> +// * } +// * +// * 根据foreign找出加工规则对应的上下文,判断是否需要打印 +// * +// */ + String organizeCode = reqBean.getOrganizeCode(); + StationResultBean resultBean = new StationResultBean(); + StepResult stepResult = StepResult.getSuccessComplete(); + + //获取上下文加工结果 + String prodResult = productionDispatchContextStepService.getProductResultContext(reqBean); + //验证加工结果是否满足参数条件: 可疑/报废是否打印 + if (checkIsMatchProdResult(reqBean, prodResult, MesExtEnumUtil.PRODUCT_RESULT_EQUIP_PARAM.PRODUCT_SUSPICIOUS) || checkIsMatchProdResult(reqBean, prodResult, MesExtEnumUtil.PRODUCT_RESULT_EQUIP_PARAM.PRODUCT_SCRAP)) + return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, String.format("打印失败:%s!", MesExtEnumUtil.PRODUCT_RESULT_EQUIP_PARAM.codeOfDescription(prodResult))); + + // 根据foreign找出加工规则对应的上下文,判断是否需要打印 + List prodRuleDataContext = productionDispatchContextStepService.getProdRuleDataContext(reqBean); + Map> prodRuleContextMap = prodRuleDataContext.stream().collect(Collectors.groupingBy(MesProdRuleContext::getForeignKey)); + //需要打印的数据 String 是打印模板code + Map> resultData = new HashMap<>(); + //用于保存客户模板代码 和 模板信息关系 + Map labelTemplateMap = new HashMap<>(); + //返回打印标识 给前端 + //1. 获取上下文中生成的主条码 + List productionPsOutContextList = productionDispatchContextStepService.getProductionPsOutContext(reqBean); + /** + * 重构,返回给前端打印数据 + */ + List printModelList = new ArrayList<>(); + //2. 获取条码需要模板、模板代码、打印机 --- 循环遍历条码 封装数据 + for (MesProductionPsOutContext sn : productionPsOutContextList) { + List mesProdRuleContexts = prodRuleContextMap.get(sn.getForeignKey()); + if (mesProdRuleContexts == null || mesProdRuleContexts.isEmpty()) { + stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("零件号[%s]的加工规则丢失,请配置!", sn.getPartNo())); + } + MesProdRuleContext mesProdRuleContext = mesProdRuleContexts.get(0); + Integer isPrint = mesProdRuleContext.getIsPrint(); + if (isPrint == null || isPrint == CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) { + continue; + } + String prodLabelTemplate = sn.getProdLabelTemplate(); + if (prodLabelTemplate == null) { + stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("零件号[%s]的模板代码[%s]的模板信息丢失,请配置!", sn.getPartNo(), prodLabelTemplate)); + } + + MesProduceSnPrintModel mesProduceSnPrintModel = new MesProduceSnPrintModel(); + // 查模板代码 + MesLabelTemplate labelTemplate = getLabelTemplate(prodLabelTemplate, organizeCode); + mesProduceSnPrintModel.setMesLabelTemplate(labelTemplate); + mesProduceSnPrintModel.setProductSn(sn.getProductSn()); + mesProduceSnPrintModel.setPartNo(sn.getPartNo()); + mesProduceSnPrintModel.setOrganizeCode(organizeCode); + List snList = new ArrayList<>(); + snList.add(sn); + mesProduceSnPrintModel.getMesProduceSnList().addAll(snList); + //模板信息丢失抛出异常 + if (labelTemplate == null) { + stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("零件号[%s]的模板代码[%s]的模板信息丢失,请配置!", sn.getPartNo(), prodLabelTemplate)); + } + //根据反射获取策略类--封装打印数据 + String methodCode = labelTemplate.getMethodCode(); + //模板信息丢失抛出异常 + if (methodCode == null) { + stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("零件号[%s]的模板代码[%s]的反射类丢失,请配置!", sn.getPartNo(), prodLabelTemplate)); + } + IPrintTemplateStrategyService strategyService = (IPrintTemplateStrategyService) SpringContextsUtil.getBean(methodCode); + // GenSerialNoModel model , MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep + MesProduceSnPrintModel printModel = strategyService.execute(null, mesProduceSnPrintModel, null, stepResult, reqBean, true); + printModelList.add(printModel); + } + + //前端接收到busiTyep是customComponent,并且 dataType是file类型的消息,就需要打印后续消息里的数据,一个模板对应多个打印数据 + resultBean.setBusiType(MesPcnEnumUtil.STATION_BUSI_TYPE.CUSTOM_COMPONENT.getValue()); + resultBean.setDataType(MesPcnEnumUtil.STATION_DATA_TYPE.FILE.getValue()); + resultBean.setResultObj(printModelList); + //3. 发送数据给到前端 + this.sendMessage(reqBean, resultBean); + List snLogList = printModelList.stream().map(MesProduceSnPrintModel::getMesPrintedSnLogList).flatMap(List::stream).collect(Collectors.toList()); + //更新打印状态 + for (MesProductionPsOutContext outSn : productionPsOutContextList) { + DdlPackBean packBean = DdlPackBean.getDdlPackBean(outSn.getOrganizeCode()); + DdlPreparedPack.getNumEqualPack(outSn.getId(), MesPcnExtConstWords.ID, packBean); + mesProduceSnRao.updateByProperties( + new String[]{MesPcnExtConstWords.PRINT_STATUS, MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME}, + new Object[]{MesExtEnumUtil.PRINT_STATUS.PRINTED.getValue(), reqBean.getUserInfo(), TimeTool.getNowTime(true)}, packBean); + } + //保存打印条码记录 + snLogRao.saveAll(snLogList); + return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "打印成功!"); + } + + //验证加工结果是否满足参数条件: 可疑/报废是否打印 + private Boolean checkIsMatchProdResult(StationRequestBean reqBean, String prodResult, MesExtEnumUtil.PRODUCT_RESULT_EQUIP_PARAM prodResultEnum) { + + if (StringUtils.isEmpty(prodResult)) return false; + if (!prodResult.equals(prodResultEnum.getCode())) return false; + + Optional> stepParamMap = getStepParams(reqBean); + String unPrintParam = (null != stepParamMap && stepParamMap.isPresent() && stepParamMap.get().containsKey(prodResultEnum.name())) ? stepParamMap.get().get(prodResultEnum.name()).getParamValue() : null; + if (StringUtils.isEmpty(unPrintParam)) return false; + + return true; + + } + + /** + * 根据templateCode 获取模板信息 + * + * @param templateCode + * @param organizeCode + * @return + */ + private MesLabelTemplate getLabelTemplate(String templateCode, String organizeCode) { + DdlPackBean templatePackBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getStringEqualPack(templateCode, "templateCode", templatePackBean); + List mesLabelTemplateList = labelTemplateRao.findByHqlWhere(templatePackBean); + MesLabelTemplate mesLabelTemplate = null; + if (!mesLabelTemplateList.isEmpty()) { + mesLabelTemplate = mesLabelTemplateList.get(0); + //级联获取labelTemplateParam + DdlPackBean templateParamPackBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getNumEqualPack(mesLabelTemplate.getId(), "templateId", templateParamPackBean); + List params = labelTemplateParamRao.findByHqlWhere(templateParamPackBean); + mesLabelTemplate.setLabelTemplateParamList(params); + } + return mesLabelTemplate; + } +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnPrintStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnPrintStepService.java index c696411..ea7c274 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnPrintStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnPrintStepService.java @@ -1,34 +1,14 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step; -import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService; -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.MesProductionPsOutContext; -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.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService; import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService; -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.MesPcnEnumUtil; -import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; -import cn.estsh.i3plus.pojo.mes.bean.*; +import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.IStepService; import cn.estsh.i3plus.pojo.mes.model.StationRequestBean; -import cn.estsh.i3plus.pojo.mes.model.StationResultBean; import cn.estsh.i3plus.pojo.mes.model.StepResult; -import cn.estsh.i3plus.pojo.mes.repository.IMesPrintedSnLogRepository; -import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateParamRepository; -import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateRepository; -import cn.estsh.i3plus.pojo.mes.repository.MesProduceSnRepository; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; import cn.estsh.impp.framework.boot.util.SpringContextsUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.util.StringUtils; - -import java.util.*; -import java.util.stream.Collectors; /** * @Description : 打印主条码 @@ -37,157 +17,21 @@ import java.util.stream.Collectors; * @CreateDate : 2024/6/6 13:39 * @Modify: **/ -@Service +@Service("mesProductSnPrintStepService") public class MesProductSnPrintStepService extends BaseStepService { @Autowired - private IMesProductionDispatchContextStepService productionDispatchContextStepService; - - @Autowired - private MesLabelTemplateRepository labelTemplateRao; - - @Autowired - private MesLabelTemplateParamRepository labelTemplateParamRao; - - @Autowired - private IMesPrintedSnLogRepository snLogRao; - - @Autowired - private MesProduceSnRepository mesProduceSnRao; + private IMesProductionProcessContextStepService productionProcessContextStepService; @Override public StepResult execute(StationRequestBean reqBean) { -// /** -// * Map -// * valueList:List> -// * paramInfo:{ -// * templateContent:xxxx, -// * labelTemplateParamList: List> -// * } -// * -// * 根据foreign找出加工规则对应的上下文,判断是否需要打印 -// * -// */ - String organizeCode = reqBean.getOrganizeCode(); - StationResultBean resultBean = new StationResultBean(); - StepResult stepResult = StepResult.getSuccessComplete(); - //获取上下文加工结果 - String prodResult = productionDispatchContextStepService.getProductResultContext(reqBean); - //验证加工结果是否满足参数条件: 可疑/报废是否打印 - if (checkIsMatchProdResult(reqBean, prodResult, MesExtEnumUtil.PRODUCT_RESULT_EQUIP_PARAM.PRODUCT_SUSPICIOUS) || checkIsMatchProdResult(reqBean, prodResult, MesExtEnumUtil.PRODUCT_RESULT_EQUIP_PARAM.PRODUCT_SCRAP)) - return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, String.format("打印失败:%s!", MesExtEnumUtil.PRODUCT_RESULT_EQUIP_PARAM.codeOfDescription(prodResult))); + //排序线 打印客户条码工步 + if (MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue() == productionProcessContextStepService.getCenterType(reqBean)) return ((IStepService) SpringContextsUtil.getBean("mesProductSnPrintSortStepService")).executeInState(reqBean); - // 根据foreign找出加工规则对应的上下文,判断是否需要打印 - List prodRuleDataContext = productionDispatchContextStepService.getProdRuleDataContext(reqBean); - Map> prodRuleContextMap = prodRuleDataContext.stream().collect(Collectors.groupingBy(MesProdRuleContext::getForeignKey)); - //需要打印的数据 String 是打印模板code - Map> resultData = new HashMap<>(); - //用于保存客户模板代码 和 模板信息关系 - Map labelTemplateMap = new HashMap<>(); - //返回打印标识 给前端 - //1. 获取上下文中生成的主条码 - List productionPsOutContextList = productionDispatchContextStepService.getProductionPsOutContext(reqBean); - /** - * 重构,返回给前端打印数据 - */ - List printModelList = new ArrayList<>(); - //2. 获取条码需要模板、模板代码、打印机 --- 循环遍历条码 封装数据 - for (MesProductionPsOutContext sn : productionPsOutContextList) { - List mesProdRuleContexts = prodRuleContextMap.get(sn.getForeignKey()); - if (mesProdRuleContexts == null || mesProdRuleContexts.isEmpty()) { - stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("零件号[%s]的加工规则丢失,请配置!", sn.getPartNo())); - } - MesProdRuleContext mesProdRuleContext = mesProdRuleContexts.get(0); - Integer isPrint = mesProdRuleContext.getIsPrint(); - if (isPrint == null || isPrint == CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) { - continue; - } - String prodLabelTemplate = sn.getProdLabelTemplate(); - if (prodLabelTemplate == null) { - stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("零件号[%s]的模板代码[%s]的模板信息丢失,请配置!", sn.getPartNo(), prodLabelTemplate)); - } - - MesProduceSnPrintModel mesProduceSnPrintModel = new MesProduceSnPrintModel(); - // 查模板代码 - MesLabelTemplate labelTemplate = getLabelTemplate(prodLabelTemplate, organizeCode); - mesProduceSnPrintModel.setMesLabelTemplate(labelTemplate); - mesProduceSnPrintModel.setProductSn(sn.getProductSn()); - mesProduceSnPrintModel.setPartNo(sn.getPartNo()); - mesProduceSnPrintModel.setOrganizeCode(organizeCode); - List snList = new ArrayList<>(); - snList.add(sn); - mesProduceSnPrintModel.getMesProduceSnList().addAll(snList); - //模板信息丢失抛出异常 - if (labelTemplate == null) { - stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("零件号[%s]的模板代码[%s]的模板信息丢失,请配置!", sn.getPartNo(), prodLabelTemplate)); - } - //根据反射获取策略类--封装打印数据 - String methodCode = labelTemplate.getMethodCode(); - //模板信息丢失抛出异常 - if (methodCode == null) { - stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("零件号[%s]的模板代码[%s]的反射类丢失,请配置!", sn.getPartNo(), prodLabelTemplate)); - } - IPrintTemplateStrategyService strategyService = (IPrintTemplateStrategyService) SpringContextsUtil.getBean(methodCode); - // GenSerialNoModel model , MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep - MesProduceSnPrintModel printModel = strategyService.execute(null, mesProduceSnPrintModel, null, stepResult, reqBean, true); - printModelList.add(printModel); - } - - //前端接收到busiTyep是customComponent,并且 dataType是file类型的消息,就需要打印后续消息里的数据,一个模板对应多个打印数据 - resultBean.setBusiType(MesPcnEnumUtil.STATION_BUSI_TYPE.CUSTOM_COMPONENT.getValue()); - resultBean.setDataType(MesPcnEnumUtil.STATION_DATA_TYPE.FILE.getValue()); - resultBean.setResultObj(printModelList); - //3. 发送数据给到前端 - this.sendMessage(reqBean, resultBean); - List snLogList = printModelList.stream().map(MesProduceSnPrintModel::getMesPrintedSnLogList).flatMap(List::stream).collect(Collectors.toList()); - //更新打印状态 - for (MesProductionPsOutContext outSn : productionPsOutContextList) { - DdlPackBean packBean = DdlPackBean.getDdlPackBean(outSn.getOrganizeCode()); - DdlPreparedPack.getNumEqualPack(outSn.getId(), MesPcnExtConstWords.ID, packBean); - mesProduceSnRao.updateByProperties( - new String[]{MesPcnExtConstWords.PRINT_STATUS, MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME}, - new Object[]{MesExtEnumUtil.PRINT_STATUS.PRINTED.getValue(), reqBean.getUserInfo(), TimeTool.getNowTime(true)}, packBean); - } - //保存打印条码记录 - snLogRao.saveAll(snLogList); - return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "打印成功!"); - } - - //验证加工结果是否满足参数条件: 可疑/报废是否打印 - private Boolean checkIsMatchProdResult(StationRequestBean reqBean, String prodResult, MesExtEnumUtil.PRODUCT_RESULT_EQUIP_PARAM prodResultEnum) { - - if (StringUtils.isEmpty(prodResult)) return false; - if (!prodResult.equals(prodResultEnum.getCode())) return false; - - Optional> stepParamMap = getStepParams(reqBean); - String unPrintParam = (null != stepParamMap && stepParamMap.isPresent() && stepParamMap.get().containsKey(prodResultEnum.name())) ? stepParamMap.get().get(prodResultEnum.name()).getParamValue() : null; - if (StringUtils.isEmpty(unPrintParam)) return false; - - return true; + //非排序线 打印主条码工步 + return ((IStepService) SpringContextsUtil.getBean("mesProductSnPrintNosortStepService")).executeInState(reqBean); } - /** - * 根据templateCode 获取模板信息 - * - * @param templateCode - * @param organizeCode - * @return - */ - private MesLabelTemplate getLabelTemplate(String templateCode, String organizeCode) { - DdlPackBean templatePackBean = DdlPackBean.getDdlPackBean(organizeCode); - DdlPreparedPack.getStringEqualPack(templateCode, "templateCode", templatePackBean); - List mesLabelTemplateList = labelTemplateRao.findByHqlWhere(templatePackBean); - MesLabelTemplate mesLabelTemplate = null; - if (!mesLabelTemplateList.isEmpty()) { - mesLabelTemplate = mesLabelTemplateList.get(0); - //级联获取labelTemplateParam - DdlPackBean templateParamPackBean = DdlPackBean.getDdlPackBean(organizeCode); - DdlPreparedPack.getNumEqualPack(mesLabelTemplate.getId(), "templateId", templateParamPackBean); - List params = labelTemplateParamRao.findByHqlWhere(templateParamPackBean); - mesLabelTemplate.setLabelTemplateParamList(params); - } - return mesLabelTemplate; - } } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/context/MesProductionDispatchContextStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/context/MesProductionDispatchContextStepService.java index 66dcd0e..e15258e 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/context/MesProductionDispatchContextStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/context/MesProductionDispatchContextStepService.java @@ -29,7 +29,13 @@ import java.util.StringJoiner; @Service("mesProductionDispatchContextStepService") public class MesProductionDispatchContextStepService extends BaseStepService implements IMesProductionDispatchContextStepService { - private String getContextKey(StationRequestBean reqBean) { return getFsmBusikey(reqBean, new StringJoiner(MesPcnExtConstWords.COLON).add(MesPcnExtConstWords.PRODUCTION_PROCESS_CONTEXT).add(MesPcnExtConstWords.BUSI_DATA_CONTEXT).toString()); } + private String getContextKey(StationRequestBean reqBean) { + return getFsmBusikey(reqBean, new StringJoiner(MesPcnExtConstWords.COLON).add(MesPcnExtConstWords.PRODUCTION_PROCESS_CONTEXT).add(MesPcnExtConstWords.BUSI_DATA_CONTEXT).toString()); + } + + private String getContextKey(String organizeCode, String workCenterCode, String workCellCode) { + return new StringJoiner(MesPcnExtConstWords.COLON).add(organizeCode).add(workCenterCode).add(workCellCode).add(MesPcnExtConstWords.PRODUCTION_PROCESS_CONTEXT).add(MesPcnExtConstWords.BUSI_DATA_CONTEXT).toString(); + } //清除上下文中的所有业务数据 @Override @@ -385,6 +391,13 @@ public class MesProductionDispatchContextStepService extends BaseStepService imp return !StringUtils.isEmpty(prodRuleNosortJson) ? JSONObject.parseArray(prodRuleNosortJson, MesProdRuleContext.class) : null; } + //获取上下文产品加工规则信息集合 + @Override + public List getProdRuleDataContext(String organizeCode, String workCenterCode, String workCellCode) { + String prodRuleNosortJson = getFsmBusiData(organizeCode, getContextKey(organizeCode, workCenterCode, workCellCode), MesPcnExtConstWords.PROD_RULE_DATA_CONTEXT); + return !StringUtils.isEmpty(prodRuleNosortJson) ? JSONObject.parseArray(prodRuleNosortJson, MesProdRuleContext.class) : null; + } + //验证上下文产品加工规则信息集合是否存在 @Override public Boolean checkProdRuleDataIsExistContext(StationRequestBean reqBean) { @@ -511,4 +524,38 @@ public class MesProductionDispatchContextStepService extends BaseStepService imp return true; } + @Override + public List getProdTempDataContext(StationRequestBean reqBean) { + String prodTempDataJson = getFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), MesPcnExtConstWords.PROD_TEMP_DATA_CONTEXT); + return !StringUtils.isEmpty(prodTempDataJson) ? JSONObject.parseArray(prodTempDataJson, MesProdTempDataContext.class) : null; + } + + @Override + public List getProdTempDataContext(String organizeCode, String workCenterCode, String workCellCode) { + String prodTempDataJson = getFsmBusiData(organizeCode, getContextKey(organizeCode, workCenterCode, workCellCode), MesPcnExtConstWords.PROD_TEMP_DATA_CONTEXT); + return !StringUtils.isEmpty(prodTempDataJson) ? JSONObject.parseArray(prodTempDataJson, MesProdTempDataContext.class) : null; + } + + @Override + public Boolean dispatchProdTempDataContext(StationRequestBean reqBean, List prodTempDataContextList) { + if (CollectionUtils.isEmpty(prodTempDataContextList)) return false; + return dispatchFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), MesPcnExtConstWords.PROD_TEMP_DATA_CONTEXT, JSONObject.toJSONString(prodTempDataContextList)); + } + + @Override + public Boolean dispatchProdTempDataContext(String organizeCode, String workCenterCode, String workCellCode, List prodTempDataContextList) { + if (CollectionUtils.isEmpty(prodTempDataContextList)) return false; + return dispatchFsmBusiData(organizeCode, getContextKey(organizeCode, workCenterCode, workCellCode), MesPcnExtConstWords.PROD_TEMP_DATA_CONTEXT, JSONObject.toJSONString(prodTempDataContextList)); + } + + @Override + public void removeProdTempDataContext(StationRequestBean reqBean) { + removeFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), MesPcnExtConstWords.PROD_TEMP_DATA_CONTEXT); + } + + @Override + public void removeProdTempDataContext(String organizeCode, String workCenterCode, String workCellCode) { + removeFsmBusiData(organizeCode, getContextKey(organizeCode, workCenterCode, workCellCode), MesPcnExtConstWords.PROD_TEMP_DATA_CONTEXT); + } + } diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/context/MesProdTempDataContext.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/context/MesProdTempDataContext.java new file mode 100644 index 0000000..1c99f65 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/context/MesProdTempDataContext.java @@ -0,0 +1,41 @@ +package cn.estsh.i3plus.ext.mes.pcn.pojo.context; + +import io.swagger.annotations.ApiParam; +import lombok.Data; + +import java.io.Serializable; + +/** + * 生产过程上下文对象-临时数据 + */ +@Data +public class MesProdTempDataContext implements Serializable { + + private static final long serialVersionUID = -5184127961206077150L; + + @ApiParam("组织代码") + public String organizeCode; + + @ApiParam(name = "数据关联键") + private Integer foreignKey; + + @ApiParam("流水号") + public String serialNo; + + public MesProdTempDataContext() {} + + public MesProdTempDataContext(String organizeCode) { + this.organizeCode = organizeCode; + } + + public MesProdTempDataContext(String organizeCode, Integer foreignKey) { + this.organizeCode = organizeCode; + this.foreignKey = foreignKey; + } + + public MesProdTempDataContext serialNo(String serialNo) { + this.serialNo = serialNo; + return this; + } + +} diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/context/MesProductionAssemblyNosortContext.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/context/MesProductionAssemblyNosortContext.java index 59a715d..698ecfe 100644 --- a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/context/MesProductionAssemblyNosortContext.java +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/context/MesProductionAssemblyNosortContext.java @@ -37,6 +37,9 @@ public class MesProductionAssemblyNosortContext extends MesProductionAssemblyCon @ApiParam(name = "产成品图") private String outPartNoPic; + @ApiParam(value = "截取的流水号长度") + private Integer serialLength; + public MesProductionAssemblyNosortContext() {} public MesProductionAssemblyNosortContext copy(MesProdRuleContext prodRuleContext, MesAssemblyNosortCfg assemblyNosortCfg, String assemblySn) { 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 70940fb..41cb7e8 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 @@ -453,9 +453,10 @@ public class MesPcnExtConstWords { public static final String RAW_PART_CHARGING_DATA_CONTEXT = "RAW_PART_CHARGING_DATA_CONTEXT"; // 上下文: 可回用包装数据信息 public static final String PRODUCTION_RECYCLABLE_PACKAGE_CONTEXT = "PRODUCTION_RECYCLABLE_PACKAGE_CONTEXT"; - // 上下文: 裁片工单成品数据 public static final String WORK_ORDER_CUT_FG_DATA_CONTEXT = "WORK_ORDER_CUT_FG_DATA_CONTEXT"; + // 上下文: 临时数据 + public static final String PROD_TEMP_DATA_CONTEXT = "PROD_TEMP_DATA_CONTEXT"; //OPC_API_PARAM From a536b82cfdbd9ddeab5170592fd21fa13e843f37 Mon Sep 17 00:00:00 2001 From: yxw Date: Sun, 29 Sep 2024 17:49:32 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E6=8E=92=E5=BA=8F=E4=BA=A7=E7=BA=BF?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E6=9D=A1=E7=A0=81=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../print/strategy/CustSnPrintStrategy.java | 169 +++++++++++++++ .../step/MesProductSnPrintSortStepService.java | 238 +++++++++++++++++++++ .../ext/mes/pcn/apiservice/util/BarCodeUtils.java | 113 ++++++++++ .../ext/mes/pcn/pojo/util/MesPcnExtConstWords.java | 27 +++ 4 files changed, 547 insertions(+) create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/CustSnPrintStrategy.java create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnPrintSortStepService.java create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/util/BarCodeUtils.java diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/CustSnPrintStrategy.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/CustSnPrintStrategy.java new file mode 100644 index 0000000..42fc015 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/CustSnPrintStrategy.java @@ -0,0 +1,169 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.strategy; + +import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService; +import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.BarCodeUtils; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel; +import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; +import cn.estsh.i3plus.pojo.mes.bean.*; +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 com.google.zxing.WriterException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.*; + +/** + * @Description : 客户标签打印 + * @Reference : + * @Author : xinwang.yi + * @CreateDate : 2024/9/29 16:43 + * @Modify: + **/ +@Component +@Slf4j +public class CustSnPrintStrategy implements IPrintTemplateStrategyService { + + @Override + public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel model, + MesNumberRule numberRule , StepResult stepResult, StationRequestBean reqBean, + Boolean isStep) { + + Map modelMap = (Map) model.getSourceData(); + + // 工单信息 + MesWorkOrder workOrder = (MesWorkOrder) modelMap.get("mesWorkOrder"); + + if (workOrder == null) { + log.info("CustSnPrintStrategy --- execute --- 工单信息为空"); + return null; + } + + // 客户零件号 + String custPartNo = workOrder.getCustPartNo(); + // 客户零件号 前缀 排除后四位 + String custPartNoPrefix = StringUtils.isEmpty(custPartNo) ? "" : custPartNo.substring(0, custPartNo.length() - 4); + // 客户零件号 后四位 + String custPartNoAfterFour = StringUtils.isEmpty(custPartNo) ? "" : custPartNo.substring(custPartNo.length() - 4).toUpperCase(); + + // 返回的结果集合 + List> printDataMapList = new ArrayList<>(); + // 单个标签参数值 + Map resultMap = new HashMap<>(); + // 客户条码 + resultMap.put(MesPcnExtConstWords.CUST_SN, workOrder.getCustSn()); + // 客户零件号 前缀 排除后四位 + resultMap.put(MesPcnExtConstWords.CUST_PART_NO_PERFIX, custPartNoPrefix); + // 客户零件号 后四位 + resultMap.put(MesPcnExtConstWords.CUST_PART_NO_AFTER_FOUR, custPartNoAfterFour); + + String snOriginal = workOrder.getCustSn(); + + String[] split = snOriginal.split(""); + StringBuilder rsStr = new StringBuilder(); + for (int i = 0; i < split.length-1; i++) { + rsStr.append(split[i]).append("%RS%"); + } + rsStr.append(split[split.length - 1]); + StringBuilder gsStr = new StringBuilder(); + String[] split1 = rsStr.toString().split(""); + for (int i = 0; i < split1.length-1; i++) { + gsStr.append(split1[i]).append("%GS%"); + } + gsStr.append(split1[split1.length-1]); + String[] split2 = gsStr.toString().split(""); + + String sn = split2[0]+"%EOT%"; + + if (numberRule == null) { + log.error("CustSnPrintStrategy --- exec --- numberRule 为空"); + return model; + } + + if (StringUtils.isEmpty(numberRule.getRuleLengthSpiltExt())) { + log.error("CustSnPrintStrategy --- exec --- 规则属性长度拼接 为空"); + return model; + } + + // 规则属性长度拼接 + String[] ruleLengthSpiltExt = numberRule.getRuleLengthSpiltExt().split(MesPcnExtConstWords.COMMA); + + /* + * 1 2 3 4 5 6 7 8 9 10 11 12 + * 编码规则:{spiltRule}{spiltRule}{spiltRule}{partNo}{spiltRule}{spiltRule}{spiltRule}{year}{day}{spiltRule}{serialNo}{spiltRule} + * 规则属性长度拼接:14,14,5,8,7,9,7,2,3,5,4,9 + * 拼接固定字符:[)>%RS%06%GS%Y,4110000000000X,%GS%P,%GS%12V,545238347,%GS%T1A,A2B4C,%RS%%EOT% + * 条码:[)>06Y4110000000000XP26560848Z12V545238347T1A24269A2B4C0005 + * 转换后条码:[)>%RS%06%GS%Y4110000000000X%GS%P26560850%GS%12V545238347%GS%T1A24269A2B4C0019%RS + * 客户条码 VPPS 取 第 2 + * 客户条码 DUNS 取 第 5 + * 客户条码后半部分取 7 的后两位 A1到 11 + * */ + + int vppsLengthStart = 0; + int vppsLengthEnd = 0; + int dunsLengthStart = 0; + int dunsLengthEnd = 0; + int afterContentPerfixLengthStart = 0; + int afterContentPerfixLengthEnd = 0; + int afterContentLengthStart = 0; + int afterContentLengthEnd = 0; + for (int index = 0; index < ruleLengthSpiltExt.length; index++) { + if (index < 1) vppsLengthStart += Integer.parseInt(ruleLengthSpiltExt[index]); + if (index < 2) vppsLengthEnd += Integer.parseInt(ruleLengthSpiltExt[index]); + if (index < 5) dunsLengthStart += Integer.parseInt(ruleLengthSpiltExt[index]); + if (index < 6) dunsLengthEnd += Integer.parseInt(ruleLengthSpiltExt[index]); + if (index < 6) afterContentPerfixLengthStart += Integer.parseInt(ruleLengthSpiltExt[index]); + if (index < 7) afterContentPerfixLengthEnd += Integer.parseInt(ruleLengthSpiltExt[index]); + if (index < 8) afterContentLengthStart += Integer.parseInt(ruleLengthSpiltExt[index]); + if (index < 11) afterContentLengthEnd += Integer.parseInt(ruleLengthSpiltExt[index]); + } + + String custSnVPPS = sn.substring(vppsLengthStart, vppsLengthEnd); + String custSnDUNS = sn.substring(dunsLengthStart, dunsLengthEnd); + String custSnAfterPerfixContent = sn.substring(afterContentPerfixLengthStart, afterContentPerfixLengthEnd); + custSnAfterPerfixContent = custSnAfterPerfixContent.substring(custSnAfterPerfixContent.length() - 2, custSnAfterPerfixContent.length()); + String custSnAfterContent = custSnAfterPerfixContent + sn.substring(afterContentLengthStart, afterContentLengthEnd); + + // 客户条码 VPPS + resultMap.put(MesPcnExtConstWords.CUST_SN_VPPS, custSnVPPS); + // 客户条码 DUNS + resultMap.put(MesPcnExtConstWords.CUST_SN_DUNS, custSnDUNS); + // 客户条码 CUST_AFTER_CONTENT + resultMap.put(MesPcnExtConstWords.CUST_SN_AFTER_CONTENT, custSnAfterContent); + // 客户条码 dataMatrix + ByteArrayOutputStream dataMatrixCode = null; + try { + dataMatrixCode = BarCodeUtils.createDataMatrixCode(workOrder.getCustSn()); + } catch (WriterException e) { + log.error("CustSnPrintStrategy --- execute --- 报错:{}", e.getMessage()); + return model; + } catch (IOException e) { + log.error("CustSnPrintStrategy --- execute --- 报错:{}", e.getMessage()); + return model; + } + resultMap.put(MesPcnExtConstWords.CUST_SN_DATA_MATRIX, dataMatrixCode); + + printDataMapList.add(resultMap); + + model.setPrintContextList(packResultMapList(model, printDataMapList)); + + return model; + } + + private List> packResultMapList(MesProduceSnPrintModel printModel, List> printTemplateDateList) { + List> resultMapList = new ArrayList<>(); + 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()); + resultMapList.add(resultMap); + return resultMapList; + } + +} 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 new file mode 100644 index 0000000..f1d8f7e --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnPrintSortStepService.java @@ -0,0 +1,238 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step; + +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService; +import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService; +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.serviceimpl.fsm.BaseStepService; +import cn.estsh.i3plus.platform.common.convert.ConvertBean; +import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; +import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil; +import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; +import cn.estsh.i3plus.pojo.mes.bean.*; +import cn.estsh.i3plus.pojo.mes.model.StationRequestBean; +import cn.estsh.i3plus.pojo.mes.model.StationResultBean; +import cn.estsh.i3plus.pojo.mes.model.StepResult; +import cn.estsh.i3plus.pojo.mes.repository.*; +import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; +import cn.estsh.impp.framework.boot.util.SpringContextsUtil; +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.stream.Collectors; + +/** + * @Description : 打印客户条码 + * @Reference : + * @Author : Castle + * @CreateDate : 2024/6/6 13:39 + * @Modify: + **/ +@Slf4j +@Service +public class MesProductSnPrintSortStepService extends BaseStepService { + + @Autowired + private IMesProductionDispatchContextStepService productionDispatchContextStepService; + + @Autowired + private MesLabelTemplateRepository labelTemplateRao; + + @Autowired + private MesLabelTemplateParamRepository labelTemplateParamRao; + + @Autowired + private IMesPrintedSnLogRepository snLogRao; + + @Autowired + private MesWorkOrderRepository workOrderRepository; + + @Autowired + private MesNumberRuleRepository numberRuleRepository; + + @Override + public StepResult execute(StationRequestBean reqBean) { +// /** +// * Map +// * valueList:List> +// * paramInfo:{ +// * templateContent:xxxx, +// * labelTemplateParamList: List> +// * } +// * +// * 根据foreign找出加工规则对应的上下文,判断是否需要打印 +// * +// */ + String organizeCode = reqBean.getOrganizeCode(); + StationResultBean resultBean = new StationResultBean(); + StepResult stepResult = StepResult.getSuccessComplete(); + + //返回打印标识 给前端 + //1. 获取上下文中生成的主条码 + List productionPartContextList = productionDispatchContextStepService.getProductionPartContext(reqBean); + + // 排除掉空腔的partContext数据 + productionPartContextList = CollectionUtils.isEmpty(productionPartContextList) ? null :productionPartContextList.stream().filter(o -> o.getForeignKey() != null).collect(Collectors.toList()); + + /** + * 重构,返回给前端打印数据 + */ + List printModelList = new ArrayList<>(); + //2. 获取条码需要模板、模板代码、打印机 --- 循环遍历条码 封装数据 + + if (CollectionUtils.isEmpty(productionPartContextList)) return stepResult; + + // 根据工单号分组 + Map workOrderMap = getMesWorkOrderMap(reqBean, productionPartContextList); + + // 获取零件信息上下文 + Map partDataContext = productionDispatchContextStepService.getPartDataContext(reqBean); + + List needModifyWorkOrderList = new ArrayList<>(); + + DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getStringEqualPack("WH_CUST_SN_RULE", MesPcnExtConstWords.RULE_CODE, packBean); + MesNumberRule numberRule = numberRuleRepository.getByProperty(packBean); + + if (numberRule == null) { + log.error("MesCustSnPrintStepService --- exec --- 客户条码编码规则[WH_CUST_SN_RULE]无效"); + return stepResult; + } + + for (MesProductionPartContext sn : productionPartContextList) { + + // 根据工单号获取工单信息 + MesWorkOrder workOrder = workOrderMap.get(sn.getWorkOrderNo()); + + if (workOrder == null) { + log.error("MesCustSnPrintStepService --- exec --- 工单号:{}无效", sn.getWorkOrderNo()); + continue; + } + + if ((partDataContext == null) || (!partDataContext.containsKey(workOrder.getPartNo()))) { + log.error("MesCustSnPrintStepService --- exec --- 工单号:{}零件{}丢失缓存", sn.getWorkOrderNo(), sn.getPartNo()); + continue; + } + + // 从物料信息中获取标签模板 + String labelTemplateCode = partDataContext.get(sn.getPartNo()).getProductLabelTemplate(); + + // 从物料信息中获取打印机 + String productPrinterCode = partDataContext.get(sn.getPartNo()).getProductPrinterCode(); + + if (labelTemplateCode == null) { + stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]未在ERP物料信息维护打印模板,请检查并修改!", sn.getWorkOrderNo(), sn.getPartNo())); + } + + if (StringUtils.isEmpty(productPrinterCode)) { + stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]未在ERP物料信息维护打印机,请检查并修改!", sn.getWorkOrderNo(), sn.getPartNo())); + } + + MesProduceSnPrintModel mesProduceSnPrintModel = new MesProduceSnPrintModel(); + // 查模板代码 + MesLabelTemplate labelTemplate = getLabelTemplate(labelTemplateCode, organizeCode); + + if (labelTemplate == null) { + stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]的模板代码[%s]无效,请检查并修改!", sn.getWorkOrderNo(), sn.getPartNo(), labelTemplateCode)); + } + + mesProduceSnPrintModel.setMesLabelTemplate(labelTemplate); + mesProduceSnPrintModel.setPrinter(productPrinterCode); + mesProduceSnPrintModel.setPartNo(sn.getPartNo()); + mesProduceSnPrintModel.setOrganizeCode(organizeCode); + mesProduceSnPrintModel.setSourceData(workOrder); + + //根据反射获取策略类--封装打印数据 + String methodCode = labelTemplate.getMethodCode(); + //模板信息丢失抛出异常 + if (StringUtils.isEmpty(methodCode)) { + stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]的模板代码[%s]的反射类丢失,请配置!", sn.getWorkOrderNo(), sn.getPartNo(), labelTemplateCode)); + } + IPrintTemplateStrategyService strategyService = (IPrintTemplateStrategyService) SpringContextsUtil.getBean(methodCode); + // GenSerialNoModel model , MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep + MesProduceSnPrintModel printModel = strategyService.execute(null, mesProduceSnPrintModel, null, stepResult, reqBean, true); + printModelList.add(printModel); + needModifyWorkOrderList.add(workOrder); + + } + + //前端接收到busiTyep是customComponent,并且 dataType是file类型的消息,就需要打印后续消息里的数据,一个模板对应多个打印数据 + resultBean.setBusiType(MesPcnEnumUtil.STATION_BUSI_TYPE.CUSTOM_COMPONENT.getValue()); + resultBean.setDataType(MesPcnEnumUtil.STATION_DATA_TYPE.FILE.getValue()); + resultBean.setResultObj(printModelList); + //3. 发送数据给到前端 + this.sendMessage(reqBean, resultBean); + List snLogList = printModelList.stream().map(MesProduceSnPrintModel::getMesPrintedSnLogList).flatMap(List::stream).collect(Collectors.toList()); + //更新打印状态 + for (MesWorkOrder workOrder : needModifyWorkOrderList) { + MesPrintedSnLog snLog = new MesPrintedSnLog(); + snLog.setBarcode(workOrder.getCustSn()); + snLog.setCustPartNo(workOrder.getCustPartNo()); + snLog.setWorkOrderNo(workOrder.getWorkOrderNo()); + snLog.setPartNo(workOrder.getPartNo()); + snLog.setPartName(workOrder.getPartName()); + ConvertBean.serviceModelInitialize(snLog, reqBean.getUserInfo()); + snLog.setOrganizeCode(reqBean.getOrganizeCode()); + snLogList.add(snLog); + } + //保存打印条码记录 + snLogRao.saveAll(snLogList); + return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "打印成功!"); + } + + private Map getMesWorkOrderMap(StationRequestBean reqBean, List productionPartContextList) { + // 从产成物料上下文中获取 工单号集合 + List workOrderNoList = productionPartContextList.stream().map(MesProductionPartContext::getWorkOrderNo).distinct().collect(Collectors.toList()); + + DdlPackBean packBean = DdlPackBean.getDdlPackBean(reqBean.getOrganizeCode()); + DdlPreparedPack.getInPackList(workOrderNoList, MesPcnExtConstWords.WORK_ORDER_NO, packBean); + List workOrderList = workOrderRepository.findByHqlWhere(packBean); + + // 根据工单号分组 + Map workOrderMap = workOrderList.stream().collect(Collectors.toMap(MesWorkOrder::getWorkOrderNo, Function.identity(), (x, y) -> y)); + return workOrderMap; + } + + //验证加工结果是否满足参数条件: 可疑/报废是否打印 + private Boolean checkIsMatchProdResult(StationRequestBean reqBean, String prodResult, MesExtEnumUtil.PRODUCT_RESULT_EQUIP_PARAM prodResultEnum) { + + if (StringUtils.isEmpty(prodResult)) return false; + if (!prodResult.equals(prodResultEnum.getCode())) return false; + + Optional> stepParamMap = getStepParams(reqBean); + String unPrintParam = (null != stepParamMap && stepParamMap.isPresent() && stepParamMap.get().containsKey(prodResultEnum.name())) ? stepParamMap.get().get(prodResultEnum.name()).getParamValue() : null; + if (StringUtils.isEmpty(unPrintParam)) return false; + + return true; + + } + + /** + * 根据templateCode 获取模板信息 + * + * @param templateCode + * @param organizeCode + * @return + */ + private MesLabelTemplate getLabelTemplate(String templateCode, String organizeCode) { + DdlPackBean templatePackBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getStringEqualPack(templateCode, "templateCode", templatePackBean); + List mesLabelTemplateList = labelTemplateRao.findByHqlWhere(templatePackBean); + MesLabelTemplate mesLabelTemplate = null; + if (!mesLabelTemplateList.isEmpty()) { + mesLabelTemplate = mesLabelTemplateList.get(0); + //级联获取labelTemplateParam + DdlPackBean templateParamPackBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getNumEqualPack(mesLabelTemplate.getId(), "templateId", templateParamPackBean); + List params = labelTemplateParamRao.findByHqlWhere(templateParamPackBean); + mesLabelTemplate.setLabelTemplateParamList(params); + } + return mesLabelTemplate; + } +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/util/BarCodeUtils.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/util/BarCodeUtils.java new file mode 100644 index 0000000..1d01caf --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/util/BarCodeUtils.java @@ -0,0 +1,113 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.util; + +import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; +import com.google.zxing.BarcodeFormat; +import com.google.zxing.EncodeHintType; +import com.google.zxing.MultiFormatWriter; +import com.google.zxing.WriterException; +import com.google.zxing.client.j2se.MatrixToImageWriter; +import com.google.zxing.common.BitMatrix; +import com.google.zxing.datamatrix.encoder.SymbolShapeHint; +import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +/** + * @Description : 描述 + * @Reference : 关联 + * @Author : duan.yang + * @CreateDate : 2021-09-03 15:54 + * @Modify: 修改 + **/ +public class BarCodeUtils { + public static ByteArrayOutputStream createBarCode(String code) throws WriterException, IOException { + // 二维码基本参数设置 + Map hints = new HashMap<>(); + // 设置编码字符集utf-8 + hints.put(EncodeHintType.CHARACTER_SET, "utf-8"); + // 设置纠错等级L/M/Q/H,纠错等级越高越不易识别,当前设置等级为最高等级H,最低L + hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); + // 可设置距离边界的范围0-10 + hints.put(EncodeHintType.MARGIN, 1); + // 生成图片类型为条码 + BarcodeFormat format = BarcodeFormat.CODE_39; + // 创建位矩阵对象 + BitMatrix bitMatrix = new MultiFormatWriter().encode(code, format, MesPcnExtConstWords.CODE_93_WIDTH, MesPcnExtConstWords.CODE_93_HEIGHT, hints); + // 设置位矩阵转图片的参数 + // MatrixToImageConfig config = new MatrixToImageConfig(Color.black.getRGB(), Color.white.getRGB()); + // 位矩阵对象转流对象 + ByteArrayOutputStream os = new ByteArrayOutputStream(); + MatrixToImageWriter.writeToStream(bitMatrix, "png", os); + return os; + } + + public static ByteArrayOutputStream createPalletBarCode(String code) throws WriterException, IOException { + // 二维码基本参数设置 + Map hints = new HashMap<>(); + // 设置编码字符集utf-8 + hints.put(EncodeHintType.CHARACTER_SET, "utf-8"); + // 设置纠错等级L/M/Q/H,纠错等级越高越不易识别,当前设置等级为最高等级H,最低L + hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); + // 可设置距离边界的范围0-10 + hints.put(EncodeHintType.MARGIN, 1); + // 生成图片类型为条码 + BarcodeFormat format = BarcodeFormat.CODE_93; + // 创建位矩阵对象 + BitMatrix bitMatrix = new MultiFormatWriter().encode(code, format, MesPcnExtConstWords.PALLET_CODE_93_WIDTH, MesPcnExtConstWords.PALLET_CODE_93_HEIGHT, hints); + // 设置位矩阵转图片的参数 + // MatrixToImageConfig config = new MatrixToImageConfig(Color.black.getRGB(), Color.white.getRGB()); + // 位矩阵对象转流对象 + ByteArrayOutputStream os = new ByteArrayOutputStream(); + MatrixToImageWriter.writeToStream(bitMatrix, "png", os); + return os; + } + + public static ByteArrayOutputStream createPalletBarCodeToQr(String code) throws WriterException, IOException { + // 二维码基本参数设置 + Map hints = new HashMap<>(); + // 设置编码字符集utf-8 + hints.put(EncodeHintType.CHARACTER_SET, "utf-8"); + // 设置纠错等级L/M/Q/H,纠错等级越高越不易识别,当前设置等级为最高等级H,最低L + hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); + // 可设置距离边界的范围0-10 + hints.put(EncodeHintType.MARGIN, 1); + // 生成图片类型为二维码 + BarcodeFormat format = BarcodeFormat.QR_CODE; + // 创建位矩阵对象 + BitMatrix bitMatrix = new MultiFormatWriter().encode(code, format, MesPcnExtConstWords.PALLET_QR_CODE_LENTH, MesPcnExtConstWords.PALLET_QR_CODE_LENTH, hints); + // 设置位矩阵转图片的参数 + // MatrixToImageConfig config = new MatrixToImageConfig(Color.black.getRGB(), Color.white.getRGB()); + // 位矩阵对象转流对象 + ByteArrayOutputStream os = new ByteArrayOutputStream(); + MatrixToImageWriter.writeToStream(bitMatrix, "png", os); + return os; + } + + public static ByteArrayOutputStream createDataMatrixCode(String code) throws WriterException, IOException { + // 二维码基本参数设置 + Map hints = new HashMap<>(); + // 设置编码字符集utf-8 + hints.put(EncodeHintType.CHARACTER_SET, "utf-8"); + // 设置纠错等级L/M/Q/H,纠错等级越高越不易识别,当前设置等级为最高等级H,最低L + hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); + //DATA_MATRIX_SHAPE设置二维码的形状,如果不设置会默认为null,FORCE_SQUARE为正方形 + hints.put(EncodeHintType.DATA_MATRIX_SHAPE, SymbolShapeHint.FORCE_SQUARE); + // 可设置距离边界的范围0-10 + hints.put(EncodeHintType.MARGIN, 1); + // 生成图片类型为数字矩阵 + BarcodeFormat format = BarcodeFormat.DATA_MATRIX; + // 创建位矩阵对象 + BitMatrix bitMatrix = new MultiFormatWriter().encode(code, format, MesPcnExtConstWords.DATA_MATRIX_CODE_WIDTH, MesPcnExtConstWords.DATA_MATRIX_CODE_HEIGHT, hints); + // 设置位矩阵转图片的参数 +// MatrixToImageConfig config = new MatrixToImageConfig(Color.black.getRGB(), Color.white.getRGB()); + //输出图片文件 +// MatrixToImageWriter.writeToPath(bitMatrix, "png", Paths.get("D://sn.png")); + // 位矩阵对象转流对象 + ByteArrayOutputStream os = new ByteArrayOutputStream(); + MatrixToImageWriter.writeToStream(bitMatrix, "png", os); + return os; + } +} 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 41cb7e8..0115a0e 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 @@ -514,6 +514,16 @@ public class MesPcnExtConstWords { public static final String PRINTER = "printer"; //客户零件号 public static final String CUST_PART_NO = "custPartNo"; + //客户零件号 前缀 排除后四位 + public static final String CUST_PART_NO_PERFIX = "custPartNoPerfix"; + //客户零件号 后四位 + public static final String CUST_PART_NO_AFTER_FOUR = "custPartNoAfterFour"; + //客户条码VPPS + public static final String CUST_SN_VPPS = "custSnVPPS"; + //客户条码DUNS + public static final String CUST_SN_DUNS = "custSnDUNS"; + //客户条码 后部分内容 + public static final String CUST_SN_AFTER_CONTENT = "custSnAfterContent"; //生产日期 public static final String LOT_NO = "lotNo"; @@ -588,4 +598,21 @@ public class MesPcnExtConstWords { // 产线名称 public static final String WORK_CENTER_NAME = "workCenterName"; + + // + public static final int PALLET_CODE_93_WIDTH = 93; + // + public static final int PALLET_CODE_93_HEIGHT = 93; + + public static final int PALLET_QR_CODE_LENTH = 90; + + public static final int CODE_93_WIDTH = 93; + + public static final int CODE_93_HEIGHT = 93; + + public static final int DATA_MATRIX_CODE_WIDTH = 60; + + public static final int DATA_MATRIX_CODE_HEIGHT = 80; + // dataMatrix 形式的客户条码 + public static final String CUST_SN_DATA_MATRIX = "custSnDataMatrix"; } From 78fb82c88a69fc3ce0db6fcd9db126ce41ce3f47 Mon Sep 17 00:00:00 2001 From: "jhforever.wang@estsh.com" Date: Mon, 30 Sep 2024 14:43:45 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E8=A7=84=E5=88=99=E5=B9=B6=E6=88=AA?= =?UTF-8?q?=E5=8F=96=E5=8F=B3=E4=BE=A7=E6=B5=81=E6=B0=B4=E8=A3=85=E9=85=8D?= =?UTF-8?q?=E4=BB=B6=E8=A7=84=E5=88=99,=20=E7=94=9F=E6=88=90=E9=9B=B6?= =?UTF-8?q?=E4=BB=B6=E6=9D=A1=E7=A0=81=E5=B7=A5=E6=AD=A5=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=AD=A4=E6=B5=81=E6=B0=B4=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=96=B0=E7=9A=84=E9=9B=B6=E4=BB=B6=E6=9D=A1=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...esNumberRuleStrategySubstringSerialService.java | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/numberrule/MesNumberRuleStrategySubstringSerialService.java diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/numberrule/MesNumberRuleStrategySubstringSerialService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/numberrule/MesNumberRuleStrategySubstringSerialService.java new file mode 100644 index 0000000..8cf159b --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/numberrule/MesNumberRuleStrategySubstringSerialService.java @@ -0,0 +1,42 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.numberrule; + +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService; +import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdTempDataContext; +import cn.estsh.i3plus.mes.pcn.api.iservice.busi.INumberRulePackAttributeStrategyService; +import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; + +import java.util.List; +import java.util.Optional; + +/** + * @Description : 使用规则并截取右侧流水装配件规则截取的流水号作为条码的流水号 + * @Reference : + * @Author : wangjie + * @CreateDate 2024/9/26 19:24 + * @Modify: + **/ +@Component +public class MesNumberRuleStrategySubstringSerialService implements INumberRulePackAttributeStrategyService { + + @Autowired + private IMesProductionDispatchContextStepService productionDispatchContextStepService; + + @Override + public GenSerialNoModel execute(GenSerialNoModel genSerialNoModel) { + + //规则并截取右侧流水装配件规则, 生成零件条码工步需要使用此流水生成新的零件条码 + List prodTempDataContextList = productionDispatchContextStepService.getProdTempDataContext(genSerialNoModel.getOrganizeCode(), genSerialNoModel.getWorkCenterCode(), genSerialNoModel.getWorkCellCode()); + + Optional optional = CollectionUtils.isEmpty(prodTempDataContextList) ? null : + prodTempDataContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getForeignKey()) && o.getForeignKey().compareTo(genSerialNoModel.getForeignKey()) == 0)).findFirst(); + + if (null != optional && optional.isPresent() && !StringUtils.isEmpty(optional.get().getSerialNo())) genSerialNoModel.appendSerialno(optional.get().getSerialNo()); + + return genSerialNoModel; + + } +} From 1cf4524daf07ad23c3ad477e7e0998c194d0f951 Mon Sep 17 00:00:00 2001 From: yxw Date: Mon, 30 Sep 2024 15:30:38 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E6=9D=A1=E7=A0=81?= =?UTF-8?q?=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../print/strategy/CustSnPrintStrategy.java | 9 +++--- .../step/MesProductSnPrintSortStepService.java | 36 +++++++++++++--------- .../ext/mes/pcn/pojo/util/MesPcnExtConstWords.java | 3 +- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/CustSnPrintStrategy.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/CustSnPrintStrategy.java index 42fc015..af80064 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/CustSnPrintStrategy.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/CustSnPrintStrategy.java @@ -33,10 +33,10 @@ public class CustSnPrintStrategy implements IPrintTemplateStrategyService { MesNumberRule numberRule , StepResult stepResult, StationRequestBean reqBean, Boolean isStep) { - Map modelMap = (Map) model.getSourceData(); + MesWorkOrder workOrder = (MesWorkOrder) model.getSourceData(); // 工单信息 - MesWorkOrder workOrder = (MesWorkOrder) modelMap.get("mesWorkOrder"); + //MesWorkOrder workOrder = (MesWorkOrder) modelMap.get("mesWorkOrder"); if (workOrder == null) { log.info("CustSnPrintStrategy --- execute --- 工单信息为空"); @@ -57,7 +57,7 @@ public class CustSnPrintStrategy implements IPrintTemplateStrategyService { // 客户条码 resultMap.put(MesPcnExtConstWords.CUST_SN, workOrder.getCustSn()); // 客户零件号 前缀 排除后四位 - resultMap.put(MesPcnExtConstWords.CUST_PART_NO_PERFIX, custPartNoPrefix); + resultMap.put(MesPcnExtConstWords.CUST_PART_NO_PREFIX, custPartNoPrefix); // 客户零件号 后四位 resultMap.put(MesPcnExtConstWords.CUST_PART_NO_AFTER_FOUR, custPartNoAfterFour); @@ -146,7 +146,8 @@ public class CustSnPrintStrategy implements IPrintTemplateStrategyService { log.error("CustSnPrintStrategy --- execute --- 报错:{}", e.getMessage()); return model; } - resultMap.put(MesPcnExtConstWords.CUST_SN_DATA_MATRIX, dataMatrixCode); + resultMap.put(MesPcnExtConstWords.CUST_SN_DATA_MATRIX, Base64.getEncoder().encodeToString(dataMatrixCode.toByteArray())); + //resultMap.put(MesPcnExtConstWords.CUST_SN_DATA_MATRIX_BASE64, ); printDataMapList.add(resultMap); 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 f1d8f7e..e9e5023 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 @@ -83,7 +83,7 @@ public class MesProductSnPrintSortStepService extends BaseStepService { /** * 重构,返回给前端打印数据 */ - List printModelList = new ArrayList<>(); + //List printModelList = new ArrayList<>(); //2. 获取条码需要模板、模板代码、打印机 --- 循环遍历条码 封装数据 if (CollectionUtils.isEmpty(productionPartContextList)) return stepResult; @@ -96,14 +96,7 @@ public class MesProductSnPrintSortStepService extends BaseStepService { List needModifyWorkOrderList = new ArrayList<>(); - DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); - DdlPreparedPack.getStringEqualPack("WH_CUST_SN_RULE", MesPcnExtConstWords.RULE_CODE, packBean); - MesNumberRule numberRule = numberRuleRepository.getByProperty(packBean); - - if (numberRule == null) { - log.error("MesCustSnPrintStepService --- exec --- 客户条码编码规则[WH_CUST_SN_RULE]无效"); - return stepResult; - } + List> resultMap = new ArrayList<>(); for (MesProductionPartContext sn : productionPartContextList) { @@ -112,16 +105,28 @@ public class MesProductSnPrintSortStepService extends BaseStepService { if (workOrder == null) { log.error("MesCustSnPrintStepService --- exec --- 工单号:{}无效", sn.getWorkOrderNo()); + stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号:{}无效!", sn.getWorkOrderNo())); continue; } if ((partDataContext == null) || (!partDataContext.containsKey(workOrder.getPartNo()))) { log.error("MesCustSnPrintStepService --- exec --- 工单号:{}零件{}丢失缓存", sn.getWorkOrderNo(), sn.getPartNo()); - continue; + stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]丢失零件信息缓存!", sn.getWorkOrderNo(), sn.getPartNo())); + } + MesPart mesPart = partDataContext.get(sn.getPartNo()); + + String custMatchRule = StringUtils.isEmpty(mesPart.getCustMatchRule()) ? "WH_CUST_SN_RULE" : mesPart.getCustMatchRule(); + DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getStringEqualPack(custMatchRule, MesPcnExtConstWords.RULE_CODE, packBean); + MesNumberRule numberRule = numberRuleRepository.getByProperty(packBean); + + if (numberRule == null) { + log.error("MesCustSnPrintStepService --- exec --- 客户条码编码规则[WH_CUST_SN_RULE]无效"); + stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]客户条码编码规则[%s]无效!", sn.getWorkOrderNo(), sn.getPartNo(), custMatchRule)); } // 从物料信息中获取标签模板 - String labelTemplateCode = partDataContext.get(sn.getPartNo()).getProductLabelTemplate(); + String labelTemplateCode = partDataContext.get(sn.getPartNo()).getCustLabelTemplate(); // 从物料信息中获取打印机 String productPrinterCode = partDataContext.get(sn.getPartNo()).getProductPrinterCode(); @@ -156,8 +161,8 @@ public class MesProductSnPrintSortStepService extends BaseStepService { } IPrintTemplateStrategyService strategyService = (IPrintTemplateStrategyService) SpringContextsUtil.getBean(methodCode); // GenSerialNoModel model , MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep - MesProduceSnPrintModel printModel = strategyService.execute(null, mesProduceSnPrintModel, null, stepResult, reqBean, true); - printModelList.add(printModel); + MesProduceSnPrintModel printModel = strategyService.execute(null, mesProduceSnPrintModel, numberRule, stepResult, reqBean, true); + resultMap.addAll(printModel.getPrintContextList()); needModifyWorkOrderList.add(workOrder); } @@ -165,10 +170,11 @@ public class MesProductSnPrintSortStepService extends BaseStepService { //前端接收到busiTyep是customComponent,并且 dataType是file类型的消息,就需要打印后续消息里的数据,一个模板对应多个打印数据 resultBean.setBusiType(MesPcnEnumUtil.STATION_BUSI_TYPE.CUSTOM_COMPONENT.getValue()); resultBean.setDataType(MesPcnEnumUtil.STATION_DATA_TYPE.FILE.getValue()); - resultBean.setResultObj(printModelList); + resultBean.setCustomPageName("SORT_WORK_CENTER_PRINT"); + resultBean.setResultObj(resultMap); //3. 发送数据给到前端 this.sendMessage(reqBean, resultBean); - List snLogList = printModelList.stream().map(MesProduceSnPrintModel::getMesPrintedSnLogList).flatMap(List::stream).collect(Collectors.toList()); + List snLogList = new ArrayList<>(); //更新打印状态 for (MesWorkOrder workOrder : needModifyWorkOrderList) { MesPrintedSnLog snLog = new MesPrintedSnLog(); 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 0115a0e..9919565 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 @@ -515,7 +515,7 @@ public class MesPcnExtConstWords { //客户零件号 public static final String CUST_PART_NO = "custPartNo"; //客户零件号 前缀 排除后四位 - public static final String CUST_PART_NO_PERFIX = "custPartNoPerfix"; + public static final String CUST_PART_NO_PREFIX = "custPartNoPrefix"; //客户零件号 后四位 public static final String CUST_PART_NO_AFTER_FOUR = "custPartNoAfterFour"; //客户条码VPPS @@ -615,4 +615,5 @@ public class MesPcnExtConstWords { public static final int DATA_MATRIX_CODE_HEIGHT = 80; // dataMatrix 形式的客户条码 public static final String CUST_SN_DATA_MATRIX = "custSnDataMatrix"; + public static final String CUST_SN_DATA_MATRIX_BASE64 = "custSnDataMatrixBase64"; }