From 38a83612e02f1800c89cb29d66e1899779b74424 Mon Sep 17 00:00:00 2001
From: zhanghl <253316343@qq.com>
Date: 星期一, 28 四月 2025 21:16:07 +0800
Subject: [PATCH] 气体管路

---
 aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipingRouteStatServiceImpl.java |   52 +++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipingRouteStatServiceImpl.java b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipingRouteStatServiceImpl.java
index 6535423..79a26b3 100644
--- a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipingRouteStatServiceImpl.java
+++ b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipingRouteStatServiceImpl.java
@@ -203,9 +203,9 @@
 //                    apsGasMaterialUsage.setItemNumber(apsGasPipingPlan.getItemNumber());
 //                    apsGasMaterialUsage.setProcessName(apsProcessRoute.getProcessName());
 //                    List<ApsGasMaterialUsage> apsGasMaterialUsageList = apsGasMaterialUsageService.selectApsGasMaterialUsageList(apsGasMaterialUsage);
-                    apsGasPipingRouteStat.setStandardDosage(apsProcessRoute.getStandardTime().multiply(apsGasPipingPlan.getProductionQuantity()));
+//                    apsGasPipingRouteStat.setStandardDosage(apsProcessRoute.getStandardTime().multiply(apsGasPipingPlan.getProductionQuantity()));
                     //宸ュ簭鎬荤敤閲� = 鏍囧噯鐢ㄩ噺*鐢熶骇鏁伴噺
-                    apsGasPipingRouteStat.setProcessTotalDosage(apsGasPipingRouteStat.getStandardDosage().multiply(apsGasPipingPlan.getProductionQuantity()));
+//                    apsGasPipingRouteStat.setProcessTotalDosage(apsGasPipingRouteStat.getStandardDosage().multiply(apsGasPipingPlan.getProductionQuantity()));
                     apsGasPipingRouteStat.setCreateTime(DateUtils.getNowDate());
                     apsGasPipingRouteStat.setCreateBy("auto");
                     apsGasPipingRouteStat.setBatchNumber(batchNum);
@@ -234,6 +234,8 @@
     @Override
     public JSONObject getCapacityPlanData(ApsGasPipingRouteStat apsGasPipingRouteStat) {
         JSONObject result = new JSONObject();
+        YearMonth yearMonth = YearMonth.parse(apsGasPipingRouteStat.getSearchEndDate());
+        int daysInMonth = yearMonth.lengthOfMonth();
         HashSet<String> startPlanTimeSet = new HashSet<>();
         //宸ュ簭鍒嗙粍缁熻
         LinkedHashMap<String, List<ApsResourceDateStat>> processMap = new LinkedHashMap<>();
@@ -249,7 +251,21 @@
             }
             //鑾峰彇宸ュ簭璁″垝浜ц兘鏁版嵁
             HashMap<String, ApsGasPipelineCapacityPlan> apsGasPipingPlanMap = new HashMap<>();
-            List<ApsGasPipelineCapacityPlan> apsGasPipelineCapacityPlanList = apsGasPipelineCapacityPlanMapper.selectApsGasPipelineCapacityPlanList(new ApsGasPipelineCapacityPlan());
+            ApsGasPipelineCapacityPlan searchCapacityPlan = new ApsGasPipelineCapacityPlan();
+            searchCapacityPlan.setMajor(apsGasPipingRouteStat.getMajor().equals("gas")?"姘旀煖":"绠¤矾");
+            if("day".equals(apsGasPipingRouteStat.getSearchType())){
+                searchCapacityPlan.setYear(yearMonth.getYear()+"");
+                searchCapacityPlan.setMonth(yearMonth.getMonthValue()+"");
+                for(int i=1;i<=daysInMonth;i++){
+                    startPlanTimeSet.add(yearMonth +"-"+ (i<10?"0"+i:i));
+                }
+            }else if("month".equals(apsGasPipingRouteStat.getSearchType())){
+                searchCapacityPlan.setYear(yearMonth.getYear()+"");
+                for(int i=1;i<=12;i++){
+                    startPlanTimeSet.add(yearMonth.getYear()+"-"+(i<10?"0"+i:i));
+                }
+            }
+            List<ApsGasPipelineCapacityPlan> apsGasPipelineCapacityPlanList = apsGasPipelineCapacityPlanMapper.selectApsGasPipelineCapacityPlanList(searchCapacityPlan);
             apsGasPipelineCapacityPlanList.forEach(apsGasPipelineCapacityPlan -> {
                 apsGasPipingPlanMap.put(apsGasPipelineCapacityPlan.getProcessName(),apsGasPipelineCapacityPlan);
             });
@@ -257,8 +273,6 @@
             DateTimeFormatter formatter = null;
             List<ApsGasPipingRouteStat> apsGasPipingRouteStats;
             SimpleDateFormat simpleDateFormat = null;
-            YearMonth yearMonth = YearMonth.parse(apsGasPipingRouteStat.getSearchEndDate());
-            int daysInMonth = yearMonth.lengthOfMonth();
             apsGasPipingRouteStat.setSearchStartDate(apsGasPipingRouteStat.getSearchStartDate()+"-01 00:00:00");
             apsGasPipingRouteStat.setSearchEndDate(apsGasPipingRouteStat.getSearchEndDate()+"-"+ daysInMonth +" 23:59:59");
             if("day".equals(apsGasPipingRouteStat.getSearchType())){
@@ -304,7 +318,7 @@
             processMap.forEach((processName, apsResourceDateStatList) -> {
                 LinkedHashMap<String, ApsResourceDateStat> dayMap = new LinkedHashMap<>();
                 apsResourceDateStatList.forEach(apsResourceDateStat -> {
-                    startPlanTimeSet.add(apsResourceDateStat.getPlanDay().toString());
+//                    startPlanTimeSet.add(apsResourceDateStat.getPlanDay().toString());
                     if(dayMap.containsKey(apsResourceDateStat.getPlanDay().toString())){
                         ApsResourceDateStat apsResourceDateStatTemp = dayMap.get(apsResourceDateStat.getPlanDay().toString());
                         if("month".equals(apsGasPipingRouteStat.getSearchType())){
@@ -314,8 +328,8 @@
                         }
                         apsResourceDateStatTemp.setRequireTimes(apsResourceDateStatTemp.getRequireTimes().add(apsResourceDateStat.getRequireTimes()));
                         if(apsResourceDateStatTemp.getDesignTimes().compareTo(BigDecimal.ZERO) > 0){
-                            apsResourceDateStat.setCapacityLoad(apsResourceDateStat.getRequireTimes()
-                                    .divide(apsResourceDateStat.getDesignTimes(), 2, RoundingMode.HALF_UP)
+                            apsResourceDateStatTemp.setCapacityLoad(apsResourceDateStatTemp.getRequireTimes()
+                                    .divide(apsResourceDateStatTemp.getDesignTimes(), 2, RoundingMode.HALF_UP)
                                     .multiply(new BigDecimal(100)));
                         }else{
                             apsResourceDateStatTemp.setCapacityLoad(new BigDecimal(0));
@@ -342,22 +356,30 @@
                 HashMap<String, List<ApsResourceDateStat>> temp = processList.get(i);
                 for (Map.Entry<String, List<ApsResourceDateStat>> entry : temp.entrySet()){
                     List<ApsResourceDateStat> apsResourceDateStatList = entry.getValue();
-                    if(apsResourceDateStatList.size()<=0){
-                        for(String tempTime:sortedStartPlanTimeList){
+                    String key = entry.getKey();
+                    List<ApsResourceDateStat> crtList = new ArrayList<>();
+                    for(String tempTime:sortedStartPlanTimeList) {
+                        LocalDate crtDate = LocalDate.parse(tempTime, formatter);
+                        Optional<ApsResourceDateStat> first = apsResourceDateStatList.stream().filter(x -> x.getPlanDay().equals(crtDate)).findFirst();
+                        if (first.isPresent()) {
+                            ApsResourceDateStat apsResourceDateStat = first.get();
+                            crtList.add(apsResourceDateStat);
+                        } else {
                             ApsResourceDateStat apsResourceDateStat = new ApsResourceDateStat();
                             apsResourceDateStat.setPlanDay(LocalDate.parse(tempTime, formatter));
-                            if("month".equals(apsGasPipingRouteStat.getSearchType())){
-                                apsResourceDateStat.setDesignTimes(apsGasPipingPlanMap.get(entry.getKey())!=null?apsGasPipingPlanMap.get(entry.getKey()).getMonthProduceAllNum():new BigDecimal(0));
-                            }else{
-                                apsResourceDateStat.setDesignTimes(apsGasPipingPlanMap.get(entry.getKey())!=null?apsGasPipingPlanMap.get(entry.getKey()).getDayProduceAllNum():new BigDecimal(0));
+                            if ("month".equals(apsGasPipingRouteStat.getSearchType())) {
+                                apsResourceDateStat.setDesignTimes(apsGasPipingPlanMap.get(entry.getKey()) != null ? apsGasPipingPlanMap.get(entry.getKey()).getMonthProduceAllNum() : new BigDecimal(0));
+                            } else {
+                                apsResourceDateStat.setDesignTimes(apsGasPipingPlanMap.get(entry.getKey()) != null ? apsGasPipingPlanMap.get(entry.getKey()).getDayProduceAllNum() : new BigDecimal(0));
                             }
                             apsResourceDateStat.setRequireTimes(new BigDecimal(0));
                             apsResourceDateStat.setCapacityLoad(new BigDecimal(0));
                             apsResourceDateStat.setResourceName(entry.getKey());
                             apsResourceDateStat.setResourceGroupName(entry.getKey());
                             apsResourceDateStatList.add(apsResourceDateStat);
+                            crtList.add(apsResourceDateStat);
                         }
-                        temp.put(entry.getKey(), apsResourceDateStatList);
+                        temp.put(entry.getKey(), crtList);
                         processList.set(i, temp);
                     }
                 }

--
Gitblit v1.9.3