From dec8951aae400e54f6ee83a8f95867dba9da8af1 Mon Sep 17 00:00:00 2001 From: zhanghl <253316343@qq.com> Date: 星期五, 23 五月 2025 17:17:33 +0800 Subject: [PATCH] [钣金计划大表] 优化:焊缝统计导出Excel样式 --- aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipingRouteStatServiceImpl.java | 80 +++++++++++++++++++++++++++++++++++++++- 1 files changed, 78 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 49878d5..248f120 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; } @@ -1690,7 +1742,7 @@ capacityPlans = capacityPlanCache.get(cacheKey); } else { // 浣跨敤涓撶敤鏌ヨ鏂规硶鏌ヨ璁捐浜ц兘鏁版嵁 - // 鎸夋枃妗h姹傦細鏍规嵁澶氫釜process_name鍜宮ajor銆乸lant鍘籥ps_gas_pipeline_capacity_plan琛ㄤ腑鏌ヨ + // 鎸夋枃妗h姹傦細鏍规嵁process_name鍜宲lant鍘籥ps_gas_pipeline_capacity_plan琛ㄤ腑鏌ヨ capacityPlans = apsGasPipelineCapacityPlanMapper.selectDesignCapacityForInterface2( processName.trim(), year, month, major, plant); @@ -1757,7 +1809,7 @@ capacityPlans = capacityPlanCache.get(cacheKey); } else { // 浣跨敤涓撶敤鏌ヨ鏂规硶鏌ヨ璁捐浜ц兘鏁版嵁 - // 鎸夋枃妗h姹傦細鏍规嵁process_name銆乵ajor銆乸lant鍘籥ps_gas_pipeline_capacity_plan琛ㄤ腑鏌ヨ + // 鎸夋枃妗h姹傦細鏍规嵁process_name鍜宲lant鍘籥ps_gas_pipeline_capacity_plan琛ㄤ腑鏌ヨ capacityPlans = apsGasPipelineCapacityPlanMapper.selectDesignCapacityForInterface2( processName, year, month, major, plant); @@ -1802,6 +1854,30 @@ result.put("timePoints", timePoints); result.put("rowGroupBy", rowGroupBy); + // 鏍规嵁鏂囨。娉ㄦ剰鐐�3锛屾坊鍔犳帓搴忛�昏緫 + if (!plantTable.isEmpty()) { + // 瀵硅仛鍚堢粨鏋滆繘琛屾帓搴� + Collections.sort(plantTable, (map1, map2) -> { + String key1 = map1.keySet().iterator().next(); + String key2 = map2.keySet().iterator().next(); + + // 棣栧厛鎸塺owGroupBy鎺掑簭锛坧rocessName鎴杦orkshop锛� + int result1 = key1.compareTo(key2); + if (result1 != 0) { + return result1; + } + + // 濡傛灉rowGroupBy鐩稿悓锛屽啀鎸塸lant鎺掑簭 + Map<String, Object> detail1 = (Map<String, Object>) map1.get(key1); + Map<String, Object> detail2 = (Map<String, Object>) map2.get(key2); + + String plant1 = detail1.containsKey("plant") ? (String) detail1.get("plant") : ""; + String plant2 = detail2.containsKey("plant") ? (String) detail2.get("plant") : ""; + + return plant1.compareTo(plant2); + }); + } + return result; } -- Gitblit v1.9.3