From ca43270a64f7c62112f3e9f36d5c97a6f149a9ce Mon Sep 17 00:00:00 2001
From: zhizhijie <zhizhijie@users.noreply.gitee.com>
Date: 星期三, 09 九月 2026 17:05:31 +0800
Subject: [PATCH] fix: 审核结果页选月一直转圈——isReminderRow误放computed改为methods(带参函数需在methods),含测试报告与工作日结
---
traffic-audit-server/src/main/java/com/trafficaudit/dataimport/service/DataImportService.java | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 51 insertions(+), 9 deletions(-)
diff --git a/traffic-audit-server/src/main/java/com/trafficaudit/dataimport/service/DataImportService.java b/traffic-audit-server/src/main/java/com/trafficaudit/dataimport/service/DataImportService.java
index 0f0c0f6..0fe1227 100644
--- a/traffic-audit-server/src/main/java/com/trafficaudit/dataimport/service/DataImportService.java
+++ b/traffic-audit-server/src/main/java/com/trafficaudit/dataimport/service/DataImportService.java
@@ -558,24 +558,30 @@
}
}
- /** 鍏矾鏃呭杩愭斂杞﹁締鏁帮紙鐙珛妯℃澘锛氫紒涓氫唬鐮�/浼佷笟鍚嶇О/杞﹁締鏁�/杞藉浣嶆暟锛� */
+ /** 鍏矾鏃呭杩愭斂杞﹁締鏁帮紙鍏煎涓ょ琛ㄥご锛氣憼 浼佷笟浠g爜/浼佷笟鍚嶇О/杞﹁締鏁�/杞藉浣嶆暟锛涒憽 杩愭斂搴撳鍑� OWNERNAME/鎬昏溅杈嗘暟/瀹綅鏁帮紝鏃犱紒涓氫唬鐮佸垪锛� */
public ImportResult importPassengerAuth(MultipartFile file, String period) throws Exception {
List<PassengerAuthVehicle> authList = new ArrayList<>();
try (Workbook wb = WorkbookFactory.create(file.getInputStream())) {
Sheet sheet = wb.getSheetAt(0);
- Map<String, Integer> colMap = buildHeaderMap(sheet.getRow(0));
- requireHeaderCols(sheet, "鏃呭杩愭斂杞﹁締鏁�", "浼佷笟鍚嶇О", "杞﹁締鏁�", "杞藉浣嶆暟");
+ Map<String, Integer> colMap = buildHeaderMapCompat(sheet.getRow(0));
+ Integer nameCol = firstColIdx(colMap, "浼佷笟鍚嶇О", "OWNERNAME");
+ Integer vehicleCol = firstColIdx(colMap, "杞﹁締鏁�", "鎬昏溅杈嗘暟");
+ Integer seatCol = firstColIdx(colMap, "杞藉浣嶆暟", "瀹綅鏁�");
+ Integer codeCol = firstColIdx(colMap, "浼佷笟浠g爜");
+ if (nameCol == null || vehicleCol == null || seatCol == null) {
+ throw new RuntimeException("鎵�閫夋暟鎹被鍨嬨�愭梾瀹㈣繍鏀胯溅杈嗘暟銆戜笌鏂囦欢鍐呭涓嶇锛氳〃澶撮渶鍚�愪紒涓氬悕绉�/杞﹁締鏁�/杞藉浣嶆暟銆戞垨銆怬WNERNAME/鎬昏溅杈嗘暟/瀹綅鏁般�戯紝璇风‘璁ゆ槸鍚﹂�夐敊浜嗘暟鎹被鍨嬫垨浣跨敤浜嗘棫妯℃澘");
+ }
for (int r = 1; r <= sheet.getLastRowNum(); r++) {
Row row = sheet.getRow(r);
if (row == null) continue;
- String name = gs(row, colMap, "浼佷笟鍚嶇О");
+ String name = getString(row, nameCol);
if (name == null || name.trim().isEmpty()) continue;
PassengerAuthVehicle auth = new PassengerAuthVehicle();
auth.setReportPeriod(period);
- auth.setEnterpriseCode(gs(row, colMap, "浼佷笟浠g爜"));
+ auth.setEnterpriseCode(codeCol == null ? null : getString(row, codeCol));
auth.setEnterpriseName(name.trim());
- auth.setVehicleCount(gi(row, colMap, "杞﹁締鏁�"));
- auth.setSeatCount(gi(row, colMap, "杞藉浣嶆暟"));
+ auth.setVehicleCount(getInt(row, vehicleCol));
+ auth.setSeatCount(getInt(row, seatCol));
authList.add(auth);
}
} catch (Exception e) {
@@ -924,6 +930,7 @@
List<ScaleSplitTransport> list = new ArrayList<>();
int failRows = 0;
try (Workbook wb = WorkbookFactory.create(file.getInputStream())) {
+ int targetMonth = Integer.parseInt(period.split("-")[1]); // 浠呭鍏ョ洰鏍囨湡鎵�鍦ㄦ湀鐨勯〉绛撅紙1-N鏈堟枃浠舵寜鐩爣鏈熷彇褰撴湀/绱锛�
boolean hasPeriodSheet = false;
for (int i = 0; i < wb.getNumberOfSheets(); i++) {
String sn = wb.getSheetAt(i).getSheetName();
@@ -936,8 +943,16 @@
Sheet sheet = wb.getSheetAt(i);
String sheetName = sheet.getSheetName();
String periodType = null;
- if (sheetName.contains("褰撴湀") || sheetName.contains("鏈堜唤")) periodType = "MONTH";
- else if (sheetName.contains("绱")) periodType = "CUMULATIVE";
+ java.util.regex.Matcher mSheetMonth = java.util.regex.Pattern.compile("(\\d{1,2})\\u6708(\\u4efd|\\u7d2f\\u8ba1)").matcher(sheetName);
+ if (mSheetMonth.find()) {
+ int sheetMonth = Integer.parseInt(mSheetMonth.group(1));
+ if (sheetMonth == targetMonth) {
+ periodType = "浠�".equals(mSheetMonth.group(2)) ? "MONTH" : "CUMULATIVE";
+ }
+ } else {
+ if (sheetName.contains("褰撴湀")) periodType = "MONTH";
+ else if (sheetName.contains("绱")) periodType = "CUMULATIVE";
+ }
if (periodType == null) continue;
// 鏍¢獙 sheet 甯冨眬锛氱2琛屽簲鍚�屽競宸�/瑙勪笂浼佷笟杩愯緭閲忋�嶏紝绗�3琛屽瓙琛ㄥご搴斿惈銆屽懆杞噺銆嶆垨銆岃揣杩愰噺銆嶏紙鎵╁睍甯冨眬锛�
@@ -1387,6 +1402,33 @@
return colMap;
}
+ /** 鍏煎琛ㄥご鏄犲皠锛氬幓寮曞彿/鍘荤┖鐧斤紱绾嫳鏂囪〃澶寸粺涓�澶у啓锛堝 'OWNERNAME' 鈫� OWNERNAME锛夛紝渚夸簬鏂版棫妯℃澘娣风敤 */
+ private Map<String, Integer> buildHeaderMapCompat(Row header) {
+ Map<String, Integer> colMap = new HashMap<>();
+ if (header == null) return colMap;
+ for (Cell cell : header) {
+ if (cell == null) continue;
+ String h = FORMATTER.formatCellValue(cell).replace("'", "").replace("\"", "").trim();
+ if (h.isEmpty()) continue;
+ boolean ascii = true;
+ for (int i = 0; i < h.length(); i++) {
+ if (h.charAt(i) > 127) { ascii = false; break; }
+ }
+ if (ascii) h = h.toUpperCase();
+ if (!colMap.containsKey(h)) colMap.put(h, cell.getColumnIndex());
+ }
+ return colMap;
+ }
+
+ /** 鎸夊埆鍚嶉『搴忓彇绗竴涓瓨鍦ㄧ殑鍒楀彿锛屽叏閮ㄧ己澶辫繑鍥� null */
+ private Integer firstColIdx(Map<String, Integer> colMap, String... aliases) {
+ for (String a : aliases) {
+ Integer idx = colMap.get(a);
+ if (idx != null) return idx;
+ }
+ return null;
+ }
+
private int colIdx(Map<String, Integer> colMap, String header) {
Integer idx = colMap.get(header);
return idx == null ? -1 : idx;
--
Gitblit v1.9.1