浏览代码

数据同步定时任务修改

master
CMM 1年前
父节点
当前提交
095c96be65
共有 2 个文件被更改,包括 3 次插入27 次删除
  1. +1
    -1
      syn-data-task/src/main/java/com/ningdatech/syndataapi/SynDataTaskApp.java
  2. +2
    -26
      syn-data-task/src/main/java/com/ningdatech/syndataapi/scheduler/task/SynDataTask.java

+ 1
- 1
syn-data-task/src/main/java/com/ningdatech/syndataapi/SynDataTaskApp.java 查看文件

@@ -16,7 +16,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
* @author CMM
* @since 2023/08/22 18:14
*/
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class })
@SpringBootApplication
@EnableAsync
@MapperScan(SynDataTaskApp.MAPPER_PACKAGES)
@EnableScheduling


+ 2
- 26
syn-data-task/src/main/java/com/ningdatech/syndataapi/scheduler/task/SynDataTask.java 查看文件

@@ -193,56 +193,32 @@ public class SynDataTask {
* 定时同步前置机数据 每天3点开始执行一次
*
*/
@Scheduled(cron = "0 55 19 * * ?")
@Scheduled(cron = "0 15 10 * * ?")
public void doTask() throws UnknownHostException {
if (flag && HOST.equals(InetAddress.getLocalHost().getHostName())) {
log.info("数据同步任务开始");
// 先删除表中的所有数据,再插入数据,测试数据只有一条,这里只插入一条
List<ProjectBaseInfo> baseInfos = projectBaseInfoService.list();
if (CollUtil.isNotEmpty(baseInfos)) {
projectBaseInfoService.removeBatchByIds(baseInfos);
}
// 前置机每天晚上10点自动清空,测试数据只有一条,这里只插入一条

// 项目基本信息
ProjectBaseInfo projectBaseInfo = JSON.parseObject(PROJECT_BASE_INFO_TEST_DATA, ProjectBaseInfo.class);
projectBaseInfoService.save(projectBaseInfo);

List<ProjectApply> applies = projectApplyService.list();
if (CollUtil.isNotEmpty(applies)){
projectApplyService.removeBatchByIds(applies);
}
// 项目申报信息
ProjectApply projectApply = JSON.parseObject(PROJECT_APPLY_TEST_DATA, ProjectApply.class);
projectApplyService.save(projectApply);

List<ProjectApprove> approves = projectApproveService.list();
if (CollUtil.isNotEmpty(approves)){
projectApproveService.removeBatchByIds(approves);
}
// 项目立项评审信息
ProjectApprove projectApprove = JSON.parseObject(PROJECT_APPROVE_TEST_DATA, ProjectApprove.class);
projectApproveService.save(projectApprove);

List<ProjectProcure> procures = projectProcureService.list();
if (CollUtil.isNotEmpty(procures)){
projectProcureService.removeBatchByIds(procures);
}
// 项目采购信息
ProjectProcure projectProcure = JSON.parseObject(PROJECT_PROCURE_TEST_DATA, ProjectProcure.class);
projectProcureService.save(projectProcure);

List<ProjectCimplement> cimplements = projectCimplementService.list();
if (CollUtil.isNotEmpty(cimplements)){
projectCimplementService.removeBatchByIds(cimplements);
}
// 建设项目实施信息
ProjectCimplement projectCimplement = JSON.parseObject(PROJECT_CIMPLEMENT_TEST_DATA, ProjectCimplement.class);
projectCimplementService.save(projectCimplement);

List<ProjectMimplement> mimplements = projectMimplementService.list();
if (CollUtil.isNotEmpty(mimplements)){
projectCimplementService.removeBatchByIds(cimplements);
}
// 运维项目实施信息
ProjectMimplement projectMimplement = JSON.parseObject(PROJECT_MIMPLEMENT_TEST_DATA, ProjectMimplement.class);
projectMimplementService.save(projectMimplement);


正在加载...
取消
保存