From 0de06ac0a530227080e9b9b4c7560d4e809fed1e Mon Sep 17 00:00:00 2001
From: zhanghl <253316343@qq.com>
Date: 星期五, 23 五月 2025 14:58:12 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev
---
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipingRouteStatServiceImpl.java | 233 ++++++++++++++++++++++++++++++++++++++
aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipelineCapacityPlanMapper.xml | 19 +++
aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipingRouteStatMapper.xml | 39 ++++++
aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsGasPipelineCapacityPlanMapper.java | 18 +++
aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsGasPipingRouteStatMapper.java | 8 +
5 files changed, 313 insertions(+), 4 deletions(-)
diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsGasPipelineCapacityPlanMapper.java b/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsGasPipelineCapacityPlanMapper.java
index 22ddc1c..c19b6a8 100644
--- a/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsGasPipelineCapacityPlanMapper.java
+++ b/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsGasPipelineCapacityPlanMapper.java
@@ -3,6 +3,7 @@
import com.aps.core.domain.ApsGasPipelineCapacityPlan;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -30,6 +31,23 @@
* @return 姘斾綋绠¤矾浜ц兘瑙勫垝闆嗗悎
*/
public List<ApsGasPipelineCapacityPlan> selectApsGasPipelineCapacityPlanList(ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlan);
+
+ /**
+ * 鏌ヨ璁捐浜ц兘鏁版嵁 - 涓撶敤浜庢帴鍙d簩鍔熻兘
+ *
+ * @param processName 宸ュ簭鍚嶇О
+ * @param year 骞翠唤
+ * @param month 鏈堜唤
+ * @param major 涓撲笟
+ * @param orgCode 宸ュ巶浠g爜
+ * @return 姘斾綋绠¤矾浜ц兘瑙勫垝闆嗗悎
+ */
+ public List<ApsGasPipelineCapacityPlan> selectDesignCapacityForInterface2(
+ @Param("processName") String processName,
+ @Param("year") String year,
+ @Param("month") String month,
+ @Param("major") String major,
+ @Param("orgCode") String orgCode);
/**
* 鏂板姘斾綋绠¤矾浜ц兘瑙勫垝
diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsGasPipingRouteStatMapper.java b/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsGasPipingRouteStatMapper.java
index 6dd1432..f1fcb23 100644
--- a/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsGasPipingRouteStatMapper.java
+++ b/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsGasPipingRouteStatMapper.java
@@ -122,4 +122,12 @@
* @return 鎵�鏈夋墜宸ユ皵浣撳伐鍗曟暟鎹�
*/
public List<Map<String, Object>> selectAllMoData();
+
+ /**
+ * 鏌ヨ鍩虹缁熻鏁版嵁锛堜笉鍖呭惈鏃堕棿闄愬埗锛�
+ *
+ * @param params 鏌ヨ鍙傛暟锛堜笉鍖呭惈鏃堕棿鑼冨洿鍙傛暟锛�
+ * @return 鍩虹缁熻鏁版嵁鍒楄〃
+ */
+ public List<Map<String, Object>> selectBaseStatData(Map<String, Object> params);
}
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 ce61324..53dd3b5 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
@@ -1489,9 +1489,61 @@
// 鏌ヨ鍘熷鏁版嵁锛堜笉渚濊禆鏁版嵁搴撹仛鍚堬級
List<Map<String, Object>> rawData = apsGasPipingRouteStatMapper.selectRawStatData(queryParams);
+ // 濡傛灉娌℃湁鏌ヨ鍒板師濮嬫暟鎹紝浣嗛渶瑕佽繑鍥炴墍鏈夊伐搴�/杞﹂棿鐨勬暟鎹�
if (rawData.isEmpty()) {
+ // 鍒涘缓娌℃湁鏃堕棿闄愬埗鐨勫熀纭�鏌ヨ鍙傛暟
+ Map<String, Object> baseParams = new HashMap<>(queryParams);
+ baseParams.remove("yearStart");
+ baseParams.remove("monthStart");
+ baseParams.remove("yearEnd");
+ baseParams.remove("monthEnd");
+
+ // 鐩存帴浠巃ps_gas_piping_route_stat琛ㄦ煡璇㈡墍鏈夊彲鑳界殑宸ュ簭鍜岃溅闂�
+ List<Map<String, Object>> baseData = apsGasPipingRouteStatMapper.selectBaseStatData(baseParams);
+
+ // 涓烘瘡涓伐搴�/杞﹂棿鍒涘缓鍩轰簬鏃堕棿鐨勭┖鏁版嵁
+ for (Map<String, Object> data : baseData) {
+ String rowGroupValue = getStringValue(data, rowGroupBy);
+ if (rowGroupValue == null || rowGroupValue.trim().isEmpty()) continue;
+
+ Map<String, Object> rowEntry = new HashMap<>();
+ Map<String, Object> rowDetail = new HashMap<>();
+
+ // 娣诲姞鍩烘湰淇℃伅
+ String plant = getStringValue(data, "plant");
+ String major = getStringValue(data, "major");
+ String workshop = getStringValue(data, "workshop");
+
+ if (groupByPlant) rowDetail.put("plant", plant);
+ if (groupByMajor) rowDetail.put("major", major);
+ if (groupByWorkshop) rowDetail.put("workshop", workshop);
+
+ // 澶勭悊宸ュ簭鍚嶇О - 濡傛灉rowGroupBy涓簑orkshop锛岄渶瑕佹坊鍔爌rocessName瀛楁
+ if ("workshop".equals(rowGroupBy)) {
+ String processName = getStringValue(data, "processName");
+ rowDetail.put("processName", processName != null ? processName : "");
+ }
+
+ // 涓烘瘡涓椂闂寸偣鍒涘缓闆跺�兼暟鎹�
+ List<Map<String, Object>> timeDataList = new ArrayList<>();
+ for (String timePoint : timePoints) {
+ Map<String, Object> pointData = new HashMap<>();
+ pointData.put("planDay", timePoint);
+ pointData.put("requireTimes", BigDecimal.ZERO);
+ pointData.put("designTimes", BigDecimal.ZERO);
+ pointData.put("capacityLoad", BigDecimal.ZERO);
+ timeDataList.add(pointData);
+ }
+
+ rowDetail.put("timeData", timeDataList);
+ rowEntry.put(rowGroupValue, rowDetail);
+ plantTable.add(rowEntry);
+ }
+
result.put("plantTable", plantTable);
result.put("timePoints", timePoints);
+ result.put("rowGroupBy", rowGroupBy);
+
return result;
}
@@ -1499,6 +1551,8 @@
// 浣跨敤缁勫悎key鏉ュ疄鐜板缁村害鍒嗙粍锛堝姩鎬乺owGroupBy瀛楁 + 鍙�夌殑宸ュ巶/涓撲笟/杞﹂棿锛�
Map<String, Map<String, Object>> groupInfoMap = new HashMap<>();
Map<String, Map<String, BigDecimal>> groupTimeDataMap = new HashMap<>();
+ // 瀛樺偍姣忎釜groupKey瀵瑰簲鐨刾rocessName闆嗗悎
+ Map<String, Set<String>> groupProcessNamesMap = new HashMap<>();
// 閬嶅巻鍘熷鏁版嵁锛屾寜澶氱淮搴﹀垎缁勮繘琛岃仛鍚�
for (Map<String, Object> data : rawData) {
@@ -1550,6 +1604,14 @@
groupInfoMap.put(groupKey, groupInfo);
}
+ // 鏀堕泦processName
+ if (processName != null && !processName.trim().isEmpty()) {
+ if (!groupProcessNamesMap.containsKey(groupKey)) {
+ groupProcessNamesMap.put(groupKey, new HashSet<>());
+ }
+ groupProcessNamesMap.get(groupKey).add(processName);
+ }
+
// 璁$畻鏃堕棿鐐筀ey
String timeKey;
LocalDate planStartLocalDate = processPlanStartDay.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
@@ -1596,8 +1658,17 @@
rowDetail.put("workshop", groupInfo.get("workshop"));
}
- // 淇濈暀宸ュ簭鍚嶇О淇℃伅锛屼互渚垮墠绔睍绀�
- if (!"processName".equals(rowGroupBy)) {
+ // 澶勭悊processName - 濡傛灉rowGroupBy涓簑orkshop锛屽垯灏嗘墍鏈塸rocessName鐢ㄥ垎鍙疯繛鎺�
+ if ("workshop".equals(rowGroupBy)) {
+ Set<String> processNames = groupProcessNamesMap.getOrDefault(groupKey, new HashSet<>());
+ if (!processNames.isEmpty()) {
+ String joinedProcessNames = String.join(";", processNames);
+ rowDetail.put("processName", joinedProcessNames);
+ } else {
+ rowDetail.put("processName", groupInfo.get("processName"));
+ }
+ } else if (!"processName".equals(rowGroupBy)) {
+ // 淇濈暀宸ュ簭鍚嶇О淇℃伅锛屼互渚垮墠绔睍绀�
rowDetail.put("processName", groupInfo.get("processName"));
}
@@ -1608,13 +1679,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);
@@ -1625,6 +1696,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);
diff --git a/aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipelineCapacityPlanMapper.xml b/aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipelineCapacityPlanMapper.xml
index 5c16e41..b41970a 100644
--- a/aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipelineCapacityPlanMapper.xml
+++ b/aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipelineCapacityPlanMapper.xml
@@ -146,4 +146,23 @@
and org_code = #{factory}
and major = #{major}
</delete>
+
+ <!-- 鏌ヨ璁捐浜ц兘鏁版嵁 - 涓撶敤浜庢帴鍙d簩鍔熻兘 -->
+ <select id="selectDesignCapacityForInterface2" resultMap="ApsGasPipelineCapacityPlanResult">
+ <include refid="selectApsGasPipelineCapacityPlanVo"/>
+ <where>
+ <if test="processName != null and processName != ''">
+ and process_name = #{processName}
+ </if>
+ <if test="year != null and year != ''">
+ and year = #{year}
+ </if>
+ <if test="month != null and month != ''">
+ and CAST(month AS INTEGER) = CAST(#{month} AS INTEGER)
+ </if>
+ <if test="orgCode != null and orgCode != ''">
+ and org_code = #{orgCode}
+ </if>
+ </where>
+ </select>
</mapper>
\ No newline at end of file
diff --git a/aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipingRouteStatMapper.xml b/aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipingRouteStatMapper.xml
index 4789ec5..0cee419 100644
--- a/aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipingRouteStatMapper.xml
+++ b/aps-modules/aps-core/src/main/resources/mapper/core/ApsGasPipingRouteStatMapper.xml
@@ -413,4 +413,43 @@
FROM aps_gas_pipeline_mo
</select>
+ <!-- 鏌ヨ鍩虹缁熻鏁版嵁锛堜笉鍖呭惈鏃堕棿闄愬埗锛夛紝鐢ㄤ簬鑾峰彇鎵�鏈夊彲鑳界殑宸ュ簭鍚嶅拰杞﹂棿 -->
+ <select id="selectBaseStatData" parameterType="java.util.Map" resultType="java.util.Map">
+ SELECT DISTINCT
+ process_name AS "processName",
+ plant AS "plant",
+ major AS "major",
+ workshop AS "workshop"
+ FROM aps_gas_piping_route_stat
+ <where>
+ <if test="plants != null and plants.size() > 0">
+ AND plant IN
+ <foreach collection="plants" item="item" open="(" separator="," close=")">
+ #{item}
+ </foreach>
+ </if>
+ <if test="plant != null and plant != ''">
+ AND plant = #{plant}
+ </if>
+ <if test="majors != null and majors.size() > 0">
+ AND major IN
+ <foreach collection="majors" item="item" open="(" separator="," close=")">
+ #{item}
+ </foreach>
+ </if>
+ <if test="major != null and major != ''">
+ AND major = #{major}
+ </if>
+ <if test="workshops != null and workshops.size() > 0">
+ AND workshop IN
+ <foreach collection="workshops" item="item" open="(" separator="," close=")">
+ #{item}
+ </foreach>
+ </if>
+ <if test="workshop != null and workshop != ''">
+ AND workshop = #{workshop}
+ </if>
+ </where>
+ </select>
+
</mapper>
\ No newline at end of file
--
Gitblit v1.9.3