| | |
| | | // 查询原始数据(不依赖数据库聚合) |
| | | 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"); |
| | | |
| | | // 直接从aps_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为workshop,需要添加processName字段 |
| | | 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; |
| | | } |
| | | |