From f5f908446cab6a5563cd5146bdf0119384514697 Mon Sep 17 00:00:00 2001 From: huangjiayang <5265313@qq.com> Date: 星期一, 28 四月 2025 21:37:35 +0800 Subject: [PATCH] 【UPDATE-BUGFIX】修改获取设计产能数BUG --- aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipingRouteStatServiceImpl.java | 32 +++++++++++++++++++++++++------- 1 files changed, 25 insertions(+), 7 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 092a6be..bcb7094 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 @@ -236,7 +236,7 @@ JSONObject result = new JSONObject(); YearMonth yearMonth = YearMonth.parse(apsGasPipingRouteStat.getSearchEndDate()); int daysInMonth = yearMonth.lengthOfMonth(); - HashSet<String> startPlanTimeSet = new HashSet<>(); + LinkedHashSet<String> startPlanTimeSet = new LinkedHashSet<>(); //宸ュ簭鍒嗙粍缁熻 LinkedHashMap<String, List<ApsResourceDateStat>> processMap = new LinkedHashMap<>(); List<HashMap<String, List<ApsResourceDateStat>>> processList = new ArrayList<>(); @@ -261,8 +261,11 @@ } }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)); + YearMonth start = YearMonth.of(Integer.parseInt(apsGasPipingRouteStat.getSearchStartDate().split("-")[0]), Integer.parseInt(apsGasPipingRouteStat.getSearchStartDate().split("-")[1])); + YearMonth end = YearMonth.of(Integer.parseInt(apsGasPipingRouteStat.getSearchEndDate().split("-")[0]), Integer.parseInt(apsGasPipingRouteStat.getSearchEndDate().split("-")[1])); + List<String> yearMonths = getYearMonthsInRange(start, end); + for (String yearMonthStr : yearMonths) { + startPlanTimeSet.add(yearMonthStr); } } List<ApsGasPipelineCapacityPlan> apsGasPipelineCapacityPlanList = apsGasPipelineCapacityPlanMapper.selectApsGasPipelineCapacityPlanList(searchCapacityPlan); @@ -328,8 +331,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)); @@ -357,9 +360,12 @@ for (Map.Entry<String, List<ApsResourceDateStat>> entry : temp.entrySet()){ List<ApsResourceDateStat> apsResourceDateStatList = entry.getValue(); String key = entry.getKey(); - LocalDate crtDate=LocalDate.parse(key, formatter); + List<ApsResourceDateStat> crtList = new ArrayList<>(); for(String tempTime:sortedStartPlanTimeList) { - List<ApsResourceDateStat> crtList = new ArrayList<>(); + if("month".equals(apsGasPipingRouteStat.getSearchType())){ + tempTime += "-01"; + } + 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(); @@ -485,4 +491,16 @@ styles.put("title", style); return styles; } + + public static List<String> getYearMonthsInRange(YearMonth start, YearMonth end) { + List<String> yearMonths = new ArrayList<>(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM"); + + while (!start.isAfter(end)) { + yearMonths.add(start.format(formatter)); + start = start.plusMonths(1); + } + + return yearMonths; + } } -- Gitblit v1.9.3