From 0b39edb68acc67ed01fbfe5d31bfa776a1b17de1 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期三, 25 三月 2026 09:14:53 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/show-demo' into show_demo
---
jyz-base-start/src/main/java/com/tievd/jyz/service/impl/DepartLabelServiceImpl.java | 200 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 200 insertions(+), 0 deletions(-)
diff --git a/jyz-base-start/src/main/java/com/tievd/jyz/service/impl/DepartLabelServiceImpl.java b/jyz-base-start/src/main/java/com/tievd/jyz/service/impl/DepartLabelServiceImpl.java
new file mode 100644
index 0000000..73880b3
--- /dev/null
+++ b/jyz-base-start/src/main/java/com/tievd/jyz/service/impl/DepartLabelServiceImpl.java
@@ -0,0 +1,200 @@
+package com.tievd.jyz.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.tievd.jyz.entity.DepartLabel;
+import com.tievd.jyz.mapper.DepartLabelMapper;
+import com.tievd.jyz.service.IDepartLabelService;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class DepartLabelServiceImpl extends ServiceImpl<DepartLabelMapper, DepartLabel> implements IDepartLabelService {
+
+ @Override
+ public List<Map<String, Object>> queryDepartLabelList(String labelName, String parentCode, String parentId) {
+ return baseMapper.queryDepartLabelList(labelName, parentCode, parentId);
+ }
+
+ @Override
+ public List<String> queryAllLabelNames(String parentCode, String parentId) {
+ return baseMapper.queryAllLabelNames(parentCode, parentId);
+ }
+
+ @Override
+ public List<Map<String, Object>> queryOrgOilCount(String orgCode, String startTime, String endTime) {
+ List<Map<String, Object>> oilCountList = baseMapper.queryOrgOilCount(orgCode, startTime, endTime);
+
+ System.out.println("=== queryOrgOilCount 寮�濮� ===");
+ System.out.println("orgCode: " + orgCode);
+ System.out.println("startTime: " + startTime);
+ System.out.println("endTime: " + endTime);
+ System.out.println("oilCountList size: " + (oilCountList != null ? oilCountList.size() : 0));
+
+ if (oilCountList == null || oilCountList.isEmpty()) {
+ return new ArrayList<>();
+ }
+
+ Map<String, String> orgCodeToIdMap = new HashMap<>();
+ Map<String, String> idToParentIdMap = new HashMap<>();
+ Map<String, Integer> idOilCountMap = new HashMap<>();
+ Map<String, Integer> idCarCountMap = new HashMap<>();
+ Map<String, Integer> idStationCountMap = new HashMap<>();
+ Map<String, Integer> idOilVolumeMap = new HashMap<>();
+
+ for (Map<String, Object> item : oilCountList) {
+ String orgCodeStr = (String) item.get("org_code");
+ String departId = (String) item.get("depart_id");
+
+ Object oilCountObj = item.get("oilCount");
+ Integer oilCount = null;
+ if (oilCountObj instanceof Integer) {
+ oilCount = (Integer) oilCountObj;
+ } else if (oilCountObj instanceof Number) {
+ oilCount = ((Number) oilCountObj).intValue();
+ } else if (oilCountObj instanceof String) {
+ oilCount = Integer.parseInt((String) oilCountObj);
+ }
+
+ Object carCountObj = item.get("carCount");
+ Integer carCount = null;
+ if (carCountObj instanceof Integer) {
+ carCount = (Integer) carCountObj;
+ } else if (carCountObj instanceof Number) {
+ carCount = ((Number) carCountObj).intValue();
+ } else if (carCountObj instanceof String) {
+ carCount = Integer.parseInt((String) carCountObj);
+ }
+
+ Object stationCountObj = item.get("stationCount");
+ Integer stationCount = null;
+ if (stationCountObj instanceof Integer) {
+ stationCount = (Integer) stationCountObj;
+ } else if (stationCountObj instanceof Number) {
+ stationCount = ((Number) stationCountObj).intValue();
+ } else if (stationCountObj instanceof String) {
+ stationCount = Integer.parseInt((String) stationCountObj);
+ }
+
+ Object oilVolumeObj = item.get("oilVolume");
+ Integer oilVolume = null;
+ if (oilVolumeObj instanceof Integer) {
+ oilVolume = (Integer) oilVolumeObj;
+ } else if (oilVolumeObj instanceof Number) {
+ oilVolume = ((Number) oilVolumeObj).intValue();
+ } else if (oilVolumeObj instanceof String) {
+ oilVolume = Integer.parseInt((String) oilVolumeObj);
+ }
+
+ if (departId != null) {
+ orgCodeToIdMap.put(orgCodeStr, departId);
+ if (oilCount != null) {
+ idOilCountMap.put(departId, oilCount);
+ }
+ if (carCount != null) {
+ idCarCountMap.put(departId, carCount);
+ }
+ if (stationCount != null) {
+ idStationCountMap.put(departId, stationCount);
+ }
+ if (oilVolume != null) {
+ idOilVolumeMap.put(departId, oilVolume);
+ }
+ }
+ }
+
+ List<Map<String, Object>> departList = baseMapper.queryDepartLabelList(null, orgCode, null);
+ System.out.println("departList size: " + (departList != null ? departList.size() : 0));
+
+ for (Map<String, Object> depart : departList) {
+ String departId = (String) depart.get("id");
+ Object parentIdObj = depart.get("parent_id");
+ System.out.println("departId: " + departId + ", parentId: " + parentIdObj);
+ if (parentIdObj != null) {
+ String parentIdStr = parentIdObj.toString();
+ if (parentIdStr != null && !parentIdStr.isEmpty()) {
+ String[] parentIds = parentIdStr.split(",");
+ for (String pid : parentIds) {
+ if (!pid.trim().isEmpty()) {
+ idToParentIdMap.put(departId, pid.trim());
+ System.out.println(" -> 鐖跺瓙鍏崇郴: " + departId + " -> " + pid.trim());
+ }
+ }
+ }
+ }
+ }
+
+ System.out.println("idToParentIdMap size: " + idToParentIdMap.size());
+ System.out.println("idOilCountMap: " + idOilCountMap);
+ System.out.println("idCarCountMap: " + idCarCountMap);
+ System.out.println("idStationCountMap: " + idStationCountMap);
+ System.out.println("idOilVolumeMap: " + idOilVolumeMap);
+
+ Map<String, Integer> finalOilCountMap = new HashMap<>(idOilCountMap);
+ Map<String, Integer> finalCarCountMap = new HashMap<>(idCarCountMap);
+ Map<String, Integer> finalStationCountMap = new HashMap<>(idStationCountMap);
+ Map<String, Integer> finalOilVolumeMap = new HashMap<>(idOilVolumeMap);
+
+ for (Map.Entry<String, String> entry : idToParentIdMap.entrySet()) {
+ String childId = entry.getKey();
+ String parentIdStr = entry.getValue();
+ if (parentIdStr != null && !parentIdStr.isEmpty()) {
+ Integer childOilCount = idOilCountMap.get(childId);
+ if (childOilCount != null) {
+ finalOilCountMap.merge(parentIdStr, childOilCount, Integer::sum);
+ System.out.println("绱姞鍔犳补鏁�: 鐖惰妭鐐� " + parentIdStr + " += 瀛愯妭鐐� " + childId + " 鐨� " + childOilCount);
+ }
+ Integer childCarCount = idCarCountMap.get(childId);
+ if (childCarCount != null) {
+ finalCarCountMap.merge(parentIdStr, childCarCount, Integer::sum);
+ System.out.println("绱姞杞︽祦閲�: 鐖惰妭鐐� " + parentIdStr + " += 瀛愯妭鐐� " + childId + " 鐨� " + childCarCount);
+ }
+ Integer childStationCount = idStationCountMap.get(childId);
+ if (childStationCount != null) {
+ finalStationCountMap.merge(parentIdStr, childStationCount, Integer::sum);
+ System.out.println("绱姞杩涚珯鏁�: 鐖惰妭鐐� " + parentIdStr + " += 瀛愯妭鐐� " + childId + " 鐨� " + childStationCount);
+ }
+ Integer childOilVolume = idOilVolumeMap.get(childId);
+ if (childOilVolume != null) {
+ finalOilVolumeMap.merge(parentIdStr, childOilVolume, Integer::sum);
+ System.out.println("绱姞娌瑰搧閿�閲�: 鐖惰妭鐐� " + parentIdStr + " += 瀛愯妭鐐� " + childId + " 鐨� " + childOilVolume);
+ }
+ }
+ }
+
+ System.out.println("finalOilCountMap: " + finalOilCountMap);
+ System.out.println("finalCarCountMap: " + finalCarCountMap);
+ System.out.println("finalStationCountMap: " + finalStationCountMap);
+ System.out.println("finalOilVolumeMap: " + finalOilVolumeMap);
+
+ for (Map<String, Object> item : oilCountList) {
+ String departId = (String) item.get("depart_id");
+ Integer finalOilCount = finalOilCountMap.get(departId);
+ if (finalOilCount != null) {
+ item.put("oilCount", finalOilCount);
+ System.out.println("鏇存柊 " + item.get("depart_name") + " 鐨勫姞娌规暟: " + finalOilCount);
+ }
+ Integer finalCarCount = finalCarCountMap.get(departId);
+ if (finalCarCount != null) {
+ item.put("carCount", finalCarCount);
+ System.out.println("鏇存柊 " + item.get("depart_name") + " 鐨勮溅娴侀噺: " + finalCarCount);
+ }
+ Integer finalStationCount = finalStationCountMap.get(departId);
+ if (finalStationCount != null) {
+ item.put("stationCount", finalStationCount);
+ System.out.println("鏇存柊 " + item.get("depart_name") + " 鐨勮繘绔欐暟: " + finalStationCount);
+ }
+ Integer finalOilVolume = finalOilVolumeMap.get(departId);
+ if (finalOilVolume != null) {
+ item.put("oilVolume", finalOilVolume);
+ System.out.println("鏇存柊 " + item.get("depart_name") + " 鐨勬补鍝侀攢閲�: " + finalOilVolume);
+ }
+ }
+
+ System.out.println("=== queryOrgOilCount 缁撴潫 ===");
+ return oilCountList;
+ }
+}
\ No newline at end of file
--
Gitblit v1.8.0