From 603853a1290e7d71297c9ce5b64181a090adab87 Mon Sep 17 00:00:00 2001
From: zhizhijie <zhizhijie@users.noreply.gitee.com>
Date: 星期二, 08 九月 2026 17:44:50 +0800
Subject: [PATCH] docs: 09-08 工作日结补记下班前状态(最新代码已重启就绪,明日待办8月填值/9月整链/临时文件清理)

---
 traffic-audit-server/src/main/java/com/trafficaudit/reportexport/calc/MidCalc.java |  110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 110 insertions(+), 0 deletions(-)

diff --git a/traffic-audit-server/src/main/java/com/trafficaudit/reportexport/calc/MidCalc.java b/traffic-audit-server/src/main/java/com/trafficaudit/reportexport/calc/MidCalc.java
new file mode 100644
index 0000000..66a477e
--- /dev/null
+++ b/traffic-audit-server/src/main/java/com/trafficaudit/reportexport/calc/MidCalc.java
@@ -0,0 +1,110 @@
+package com.trafficaudit.reportexport.calc;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.trafficaudit.common.util.RegionUtil;
+import com.trafficaudit.dataimport.entity.PassengerEnterpriseMonthly;
+import com.trafficaudit.dataimport.entity.PassengerIndividualMonthly;
+import com.trafficaudit.dataimport.mapper.PassengerEnterpriseMonthlyMapper;
+import com.trafficaudit.dataimport.mapper.PassengerIndividualMonthlyMapper;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 鍏矾鐝嚎锛堝惈涓綋锛夊彛寰勮绠楁湇鍔★紙姹囨�诲ぇ琛ㄦ暟鎹┍鍔ㄦ敼閫� M1-鐝嚎鍖呰溅锛�2026-09-08锛夈��
+ *
+ * 鍙e緞锛�2026-07 涓� _澶囦唤_2026骞�7鏈堥亾璺繍杈撻噺姹囨�昏〃_娓呯悊鍓峗20260904.xlsx 鐝嚎鍖呰溅椤�
+ * 浼佷笟/涓綋琛� 1-7 鏈堥�愭牸鍥炲綊 0 宸紓锛�350 鏍煎叏涓級锛�
+ * 1. 鐝嚎鍖呰溅椤碘�滃杩愰噺/鏃呭鍛ㄨ浆閲忊�濊 = h2031_enterprise_monthly 鎸� 17 甯傚窞姹囨��
+ *    锛坧assenger_total / turnover_total锛屼汉 / 浜哄叕閲岋級闄や互 10000锛屽啀骞跺叆涓綋瀹㈣繍
+ *    锛坧assenger_individual_monthly 鍚屽彛寰勶級锛涒�滃叾涓釜浣撳杩愰噺/鍛ㄨ浆閲忊�濊 = 涓綋鏁伴櫎浠� 10000
+ *    锛堝綋鍓嶄粎榛勭煶/瑗勯槼/鑽嗛棬/瀛濇劅/榛勫唸/闅忓窞鏈夋暟锛夈��
+ * 2. 鍏ㄧ渷琛� = 17 甯傚窞涔嬪拰锛屼笌姣嶇増鈥滃叏鐪佽=鍩庡競琛屾眰鍜屸�濆叕寮忎竴鑷达紱涓彛寰勫垎鏋愰〉鈥滃叕璺彮绾库��
+ *    = 鏈彛寰勫叏鐪佸悎璁★紙褰撴湀 1631.2013銆佺疮璁� 11204.5406 涓庢瘝鐗� 0 宸紓锛夈��
+ * 3. 鍚屾瘮浠ユ瘝鐗堢紦瀛� 2025 鍙傜収缁勪负鍩哄噯锛圦1锛夛紝涓嶅湪鏈湇鍔¤绠椼��
+ *
+ * 杈撳嚭锛氭湀 鈫� 甯傚窞锛堝惈 PROVINCE=婀栧寳鐪侊級 鈫� double[4] =
+ * [瀹㈣繍閲�(鍚釜浣�), 鍛ㄨ浆閲�(鍚釜浣�), 涓綋瀹㈣繍閲�, 涓綋鍛ㄨ浆閲廬锛�
+ * 鍗曚綅鍧囦负姣嶇増灞曠ず鍙e緞锛堜竾浜� / 涓囦汉鍏噷锛夛紱浼佷笟鍗曠嫭閲� = arr[0]-arr[2] 涓� arr[1]-arr[3]銆�
+ */
+@Service
+public class MidCalc {
+
+    public static final String PROVINCE = "婀栧寳鐪�";
+
+    @Resource
+    private PassengerEnterpriseMonthlyMapper passengerMapper;
+    @Resource
+    private PassengerIndividualMonthlyMapper individualMapper;
+
+    /** 鐝嚎鍖呰溅椤垫暟鍊肩煩闃碉細鏈� 鈫� 甯傚窞/鍏ㄧ渷 鈫� [瀹㈣繍閲�,鍛ㄨ浆閲�,涓綋瀹㈣繍閲�,涓綋鍛ㄨ浆閲廬 */
+    public Map<Integer, Map<String, double[]>> banxianMonthly(String yearPrefix, int limit) {
+        Map<Integer, Map<String, double[]>> result = new LinkedHashMap<>();
+        List<PassengerEnterpriseMonthly> entRows = passengerMapper.selectList(
+            new LambdaQueryWrapper<PassengerEnterpriseMonthly>().likeRight(
+                PassengerEnterpriseMonthly::getReportPeriod, yearPrefix));
+        for (PassengerEnterpriseMonthly r : entRows) {
+            int m = monthOf(r.getReportPeriod());
+            if (m < 1 || m > limit) continue;
+            String city = RegionUtil.cityByCode(r.getRegionCode());
+            if (city == null) continue;
+            double pax = nz(r.getPassengerTotal());
+            double turn = nz(r.getTurnoverTotal());
+            if (pax == 0.0 && turn == 0.0) {
+                pax = nz(r.getPassengerClass1()) + nz(r.getPassengerClass2())
+                    + nz(r.getPassengerClass3()) + nz(r.getPassengerClass4())
+                    + nz(r.getPassengerCharter());
+                turn = nz(r.getTurnoverClass1()) + nz(r.getTurnoverClass2())
+                    + nz(r.getTurnoverClass3()) + nz(r.getTurnoverClass4())
+                    + nz(r.getTurnoverCharter());
+            }
+            accumulate(result, m, city, pax / 10000.0, turn / 10000.0, 0.0, 0.0);
+        }
+        List<PassengerIndividualMonthly> indRows = individualMapper.selectList(
+            new LambdaQueryWrapper<PassengerIndividualMonthly>().likeRight(
+                PassengerIndividualMonthly::getReportPeriod, yearPrefix));
+        for (PassengerIndividualMonthly r : indRows) {
+            int m = monthOf(r.getReportPeriod());
+            if (m < 1 || m > limit) continue;
+            String city = RegionUtil.cityByCode(r.getRegionCode());
+            if (city == null) continue;
+            double pax = nz(r.getPassengerCount()) / 10000.0;
+            double turn = nz(r.getTurnover()) / 10000.0;
+            accumulate(result, m, city, pax, turn, pax, turn);
+        }
+        return result;
+    }
+
+    private void accumulate(Map<Integer, Map<String, double[]>> result, int m, String city,
+                            double paxAll, double turnAll, double paxIndi, double turnIndi) {
+        Map<String, double[]> monthMap = result.computeIfAbsent(m, k -> new HashMap<>());
+        add(monthMap.computeIfAbsent(city, k -> new double[4]), paxAll, turnAll, paxIndi, turnIndi);
+        add(monthMap.computeIfAbsent(PROVINCE, k -> new double[4]), paxAll, turnAll, paxIndi, turnIndi);
+    }
+
+    private void add(double[] arr, double paxAll, double turnAll, double paxIndi, double turnIndi) {
+        arr[0] += paxAll;
+        arr[1] += turnAll;
+        arr[2] += paxIndi;
+        arr[3] += turnIndi;
+    }
+
+    private int monthOf(String reportPeriod) {
+        if (reportPeriod == null) return 0;
+        String[] parts = reportPeriod.split("-");
+        if (parts.length < 2) return 0;
+        try {
+            return Integer.parseInt(parts[1]);
+        } catch (NumberFormatException e) {
+            return 0;
+        }
+    }
+
+    private double nz(Double v) {
+        return v == null ? 0.0 : v;
+    }
+}

--
Gitblit v1.9.1