From 7645ac2997527de6b730c55de8510fc87aa43a30 Mon Sep 17 00:00:00 2001 From: gaoqr <13665037151@163.com> Date: Wed, 9 Apr 2025 12:34:31 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A6=85=E9=81=93#1470=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../factory/WebCadOrderImportFactory.java | 46 ++++++++++++++++--- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/orderImport/factory/WebCadOrderImportFactory.java b/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/orderImport/factory/WebCadOrderImportFactory.java index 4b4fbd254..8d5ebd608 100644 --- a/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/orderImport/factory/WebCadOrderImportFactory.java +++ b/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/java/com/cf/imes/module/plan/service/orderImport/factory/WebCadOrderImportFactory.java @@ -165,6 +165,9 @@ public class WebCadOrderImportFactory { // 房间名+柜体名+加工组名 private Map orderGroupMap = new HashMap<>(); + // 板材缓存:{商品编号:order_goods} + private Map materialMap = new HashMap<>(); + // 加工组缓存 private Map processGroupMap = new HashMap<>(); @@ -340,11 +343,21 @@ public class WebCadOrderImportFactory { for (WebCadDataMaterialReqVO materialReqVO : materialReqVOS) { String plateGoodsId = materialReqVO.getId(); String plateGoodsGoodsId = materialReqVO.getGoodsId(); + List orginIds = materialReqVO.getOrginIds(); PlateGoodDO plateGoodDO = plateGoodMapper.selectById(plateGoodsId); // 检查板材库 if (ObjectUtil.isNull(plateGoodDO)) { throw ServiceExceptionUtil.exception(WEBCAD_ORDER_IMPORT_PLATE_NOT_EXIST_ERROR, plateGoodsId); } + // 获取缓存的orderGoods + GoodsDO cacheOrderPlate = materialMap.get(plateGoodsGoodsId); + // 缓存没有才创建 + if (ObjectUtil.isNotNull(cacheOrderPlate)) { + Long cacheOrderPlateId = cacheOrderPlate.getId(); + // 使用缓存中的order_goods信息赋值到板件 + setGoodsInfoToBlock(plateGoodsGoodsId, cacheOrderPlateId, orginIds, blockReqVOS); + continue; + } // 检查生产单下是否已经有板材下的order_goods,有不再创建 List existOrderGoods = goodsMapper.selectList(new LambdaUpdateWrapper() .eq(GoodsDO::getGoodsId, plateGoodsGoodsId) @@ -400,19 +413,37 @@ public class WebCadOrderImportFactory { goodsDOS.add(goodsDO); rawGoodsDOS.add(rawGoodsDO); + + // 缓存板材 + materialMap.put(plateGoodsGoodsId, goodsDO); } - for (Integer blockIndex : materialReqVO.getOrginIds()) { - // blockIndex序号获取对应板件a - WebCadDataBlockReqVO webCadDataBlockReqVO = blockReqVOS.get(blockIndex - 1); - // 把板材的id和goodsId赋给cad板件 - webCadDataBlockReqVO.setGoodsId(plateGoodsGoodsId); - webCadDataBlockReqVO.setPlateGoodsId(orderGoodsId); - } + setGoodsInfoToBlock(plateGoodsGoodsId, orderGoodsId, orginIds, blockReqVOS); } orderInfoBatchInsertWithinThreshold(rawGoodsMapper, rawGoodsDOS, true); orderInfoBatchInsertWithinThreshold(goodsMapper, goodsDOS, true); } + /** + * 板件信息映射到对应的cad板材中 + * + * @param plateGoodsGoodsId + * @param orderGoodsId + * @param orginIds + * @param blockReqVOS + */ + private void setGoodsInfoToBlock(String plateGoodsGoodsId, Long orderGoodsId, List orginIds, List blockReqVOS) { + if (CollUtil.isEmpty(orginIds)) { + return; + } + for (Integer blockIndex : orginIds) { + // blockIndex序号获取对应板件a + WebCadDataBlockReqVO webCadDataBlockReqVO = blockReqVOS.get(blockIndex - 1); + // 把板材的id和goodsId赋给cad板件 + webCadDataBlockReqVO.setGoodsId(plateGoodsGoodsId); + webCadDataBlockReqVO.setPlateGoodsId(orderGoodsId); + } + } + /** * 缓存加工组类型 * @@ -1842,6 +1873,7 @@ public class WebCadOrderImportFactory { bodyMap.clear(); sealEdgeConfigList.clear(); processGroupMap.clear(); + materialMap.clear(); } public static void main(String[] args) {