Browse Source

feat: 执行日志记录数据库

weijianghai 7 months ago
parent
commit
cb070400bc
57 changed files with 1219 additions and 315 deletions
  1. 1 1
      src/main/java/com/nokia/finance/tasks/config/web/ControllerExceptionHandler.java
  2. 9 0
      src/main/java/com/nokia/finance/tasks/dao/common/DataLogDao.java
  3. 19 0
      src/main/java/com/nokia/finance/tasks/enums/DataStageEnum.java
  4. 25 5
      src/main/java/com/nokia/finance/tasks/jobs/car/CarReportJob.java
  5. 33 10
      src/main/java/com/nokia/finance/tasks/jobs/car/chengben/CarBaoXianJob.java
  6. 33 10
      src/main/java/com/nokia/finance/tasks/jobs/car/chengben/CarDaWeiXiuJob.java
  7. 5 4
      src/main/java/com/nokia/finance/tasks/jobs/car/chengben/CarFuWuFeiJob.java
  8. 33 10
      src/main/java/com/nokia/finance/tasks/jobs/car/chengben/CarLuQiaoJob.java
  9. 33 10
      src/main/java/com/nokia/finance/tasks/jobs/car/chengben/CarNianJianFeiJob.java
  10. 33 10
      src/main/java/com/nokia/finance/tasks/jobs/car/chengben/CarQiTaJob.java
  11. 33 10
      src/main/java/com/nokia/finance/tasks/jobs/car/chengben/CarRanYouJob.java
  12. 5 4
      src/main/java/com/nokia/finance/tasks/jobs/car/chengben/CarSiCheGongYongJob.java
  13. 33 10
      src/main/java/com/nokia/finance/tasks/jobs/car/chengben/CarWeiXiuJob.java
  14. 29 7
      src/main/java/com/nokia/finance/tasks/jobs/car/cxdp/CarCxdpJob.java
  15. 24 3
      src/main/java/com/nokia/finance/tasks/jobs/car/procedure/CarBaseDataMonthProcJob.java
  16. 24 3
      src/main/java/com/nokia/finance/tasks/jobs/car/procedure/CarFeeProcJob.java
  17. 23 3
      src/main/java/com/nokia/finance/tasks/jobs/car/procedure/CarLiChengMonthProcJob.java
  18. 25 4
      src/main/java/com/nokia/finance/tasks/jobs/car/procedure/CarPaiDanProcJob.java
  19. 33 10
      src/main/java/com/nokia/finance/tasks/jobs/car/ruixing/CarBaoFeiJob.java
  20. 33 10
      src/main/java/com/nokia/finance/tasks/jobs/car/ruixing/CarBaseDataDayJob.java
  21. 33 10
      src/main/java/com/nokia/finance/tasks/jobs/car/ruixing/CarLiChengDayJob.java
  22. 37 14
      src/main/java/com/nokia/finance/tasks/jobs/car/ruixing/CarLiChengMonthJob.java
  23. 34 11
      src/main/java/com/nokia/finance/tasks/jobs/car/ruixing/CarWuDanYongCheJob.java
  24. 37 14
      src/main/java/com/nokia/finance/tasks/jobs/car/ruixing/CarYongCheJob.java
  25. 4 4
      src/main/java/com/nokia/finance/tasks/jobs/car/ruixing/CarYongCheZongLanJob.java
  26. 34 11
      src/main/java/com/nokia/finance/tasks/jobs/car/ruixing/CarYueJieJob.java
  27. 33 10
      src/main/java/com/nokia/finance/tasks/jobs/car/shujucangku/CarFeeBsJob.java
  28. 34 10
      src/main/java/com/nokia/finance/tasks/jobs/car/shujucangku/CarFeeHbJob.java
  29. 28 7
      src/main/java/com/nokia/finance/tasks/jobs/car/strategy/CarHighFuelConsumptionJob.java
  30. 28 7
      src/main/java/com/nokia/finance/tasks/jobs/car/strategy/CarHighRepairJob.java
  31. 28 5
      src/main/java/com/nokia/finance/tasks/jobs/car/strategy/CarInefficiencyPercentJob.java
  32. 26 5
      src/main/java/com/nokia/finance/tasks/jobs/car/strategy/CarInefficiencyQxJob.java
  33. 28 7
      src/main/java/com/nokia/finance/tasks/jobs/car/strategy/CarRentalRepairJob.java
  34. 26 5
      src/main/java/com/nokia/finance/tasks/jobs/car/strategy/CarViolationUnprocessedJob.java
  35. 26 5
      src/main/java/com/nokia/finance/tasks/jobs/car/strategy/CarWdyjJob.java
  36. 3 3
      src/main/java/com/nokia/finance/tasks/jobs/gdc/car/CarPhpRequestLogJob.java
  37. 25 5
      src/main/java/com/nokia/finance/tasks/jobs/house/HouseReportJob.java
  38. 34 10
      src/main/java/com/nokia/finance/tasks/jobs/house/chengben/HouseBuildingRepairMonthJob.java
  39. 5 4
      src/main/java/com/nokia/finance/tasks/jobs/house/chengben/HouseRentInRepairMonthJob.java
  40. 26 5
      src/main/java/com/nokia/finance/tasks/jobs/house/fcdp/HouseBuildingAreaStatJob.java
  41. 26 5
      src/main/java/com/nokia/finance/tasks/jobs/house/fcdp/HouseBuildingLandCountJob.java
  42. 23 3
      src/main/java/com/nokia/finance/tasks/jobs/house/procedure/HouseBuildingRepairProcJob.java
  43. 27 5
      src/main/java/com/nokia/finance/tasks/jobs/house/strategy/HouseBuildingIdleStrategyJob.java
  44. 91 0
      src/main/java/com/nokia/finance/tasks/pojo/po/common/DataLogPo.java
  45. 11 0
      src/main/java/com/nokia/finance/tasks/service/common/DataLogServiceImpl.java
  46. 1 1
      src/main/java/com/nokia/finance/tasks/utils/PinYinUtil.java
  47. 6 6
      src/main/resources/application-dev.yml
  48. 1 1
      src/test/java/com/nokia/finance/tasks/HanZiToPinYinTest.java
  49. 2 2
      src/test/java/com/nokia/finance/tasks/MybatisPlusGeneratorTest.java
  50. 2 2
      src/test/java/com/nokia/finance/tasks/car/CarGongCheShiYongTests.java
  51. 2 2
      src/test/java/com/nokia/finance/tasks/car/CarGongCheShiYongTests1.java
  52. 3 3
      src/test/java/com/nokia/finance/tasks/car/CarGongCheShiYongTests2.java
  53. 2 2
      src/test/java/com/nokia/finance/tasks/car/CarGongCheShiYongTests3.java
  54. 2 2
      src/test/java/com/nokia/finance/tasks/car/CarJiaoTongBuTieTests.java
  55. 2 2
      src/test/java/com/nokia/finance/tasks/car/CarLianXuJiaYouTests.java
  56. 1 1
      src/test/java/com/nokia/finance/tasks/requestlogs/JavaRequestLogTest.java
  57. 2 2
      src/test/java/com/nokia/finance/tasks/requestlogs/PhpRequestLogTest.java

+ 1 - 1
src/main/java/com/nokia/finance/tasks/config/web/ControllerExceptionHandler.java

@@ -80,7 +80,7 @@ public class ControllerExceptionHandler
     @ExceptionHandler(Exception.class)
     public ResponseEntity<Object> exceptionHandler(Exception e)
     {
-        log.error("╭( ′• o •′ )╭☞ 发生错误了 {}", e.getMessage(), e);
+        log.error("╭( ′• o •′ )╭☞ 发生错误了 {}", e.toString(), e);
         return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(R.error());
     }
 }

+ 9 - 0
src/main/java/com/nokia/finance/tasks/dao/common/DataLogDao.java

@@ -0,0 +1,9 @@
+package com.nokia.finance.tasks.dao.common;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface DataLogDao extends BaseMapper<DataLogPo> {
+}

+ 19 - 0
src/main/java/com/nokia/finance/tasks/enums/DataStageEnum.java

@@ -0,0 +1,19 @@
+package com.nokia.finance.tasks.enums;
+
+public enum DataStageEnum {
+    /**
+     * 存储
+     */
+    CC("存储"),
+    /**
+     * 加工
+     */
+    JG("加工"),
+    ;
+
+    public final String value;
+
+    DataStageEnum(String value) {
+        this.value = value;
+    }
+}

+ 25 - 5
src/main/java/com/nokia/finance/tasks/jobs/car/CarReportJob.java

@@ -3,6 +3,7 @@ package com.nokia.finance.tasks.jobs.car;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.config.CarReportConfig;
 import com.nokia.finance.tasks.dao.car.CarReportDao;
+import com.nokia.finance.tasks.enums.DataStageEnum;
 import com.nokia.finance.tasks.pojo.po.car_report.CarBglryQsPo;
 import com.nokia.finance.tasks.pojo.po.car_report.CarBglryUnitPo;
 import com.nokia.finance.tasks.pojo.po.car_report.CarBszsbPo;
@@ -25,6 +26,7 @@ import com.nokia.finance.tasks.pojo.po.car_report.CarWzUnitPo;
 import com.nokia.finance.tasks.pojo.po.car_report.CarZlwxycPo;
 import com.nokia.finance.tasks.pojo.po.car_report.CarZywxycPo;
 import com.nokia.finance.tasks.pojo.po.car_report.CarZywxycUnitPo;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
 import com.nokia.finance.tasks.pojo.vo.car_report.CarCldxVo;
 import com.nokia.finance.tasks.pojo.vo.car_report.CarClfyVo;
 import com.nokia.finance.tasks.pojo.vo.car_report.CarClgkVo;
@@ -37,6 +39,7 @@ import com.nokia.finance.tasks.pojo.vo.car_report.CarWzclycVo;
 import com.nokia.finance.tasks.pojo.vo.car_report.CarYcryfVo;
 import com.nokia.finance.tasks.pojo.vo.car_report.CarZlycwxVo;
 import com.nokia.finance.tasks.pojo.vo.car_report.CarZyycwxVo;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.service.common.file.FileService;
 import com.nokia.finance.tasks.utils.OfficeUtil;
 import com.nokia.finance.tasks.utils.ZipUtil;
@@ -63,6 +66,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CompletableFuture;
 
 /**
  * 车辆报告定时任务
@@ -73,11 +77,14 @@ public class CarReportJob {
     private final CarReportConfig carReportConfig;
     private final CarReportDao carReportDao;
     private final FileService fileService;
+    private final DataLogServiceImpl dataLogService;
 
-    public CarReportJob(CarReportConfig carReportConfig, CarReportDao carReportDao, FileService fileService) {
+    public CarReportJob(CarReportConfig carReportConfig, CarReportDao carReportDao, FileService fileService,
+                        DataLogServiceImpl dataLogService) {
         this.carReportConfig = carReportConfig;
         this.carReportDao = carReportDao;
         this.fileService = fileService;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -86,11 +93,17 @@ public class CarReportJob {
     @Scheduled(cron = "0 30 0 13 * ?")
     @Transactional(timeout = 300, rollbackFor = Exception.class)
     public void runJob() {
+        log.info("执行车辆报告定时任务");
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("车辆报告");
+        dataLogPo.setStage(DataStageEnum.JG.value);
+        dataLogPo.setOperationName("生成车辆报告");
+        dataLogPoList.add(dataLogPo);
         try {
-            log.info("执行车辆报告定时任务");
             CarReportVo vo = getReportVo();
             // 生成docx
-            generateDocx(vo);
+            generateDocx(vo, dataLogPo);
             // 生成pdf
             OfficeUtil.toPdf(carReportConfig.getOutDir(), carReportConfig.getDocx(), 1L);
             // 上传文件
@@ -98,8 +111,12 @@ public class CarReportJob {
             // 更新公告
             updateNotices(vo);
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            dataLogPo.setStatus(0);
+            dataLogPo.setExceptionInfo(e.toString());
             throw new MyRuntimeException("车辆报告定时任务失败");
+        } finally {
+            CompletableFuture.runAsync(() -> dataLogService.saveBatch(dataLogPoList));
         }
     }
 
@@ -176,7 +193,7 @@ public class CarReportJob {
     /**
      * 生成docx
      */
-    public void generateDocx(CarReportVo vo) throws IOException, TemplateException {
+    public void generateDocx(CarReportVo vo, DataLogPo dataLogPo) throws IOException, TemplateException {
         Configuration configuration = new Configuration(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS);
         configuration.setDefaultEncoding(StandardCharsets.UTF_8.name());
         configuration.setDirectoryForTemplateLoading(new File(carReportConfig.getFtlDir()));
@@ -226,6 +243,9 @@ public class CarReportJob {
         Path inputDir = Paths.get(carReportConfig.getDocxDir());
         Path outputFile = Paths.get(carReportConfig.getDocx());
         ZipUtil.zipDirNonSelf(inputDir, outputFile);
+        long fileSize = Files.size(outputFile);
+        dataLogPo.setDataSize(fileSize);
+        dataLogPo.setObject(vo.getReportMonth() + ".docx");
     }
 
     /**

+ 33 - 10
src/main/java/com/nokia/finance/tasks/jobs/car/chengben/CarBaoXianJob.java

@@ -3,10 +3,13 @@ package com.nokia.finance.tasks.jobs.car.chengben;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.common.utils.psql.PsqlUtil;
 import com.nokia.finance.tasks.config.JobConfig;
+import com.nokia.finance.tasks.enums.DataStageEnum;
 import com.nokia.finance.tasks.pojo.po.common.AreaPo;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
 import com.nokia.finance.tasks.pojo.po.common.OrganizationPo;
 import com.nokia.finance.tasks.service.car.CarService;
 import com.nokia.finance.tasks.service.common.AreaService;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.service.common.OrganizationService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -18,6 +21,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
+import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
 import java.nio.charset.StandardCharsets;
@@ -43,13 +47,15 @@ public class CarBaoXianJob {
     private final CarService carService;
     private final OrganizationService organizationService;
     private final AreaService areaService;
+    private final DataLogServiceImpl dataLogService;
 
     public CarBaoXianJob(JobConfig jobConfig, CarService carService, OrganizationService organizationService,
-                         AreaService areaService) {
+                         AreaService areaService, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.carService = carService;
         this.organizationService = organizationService;
         this.areaService = areaService;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -57,6 +63,7 @@ public class CarBaoXianJob {
      */
     @Scheduled(cron = "0 10 6 12 * ?")
     public void runJob() {
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
         // 数据目录
         Path dir = Paths.get(jobConfig.getCarBaoXianSourcePath());
         try (Stream<Path> stream = Files.list(dir)) {
@@ -69,32 +76,48 @@ public class CarBaoXianJob {
             for (Path path : pathList) {
                 CompletableFuture.runAsync(() -> {
                     try {
-                        singleJob(path);
+                        singleJob(path, dataLogPoList);
                     } catch (Exception e) {
                         throw new MyRuntimeException(e);
                     }
                 }).get(1, TimeUnit.MINUTES);
             }
         } catch (InterruptedException e) {
-            log.error("线程中断: {}", e.getMessage(), e);
+            log.error("线程中断: {}", e, e);
             Thread.currentThread().interrupt();
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "河北成本管理系统车辆保险数据", DataStageEnum.CC, "入库");
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "河北成本管理系统车辆保险数据", DataStageEnum.CC, "入库");
+        } finally {
+            if (!CollectionUtils.isEmpty(dataLogPoList)) {
+                dataLogService.saveBatch(dataLogPoList);
+            }
         }
     }
 
     /**
      * 处理单个文件
      *
-     * @param path 文件路径
+     * @param path          文件路径
+     * @param dataLogPoList 数据处理日志列表
      */
-    public void singleJob(Path path) throws Exception {
-        if (Files.size(path) == 0) {
+    public void singleJob(Path path, List<DataLogPo> dataLogPoList) throws IOException {
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("河北成本管理系统车辆保险数据");
+        dataLogPo.setObject(path.getFileName().toString());
+        dataLogPo.setStage(DataStageEnum.CC.value);
+        dataLogPo.setOperationName("入库");
+        long fileSize = Files.size(path);
+        dataLogPo.setDataSize(fileSize);
+        dataLogPoList.add(dataLogPo);
+        if (fileSize == 0) {
             move(path);
             throw new MyRuntimeException(path.getFileName() + " 空文件");
         }
         List<Map<String, String>> list = readFile(path);
         List<Map<String, String>> distinctList = dataProcessing(path, list);
+        dataLogPo.setDataCount(distinctList.size());
         Path csvPath = toCsv(path, distinctList);
         copyCsv(csvPath);
         move(path);
@@ -105,7 +128,7 @@ public class CarBaoXianJob {
      *
      * @param path 文件路径
      */
-    public List<Map<String, String>> readFile(Path path) throws Exception {
+    public List<Map<String, String>> readFile(Path path) throws IOException {
         log.info("读取: {}", path);
         List<String> headers = Stream.of(
                 "data_time_nlsd",
@@ -210,7 +233,7 @@ public class CarBaoXianJob {
      * @param path 源文件路径
      * @param list 数据
      */
-    public Path toCsv(Path path, List<Map<String, String>> list) throws Exception {
+    public Path toCsv(Path path, List<Map<String, String>> list) throws IOException {
         log.info("条数:{}", list.size());
         Files.createDirectories(Paths.get(jobConfig.getCarBaoXianHistoryPath()));
         Path csvPath = Paths.get(jobConfig.getCarBaoXianHistoryPath() + path.getFileName() + ".csv");
@@ -249,7 +272,7 @@ public class CarBaoXianJob {
      *
      * @param path 源文件路径
      */
-    public void move(Path path) throws Exception {
+    public void move(Path path) throws IOException {
         if (Files.exists(Paths.get(path + ".MD5"))) {
             Files.move(Paths.get(path + ".MD5"),
                     Paths.get(jobConfig.getCarBaoXianHistoryPath(), path.getFileName().toString() + ".MD5"),

+ 33 - 10
src/main/java/com/nokia/finance/tasks/jobs/car/chengben/CarDaWeiXiuJob.java

@@ -3,10 +3,13 @@ package com.nokia.finance.tasks.jobs.car.chengben;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.common.utils.psql.PsqlUtil;
 import com.nokia.finance.tasks.config.JobConfig;
+import com.nokia.finance.tasks.enums.DataStageEnum;
 import com.nokia.finance.tasks.pojo.po.common.AreaPo;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
 import com.nokia.finance.tasks.pojo.po.common.OrganizationPo;
 import com.nokia.finance.tasks.service.car.CarService;
 import com.nokia.finance.tasks.service.common.AreaService;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.service.common.OrganizationService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -18,6 +21,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
+import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
 import java.nio.charset.StandardCharsets;
@@ -43,13 +47,15 @@ public class CarDaWeiXiuJob {
     private final CarService carService;
     private final OrganizationService organizationService;
     private final AreaService areaService;
+    private final DataLogServiceImpl dataLogService;
 
     public CarDaWeiXiuJob(JobConfig jobConfig, CarService carService, OrganizationService organizationService,
-                          AreaService areaService) {
+                          AreaService areaService, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.carService = carService;
         this.organizationService = organizationService;
         this.areaService = areaService;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -57,6 +63,7 @@ public class CarDaWeiXiuJob {
      */
     @Scheduled(cron = "0 12 6 12 * ?")
     public void runJob() {
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
         // 数据目录
         Path dir = Paths.get(jobConfig.getCarDaWeiXiuSourcePath());
         try (Stream<Path> stream = Files.list(dir)) {
@@ -69,32 +76,48 @@ public class CarDaWeiXiuJob {
             for (Path path : pathList) {
                 CompletableFuture.runAsync(() -> {
                     try {
-                        singleJob(path);
+                        singleJob(path, dataLogPoList);
                     } catch (Exception e) {
                         throw new MyRuntimeException(e);
                     }
                 }).get(1, TimeUnit.MINUTES);
             }
         } catch (InterruptedException e) {
-            log.error("线程中断: {}", e.getMessage(), e);
+            log.error("线程中断: {}", e, e);
             Thread.currentThread().interrupt();
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "河北成本管理系统车辆大额维修数据", DataStageEnum.CC, "入库");
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "河北成本管理系统车辆大额维修数据", DataStageEnum.CC, "入库");
+        } finally {
+            if (!CollectionUtils.isEmpty(dataLogPoList)) {
+                dataLogService.saveBatch(dataLogPoList);
+            }
         }
     }
 
     /**
      * 处理单个文件
      *
-     * @param path 文件路径
+     * @param path          文件路径
+     * @param dataLogPoList 数据处理日志列表
      */
-    public void singleJob(Path path) throws Exception {
-        if (Files.size(path) == 0) {
+    public void singleJob(Path path, List<DataLogPo> dataLogPoList) throws IOException {
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("河北成本管理系统车辆大额维修数据");
+        dataLogPo.setObject(path.getFileName().toString());
+        dataLogPo.setStage(DataStageEnum.CC.value);
+        dataLogPo.setOperationName("入库");
+        long fileSize = Files.size(path);
+        dataLogPo.setDataSize(fileSize);
+        dataLogPoList.add(dataLogPo);
+        if (fileSize == 0) {
             move(path);
             throw new MyRuntimeException(path.getFileName() + " 空文件");
         }
         List<Map<String, String>> list = readFile(path);
         List<Map<String, String>> distinctList = dataProcessing(path, list);
+        dataLogPo.setDataCount(distinctList.size());
         Path csvPath = toCsv(path, distinctList);
         copyCsv(csvPath);
         move(path);
@@ -105,7 +128,7 @@ public class CarDaWeiXiuJob {
      *
      * @param path 文件路径
      */
-    public List<Map<String, String>> readFile(Path path) throws Exception {
+    public List<Map<String, String>> readFile(Path path) throws IOException {
         log.info("读取: {}", path);
         List<String> headers = Stream.of(
                 "data_time_nlsd",
@@ -207,7 +230,7 @@ public class CarDaWeiXiuJob {
      * @param path 源文件路径
      * @param list 数据
      */
-    public Path toCsv(Path path, List<Map<String, String>> list) throws Exception {
+    public Path toCsv(Path path, List<Map<String, String>> list) throws IOException {
         log.info("条数:{}", list.size());
         Files.createDirectories(Paths.get(jobConfig.getCarDaWeiXiuHistoryPath()));
         Path csvPath = Paths.get(jobConfig.getCarDaWeiXiuHistoryPath() + path.getFileName() + ".csv");
@@ -246,7 +269,7 @@ public class CarDaWeiXiuJob {
      *
      * @param path 源文件路径
      */
-    public void move(Path path) throws Exception {
+    public void move(Path path) throws IOException {
         if (Files.exists(Paths.get(path + ".MD5"))) {
             Files.move(Paths.get(path + ".MD5"),
                     Paths.get(jobConfig.getCarDaWeiXiuHistoryPath(), path.getFileName().toString() + ".MD5"),

+ 5 - 4
src/main/java/com/nokia/finance/tasks/jobs/car/chengben/CarFuWuFeiJob.java

@@ -7,6 +7,7 @@ import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
+import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -52,10 +53,10 @@ public class CarFuWuFeiJob {
                 }).get(1, TimeUnit.MINUTES);
             }
         } catch (InterruptedException e) {
-            log.error("线程中断: {}", e.getMessage(), e);
+            log.error("线程中断: {}", e, e);
             Thread.currentThread().interrupt();
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
         }
     }
 
@@ -64,7 +65,7 @@ public class CarFuWuFeiJob {
      *
      * @param path 文件路径
      */
-    public void singleJob(Path path) throws Exception {
+    public void singleJob(Path path) throws IOException {
         if (Files.size(path) == 0) {
             move(path);
             throw new MyRuntimeException(path.getFileName() + " 空文件");
@@ -77,7 +78,7 @@ public class CarFuWuFeiJob {
      *
      * @param path 源文件路径
      */
-    public void move(Path path) throws Exception {
+    public void move(Path path) throws IOException {
         if (Files.exists(Paths.get(path + ".MD5"))) {
             Files.move(Paths.get(path + ".MD5"),
                     Paths.get(jobConfig.getCarFuWuFeiHistoryPath(), path.getFileName().toString() + ".MD5"),

+ 33 - 10
src/main/java/com/nokia/finance/tasks/jobs/car/chengben/CarLuQiaoJob.java

@@ -3,10 +3,13 @@ package com.nokia.finance.tasks.jobs.car.chengben;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.common.utils.psql.PsqlUtil;
 import com.nokia.finance.tasks.config.JobConfig;
+import com.nokia.finance.tasks.enums.DataStageEnum;
 import com.nokia.finance.tasks.pojo.po.common.AreaPo;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
 import com.nokia.finance.tasks.pojo.po.common.OrganizationPo;
 import com.nokia.finance.tasks.service.car.CarService;
 import com.nokia.finance.tasks.service.common.AreaService;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.service.common.OrganizationService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -18,6 +21,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
+import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
 import java.nio.charset.StandardCharsets;
@@ -43,13 +47,15 @@ public class CarLuQiaoJob {
     private final CarService carService;
     private final OrganizationService organizationService;
     private final AreaService areaService;
+    private final DataLogServiceImpl dataLogService;
 
     public CarLuQiaoJob(JobConfig jobConfig, CarService carService, OrganizationService organizationService,
-                        AreaService areaService) {
+                        AreaService areaService, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.carService = carService;
         this.organizationService = organizationService;
         this.areaService = areaService;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -57,6 +63,7 @@ public class CarLuQiaoJob {
      */
     @Scheduled(cron = "0 14 6 12 * ?")
     public void runJob() {
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
         // 数据目录
         Path dir = Paths.get(jobConfig.getCarLuQiaoSourcePath());
         try (Stream<Path> stream = Files.list(dir)) {
@@ -69,32 +76,48 @@ public class CarLuQiaoJob {
             for (Path path : pathList) {
                 CompletableFuture.runAsync(() -> {
                     try {
-                        singleJob(path);
+                        singleJob(path, dataLogPoList);
                     } catch (Exception e) {
                         throw new MyRuntimeException(e);
                     }
                 }).get(1, TimeUnit.MINUTES);
             }
         } catch (InterruptedException e) {
-            log.error("线程中断: {}", e.getMessage(), e);
+            log.error("线程中断: {}", e, e);
             Thread.currentThread().interrupt();
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "河北成本管理系统车辆路桥数据", DataStageEnum.CC, "入库");
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "河北成本管理系统车辆路桥数据", DataStageEnum.CC, "入库");
+        } finally {
+            if (!CollectionUtils.isEmpty(dataLogPoList)) {
+                dataLogService.saveBatch(dataLogPoList);
+            }
         }
     }
 
     /**
      * 处理单个文件
      *
-     * @param path 文件路径
+     * @param path          文件路径
+     * @param dataLogPoList 数据处理日志列表
      */
-    public void singleJob(Path path) throws Exception {
-        if (Files.size(path) == 0) {
+    public void singleJob(Path path, List<DataLogPo> dataLogPoList) throws IOException {
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("河北成本管理系统车辆路桥数据");
+        dataLogPo.setObject(path.getFileName().toString());
+        dataLogPo.setStage(DataStageEnum.CC.value);
+        dataLogPo.setOperationName("入库");
+        long fileSize = Files.size(path);
+        dataLogPo.setDataSize(fileSize);
+        dataLogPoList.add(dataLogPo);
+        if (fileSize == 0) {
             move(path);
             throw new MyRuntimeException(path.getFileName() + " 空文件");
         }
         List<Map<String, String>> list = readFile(path);
         List<Map<String, String>> distinctList = dataProcessing(path, list);
+        dataLogPo.setDataCount(distinctList.size());
         Path csvPath = toCsv(path, distinctList);
         copyCsv(csvPath);
         move(path);
@@ -105,7 +128,7 @@ public class CarLuQiaoJob {
      *
      * @param path 文件路径
      */
-    public List<Map<String, String>> readFile(Path path) throws Exception {
+    public List<Map<String, String>> readFile(Path path) throws IOException {
         log.info("读取: {}", path);
         List<String> headers = Stream.of(
                 "data_time_nlsd",
@@ -206,7 +229,7 @@ public class CarLuQiaoJob {
      * @param path 源文件路径
      * @param list 数据
      */
-    public Path toCsv(Path path, List<Map<String, String>> list) throws Exception {
+    public Path toCsv(Path path, List<Map<String, String>> list) throws IOException {
         log.info("条数:{}", list.size());
         Files.createDirectories(Paths.get(jobConfig.getCarLuQiaoHistoryPath()));
         Path csvPath = Paths.get(jobConfig.getCarLuQiaoHistoryPath() + path.getFileName() + ".csv");
@@ -245,7 +268,7 @@ public class CarLuQiaoJob {
      *
      * @param path 源文件路径
      */
-    public void move(Path path) throws Exception {
+    public void move(Path path) throws IOException {
         if (Files.exists(Paths.get(path + ".MD5"))) {
             Files.move(Paths.get(path + ".MD5"),
                     Paths.get(jobConfig.getCarLuQiaoHistoryPath(), path.getFileName().toString() + ".MD5"),

+ 33 - 10
src/main/java/com/nokia/finance/tasks/jobs/car/chengben/CarNianJianFeiJob.java

@@ -3,10 +3,13 @@ package com.nokia.finance.tasks.jobs.car.chengben;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.common.utils.psql.PsqlUtil;
 import com.nokia.finance.tasks.config.JobConfig;
+import com.nokia.finance.tasks.enums.DataStageEnum;
 import com.nokia.finance.tasks.pojo.po.common.AreaPo;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
 import com.nokia.finance.tasks.pojo.po.common.OrganizationPo;
 import com.nokia.finance.tasks.service.car.CarService;
 import com.nokia.finance.tasks.service.common.AreaService;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.service.common.OrganizationService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -18,6 +21,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
+import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
 import java.nio.charset.StandardCharsets;
@@ -43,13 +47,15 @@ public class CarNianJianFeiJob {
     private final CarService carService;
     private final OrganizationService organizationService;
     private final AreaService areaService;
+    private final DataLogServiceImpl dataLogService;
 
     public CarNianJianFeiJob(JobConfig jobConfig, CarService carService, OrganizationService organizationService,
-                             AreaService areaService) {
+                             AreaService areaService, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.carService = carService;
         this.organizationService = organizationService;
         this.areaService = areaService;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -57,6 +63,7 @@ public class CarNianJianFeiJob {
      */
     @Scheduled(cron = "0 16 6 12 * ?")
     public void runJob() {
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
         // 数据目录
         Path dir = Paths.get(jobConfig.getCarNianJianFeiSourcePath());
         try (Stream<Path> stream = Files.list(dir)) {
@@ -69,32 +76,48 @@ public class CarNianJianFeiJob {
             for (Path path : pathList) {
                 CompletableFuture.runAsync(() -> {
                     try {
-                        singleJob(path);
+                        singleJob(path, dataLogPoList);
                     } catch (Exception e) {
                         throw new MyRuntimeException(e);
                     }
                 }).get(1, TimeUnit.MINUTES);
             }
         } catch (InterruptedException e) {
-            log.error("线程中断: {}", e.getMessage(), e);
+            log.error("线程中断: {}", e, e);
             Thread.currentThread().interrupt();
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "河北成本管理系统车辆年检数据", DataStageEnum.CC, "入库");
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "河北成本管理系统车辆年检数据", DataStageEnum.CC, "入库");
+        } finally {
+            if (!CollectionUtils.isEmpty(dataLogPoList)) {
+                dataLogService.saveBatch(dataLogPoList);
+            }
         }
     }
 
     /**
      * 处理单个文件
      *
-     * @param path 文件路径
+     * @param path          文件路径
+     * @param dataLogPoList 数据处理日志列表
      */
-    public void singleJob(Path path) throws Exception {
-        if (Files.size(path) == 0) {
+    public void singleJob(Path path, List<DataLogPo> dataLogPoList) throws IOException {
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("河北成本管理系统车辆年检数据");
+        dataLogPo.setObject(path.getFileName().toString());
+        dataLogPo.setStage(DataStageEnum.CC.value);
+        dataLogPo.setOperationName("入库");
+        long fileSize = Files.size(path);
+        dataLogPo.setDataSize(fileSize);
+        dataLogPoList.add(dataLogPo);
+        if (fileSize == 0) {
             move(path);
             throw new MyRuntimeException(path.getFileName() + " 空文件");
         }
         List<Map<String, String>> list = readFile(path);
         List<Map<String, String>> distinctList = dataProcessing(path, list);
+        dataLogPo.setDataCount(distinctList.size());
         Path csvPath = toCsv(path, distinctList);
         copyCsv(csvPath);
         move(path);
@@ -105,7 +128,7 @@ public class CarNianJianFeiJob {
      *
      * @param path 文件路径
      */
-    public List<Map<String, String>> readFile(Path path) throws Exception {
+    public List<Map<String, String>> readFile(Path path) throws IOException {
         log.info("读取: {}", path);
         List<String> headers = Stream.of(
                 "data_time_nlsd",
@@ -206,7 +229,7 @@ public class CarNianJianFeiJob {
      * @param path 源文件路径
      * @param list 数据
      */
-    public Path toCsv(Path path, List<Map<String, String>> list) throws Exception {
+    public Path toCsv(Path path, List<Map<String, String>> list) throws IOException {
         log.info("条数:{}", list.size());
         Files.createDirectories(Paths.get(jobConfig.getCarNianJianFeiHistoryPath()));
         Path csvPath = Paths.get(jobConfig.getCarNianJianFeiHistoryPath() + path.getFileName() + ".csv");
@@ -245,7 +268,7 @@ public class CarNianJianFeiJob {
      *
      * @param path 源文件路径
      */
-    public void move(Path path) throws Exception {
+    public void move(Path path) throws IOException {
         if (Files.exists(Paths.get(path + ".MD5"))) {
             Files.move(Paths.get(path + ".MD5"),
                     Paths.get(jobConfig.getCarNianJianFeiHistoryPath(), path.getFileName().toString() + ".MD5"),

+ 33 - 10
src/main/java/com/nokia/finance/tasks/jobs/car/chengben/CarQiTaJob.java

@@ -3,10 +3,13 @@ package com.nokia.finance.tasks.jobs.car.chengben;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.common.utils.psql.PsqlUtil;
 import com.nokia.finance.tasks.config.JobConfig;
+import com.nokia.finance.tasks.enums.DataStageEnum;
 import com.nokia.finance.tasks.pojo.po.common.AreaPo;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
 import com.nokia.finance.tasks.pojo.po.common.OrganizationPo;
 import com.nokia.finance.tasks.service.car.CarService;
 import com.nokia.finance.tasks.service.common.AreaService;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.service.common.OrganizationService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -18,6 +21,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
+import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
 import java.nio.charset.StandardCharsets;
@@ -43,13 +47,15 @@ public class CarQiTaJob {
     private final CarService carService;
     private final OrganizationService organizationService;
     private final AreaService areaService;
+    private final DataLogServiceImpl dataLogService;
 
     public CarQiTaJob(JobConfig jobConfig, CarService carService, OrganizationService organizationService,
-                      AreaService areaService) {
+                      AreaService areaService, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.carService = carService;
         this.organizationService = organizationService;
         this.areaService = areaService;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -57,6 +63,7 @@ public class CarQiTaJob {
      */
     @Scheduled(cron = "0 18 6 12 * ?")
     public void runJob() {
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
         // 数据目录
         Path dir = Paths.get(jobConfig.getCarQiTaSourcePath());
         try (Stream<Path> stream = Files.list(dir)) {
@@ -69,32 +76,48 @@ public class CarQiTaJob {
             for (Path path : pathList) {
                 CompletableFuture.runAsync(() -> {
                     try {
-                        singleJob(path);
+                        singleJob(path, dataLogPoList);
                     } catch (Exception e) {
                         throw new MyRuntimeException(e);
                     }
                 }).get(1, TimeUnit.MINUTES);
             }
         } catch (InterruptedException e) {
-            log.error("线程中断: {}", e.getMessage(), e);
+            log.error("线程中断: {}", e, e);
             Thread.currentThread().interrupt();
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "河北成本管理系统车辆其他费用数据", DataStageEnum.CC, "入库");
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "河北成本管理系统车辆其他费用数据", DataStageEnum.CC, "入库");
+        } finally {
+            if (!CollectionUtils.isEmpty(dataLogPoList)) {
+                dataLogService.saveBatch(dataLogPoList);
+            }
         }
     }
 
     /**
      * 处理单个文件
      *
-     * @param path 文件路径
+     * @param path          文件路径
+     * @param dataLogPoList 数据处理日志列表
      */
-    public void singleJob(Path path) throws Exception {
-        if (Files.size(path) == 0) {
+    public void singleJob(Path path, List<DataLogPo> dataLogPoList) throws IOException {
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("河北成本管理系统车辆其他费用数据");
+        dataLogPo.setObject(path.getFileName().toString());
+        dataLogPo.setStage(DataStageEnum.CC.value);
+        dataLogPo.setOperationName("入库");
+        long fileSize = Files.size(path);
+        dataLogPo.setDataSize(fileSize);
+        dataLogPoList.add(dataLogPo);
+        if (fileSize == 0) {
             move(path);
             throw new MyRuntimeException(path.getFileName() + " 空文件");
         }
         List<Map<String, String>> list = readFile(path);
         List<Map<String, String>> distinctList = dataProcessing(path, list);
+        dataLogPo.setDataCount(distinctList.size());
         Path csvPath = toCsv(path, distinctList);
         copyCsv(csvPath);
         move(path);
@@ -105,7 +128,7 @@ public class CarQiTaJob {
      *
      * @param path 文件路径
      */
-    public List<Map<String, String>> readFile(Path path) throws Exception {
+    public List<Map<String, String>> readFile(Path path) throws IOException {
         log.info("读取: {}", path);
         List<String> headers = Stream.of(
                 "data_time_nlsd",
@@ -206,7 +229,7 @@ public class CarQiTaJob {
      * @param path 源文件路径
      * @param list 数据
      */
-    public Path toCsv(Path path, List<Map<String, String>> list) throws Exception {
+    public Path toCsv(Path path, List<Map<String, String>> list) throws IOException {
         log.info("条数:{}", list.size());
         Files.createDirectories(Paths.get(jobConfig.getCarQiTaHistoryPath()));
         Path csvPath = Paths.get(jobConfig.getCarQiTaHistoryPath() + path.getFileName() + ".csv");
@@ -245,7 +268,7 @@ public class CarQiTaJob {
      *
      * @param path 源文件路径
      */
-    public void move(Path path) throws Exception {
+    public void move(Path path) throws IOException {
         if (Files.exists(Paths.get(path + ".MD5"))) {
             Files.move(Paths.get(path + ".MD5"),
                     Paths.get(jobConfig.getCarQiTaHistoryPath(), path.getFileName().toString() + ".MD5"),

+ 33 - 10
src/main/java/com/nokia/finance/tasks/jobs/car/chengben/CarRanYouJob.java

@@ -3,10 +3,13 @@ package com.nokia.finance.tasks.jobs.car.chengben;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.common.utils.psql.PsqlUtil;
 import com.nokia.finance.tasks.config.JobConfig;
+import com.nokia.finance.tasks.enums.DataStageEnum;
 import com.nokia.finance.tasks.pojo.po.common.AreaPo;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
 import com.nokia.finance.tasks.pojo.po.common.OrganizationPo;
 import com.nokia.finance.tasks.service.car.CarService;
 import com.nokia.finance.tasks.service.common.AreaService;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.service.common.OrganizationService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -18,6 +21,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
+import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
 import java.nio.charset.StandardCharsets;
@@ -43,13 +47,15 @@ public class CarRanYouJob {
     private final CarService carService;
     private final OrganizationService organizationService;
     private final AreaService areaService;
+    private final DataLogServiceImpl dataLogService;
 
     public CarRanYouJob(JobConfig jobConfig, CarService carService, OrganizationService organizationService,
-                        AreaService areaService) {
+                        AreaService areaService, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.carService = carService;
         this.organizationService = organizationService;
         this.areaService = areaService;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -57,6 +63,7 @@ public class CarRanYouJob {
      */
     @Scheduled(cron = "0 20 6 12 * ?")
     public void runJob() {
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
         // 数据目录
         Path dir = Paths.get(jobConfig.getCarRanYouSourcePath());
         try (Stream<Path> stream = Files.list(dir)) {
@@ -69,32 +76,48 @@ public class CarRanYouJob {
             for (Path path : pathList) {
                 CompletableFuture.runAsync(() -> {
                     try {
-                        singleJob(path);
+                        singleJob(path, dataLogPoList);
                     } catch (Exception e) {
                         throw new MyRuntimeException(e);
                     }
                 }).get(1, TimeUnit.MINUTES);
             }
         } catch (InterruptedException e) {
-            log.error("线程中断: {}", e.getMessage(), e);
+            log.error("线程中断: {}", e, e);
             Thread.currentThread().interrupt();
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "河北成本管理系统车辆燃油数据", DataStageEnum.CC, "入库");
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "河北成本管理系统车辆燃油数据", DataStageEnum.CC, "入库");
+        } finally {
+            if (!CollectionUtils.isEmpty(dataLogPoList)) {
+                dataLogService.saveBatch(dataLogPoList);
+            }
         }
     }
 
     /**
      * 处理单个文件
      *
-     * @param path 文件路径
+     * @param path          文件路径
+     * @param dataLogPoList 数据处理日志列表
      */
-    public void singleJob(Path path) throws Exception {
-        if (Files.size(path) == 0) {
+    public void singleJob(Path path, List<DataLogPo> dataLogPoList) throws IOException {
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("河北成本管理系统车辆燃油数据");
+        dataLogPo.setObject(path.getFileName().toString());
+        dataLogPo.setStage(DataStageEnum.CC.value);
+        dataLogPo.setOperationName("入库");
+        long fileSize = Files.size(path);
+        dataLogPo.setDataSize(fileSize);
+        dataLogPoList.add(dataLogPo);
+        if (fileSize == 0) {
             move(path);
             throw new MyRuntimeException(path.getFileName() + " 空文件");
         }
         List<Map<String, String>> list = readFile(path);
         List<Map<String, String>> distinctList = dataProcessing(path, list);
+        dataLogPo.setDataCount(distinctList.size());
         Path csvPath = toCsv(path, distinctList);
         copyCsv(csvPath);
         move(path);
@@ -105,7 +128,7 @@ public class CarRanYouJob {
      *
      * @param path 文件路径
      */
-    public List<Map<String, String>> readFile(Path path) throws Exception {
+    public List<Map<String, String>> readFile(Path path) throws IOException {
         log.info("读取: {}", path);
         List<String> headers = Stream.of(
                 "data_time_nlsd",
@@ -208,7 +231,7 @@ public class CarRanYouJob {
      * @param path 源文件路径
      * @param list 数据
      */
-    public Path toCsv(Path path, List<Map<String, String>> list) throws Exception {
+    public Path toCsv(Path path, List<Map<String, String>> list) throws IOException {
         log.info("条数:{}", list.size());
         Files.createDirectories(Paths.get(jobConfig.getCarRanYouHistoryPath()));
         Path csvPath = Paths.get(jobConfig.getCarRanYouHistoryPath() + path.getFileName() + ".csv");
@@ -247,7 +270,7 @@ public class CarRanYouJob {
      *
      * @param path 源文件路径
      */
-    public void move(Path path) throws Exception {
+    public void move(Path path) throws IOException {
         if (Files.exists(Paths.get(path + ".MD5"))) {
             Files.move(Paths.get(path + ".MD5"),
                     Paths.get(jobConfig.getCarRanYouHistoryPath(), path.getFileName().toString() + ".MD5"),

+ 5 - 4
src/main/java/com/nokia/finance/tasks/jobs/car/chengben/CarSiCheGongYongJob.java

@@ -7,6 +7,7 @@ import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
+import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -52,10 +53,10 @@ public class CarSiCheGongYongJob {
                 }).get(1, TimeUnit.MINUTES);
             }
         } catch (InterruptedException e) {
-            log.error("线程中断: {}", e.getMessage(), e);
+            log.error("线程中断: {}", e, e);
             Thread.currentThread().interrupt();
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
         }
     }
 
@@ -64,7 +65,7 @@ public class CarSiCheGongYongJob {
      *
      * @param path 文件路径
      */
-    public void singleJob(Path path) throws Exception {
+    public void singleJob(Path path) throws IOException {
         if (Files.size(path) == 0) {
             move(path);
             throw new MyRuntimeException(path.getFileName() + " 空文件");
@@ -77,7 +78,7 @@ public class CarSiCheGongYongJob {
      *
      * @param path 源文件路径
      */
-    public void move(Path path) throws Exception {
+    public void move(Path path) throws IOException {
         if (Files.exists(Paths.get(path + ".MD5"))) {
             Files.move(Paths.get(path + ".MD5"),
                     Paths.get(jobConfig.getCarSiCheGongYongHistoryPath(), path.getFileName().toString() + ".MD5"),

+ 33 - 10
src/main/java/com/nokia/finance/tasks/jobs/car/chengben/CarWeiXiuJob.java

@@ -3,10 +3,13 @@ package com.nokia.finance.tasks.jobs.car.chengben;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.common.utils.psql.PsqlUtil;
 import com.nokia.finance.tasks.config.JobConfig;
+import com.nokia.finance.tasks.enums.DataStageEnum;
 import com.nokia.finance.tasks.pojo.po.common.AreaPo;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
 import com.nokia.finance.tasks.pojo.po.common.OrganizationPo;
 import com.nokia.finance.tasks.service.car.CarService;
 import com.nokia.finance.tasks.service.common.AreaService;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.service.common.OrganizationService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -18,6 +21,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
+import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
 import java.nio.charset.StandardCharsets;
@@ -43,13 +47,15 @@ public class CarWeiXiuJob {
     private final CarService carService;
     private final OrganizationService organizationService;
     private final AreaService areaService;
+    private final DataLogServiceImpl dataLogService;
 
     public CarWeiXiuJob(JobConfig jobConfig, CarService carService, OrganizationService organizationService,
-                        AreaService areaService) {
+                        AreaService areaService, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.carService = carService;
         this.organizationService = organizationService;
         this.areaService = areaService;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -57,6 +63,7 @@ public class CarWeiXiuJob {
      */
     @Scheduled(cron = "0 22 6 12 * ?")
     public void runJob() {
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
         // 数据目录
         Path dir = Paths.get(jobConfig.getCarWeiXiuSourcePath());
         try (Stream<Path> stream = Files.list(dir)) {
@@ -69,32 +76,48 @@ public class CarWeiXiuJob {
             for (Path path : pathList) {
                 CompletableFuture.runAsync(() -> {
                     try {
-                        singleJob(path);
+                        singleJob(path, dataLogPoList);
                     } catch (Exception e) {
                         throw new MyRuntimeException(e);
                     }
                 }).get(1, TimeUnit.MINUTES);
             }
         } catch (InterruptedException e) {
-            log.error("线程中断: {}", e.getMessage(), e);
+            log.error("线程中断: {}", e, e);
             Thread.currentThread().interrupt();
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "河北成本管理系统车辆普通维修数据", DataStageEnum.CC, "入库");
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "河北成本管理系统车辆普通维修数据", DataStageEnum.CC, "入库");
+        } finally {
+            if (!CollectionUtils.isEmpty(dataLogPoList)) {
+                dataLogService.saveBatch(dataLogPoList);
+            }
         }
     }
 
     /**
      * 处理单个文件
      *
-     * @param path 文件路径
+     * @param path          文件路径
+     * @param dataLogPoList 数据处理日志列表
      */
-    public void singleJob(Path path) throws Exception {
-        if (Files.size(path) == 0) {
+    public void singleJob(Path path, List<DataLogPo> dataLogPoList) throws IOException {
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("河北成本管理系统车辆普通维修数据");
+        dataLogPo.setObject(path.getFileName().toString());
+        dataLogPo.setStage(DataStageEnum.CC.value);
+        dataLogPo.setOperationName("入库");
+        long fileSize = Files.size(path);
+        dataLogPo.setDataSize(fileSize);
+        dataLogPoList.add(dataLogPo);
+        if (fileSize == 0) {
             move(path);
             throw new MyRuntimeException(path.getFileName() + " 空文件");
         }
         List<Map<String, String>> list = readFile(path);
         List<Map<String, String>> distinctList = dataProcessing(path, list);
+        dataLogPo.setDataCount(distinctList.size());
         Path csvPath = toCsv(path, distinctList);
         copyCsv(csvPath);
         move(path);
@@ -105,7 +128,7 @@ public class CarWeiXiuJob {
      *
      * @param path 文件路径
      */
-    public List<Map<String, String>> readFile(Path path) throws Exception {
+    public List<Map<String, String>> readFile(Path path) throws IOException {
         log.info("读取: {}", path);
         List<String> headers = Stream.of(
                 "data_time_nlsd",
@@ -207,7 +230,7 @@ public class CarWeiXiuJob {
      * @param path 源文件路径
      * @param list 数据
      */
-    public Path toCsv(Path path, List<Map<String, String>> list) throws Exception {
+    public Path toCsv(Path path, List<Map<String, String>> list) throws IOException {
         log.info("条数:{}", list.size());
         Files.createDirectories(Paths.get(jobConfig.getCarWeiXiuHistoryPath()));
         Path csvPath = Paths.get(jobConfig.getCarWeiXiuHistoryPath() + path.getFileName() + ".csv");
@@ -246,7 +269,7 @@ public class CarWeiXiuJob {
      *
      * @param path 源文件路径
      */
-    public void move(Path path) throws Exception {
+    public void move(Path path) throws IOException {
         if (Files.exists(Paths.get(path + ".MD5"))) {
             Files.move(Paths.get(path + ".MD5"),
                     Paths.get(jobConfig.getCarWeiXiuHistoryPath(), path.getFileName().toString() + ".MD5"),

+ 29 - 7
src/main/java/com/nokia/finance/tasks/jobs/car/cxdp/CarCxdpJob.java

@@ -3,6 +3,9 @@ package com.nokia.finance.tasks.jobs.car.cxdp;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.config.JobConfig;
 import com.nokia.finance.tasks.dao.car.CarCxdpDao;
+import com.nokia.finance.tasks.enums.DataStageEnum;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.utils.FileUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -19,9 +22,11 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CompletableFuture;
 
 /**
  * 车效大屏建设数据定时任务
@@ -31,11 +36,14 @@ import java.util.Map;
 public class CarCxdpJob {
     private final JobConfig jobConfig;
     private final CarCxdpDao carCxdpDao;
+    private final DataLogServiceImpl dataLogService;
 
-    CarCxdpJob(JobConfig jobConfig, CarCxdpDao carCxdpDao) {
+    CarCxdpJob(JobConfig jobConfig, CarCxdpDao carCxdpDao, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.carCxdpDao = carCxdpDao;
+        this.dataLogService = dataLogService;
     }
+
     /**
      * 执行任务
      */
@@ -43,12 +51,18 @@ public class CarCxdpJob {
     @Transactional(timeout = 60, rollbackFor = Exception.class)
     public void runJob() {
         log.info("执行车效大屏建设数据定时任务");
-        LocalDate localDateNow = LocalDate.now();
-        LocalDate localDateEnd = localDateNow.minusMonths(1);
-        LocalDate localDateStart = localDateEnd.withDayOfYear(1);
-        Integer endYearMonth = Integer.valueOf(localDateEnd.format(DateTimeFormatter.ofPattern("yyyyMM")));
-        Integer startYearMonth = Integer.valueOf(localDateStart.format(DateTimeFormatter.ofPattern("yyyyMM")));
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("车效大屏建设数据");
+        dataLogPo.setStage(DataStageEnum.JG.value);
+        dataLogPo.setOperationName("生成车效大屏建设数据");
+        dataLogPoList.add(dataLogPo);
         try {
+            LocalDate localDateNow = LocalDate.now();
+            LocalDate localDateEnd = localDateNow.minusMonths(1);
+            LocalDate localDateStart = localDateEnd.withDayOfYear(1);
+            Integer endYearMonth = Integer.valueOf(localDateEnd.format(DateTimeFormatter.ofPattern("yyyyMM")));
+            Integer startYearMonth = Integer.valueOf(localDateStart.format(DateTimeFormatter.ofPattern("yyyyMM")));
             boolean flag = carCxdpDao.hasCarCxdp(endYearMonth);
             if (!flag) {
                 throw new MyRuntimeException("车效大屏缺少数据");
@@ -83,9 +97,17 @@ public class CarCxdpJob {
             FileUtil.setDefaultFilePermissions(filePath);
             Files.createDirectories(Paths.get(jobConfig.getTempOutputDir()));
             Files.copy(filePath, Paths.get(jobConfig.getTempOutputDir() + filename));
+            long fileSize = Files.size(filePath);
+            dataLogPo.setDataSize(fileSize);
+            dataLogPo.setDataCount(list.size());
+            dataLogPo.setObject(filePath.getFileName().toString());
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            dataLogPo.setStatus(0);
+            dataLogPo.setExceptionInfo(e.toString());
             throw new MyRuntimeException("车效大屏建设数据定时任务失败");
+        } finally {
+            CompletableFuture.runAsync(() -> dataLogService.saveBatch(dataLogPoList));
         }
     }
 }

+ 24 - 3
src/main/java/com/nokia/finance/tasks/jobs/car/procedure/CarBaseDataMonthProcJob.java

@@ -3,6 +3,9 @@ package com.nokia.finance.tasks.jobs.car.procedure;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.dao.car.CarProcedureDao;
 import com.nokia.finance.tasks.dao.gdc.car.GdcCarProcedureDao;
+import com.nokia.finance.tasks.enums.DataStageEnum;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
@@ -10,6 +13,9 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
 
 /**
  * 车辆基本信息月数据加工定时任务
@@ -19,10 +25,13 @@ import java.time.format.DateTimeFormatter;
 public class CarBaseDataMonthProcJob {
     private final CarProcedureDao carProcedureDao;
     private final GdcCarProcedureDao gdcCarProcedureDao;
+    private final DataLogServiceImpl dataLogService;
 
-    public CarBaseDataMonthProcJob(CarProcedureDao carProcedureDao, GdcCarProcedureDao gdcCarProcedureDao) {
+    public CarBaseDataMonthProcJob(CarProcedureDao carProcedureDao, GdcCarProcedureDao gdcCarProcedureDao,
+                                   DataLogServiceImpl dataLogService) {
         this.carProcedureDao = carProcedureDao;
         this.gdcCarProcedureDao = gdcCarProcedureDao;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -31,8 +40,15 @@ public class CarBaseDataMonthProcJob {
     @Scheduled(cron = "0 0 0 7 * ?")
     @Transactional(timeout = 60, rollbackFor = Exception.class)
     public void runJob() {
+        log.info("执行车辆基本信息月数据加工定时任务");
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("车辆基本信息月数据加工");
+        dataLogPo.setStage(DataStageEnum.JG.value);
+        dataLogPo.setOperationName("车辆基本信息月数据加工");
+        dataLogPo.setObject("car.car_base_data_month");
+        dataLogPoList.add(dataLogPo);
         try {
-            log.info("执行车辆基本信息月数据加工定时任务");
             LocalDate localDateNow = LocalDate.now();
             LocalDate localDateEnd = localDateNow.minusMonths(1);
             Integer endYearMonth = Integer.valueOf(localDateEnd.format(DateTimeFormatter.ofPattern("yyyyMM")));
@@ -43,9 +59,14 @@ public class CarBaseDataMonthProcJob {
             if (update1 == 0 || update2 == 0 || update3 == 0) {
                 throw new MyRuntimeException("车辆基本信息月数据加工定时任务失败");
             }
+            dataLogPo.setDataCount(update1);
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            dataLogPo.setStatus(0);
+            dataLogPo.setExceptionInfo(e.toString());
             throw new MyRuntimeException("车辆基本信息月数据加工定时任务失败");
+        } finally {
+            CompletableFuture.runAsync(() -> dataLogService.saveBatch(dataLogPoList));
         }
     }
 }

+ 24 - 3
src/main/java/com/nokia/finance/tasks/jobs/car/procedure/CarFeeProcJob.java

@@ -3,6 +3,9 @@ package com.nokia.finance.tasks.jobs.car.procedure;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.dao.car.CarProcedureDao;
 import com.nokia.finance.tasks.dao.gdc.car.GdcCarProcedureDao;
+import com.nokia.finance.tasks.enums.DataStageEnum;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
@@ -10,6 +13,9 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
 
 /**
  * 车辆费用数据加工定时任务
@@ -19,10 +25,13 @@ import java.time.format.DateTimeFormatter;
 public class CarFeeProcJob {
     private final CarProcedureDao carProcedureDao;
     private final GdcCarProcedureDao gdcCarProcedureDao;
+    private final DataLogServiceImpl dataLogService;
 
-    public CarFeeProcJob(CarProcedureDao carProcedureDao, GdcCarProcedureDao gdcCarProcedureDao) {
+    public CarFeeProcJob(CarProcedureDao carProcedureDao, GdcCarProcedureDao gdcCarProcedureDao,
+                         DataLogServiceImpl dataLogService) {
         this.carProcedureDao = carProcedureDao;
         this.gdcCarProcedureDao = gdcCarProcedureDao;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -31,8 +40,15 @@ public class CarFeeProcJob {
     @Scheduled(cron = "0 2 0 13 * ?")
     @Transactional(timeout = 60, rollbackFor = Exception.class)
     public void runJob() {
+        log.info("执行车辆费用数据加工定时任务");
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("车辆费用数据加工");
+        dataLogPo.setStage(DataStageEnum.JG.value);
+        dataLogPo.setOperationName("车辆费用数据加工");
+        dataLogPo.setObject("car.car_fei_yong_month");
+        dataLogPoList.add(dataLogPo);
         try {
-            log.info("执行车辆费用数据加工定时任务");
             // 当前日期
             LocalDate localDateNow = LocalDate.now();
             // 上个月1号
@@ -66,9 +82,14 @@ public class CarFeeProcJob {
             if (update1 == 0 || update2 == 0 || update3 == 0) {
                 throw new MyRuntimeException("车辆费用数据加工定时任务失败");
             }
+            dataLogPo.setDataCount(update1);
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            dataLogPo.setStatus(0);
+            dataLogPo.setExceptionInfo(e.toString());
             throw new MyRuntimeException("车辆费用数据加工定时任务失败");
+        } finally {
+            CompletableFuture.runAsync(() -> dataLogService.saveBatch(dataLogPoList));
         }
     }
 }

+ 23 - 3
src/main/java/com/nokia/finance/tasks/jobs/car/procedure/CarLiChengMonthProcJob.java

@@ -2,6 +2,9 @@ package com.nokia.finance.tasks.jobs.car.procedure;
 
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.dao.car.CarProcedureDao;
+import com.nokia.finance.tasks.enums.DataStageEnum;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
@@ -9,6 +12,9 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
 
 /**
  * 车辆行驶里程月数据加工定时任务
@@ -17,9 +23,11 @@ import java.time.format.DateTimeFormatter;
 @Service
 public class CarLiChengMonthProcJob {
     private final CarProcedureDao carProcedureDao;
+    private final DataLogServiceImpl dataLogService;
 
-    public CarLiChengMonthProcJob(CarProcedureDao carProcedureDao) {
+    public CarLiChengMonthProcJob(CarProcedureDao carProcedureDao, DataLogServiceImpl dataLogService) {
         this.carProcedureDao = carProcedureDao;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -28,8 +36,15 @@ public class CarLiChengMonthProcJob {
     @Scheduled(cron = "0 2 0 7 * ?")
     @Transactional(timeout = 60, rollbackFor = Exception.class)
     public void runJob() {
+        log.info("执行车辆行驶里程月数据加工定时任务");
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("车辆行驶里程月数据加工");
+        dataLogPo.setStage(DataStageEnum.JG.value);
+        dataLogPo.setOperationName("车辆行驶里程月数据加工");
+        dataLogPo.setObject("car.car_li_cheng_month");
+        dataLogPoList.add(dataLogPo);
         try {
-            log.info("执行车辆行驶里程月数据加工定时任务");
             // 当前日期
             LocalDate localDateNow = LocalDate.now();
             // 上个月1号
@@ -49,9 +64,14 @@ public class CarLiChengMonthProcJob {
             if (update1 == 0 || update2 == 0 || update3 == 0 || update4 == 0 || update5 == 0) {
                 throw new MyRuntimeException("车辆行驶里程月数据加工定时任务失败");
             }
+            dataLogPo.setDataCount(update1);
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            dataLogPo.setStatus(0);
+            dataLogPo.setExceptionInfo(e.toString());
             throw new MyRuntimeException("车辆行驶里程月数据加工定时任务失败");
+        } finally {
+            CompletableFuture.runAsync(() -> dataLogService.saveBatch(dataLogPoList));
         }
     }
 }

+ 25 - 4
src/main/java/com/nokia/finance/tasks/jobs/car/procedure/CarPaiDanProcJob.java

@@ -3,6 +3,9 @@ package com.nokia.finance.tasks.jobs.car.procedure;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.dao.car.CarProcedureDao;
 import com.nokia.finance.tasks.dao.gdc.car.GdcCarProcedureDao;
+import com.nokia.finance.tasks.enums.DataStageEnum;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
@@ -10,6 +13,9 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
 
 /**
  * 车辆派单数据加工定时任务
@@ -19,10 +25,13 @@ import java.time.format.DateTimeFormatter;
 public class CarPaiDanProcJob {
     private final CarProcedureDao carProcedureDao;
     private final GdcCarProcedureDao gdcCarProcedureDao;
+    private final DataLogServiceImpl dataLogService;
 
-    public CarPaiDanProcJob(CarProcedureDao carProcedureDao, GdcCarProcedureDao gdcCarProcedureDao) {
+    public CarPaiDanProcJob(CarProcedureDao carProcedureDao, GdcCarProcedureDao gdcCarProcedureDao,
+                            DataLogServiceImpl dataLogService) {
         this.carProcedureDao = carProcedureDao;
         this.gdcCarProcedureDao = gdcCarProcedureDao;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -31,8 +40,15 @@ public class CarPaiDanProcJob {
     @Scheduled(cron = "0 4 0 7 * ?")
     @Transactional(timeout = 60, rollbackFor = Exception.class)
     public void runJob() {
+        log.info("执行车辆派单数据加工定时任务");
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("车辆派单数据加工");
+        dataLogPo.setStage(DataStageEnum.JG.value);
+        dataLogPo.setOperationName("车辆派单数据加工");
+        dataLogPo.setObject("car.car_wei_gui");
+        dataLogPoList.add(dataLogPo);
         try {
-            log.info("执行车辆派单数据加工定时任务");
             // 当前日期
             LocalDate localDateNow = LocalDate.now();
             // 上个月1号
@@ -47,13 +63,18 @@ public class CarPaiDanProcJob {
             if (!flag) {
                 throw new MyRuntimeException("没有车辆基本信息、用车数据");
             }
-            carProcedureDao.insertCarWeiGui(endYearMonth);
+            int update1 = carProcedureDao.insertCarWeiGui(endYearMonth);
             gdcCarProcedureDao.insertCarWeiGui(endYearMonth);
             gdcCarProcedureDao.insertCarWuDanYongCheBaoJing(endYearMonth);
             gdcCarProcedureDao.insertCarWuPaiDanYueJieTongJi(startYearMonth, endYearMonth);
+            dataLogPo.setDataCount(update1);
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            dataLogPo.setStatus(0);
+            dataLogPo.setExceptionInfo(e.toString());
             throw new MyRuntimeException("车辆派单数据加工定时任务失败");
+        } finally {
+            CompletableFuture.runAsync(() -> dataLogService.saveBatch(dataLogPoList));
         }
     }
 }

+ 33 - 10
src/main/java/com/nokia/finance/tasks/jobs/car/ruixing/CarBaoFeiJob.java

@@ -3,10 +3,13 @@ package com.nokia.finance.tasks.jobs.car.ruixing;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.common.utils.psql.PsqlUtil;
 import com.nokia.finance.tasks.config.JobConfig;
+import com.nokia.finance.tasks.enums.DataStageEnum;
 import com.nokia.finance.tasks.pojo.po.common.AreaPo;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
 import com.nokia.finance.tasks.pojo.po.common.OrganizationPo;
 import com.nokia.finance.tasks.service.car.CarService;
 import com.nokia.finance.tasks.service.common.AreaService;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.service.common.OrganizationService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -22,6 +25,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStreamWriter;
 import java.nio.charset.StandardCharsets;
@@ -53,13 +57,15 @@ public class CarBaoFeiJob {
     private final CarService carService;
     private final OrganizationService organizationService;
     private final AreaService areaService;
+    private final DataLogServiceImpl dataLogService;
 
     public CarBaoFeiJob(JobConfig jobConfig, CarService carService, OrganizationService organizationService,
-                        AreaService areaService) {
+                        AreaService areaService, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.carService = carService;
         this.organizationService = organizationService;
         this.areaService = areaService;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -67,6 +73,7 @@ public class CarBaoFeiJob {
      */
     @Scheduled(cron = "0 0 5 1 * ?")
     public void runJob() {
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
         // 数据目录
         Path dir = Paths.get(jobConfig.getCarBaoFeiSourcePath());
         try (Stream<Path> stream = Files.list(dir)) {
@@ -79,32 +86,48 @@ public class CarBaoFeiJob {
             for (Path path : pathList) {
                 CompletableFuture.runAsync(() -> {
                     try {
-                        singleJob(path);
+                        singleJob(path, dataLogPoList);
                     } catch (Exception e) {
                         throw new MyRuntimeException(e);
                     }
                 }).get(1, TimeUnit.MINUTES);
             }
         } catch (InterruptedException e) {
-            log.error("线程中断: {}", e.getMessage(), e);
+            log.error("线程中断: {}", e, e);
             Thread.currentThread().interrupt();
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "睿行车辆报废月数据", DataStageEnum.CC, "入库");
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "睿行车辆报废月数据", DataStageEnum.CC, "入库");
+        } finally {
+            if (!CollectionUtils.isEmpty(dataLogPoList)) {
+                dataLogService.saveBatch(dataLogPoList);
+            }
         }
     }
 
     /**
      * 处理单个文件
      *
-     * @param path 文件路径
+     * @param path          文件路径
+     * @param dataLogPoList 数据处理日志列表
      */
-    public void singleJob(Path path) throws Exception {
-        if (Files.size(path) == 0) {
+    public void singleJob(Path path, List<DataLogPo> dataLogPoList) throws IOException {
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("睿行车辆报废月数据");
+        dataLogPo.setObject(path.getFileName().toString());
+        dataLogPo.setStage(DataStageEnum.CC.value);
+        dataLogPo.setOperationName("入库");
+        long fileSize = Files.size(path);
+        dataLogPo.setDataSize(fileSize);
+        dataLogPoList.add(dataLogPo);
+        if (fileSize == 0) {
             move(path);
             throw new MyRuntimeException(path.getFileName() + " 空文件");
         }
         List<Map<String, String>> list = readFile(path);
         List<Map<String, String>> distinctList = dataProcessing(path, list);
+        dataLogPo.setDataCount(distinctList.size());
         Path csvPath = toCsv(path, distinctList);
         copyCsv(csvPath);
         move(path);
@@ -115,7 +138,7 @@ public class CarBaoFeiJob {
      *
      * @param path 文件路径
      */
-    public List<Map<String, String>> readFile(Path path) throws Exception {
+    public List<Map<String, String>> readFile(Path path) throws IOException {
         log.info("读取: {}", path);
         List<String> rawHeaders = Stream.of("车牌号码", "车辆所属单位", "报废类型", "报废标准", "报废日期",
                 "行驶公里数(Km)", "备注", "资产编号", "资产名称", "规格型号", "实际使用年限", "资产原值(万元)",
@@ -274,7 +297,7 @@ public class CarBaoFeiJob {
      * @param path 源文件路径
      * @param list 数据
      */
-    public Path toCsv(Path path, List<Map<String, String>> list) throws Exception {
+    public Path toCsv(Path path, List<Map<String, String>> list) throws IOException {
         log.info("去重后条数:{}", list.size());
         Files.createDirectories(Paths.get(jobConfig.getCarBaoFeiHistoryPath()));
         Path csvPath = Paths.get(jobConfig.getCarBaoFeiHistoryPath() + path.getFileName() + ".csv");
@@ -313,7 +336,7 @@ public class CarBaoFeiJob {
      *
      * @param path 源文件路径
      */
-    public void move(Path path) throws Exception {
+    public void move(Path path) throws IOException {
         Path targetPath = Paths.get(jobConfig.getCarBaoFeiHistoryPath(), path.getFileName().toString());
         Files.move(path, targetPath, StandardCopyOption.REPLACE_EXISTING);
     }

+ 33 - 10
src/main/java/com/nokia/finance/tasks/jobs/car/ruixing/CarBaseDataDayJob.java

@@ -3,10 +3,13 @@ package com.nokia.finance.tasks.jobs.car.ruixing;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.common.utils.psql.PsqlUtil;
 import com.nokia.finance.tasks.config.JobConfig;
+import com.nokia.finance.tasks.enums.DataStageEnum;
 import com.nokia.finance.tasks.pojo.po.common.AreaPo;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
 import com.nokia.finance.tasks.pojo.po.common.OrganizationPo;
 import com.nokia.finance.tasks.service.car.CarService;
 import com.nokia.finance.tasks.service.common.AreaService;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.service.common.OrganizationService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -22,6 +25,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStreamWriter;
 import java.math.BigDecimal;
@@ -58,13 +62,15 @@ public class CarBaseDataDayJob {
     private final CarService carService;
     private final OrganizationService organizationService;
     private final AreaService areaService;
+    private final DataLogServiceImpl dataLogService;
 
     public CarBaseDataDayJob(JobConfig jobConfig, CarService carService, OrganizationService organizationService,
-                             AreaService areaService) {
+                             AreaService areaService, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.carService = carService;
         this.organizationService = organizationService;
         this.areaService = areaService;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -72,6 +78,7 @@ public class CarBaseDataDayJob {
      */
     @Scheduled(cron = "0 56 23 * * ?")
     public void runJob() {
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
         // 数据目录
         Path dir = Paths.get(jobConfig.getCarBaseDataDaySourcePath());
         try (Stream<Path> stream = Files.list(dir)) {
@@ -84,32 +91,48 @@ public class CarBaseDataDayJob {
             for (Path path : pathList) {
                 CompletableFuture.runAsync(() -> {
                     try {
-                        singleJob(path);
+                        singleJob(path, dataLogPoList);
                     } catch (Exception e) {
                         throw new MyRuntimeException(e);
                     }
                 }).get(1, TimeUnit.MINUTES);
             }
         } catch (InterruptedException e) {
-            log.error("线程中断: {}", e.getMessage(), e);
+            log.error("线程中断: {}", e, e);
             Thread.currentThread().interrupt();
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "睿行车辆基本信息日数据", DataStageEnum.CC, "入库");
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "睿行车辆基本信息日数据", DataStageEnum.CC, "入库");
+        } finally {
+            if (!CollectionUtils.isEmpty(dataLogPoList)) {
+                dataLogService.saveBatch(dataLogPoList);
+            }
         }
     }
 
     /**
      * 处理单个文件
      *
-     * @param path 文件路径
+     * @param path          文件路径
+     * @param dataLogPoList 数据处理日志列表
      */
-    public void singleJob(Path path) throws Exception {
-        if (Files.size(path) == 0) {
+    public void singleJob(Path path, List<DataLogPo> dataLogPoList) throws IOException {
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("睿行车辆基本信息日数据");
+        dataLogPo.setObject(path.getFileName().toString());
+        dataLogPo.setStage(DataStageEnum.CC.value);
+        dataLogPo.setOperationName("入库");
+        long fileSize = Files.size(path);
+        dataLogPo.setDataSize(fileSize);
+        dataLogPoList.add(dataLogPo);
+        if (fileSize == 0) {
             move(path);
             throw new MyRuntimeException(path.getFileName() + " 空文件");
         }
         List<Map<String, String>> list = readFile(path);
         List<Map<String, String>> distinctList = dataProcessing(path, list);
+        dataLogPo.setDataCount(distinctList.size());
         Path csvPath = toCsv(path, distinctList);
         copyCsv(csvPath);
         move(path);
@@ -120,7 +143,7 @@ public class CarBaseDataDayJob {
      *
      * @param path 文件路径
      */
-    public List<Map<String, String>> readFile(Path path) throws Exception {
+    public List<Map<String, String>> readFile(Path path) throws IOException {
         log.info("读取: {}", path);
         List<String> rawHeaders = Stream.of("车牌号", "车辆品牌", "排量", "排量类型", "燃油类型", "燃油标号",
                 "登记日期", "车辆来源", "车辆类型", "车辆使用性质", "环保等级", "用车模式", "发动机号", "车架号", "初始里程",
@@ -305,7 +328,7 @@ public class CarBaseDataDayJob {
      * @param path 源文件路径
      * @param list 数据
      */
-    public Path toCsv(Path path, List<Map<String, String>> list) throws Exception {
+    public Path toCsv(Path path, List<Map<String, String>> list) throws IOException {
         log.info("去重后条数:{}", list.size());
         Files.createDirectories(Paths.get(jobConfig.getCarBaseDataDayHistoryPath()));
         Path csvPath = Paths.get(jobConfig.getCarBaseDataDayHistoryPath() + path.getFileName() + ".csv");
@@ -342,7 +365,7 @@ public class CarBaseDataDayJob {
      * 移动源文件到历史文件夹
      * @param path 源文件路径
      */
-    public void move(Path path) throws Exception {
+    public void move(Path path) throws IOException {
         Path targetPath = Paths.get(jobConfig.getCarBaseDataDayHistoryPath(), path.getFileName().toString());
         Files.move(path, targetPath, StandardCopyOption.REPLACE_EXISTING);
     }

+ 33 - 10
src/main/java/com/nokia/finance/tasks/jobs/car/ruixing/CarLiChengDayJob.java

@@ -3,10 +3,13 @@ package com.nokia.finance.tasks.jobs.car.ruixing;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.common.utils.psql.PsqlUtil;
 import com.nokia.finance.tasks.config.JobConfig;
+import com.nokia.finance.tasks.enums.DataStageEnum;
 import com.nokia.finance.tasks.pojo.po.common.AreaPo;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
 import com.nokia.finance.tasks.pojo.po.common.OrganizationPo;
 import com.nokia.finance.tasks.service.car.CarService;
 import com.nokia.finance.tasks.service.common.AreaService;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.service.common.OrganizationService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -22,6 +25,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStreamWriter;
 import java.nio.charset.StandardCharsets;
@@ -53,13 +57,15 @@ public class CarLiChengDayJob {
     private final CarService carService;
     private final OrganizationService organizationService;
     private final AreaService areaService;
+    private final DataLogServiceImpl dataLogService;
 
     public CarLiChengDayJob(JobConfig jobConfig, CarService carService, OrganizationService organizationService,
-                            AreaService areaService) {
+                            AreaService areaService, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.carService = carService;
         this.organizationService = organizationService;
         this.areaService = areaService;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -67,6 +73,7 @@ public class CarLiChengDayJob {
      */
     @Scheduled(cron = "0 48 5 * * ?")
     public void runJob() {
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
         // 数据目录
         Path dir = Paths.get(jobConfig.getCarLiChengDaySourcePath());
         try (Stream<Path> stream = Files.list(dir)) {
@@ -79,32 +86,48 @@ public class CarLiChengDayJob {
             for (Path path : pathList) {
                 CompletableFuture.runAsync(() -> {
                     try {
-                        singleJob(path);
+                        singleJob(path, dataLogPoList);
                     } catch (Exception e) {
                         throw new MyRuntimeException(e);
                     }
                 }).get(1, TimeUnit.MINUTES);
             }
         } catch (InterruptedException e) {
-            log.error("线程中断: {}", e.getMessage(), e);
+            log.error("线程中断: {}", e, e);
             Thread.currentThread().interrupt();
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "睿行车辆行驶里程日数据", DataStageEnum.CC, "入库");
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "睿行车辆行驶里程日数据", DataStageEnum.CC, "入库");
+        } finally {
+            if (!CollectionUtils.isEmpty(dataLogPoList)) {
+                dataLogService.saveBatch(dataLogPoList);
+            }
         }
     }
 
     /**
      * 处理单个文件
      *
-     * @param path 文件路径
+     * @param path          文件路径
+     * @param dataLogPoList 数据处理日志列表
      */
-    public void singleJob(Path path) throws Exception {
-        if (Files.size(path) == 0) {
+    public void singleJob(Path path, List<DataLogPo> dataLogPoList) throws IOException {
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("睿行车辆行驶里程日数据");
+        dataLogPo.setObject(path.getFileName().toString());
+        dataLogPo.setStage(DataStageEnum.CC.value);
+        dataLogPo.setOperationName("入库");
+        long fileSize = Files.size(path);
+        dataLogPo.setDataSize(fileSize);
+        dataLogPoList.add(dataLogPo);
+        if (fileSize == 0) {
             move(path);
             throw new MyRuntimeException(path.getFileName() + " 空文件");
         }
         List<Map<String, String>> list = readFile(path);
         List<Map<String, String>> distinctList = dataProcessing(path, list);
+        dataLogPo.setDataCount(distinctList.size());
         Path csvPath = toCsv(path, distinctList);
         copyCsv(csvPath);
         move(path);
@@ -115,7 +138,7 @@ public class CarLiChengDayJob {
      *
      * @param path 文件路径
      */
-    public List<Map<String, String>> readFile(Path path) throws Exception {
+    public List<Map<String, String>> readFile(Path path) throws IOException {
         log.info("读取: {}", path);
         List<String> rawHeaders = Stream.of("车辆所属单位", "车牌号码", "车辆类型", "车辆来源", "车辆使用性质",
                 "行驶时长(小时)", "行驶天数", "总里程(公里)", "OBD总油耗(升)", "百公里油耗(升)", "日期").toList();
@@ -275,7 +298,7 @@ public class CarLiChengDayJob {
      * @param path 源文件路径
      * @param list 数据
      */
-    public Path toCsv(Path path, List<Map<String, String>> list) throws Exception {
+    public Path toCsv(Path path, List<Map<String, String>> list) throws IOException {
         log.info("去重后条数:{}", list.size());
         Files.createDirectories(Paths.get(jobConfig.getCarLiChengDayHistoryPath()));
         Path csvPath = Paths.get(jobConfig.getCarLiChengDayHistoryPath() + path.getFileName() + ".csv");
@@ -314,7 +337,7 @@ public class CarLiChengDayJob {
      *
      * @param path 源文件路径
      */
-    public void move(Path path) throws Exception {
+    public void move(Path path) throws IOException {
         Path targetPath = Paths.get(jobConfig.getCarLiChengDayHistoryPath(), path.getFileName().toString());
         Files.move(path, targetPath, StandardCopyOption.REPLACE_EXISTING);
     }

+ 37 - 14
src/main/java/com/nokia/finance/tasks/jobs/car/ruixing/CarLiChengMonthJob.java

@@ -3,10 +3,13 @@ package com.nokia.finance.tasks.jobs.car.ruixing;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.common.utils.psql.PsqlUtil;
 import com.nokia.finance.tasks.config.JobConfig;
+import com.nokia.finance.tasks.enums.DataStageEnum;
 import com.nokia.finance.tasks.pojo.po.common.AreaPo;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
 import com.nokia.finance.tasks.pojo.po.common.OrganizationPo;
 import com.nokia.finance.tasks.service.car.CarService;
 import com.nokia.finance.tasks.service.common.AreaService;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.service.common.OrganizationService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -22,6 +25,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStreamWriter;
 import java.nio.charset.StandardCharsets;
@@ -55,13 +59,15 @@ public class CarLiChengMonthJob {
     private final CarService carService;
     private final OrganizationService organizationService;
     private final AreaService areaService;
+    private final DataLogServiceImpl dataLogService;
 
     public CarLiChengMonthJob(JobConfig jobConfig, CarService carService, OrganizationService organizationService,
-                              AreaService areaService) {
+                              AreaService areaService, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.carService = carService;
         this.organizationService = organizationService;
         this.areaService = areaService;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -69,6 +75,7 @@ public class CarLiChengMonthJob {
      */
     @Scheduled(cron = "0 54 5 1 * ?")
     public void runJob() {
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
         // 数据目录
         Path dir = Paths.get(jobConfig.getCarLiChengMonthSourcePath());
         try (Stream<Path> stream = Files.list(dir)) {
@@ -81,26 +88,45 @@ public class CarLiChengMonthJob {
             for (Path path : pathList) {
                 CompletableFuture.runAsync(() -> {
                     try {
-                        singleJob(path);
+                        singleJob(path, dataLogPoList);
                     } catch (Exception e) {
                         throw new MyRuntimeException(e);
                     }
                 }).get(1, TimeUnit.MINUTES);
             }
         } catch (InterruptedException e) {
-            log.error("线程中断: {}", e.getMessage(), e);
+            log.error("线程中断: {}", e, e);
             Thread.currentThread().interrupt();
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "睿行车辆行驶里程月数据", DataStageEnum.CC, "入库");
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "睿行车辆行驶里程月数据", DataStageEnum.CC, "入库");
+        } finally {
+            if (!CollectionUtils.isEmpty(dataLogPoList)) {
+                dataLogService.saveBatch(dataLogPoList);
+            }
         }
     }
 
     /**
      * 处理单个文件
      *
-     * @param path 文件路径
+     * @param path          文件路径
+     * @param dataLogPoList 数据处理日志列表
      */
-    public void singleJob(Path path) throws Exception {
+    public void singleJob(Path path, List<DataLogPo> dataLogPoList) throws IOException {
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("睿行车辆行驶里程日数据");
+        dataLogPo.setObject(path.getFileName().toString());
+        dataLogPo.setStage(DataStageEnum.CC.value);
+        dataLogPo.setOperationName("入库");
+        long fileSize = Files.size(path);
+        dataLogPo.setDataSize(fileSize);
+        dataLogPoList.add(dataLogPo);
+        if (fileSize == 0) {
+            move(path);
+            throw new MyRuntimeException(path.getFileName() + " 空文件");
+        }
         // 从文件名提取日期
         String regex = "\\d{6}";
         Pattern pattern = Pattern.compile(regex);
@@ -111,12 +137,9 @@ public class CarLiChengMonthJob {
         } else {
             throw new MyRuntimeException(path.getFileName() + " 提取日期失败");
         }
-        if (Files.size(path) == 0) {
-            move(path);
-            throw new MyRuntimeException(path.getFileName() + " 空文件");
-        }
         List<Map<String, String>> list = readFile(path);
         List<Map<String, String>> distinctList = dataProcessing(path, list, dateString);
+        dataLogPo.setDataCount(distinctList.size());
         Path csvPath = toCsv(path, distinctList);
         copyCsv(csvPath);
         move(path);
@@ -127,7 +150,7 @@ public class CarLiChengMonthJob {
      *
      * @param path 文件路径
      */
-    public List<Map<String, String>> readFile(Path path) throws Exception {
+    public List<Map<String, String>> readFile(Path path) throws IOException {
         log.info("读取: {}", path);
         List<String> rawHeaders = Stream.of("车牌号码", "车辆所属单位", "车辆类型", "车辆来源", "车辆使用性质",
                 "行驶时长(小时)", "行驶天数", "总里程(公里)", "OBD总油耗(升)", "百公里油耗(升)").toList();
@@ -185,7 +208,7 @@ public class CarLiChengMonthJob {
                         case NUMERIC:
                             if (DateUtil.isCellDateFormatted(cell)) {
                                 cellValue = DateUtil.getLocalDateTime(cell.getNumericCellValue())
-                                        .format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"));
+                                        .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
                                 break;
                             }
                             cellValue = String.valueOf(cell.getNumericCellValue());
@@ -292,7 +315,7 @@ public class CarLiChengMonthJob {
      * @param path 源文件路径
      * @param list 数据
      */
-    public Path toCsv(Path path, List<Map<String, String>> list) throws Exception {
+    public Path toCsv(Path path, List<Map<String, String>> list) throws IOException {
         log.info("去重后条数:{}", list.size());
         Files.createDirectories(Paths.get(jobConfig.getCarLiChengMonthHistoryPath()));
         Path csvPath = Paths.get(jobConfig.getCarLiChengMonthHistoryPath() + path.getFileName() + ".csv");
@@ -331,7 +354,7 @@ public class CarLiChengMonthJob {
      *
      * @param path 源文件路径
      */
-    public void move(Path path) throws Exception {
+    public void move(Path path) throws IOException {
         Path targetPath = Paths.get(jobConfig.getCarLiChengMonthHistoryPath(), path.getFileName().toString());
         Files.move(path, targetPath, StandardCopyOption.REPLACE_EXISTING);
     }

+ 34 - 11
src/main/java/com/nokia/finance/tasks/jobs/car/ruixing/CarWuDanYongCheJob.java

@@ -3,10 +3,13 @@ package com.nokia.finance.tasks.jobs.car.ruixing;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.common.utils.psql.PsqlUtil;
 import com.nokia.finance.tasks.config.JobConfig;
+import com.nokia.finance.tasks.enums.DataStageEnum;
 import com.nokia.finance.tasks.pojo.po.common.AreaPo;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
 import com.nokia.finance.tasks.pojo.po.common.OrganizationPo;
 import com.nokia.finance.tasks.service.car.CarService;
 import com.nokia.finance.tasks.service.common.AreaService;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.service.common.OrganizationService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -22,6 +25,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStreamWriter;
 import java.nio.charset.StandardCharsets;
@@ -53,13 +57,15 @@ public class CarWuDanYongCheJob {
     private final CarService carService;
     private final OrganizationService organizationService;
     private final AreaService areaService;
+    private final DataLogServiceImpl dataLogService;
 
     public CarWuDanYongCheJob(JobConfig jobConfig, CarService carService, OrganizationService organizationService,
-                              AreaService areaService) {
+                              AreaService areaService, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.carService = carService;
         this.organizationService = organizationService;
         this.areaService = areaService;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -67,6 +73,7 @@ public class CarWuDanYongCheJob {
      */
     @Scheduled(cron = "0 56 5 1 * ?")
     public void runJob() {
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
         // 数据目录
         Path dir = Paths.get(jobConfig.getCarWuDanYongCheSourcePath());
         try (Stream<Path> stream = Files.list(dir)) {
@@ -79,32 +86,48 @@ public class CarWuDanYongCheJob {
             for (Path path : pathList) {
                 CompletableFuture.runAsync(() -> {
                     try {
-                        singleJob(path);
+                        singleJob(path, dataLogPoList);
                     } catch (Exception e) {
                         throw new MyRuntimeException(e);
                     }
                 }).get(1, TimeUnit.MINUTES);
             }
         } catch (InterruptedException e) {
-            log.error("线程中断: {}", e.getMessage(), e);
+            log.error("线程中断: {}", e, e);
             Thread.currentThread().interrupt();
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "睿行车辆无单用车报警月统计数据", DataStageEnum.CC, "入库");
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "睿行车辆无单用车报警月统计数据", DataStageEnum.CC, "入库");
+        } finally {
+            if (!CollectionUtils.isEmpty(dataLogPoList)) {
+                dataLogService.saveBatch(dataLogPoList);
+            }
         }
     }
 
     /**
      * 处理单个文件
      *
-     * @param path 文件路径
+     * @param path          文件路径
+     * @param dataLogPoList 数据处理日志列表
      */
-    public void singleJob(Path path) throws Exception {
-        if (Files.size(path) == 0) {
+    public void singleJob(Path path, List<DataLogPo> dataLogPoList) throws IOException {
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("睿行车辆无单用车报警月统计数据");
+        dataLogPo.setObject(path.getFileName().toString());
+        dataLogPo.setStage(DataStageEnum.CC.value);
+        dataLogPo.setOperationName("入库");
+        long fileSize = Files.size(path);
+        dataLogPo.setDataSize(fileSize);
+        dataLogPoList.add(dataLogPo);
+        if (fileSize == 0) {
             move(path);
             throw new MyRuntimeException(path.getFileName() + " 空文件");
         }
         List<Map<String, String>> list = readFile(path);
         List<Map<String, String>> distinctList = dataProcessing(path, list);
+        dataLogPo.setDataCount(distinctList.size());
         Path csvPath = toCsv(path, distinctList);
         copyCsv(csvPath);
         move(path);
@@ -115,7 +138,7 @@ public class CarWuDanYongCheJob {
      *
      * @param path 文件路径
      */
-    public List<Map<String, String>> readFile(Path path) throws Exception {
+    public List<Map<String, String>> readFile(Path path) throws IOException {
         log.info("读取: {}", path);
         List<String> rawHeaders = Stream.of("车辆所属单位", "车牌号码", "违规开始时间", "违规结束时间",
                 "违规持续时间(分)").toList();
@@ -176,7 +199,7 @@ public class CarWuDanYongCheJob {
                         case NUMERIC:
                             if (DateUtil.isCellDateFormatted(cell)) {
                                 cellValue = DateUtil.getLocalDateTime(cell.getNumericCellValue())
-                                        .format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"));
+                                        .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
                                 break;
                             }
                             cellValue = String.valueOf(cell.getNumericCellValue());
@@ -278,7 +301,7 @@ public class CarWuDanYongCheJob {
      * @param path 源文件路径
      * @param list 数据
      */
-    public Path toCsv(Path path, List<Map<String, String>> list) throws Exception {
+    public Path toCsv(Path path, List<Map<String, String>> list) throws IOException {
         log.info("去重后条数:{}", list.size());
         Files.createDirectories(Paths.get(jobConfig.getCarWuDanYongCheHistoryPath()));
         Path csvPath = Paths.get(jobConfig.getCarWuDanYongCheHistoryPath() + path.getFileName() + ".csv");
@@ -317,7 +340,7 @@ public class CarWuDanYongCheJob {
      *
      * @param path 源文件路径
      */
-    public void move(Path path) throws Exception {
+    public void move(Path path) throws IOException {
         Path targetPath = Paths.get(jobConfig.getCarWuDanYongCheHistoryPath(), path.getFileName().toString());
         Files.move(path, targetPath, StandardCopyOption.REPLACE_EXISTING);
     }

+ 37 - 14
src/main/java/com/nokia/finance/tasks/jobs/car/ruixing/CarYongCheJob.java

@@ -3,10 +3,13 @@ package com.nokia.finance.tasks.jobs.car.ruixing;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.common.utils.psql.PsqlUtil;
 import com.nokia.finance.tasks.config.JobConfig;
+import com.nokia.finance.tasks.enums.DataStageEnum;
 import com.nokia.finance.tasks.pojo.po.common.AreaPo;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
 import com.nokia.finance.tasks.pojo.po.common.OrganizationPo;
 import com.nokia.finance.tasks.service.car.CarService;
 import com.nokia.finance.tasks.service.common.AreaService;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.service.common.OrganizationService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -22,6 +25,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStreamWriter;
 import java.nio.charset.StandardCharsets;
@@ -52,13 +56,15 @@ public class CarYongCheJob {
     private final CarService carService;
     private final OrganizationService organizationService;
     private final AreaService areaService;
+    private final DataLogServiceImpl dataLogService;
 
     public CarYongCheJob(JobConfig jobConfig, CarService carService, OrganizationService organizationService,
-                         AreaService areaService) {
+                         AreaService areaService, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.carService = carService;
         this.organizationService = organizationService;
         this.areaService = areaService;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -66,6 +72,7 @@ public class CarYongCheJob {
      */
     @Scheduled(cron = "0 58 5 1 * ?")
     public void runJob() {
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
         // 数据目录
         Path dir = Paths.get(jobConfig.getCarYongCheSourcePath());
         try (Stream<Path> stream = Files.list(dir)) {
@@ -78,26 +85,45 @@ public class CarYongCheJob {
             for (Path path : pathList) {
                 CompletableFuture.runAsync(() -> {
                     try {
-                        singleJob(path);
+                        singleJob(path, dataLogPoList);
                     } catch (Exception e) {
                         throw new MyRuntimeException(e);
                     }
                 }).get(1, TimeUnit.MINUTES);
             }
         } catch (InterruptedException e) {
-            log.error("线程中断: {}", e.getMessage(), e);
+            log.error("线程中断: {}", e, e);
             Thread.currentThread().interrupt();
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "睿行车辆用车月统计数据", DataStageEnum.CC, "入库");
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "睿行车辆用车月统计数据", DataStageEnum.CC, "入库");
+        } finally {
+            if (!CollectionUtils.isEmpty(dataLogPoList)) {
+                dataLogService.saveBatch(dataLogPoList);
+            }
         }
     }
 
     /**
      * 处理单个文件
      *
-     * @param path 文件路径
+     * @param path          文件路径
+     * @param dataLogPoList 数据处理日志列表
      */
-    public void singleJob(Path path) throws Exception {
+    public void singleJob(Path path, List<DataLogPo> dataLogPoList) throws IOException {
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("睿行车辆用车月统计数据");
+        dataLogPo.setObject(path.getFileName().toString());
+        dataLogPo.setStage(DataStageEnum.CC.value);
+        dataLogPo.setOperationName("入库");
+        long fileSize = Files.size(path);
+        dataLogPo.setDataSize(fileSize);
+        dataLogPoList.add(dataLogPo);
+        if (fileSize == 0) {
+            move(path);
+            throw new MyRuntimeException(path.getFileName() + " 空文件");
+        }
         // 从文件名提取日期
         String regex = "\\d{6}";
         Pattern pattern = Pattern.compile(regex);
@@ -108,12 +134,9 @@ public class CarYongCheJob {
         } else {
             throw new MyRuntimeException(path.getFileName() + " 提取日期失败");
         }
-        if (Files.size(path) == 0) {
-            move(path);
-            throw new MyRuntimeException(path.getFileName() + " 空文件");
-        }
         List<Map<String, String>> list = readFile(path);
         List<Map<String, String>> distinctList = dataProcessing(path, list, dateString);
+        dataLogPo.setDataCount(distinctList.size());
         Path csvPath = toCsv(path, distinctList);
         copyCsv(csvPath);
         move(path);
@@ -124,7 +147,7 @@ public class CarYongCheJob {
      *
      * @param path 文件路径
      */
-    public List<Map<String, String>> readFile(Path path) throws Exception {
+    public List<Map<String, String>> readFile(Path path) throws IOException {
         log.info("读取: {}", path);
         List<String> rawHeaders = Stream.of("申请单号", "派遣单号", "申请类型", "车牌号", "车辆类型", "车辆级别",
                 "司机名称", "用车人", "用车部门", "用车事由", "出发地", "目的地", "出发时间", "归队时间", "行驶里程", "出车时长")
@@ -206,7 +229,7 @@ public class CarYongCheJob {
                         case NUMERIC:
                             if (DateUtil.isCellDateFormatted(cell)) {
                                 cellValue = DateUtil.getLocalDateTime(cell.getNumericCellValue())
-                                        .format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"));
+                                        .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
                                 break;
                             }
                             cellValue = String.valueOf(cell.getNumericCellValue());
@@ -307,7 +330,7 @@ public class CarYongCheJob {
      * @param path 源文件路径
      * @param list 数据
      */
-    public Path toCsv(Path path, List<Map<String, String>> list) throws Exception {
+    public Path toCsv(Path path, List<Map<String, String>> list) throws IOException {
         log.info("去重后条数:{}", list.size());
         Files.createDirectories(Paths.get(jobConfig.getCarYongCheHistoryPath()));
         Path csvPath = Paths.get(jobConfig.getCarYongCheHistoryPath() + path.getFileName() + ".csv");
@@ -346,7 +369,7 @@ public class CarYongCheJob {
      *
      * @param path 源文件路径
      */
-    public void move(Path path) throws Exception {
+    public void move(Path path) throws IOException {
         Path targetPath = Paths.get(jobConfig.getCarYongCheHistoryPath(), path.getFileName().toString());
         Files.move(path, targetPath, StandardCopyOption.REPLACE_EXISTING);
     }

+ 4 - 4
src/main/java/com/nokia/finance/tasks/jobs/car/ruixing/CarYongCheZongLanJob.java

@@ -84,10 +84,10 @@
 //                }).get(5, TimeUnit.MINUTES);
 //            }
 //        } catch (InterruptedException e) {
-//            log.error("线程中断: {}", e.getMessage(), e);
+//            log.error("线程中断: {}", e.toString(), e);
 //            Thread.currentThread().interrupt();
 //        } catch (Exception e) {
-//            log.error(e.getMessage(), e);
+//            log.error(e.toString(), e);
 //        }
 //    }
 //
@@ -171,7 +171,7 @@
 //                        case NUMERIC:
 //                            if (DateUtil.isCellDateFormatted(cell)) {
 //                                cellValue = DateUtil.getLocalDateTime(cell.getNumericCellValue())
-//                                        .format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"));
+//                                        .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
 //                                break;
 //                            }
 //                            cellValue = String.valueOf(cell.getNumericCellValue());
@@ -222,7 +222,7 @@
 //                            case NUMERIC:
 //                                if (DateUtil.isCellDateFormatted(cell)) {
 //                                    cellValue = DateUtil.getLocalDateTime(cell.getNumericCellValue())
-//                                            .format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"));
+//                                            .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
 //                                    break;
 //                                }
 //                                cellValue = String.valueOf(cell.getNumericCellValue());

+ 34 - 11
src/main/java/com/nokia/finance/tasks/jobs/car/ruixing/CarYueJieJob.java

@@ -3,10 +3,13 @@ package com.nokia.finance.tasks.jobs.car.ruixing;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.common.utils.psql.PsqlUtil;
 import com.nokia.finance.tasks.config.JobConfig;
+import com.nokia.finance.tasks.enums.DataStageEnum;
 import com.nokia.finance.tasks.pojo.po.common.AreaPo;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
 import com.nokia.finance.tasks.pojo.po.common.OrganizationPo;
 import com.nokia.finance.tasks.service.car.CarService;
 import com.nokia.finance.tasks.service.common.AreaService;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.service.common.OrganizationService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -22,6 +25,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStreamWriter;
 import java.nio.charset.StandardCharsets;
@@ -53,13 +57,15 @@ public class CarYueJieJob {
     private final CarService carService;
     private final OrganizationService organizationService;
     private final AreaService areaService;
+    private final DataLogServiceImpl dataLogService;
 
     public CarYueJieJob(JobConfig jobConfig, CarService carService, OrganizationService organizationService,
-                        AreaService areaService) {
+                        AreaService areaService, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.carService = carService;
         this.organizationService = organizationService;
         this.areaService = areaService;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -67,6 +73,7 @@ public class CarYueJieJob {
      */
     @Scheduled(cron = "0 58 23 * * ?")
     public void runJob() {
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
         // 数据目录
         Path dir = Paths.get(jobConfig.getCarYueJieSourcePath());
         try (Stream<Path> stream = Files.list(dir)) {
@@ -79,32 +86,48 @@ public class CarYueJieJob {
             for (Path path : pathList) {
                 CompletableFuture.runAsync(() -> {
                     try {
-                        singleJob(path);
+                        singleJob(path, dataLogPoList);
                     } catch (Exception e) {
                         throw new MyRuntimeException(e);
                     }
                 }).get(1, TimeUnit.MINUTES);
             }
         } catch (InterruptedException e) {
-            log.error("线程中断: {}", e.getMessage(), e);
+            log.error("线程中断: {}", e, e);
             Thread.currentThread().interrupt();
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "睿行车辆越界报警日数据", DataStageEnum.CC, "入库");
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "睿行车辆越界报警日数据", DataStageEnum.CC, "入库");
+        } finally {
+            if (!CollectionUtils.isEmpty(dataLogPoList)) {
+                dataLogService.saveBatch(dataLogPoList);
+            }
         }
     }
 
     /**
      * 处理单个文件
      *
-     * @param path 文件路径
+     * @param path          文件路径
+     * @param dataLogPoList 数据处理日志列表
      */
-    public void singleJob(Path path) throws Exception {
-        if (Files.size(path) == 0) {
+    public void singleJob(Path path, List<DataLogPo> dataLogPoList) throws IOException {
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("睿行车辆越界报警日数据");
+        dataLogPo.setObject(path.getFileName().toString());
+        dataLogPo.setStage(DataStageEnum.CC.value);
+        dataLogPo.setOperationName("入库");
+        long fileSize = Files.size(path);
+        dataLogPo.setDataSize(fileSize);
+        dataLogPoList.add(dataLogPo);
+        if (fileSize == 0) {
             move(path);
             throw new MyRuntimeException(path.getFileName() + " 空文件");
         }
         List<Map<String, String>> list = readFile(path);
         List<Map<String, String>> distinctList = dataProcessing(path, list);
+        dataLogPo.setDataCount(distinctList.size());
         Path csvPath = toCsv(path, distinctList);
         copyCsv(csvPath);
         move(path);
@@ -115,7 +138,7 @@ public class CarYueJieJob {
      *
      * @param path 文件路径
      */
-    public List<Map<String, String>> readFile(Path path) throws Exception {
+    public List<Map<String, String>> readFile(Path path) throws IOException {
         log.info("读取: {}", path);
         List<String> rawHeaders = Stream.of("车辆所属单位", "车牌号码", "车辆类型", "车辆使用性质", "报警区域描述",
                 "报警规则描述", "越界时间", "是否执行中越界", "详情").toList();
@@ -176,7 +199,7 @@ public class CarYueJieJob {
                         case NUMERIC:
                             if (DateUtil.isCellDateFormatted(cell)) {
                                 cellValue = DateUtil.getLocalDateTime(cell.getNumericCellValue())
-                                        .format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"));
+                                        .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
                                 break;
                             }
                             cellValue = String.valueOf(cell.getNumericCellValue());
@@ -278,7 +301,7 @@ public class CarYueJieJob {
      * @param path 源文件路径
      * @param list 数据
      */
-    public Path toCsv(Path path, List<Map<String, String>> list) throws Exception {
+    public Path toCsv(Path path, List<Map<String, String>> list) throws IOException {
         log.info("去重后条数:{}", list.size());
         Files.createDirectories(Paths.get(jobConfig.getCarYueJieHistoryPath()));
         Path csvPath = Paths.get(jobConfig.getCarYueJieHistoryPath() + path.getFileName() + ".csv");
@@ -317,7 +340,7 @@ public class CarYueJieJob {
      *
      * @param path 源文件路径
      */
-    public void move(Path path) throws Exception {
+    public void move(Path path) throws IOException {
         Path targetPath = Paths.get(jobConfig.getCarYueJieHistoryPath(), path.getFileName().toString());
         Files.move(path, targetPath, StandardCopyOption.REPLACE_EXISTING);
     }

+ 33 - 10
src/main/java/com/nokia/finance/tasks/jobs/car/shujucangku/CarFeeBsJob.java

@@ -3,6 +3,9 @@ package com.nokia.finance.tasks.jobs.car.shujucangku;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.common.utils.psql.PsqlUtil;
 import com.nokia.finance.tasks.config.JobConfig;
+import com.nokia.finance.tasks.enums.DataStageEnum;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
 import org.apache.commons.csv.CSVParser;
@@ -13,6 +16,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
+import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
 import java.nio.charset.StandardCharsets;
@@ -35,9 +39,11 @@ import java.util.stream.Stream;
 @Service
 public class CarFeeBsJob {
     private final JobConfig jobConfig;
+    private final DataLogServiceImpl dataLogService;
 
-    public CarFeeBsJob(JobConfig jobConfig) {
+    public CarFeeBsJob(JobConfig jobConfig, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -45,6 +51,7 @@ public class CarFeeBsJob {
      */
     @Scheduled(cron = "0 28 6 9 * ?")
     public void runJob() {
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
         // 数据目录
         Path dir = Paths.get(jobConfig.getCarFeeBsSourcePath());
         try (Stream<Path> stream = Files.list(dir)) {
@@ -57,32 +64,48 @@ public class CarFeeBsJob {
             for (Path path : pathList) {
                 CompletableFuture.runAsync(() -> {
                     try {
-                        singleJob(path);
+                        singleJob(path, dataLogPoList);
                     } catch (Exception e) {
                         throw new MyRuntimeException(e);
                     }
                 }).get(1, TimeUnit.MINUTES);
             }
         } catch (InterruptedException e) {
-            log.error("线程中断: {}", e.getMessage(), e);
+            log.error("线程中断: {}", e, e);
             Thread.currentThread().interrupt();
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "河北价值管理平台北十车辆费用月数据", DataStageEnum.CC, "入库");
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "河北价值管理平台北十车辆费用月数据", DataStageEnum.CC, "入库");
+        } finally {
+            if (!CollectionUtils.isEmpty(dataLogPoList)) {
+                dataLogService.saveBatch(dataLogPoList);
+            }
         }
     }
 
     /**
      * 处理单个文件
      *
-     * @param path 文件路径
+     * @param path          文件路径
+     * @param dataLogPoList 数据处理日志列表
      */
-    public void singleJob(Path path) throws Exception {
-        if (Files.size(path) == 0) {
+    public void singleJob(Path path, List<DataLogPo> dataLogPoList) throws IOException {
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("河北价值管理平台北十车辆费用月数据");
+        dataLogPo.setObject(path.getFileName().toString());
+        dataLogPo.setStage(DataStageEnum.CC.value);
+        dataLogPo.setOperationName("入库");
+        long fileSize = Files.size(path);
+        dataLogPo.setDataSize(fileSize);
+        dataLogPoList.add(dataLogPo);
+        if (fileSize == 0) {
             move(path);
             throw new MyRuntimeException(path.getFileName() + " 空文件");
         }
         List<Map<String, String>> list = readFile(path);
         List<Map<String, String>> distinctList = dataProcessing(path, list);
+        dataLogPo.setDataCount(distinctList.size());
         Path csvPath = toCsv(path, distinctList);
         copyCsv(csvPath);
         move(path);
@@ -93,7 +116,7 @@ public class CarFeeBsJob {
      *
      * @param path 文件路径
      */
-    public List<Map<String, String>> readFile(Path path) throws Exception {
+    public List<Map<String, String>> readFile(Path path) throws IOException {
         log.info("读取: {}", path);
         List<String> headers = Stream.of("month_id", "area_no", "area_name", "kpi_id", "kpi_name", "tm_value",
                 "lm_value", "ty_value", "ly_value").toList();
@@ -141,7 +164,7 @@ public class CarFeeBsJob {
      * @param path 源文件路径
      * @param list 数据
      */
-    public Path toCsv(Path path, List<Map<String, String>> list) throws Exception {
+    public Path toCsv(Path path, List<Map<String, String>> list) throws IOException {
         log.info("条数:{}", list.size());
         Files.createDirectories(Paths.get(jobConfig.getCarFeeBsHistoryPath()));
         Path csvPath = Paths.get(jobConfig.getCarFeeBsHistoryPath() + path.getFileName() + ".csv");
@@ -180,7 +203,7 @@ public class CarFeeBsJob {
      *
      * @param path 源文件路径
      */
-    public void move(Path path) throws Exception {
+    public void move(Path path) throws IOException {
         if (Files.exists(Paths.get(path + ".MD5"))) {
             Files.move(Paths.get(path + ".MD5"),
                     Paths.get(jobConfig.getCarFeeBsHistoryPath(), path.getFileName().toString() + ".MD5"),

+ 34 - 10
src/main/java/com/nokia/finance/tasks/jobs/car/shujucangku/CarFeeHbJob.java

@@ -3,8 +3,11 @@ package com.nokia.finance.tasks.jobs.car.shujucangku;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.common.utils.psql.PsqlUtil;
 import com.nokia.finance.tasks.config.JobConfig;
+import com.nokia.finance.tasks.enums.DataStageEnum;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
 import com.nokia.finance.tasks.pojo.po.common.OrganizationPo;
 import com.nokia.finance.tasks.service.car.CarService;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.service.common.OrganizationService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -16,6 +19,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
+import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
 import java.nio.charset.StandardCharsets;
@@ -40,11 +44,14 @@ public class CarFeeHbJob {
     private final JobConfig jobConfig;
     private final CarService carService;
     private final OrganizationService organizationService;
+    private final DataLogServiceImpl dataLogService;
 
-    public CarFeeHbJob(JobConfig jobConfig, CarService carService, OrganizationService organizationService) {
+    public CarFeeHbJob(JobConfig jobConfig, CarService carService, OrganizationService organizationService,
+                       DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.carService = carService;
         this.organizationService = organizationService;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -52,6 +59,7 @@ public class CarFeeHbJob {
      */
     @Scheduled(cron = "0 26 6 9 * ?")
     public void runJob() {
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
         // 数据目录
         Path dir = Paths.get(jobConfig.getCarFeeHbSourcePath());
         try (Stream<Path> stream = Files.list(dir)) {
@@ -64,32 +72,48 @@ public class CarFeeHbJob {
             for (Path path : pathList) {
                 CompletableFuture.runAsync(() -> {
                     try {
-                        singleJob(path);
+                        singleJob(path, dataLogPoList);
                     } catch (Exception e) {
                         throw new MyRuntimeException(e);
                     }
                 }).get(1, TimeUnit.MINUTES);
             }
         } catch (InterruptedException e) {
-            log.error("线程中断: {}", e.getMessage(), e);
+            log.error("线程中断: {}", e, e);
             Thread.currentThread().interrupt();
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "河北价值管理平台省内车辆费用月数据", DataStageEnum.CC, "入库");
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "河北价值管理平台省内车辆费用月数据", DataStageEnum.CC, "入库");
+        } finally {
+            if (!CollectionUtils.isEmpty(dataLogPoList)) {
+                dataLogService.saveBatch(dataLogPoList);
+            }
         }
     }
 
     /**
      * 处理单个文件
      *
-     * @param path 文件路径
+     * @param path          文件路径
+     * @param dataLogPoList 数据处理日志列表
      */
-    public void singleJob(Path path) throws Exception {
-        if (Files.size(path) == 0) {
+    public void singleJob(Path path, List<DataLogPo> dataLogPoList) throws IOException {
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("河北价值管理平台省内车辆费用月数据");
+        dataLogPo.setObject(path.getFileName().toString());
+        dataLogPo.setStage(DataStageEnum.CC.value);
+        dataLogPo.setOperationName("入库");
+        long fileSize = Files.size(path);
+        dataLogPo.setDataSize(fileSize);
+        dataLogPoList.add(dataLogPo);
+        if (fileSize == 0) {
             move(path);
             throw new MyRuntimeException(path.getFileName() + " 空文件");
         }
         List<Map<String, String>> list = readFile(path);
         List<Map<String, String>> distinctList = dataProcessing(path, list);
+        dataLogPo.setDataCount(distinctList.size());
         Path csvPath = toCsv(path, distinctList);
         copyCsv(csvPath);
         move(path);
@@ -100,7 +124,7 @@ public class CarFeeHbJob {
      *
      * @param path 文件路径
      */
-    public List<Map<String, String>> readFile(Path path) throws Exception {
+    public List<Map<String, String>> readFile(Path path) throws IOException {
         log.info("读取: {}", path);
         List<String> headers = Stream.of("month_id", "area_no", "area_name", "kpi_id", "kpi_name", "tm_value",
                 "lm_value", "ty_value", "ly_value").toList();
@@ -173,7 +197,7 @@ public class CarFeeHbJob {
      * @param path 源文件路径
      * @param list 数据
      */
-    public Path toCsv(Path path, List<Map<String, String>> list) throws Exception {
+    public Path toCsv(Path path, List<Map<String, String>> list) throws IOException {
         log.info("条数:{}", list.size());
         Files.createDirectories(Paths.get(jobConfig.getCarFeeHbHistoryPath()));
         Path csvPath = Paths.get(jobConfig.getCarFeeHbHistoryPath() + path.getFileName() + ".csv");
@@ -212,7 +236,7 @@ public class CarFeeHbJob {
      *
      * @param path 源文件路径
      */
-    public void move(Path path) throws Exception {
+    public void move(Path path) throws IOException {
         if (Files.exists(Paths.get(path + ".MD5"))) {
             Files.move(Paths.get(path + ".MD5"),
                     Paths.get(jobConfig.getCarFeeHbHistoryPath(), path.getFileName().toString() + ".MD5"),

+ 28 - 7
src/main/java/com/nokia/finance/tasks/jobs/car/strategy/CarHighFuelConsumptionJob.java

@@ -3,6 +3,9 @@ package com.nokia.finance.tasks.jobs.car.strategy;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.config.JobConfig;
 import com.nokia.finance.tasks.dao.car.CarStrategyDao;
+import com.nokia.finance.tasks.enums.DataStageEnum;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.utils.FileUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -19,9 +22,11 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CompletableFuture;
 
 /**
  * 高油耗车辆策略定时任务
@@ -31,10 +36,12 @@ import java.util.Map;
 public class CarHighFuelConsumptionJob {
     private final JobConfig jobConfig;
     private final CarStrategyDao carStrategyDao;
+    private final DataLogServiceImpl dataLogService;
 
-    CarHighFuelConsumptionJob(JobConfig jobConfig, CarStrategyDao carStrategyDao) {
+    CarHighFuelConsumptionJob(JobConfig jobConfig, CarStrategyDao carStrategyDao, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.carStrategyDao = carStrategyDao;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -44,12 +51,18 @@ public class CarHighFuelConsumptionJob {
     @Transactional(timeout = 60, rollbackFor = Exception.class)
     public void runJob() {
         log.info("执行高油耗车辆策略定时任务");
-        LocalDate localDateNow = LocalDate.now();
-        LocalDate localDateEnd = localDateNow.minusMonths(1);
-        LocalDate localDateStart = localDateEnd.withDayOfYear(1);
-        Integer endYearMonth = Integer.valueOf(localDateEnd.format(DateTimeFormatter.ofPattern("yyyyMM")));
-        Integer startYearMonth = Integer.valueOf(localDateStart.format(DateTimeFormatter.ofPattern("yyyyMM")));
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("高油耗车辆策略");
+        dataLogPo.setStage(DataStageEnum.JG.value);
+        dataLogPo.setOperationName("生成高油耗车辆策略");
+        dataLogPoList.add(dataLogPo);
         try {
+            LocalDate localDateNow = LocalDate.now();
+            LocalDate localDateEnd = localDateNow.minusMonths(1);
+            LocalDate localDateStart = localDateEnd.withDayOfYear(1);
+            Integer endYearMonth = Integer.valueOf(localDateEnd.format(DateTimeFormatter.ofPattern("yyyyMM")));
+            Integer startYearMonth = Integer.valueOf(localDateStart.format(DateTimeFormatter.ofPattern("yyyyMM")));
             int updateCount = carStrategyDao.insertCarHighFuelConsumption(startYearMonth, endYearMonth);
             if (updateCount == 0) {
                 throw new MyRuntimeException("插入高油耗车辆策略失败");
@@ -83,9 +96,17 @@ public class CarHighFuelConsumptionJob {
             FileUtil.setDefaultFilePermissions(filePath);
             Files.createDirectories(Paths.get(jobConfig.getTempOutputDir()));
             Files.copy(filePath, Paths.get(jobConfig.getTempOutputDir() + filename));
+            long fileSize = Files.size(filePath);
+            dataLogPo.setDataSize(fileSize);
+            dataLogPo.setDataCount(list.size());
+            dataLogPo.setObject(filePath.getFileName().toString());
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            dataLogPo.setStatus(0);
+            dataLogPo.setExceptionInfo(e.toString());
             throw new MyRuntimeException("高油耗车辆策略定时任务失败");
+        } finally {
+            CompletableFuture.runAsync(() -> dataLogService.saveBatch(dataLogPoList));
         }
     }
 }

+ 28 - 7
src/main/java/com/nokia/finance/tasks/jobs/car/strategy/CarHighRepairJob.java

@@ -3,6 +3,9 @@ package com.nokia.finance.tasks.jobs.car.strategy;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.config.JobConfig;
 import com.nokia.finance.tasks.dao.car.CarStrategyDao;
+import com.nokia.finance.tasks.enums.DataStageEnum;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.utils.FileUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -19,9 +22,11 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CompletableFuture;
 
 /**
  * 高修理车辆策略定时任务
@@ -31,10 +36,12 @@ import java.util.Map;
 public class CarHighRepairJob {
     private final JobConfig jobConfig;
     private final CarStrategyDao carStrategyDao;
+    private final DataLogServiceImpl dataLogService;
 
-    CarHighRepairJob(JobConfig jobConfig, CarStrategyDao carStrategyDao) {
+    CarHighRepairJob(JobConfig jobConfig, CarStrategyDao carStrategyDao, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.carStrategyDao = carStrategyDao;
+        this.dataLogService = dataLogService;
     }
     /**
      * 执行任务
@@ -43,12 +50,18 @@ public class CarHighRepairJob {
     @Transactional(timeout = 60, rollbackFor = Exception.class)
     public void runJob() {
         log.info("执行高修理车辆策略定时任务");
-        LocalDate localDateNow = LocalDate.now();
-        LocalDate localDateEnd = localDateNow.minusMonths(1);
-        LocalDate localDateStart = localDateEnd.withDayOfYear(1);
-        Integer endYearMonth = Integer.valueOf(localDateEnd.format(DateTimeFormatter.ofPattern("yyyyMM")));
-        Integer startYearMonth = Integer.valueOf(localDateStart.format(DateTimeFormatter.ofPattern("yyyyMM")));
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("高修理车辆策略");
+        dataLogPo.setStage(DataStageEnum.JG.value);
+        dataLogPo.setOperationName("生成高修理车辆策略");
+        dataLogPoList.add(dataLogPo);
         try {
+            LocalDate localDateNow = LocalDate.now();
+            LocalDate localDateEnd = localDateNow.minusMonths(1);
+            LocalDate localDateStart = localDateEnd.withDayOfYear(1);
+            Integer endYearMonth = Integer.valueOf(localDateEnd.format(DateTimeFormatter.ofPattern("yyyyMM")));
+            Integer startYearMonth = Integer.valueOf(localDateStart.format(DateTimeFormatter.ofPattern("yyyyMM")));
             int updateCount = carStrategyDao.insertCarHighRepair(startYearMonth, endYearMonth);
             if (updateCount == 0) {
                 throw new MyRuntimeException("插入高修理车辆策略失败");
@@ -82,9 +95,17 @@ public class CarHighRepairJob {
             FileUtil.setDefaultFilePermissions(filePath);
             Files.createDirectories(Paths.get(jobConfig.getTempOutputDir()));
             Files.copy(filePath, Paths.get(jobConfig.getTempOutputDir() + filename));
+            long fileSize = Files.size(filePath);
+            dataLogPo.setDataSize(fileSize);
+            dataLogPo.setDataCount(list.size());
+            dataLogPo.setObject(filePath.getFileName().toString());
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            dataLogPo.setStatus(0);
+            dataLogPo.setExceptionInfo(e.toString());
             throw new MyRuntimeException("高修理车辆策略定时任务失败");
+        } finally {
+            CompletableFuture.runAsync(() -> dataLogService.saveBatch(dataLogPoList));
         }
     }
 }

+ 28 - 5
src/main/java/com/nokia/finance/tasks/jobs/car/strategy/CarInefficiencyPercentJob.java

@@ -3,6 +3,9 @@ package com.nokia.finance.tasks.jobs.car.strategy;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.config.JobConfig;
 import com.nokia.finance.tasks.dao.car.CarStrategyDao;
+import com.nokia.finance.tasks.enums.DataStageEnum;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.utils.FileUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -19,9 +22,11 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CompletableFuture;
 
 /**
  * 车辆低效占比策略定时任务
@@ -31,10 +36,12 @@ import java.util.Map;
 public class CarInefficiencyPercentJob {
     private final JobConfig jobConfig;
     private final CarStrategyDao carStrategyDao;
+    private final DataLogServiceImpl dataLogService;
 
-    CarInefficiencyPercentJob(JobConfig jobConfig, CarStrategyDao carStrategyDao) {
+    CarInefficiencyPercentJob(JobConfig jobConfig, CarStrategyDao carStrategyDao, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.carStrategyDao = carStrategyDao;
+        this.dataLogService = dataLogService;
     }
     /**
      * 执行任务
@@ -43,10 +50,16 @@ public class CarInefficiencyPercentJob {
     @Transactional(timeout = 60, rollbackFor = Exception.class)
     public void runJob() {
         log.info("执行车辆低效占比策略定时任务");
-        LocalDate localDateNow = LocalDate.now();
-        LocalDate localDateEnd = localDateNow.minusMonths(1);
-        Integer endYearMonth = Integer.valueOf(localDateEnd.format(DateTimeFormatter.ofPattern("yyyyMM")));
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("车辆低效占比策略");
+        dataLogPo.setStage(DataStageEnum.JG.value);
+        dataLogPo.setOperationName("生成车辆低效占比策略");
+        dataLogPoList.add(dataLogPo);
         try {
+            LocalDate localDateNow = LocalDate.now();
+            LocalDate localDateEnd = localDateNow.minusMonths(1);
+            Integer endYearMonth = Integer.valueOf(localDateEnd.format(DateTimeFormatter.ofPattern("yyyyMM")));
             boolean flag = carStrategyDao.hasCarInefficiency(endYearMonth);
             if (!flag) {
                 throw new MyRuntimeException("车辆低效占比策略缺少数据");
@@ -79,9 +92,19 @@ public class CarInefficiencyPercentJob {
                 }
             }
             FileUtil.setDefaultFilePermissions(filePath);
+            Files.createDirectories(Paths.get(jobConfig.getTempOutputDir()));
+            Files.copy(filePath, Paths.get(jobConfig.getTempOutputDir() + filename));
+            long fileSize = Files.size(filePath);
+            dataLogPo.setDataSize(fileSize);
+            dataLogPo.setDataCount(list.size());
+            dataLogPo.setObject(filePath.getFileName().toString());
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            dataLogPo.setStatus(0);
+            dataLogPo.setExceptionInfo(e.toString());
             throw new MyRuntimeException("车辆低效占比策略定时任务失败");
+        } finally {
+            CompletableFuture.runAsync(() -> dataLogService.saveBatch(dataLogPoList));
         }
     }
 }

+ 26 - 5
src/main/java/com/nokia/finance/tasks/jobs/car/strategy/CarInefficiencyQxJob.java

@@ -3,6 +3,9 @@ package com.nokia.finance.tasks.jobs.car.strategy;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.config.JobConfig;
 import com.nokia.finance.tasks.dao.car.CarStrategyDao;
+import com.nokia.finance.tasks.enums.DataStageEnum;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.utils.FileUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -19,9 +22,11 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CompletableFuture;
 
 /**
  * 车辆低效区县策略定时任务
@@ -31,10 +36,12 @@ import java.util.Map;
 public class CarInefficiencyQxJob {
     private final JobConfig jobConfig;
     private final CarStrategyDao carStrategyDao;
+    private final DataLogServiceImpl dataLogService;
 
-    CarInefficiencyQxJob(JobConfig jobConfig, CarStrategyDao carStrategyDao) {
+    CarInefficiencyQxJob(JobConfig jobConfig, CarStrategyDao carStrategyDao, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.carStrategyDao = carStrategyDao;
+        this.dataLogService = dataLogService;
     }
     /**
      * 执行任务
@@ -43,10 +50,16 @@ public class CarInefficiencyQxJob {
     @Transactional(timeout = 60, rollbackFor = Exception.class)
     public void runJob() {
         log.info("执行车辆低效区县策略定时任务");
-        LocalDate localDateNow = LocalDate.now();
-        LocalDate localDateEnd = localDateNow.minusMonths(1);
-        Integer endYearMonth = Integer.valueOf(localDateEnd.format(DateTimeFormatter.ofPattern("yyyyMM")));
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("车辆低效区县策略");
+        dataLogPo.setStage(DataStageEnum.JG.value);
+        dataLogPo.setOperationName("生成车辆低效区县策略");
+        dataLogPoList.add(dataLogPo);
         try {
+            LocalDate localDateNow = LocalDate.now();
+            LocalDate localDateEnd = localDateNow.minusMonths(1);
+            Integer endYearMonth = Integer.valueOf(localDateEnd.format(DateTimeFormatter.ofPattern("yyyyMM")));
             boolean flag = carStrategyDao.hasCarInefficiency(endYearMonth);
             if (!flag) {
                 throw new MyRuntimeException("车辆低效区县策略缺少数据");
@@ -81,9 +94,17 @@ public class CarInefficiencyQxJob {
             FileUtil.setDefaultFilePermissions(filePath);
             Files.createDirectories(Paths.get(jobConfig.getTempOutputDir()));
             Files.copy(filePath, Paths.get(jobConfig.getTempOutputDir() + filename));
+            long fileSize = Files.size(filePath);
+            dataLogPo.setDataSize(fileSize);
+            dataLogPo.setDataCount(list.size());
+            dataLogPo.setObject(filePath.getFileName().toString());
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            dataLogPo.setStatus(0);
+            dataLogPo.setExceptionInfo(e.toString());
             throw new MyRuntimeException("车辆低效区县策略定时任务失败");
+        } finally {
+            CompletableFuture.runAsync(() -> dataLogService.saveBatch(dataLogPoList));
         }
     }
 }

+ 28 - 7
src/main/java/com/nokia/finance/tasks/jobs/car/strategy/CarRentalRepairJob.java

@@ -3,6 +3,9 @@ package com.nokia.finance.tasks.jobs.car.strategy;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.config.JobConfig;
 import com.nokia.finance.tasks.dao.car.CarStrategyDao;
+import com.nokia.finance.tasks.enums.DataStageEnum;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.utils.FileUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -19,9 +22,11 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CompletableFuture;
 
 /**
  * 租赁车辆产生维修费策略定时任务
@@ -31,10 +36,12 @@ import java.util.Map;
 public class CarRentalRepairJob {
     private final JobConfig jobConfig;
     private final CarStrategyDao carStrategyDao;
+    private final DataLogServiceImpl dataLogService;
 
-    CarRentalRepairJob(JobConfig jobConfig, CarStrategyDao carStrategyDao) {
+    CarRentalRepairJob(JobConfig jobConfig, CarStrategyDao carStrategyDao, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.carStrategyDao = carStrategyDao;
+        this.dataLogService = dataLogService;
     }
     /**
      * 执行任务
@@ -43,12 +50,18 @@ public class CarRentalRepairJob {
     @Transactional(timeout = 60, rollbackFor = Exception.class)
     public void runJob() {
         log.info("执行租赁车辆产生维修费策略定时任务");
-        LocalDate localDateNow = LocalDate.now();
-        LocalDate localDateEnd = localDateNow.minusMonths(1);
-        LocalDate localDateStart = localDateEnd.withDayOfYear(1);
-        Integer endYearMonth = Integer.valueOf(localDateEnd.format(DateTimeFormatter.ofPattern("yyyyMM")));
-        Integer startYearMonth = Integer.valueOf(localDateStart.format(DateTimeFormatter.ofPattern("yyyyMM")));
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("租赁车辆产生维修费策略");
+        dataLogPo.setStage(DataStageEnum.JG.value);
+        dataLogPo.setOperationName("生成租赁车辆产生维修费策略");
+        dataLogPoList.add(dataLogPo);
         try {
+            LocalDate localDateNow = LocalDate.now();
+            LocalDate localDateEnd = localDateNow.minusMonths(1);
+            LocalDate localDateStart = localDateEnd.withDayOfYear(1);
+            Integer endYearMonth = Integer.valueOf(localDateEnd.format(DateTimeFormatter.ofPattern("yyyyMM")));
+            Integer startYearMonth = Integer.valueOf(localDateStart.format(DateTimeFormatter.ofPattern("yyyyMM")));
             boolean flag = carStrategyDao.hasCarRentalRepair(endYearMonth);
             if (!flag) {
                 throw new MyRuntimeException("租赁车辆产生维修费策略缺少数据");
@@ -83,9 +96,17 @@ public class CarRentalRepairJob {
             FileUtil.setDefaultFilePermissions(filePath);
             Files.createDirectories(Paths.get(jobConfig.getTempOutputDir()));
             Files.copy(filePath, Paths.get(jobConfig.getTempOutputDir() + filename));
+            long fileSize = Files.size(filePath);
+            dataLogPo.setDataSize(fileSize);
+            dataLogPo.setDataCount(list.size());
+            dataLogPo.setObject(filePath.getFileName().toString());
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            dataLogPo.setStatus(0);
+            dataLogPo.setExceptionInfo(e.toString());
             throw new MyRuntimeException("租赁车辆产生维修费策略定时任务失败");
+        } finally {
+            CompletableFuture.runAsync(() -> dataLogService.saveBatch(dataLogPoList));
         }
     }
 }

+ 26 - 5
src/main/java/com/nokia/finance/tasks/jobs/car/strategy/CarViolationUnprocessedJob.java

@@ -3,6 +3,9 @@ package com.nokia.finance.tasks.jobs.car.strategy;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.config.JobConfig;
 import com.nokia.finance.tasks.dao.car.CarStrategyDao;
+import com.nokia.finance.tasks.enums.DataStageEnum;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.utils.FileUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -19,9 +22,11 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CompletableFuture;
 
 /**
  * 车辆违章未处理策略定时任务
@@ -31,10 +36,12 @@ import java.util.Map;
 public class CarViolationUnprocessedJob {
     private final JobConfig jobConfig;
     private final CarStrategyDao carStrategyDao;
+    private final DataLogServiceImpl dataLogService;
 
-    CarViolationUnprocessedJob(JobConfig jobConfig, CarStrategyDao carStrategyDao) {
+    CarViolationUnprocessedJob(JobConfig jobConfig, CarStrategyDao carStrategyDao, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.carStrategyDao = carStrategyDao;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -44,10 +51,16 @@ public class CarViolationUnprocessedJob {
     @Transactional(timeout = 60, rollbackFor = Exception.class)
     public void runJob() {
         log.info("执行车辆违章未处理策略定时任务");
-        LocalDate localDateNow = LocalDate.now();
-        LocalDate localDateEnd = localDateNow.minusMonths(1);
-        Integer endYearMonth = Integer.valueOf(localDateEnd.format(DateTimeFormatter.ofPattern("yyyyMM")));
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("车辆违章未处理策略");
+        dataLogPo.setStage(DataStageEnum.JG.value);
+        dataLogPo.setOperationName("生成车辆违章未处理策略");
+        dataLogPoList.add(dataLogPo);
         try {
+            LocalDate localDateNow = LocalDate.now();
+            LocalDate localDateEnd = localDateNow.minusMonths(1);
+            Integer endYearMonth = Integer.valueOf(localDateEnd.format(DateTimeFormatter.ofPattern("yyyyMM")));
             boolean flag = carStrategyDao.hasCarViolationUnprocessed(endYearMonth);
             if (!flag) {
                 throw new MyRuntimeException("车辆违章未处理策略缺少数据");
@@ -82,9 +95,17 @@ public class CarViolationUnprocessedJob {
             FileUtil.setDefaultFilePermissions(filePath);
             Files.createDirectories(Paths.get(jobConfig.getTempOutputDir()));
             Files.copy(filePath, Paths.get(jobConfig.getTempOutputDir() + filename));
+            long fileSize = Files.size(filePath);
+            dataLogPo.setDataSize(fileSize);
+            dataLogPo.setDataCount(list.size());
+            dataLogPo.setObject(filePath.getFileName().toString());
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            dataLogPo.setStatus(0);
+            dataLogPo.setExceptionInfo(e.toString());
             throw new MyRuntimeException("车辆违章未处理策略定时任务失败");
+        } finally {
+            CompletableFuture.runAsync(() -> dataLogService.saveBatch(dataLogPoList));
         }
     }
 }

+ 26 - 5
src/main/java/com/nokia/finance/tasks/jobs/car/strategy/CarWdyjJob.java

@@ -3,6 +3,9 @@ package com.nokia.finance.tasks.jobs.car.strategy;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.config.JobConfig;
 import com.nokia.finance.tasks.dao.car.CarStrategyDao;
+import com.nokia.finance.tasks.enums.DataStageEnum;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.utils.FileUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -19,9 +22,11 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CompletableFuture;
 
 /**
  * 违规车辆策略定时任务
@@ -31,10 +36,12 @@ import java.util.Map;
 public class CarWdyjJob {
     private final JobConfig jobConfig;
     private final CarStrategyDao carStrategyDao;
+    private final DataLogServiceImpl dataLogService;
 
-    CarWdyjJob(JobConfig jobConfig, CarStrategyDao carStrategyDao) {
+    CarWdyjJob(JobConfig jobConfig, CarStrategyDao carStrategyDao, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.carStrategyDao = carStrategyDao;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -44,10 +51,16 @@ public class CarWdyjJob {
     @Transactional(timeout = 60, rollbackFor = Exception.class)
     public void runJob() {
         log.info("执行违规车辆策略定时任务");
-        LocalDate localDateNow = LocalDate.now();
-        LocalDate localDateEnd = localDateNow.minusMonths(1);
-        Integer endYearMonth = Integer.valueOf(localDateEnd.format(DateTimeFormatter.ofPattern("yyyyMM")));
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("违规车辆策略");
+        dataLogPo.setStage(DataStageEnum.JG.value);
+        dataLogPo.setOperationName("生成违规车辆策略");
+        dataLogPoList.add(dataLogPo);
         try {
+            LocalDate localDateNow = LocalDate.now();
+            LocalDate localDateEnd = localDateNow.minusMonths(1);
+            Integer endYearMonth = Integer.valueOf(localDateEnd.format(DateTimeFormatter.ofPattern("yyyyMM")));
             carStrategyDao.insertCarWdyj(endYearMonth);
             List<LinkedHashMap<String, Object>> list = carStrategyDao.getCarWdyj(endYearMonth);
             String dir = jobConfig.getCarWdyjOutputPath();
@@ -78,9 +91,17 @@ public class CarWdyjJob {
             FileUtil.setDefaultFilePermissions(filePath);
             Files.createDirectories(Paths.get(jobConfig.getTempOutputDir()));
             Files.copy(filePath, Paths.get(jobConfig.getTempOutputDir() + filename));
+            long fileSize = Files.size(filePath);
+            dataLogPo.setDataSize(fileSize);
+            dataLogPo.setDataCount(list.size());
+            dataLogPo.setObject(filePath.getFileName().toString());
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            dataLogPo.setStatus(0);
+            dataLogPo.setExceptionInfo(e.toString());
             throw new MyRuntimeException("违规车辆策略定时任务失败");
+        } finally {
+            CompletableFuture.runAsync(() -> dataLogService.saveBatch(dataLogPoList));
         }
     }
 }

+ 3 - 3
src/main/java/com/nokia/finance/tasks/jobs/gdc/car/CarPhpRequestLogJob.java

@@ -105,7 +105,7 @@ public class CarPhpRequestLogJob {
                         requestLogPo.setExpireTimeStamp(expireTimeStamp);
                         list.add(requestLogPo);
                     } catch (Exception e) {
-                        log.error("请求日志解析失败: {} -> {}", carPhpRequestLogPo, e.getMessage(), e);
+                        log.error("请求日志解析失败: {} -> {}", carPhpRequestLogPo, e.toString(), e);
                     }
                 }
                 if (CollectionUtils.isEmpty(list)) {
@@ -114,10 +114,10 @@ public class CarPhpRequestLogJob {
                 requestLogDao.insertBatch(list);
             }).get(1, TimeUnit.MINUTES);
         } catch (InterruptedException e) {
-            log.error("线程中断: {}", e.getMessage(), e);
+            log.error("线程中断: {}", e.toString(), e);
             Thread.currentThread().interrupt();
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
         }
     }
 }

+ 25 - 5
src/main/java/com/nokia/finance/tasks/jobs/house/HouseReportJob.java

@@ -3,6 +3,8 @@ package com.nokia.finance.tasks.jobs.house;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.config.HouseReportConfig;
 import com.nokia.finance.tasks.dao.house.HouseReportDao;
+import com.nokia.finance.tasks.enums.DataStageEnum;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
 import com.nokia.finance.tasks.pojo.po.house_report.HouseBuildingHighSporadicRepairPo;
 import com.nokia.finance.tasks.pojo.po.house_report.HouseBuildingIdleStrategyPo;
 import com.nokia.finance.tasks.pojo.po.house_report.HouseBuildingSameRepairFrequencyPo;
@@ -24,6 +26,7 @@ import com.nokia.finance.tasks.pojo.vo.house_report.HousePjczdjhlxclVo;
 import com.nokia.finance.tasks.pojo.vo.house_report.HouseReportVo;
 import com.nokia.finance.tasks.pojo.vo.house_report.HouseZyztqkTableVo;
 import com.nokia.finance.tasks.pojo.vo.house_report.HouseZyztqkVo;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.service.common.file.FileService;
 import com.nokia.finance.tasks.utils.OfficeUtil;
 import com.nokia.finance.tasks.utils.ZipUtil;
@@ -50,6 +53,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CompletableFuture;
 
 /**
  * 不动产报告定时任务
@@ -60,11 +64,14 @@ public class HouseReportJob {
     private final HouseReportConfig houseReportConfig;
     private final HouseReportDao houseReportDao;
     private final FileService fileService;
+    private final DataLogServiceImpl dataLogService;
 
-    public HouseReportJob(HouseReportConfig houseReportConfig, HouseReportDao houseReportDao, FileService fileService) {
+    public HouseReportJob(HouseReportConfig houseReportConfig, HouseReportDao houseReportDao, FileService fileService,
+                          DataLogServiceImpl dataLogService) {
         this.houseReportConfig = houseReportConfig;
         this.houseReportDao = houseReportDao;
         this.fileService = fileService;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -73,11 +80,17 @@ public class HouseReportJob {
     @Scheduled(cron = "0 35 0 13 * ?")
     @Transactional(timeout = 300, rollbackFor = Exception.class)
     public void runJob() {
+        log.info("执行不动产报告定时任务");
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("不动产报告");
+        dataLogPo.setStage(DataStageEnum.JG.value);
+        dataLogPo.setOperationName("生成不动产报告");
+        dataLogPoList.add(dataLogPo);
         try {
-            log.info("执行不动产报告定时任务");
             HouseReportVo vo = getReportVo();
             // 生成docx
-            generateDocx(vo);
+            generateDocx(vo, dataLogPo);
             // 生成pdf
             OfficeUtil.toPdf(houseReportConfig.getOutDir(), houseReportConfig.getDocx(), 1L);
             // 上传文件
@@ -85,8 +98,12 @@ public class HouseReportJob {
             // 更新公告
             updateNotices(vo);
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            dataLogPo.setStatus(0);
+            dataLogPo.setExceptionInfo(e.toString());
             throw new MyRuntimeException("不动产报告定时任务失败");
+        } finally {
+            CompletableFuture.runAsync(() -> dataLogService.saveBatch(dataLogPoList));
         }
     }
 
@@ -137,7 +154,7 @@ public class HouseReportJob {
     /**
      * 生成docx
      */
-    public void generateDocx(HouseReportVo vo) throws IOException, TemplateException {
+    public void generateDocx(HouseReportVo vo, DataLogPo dataLogPo) throws IOException, TemplateException {
         Configuration configuration = new Configuration(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS);
         configuration.setDefaultEncoding(StandardCharsets.UTF_8.name());
         configuration.setDirectoryForTemplateLoading(new File(houseReportConfig.getFtlDir()));
@@ -152,6 +169,9 @@ public class HouseReportJob {
         Path inputDir = Paths.get(houseReportConfig.getDocxDir());
         Path outputFile = Paths.get(houseReportConfig.getDocx());
         ZipUtil.zipDirNonSelf(inputDir, outputFile);
+        long fileSize = Files.size(outputFile);
+        dataLogPo.setDataSize(fileSize);
+        dataLogPo.setObject(vo.getReportMonth() + ".docx");
     }
 
     /**

+ 34 - 10
src/main/java/com/nokia/finance/tasks/jobs/house/chengben/HouseBuildingRepairMonthJob.java

@@ -4,6 +4,9 @@ import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.common.utils.psql.PsqlUtil;
 import com.nokia.finance.tasks.config.JobConfig;
 import com.nokia.finance.tasks.dao.house.HouseProcedureDao;
+import com.nokia.finance.tasks.enums.DataStageEnum;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
 import org.apache.commons.csv.CSVParser;
@@ -14,6 +17,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
+import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
 import java.nio.charset.StandardCharsets;
@@ -37,10 +41,13 @@ import java.util.stream.Stream;
 public class HouseBuildingRepairMonthJob {
     private final JobConfig jobConfig;
     private final HouseProcedureDao houseProcedureDao;
+    private final DataLogServiceImpl dataLogService;
 
-    public HouseBuildingRepairMonthJob(JobConfig jobConfig, HouseProcedureDao houseProcedureDao) {
+    public HouseBuildingRepairMonthJob(JobConfig jobConfig, HouseProcedureDao houseProcedureDao,
+                                       DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.houseProcedureDao = houseProcedureDao;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -48,6 +55,7 @@ public class HouseBuildingRepairMonthJob {
      */
     @Scheduled(cron = "0 24 6 12 * ?")
     public void runJob() {
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
         // 数据目录
         Path dir = Paths.get(jobConfig.getHouseBuildingRepairMonthSourcePath());
         try (Stream<Path> stream = Files.list(dir)) {
@@ -60,32 +68,48 @@ public class HouseBuildingRepairMonthJob {
             for (Path path : pathList) {
                 CompletableFuture.runAsync(() -> {
                     try {
-                        singleJob(path);
+                        singleJob(path, dataLogPoList);
                     } catch (Exception e) {
                         throw new MyRuntimeException(e);
                     }
                 }).get(1, TimeUnit.MINUTES);
             }
         } catch (InterruptedException e) {
-            log.error("线程中断: {}", e.getMessage(), e);
+            log.error("线程中断: {}", e, e);
             Thread.currentThread().interrupt();
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "河北成本管理系统自有类房产维修数据", DataStageEnum.CC, "入库");
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            DataLogPo.addExceptionInfo(dataLogPoList, e, "河北成本管理系统自有类房产维修数据", DataStageEnum.CC, "入库");
+        } finally {
+            if (!CollectionUtils.isEmpty(dataLogPoList)) {
+                dataLogService.saveBatch(dataLogPoList);
+            }
         }
     }
 
     /**
      * 处理单个文件
      *
-     * @param path 文件路径
+     * @param path          文件路径
+     * @param dataLogPoList 数据处理日志列表
      */
-    public void singleJob(Path path) throws Exception {
-        if (Files.size(path) == 0) {
+    public void singleJob(Path path, List<DataLogPo> dataLogPoList) throws IOException {
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("河北成本管理系统自有类房产维修数据");
+        dataLogPo.setObject(path.getFileName().toString());
+        dataLogPo.setStage(DataStageEnum.CC.value);
+        dataLogPo.setOperationName("入库");
+        long fileSize = Files.size(path);
+        dataLogPo.setDataSize(fileSize);
+        dataLogPoList.add(dataLogPo);
+        if (fileSize == 0) {
             move(path);
             throw new MyRuntimeException(path.getFileName() + " 空文件");
         }
         List<Map<String, String>> list = readFile(path);
         List<Map<String, String>> distinctList = dataProcessing(path, list);
+        dataLogPo.setDataCount(distinctList.size());
         Path csvPath = toCsv(path, distinctList);
         copyCsv(csvPath);
         move(path);
@@ -101,7 +125,7 @@ public class HouseBuildingRepairMonthJob {
      *
      * @param path 文件路径
      */
-    public List<Map<String, String>> readFile(Path path) throws Exception {
+    public List<Map<String, String>> readFile(Path path) throws IOException {
         log.info("读取: {}", path);
         List<String> headers = Stream.of(
                 "data_time_nlsd",
@@ -178,7 +202,7 @@ public class HouseBuildingRepairMonthJob {
      * @param path 源文件路径
      * @param list 数据
      */
-    public Path toCsv(Path path, List<Map<String, String>> list) throws Exception {
+    public Path toCsv(Path path, List<Map<String, String>> list) throws IOException {
         log.info("条数:{}", list.size());
         Files.createDirectories(Paths.get(jobConfig.getHouseBuildingRepairMonthHistoryPath()));
         Path csvPath = Paths.get(jobConfig.getHouseBuildingRepairMonthHistoryPath() + path.getFileName() + ".csv");
@@ -217,7 +241,7 @@ public class HouseBuildingRepairMonthJob {
      *
      * @param path 源文件路径
      */
-    public void move(Path path) throws Exception {
+    public void move(Path path) throws IOException {
         if (Files.exists(Paths.get(path + ".MD5"))) {
             Files.move(Paths.get(path + ".MD5"),
                     Paths.get(jobConfig.getHouseBuildingRepairMonthHistoryPath(), path.getFileName().toString() + ".MD5"),

+ 5 - 4
src/main/java/com/nokia/finance/tasks/jobs/house/chengben/HouseRentInRepairMonthJob.java

@@ -7,6 +7,7 @@ import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
+import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -52,10 +53,10 @@ public class HouseRentInRepairMonthJob {
                 }).get(1, TimeUnit.MINUTES);
             }
         } catch (InterruptedException e) {
-            log.error("线程中断: {}", e.getMessage(), e);
+            log.error("线程中断: {}", e, e);
             Thread.currentThread().interrupt();
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
         }
     }
 
@@ -64,7 +65,7 @@ public class HouseRentInRepairMonthJob {
      *
      * @param path 文件路径
      */
-    public void singleJob(Path path) throws Exception {
+    public void singleJob(Path path) throws IOException {
         if (Files.size(path) == 0) {
             move(path);
             throw new MyRuntimeException(path.getFileName() + " 空文件");
@@ -77,7 +78,7 @@ public class HouseRentInRepairMonthJob {
      *
      * @param path 源文件路径
      */
-    public void move(Path path) throws Exception {
+    public void move(Path path) throws IOException {
         if (Files.exists(Paths.get(path + ".MD5"))) {
             Files.move(Paths.get(path + ".MD5"),
                     Paths.get(jobConfig.getHouseRentInRepairMonthHistoryPath(), path.getFileName().toString() + ".MD5"),

+ 26 - 5
src/main/java/com/nokia/finance/tasks/jobs/house/fcdp/HouseBuildingAreaStatJob.java

@@ -3,6 +3,9 @@ package com.nokia.finance.tasks.jobs.house.fcdp;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.config.JobConfig;
 import com.nokia.finance.tasks.dao.house.HouseFcdpDao;
+import com.nokia.finance.tasks.enums.DataStageEnum;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.utils.FileUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -19,9 +22,11 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CompletableFuture;
 
 /**
  * 房产大屏建筑面积统计定时任务
@@ -31,10 +36,12 @@ import java.util.Map;
 public class HouseBuildingAreaStatJob {
     private final JobConfig jobConfig;
     private final HouseFcdpDao houseFcdpDao;
+    private final DataLogServiceImpl dataLogService;
 
-    HouseBuildingAreaStatJob(JobConfig jobConfig, HouseFcdpDao houseFcdpDao) {
+    HouseBuildingAreaStatJob(JobConfig jobConfig, HouseFcdpDao houseFcdpDao, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.houseFcdpDao = houseFcdpDao;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -44,10 +51,16 @@ public class HouseBuildingAreaStatJob {
     @Transactional(timeout = 60, rollbackFor = Exception.class)
     public void runJob() {
         log.info("执行房产大屏建筑面积统计定时任务");
-        LocalDate localDateNow = LocalDate.now();
-        LocalDate localDateEnd = localDateNow.minusMonths(1);
-        Integer endYearMonth = Integer.valueOf(localDateEnd.format(DateTimeFormatter.ofPattern("yyyyMM")));
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("房产大屏建筑面积统计");
+        dataLogPo.setStage(DataStageEnum.JG.value);
+        dataLogPo.setOperationName("生成房产大屏建筑面积统计");
+        dataLogPoList.add(dataLogPo);
         try {
+            LocalDate localDateNow = LocalDate.now();
+            LocalDate localDateEnd = localDateNow.minusMonths(1);
+            Integer endYearMonth = Integer.valueOf(localDateEnd.format(DateTimeFormatter.ofPattern("yyyyMM")));
             int update1 = houseFcdpDao.insertHouseBuildingAreaStat(endYearMonth);
             if (update1 == 0) {
                 throw new MyRuntimeException("房产大屏建筑面积统计定时任务失败");
@@ -81,9 +94,17 @@ public class HouseBuildingAreaStatJob {
             FileUtil.setDefaultFilePermissions(filePath);
             Files.createDirectories(Paths.get(jobConfig.getTempOutputDir()));
             Files.copy(filePath, Paths.get(jobConfig.getTempOutputDir() + filename));
+            long fileSize = Files.size(filePath);
+            dataLogPo.setDataSize(fileSize);
+            dataLogPo.setDataCount(list.size());
+            dataLogPo.setObject(filePath.getFileName().toString());
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            dataLogPo.setStatus(0);
+            dataLogPo.setExceptionInfo(e.toString());
             throw new MyRuntimeException("房产大屏建筑面积统计定时任务失败");
+        } finally {
+            CompletableFuture.runAsync(() -> dataLogService.saveBatch(dataLogPoList));
         }
     }
 }

+ 26 - 5
src/main/java/com/nokia/finance/tasks/jobs/house/fcdp/HouseBuildingLandCountJob.java

@@ -3,6 +3,9 @@ package com.nokia.finance.tasks.jobs.house.fcdp;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.config.JobConfig;
 import com.nokia.finance.tasks.dao.house.HouseFcdpDao;
+import com.nokia.finance.tasks.enums.DataStageEnum;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.utils.FileUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -19,9 +22,11 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CompletableFuture;
 
 /**
  * 房产大屏建筑和土地数量统计定时任务
@@ -31,10 +36,12 @@ import java.util.Map;
 public class HouseBuildingLandCountJob {
     private final JobConfig jobConfig;
     private final HouseFcdpDao houseFcdpDao;
+    private final DataLogServiceImpl dataLogService;
 
-    HouseBuildingLandCountJob(JobConfig jobConfig, HouseFcdpDao houseFcdpDao) {
+    HouseBuildingLandCountJob(JobConfig jobConfig, HouseFcdpDao houseFcdpDao, DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.houseFcdpDao = houseFcdpDao;
+        this.dataLogService = dataLogService;
     }
     /**
      * 执行任务
@@ -43,10 +50,16 @@ public class HouseBuildingLandCountJob {
     @Transactional(timeout = 60, rollbackFor = Exception.class)
     public void runJob() {
         log.info("执行房产大屏建筑和土地数量统计定时任务");
-        LocalDate localDateNow = LocalDate.now();
-        LocalDate localDateEnd = localDateNow.minusMonths(1);
-        Integer endYearMonth = Integer.valueOf(localDateEnd.format(DateTimeFormatter.ofPattern("yyyyMM")));
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("房产大屏建筑和土地数量统计");
+        dataLogPo.setStage(DataStageEnum.JG.value);
+        dataLogPo.setOperationName("生成房产大屏建筑和土地数量统计");
+        dataLogPoList.add(dataLogPo);
         try {
+            LocalDate localDateNow = LocalDate.now();
+            LocalDate localDateEnd = localDateNow.minusMonths(1);
+            Integer endYearMonth = Integer.valueOf(localDateEnd.format(DateTimeFormatter.ofPattern("yyyyMM")));
             int update1 = houseFcdpDao.insertHouseBuildingLandCount(endYearMonth);
             if (update1 == 0) {
                 throw new MyRuntimeException("房产大屏建筑和土地数量统计定时任务失败");
@@ -80,9 +93,17 @@ public class HouseBuildingLandCountJob {
             FileUtil.setDefaultFilePermissions(filePath);
             Files.createDirectories(Paths.get(jobConfig.getTempOutputDir()));
             Files.copy(filePath, Paths.get(jobConfig.getTempOutputDir() + filename));
+            long fileSize = Files.size(filePath);
+            dataLogPo.setDataSize(fileSize);
+            dataLogPo.setDataCount(list.size());
+            dataLogPo.setObject(filePath.getFileName().toString());
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            dataLogPo.setStatus(0);
+            dataLogPo.setExceptionInfo(e.toString());
             throw new MyRuntimeException("房产大屏建筑和土地数量统计定时任务失败");
+        } finally {
+            CompletableFuture.runAsync(() -> dataLogService.saveBatch(dataLogPoList));
         }
     }
 }

+ 23 - 3
src/main/java/com/nokia/finance/tasks/jobs/house/procedure/HouseBuildingRepairProcJob.java

@@ -2,6 +2,9 @@ package com.nokia.finance.tasks.jobs.house.procedure;
 
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.dao.house.HouseProcedureDao;
+import com.nokia.finance.tasks.enums.DataStageEnum;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
@@ -9,6 +12,9 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
 
 /**
  * 不动产自有房产维修数据加工定时任务
@@ -17,9 +23,11 @@ import java.time.format.DateTimeFormatter;
 @Service
 public class HouseBuildingRepairProcJob {
     private final HouseProcedureDao houseProcedureDao;
+    private final DataLogServiceImpl dataLogService;
 
-    public HouseBuildingRepairProcJob(HouseProcedureDao houseProcedureDao) {
+    public HouseBuildingRepairProcJob(HouseProcedureDao houseProcedureDao, DataLogServiceImpl dataLogService) {
         this.houseProcedureDao = houseProcedureDao;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -28,8 +36,15 @@ public class HouseBuildingRepairProcJob {
     @Scheduled(cron = "0 0 0 13 * ?")
     @Transactional(timeout = 60, rollbackFor = Exception.class)
     public void runJob() {
+        log.info("执行不动产自有房产维修数据加工定时任务");
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("不动产自有房产维修数据加工");
+        dataLogPo.setStage(DataStageEnum.JG.value);
+        dataLogPo.setOperationName("不动产自有房产维修数据加工");
+        dataLogPo.setObject("house.building_same_repair_frequency");
+        dataLogPoList.add(dataLogPo);
         try {
-            log.info("执行不动产自有房产维修数据加工定时任务");
             // 当前日期
             LocalDate localDateNow = LocalDate.now();
             // 上个月1号
@@ -47,9 +62,14 @@ public class HouseBuildingRepairProcJob {
             if (update1 == 0 || update2 == 0 || update3 == 0) {
                 throw new MyRuntimeException("不动产自有房产维修数据加工定时任务失败");
             }
+            dataLogPo.setDataCount(update1);
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            dataLogPo.setStatus(0);
+            dataLogPo.setExceptionInfo(e.toString());
             throw new MyRuntimeException("不动产自有房产维修数据加工定时任务失败");
+        } finally {
+            CompletableFuture.runAsync(() -> dataLogService.saveBatch(dataLogPoList));
         }
     }
 }

+ 27 - 5
src/main/java/com/nokia/finance/tasks/jobs/house/strategy/HouseBuildingIdleStrategyJob.java

@@ -3,6 +3,9 @@ package com.nokia.finance.tasks.jobs.house.strategy;
 import com.nokia.finance.tasks.common.exception.MyRuntimeException;
 import com.nokia.finance.tasks.config.JobConfig;
 import com.nokia.finance.tasks.dao.house.HouseStrategyDao;
+import com.nokia.finance.tasks.enums.DataStageEnum;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
+import com.nokia.finance.tasks.service.common.DataLogServiceImpl;
 import com.nokia.finance.tasks.utils.FileUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -19,9 +22,11 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CompletableFuture;
 
 /**
  * 闲置建筑面积超过1000平米策略定时任务
@@ -31,10 +36,13 @@ import java.util.Map;
 public class HouseBuildingIdleStrategyJob {
     private final JobConfig jobConfig;
     private final HouseStrategyDao houseStrategyDao;
+    private final DataLogServiceImpl dataLogService;
 
-    HouseBuildingIdleStrategyJob(JobConfig jobConfig, HouseStrategyDao houseStrategyDao) {
+    HouseBuildingIdleStrategyJob(JobConfig jobConfig, HouseStrategyDao houseStrategyDao,
+                                 DataLogServiceImpl dataLogService) {
         this.jobConfig = jobConfig;
         this.houseStrategyDao = houseStrategyDao;
+        this.dataLogService = dataLogService;
     }
 
     /**
@@ -44,10 +52,16 @@ public class HouseBuildingIdleStrategyJob {
     @Transactional(timeout = 60, rollbackFor = Exception.class)
     public void runJob() {
         log.info("执行闲置建筑面积超过1000平米策略定时任务");
-        LocalDate localDateNow = LocalDate.now();
-        LocalDate localDateEnd = localDateNow.minusMonths(1);
-        Integer endYearMonth = Integer.valueOf(localDateEnd.format(DateTimeFormatter.ofPattern("yyyyMM")));
+        List<DataLogPo> dataLogPoList = new ArrayList<>();
+        DataLogPo dataLogPo = new DataLogPo();
+        dataLogPo.setDataName("闲置建筑面积超过1000平米策略");
+        dataLogPo.setStage(DataStageEnum.JG.value);
+        dataLogPo.setOperationName("生成闲置建筑面积超过1000平米策略");
+        dataLogPoList.add(dataLogPo);
         try {
+            LocalDate localDateNow = LocalDate.now();
+            LocalDate localDateEnd = localDateNow.minusMonths(1);
+            Integer endYearMonth = Integer.valueOf(localDateEnd.format(DateTimeFormatter.ofPattern("yyyyMM")));
             boolean flag = houseStrategyDao.hasBuildingMonth(endYearMonth);
             if (!flag) {
                 throw new MyRuntimeException("闲置建筑面积超过1000平米策略缺少数据");
@@ -83,9 +97,17 @@ public class HouseBuildingIdleStrategyJob {
             FileUtil.setDefaultFilePermissions(filePath);
             Files.createDirectories(Paths.get(jobConfig.getTempOutputDir()));
             Files.copy(filePath, Paths.get(jobConfig.getTempOutputDir() + filename));
+            long fileSize = Files.size(filePath);
+            dataLogPo.setDataSize(fileSize);
+            dataLogPo.setDataCount(list.size());
+            dataLogPo.setObject(filePath.getFileName().toString());
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
+            dataLogPo.setStatus(0);
+            dataLogPo.setExceptionInfo(e.toString());
             throw new MyRuntimeException("闲置建筑面积超过1000平米策略定时任务失败");
+        } finally {
+            CompletableFuture.runAsync(() -> dataLogService.saveBatch(dataLogPoList));
         }
     }
 }

+ 91 - 0
src/main/java/com/nokia/finance/tasks/pojo/po/common/DataLogPo.java

@@ -0,0 +1,91 @@
+package com.nokia.finance.tasks.pojo.po.common;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.nokia.finance.tasks.enums.DataStageEnum;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+@Data
+@TableName("common.data_log")
+public class DataLogPo {
+    /**
+     * 执行时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 数据名称
+     */
+    private String dataName;
+
+    /**
+     * 执行对象
+     */
+    private String object;
+
+    /**
+     * 操作状态
+     */
+    private Integer status;
+
+    /**
+     * 数据大小
+     */
+    private Long dataSize;
+
+    /**
+     * 数据条数
+     */
+    private Integer dataCount;
+
+    /**
+     * 数据环节
+     */
+    private String stage;
+
+    /**
+     * 操作动作
+     */
+    private String operationName;
+
+    /**
+     * 操作者
+     */
+    private String operator;
+
+    /**
+     * 操作者ip
+     */
+    private String operatorIp;
+
+    /**
+     * 异常信息
+     */
+    private String exceptionInfo;
+
+    public DataLogPo() {
+        this.createTime = LocalDateTime.now();
+        this.status = 1;
+        this.operator = "system";
+        this.operatorIp = "172.16.107.4";
+    }
+
+    public static void addExceptionInfo(List<DataLogPo> dataLogPoList, Exception e, String dataName,
+                                        DataStageEnum dataStageEnum, String operationName) {
+        dataLogPoList.stream().reduce((first, second) -> second).ifPresentOrElse(t -> {
+            t.setStatus(0);
+            t.setExceptionInfo(e.toString());
+            dataLogPoList.add(t);
+        }, () -> {
+            DataLogPo t = new DataLogPo();
+            t.setDataName(dataName);
+            t.setStage(dataStageEnum.value);
+            t.setOperationName(operationName);
+            t.setStatus(0);
+            t.setExceptionInfo(e.toString());
+            dataLogPoList.add(t);
+        });
+    }
+}

+ 11 - 0
src/main/java/com/nokia/finance/tasks/service/common/DataLogServiceImpl.java

@@ -0,0 +1,11 @@
+package com.nokia.finance.tasks.service.common;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nokia.finance.tasks.dao.common.DataLogDao;
+import com.nokia.finance.tasks.pojo.po.common.DataLogPo;
+import org.springframework.stereotype.Service;
+
+@Service
+public class DataLogServiceImpl extends ServiceImpl<DataLogDao, DataLogPo> implements IService<DataLogPo> {
+}

+ 1 - 1
src/main/java/com/nokia/finance/tasks/utils/PinYinUtil.java

@@ -35,7 +35,7 @@
 //                        sb.append(" ");
 //                    }
 //                } catch (Exception e) {
-//                    log.info(e.getMessage(), e);
+//                    log.info(e.toString(), e);
 //                }
 //            }
 //        }

+ 6 - 6
src/main/resources/application-dev.yml

@@ -7,16 +7,16 @@ logging:
 spring:
   datasource:
     driver-class-name: org.postgresql.Driver
-    username: postgres
-    password: Test!234
+#    username: postgres
+#    password: Test!234
 #    url: jdbc:postgresql://127.0.0.1:5432/financialdb
-    url: jdbc:postgresql://192.168.65.128:5432/financialdb
+#    url: jdbc:postgresql://192.168.65.128:5432/financialdb
 #    url: jdbc:postgresql://172.16.107.5:5432/financialdb
 #    username: finance
 #    password: Finance@unicom23
-#    url: jdbc:postgresql://192.168.50.3:15432/financialdb
-#    username: postgres
-#    password: NFQCgBA6YhNvgAqG6THw
+    url: jdbc:postgresql://192.168.50.3:15432/financialdb
+    username: postgres
+    password: NFQCgBA6YhNvgAqG6THw
 minio:
   accessKey: house-car
   bucket: house-car

+ 1 - 1
src/test/java/com/nokia/finance/tasks/HanZiToPinYinTest.java

@@ -31,7 +31,7 @@
 //                        sb.append(" ");
 //                    }
 //                } catch (Exception e) {
-//                    log.info(e.getMessage(), e);
+//                    log.info(e.toString(), e);
 //                }
 //            }
 //        }

+ 2 - 2
src/test/java/com/nokia/finance/tasks/MybatisPlusGeneratorTest.java

@@ -9,12 +9,12 @@ public class MybatisPlusGeneratorTest {
         FastAutoGenerator.create(
                 new DataSourceConfig.Builder("jdbc:postgresql://172.16.107.5:5432/financialdb",
                         "finance",
-                        "Finance@unicom23").schema("car"))
+                        "Finance@unicom23").schema("common"))
                 .globalConfig(builder -> {
                     builder.outputDir("z:/").disableOpenDir();
                 })
                 .strategyConfig(builder -> {
-                    builder.addInclude("car_wei_zhang_chang_qi")
+                    builder.addInclude("data_log")
                             .entityBuilder()
                             .disableSerialVersionUID()
                             .enableFileOverride()

+ 2 - 2
src/test/java/com/nokia/finance/tasks/car/CarGongCheShiYongTests.java

@@ -72,7 +72,7 @@
 //                singleJob(path);
 //            }
 //        } catch (Exception e) {
-//            log.error(e.getMessage(), e);
+//            log.error(e.toString(), e);
 //        }
 //    }
 //
@@ -147,7 +147,7 @@
 //                        case NUMERIC:
 //                            if (DateUtil.isCellDateFormatted(cell)) {
 //                                cellValue = DateUtil.getLocalDateTime(cell.getNumericCellValue())
-//                                        .format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"));
+//                                        .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
 //                                break;
 //                            }
 //                            cellValue = String.valueOf(cell.getNumericCellValue());

+ 2 - 2
src/test/java/com/nokia/finance/tasks/car/CarGongCheShiYongTests1.java

@@ -72,7 +72,7 @@
 //                singleJob(path);
 //            }
 //        } catch (Exception e) {
-//            log.error(e.getMessage(), e);
+//            log.error(e.toString(), e);
 //        }
 //    }
 //
@@ -147,7 +147,7 @@
 //                        case NUMERIC:
 //                            if (DateUtil.isCellDateFormatted(cell)) {
 //                                cellValue = DateUtil.getLocalDateTime(cell.getNumericCellValue())
-//                                        .format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"));
+//                                        .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
 //                                break;
 //                            }
 //                            cellValue = String.valueOf(cell.getNumericCellValue());

+ 3 - 3
src/test/java/com/nokia/finance/tasks/car/CarGongCheShiYongTests2.java

@@ -74,7 +74,7 @@
 //                singleJob(path);
 //            }
 //        } catch (Exception e) {
-//            log.error(e.getMessage(), e);
+//            log.error(e.toString(), e);
 //        }
 //    }
 //
@@ -151,7 +151,7 @@
 //                        case NUMERIC:
 //                            if (DateUtil.isCellDateFormatted(cell)) {
 //                                cellValue = DateUtil.getLocalDateTime(cell.getNumericCellValue())
-//                                        .format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"));
+//                                        .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
 //                                break;
 //                            }
 //                            cellValue = String.valueOf(cell.getNumericCellValue());
@@ -202,7 +202,7 @@
 //                            case NUMERIC:
 //                                if (DateUtil.isCellDateFormatted(cell)) {
 //                                    cellValue = DateUtil.getLocalDateTime(cell.getNumericCellValue())
-//                                            .format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"));
+//                                            .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
 //                                    break;
 //                                }
 //                                cellValue = String.valueOf(cell.getNumericCellValue());

+ 2 - 2
src/test/java/com/nokia/finance/tasks/car/CarGongCheShiYongTests3.java

@@ -71,7 +71,7 @@ class CarGongCheShiYongTests3 {
                 singleJob(path);
             }
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
         }
     }
 
@@ -141,7 +141,7 @@ class CarGongCheShiYongTests3 {
                         case NUMERIC:
                             if (DateUtil.isCellDateFormatted(cell)) {
                                 cellValue = DateUtil.getLocalDateTime(cell.getNumericCellValue())
-                                        .format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"));
+                                        .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
                                 break;
                             }
                             cellValue = String.valueOf(cell.getNumericCellValue());

+ 2 - 2
src/test/java/com/nokia/finance/tasks/car/CarJiaoTongBuTieTests.java

@@ -59,7 +59,7 @@ class CarJiaoTongBuTieTests {
                 singleJob(path);
             }
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
         }
     }
 
@@ -124,7 +124,7 @@ class CarJiaoTongBuTieTests {
                         case NUMERIC:
                             if (DateUtil.isCellDateFormatted(cell)) {
                                 cellValue = DateUtil.getLocalDateTime(cell.getNumericCellValue())
-                                        .format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"));
+                                        .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
                                 break;
                             }
                             cellValue = String.valueOf(cell.getNumericCellValue());

+ 2 - 2
src/test/java/com/nokia/finance/tasks/car/CarLianXuJiaYouTests.java

@@ -72,7 +72,7 @@ class CarLianXuJiaYouTests {
                 singleJob(path);
             }
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
         }
     }
 
@@ -140,7 +140,7 @@ class CarLianXuJiaYouTests {
                         case NUMERIC:
                             if (DateUtil.isCellDateFormatted(cell)) {
                                 cellValue = DateUtil.getLocalDateTime(cell.getNumericCellValue())
-                                        .format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"));
+                                        .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
                                 break;
                             }
                             cellValue = String.valueOf(cell.getNumericCellValue());

+ 1 - 1
src/test/java/com/nokia/finance/tasks/requestlogs/JavaRequestLogTest.java

@@ -64,7 +64,7 @@ class JavaRequestLogTest {
                 }
             });
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
         }
     }
 

+ 2 - 2
src/test/java/com/nokia/finance/tasks/requestlogs/PhpRequestLogTest.java

@@ -66,7 +66,7 @@ select to_char(to_timestamp(create_time), 'YYYY-MM-DD HH24:MI:SS') as request_ti
                 try {
                     decodeToken = AESUtil.decrypt(urlDecodeToken);
                 } catch (Exception e) {
-                    log.error("token解密失败: {} -> {} -> {}", urlDecodeToken, queryString, e.getMessage(), e);
+                    log.error("token解密失败: {} -> {} -> {}", urlDecodeToken, queryString, e.toString(), e);
                     continue;
                 }
                 Map<String, String> tokenMap = gson.fromJson(decodeToken, new TypeToken<Map<String, String>>() {
@@ -91,7 +91,7 @@ select to_char(to_timestamp(create_time), 'YYYY-MM-DD HH24:MI:SS') as request_ti
                 );
             }
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            log.error(e.toString(), e);
         }
     }
 }