From d35aed30c9b5920065774eeaaeefafcc05c49761 Mon Sep 17 00:00:00 2001
From: xyc <jc_xiong@hotmail.com>
Date: 星期二, 01 九月 2026 17:32:14 +0800
Subject: [PATCH] docs: 关机快照补充——发布后又拉取到同事 2 个新提交(fbc1c15/91d7eee),已发布版本落后 HEAD

---
 traffic-audit-server/src/main/java/com/trafficaudit/dataimport/controller/DataImportController.java |  315 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 315 insertions(+), 0 deletions(-)

diff --git a/traffic-audit-server/src/main/java/com/trafficaudit/dataimport/controller/DataImportController.java b/traffic-audit-server/src/main/java/com/trafficaudit/dataimport/controller/DataImportController.java
index abd2716..18e657b 100644
--- a/traffic-audit-server/src/main/java/com/trafficaudit/dataimport/controller/DataImportController.java
+++ b/traffic-audit-server/src/main/java/com/trafficaudit/dataimport/controller/DataImportController.java
@@ -2,8 +2,12 @@
 
 import com.trafficaudit.common.Result;
 import com.trafficaudit.dataimport.dto.ImportResult;
+import com.trafficaudit.dataimport.entity.ImportBatch;
+import com.trafficaudit.dataimport.mapper.ImportBatchMapper;
 import com.trafficaudit.dataimport.service.DataImportService;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -11,6 +15,9 @@
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
 
 @Slf4j
 @RestController
@@ -19,6 +26,8 @@
 
     @Resource
     private DataImportService importService;
+    @Resource
+    private ImportBatchMapper importBatchMapper;
 
     /** H203-2琛� 閬撹矾璐х墿杩愯緭鏈堝害鐢熶骇鎯呭喌 */
     @PostMapping("/h2032")
@@ -50,6 +59,253 @@
     }
 
 
+
+    /** H204 閬撹矾璐ц繍杞﹁締鑳芥簮娑堣�楁儏鍐碉紙瀛e害鑳借�楁槑缁� + 杩愭斂杞﹁締淇℃伅锛� */
+    @PostMapping("/energyMonthly")
+    public Result<String> importEnergyMonthly(@RequestParam("file") MultipartFile file,
+                                              @RequestParam("period") String period) {
+        try {
+            ImportResult result = importService.importEnergyMonthly(file, period);
+            String msg = "H204鑳借�楀鎶ュ鍏ュ畬鎴愶細鎴愬姛 " + result.getSuccess() + " 鏉★紝澶辫触 " + result.getFail() + " 鏉★紙鍚悓鎶ヨ〃鏈熻繍鏀胯溅杈嗕俊鎭級";
+            if (result.getFail() > 0) {
+                java.util.List<String> details = result.getFailDetails();
+                int shown = Math.min(details.size(), 100);
+                for (int i = 0; i < shown; i++) {
+                    msg += "\n" + details.get(i);
+                }
+                if (details.size() > shown) {
+                    msg += "\n鈥︹�﹀叡 " + details.size() + " 琛屽け璐�";
+                }
+            }
+            return Result.ok(msg);
+        } catch (Exception e) {
+            log.error("energyMonthly import error", e);
+            return Result.error("瀵煎叆澶辫触: " + e.getMessage());
+        }
+    }
+
+    /** 鑳借�楄溅杈嗚繍鏀夸俊鎭紙鐙珛妯℃澘锛屼篃鍙殢 H204 瀛f姤绗簩涓� sheet 涓�骞跺鍏ワ級 */
+    @PostMapping("/energyAuth")
+    public Result<String> importEnergyAuth(@RequestParam("file") MultipartFile file,
+                                           @RequestParam("period") String period) {
+        try {
+            ImportResult result = importService.importEnergyAuth(file, period);
+            String msg = "鑳借�楄溅杈嗚繍鏀夸俊鎭鍏ュ畬鎴愶細鎴愬姛 " + result.getSuccess() + " 鏉★紝澶辫触 " + result.getFail() + " 鏉�";
+            if (result.getFail() > 0) {
+                java.util.List<String> details = result.getFailDetails();
+                int shown = Math.min(details.size(), 100);
+                for (int i = 0; i < shown; i++) {
+                    msg += "\n" + details.get(i);
+                }
+                if (details.size() > shown) {
+                    msg += "\n鈥︹�﹀叡 " + details.size() + " 琛屽け璐�";
+                }
+            }
+            return Result.ok(msg);
+        } catch (Exception e) {
+            log.error("energyAuth import error", e);
+            return Result.error("瀵煎叆澶辫触: " + e.getMessage());
+        }
+    }
+
+    /** H203-1琛� 鍏矾鏃呭杩愯緭鏈堝害鐢熶骇鎯呭喌锛堝惈杩愭斂杞﹁締鏁皊heet锛� */
+    @PostMapping("/passengerMonthly")
+    public Result<String> importPassengerMonthly(@RequestParam("file") MultipartFile file,
+                                                 @RequestParam("period") String period) {
+        try {
+            ImportResult result = importService.importPassengerMonthly(file, period);
+            String msg = "H2031鏃呭鏈堟姤瀵煎叆瀹屾垚锛氭垚鍔� " + result.getSuccess() + " 鏉★紝澶辫触 " + result.getFail() + " 鏉★紙鍚悓鎶ヨ〃鏈熻繍鏀胯溅杈嗘暟鎹級";
+            if (result.getFail() > 0) {
+                java.util.List<String> details = result.getFailDetails();
+                int shown = Math.min(details.size(), 100);
+                for (int i = 0; i < shown; i++) {
+                    msg += "\n" + details.get(i);
+                }
+                if (details.size() > shown) {
+                    msg += "\n鈥︹�﹀叡 " + details.size() + " 琛屽け璐�";
+                }
+            }
+            return Result.ok(msg);
+        } catch (Exception e) {
+            log.error("passengerMonthly import error", e);
+            return Result.error("瀵煎叆澶辫触: " + e.getMessage());
+        }
+    }
+
+
+    /** 鍏矾鏃呭涓綋瀹㈣繍閲�/鍛ㄨ浆閲忥紙浼佷笟绾夸笅姹囨姤锛屽鍏ュ悗渚涘垎甯傚窞琛ㄤ釜浣撹濉厖锛� */
+    @PostMapping("/passengerIndividual")
+    public Result<String> importPassengerIndividual(@RequestParam("file") MultipartFile file,
+                                                    @RequestParam("period") String period) {
+        try {
+            ImportResult result = importService.importPassengerIndividual(file, period);
+            String msg = "涓綋瀹㈣繍閲忓鍏ュ畬鎴愶細鎴愬姛 " + result.getSuccess() + " 鏉★紝澶辫触 " + result.getFail() + " 鏉�";
+            if (result.getFail() > 0) {
+                java.util.List<String> details = result.getFailDetails();
+                int shown = Math.min(details.size(), 100);
+                for (int i = 0; i < shown; i++) {
+                    msg += "\n" + details.get(i);
+                }
+                if (details.size() > shown) {
+                    msg += "\n鈥︹�﹀叡 " + details.size() + " 琛屽け璐�";
+                }
+            }
+            return Result.ok(msg);
+        } catch (Exception e) {
+            log.error("passengerIndividual import error", e);
+            return Result.error("瀵煎叆澶辫触: " + e.getMessage());
+        }
+    }
+
+    /** 鍏矾鏃呭杩愭斂杞﹁締鏁帮紙鐙珛妯℃澘锛屼篃鍙殢 H203-1 鏈堟姤绗簩涓� sheet 涓�骞跺鍏ワ級 */
+    @PostMapping("/passengerAuth")
+    public Result<String> importPassengerAuth(@RequestParam("file") MultipartFile file,
+                                              @RequestParam("period") String period) {
+        try {
+            ImportResult result = importService.importPassengerAuth(file, period);
+            String msg = "鏃呭杩愭斂杞﹁締鏁板鍏ュ畬鎴愶細鎴愬姛 " + result.getSuccess() + " 鏉★紝澶辫触 " + result.getFail() + " 鏉�";
+            if (result.getFail() > 0) {
+                java.util.List<String> details = result.getFailDetails();
+                int shown = Math.min(details.size(), 100);
+                for (int i = 0; i < shown; i++) {
+                    msg += "\n" + details.get(i);
+                }
+                if (details.size() > shown) {
+                    msg += "\n鈥︹�﹀叡 " + details.size() + " 琛屽け璐�";
+                }
+            }
+            return Result.ok(msg);
+        } catch (Exception e) {
+            log.error("passengerAuth import error", e);
+            return Result.error("瀵煎叆澶辫触: " + e.getMessage());
+        }
+    }
+
+    /** 鍩庡競鍏氦鏈堟姤锛堝煄甯傚叕鍏变氦閫氭湀搴﹁繍钀ユ儏鍐碉紝浼佷笟绾ф槑缁嗭級 */
+    @PostMapping("/cityBus")
+    public Result<String> importCityBus(@RequestParam("file") MultipartFile file,
+                                        @RequestParam("period") String period) {
+        try {
+            ImportResult result = importService.importCityBus(file, period);
+            String msg = "鍩庡競鍏氦鏈堟姤瀵煎叆瀹屾垚锛氭垚鍔� " + result.getSuccess() + " 鏉★紝澶辫触 " + result.getFail() + " 鏉�";
+            if (result.getFail() > 0) {
+                java.util.List<String> details = result.getFailDetails();
+                int shown = Math.min(details.size(), 100);
+                for (int i = 0; i < shown; i++) {
+                    msg += "\n" + details.get(i);
+                }
+                if (details.size() > shown) {
+                    msg += "\n鈥︹�﹀叡 " + details.size() + " 琛屽け璐�";
+                }
+            }
+            return Result.ok(msg);
+        } catch (Exception e) {
+            log.error("cityBus import error", e);
+            return Result.error("瀵煎叆澶辫触: " + e.getMessage());
+        }
+    }
+
+    /** 宸℃父鍑虹姹借溅杩愯惀鏈嶅姟鎯呭喌鏈堟姤锛堝競宸炵骇锛� */
+    @PostMapping("/cityTaxi")
+    public Result<String> importCityTaxi(@RequestParam("file") MultipartFile file,
+                                         @RequestParam("period") String period) {
+        try {
+            ImportResult result = importService.importCityTaxi(file, period);
+            String msg = "宸℃父鍑虹鏈堟姤瀵煎叆瀹屾垚锛氭垚鍔� " + result.getSuccess() + " 鏉★紝澶辫触 " + result.getFail() + " 鏉�";
+            if (result.getFail() > 0) {
+                java.util.List<String> details = result.getFailDetails();
+                int shown = Math.min(details.size(), 100);
+                for (int i = 0; i < shown; i++) {
+                    msg += "\n" + details.get(i);
+                }
+                if (details.size() > shown) {
+                    msg += "\n鈥︹�﹀叡 " + details.size() + " 琛屽け璐�";
+                }
+            }
+            return Result.ok(msg);
+        } catch (Exception e) {
+            log.error("cityTaxi import error", e);
+            return Result.error("瀵煎叆澶辫触: " + e.getMessage());
+        }
+    }
+
+    /** 鍑虹杞﹁繍鏀胯溅杈嗕俊鎭紙杞﹁締绾ф槑缁嗭紝鐢ㄤ簬杩愯惀杞︽暟瀵规瘮锛� */
+    @PostMapping("/cityTaxiAuth")
+    public Result<String> importCityTaxiAuth(@RequestParam("file") MultipartFile file,
+                                             @RequestParam("period") String period) {
+        try {
+            int count = importService.importCityTaxiAuth(file, period);
+            return Result.ok("鍑虹杞﹁繍鏀胯溅杈嗗鍏ユ垚鍔�, 鍏� " + count + " 鏉¤褰�");
+        } catch (Exception e) {
+            log.error("cityTaxiAuth import error", e);
+            return Result.error("瀵煎叆澶辫触: " + e.getMessage());
+        }
+    }
+
+    /** 鎶曡祫鏈堟姤锛堝叏鐪佹眹鎬诲ぇ琛級锛歝ategory=瀹㈣繍绔欏満/鐗╂祦鍥尯 */
+    @PostMapping("/investment")
+    public Result<String> importInvestment(@RequestParam("file") MultipartFile file,
+                                           @RequestParam("period") String period,
+                                           @RequestParam(value = "category", defaultValue = "瀹㈣繍绔欏満") String category) {
+        try {
+            ImportResult result = importService.importInvestment(file, period, category);
+            String msg = "鎶曡祫鏈堟姤瀵煎叆瀹屾垚锛�" + category + "锛夛細鎴愬姛 " + result.getSuccess() + " 鏉★紝澶辫触 " + result.getFail() + " 鏉�";
+            if (result.getFail() > 0) {
+                java.util.List<String> details = result.getFailDetails();
+                int shown = Math.min(details.size(), 100);
+                for (int i = 0; i < shown; i++) {
+                    msg += "\n" + details.get(i);
+                }
+                if (details.size() > shown) {
+                    msg += "\n鈥︹�﹀叡 " + details.size() + " 琛屽け璐�";
+                }
+            }
+            return Result.ok(msg);
+        } catch (Exception e) {
+            log.error("investment import error", e);
+            return Result.error("瀵煎叆澶辫触: " + e.getMessage());
+        }
+    }
+
+    /** 澶氭枃浠舵壒閲忓鍏ワ細鍓嶇涓�娆¢�夋嫨澶氫釜 Excel 涓婁紶锛坱ype 涓烘暟鎹被鍨嬶紝鎶曡祫绫诲瀷鎸夊競宸炲崟琛ㄨВ鏋愶級 */
+    @PostMapping("/batch")
+    public Result<Object> importBatch(@RequestParam("type") String type,
+                                      @RequestParam("period") String period,
+                                      @RequestParam("files") List<MultipartFile> files) {
+        try {
+            Map<String, Object> result = importService.importBatchFiles(type, period, files);
+            return Result.ok(result);
+        } catch (Exception e) {
+            log.error("batch import error", e);
+            return Result.error("鎵归噺瀵煎叆澶辫触: " + e.getMessage());
+        }
+    }
+
+    /** 鎶曡祫甯傚窞鍗曡〃鎵归噺瀵煎叆锛圡2锛夛細鎵弿 docs/鎶曡祫/杈撳叆/{绫诲埆}/{X鏈坿 鐩綍鍏ㄩ儴甯傚窞鎶ヨ〃锛宑ategory=瀹㈣繍绔欏満/鐗╂祦鍥尯 */
+    @PostMapping("/investCityBatch")
+    public Result<Object> importInvestCityBatch(@RequestParam("period") String period,
+                                                @RequestParam(value = "category", defaultValue = "瀹㈣繍绔欏満") String category) {
+        try {
+            Map<String, Object> result = importService.importInvestCityDir(period, category);
+            return Result.ok(result);
+        } catch (Exception e) {
+            log.error("investCityBatch import error", e);
+            return Result.error("瀵煎叆澶辫触: " + e.getMessage());
+        }
+    }
+
+    /** 鎶曡祫绯荤粺瀵煎嚭锛堝鏍告瘮瀵瑰熀鍑嗭級 */
+    @PostMapping("/investmentSystem")
+    public Result<String> importInvestmentSystem(@RequestParam("file") MultipartFile file,
+                                                 @RequestParam("period") String period) {
+        try {
+            int count = importService.importInvestmentSystem(file, period);
+            return Result.ok("鎶曡祫绯荤粺瀵煎嚭瀵煎叆鎴愬姛, 鍏� " + count + " 鏉¤褰�");
+        } catch (Exception e) {
+            log.error("investmentSystem import error", e);
+            return Result.error("瀵煎叆澶辫触: " + e.getMessage());
+        }
+    }
     /** 杩愭斂杞﹁締 */
     @PostMapping("/transportAuth")
     public Result<String> importTransportAuth(@RequestParam("file") MultipartFile file,
@@ -101,4 +357,63 @@
             return Result.error("瀵煎叆澶辫触: " + e.getMessage());
         }
     }
+    /** 鐩綍娴忚鍣細path 涓虹┖杩斿洖椤圭洰 docs 鏁版嵁鐩綍锛岃繑鍥炲瓙鐩綍涓庡綋鍓嶇洰褰� Excel 鏂囦欢 */
+    @GetMapping("/dirs")
+    public Result<Map<String, Object>> dirs(@RequestParam(value = "path", required = false) String path) {
+        try {
+            Map<String, Object> result = importService.listDirs(path);
+            return Result.ok(result);
+        } catch (Exception e) {
+            log.error("list dirs error", e);
+            return Result.error("鐩綍娴忚澶辫触: " + e.getMessage());
+        }
+    }
+
+    /** 鎸夎矾寰勫鍏ュ崟涓� Excel 鏂囦欢锛堝墠绔�愭枃浠跺鍏ユ樉绀鸿繘搴︼級锛涙姤琛ㄦ湡浼樺厛浠庢枃浠跺悕璇嗗埆 */
+    @PostMapping("/fromDirFile")
+    public Result<Map<String, Object>> importFromDirFile(@RequestParam("type") String type,
+                                                         @RequestParam(value = "period", required = false) String period,
+                                                         @RequestParam(value = "skipImported", defaultValue = "true") boolean skipImported,
+                                                         @RequestParam("path") String path) {
+        try {
+            Map<String, Object> result = importService.importDirFileByPath(type, period, skipImported, path);
+            return Result.ok(result);
+        } catch (Exception e) {
+            log.error("fromDirFile import error", e);
+            return Result.error("瀵煎叆澶辫触: " + e.getMessage());
+        }
+    }
+
+    /** 浠庢湇鍔$鏂囦欢澶规壒閲忓鍏ワ細鎵弿 dir 涓嬪叏閮� .xlsx/.xls锛屾寜 type 閫愪釜瀵煎叆锛涙姤琛ㄦ湡浼樺厛浠庢枃浠跺悕璇嗗埆 */
+    @PostMapping("/fromDir")
+    public Result<Object> importFromDir(@RequestParam("type") String type,
+                                        @RequestParam(value = "period", required = false) String period,
+                                        @RequestParam(value = "skipImported", defaultValue = "true") boolean skipImported,
+                                        @RequestParam("dir") String dir) {
+        try {
+            Map<String, Object> result = importService.importFromDir(type, period, skipImported, dir);
+            return Result.ok(result);
+        } catch (Exception e) {
+            log.error("fromDir import error", e);
+            return Result.error("瀵煎叆澶辫触: " + e.getMessage());
+        }
+    }
+
+    /** 瀵煎叆鎵规鍘嗗彶锛堟暟鎹鍏ラ〉灞曠ず鏈�杩戝鍏ョ粨鏋滐級 */
+    @GetMapping("/batches")
+    public Result<Map<String, Object>> batches(@RequestParam(value = "type", required = false) String type,
+                                               @RequestParam(value = "period", required = false) String period,
+                                               @RequestParam(value = "limit", defaultValue = "20") int limit) {
+        int safeLimit = Math.min(Math.max(limit, 1), 200);
+        LambdaQueryWrapper<ImportBatch> w = new LambdaQueryWrapper<ImportBatch>()
+            .eq(type != null && !type.trim().isEmpty(), ImportBatch::getImportType, type)
+            .eq(period != null && !period.trim().isEmpty(), ImportBatch::getReportPeriod, period)
+            .orderByDesc(ImportBatch::getId)
+            .last("limit " + safeLimit);
+        List<ImportBatch> list = importBatchMapper.selectList(w);
+        Map<String, Object> result = new LinkedHashMap<>();
+        result.put("records", list);
+        return Result.ok(result);
+    }
+
 }

--
Gitblit v1.9.1