From d44c9ab933cfca67d4c550e499228f90432cbb3a Mon Sep 17 00:00:00 2001 From: zhanghl <253316343@qq.com> Date: 星期四, 15 五月 2025 11:03:11 +0800 Subject: [PATCH] 钣金工单计划:优化子件工单的读取方式 先存储内存,再从内存扣减,最后一起保存 --- aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlateStandardRequireServiceImpl.java | 39 +++++++++++++++++++++++++++++---------- 1 files changed, 29 insertions(+), 10 deletions(-) diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlateStandardRequireServiceImpl.java b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlateStandardRequireServiceImpl.java index 84995db..e8178ce 100644 --- a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlateStandardRequireServiceImpl.java +++ b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlateStandardRequireServiceImpl.java @@ -64,7 +64,7 @@ ApsPlateStandardRequireBomOrderDetailMapper plateBomOrderDetailMapper; @Autowired - private ApsPlatePlanMapper apsPlatePlanMapper; + private IApsPlatePlanService apsPlatePlanService; @Resource IApsPlateStandardRequireBomOrderDetailService bomOrderDetailService; @@ -176,19 +176,23 @@ /*鑾峰彇閽i噾涓诲崟淇℃伅*/ List<ApsPlatePlan> mainPlans = platePlanMapper.selectPlatePlanByPlantMajor(plantCode,mainOrderType); Hashtable<String, ApsMaterialStorageManagement> usedStorage = new Hashtable<>(); + /*鍐呭瓨涓瓨鍌ㄥ瓙浠跺伐鍗�*/ + Hashtable<String, List<ApsPlatePlan>> subPlans = new Hashtable<>(); log.info("寮�濮嬬敓鎴愰渶姹傦細"); for (ApsPlatePlan mainPlan : mainPlans) { String itemNumber = mainPlan.getItemNumber(); /*鏍规嵁鏂欏彿 鑾峰彇BOM Header */ - /*褰撳墠Bom鑺傜偣澶勭悊瀹屾垚鍚庯紝澶勭悊涓嬬骇BOM*/ + List<ApsPlateStandardRequire> requiresList=new ArrayList<>(); List<ApsPlateStandardRequireBomStockDetail> stockDetailsList=new ArrayList<>(); List<ApsPlateStandardRequireBomOrderDetail> orderDetailsList=new ArrayList<>(); + log.info("寮�濮嬬敓鎴愰渶姹傦細宸ュ崟鍙凤細"+mainPlan.getDocumentNumber()); + /*褰撳墠Bom鑺傜偣澶勭悊瀹屾垚鍚庯紝澶勭悊涓嬬骇BOM*/ getBomRequires(plantCode, "0","0",itemNumber,BigDecimal.ONE, batchNum, null - , mainPlan, requiresList, 0L,stockDetailsList,orderDetailsList,usedStorage + , mainPlan, requiresList, 0L,stockDetailsList,orderDetailsList,usedStorage,subPlans ); // 鎵归噺鎻掑叆浠ユ彁楂樻�ц兘 @@ -225,6 +229,15 @@ storageManagementService.updateRemainderStock(sm.getId(),sm.getRemainderStock(),sm.getVersion()); }); } + if(!subPlans.isEmpty()){ + subPlans.forEach((key, subPlansList) -> { + subPlansList.forEach(x->{ + if (!x.getUnmatchedQuantity().equals(x.getProductionQuantity())){ + platePlanMapper.updatePlanUnMatchQtyAndVersion(x); + } + }); + }); + } } /** @@ -248,7 +261,8 @@ List<ApsPlateStandardRequire> allRequires, Long level,List<ApsPlateStandardRequireBomStockDetail> stockDetailsList, List<ApsPlateStandardRequireBomOrderDetail> orderDetailsList, - Hashtable<String, ApsMaterialStorageManagement> usedStorage + Hashtable<String, ApsMaterialStorageManagement> usedStorage, + Hashtable<String, List<ApsPlatePlan>> subPlans ) { /*鏋勫缓闇�姹備俊鎭�*/ ApsPlateStandardRequire require = new ApsPlateStandardRequire(); @@ -367,7 +381,7 @@ if (require.getNetRequirement().compareTo(BigDecimal.ZERO) > 0) { require.setMatchMode("宸ュ崟鍖归厤"); /*浣跨敤瀛愪欢宸ュ崟杩涜闇�姹傚尮閰�*/ - matchRequireAndSubPlan(require,orderDetailsList); + matchRequireAndSubPlan(require,orderDetailsList,subPlans); } allRequires.add(require); log.info("宸茬敓鎴愰渶姹傦細"+plan.getDocumentNumber()+"bomHeaderCode:"+bomHeaderCode+"bomLineCode:"+itemCode+"bomLevel:"+level); @@ -379,7 +393,7 @@ bomLineList.forEach(line -> { getBomRequires(plant, itemCode, line.getBomLineId(),line.getItemCode() ,line.getNum() , batchNum , require.getStartDate(), plan, allRequires, nextLevel,stockDetailsList - ,orderDetailsList,usedStorage + ,orderDetailsList,usedStorage,subPlans ); }); } @@ -403,12 +417,12 @@ * 浣跨敤瀛愪欢宸ュ崟鍖归厤闇�姹備腑鐨勫噣闇�姹� * */ - private void matchRequireAndSubPlan(ApsPlateStandardRequire require, List<ApsPlateStandardRequireBomOrderDetail> orderDetailsList) { + private void matchRequireAndSubPlan(ApsPlateStandardRequire require, List<ApsPlateStandardRequireBomOrderDetail> orderDetailsList,Hashtable<String, List<ApsPlatePlan>> subPlans) { BigDecimal netRequirement = require.getNetRequirement(); require.setMatchMode("宸ュ崟鍖归厤"); require.setMatchState("宸插尮閰�"); if (netRequirement.compareTo(BigDecimal.ZERO) > 0) { - ApsPlatePlan platePlan = apsPlatePlanMapper.selectUnMatchPlateSubPlan(require.getOrgCode(), require.getBomLineCode()); + ApsPlatePlan platePlan = apsPlatePlanService.selectUnMatchPlateSubPlan(require.getOrgCode(), require.getBomLineCode(),subPlans); /*瀛愪欢宸ュ崟鐨勬湭鍖归厤鏁伴噺 浣滀负褰撳墠鐨勫簱瀛�*/ while (platePlan != null && netRequirement.compareTo(BigDecimal.ZERO) > 0) { BigDecimal stock = platePlan.getUnmatchedQuantity(); @@ -416,6 +430,8 @@ /* 搴撳瓨鏁伴噺 澶т簬 鍑�闇�姹傛暟閲�*/ /* 鍑�闇�姹傛暟閲�=0 锛屽瓙浠跺伐鍗曟湭鍖归厤鏁伴噺= 搴撳瓨-鍑�闇�姹�*/ BigDecimal subtract = stock.subtract(netRequirement); + platePlan.setUnmatchedQuantity(subtract); + platePlan.setVersion(platePlan.getVersion() + 1); bomOrderDetailService.savePlastPlanAndBomOrderDetail(require, platePlan, subtract, stock, netRequirement,orderDetailsList); netRequirement = BigDecimal.ZERO; @@ -426,6 +442,8 @@ /*鍑�闇�姹傛暟閲� == 搴撳瓨鏁伴噺*/ BigDecimal subtract = BigDecimal.ZERO; + platePlan.setUnmatchedQuantity(subtract); + platePlan.setVersion(platePlan.getVersion() + 1); bomOrderDetailService.savePlastPlanAndBomOrderDetail(require, platePlan, subtract, stock, netRequirement,orderDetailsList); netRequirement = BigDecimal.ZERO; @@ -436,11 +454,12 @@ /*闇�姹傚ぇ浜庡簱瀛�*/ /*鍑�闇�姹� 琚儴鍒嗘弧瓒� */ BigDecimal rest = netRequirement.subtract(stock); - + platePlan.setUnmatchedQuantity(BigDecimal.ZERO); + platePlan.setVersion(platePlan.getVersion() + 1); /*宸ュ崟 鏈尮閰嶆暟閲忎负0 鍏ㄩ儴鐢ㄤ簬鍖归厤闇�姹�*/ bomOrderDetailService.savePlastPlanAndBomOrderDetail(require, platePlan, BigDecimal.ZERO, stock, netRequirement,orderDetailsList); /*鍑�闇�姹傛湭琚弧瓒筹紝闇�瑕佺户缁尮閰�*/ - platePlan = apsPlatePlanMapper.selectUnMatchPlateSubPlan(require.getOrgCode(), require.getBomLineCode()); + platePlan = apsPlatePlanService.selectUnMatchPlateSubPlan(require.getOrgCode(), require.getBomLineCode(),subPlans); /*鍓╀綑鍑�闇�姹�*/ netRequirement = rest; require.setUnmatchedDemandAmount(rest); -- Gitblit v1.9.3