From ade4387f72c876f779b0956295922003464434f0 Mon Sep 17 00:00:00 2001
From: zhizhijie <zhizhijie@users.noreply.gitee.com>
Date: 星期六, 19 九月 2026 23:26:59 +0800
Subject: [PATCH] fix(汇总表): 中口径排名周转量口径统一为「总量-城市内」差额法

---
 traffic-audit-server/src/main/java/com/trafficaudit/reportexport/calc/WycSplitCalc.java |   30 +++++++++++++++++++++++++-----
 1 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/traffic-audit-server/src/main/java/com/trafficaudit/reportexport/calc/WycSplitCalc.java b/traffic-audit-server/src/main/java/com/trafficaudit/reportexport/calc/WycSplitCalc.java
index 947eff3..903f103 100644
--- a/traffic-audit-server/src/main/java/com/trafficaudit/reportexport/calc/WycSplitCalc.java
+++ b/traffic-audit-server/src/main/java/com/trafficaudit/reportexport/calc/WycSplitCalc.java
@@ -4,8 +4,10 @@
 import com.trafficaudit.common.util.RegionUtil;
 import com.trafficaudit.dataimport.entity.CityTaxiMonthly;
 import com.trafficaudit.dataimport.entity.WycOrderMonthly;
+import com.trafficaudit.dataimport.entity.WycTotalMonthly;
 import com.trafficaudit.dataimport.mapper.CityTaxiMonthlyMapper;
 import com.trafficaudit.dataimport.mapper.WycOrderMonthlyMapper;
+import com.trafficaudit.dataimport.mapper.WycTotalMonthlyMapper;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.DataFormatter;
@@ -80,6 +82,8 @@
     private CityTaxiMonthlyMapper cityTaxiMapper;
     @Resource
     private WycOrderMonthlyMapper wycOrderMapper;
+    @Resource
+    private WycTotalMonthlyMapper wycTotalMapper;
     @Value("${city-passenger.template-dir:docs/鍩庡競瀹㈣繍}")
     private String templateDir;
 
@@ -254,14 +258,30 @@
         if (sum <= 0) return null;
         double orderSum = sum;
         if (row.getOrderSum() != null && row.getOrderSum() > 0) orderSum = row.getOrderSum();
+        double pinK = row.getPinK() == null ? 0.0 : row.getPinK();
+        double pinCK = row.getPinCK() == null ? 0.0 : row.getPinCK();
+        double pinZ = row.getPinZ() == null ? 0.0 : row.getPinZ();
+        double pinCZ = row.getPinCZ() == null ? 0.0 : row.getPinCZ();
+        boolean pinFix = false;
+        // pin 鍏滃簳锛氳鍗曡〃 pin 鍒椾负绌�/涓� 0 鏃跺洖钀� wyc_total_monthly锛坧in 涓撹〃锛�
+        if (pinK <= 0 || pinCK <= 0 || pinZ <= 0 || pinCZ <= 0) {
+            WycTotalMonthly tot = wycTotalMapper.selectOne(new LambdaQueryWrapper<WycTotalMonthly>()
+                    .eq(WycTotalMonthly::getReportPeriod, period).last("LIMIT 1"));
+            if (tot != null) {
+                if (pinK <= 0 && tot.getPinK() != null && tot.getPinK() > 0) { pinK = tot.getPinK(); pinFix = true; }
+                if (pinCK <= 0 && tot.getPinCK() != null && tot.getPinCK() > 0) { pinCK = tot.getPinCK(); pinFix = true; }
+                if (pinZ <= 0 && tot.getPinZ() != null && tot.getPinZ() > 0) { pinZ = tot.getPinZ(); pinFix = true; }
+                if (pinCZ <= 0 && tot.getPinCZ() != null && tot.getPinCZ() > 0) { pinCZ = tot.getPinCZ(); pinFix = true; }
+            }
+        }
         Map<String, Object> map = new LinkedHashMap<>();
-        map.put("pinK", row.getPinK() == null ? 0.0 : row.getPinK());
-        map.put("pinCK", row.getPinCK() == null ? 0.0 : row.getPinCK());
-        map.put("pinZ", row.getPinZ() == null ? 0.0 : row.getPinZ());
-        map.put("pinCZ", row.getPinCZ() == null ? 0.0 : row.getPinCZ());
+        map.put("pinK", pinK);
+        map.put("pinCK", pinCK);
+        map.put("pinZ", pinZ);
+        map.put("pinCZ", pinCZ);
         map.put("orders", orders);
         map.put("orderSum", orderSum);
-        map.put("source", "db");
+        map.put("source", pinFix ? "db+wyc_total" : "db");
         return map;
     }
     private File findInput() throws Exception {

--
Gitblit v1.9.1