Browse Source

1.更新了周、月工时标准化、更新方法

verguenza 4 years ago
parent
commit
84a587c654

+ 30 - 1
src/main/java/com/galaxis/manatee/service/LogService.java

@@ -17,10 +17,12 @@ public class LogService {
 
     private final ChuanyunUserCompanyDao chuanyunUserCompanyDao;
     private final LogStandardService logStandardService;
+    private final LogUpdateService logUpdateService;
 
-    public LogService(ChuanyunUserCompanyDao chuanyunUserCompanyDao, LogStandardService logStandardService) {
+    public LogService(ChuanyunUserCompanyDao chuanyunUserCompanyDao, LogStandardService logStandardService, LogUpdateService logUpdateService) {
         this.chuanyunUserCompanyDao = chuanyunUserCompanyDao;
         this.logStandardService = logStandardService;
+        this.logUpdateService = logUpdateService;
     }
 
     /**
@@ -40,4 +42,31 @@ public class LogService {
         chuanyunUserCompanyDao.findAll().forEach(chuanyunUserCompanyDO -> logStandardService.standardSelfCostByUserId(chuanyunUserCompanyDO.getUserId()));
         log.info("标准化所有月工时耗时"+(Instant.now().getEpochSecond()-start)+"秒");
     }
+
+    /**
+     * 更新所有日工时
+     */
+    public void updateAllChuanyunSelfWorkHour() {
+        long startTime = Instant.now().getEpochSecond();
+        chuanyunUserCompanyDao.findAll().forEach(chuanyunUserCompanyDO -> logUpdateService.updateChuanyunSelfWorkHourListByUserId(chuanyunUserCompanyDO.getUserId()));
+        log.info("更新所有每日工时花费" + (Instant.now().getEpochSecond() - startTime) + "秒");
+    }
+
+    /**
+     * 更新所有周工时
+     */
+    public void updateAllChuanyunWeekMemberHour() {
+        long startTime = Instant.now().getEpochSecond();
+        chuanyunUserCompanyDao.findAll().forEach(chuanyunUserCompanyDO -> logUpdateService.updateChuanyunWeekMemberHourListByUserId(chuanyunUserCompanyDO.getUserId()));
+        log.info("更新所有每周工时花费" + (Instant.now().getEpochSecond() - startTime) + "秒");
+    }
+
+    /**
+     * 更新所有月工时
+     */
+    public void updateAllChuanyunSelfCost() {
+        long startTime = Instant.now().getEpochSecond();
+        chuanyunUserCompanyDao.findAll().forEach(chuanyunUserCompanyDO -> logUpdateService.updateChuanyunSelfCostListByUserId(chuanyunUserCompanyDO.getUserId()));
+        log.info("更新所有每月工时花费" + (Instant.now().getEpochSecond() - startTime) + "秒");
+    }
 }

+ 4 - 27
src/main/java/com/galaxis/manatee/service/LogUpdateService.java

@@ -14,6 +14,7 @@ import com.galaxis.manatee.entity.chuanyun.dto.ChuanyunWeekMemberHourDTO;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.data.domain.PageRequest;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
@@ -44,33 +45,6 @@ public class LogUpdateService {
     }
 
     /**
-     * 更新所有日工时
-     */
-    public void updateAllChuanyunSelfWorkHour() {
-        long startTime = Instant.now().getEpochSecond();
-        chuanyunUserCompanyDao.findAll().forEach(chuanyunUserCompanyDO -> this.updateChuanyunSelfWorkHourListByUserId(chuanyunUserCompanyDO.getUserId()));
-        log.info("更新所有每日工时花费" + (Instant.now().getEpochSecond() - startTime) + "秒");
-    }
-
-    /**
-     * 更新所有周工时
-     */
-    public void updateAllChuanyunWeekMemberHour() {
-        long startTime = Instant.now().getEpochSecond();
-        chuanyunUserCompanyDao.findAll().forEach(chuanyunUserCompanyDO -> this.updateChuanyunWeekMemberHourListByUserId(chuanyunUserCompanyDO.getUserId()));
-        log.info("更新所有每周工时花费" + (Instant.now().getEpochSecond() - startTime) + "秒");
-    }
-
-    /**
-     * 更新所有月工时
-     */
-    public void updateAllChuanyunSelfCost() {
-        long startTime = Instant.now().getEpochSecond();
-        chuanyunUserCompanyDao.findAll().forEach(chuanyunUserCompanyDO -> this.updateChuanyunSelfCostListByUserId(chuanyunUserCompanyDO.getUserId()));
-        log.info("更新所有每月工时花费" + (Instant.now().getEpochSecond() - startTime) + "秒");
-    }
-
-    /**
      * 更新最近一个月的标准每日工时
      */
     public void updateRecentChuanyunSelfWorkHour() {
@@ -95,6 +69,7 @@ public class LogUpdateService {
      *
      * @param userId 用户ID
      */
+    @Async
     public void updateChuanyunSelfWorkHourListByUserId(String userId) {
         List<ChuanyunSelfWorkHourDO> updateList = chuanyunSelfWorkHourDao.findByUserId(userId);
         this.updateChuanyunSelfWorkHourList(updateList);
@@ -105,6 +80,7 @@ public class LogUpdateService {
      *
      * @param userId 用户ID
      */
+    @Async
     public void updateChuanyunWeekMemberHourListByUserId(String userId) {
         List<ChuanyunWeekMemberHourDO> updateList = chuanyunWeekMemberHourDao.findByUserId(userId);
         this.updateChuanyunWeekMemberHourList(updateList);
@@ -115,6 +91,7 @@ public class LogUpdateService {
      *
      * @param userId 用户ID
      */
+    @Async
     public void updateChuanyunSelfCostListByUserId(String userId) {
         List<ChuanyunSelfCostDO> updateList = chuanyunSelfCostDao.findByUserId(userId);
         this.updateChuanyunSelfCostList(updateList);