From 563b227acc04b19406cc4592f5db29b8110f2794 Mon Sep 17 00:00:00 2001
From: hongjli <3117313295@qq.com>
Date: 星期五, 23 五月 2025 13:02:36 +0800
Subject: [PATCH] 设计产能从产能规划中取值时取消对major的过滤
---
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipingRouteStatServiceImpl.java | 158 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 156 insertions(+), 2 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 247add4..d01e96b 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
@@ -1627,13 +1627,13 @@
for (String timePoint : timePoints) {
Map<String, Object> pointData = new HashMap<>();
pointData.put("planDay", timePoint);
- pointData.put("designTimes", 0); // 璁捐宸ユ椂鏆傛椂缁�0
// 鑾峰彇璇ユ椂闂寸偣鐨勯渶姹傚伐鏃讹紝濡傛灉涓嶅瓨鍦ㄥ垯璁句负0
BigDecimal requireTimes = timeMap.getOrDefault(timePoint, BigDecimal.ZERO);
pointData.put("requireTimes", requireTimes);
- // 璁$畻浜ц兘璐熻嵎锛堟殏鏃朵负0锛�
+ // 璁捐宸ユ椂鍜屼骇鑳借礋鑽风◢鍚庤绠�
+ pointData.put("designTimes", 0);
pointData.put("capacityLoad", 0);
timeDataList.add(pointData);
@@ -1644,6 +1644,160 @@
plantTable.add(rowEntry);
}
+ // 鍦ㄨ繑鍥炲墠鏌ヨ璁捐浜ц兘鏁版嵁骞惰绠椾骇鑳借礋鑽�
+ for (Map<String, Object> rowEntry : plantTable) {
+ for (String rowKey : rowEntry.keySet()) {
+ Map<String, Object> rowDetail = (Map<String, Object>) rowEntry.get(rowKey);
+ List<Map<String, Object>> timeDataList = (List<Map<String, Object>>) rowDetail.get("timeData");
+
+ // 鑾峰彇鍩烘湰淇℃伅
+ String plant = rowDetail.containsKey("plant") ? (String) rowDetail.get("plant") : null;
+ String major = rowDetail.containsKey("major") ? (String) rowDetail.get("major") : null;
+ String workshop = rowDetail.containsKey("workshop") ? (String) rowDetail.get("workshop") : null;
+
+ // 澶勭悊涓嶅悓鐨剅owGroupBy鎯呭喌
+ if ("workshop".equals(rowGroupBy) && rowDetail.containsKey("processName")) {
+ // 鎯呭喌1: 鎸墂orkshop鑱氬悎锛岄渶瑕佹媶鍒唒rocessName瀛楁
+ String processNamesStr = (String) rowDetail.get("processName");
+ String[] processNames = processNamesStr.split(";");
+
+ // 浼樺寲鏌ヨ - 鍒涘缓缂撳瓨锛屾寜鏈堜唤缂撳瓨鏌ヨ缁撴灉
+ // Key: year-month-processName, Value: 鏌ヨ缁撴灉鍒楄〃
+ Map<String, List<ApsGasPipelineCapacityPlan>> capacityPlanCache = new HashMap<>();
+
+ // 閬嶅巻姣忎釜鏃堕棿鐐�
+ for (Map<String, Object> timeData : timeDataList) {
+ String planDay = (String) timeData.get("planDay");
+ BigDecimal requireTimes = new BigDecimal(timeData.get("requireTimes").toString());
+ BigDecimal totalDesignTimes = BigDecimal.ZERO;
+
+ // 鎷嗗垎骞存湀鏃�
+ String[] dateParts = planDay.split("-");
+ String year = dateParts[0];
+ String month = dateParts[1];
+ // 缁熶竴month鏍煎紡涓烘暣鏁板瓧绗︿覆锛屽幓鎺夊墠瀵奸浂
+ month = String.valueOf(Integer.parseInt(month));
+ String yearMonth = year + "-" + month;
+
+ // 绱姞澶氫釜宸ュ簭鐨勮璁′骇鑳�
+ for (String processName : processNames) {
+ // 鏋勫缓缂撳瓨閿�
+ String cacheKey = yearMonth + "-" + processName.trim();
+
+ // 浠庣紦瀛樿幏鍙栨垨鏌ヨ鏁版嵁
+ List<ApsGasPipelineCapacityPlan> capacityPlans;
+ if (capacityPlanCache.containsKey(cacheKey)) {
+ capacityPlans = capacityPlanCache.get(cacheKey);
+ } else {
+ // 浣跨敤涓撶敤鏌ヨ鏂规硶鏌ヨ璁捐浜ц兘鏁版嵁
+ // 鎸夋枃妗h姹傦細鏍规嵁process_name鍜宲lant鍘籥ps_gas_pipeline_capacity_plan琛ㄤ腑鏌ヨ
+ capacityPlans = apsGasPipelineCapacityPlanMapper.selectDesignCapacityForInterface2(
+ processName.trim(), year, month, null, plant);
+
+ // 灏嗙粨鏋滃瓨鍏ョ紦瀛�
+ capacityPlanCache.put(cacheKey, capacityPlans);
+ }
+
+ // 绱姞璁捐浜ц兘鍊�
+ for (ApsGasPipelineCapacityPlan plan : capacityPlans) {
+ if ("day".equalsIgnoreCase(timeGranularity)) {
+ // 鏃ョ矑搴︿娇鐢ㄦ棩浜у嚭鏁伴噺
+ if (plan.getDayProduceAllNum() != null) {
+ totalDesignTimes = totalDesignTimes.add(plan.getDayProduceAllNum());
+ }
+ } else {
+ // 鏈堢矑搴︿娇鐢ㄦ湀浜у嚭鎬绘暟閲�
+ if (plan.getMonthProduceAllNum() != null) {
+ totalDesignTimes = totalDesignTimes.add(plan.getMonthProduceAllNum());
+ }
+ }
+ }
+ }
+
+ // 鏇存柊璁捐宸ユ椂
+ timeData.put("designTimes", totalDesignTimes);
+
+ // 璁$畻浜ц兘璐熻嵎 = 闇�姹備骇鑳�/璁捐浜ц兘脳100%
+ if (totalDesignTimes.compareTo(BigDecimal.ZERO) > 0) {
+ BigDecimal capacityLoad = requireTimes
+ .divide(totalDesignTimes, 2, RoundingMode.HALF_UP)
+ .multiply(new BigDecimal(100));
+ timeData.put("capacityLoad", capacityLoad);
+ } else {
+ timeData.put("capacityLoad", 0);
+ }
+ }
+ } else {
+ // 鎯呭喌2: 鎸塸rocessName鎴栧叾浠栧瓧娈佃仛鍚�
+ String processName = rowDetail.containsKey("processName") ?
+ (String) rowDetail.get("processName") : rowKey;
+
+ // 浼樺寲鏌ヨ - 鍒涘缓缂撳瓨锛屾寜鏈堜唤缂撳瓨鏌ヨ缁撴灉
+ Map<String, List<ApsGasPipelineCapacityPlan>> capacityPlanCache = new HashMap<>();
+
+ // 閬嶅巻姣忎釜鏃堕棿鐐�
+ for (Map<String, Object> timeData : timeDataList) {
+ String planDay = (String) timeData.get("planDay");
+ BigDecimal requireTimes = new BigDecimal(timeData.get("requireTimes").toString());
+
+ // 鎷嗗垎骞存湀鏃�
+ String[] dateParts = planDay.split("-");
+ String year = dateParts[0];
+ String month = dateParts[1];
+ // 缁熶竴month鏍煎紡涓烘暣鏁板瓧绗︿覆锛屽幓鎺夊墠瀵奸浂
+ month = String.valueOf(Integer.parseInt(month));
+ String yearMonth = year + "-" + month;
+
+ // 鏋勫缓缂撳瓨閿�
+ String cacheKey = yearMonth + "-" + processName;
+
+ // 浠庣紦瀛樿幏鍙栨垨鏌ヨ鏁版嵁
+ List<ApsGasPipelineCapacityPlan> capacityPlans;
+ if (capacityPlanCache.containsKey(cacheKey)) {
+ capacityPlans = capacityPlanCache.get(cacheKey);
+ } else {
+ // 浣跨敤涓撶敤鏌ヨ鏂规硶鏌ヨ璁捐浜ц兘鏁版嵁
+ // 鎸夋枃妗h姹傦細鏍规嵁process_name鍜宲lant鍘籥ps_gas_pipeline_capacity_plan琛ㄤ腑鏌ヨ
+ capacityPlans = apsGasPipelineCapacityPlanMapper.selectDesignCapacityForInterface2(
+ processName, year, month, null, plant);
+
+ // 灏嗙粨鏋滃瓨鍏ョ紦瀛�
+ capacityPlanCache.put(cacheKey, capacityPlans);
+ }
+
+ // 绱姞璁捐浜ц兘鍊�
+ BigDecimal totalDesignTimes = BigDecimal.ZERO;
+ for (ApsGasPipelineCapacityPlan plan : capacityPlans) {
+ if ("day".equalsIgnoreCase(timeGranularity)) {
+ // 鏃ョ矑搴︿娇鐢ㄦ棩浜у嚭鏁伴噺
+ if (plan.getDayProduceAllNum() != null) {
+ totalDesignTimes = totalDesignTimes.add(plan.getDayProduceAllNum());
+ }
+ } else {
+ // 鏈堢矑搴︿娇鐢ㄦ湀浜у嚭鎬绘暟閲�
+ if (plan.getMonthProduceAllNum() != null) {
+ totalDesignTimes = totalDesignTimes.add(plan.getMonthProduceAllNum());
+ }
+ }
+ }
+
+ // 鏇存柊璁捐宸ユ椂
+ timeData.put("designTimes", totalDesignTimes);
+
+ // 璁$畻浜ц兘璐熻嵎 = 闇�姹備骇鑳�/璁捐浜ц兘脳100%
+ if (totalDesignTimes.compareTo(BigDecimal.ZERO) > 0) {
+ BigDecimal capacityLoad = requireTimes
+ .divide(totalDesignTimes, 2, RoundingMode.HALF_UP)
+ .multiply(new BigDecimal(100));
+ timeData.put("capacityLoad", capacityLoad);
+ } else {
+ timeData.put("capacityLoad", 0);
+ }
+ }
+ }
+ }
+ }
+
result.put("plantTable", plantTable);
result.put("timePoints", timePoints);
result.put("rowGroupBy", rowGroupBy);
--
Gitblit v1.9.3