From 4102d444dbd275b40ba14d8256ab74493a709e14 Mon Sep 17 00:00:00 2001 From: "castle.zang" Date: Mon, 10 Feb 2025 18:38:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=B1=E6=B1=95kitting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pcn/api/busi/IMesPullingOrderInfoService.java | 2 + .../busi/MesPullingOrderInfoController.java | 40 ++++++++ .../busi/MesPullingOrderInfoService.java | 104 ++++++++++++++++++++- 3 files changed, 144 insertions(+), 2 deletions(-) diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesPullingOrderInfoService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesPullingOrderInfoService.java index 641acc0..6443ef6 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesPullingOrderInfoService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesPullingOrderInfoService.java @@ -24,6 +24,8 @@ public interface IMesPullingOrderInfoService { List doMesPullingOrderInfoPrint(MesPullingOrderInfo mesPullingOrderInfo); + List doMesPullingOrderInfoPrintNew(MesPullingOrderInfo mesPullingOrderInfo); + ListPager queryMesPullingOrderPartInfoByPager(MesPullingOrderInfo mesPullingOrderInfo, Pager pager); List doMesPullingOrderInfoSend(List infoList, String userName); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesPullingOrderInfoController.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesPullingOrderInfoController.java index ecc9636..9ff660f 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesPullingOrderInfoController.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesPullingOrderInfoController.java @@ -113,6 +113,46 @@ public class MesPullingOrderInfoController { return ResultBean.fail(e); } } + @PostMapping(value = "/new/doPrint") + @ApiOperation(value = "打印未打印拉动单后修改状态--带类型") + public ResultBean doMesPullingOrderInfoNewPrint(@RequestBody MesPullingOrderInfo mesPullingOrderInfo) { + try { + + if (StringUtils.isEmpty(mesPullingOrderInfo.getOrganizeCode())) { + throw new ImppBusiException("工厂不能为空"); + } + + if (StringUtils.isEmpty(mesPullingOrderInfo.getWorkCenterCode())) { + throw new ImppBusiException("产线不能为空"); + } + + if (StringUtils.isEmpty(mesPullingOrderInfo.getPullCode())) { + throw new ImppBusiException("拉动组不能为空"); + } + + if (StringUtils.isEmpty(mesPullingOrderInfo.getModifyUser())) { + throw new ImppBusiException("操作人不能为空"); + } + + String moduleKey = new StringJoiner(MesPcnExtConstWords.COLON) + .add(mesPullingOrderInfo.getOrganizeCode()) + .add("PRINT_PULLING_ORDER_INFO") + .add(mesPullingOrderInfo.getWorkCenterCode()).add(mesPullingOrderInfo.getPullCode()).toString(); + + synchronized (moduleKey.intern()) { + + List pullingOrderInfos = mesPullingOrderInfoService.doMesPullingOrderInfoPrint(mesPullingOrderInfo); + + return ResultBean.success(CollectionUtils.isEmpty(pullingOrderInfos) ? "查询暂无可打印数据!!!" : "打印队列查询成功!!!").setResultList(pullingOrderInfos); + + } + + } catch (ImppBusiException e) { + return ResultBean.fail(e).build(); + } catch (Exception e) { + return ResultBean.fail(e); + } + } @GetMapping("/template") @ApiOperation(value = "查询打印模板和明细") public ResultBean queryMesLabelTemplate(MesLabelTemplate labelTemplate ) { diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesPullingOrderInfoService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesPullingOrderInfoService.java index 3e6828a..8432bcf 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesPullingOrderInfoService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesPullingOrderInfoService.java @@ -30,6 +30,8 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -62,6 +64,9 @@ public class MesPullingOrderInfoService implements IMesPullingOrderInfoService { @Autowired private MesCustomerCarModelRepository carModelRepository; + @Autowired + private MesWorkOrderRepository workOrderRao; + @Override public ListPager queryMesPullingOrderInfoByPager(MesPullingOrderInfo bean, Pager pager) { @@ -196,6 +201,101 @@ public class MesPullingOrderInfoService implements IMesPullingOrderInfoService { //把查出来的拉动单打印并修改打印状态为已打印 List snLogList = new ArrayList<>(); for (MesPullingOrderInfo pullingOrderInfo : pullingOrderInfos) { + //查询对应的工单 + DdlPackBean workOrderPackBean = DdlPackBean.getDdlPackBean(pullingOrderInfo.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(pullingOrderInfo.getWorkOrderNo(), MesPcnExtConstWords.WORK_ORDER_NO, workOrderPackBean); + List mesWorkOrders = workOrderRao.findByHqlTopWhere(workOrderPackBean, 1); + MesWorkOrder mesWorkOrder; + if (!CollectionUtils.isEmpty(mesWorkOrders)) { + mesWorkOrder = mesWorkOrders.get(0); + }else { + mesWorkOrder = new MesWorkOrder(); + } + //查询拉动组明细 + DdlPackBean partPackBean = DdlPackBean.getDdlPackBean(pullingOrderInfo.getOrganizeCode()); + DdlPreparedPack.getStringEqualPack(pullingOrderInfo.getPullingOrderNo(), MesPcnExtConstWords.PULLING_ORDER_NO, partPackBean); + List pullingOrderPartInfos = mesPullingOrderPartInfoRepository.findByHqlWhere(partPackBean); + if (!CollectionUtils.isEmpty(pullingOrderPartInfos)) { + pullingOrderInfo.setPartCount(pullingOrderPartInfos.size()); + pullingOrderPartInfos.forEach(item->{ + if(!StringUtil.isEmpty(item.getLocation()) && item.getLocation().contains(MesPcnExtConstWords.COMMA)){ + item.setLocatAddr(item.getLocation().split(MesPcnExtConstWords.COMMA)[0]); + item.setLightAddr(item.getLocation().split(MesPcnExtConstWords.COMMA)[1]); + }; + item.setAssemblyPartNo(pullingOrderInfo.getPartNo()); + }); + pullingOrderInfo.setPullingOrderPartInfos(pullingOrderPartInfos); + } + pullingOrderInfo.setWorkOrderNoLast(!StringUtil.isEmpty(pullingOrderInfo.getWorkOrderNo())?pullingOrderInfo.getWorkOrderNo().substring(pullingOrderInfo.getWorkOrderNo().length() - MesPcnExtConstWords.FOUR):""); + pullingOrderInfo.setWorkOrderNoPre(!StringUtil.isEmpty(pullingOrderInfo.getWorkOrderNo())?pullingOrderInfo.getWorkOrderNo().substring(MesPcnExtConstWords.ZERO,pullingOrderInfo.getWorkOrderNo().length() - MesPcnExtConstWords.FOUR):""); + pullingOrderInfo.setCustOrderNoLast(!StringUtil.isEmpty(pullingOrderInfo.getCustOrderNo())?pullingOrderInfo.getCustOrderNo().substring(pullingOrderInfo.getCustOrderNo().length() - MesPcnExtConstWords.FOUR):""); + pullingOrderInfo.setCarModelName((Objects.isNull(mesCustomerCarModelMap) || StringUtil.isEmpty(pullingOrderInfo.getCarModelCode()) || !mesCustomerCarModelMap.containsKey(pullingOrderInfo.getCarModelCode()) ? "" : mesCustomerCarModelMap.get(pullingOrderInfo.getCarModelCode()).iterator().next().getCarModelName())); + + pullingOrderInfo.setPrintTime(TimeTool.getNowTime(true)); + pullingOrderInfo.setPrintStatus(MesExtEnumUtil.PRINT_STATUS.PRINTED.getValue()); + pullingOrderInfo.setIsPrint(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()); + pullingOrderInfo.setShiftName(mesWorkOrder.getShiftName()); + pullingOrderInfo.setSummaryQty(mesWorkOrder.getQty()); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + try { + pullingOrderInfo.setPlanStartDate(sdf.format(sdf.parse(mesWorkOrder.getPlanStartTime()))); + } catch (ParseException e) { + log.error("格式化时间错误e:{}", e.getMessage()); + } + pullingOrderInfo.setPlanStartTime(mesWorkOrder.getPlanStartTime()); + pullingOrderInfo.setShiftName(mesWorkOrder.getShiftName()); + pullingOrderInfo.setCarModelCode(mesWorkOrder.getCarModelCode()); + pullingOrderInfo.setCustOrderNo(mesWorkOrder.getCustOrderNo()); + ConvertBean.serviceModelUpdate(pullingOrderInfo, bean.getModifyUser()); + + //10-12 打印补打拉动单新增log表 + MesPrintedSnLog snLog = new MesPrintedSnLog(); + snLog.setBarcode(pullingOrderInfo.getPullingOrderNo()); + snLog.setCustPartNo(pullingOrderInfo.getCustPartNo()); + snLog.setWorkOrderNo(pullingOrderInfo.getWorkOrderNo()); + snLog.setPartNo(pullingOrderInfo.getPartNo()); + snLog.setPartName(pullingOrderInfo.getPartName()); + ConvertBean.serviceModelInitialize(snLog, bean.getModifyUser()); + snLog.setOrganizeCode(bean.getOrganizeCode()); + snLogList.add(snLog); + + } + mesPullingOrderInfoRepository.saveAll(pullingOrderInfos); + //保存打印条码记录 + snLogRao.saveAll(snLogList); + } + return pullingOrderInfos; + } + + @Override + public List doMesPullingOrderInfoPrintNew(MesPullingOrderInfo bean) { + DdlPackBean packBean = DdlPackBean.getDdlPackBean(bean.getOrganizeCode()); + + List pullCodeList = Arrays.asList(bean.getPullCode().split(MesPcnExtConstWords.COMMA)); + List workCenterCodeList = Arrays.asList(bean.getWorkCenterCode().split(MesPcnExtConstWords.COMMA)); + + if (pullCodeList.size() == 1) DdlPreparedPack.getStringEqualPack(pullCodeList.get(0), MesPcnExtConstWords.PULL_CODE, packBean); + else DdlPreparedPack.getInPackList(pullCodeList, MesPcnExtConstWords.PULL_CODE, packBean); + + if (workCenterCodeList.size() == 1) DdlPreparedPack.getStringEqualPack(workCenterCodeList.get(0), MesPcnExtConstWords.WORK_CENTER_CODE, packBean); + else DdlPreparedPack.getInPackList(workCenterCodeList, MesPcnExtConstWords.WORK_CENTER_CODE, packBean); + + DdlPreparedPack.getNumEqualPack(bean.getPullOrderType(),"pullOrderType",packBean); + DdlPreparedPack.getStringEqualPack(bean.getPullingOrderNo(), MesPcnExtConstWords.PULLING_ORDER_NO, packBean); + DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PRINT_STATUS.UNPRINT.getValue(), MesPcnExtConstWords.PRINT_STATUS, packBean); + DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.ASC.getValue()}, new String[]{MesPcnExtConstWords.CUST_ORDER_NO}, packBean); + + List pullingOrderInfos = mesPullingOrderInfoRepository.findByHqlTopWhere(packBean, MesPcnExtConstWords.THREE); + + log.info("打印队列查询 --- 拉动单 --- 查询到打印数据: {} ---", CollectionUtils.isEmpty(pullingOrderInfos) ? "[]" : + pullingOrderInfos.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getWorkOrderNo()))).map(MesPullingOrderInfo::getWorkOrderNo).collect(Collectors.toList()).toString()); + + if (!CollectionUtils.isEmpty(pullingOrderInfos)) { + //根据车型代码查询车型信息 + Map> mesCustomerCarModelMap = getMesCustomerCarModelMap(bean.getOrganizeCode(), pullingOrderInfos.stream().map(MesPullingOrderInfo::getCarModelCode).distinct().collect(Collectors.toList())); + //把查出来的拉动单打印并修改打印状态为已打印 + List snLogList = new ArrayList<>(); + for (MesPullingOrderInfo pullingOrderInfo : pullingOrderInfos) { //查询拉动组明细 DdlPackBean partPackBean = DdlPackBean.getDdlPackBean(pullingOrderInfo.getOrganizeCode()); DdlPreparedPack.getStringEqualPack(pullingOrderInfo.getPullingOrderNo(), MesPcnExtConstWords.PULLING_ORDER_NO, partPackBean); @@ -210,8 +310,8 @@ public class MesPullingOrderInfoService implements IMesPullingOrderInfoService { }); pullingOrderInfo.setPullingOrderPartInfos(pullingOrderPartInfos); } - pullingOrderInfo.setWorkOrderNoLast(!StringUtil.isEmpty(pullingOrderInfo.getWorkOrderNo())?pullingOrderInfo.getWorkOrderNo().substring(pullingOrderInfo.getWorkOrderNo().length() - MesPcnExtConstWords.THREE):""); - pullingOrderInfo.setWorkOrderNoPre(!StringUtil.isEmpty(pullingOrderInfo.getWorkOrderNo())?pullingOrderInfo.getWorkOrderNo().substring(MesPcnExtConstWords.ZERO,pullingOrderInfo.getWorkOrderNo().length() - MesPcnExtConstWords.THREE):""); + pullingOrderInfo.setWorkOrderNoLast(!StringUtil.isEmpty(pullingOrderInfo.getWorkOrderNo())?pullingOrderInfo.getWorkOrderNo().substring(pullingOrderInfo.getWorkOrderNo().length() - MesPcnExtConstWords.FOUR):""); + pullingOrderInfo.setWorkOrderNoPre(!StringUtil.isEmpty(pullingOrderInfo.getWorkOrderNo())?pullingOrderInfo.getWorkOrderNo().substring(MesPcnExtConstWords.ZERO,pullingOrderInfo.getWorkOrderNo().length() - MesPcnExtConstWords.FOUR):""); pullingOrderInfo.setCustOrderNoLast(!StringUtil.isEmpty(pullingOrderInfo.getCustOrderNo())?pullingOrderInfo.getCustOrderNo().substring(pullingOrderInfo.getCustOrderNo().length() - MesPcnExtConstWords.FOUR):""); pullingOrderInfo.setCarModelName("车型:" + (Objects.isNull(mesCustomerCarModelMap) || StringUtil.isEmpty(pullingOrderInfo.getCarModelCode()) || !mesCustomerCarModelMap.containsKey(pullingOrderInfo.getCarModelCode()) ? "" : mesCustomerCarModelMap.get(pullingOrderInfo.getCarModelCode()).iterator().next().getCarModelName()));