فهرست منبع

feature 增加定时任务

xiahan 7 ماه پیش
والد
کامیت
77fe6cadb5

+ 1 - 2
jsglkh-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ScheduledTasksServiceBySqlServerServiceImpl.java

@@ -51,8 +51,7 @@ public class ScheduledTasksServiceBySqlServerServiceImpl implements ScheduledTas
         zProjectList.forEach(data -> {
             data.setDeleted("0");
         });
-        List<ZProject> collect = zProjectList.stream().filter(info -> info.getId() == 14237).collect(Collectors.toList());
-        List<List<ZProject>> partition1 = ListUtils.partition(collect, 3);
+        List<List<ZProject>> partition1 = ListUtils.partition(zProjectList, 3);
         try {
             partition1.parallelStream().forEach(data -> {
                 zProjectService.saveBatch(data, 3);

+ 2 - 0
jsglkh-server/src/main/java/com/rongwei/BusinessServerApplication.java

@@ -7,12 +7,14 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.annotation.EnableScheduling;
 
 @EnableAsync
 @SpringBootApplication
 @EnableDiscoveryClient
 @EnableFeignClients
 @MapperScan("com.rongwei.bscommon.sys.dao")
+@EnableScheduling
 public class BusinessServerApplication {
 
     public static void main(String[] args) {

+ 4 - 0
jsglkh-server/src/main/java/com/rongwei/controller/ScheduledTasksServiceController.java

@@ -5,6 +5,8 @@ import com.rongwei.bscommon.sys.service.impl.ScheduledTasksServiceBySqlServerSer
 import com.rongwei.rwcommon.base.R;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.scheduling.annotation.Schedules;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -26,6 +28,7 @@ public class ScheduledTasksServiceController {
      * 新增和修改接口同步方法
      */
     @PostMapping("/project")
+    @Scheduled(cron = "0 0 0,12 * * ? ")
     public R pushDataSync() {
         scheduledTasksServiceBySqlServer.projectAboutSync();
         return R.ok();
@@ -35,6 +38,7 @@ public class ScheduledTasksServiceController {
      * 从sql server同步人员、组织机构、关系
      */
     @PostMapping("/userAndOrgSync")
+    @Scheduled(cron = "0 0 0,12 * * ? ")
     public R userAndOrgSync() {
         scheduledTasksServiceBySqlServer.userAndOrgSync();
         return R.ok();