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/PaxCalc.java | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 112 insertions(+), 0 deletions(-)
diff --git a/traffic-audit-server/src/main/java/com/trafficaudit/reportexport/calc/PaxCalc.java b/traffic-audit-server/src/main/java/com/trafficaudit/reportexport/calc/PaxCalc.java
new file mode 100644
index 0000000..053cf1c
--- /dev/null
+++ b/traffic-audit-server/src/main/java/com/trafficaudit/reportexport/calc/PaxCalc.java
@@ -0,0 +1,112 @@
+package com.trafficaudit.reportexport.calc;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.trafficaudit.dataimport.entity.CityBusMonthly;
+import com.trafficaudit.dataimport.entity.CityTaxiMonthly;
+import com.trafficaudit.dataimport.mapper.CityBusMonthlyMapper;
+import com.trafficaudit.dataimport.mapper.CityTaxiMonthlyMapper;
+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;
+
+/**
+ * 鍩庡競瀹㈣繍鍙e緞璁$畻鏈嶅姟锛堟眹鎬诲ぇ琛ㄦ暟鎹┍鍔ㄦ敼閫� M1-鍩庡競瀹㈣繍-鍏氦/鍑虹/杞ㄩ亾杞浮锛�2026-09-08锛夈��
+ *
+ * 鍙e緞涓庢棦鏈夊琛ㄥ鍑� loadCityBusByMonth / loadCityTaxiByMonth / loadCityRailFerryByMonth 瀹屽叏涓�鑷�
+ * 锛堝喅绛栧熀绾� A2/B4/B5/C7锛�2026-07 涓� _澶囦唤鈥娓呯悊鍓峗20260904.xlsx 鍏氦/鍑虹/杞ㄩ亾杞浮鍙拌处椤� O 鍒楀洖褰� 0 宸紓锛夛細
+ * - 鍏氦/鍑虹锛氭寜鏈� 鈫� 甯傚窞 鈫� [瀹㈣繍閲�, 鏃呭鍛ㄨ浆閲�, 鍩庡競鍐呭杩愰噺, 鍩庡競鍐呮梾瀹㈠懆杞噺]锛屾寜 DB city 瀛楁鍒嗙粍锛�"鍏ㄧ渷"=鍏ㄩ儴甯傚窞鍚堣锛�
+ * - 杞ㄩ亾/杞浮锛氬悓涓� city_bus_monthly 琛ㄧ殑 rail / ferry 瀛楁锛堣建閬�=姝︽眽/榛勭煶锛岃疆娓�=姝︽眽锛涘叏鐪�=鍚堣锛夈��
+ *
+ * 杈撳嚭涓衡�滄湀 鈫� 甯傚窞 鈫� double[4]鈥濓紱绱鐢卞啓鍥炲眰瀵� 1..m 鏈堟眰鍜屻�傚悓姣旀寜 Q1 浠ユ瘝鐗堢紦瀛� 2025 鍙傜収缁勪负鍩哄噯锛屼笉鍦ㄦ湰鏈嶅姟璁$畻銆�
+ */
+@Service
+public class PaxCalc {
+
+ public static final String PROVINCE = "鍏ㄧ渷";
+
+ @Resource
+ private CityBusMonthlyMapper cityBusMapper;
+ @Resource
+ private CityTaxiMonthlyMapper cityTaxiMapper;
+
+ /** 鍏氦锛氭湀 鈫� 甯傚窞 鈫� [瀹㈣繍閲�,鍛ㄨ浆閲�,鍩庡競鍐呭杩愰噺,鍩庡競鍐呭懆杞噺] */
+ public Map<Integer, Map<String, double[]>> busMonthly(String yearPrefix, int limit) {
+ Map<Integer, Map<String, double[]>> result = new LinkedHashMap<>();
+ List<CityBusMonthly> rows = cityBusMapper.selectList(
+ new LambdaQueryWrapper<CityBusMonthly>().likeRight(CityBusMonthly::getReportPeriod, yearPrefix));
+ for (CityBusMonthly r : rows) {
+ int m = monthOf(r.getReportPeriod());
+ if (m < 1 || m > limit) continue;
+ String city = r.getCity() == null ? "鏈煡" : r.getCity();
+ accumulate(result, city, m,
+ nz(r.getPassengerVolume()), nz(r.getTurnover()),
+ nz(r.getPassengerCity()), nz(r.getTurnoverCity()));
+ }
+ return result;
+ }
+
+ /** 宸℃父鍑虹锛氭湀 鈫� 甯傚窞 鈫� [瀹㈣繍閲�,鍛ㄨ浆閲�,鍩庡競鍐呭杩愰噺,鍩庡競鍐呭懆杞噺] */
+ public Map<Integer, Map<String, double[]>> taxiMonthly(String yearPrefix, int limit) {
+ Map<Integer, Map<String, double[]>> result = new LinkedHashMap<>();
+ List<CityTaxiMonthly> rows = cityTaxiMapper.selectList(
+ new LambdaQueryWrapper<CityTaxiMonthly>().likeRight(CityTaxiMonthly::getReportPeriod, yearPrefix));
+ for (CityTaxiMonthly r : rows) {
+ int m = monthOf(r.getReportPeriod());
+ if (m < 1 || m > limit) continue;
+ String city = r.getCity() == null ? "鏈煡" : r.getCity();
+ accumulate(result, city, m,
+ nz(r.getPassengerVolume()), nz(r.getTurnover()),
+ nz(r.getPassengerCity()), nz(r.getTurnoverCity()));
+ }
+ return result;
+ }
+
+ /** 杞ㄩ亾/杞浮锛氭湀 鈫� 甯傚窞 鈫� [杞ㄩ亾瀹㈣繍閲�,杞ㄩ亾鍛ㄨ浆閲�,杞浮瀹㈣繍閲�,杞浮鍛ㄨ浆閲廬 */
+ public Map<Integer, Map<String, double[]>> railFerryMonthly(String yearPrefix, int limit) {
+ Map<Integer, Map<String, double[]>> result = new LinkedHashMap<>();
+ List<CityBusMonthly> rows = cityBusMapper.selectList(
+ new LambdaQueryWrapper<CityBusMonthly>().likeRight(CityBusMonthly::getReportPeriod, yearPrefix));
+ for (CityBusMonthly r : rows) {
+ int m = monthOf(r.getReportPeriod());
+ if (m < 1 || m > limit) continue;
+ String city = r.getCity() == null ? "鏈煡" : r.getCity();
+ accumulate(result, city, m,
+ nz(r.getRailPassengerVolume()), nz(r.getRailTurnover()),
+ nz(r.getFerryPassengerVolume()), nz(r.getFerryTurnover()));
+ }
+ return result;
+ }
+
+ private void accumulate(Map<Integer, Map<String, double[]>> result, String city, int m,
+ double v0, double v1, double v2, double v3) {
+ Map<String, double[]> cityMap = result.computeIfAbsent(m, k -> new HashMap<>());
+ double[] arr = cityMap.computeIfAbsent(city, k -> new double[4]);
+ arr[0] += v0;
+ arr[1] += v1;
+ arr[2] += v2;
+ arr[3] += v3;
+ double[] prov = cityMap.computeIfAbsent(PROVINCE, k -> new double[4]);
+ prov[0] += v0;
+ prov[1] += v1;
+ prov[2] += v2;
+ prov[3] += v3;
+ }
+
+ 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