Преглед изворни кода

修改时区问题导致的异常数据

Cyangbin пре 2 година
родитељ
комит
3098a20419

+ 1 - 2
src/main/java/com/galaxis/manatee/ManateeApplication.java

@@ -4,7 +4,6 @@ import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.openfeign.EnableFeignClients;
-import org.springframework.scheduling.annotation.EnableScheduling;
 
 import javax.annotation.PostConstruct;
 import java.util.TimeZone;
@@ -14,7 +13,7 @@ import java.util.TimeZone;
  * @version 0.1
  */
 // TODO 记得放开
-@EnableScheduling
+//@EnableScheduling
 @SpringBootApplication
 @EnableFeignClients
 @MapperScan("com.galaxis.manatee.mapper")

+ 6 - 2
src/main/java/com/galaxis/manatee/service/DataArcherService.java

@@ -8,10 +8,10 @@ import com.galaxis.manatee.entity.chuanyun.dto.*;
 import com.galaxis.manatee.manager.ChuanYunManager;
 import com.galaxis.manatee.util.TimeUtil;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
+import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -41,7 +41,11 @@ public class DataArcherService {
             List<String> matchers = new ArrayList<>();
             matchers.add("F0000001_2," + chuanyunSelfWorkHourDTO.getProjectId());
             matchers.add("F0000002_2," + chuanyunSelfWorkHourDTO.getUserId());
-            matchers.add("F0000003_2," + TimeUtil.formatDateTime(chuanyunSelfWorkHourDTO.getDayLogDate()));
+            LocalDateTime dayLogDate = chuanyunSelfWorkHourDTO.getDayLogDate();
+            LocalDateTime localDateTimeStart = LocalDateTime.of(dayLogDate.getYear(), dayLogDate.getMonthValue(), dayLogDate.getDayOfMonth(), 0, 0, 0);
+            LocalDateTime localDateTimeEnd = LocalDateTime.of(dayLogDate.getYear(), dayLogDate.getMonthValue(), dayLogDate.getDayOfMonth(), 23, 59, 59);
+            matchers.add("F0000003_1," + TimeUtil.formatDateTime(localDateTimeStart));
+            matchers.add("F0000003_3," + TimeUtil.formatDateTime(localDateTimeEnd));
             matchers.add("F0000005_2," + chuanyunSelfWorkHourDTO.getProjectType());
             if ("3".equals(chuanyunSelfWorkHourDTO.getStatus())) {
                 matchers.add("F0000006_2," + chuanyunSelfWorkHourDTO.getStatus());

+ 2 - 2
src/main/resources/application.yml

@@ -50,9 +50,9 @@ spring:
         size: 500
       thread-name-prefix: scheduled-task-
   datasource:
-    url: jdbc:mysql://localhost:3306/manatee?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
+    url: jdbc:mysql://10.1.6.49:3306/manatee?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
     username: root
-    password: root@123
+    password: root
     hikari:
       maximum-pool-size: 128
   jpa: