From aa527f732cff65689e82b660389be4ece3825ae3 Mon Sep 17 00:00:00 2001 From: huangjiayang <5265313@qq.com> Date: 星期五, 09 五月 2025 18:00:15 +0800 Subject: [PATCH] 【UPDATE】1.新增同步标准工艺路线定时任务代码 2.从redis中获取BOM数据 3.将工艺路线数据存入redis中 4.从redis中获取工艺路线数据 --- aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlateStandardRequireServiceImpl.java | 65 +++++++++++++++++++------------- 1 files changed, 38 insertions(+), 27 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 8466aaa..f49178f 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 @@ -166,7 +166,7 @@ /*瀹氫箟宸ュ巶涓哄崡閫� */ String plantCode="FORTUNA"; /*瀹氫箟涓诲崟绫诲瀷涓洪挘閲戜富鍗�*/ - String mainOrderType = "0"; + String mainOrderType = "main"; /*鐢熸垚鏂版壒娆″彿*/ String batchNum= requireBatchService.getNewBatchNumber(); /*鑾峰彇閽i噾涓诲崟淇℃伅*/ @@ -178,7 +178,7 @@ List<ApsPlateStandardRequire> requiresList=new ArrayList<>(); - getBomRequires(plantCode, "0",itemNumber,BigDecimal.ONE, batchNum, null, mainPlan, requiresList, 0L); + getBomRequires(plantCode, "0","0",itemNumber,BigDecimal.ONE, batchNum, null, mainPlan, requiresList, 0L); // 鎵归噺鎻掑叆浠ユ彁楂樻�ц兘 if (!requiresList.isEmpty()) { @@ -196,6 +196,7 @@ * 鏋勫缓闇�姹備俊鎭� * * @param plant 宸ュ巶浠g爜 + * @param bomHeaderCode BOM涓婄骇鐗╂枡缂栫爜 * @param bomLineId BOM琛孖D * @param itemCode 鐗╂枡浠g爜 * @param itemNum 鐗╂枡鏁伴噺 @@ -205,14 +206,15 @@ * @param allRequires 鎵�鏈夐渶姹傜殑鍒楄〃 * @param level 灞傜骇 */ - private void getBomRequires(String plant, String bomLineId,String itemCode,BigDecimal itemNum, String batchNum, Date upLevelStartDate, ApsPlatePlan plan, List<ApsPlateStandardRequire> allRequires, Long level) { + private void getBomRequires(String plant, String bomHeaderCode, String bomLineId,String itemCode,BigDecimal itemNum, String batchNum, Date upLevelStartDate, ApsPlatePlan plan, List<ApsPlateStandardRequire> allRequires, Long level) { /*鏋勫缓闇�姹備俊鎭�*/ ApsPlateStandardRequire require = new ApsPlateStandardRequire(); require.setId(IdUtil.getSnowflakeNextId()); - require.setRequireTrackId(plan.getId()); + require.setRequireTrackId(plan.getId() + ""); require.setBatchNumber(batchNum); require.setDocNum(plan.getDocumentNumber()); require.setOrgCode(plant); + require.setBomHeaderCode(bomHeaderCode); require.setBomLineId(bomLineId); require.setBomLineCode(itemCode); require.setBomLineLevel(level); @@ -224,8 +226,6 @@ /*璁$畻闇�姹傛暟閲�*/ if (level == 0) { require.setBomUseAmount(BigDecimal.ONE); - require.setCompleteDate(plan.getPlanEndDay()); - require.setDemandDate(plan.getPlanEndDay()); } else { require.setBomUseAmount(itemNum.multiply(plan.getProductionQuantity())); } @@ -259,6 +259,8 @@ bomStockDetailService.saveStorageAndDetail(storage, plan, bomLineId,itemCode, batchNum, deductionAmount, afterStockAmount,require.getId()); } } + /*鏈尮閰嶆暟閲忥紝榛樿涓哄噣闇�姹�*/ + require.setUnmatchedDemandAmount(require.getNetRequirement()); /*宸ヨ壓璺嚎鎬婚渶姹�*/ ApsStandardProcessRouteLine routeHeader = routeLineService.getRouteLineTotalTime(require); String routeId = routeHeader.getRouteId(); @@ -268,21 +270,27 @@ require.setProcessRouteId(routeId); require.setProcessRouteHours(String.valueOf(totalRouteTime)); - /*瀹屾垚鏃堕棿锛宭evel=0 鏃堕粯璁や负宸ュ崟鐨勮鍒掑畬鎴愭棩鏈�*/ - Date completeDate = plan.getPlanEndDay(); + /*棰勭暀澶╂暟*/ Long reservedDay = getReservedDays(); - if (level > 0) { + /*璁剧疆瀹屾垚鏃ユ湡*/ + if(level==0){ + /*瀹屾垚鏃堕棿锛宭evel=0 鏃堕粯璁や负宸ュ崟鐨勮鍒掑畬鎴愭棩鏈�*/ + require.setCompleteDate(plan.getPlanEndDay()); + require.setDemandDate(plan.getPlanEndDay()); + } else { /* 褰撳墠闇�姹傚畬鎴愭棩鏈熶负涓婇樁灞傞渶姹傜殑寮�濮嬫椂闂� - 棰勭暀澶╂暟(杞崲涓烘绉�)*/ long reservedMillisecond = reservedDay * 24 * millisecond; + Date completeDate = new Date(); completeDate.setTime(upLevelStartDate.getTime() - reservedMillisecond); + require.setCompleteDate(completeDate); + require.setDemandDate(completeDate); } - /*璁剧疆瀹屾垚鏃ユ湡*/ - require.setCompleteDate(completeDate); - require.setDemandDate(completeDate); + + /*璁剧疆寮�濮嬫椂闂�*/ Date startDay = new Date(); - startDay.setTime(completeDate.getTime() - totalRouteMillisecond); + startDay.setTime(require.getCompleteDate().getTime() - totalRouteMillisecond); require.setStartDate(startDay); /*璁$畻鏄惁鏈夐闄�*/ @@ -310,7 +318,7 @@ List<ApsBom> bomLineList = bomLineService.selectApsBomLineList(plant, itemCode); if (!bomLineList.isEmpty()) { bomLineList.forEach(line -> { - getBomRequires(plant, line.getBomLineId(),line.getItemCode() ,line.getNum() , batchNum, require.getStartDate(), plan, allRequires, nextLevel); + getBomRequires(plant, itemCode, line.getBomLineId(),line.getItemCode() ,line.getNum() , batchNum, require.getStartDate(), plan, allRequires, nextLevel); }); } } @@ -330,10 +338,10 @@ * 鑾峰彇閽i噾璁″垝 棰勭暀澶╂暟 * */ private Long getReservedDays(){ - Long days=0L; - List<SysDictData> dictDataList = DictUtils.getDictCache("aps_is_suspended"); - if (dictDataList != null) { - Long.getLong(dictDataList.get(0).getDictValue()); + long days=0L; + List<SysDictData> dictDataList = DictUtils.getDictCache("plate_plan_param"); + if (dictDataList != null && !dictDataList.isEmpty()) { + days = Long.parseLong(dictDataList.get(0).getDictValue()); } return days; } @@ -344,44 +352,47 @@ private void matchRequireAndSubPlan(ApsPlateStandardRequire require) { BigDecimal netRequirement = require.getNetRequirement(); + require.setMatchMode("宸ュ崟鍖归厤"); if (netRequirement.compareTo(BigDecimal.ZERO) > 0) { - ApsPlatePlan platePlan = apsPlatePlanMapper.selectUnMatchPlateSubPlan(require.getOrgCode()); + ApsPlatePlan platePlan = apsPlatePlanMapper.selectUnMatchPlateSubPlan(require.getOrgCode(), require.getBomLineCode()); /*瀛愪欢宸ュ崟鐨勬湭鍖归厤鏁伴噺 浣滀负褰撳墠鐨勫簱瀛�*/ while (platePlan != null && netRequirement.compareTo(BigDecimal.ZERO) > 0) { BigDecimal stock = platePlan.getUnmatchedQuantity(); if (netRequirement.compareTo(stock) < 0) { /* 搴撳瓨鏁伴噺 澶т簬 鍑�闇�姹傛暟閲�*/ /* 鍑�闇�姹傛暟閲�=0 锛屽瓙浠跺伐鍗曟湭鍖归厤鏁伴噺= 搴撳瓨-鍑�闇�姹�*/ - netRequirement = BigDecimal.ZERO; - require.setNetRequirement(netRequirement); BigDecimal subtract = stock.subtract(netRequirement); bomOrderDetailService.savePlastPlanAndBomOrderDetail(require, platePlan, subtract, stock, netRequirement); + netRequirement = BigDecimal.ZERO; + require.setMatchState("宸插尮閰�"); + require.setUnmatchedDemandAmount(BigDecimal.ZERO); /*鍑�闇�姹傚凡缁忚婊¤冻锛屼笉闇�瑕佺户缁尮閰�*/ } else if (netRequirement.compareTo(stock) == 0) { /*鍑�闇�姹傛暟閲� == 搴撳瓨鏁伴噺*/ - netRequirement = BigDecimal.ZERO; - require.setNetRequirement(netRequirement); + BigDecimal subtract = BigDecimal.ZERO; bomOrderDetailService.savePlastPlanAndBomOrderDetail(require, platePlan, subtract, stock, netRequirement); + netRequirement = BigDecimal.ZERO; + require.setMatchState("宸插尮閰�"); + require.setUnmatchedDemandAmount(BigDecimal.ZERO); /*鍑�闇�姹傚凡缁忚婊¤冻锛屼笉闇�瑕佺户缁尮閰�*/ } if (netRequirement.compareTo(stock) > 0) { /*闇�姹傚ぇ浜庡簱瀛�*/ /*鍑�闇�姹� 琚儴鍒嗘弧瓒� */ BigDecimal rest = netRequirement.subtract(stock); - require.setNetRequirement(rest); require.setMatchState("鍖归厤涓�"); /*宸ュ崟 鏈尮閰嶆暟閲忎负0 鍏ㄩ儴鐢ㄤ簬鍖归厤闇�姹�*/ bomOrderDetailService.savePlastPlanAndBomOrderDetail(require, platePlan, BigDecimal.ZERO, stock, netRequirement); /*鍑�闇�姹傛湭琚弧瓒筹紝闇�瑕佺户缁尮閰�*/ - platePlan = apsPlatePlanMapper.selectUnMatchPlateSubPlan(require.getOrgCode()); + platePlan = apsPlatePlanMapper.selectUnMatchPlateSubPlan(require.getOrgCode(), require.getBomLineCode()); + /*鍓╀綑鍑�闇�姹�*/ netRequirement = rest; + require.setUnmatchedDemandAmount(rest); } } } - require.setUnmatchedDemandAmount(require.getNetRequirement()); - } -- Gitblit v1.9.3