ソースを参照

1.将核对日志原始工时与标准化工时数据的方法开放测试接口,用于验证功能;

verguenza 4 年 前
コミット
7f767f69ff

+ 31 - 0
src/main/java/com/galaxis/manatee/controller/WorkHourController.java

@@ -0,0 +1,31 @@
+package com.galaxis.manatee.controller;
+
+import com.galaxis.manatee.service.LogService;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 日志工时controller
+ * @author zcj
+ * @version 0.1
+ * @date 2021/3/4 3:56 上午
+ */
+@RestController
+public class WorkHourController {
+
+    private final LogService logService;
+
+    public WorkHourController(LogService logService) {
+        this.logService = logService;
+    }
+
+    /**
+     * 检查工时不一致数据
+     * @param userId    用户Id
+     */
+    @GetMapping("/test/workHour/checkSelfWorkHour")
+    public void checkSelfWorkHour(@RequestParam("userId") String userId){
+        logService.checkDayWorkHour(userId);
+    }
+}

+ 16 - 11
src/main/java/com/galaxis/manatee/service/LogService.java

@@ -85,30 +85,35 @@ public class LogService {
     /**
      * 核对日志原始数据与每日工时标准化数据差异
      *
-     * @param chuanyunUserCompanyDO 人员对象
+     * @param userId 人员对象ID
      */
-    public void checkDayWorkHour(ChuanyunUserCompanyDO chuanyunUserCompanyDO) {
-        List<ChuanyunWorkHourDO> selfList = chuanyunWorkHourDao.getSelfWorkHour(chuanyunUserCompanyDO.getUserId());
+    public void checkDayWorkHour(String userId) {
+        long start=System.currentTimeMillis();
+        log.info("开始核对日志原始工时与标准化工时");
+        //根据日志原始数据获取单个人的所有工时记录
+        List<ChuanyunWorkHourDO> chuanyunWorkHourList = chuanyunWorkHourDao.getSelfWorkHour(userId);
+        //根据标准化工时获取单个人的标准化工时记录
+        List<ChuanyunSelfWorkHourDO> chuanyunSelfWorkHourList = chuanyunSelfWorkHourDao.findByUserId(userId);
         //删除多余每日工时
-        List<ChuanyunSelfWorkHourDO> list = chuanyunSelfWorkHourDao.findByUserId(chuanyunUserCompanyDO.getUserId());
-        compareDayWorkHour(selfList, list);
+        compareDayWorkHour(chuanyunWorkHourList, chuanyunSelfWorkHourList);
+        log.info("核对耗时"+(System.currentTimeMillis()-start)+"毫秒");
     }
 
     /**
      * 删除多余每日工时
      *
-     * @param selfList
-     * @param list
+     * @param chuanyunWorkHourList      日志原始工时
+     * @param chuanyunSelfWorkHourList  标准化工时列表
      */
-    private void compareDayWorkHour(List<ChuanyunWorkHourDO> selfList, List<ChuanyunSelfWorkHourDO> list) {
+    private void compareDayWorkHour(List<ChuanyunWorkHourDO> chuanyunWorkHourList, List<ChuanyunSelfWorkHourDO> chuanyunSelfWorkHourList) {
         Map<String, Integer> map = new HashMap<>(64);
         //判断工时是否有撤回
-        if (selfList.size() != list.size()) {
-            for (ChuanyunWorkHourDO chuanyunWorkHourDO : selfList) {
+        if (chuanyunWorkHourList.size() != chuanyunSelfWorkHourList.size()) {
+            for (ChuanyunWorkHourDO chuanyunWorkHourDO : chuanyunWorkHourList) {
                 map.put(chuanyunWorkHourDO.getUserId() + chuanyunWorkHourDO.getProjectId() + chuanyunWorkHourDO.getDayLogDate(), 1);
             }
             //比较是否有撤回工时
-            for (ChuanyunSelfWorkHourDO chuanyunSelfWorkHourDO : list) {
+            for (ChuanyunSelfWorkHourDO chuanyunSelfWorkHourDO : chuanyunSelfWorkHourList) {
                 Integer count = map.get(chuanyunSelfWorkHourDO.getUserId() + chuanyunSelfWorkHourDO.getProjectId() + chuanyunSelfWorkHourDO.getDayLogDate());
                 if (count == null) {
                     try {

+ 0 - 1
src/main/java/com/galaxis/manatee/task/WorkHourStatisticsRecently.java

@@ -19,7 +19,6 @@ import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
-import java.math.BigDecimal;
 import java.time.Instant;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;