1、注释拉取待办、项目相关定时代码
2、调整对接第三方接口逻辑
This commit is contained in:
2
1-sql/2025-12-24/project/simulation_demand.sql
Normal file
2
1-sql/2025-12-24/project/simulation_demand.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE simulation_demand ADD demandSource varchar(12) NULL COMMENT '需求来源:自建、同步';
|
||||
ALTER TABLE simulation_demand ADD contentHash varchar(64) NULL COMMENT 'hash值,同步待办时判断是否需要更新';
|
||||
2
1-sql/2025-12-24/project/simulation_node.sql
Normal file
2
1-sql/2025-12-24/project/simulation_node.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE simulation_node ADD projectId INT NULL COMMENT '利元亨项目id';
|
||||
ALTER TABLE simulation_node ADD projectSource varchar(16) NULL COMMENT '项目来源:自建、同步';
|
||||
@@ -19,7 +19,7 @@ public class LyricVProjectBatchToDM {
|
||||
@Schema(description = "项目ID")
|
||||
// 字段名与表字段一致,@TableField可省略,也可以保留(显式指定)
|
||||
@TableField(value = "project_id")
|
||||
private String project_id; // 改为下划线命名,与表字段完全一致
|
||||
private String projectId; // 改为下划线命名,与表字段完全一致
|
||||
|
||||
@Schema(description = "批次名称")
|
||||
@TableField(value = "batch")
|
||||
|
||||
@@ -100,17 +100,17 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.quartz-scheduler</groupId>
|
||||
<artifactId>quartz</artifactId>
|
||||
<version>2.5.0</version>
|
||||
</dependency>
|
||||
<!-- Spring整合Quartz(如果是Spring/SpringBoot项目) -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
<version>6.1.14</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.quartz-scheduler</groupId>-->
|
||||
<!-- <artifactId>quartz</artifactId>-->
|
||||
<!-- <version>2.5.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <!– Spring整合Quartz(如果是Spring/SpringBoot项目) –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework</groupId>-->
|
||||
<!-- <artifactId>spring-context-support</artifactId>-->
|
||||
<!-- <version>6.1.14</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,43 +1,43 @@
|
||||
package com.sdm.project.config;
|
||||
|
||||
import com.sdm.project.factory.CustomJobFactory;
|
||||
import org.quartz.Scheduler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
|
||||
|
||||
/**
|
||||
* 适配Spring 6.1.14的Quartz配置类
|
||||
* 关键:通过SchedulerFactoryBean实例获取Scheduler,而非静态方法
|
||||
*/
|
||||
@Configuration
|
||||
public class QuartzConfig {
|
||||
|
||||
// 注入自定义的Job工厂
|
||||
@Autowired
|
||||
private CustomJobFactory customJobFactory;
|
||||
|
||||
/**
|
||||
* 创建SchedulerFactoryBean(Quartz的核心工厂类)
|
||||
*/
|
||||
@Bean
|
||||
public SchedulerFactoryBean schedulerFactoryBean() {
|
||||
SchedulerFactoryBean factoryBean = new SchedulerFactoryBean();
|
||||
// 可选:设置Quartz属性(如线程池大小、集群配置等)
|
||||
// Properties props = new Properties();
|
||||
// props.put("org.quartz.threadPool.threadCount", "10");
|
||||
// factoryBean.setQuartzProperties(props);
|
||||
factoryBean.setJobFactory(customJobFactory);
|
||||
return factoryBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注入Scheduler实例(从factoryBean中获取,适配Spring 6非静态方法)
|
||||
*/
|
||||
@Bean
|
||||
public Scheduler scheduler(SchedulerFactoryBean schedulerFactoryBean) {
|
||||
// 这里调用的是实例方法getScheduler(),而非静态方法
|
||||
return schedulerFactoryBean.getScheduler();
|
||||
}
|
||||
}
|
||||
//package com.sdm.project.config;
|
||||
//
|
||||
//import com.sdm.project.factory.CustomJobFactory;
|
||||
//import org.quartz.Scheduler;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.scheduling.quartz.SchedulerFactoryBean;
|
||||
//
|
||||
///**
|
||||
// * 适配Spring 6.1.14的Quartz配置类
|
||||
// * 关键:通过SchedulerFactoryBean实例获取Scheduler,而非静态方法
|
||||
// */
|
||||
//@Configuration
|
||||
//public class QuartzConfig {
|
||||
//
|
||||
// // 注入自定义的Job工厂
|
||||
// @Autowired
|
||||
// private CustomJobFactory customJobFactory;
|
||||
//
|
||||
// /**
|
||||
// * 创建SchedulerFactoryBean(Quartz的核心工厂类)
|
||||
// */
|
||||
// @Bean
|
||||
// public SchedulerFactoryBean schedulerFactoryBean() {
|
||||
// SchedulerFactoryBean factoryBean = new SchedulerFactoryBean();
|
||||
// // 可选:设置Quartz属性(如线程池大小、集群配置等)
|
||||
// // Properties props = new Properties();
|
||||
// // props.put("org.quartz.threadPool.threadCount", "10");
|
||||
// // factoryBean.setQuartzProperties(props);
|
||||
// factoryBean.setJobFactory(customJobFactory);
|
||||
// return factoryBean;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 注入Scheduler实例(从factoryBean中获取,适配Spring 6非静态方法)
|
||||
// */
|
||||
// @Bean
|
||||
// public Scheduler scheduler(SchedulerFactoryBean schedulerFactoryBean) {
|
||||
// // 这里调用的是实例方法getScheduler(),而非静态方法
|
||||
// return schedulerFactoryBean.getScheduler();
|
||||
// }
|
||||
//}
|
||||
@@ -1,90 +1,90 @@
|
||||
package com.sdm.project.controller;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.project.job.ProjectSyncJob;
|
||||
import com.sdm.project.job.TodoSyncJob;
|
||||
import com.sdm.project.manager.MultiJobManager;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.quartz.SchedulerException;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* 手动管理多Job的接口
|
||||
*/
|
||||
@RestController
|
||||
@RefreshScope
|
||||
public class MultiJobController {
|
||||
|
||||
@Autowired
|
||||
private MultiJobManager multiJobManager;
|
||||
|
||||
private static final String TODO_SYNC_JOB_NAME = "todoSyncJob";
|
||||
|
||||
private static final String PROJECT_SYNC_JOB_NAME = "projectSyncJob";
|
||||
|
||||
@Value("${scheduler.todo}")
|
||||
private String schedulerTodoTime;
|
||||
|
||||
@Value("${scheduler.project}")
|
||||
private String schedulerProjectTime;
|
||||
|
||||
// 暂停指定分组的Job(比如暂停数据同步任务:/pauseJob/dataSyncGroup)
|
||||
@GetMapping("/pauseJob/{jobGroup}")
|
||||
public String pauseJob(@PathVariable String jobGroup) {
|
||||
try {
|
||||
multiJobManager.pauseJobGroup(jobGroup);
|
||||
return "已暂停分组[" + jobGroup + "]的所有任务";
|
||||
} catch (SchedulerException e) {
|
||||
return "暂停失败:" + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
// 恢复指定分组的Job
|
||||
@GetMapping("/resumeJob/{jobGroup}")
|
||||
public String resumeJob(@PathVariable String jobGroup) {
|
||||
try {
|
||||
multiJobManager.resumeJobGroup(jobGroup);
|
||||
return "已恢复分组[" + jobGroup + "]的所有任务";
|
||||
} catch (SchedulerException e) {
|
||||
return "恢复失败:" + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
// 删除指定分组的Job
|
||||
@GetMapping("/deleteJob")
|
||||
public String deleteJob(@RequestParam String jobGroup) {
|
||||
try {
|
||||
multiJobManager.deleteJobGroup(jobGroup);
|
||||
return "已删除分组[" + jobGroup + "]的所有任务";
|
||||
} catch (SchedulerException e) {
|
||||
return "删除失败:" + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
// 新增指定分组的Job
|
||||
@GetMapping("/createJob")
|
||||
public SdmResponse createJob(@RequestParam String jobGroup) {
|
||||
try {
|
||||
multiJobManager.deleteJobGroup(jobGroup);
|
||||
if (TODO_SYNC_JOB_NAME.equals(jobGroup)) {
|
||||
multiJobManager.createJob(TodoSyncJob.class,jobGroup, Collections.singletonList(schedulerTodoTime.replaceAll("\\.",":")));
|
||||
}else {
|
||||
multiJobManager.createJob(ProjectSyncJob.class,jobGroup, Collections.singletonList(schedulerProjectTime.replaceAll("\\.",":")));
|
||||
}
|
||||
return SdmResponse.success("创建" + jobGroup + "任务成功");
|
||||
} catch (SchedulerException e) {
|
||||
return SdmResponse.failed("创建" + jobGroup + "任务失败");
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//package com.sdm.project.controller;
|
||||
//
|
||||
//import com.sdm.common.common.SdmResponse;
|
||||
//import com.sdm.project.job.ProjectSyncJob;
|
||||
//import com.sdm.project.job.TodoSyncJob;
|
||||
//import com.sdm.project.manager.MultiJobManager;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.beans.factory.annotation.Value;
|
||||
//import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
//import org.springframework.web.bind.annotation.GetMapping;
|
||||
//import org.springframework.web.bind.annotation.PathVariable;
|
||||
//import org.springframework.web.bind.annotation.RequestParam;
|
||||
//import org.springframework.web.bind.annotation.RestController;
|
||||
//import org.quartz.SchedulerException;
|
||||
//
|
||||
//import java.text.ParseException;
|
||||
//import java.util.Collections;
|
||||
//
|
||||
///**
|
||||
// * 手动管理多Job的接口
|
||||
// */
|
||||
//@RestController
|
||||
//@RefreshScope
|
||||
//public class MultiJobController {
|
||||
//
|
||||
// @Autowired
|
||||
// private MultiJobManager multiJobManager;
|
||||
//
|
||||
// private static final String TODO_SYNC_JOB_NAME = "todoSyncJob";
|
||||
//
|
||||
// private static final String PROJECT_SYNC_JOB_NAME = "projectSyncJob";
|
||||
//
|
||||
// @Value("${scheduler.todo}")
|
||||
// private String schedulerTodoTime;
|
||||
//
|
||||
// @Value("${scheduler.project}")
|
||||
// private String schedulerProjectTime;
|
||||
//
|
||||
// // 暂停指定分组的Job(比如暂停数据同步任务:/pauseJob/dataSyncGroup)
|
||||
// @GetMapping("/pauseJob/{jobGroup}")
|
||||
// public String pauseJob(@PathVariable String jobGroup) {
|
||||
// try {
|
||||
// multiJobManager.pauseJobGroup(jobGroup);
|
||||
// return "已暂停分组[" + jobGroup + "]的所有任务";
|
||||
// } catch (SchedulerException e) {
|
||||
// return "暂停失败:" + e.getMessage();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 恢复指定分组的Job
|
||||
// @GetMapping("/resumeJob/{jobGroup}")
|
||||
// public String resumeJob(@PathVariable String jobGroup) {
|
||||
// try {
|
||||
// multiJobManager.resumeJobGroup(jobGroup);
|
||||
// return "已恢复分组[" + jobGroup + "]的所有任务";
|
||||
// } catch (SchedulerException e) {
|
||||
// return "恢复失败:" + e.getMessage();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 删除指定分组的Job
|
||||
// @GetMapping("/deleteJob")
|
||||
// public String deleteJob(@RequestParam String jobGroup) {
|
||||
// try {
|
||||
// multiJobManager.deleteJobGroup(jobGroup);
|
||||
// return "已删除分组[" + jobGroup + "]的所有任务";
|
||||
// } catch (SchedulerException e) {
|
||||
// return "删除失败:" + e.getMessage();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 新增指定分组的Job
|
||||
// @GetMapping("/createJob")
|
||||
// public SdmResponse createJob(@RequestParam String jobGroup) {
|
||||
// try {
|
||||
// multiJobManager.deleteJobGroup(jobGroup);
|
||||
// if (TODO_SYNC_JOB_NAME.equals(jobGroup)) {
|
||||
// multiJobManager.createJob(TodoSyncJob.class,jobGroup, Collections.singletonList(schedulerTodoTime.replaceAll("\\.",":")));
|
||||
// }else {
|
||||
// multiJobManager.createJob(ProjectSyncJob.class,jobGroup, Collections.singletonList(schedulerProjectTime.replaceAll("\\.",":")));
|
||||
// }
|
||||
// return SdmResponse.success("创建" + jobGroup + "任务成功");
|
||||
// } catch (SchedulerException e) {
|
||||
// return SdmResponse.failed("创建" + jobGroup + "任务失败");
|
||||
// } catch (ParseException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -3,6 +3,7 @@ package com.sdm.project.controller;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.outbridge.mode.GetProcessDataReq;
|
||||
import com.sdm.project.model.req.PushReportReq;
|
||||
import com.sdm.project.model.req.ep.EpProjectQueryReq;
|
||||
import com.sdm.project.service.ILyricInternalService;
|
||||
import com.sdm.project.service.ISimulationLyricNodeService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -117,5 +118,16 @@ public class SimulationLyricNodeController {
|
||||
return lyricInternalService.queryProjectInfo(projectId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询EP项目列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/queryProjectInfoList")
|
||||
@Operation(summary = "查询EP项目列表", description = "查询EP项目列表")
|
||||
public SdmResponse queryProjectInfoList(@RequestBody EpProjectQueryReq req) {
|
||||
return lyricInternalService.queryProjectInfoList(req);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
package com.sdm.project.factory;
|
||||
|
||||
import org.quartz.spi.TriggerFiredBundle;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
|
||||
import org.springframework.scheduling.quartz.AdaptableJobFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 自定义Job工厂:让Quartz的Job能注入Spring的Service
|
||||
*/
|
||||
@Component
|
||||
public class CustomJobFactory extends AdaptableJobFactory {
|
||||
|
||||
// 注入Spring的自动装配工厂(核心:用于给Job实例注入依赖)
|
||||
@Autowired
|
||||
private AutowireCapableBeanFactory autowireCapableBeanFactory;
|
||||
|
||||
/**
|
||||
* 重写创建Job实例的方法:创建后交给Spring完成依赖注入
|
||||
*/
|
||||
@Override
|
||||
protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
|
||||
// 1. 让Quartz创建Job实例
|
||||
Object jobInstance = super.createJobInstance(bundle);
|
||||
// 2. 关键:让Spring为Job实例注入依赖(Service等)
|
||||
autowireCapableBeanFactory.autowireBean(jobInstance);
|
||||
return jobInstance;
|
||||
}
|
||||
}
|
||||
//package com.sdm.project.factory;
|
||||
//
|
||||
//import org.quartz.spi.TriggerFiredBundle;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
|
||||
//import org.springframework.scheduling.quartz.AdaptableJobFactory;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
///**
|
||||
// * 自定义Job工厂:让Quartz的Job能注入Spring的Service
|
||||
// */
|
||||
//@Component
|
||||
//public class CustomJobFactory extends AdaptableJobFactory {
|
||||
//
|
||||
// // 注入Spring的自动装配工厂(核心:用于给Job实例注入依赖)
|
||||
// @Autowired
|
||||
// private AutowireCapableBeanFactory autowireCapableBeanFactory;
|
||||
//
|
||||
// /**
|
||||
// * 重写创建Job实例的方法:创建后交给Spring完成依赖注入
|
||||
// */
|
||||
// @Override
|
||||
// protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
|
||||
// // 1. 让Quartz创建Job实例
|
||||
// Object jobInstance = super.createJobInstance(bundle);
|
||||
// // 2. 关键:让Spring为Job实例注入依赖(Service等)
|
||||
// autowireCapableBeanFactory.autowireBean(jobInstance);
|
||||
// return jobInstance;
|
||||
// }
|
||||
//}
|
||||
@@ -1,31 +1,31 @@
|
||||
package com.sdm.project.job;
|
||||
|
||||
import com.sdm.project.service.impl.LyricInternalServiceImpl;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 自定义定时任务执行逻辑
|
||||
*/
|
||||
@Component
|
||||
public class ProjectSyncJob implements Job {
|
||||
|
||||
@Autowired
|
||||
private LyricInternalServiceImpl lyricInternalService;
|
||||
|
||||
/**
|
||||
* 核心执行方法:这里写你需要定时执行的代码
|
||||
*/
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
String triggerTime = context.getTrigger().getDescription();
|
||||
System.out.println("【项目】定时任务执行成功!触发时间:" + triggerTime + ",当前系统时间:" + LocalDateTime.now());
|
||||
lyricInternalService.getProjectList();
|
||||
}
|
||||
|
||||
}
|
||||
//package com.sdm.project.job;
|
||||
//
|
||||
//import com.sdm.project.service.impl.LyricInternalServiceImpl;
|
||||
//import org.quartz.Job;
|
||||
//import org.quartz.JobExecutionContext;
|
||||
//import org.quartz.JobExecutionException;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.time.LocalDateTime;
|
||||
//
|
||||
///**
|
||||
// * 自定义定时任务执行逻辑
|
||||
// */
|
||||
//@Component
|
||||
//public class ProjectSyncJob implements Job {
|
||||
//
|
||||
// @Autowired
|
||||
// private LyricInternalServiceImpl lyricInternalService;
|
||||
//
|
||||
// /**
|
||||
// * 核心执行方法:这里写你需要定时执行的代码
|
||||
// */
|
||||
// @Override
|
||||
// public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
// String triggerTime = context.getTrigger().getDescription();
|
||||
// System.out.println("【项目】定时任务执行成功!触发时间:" + triggerTime + ",当前系统时间:" + LocalDateTime.now());
|
||||
// lyricInternalService.getProjectList();
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -1,32 +1,32 @@
|
||||
package com.sdm.project.job;
|
||||
|
||||
import com.sdm.outbridge.mode.GetProcessDataReq;
|
||||
import com.sdm.project.service.impl.LyricInternalServiceImpl;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 自定义定时任务执行逻辑
|
||||
*/
|
||||
@Component
|
||||
public class TodoSyncJob implements Job {
|
||||
|
||||
@Autowired
|
||||
private LyricInternalServiceImpl lyricInternalService;
|
||||
|
||||
/**
|
||||
* 核心执行方法:这里写你需要定时执行的代码
|
||||
*/
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
String triggerTime = context.getTrigger().getDescription();
|
||||
System.out.println("【待办】定时任务执行成功!触发时间:" + triggerTime + ",当前系统时间:" + LocalDateTime.now());
|
||||
lyricInternalService.getTodoList();
|
||||
}
|
||||
|
||||
}
|
||||
//package com.sdm.project.job;
|
||||
//
|
||||
//import com.sdm.outbridge.mode.GetProcessDataReq;
|
||||
//import com.sdm.project.service.impl.LyricInternalServiceImpl;
|
||||
//import org.quartz.Job;
|
||||
//import org.quartz.JobExecutionContext;
|
||||
//import org.quartz.JobExecutionException;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.time.LocalDateTime;
|
||||
//
|
||||
///**
|
||||
// * 自定义定时任务执行逻辑
|
||||
// */
|
||||
//@Component
|
||||
//public class TodoSyncJob implements Job {
|
||||
//
|
||||
// @Autowired
|
||||
// private LyricInternalServiceImpl lyricInternalService;
|
||||
//
|
||||
// /**
|
||||
// * 核心执行方法:这里写你需要定时执行的代码
|
||||
// */
|
||||
// @Override
|
||||
// public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
// String triggerTime = context.getTrigger().getDescription();
|
||||
// System.out.println("【待办】定时任务执行成功!触发时间:" + triggerTime + ",当前系统时间:" + LocalDateTime.now());
|
||||
// lyricInternalService.getTodoList();
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -1,100 +1,100 @@
|
||||
package com.sdm.project.manager;
|
||||
|
||||
import org.quartz.*;
|
||||
import org.quartz.impl.matchers.GroupMatcher;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 通用定时任务管理类:支持管理多个不同的Job
|
||||
*/
|
||||
@Component
|
||||
public class MultiJobManager {
|
||||
|
||||
@Autowired
|
||||
private Scheduler scheduler;
|
||||
|
||||
|
||||
/**
|
||||
* 创建指定Job的定时任务
|
||||
* @param jobClass 要执行的Job类(比如DataSyncJob.class、MessagePushJob.class)
|
||||
* @param jobGroup Job分组(区分不同Job,比如"dataSyncGroup"、"messagePushGroup")
|
||||
* @param timeList 执行时间数组(如["15:00:00","16:00:00"])
|
||||
*/
|
||||
public void createJob(Class<? extends Job> jobClass, String jobGroup, List<String> timeList) throws SchedulerException, ParseException {
|
||||
// 遍历时间数组,为当前Job创建多个定时触发器
|
||||
for (String time : timeList) {
|
||||
// 1. 校验时间格式
|
||||
if (!time.matches("^\\d{2}:\\d{2}:\\d{2}$")) {
|
||||
throw new IllegalArgumentException("时间格式错误:" + time + ",请使用HH:mm:ss格式");
|
||||
}
|
||||
|
||||
// 2. 拆分时分秒,构建Cron表达式
|
||||
String[] timeParts = time.split(":");
|
||||
int second = Integer.parseInt(timeParts[2]);
|
||||
int minute = Integer.parseInt(timeParts[1]);
|
||||
int hour = Integer.parseInt(timeParts[0]);
|
||||
String cronExpression = String.format("%d %d %d * * ?", second, minute, hour);
|
||||
|
||||
// 3. 构建JobDetail(绑定指定的Job类,唯一标识:jobName=时间+分组,jobGroup=传入的分组)
|
||||
String jobName = jobGroup + "_" + time;
|
||||
JobDetail jobDetail = JobBuilder.newJob(jobClass)
|
||||
.withIdentity(jobName, jobGroup) // 唯一标识:名称+分组,区分不同Job的任务
|
||||
.build();
|
||||
|
||||
// 4. 构建Trigger(触发器)
|
||||
Trigger trigger = TriggerBuilder.newTrigger()
|
||||
.withIdentity("trigger_" + jobName, jobGroup)
|
||||
.withDescription(time)
|
||||
.withSchedule(CronScheduleBuilder.cronSchedule(cronExpression))
|
||||
.build();
|
||||
|
||||
// 5. 注册任务到调度器
|
||||
scheduler.scheduleJob(jobDetail, trigger);
|
||||
System.out.println("成功创建任务:[" + jobGroup + "] 每日" + time + "执行,Cron:" + cronExpression);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止指定分组的所有Job
|
||||
* @param jobGroup Job分组(如"dataSyncGroup")
|
||||
*/
|
||||
public void pauseJobGroup(String jobGroup) throws SchedulerException {
|
||||
scheduler.pauseJobs(GroupMatcher.jobGroupEquals(jobGroup));
|
||||
System.out.println("已暂停分组[" + jobGroup + "]的所有任务");
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动指定分组的所有Job
|
||||
* @param jobGroup Job分组
|
||||
*/
|
||||
public void resumeJobGroup(String jobGroup) throws SchedulerException {
|
||||
scheduler.resumeJobs(GroupMatcher.jobGroupEquals(jobGroup));
|
||||
System.out.println("已恢复分组[" + jobGroup + "]的所有任务");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定分组的所有Job
|
||||
* @param jobGroup Job分组
|
||||
*/
|
||||
public void deleteJobGroup(String jobGroup) throws SchedulerException {
|
||||
// 1. 获取指定分组下的所有TriggerKey(返回Set)
|
||||
Set<TriggerKey> triggerKeySet = scheduler.getTriggerKeys(GroupMatcher.triggerGroupEquals(jobGroup));
|
||||
// 2. 将Set转换为List(使用Stream流,简洁高效)
|
||||
List<TriggerKey> triggerKeyList = new ArrayList<>(triggerKeySet);
|
||||
// 3. 取消触发器(此时需要List参数)
|
||||
scheduler.unscheduleJobs(triggerKeyList);
|
||||
// 4. 删除指定分组下的所有Job(getJobKeys返回Set,但deleteJobs支持Collection,List/Set都可以)
|
||||
Set<JobKey> jobKeySet = scheduler.getJobKeys(GroupMatcher.jobGroupEquals(jobGroup));
|
||||
scheduler.deleteJobs(new ArrayList<>(jobKeySet));
|
||||
System.out.println("已删除分组[" + jobGroup + "]的所有任务");
|
||||
}
|
||||
|
||||
}
|
||||
//package com.sdm.project.manager;
|
||||
//
|
||||
//import org.quartz.*;
|
||||
//import org.quartz.impl.matchers.GroupMatcher;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.beans.factory.annotation.Value;
|
||||
//import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//import java.text.ParseException;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//import java.util.Set;
|
||||
//import java.util.stream.Collectors;
|
||||
//
|
||||
///**
|
||||
// * 通用定时任务管理类:支持管理多个不同的Job
|
||||
// */
|
||||
//@Component
|
||||
//public class MultiJobManager {
|
||||
//
|
||||
// @Autowired
|
||||
// private Scheduler scheduler;
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 创建指定Job的定时任务
|
||||
// * @param jobClass 要执行的Job类(比如DataSyncJob.class、MessagePushJob.class)
|
||||
// * @param jobGroup Job分组(区分不同Job,比如"dataSyncGroup"、"messagePushGroup")
|
||||
// * @param timeList 执行时间数组(如["15:00:00","16:00:00"])
|
||||
// */
|
||||
// public void createJob(Class<? extends Job> jobClass, String jobGroup, List<String> timeList) throws SchedulerException, ParseException {
|
||||
// // 遍历时间数组,为当前Job创建多个定时触发器
|
||||
// for (String time : timeList) {
|
||||
// // 1. 校验时间格式
|
||||
// if (!time.matches("^\\d{2}:\\d{2}:\\d{2}$")) {
|
||||
// throw new IllegalArgumentException("时间格式错误:" + time + ",请使用HH:mm:ss格式");
|
||||
// }
|
||||
//
|
||||
// // 2. 拆分时分秒,构建Cron表达式
|
||||
// String[] timeParts = time.split(":");
|
||||
// int second = Integer.parseInt(timeParts[2]);
|
||||
// int minute = Integer.parseInt(timeParts[1]);
|
||||
// int hour = Integer.parseInt(timeParts[0]);
|
||||
// String cronExpression = String.format("%d %d %d * * ?", second, minute, hour);
|
||||
//
|
||||
// // 3. 构建JobDetail(绑定指定的Job类,唯一标识:jobName=时间+分组,jobGroup=传入的分组)
|
||||
// String jobName = jobGroup + "_" + time;
|
||||
// JobDetail jobDetail = JobBuilder.newJob(jobClass)
|
||||
// .withIdentity(jobName, jobGroup) // 唯一标识:名称+分组,区分不同Job的任务
|
||||
// .build();
|
||||
//
|
||||
// // 4. 构建Trigger(触发器)
|
||||
// Trigger trigger = TriggerBuilder.newTrigger()
|
||||
// .withIdentity("trigger_" + jobName, jobGroup)
|
||||
// .withDescription(time)
|
||||
// .withSchedule(CronScheduleBuilder.cronSchedule(cronExpression))
|
||||
// .build();
|
||||
//
|
||||
// // 5. 注册任务到调度器
|
||||
// scheduler.scheduleJob(jobDetail, trigger);
|
||||
// System.out.println("成功创建任务:[" + jobGroup + "] 每日" + time + "执行,Cron:" + cronExpression);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 停止指定分组的所有Job
|
||||
// * @param jobGroup Job分组(如"dataSyncGroup")
|
||||
// */
|
||||
// public void pauseJobGroup(String jobGroup) throws SchedulerException {
|
||||
// scheduler.pauseJobs(GroupMatcher.jobGroupEquals(jobGroup));
|
||||
// System.out.println("已暂停分组[" + jobGroup + "]的所有任务");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 启动指定分组的所有Job
|
||||
// * @param jobGroup Job分组
|
||||
// */
|
||||
// public void resumeJobGroup(String jobGroup) throws SchedulerException {
|
||||
// scheduler.resumeJobs(GroupMatcher.jobGroupEquals(jobGroup));
|
||||
// System.out.println("已恢复分组[" + jobGroup + "]的所有任务");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 删除指定分组的所有Job
|
||||
// * @param jobGroup Job分组
|
||||
// */
|
||||
// public void deleteJobGroup(String jobGroup) throws SchedulerException {
|
||||
// // 1. 获取指定分组下的所有TriggerKey(返回Set)
|
||||
// Set<TriggerKey> triggerKeySet = scheduler.getTriggerKeys(GroupMatcher.triggerGroupEquals(jobGroup));
|
||||
// // 2. 将Set转换为List(使用Stream流,简洁高效)
|
||||
// List<TriggerKey> triggerKeyList = new ArrayList<>(triggerKeySet);
|
||||
// // 3. 取消触发器(此时需要List参数)
|
||||
// scheduler.unscheduleJobs(triggerKeyList);
|
||||
// // 4. 删除指定分组下的所有Job(getJobKeys返回Set,但deleteJobs支持Collection,List/Set都可以)
|
||||
// Set<JobKey> jobKeySet = scheduler.getJobKeys(GroupMatcher.jobGroupEquals(jobGroup));
|
||||
// scheduler.deleteJobs(new ArrayList<>(jobKeySet));
|
||||
// System.out.println("已删除分组[" + jobGroup + "]的所有任务");
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -1,48 +1,48 @@
|
||||
package com.sdm.project.manager;
|
||||
|
||||
import com.sdm.project.job.ProjectSyncJob;
|
||||
import com.sdm.project.job.TodoSyncJob;
|
||||
import com.sdm.project.model.entity.SimulationProjectSchedulerConfig;
|
||||
import com.sdm.project.model.entity.SimulationTodoSchedulerConfig;
|
||||
import com.sdm.project.service.ISimulationProjectSchedulerConfigService;
|
||||
import com.sdm.project.service.ISimulationTodoSchedulerConfigService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 应用启动时自动初始化两个Job
|
||||
*/
|
||||
@Component
|
||||
public class MultiJobStartupRunner implements CommandLineRunner {
|
||||
|
||||
private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("HH:mm:ss");
|
||||
|
||||
@Autowired
|
||||
private MultiJobManager multiJobManager;
|
||||
|
||||
@Value("${scheduler.todo}")
|
||||
private String schedulerTodoTime;
|
||||
|
||||
@Value("${scheduler.project}")
|
||||
private String schedulerProjectTime;
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
// ========== 初始化第一个Job:待办同步任务 ==========
|
||||
schedulerTodoTime = schedulerTodoTime.replaceAll("\\.",":");
|
||||
schedulerProjectTime = schedulerProjectTime.replaceAll("\\.",":");
|
||||
multiJobManager.createJob(TodoSyncJob.class, "todoSyncJob", Collections.singletonList(schedulerTodoTime));
|
||||
|
||||
// ========== 初始化第二个Job:项目同步任务 ==========
|
||||
multiJobManager.createJob(ProjectSyncJob.class, "projectSyncJob", Collections.singletonList(schedulerProjectTime));
|
||||
|
||||
System.out.println("应用启动成功!已初始化两个Job:待办同步任务、项目同步任务");
|
||||
}
|
||||
}
|
||||
//package com.sdm.project.manager;
|
||||
//
|
||||
//import com.sdm.project.job.ProjectSyncJob;
|
||||
//import com.sdm.project.job.TodoSyncJob;
|
||||
//import com.sdm.project.model.entity.SimulationProjectSchedulerConfig;
|
||||
//import com.sdm.project.model.entity.SimulationTodoSchedulerConfig;
|
||||
//import com.sdm.project.service.ISimulationProjectSchedulerConfigService;
|
||||
//import com.sdm.project.service.ISimulationTodoSchedulerConfigService;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.beans.factory.annotation.Value;
|
||||
//import org.springframework.boot.CommandLineRunner;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.time.format.DateTimeFormatter;
|
||||
//import java.util.Arrays;
|
||||
//import java.util.Collections;
|
||||
//import java.util.List;
|
||||
//
|
||||
///**
|
||||
// * 应用启动时自动初始化两个Job
|
||||
// */
|
||||
//@Component
|
||||
//public class MultiJobStartupRunner implements CommandLineRunner {
|
||||
//
|
||||
// private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("HH:mm:ss");
|
||||
//
|
||||
// @Autowired
|
||||
// private MultiJobManager multiJobManager;
|
||||
//
|
||||
// @Value("${scheduler.todo}")
|
||||
// private String schedulerTodoTime;
|
||||
//
|
||||
// @Value("${scheduler.project}")
|
||||
// private String schedulerProjectTime;
|
||||
//
|
||||
// @Override
|
||||
// public void run(String... args) throws Exception {
|
||||
// // ========== 初始化第一个Job:待办同步任务 ==========
|
||||
// schedulerTodoTime = schedulerTodoTime.replaceAll("\\.",":");
|
||||
// schedulerProjectTime = schedulerProjectTime.replaceAll("\\.",":");
|
||||
// multiJobManager.createJob(TodoSyncJob.class, "todoSyncJob", Collections.singletonList(schedulerTodoTime));
|
||||
//
|
||||
// // ========== 初始化第二个Job:项目同步任务 ==========
|
||||
// multiJobManager.createJob(ProjectSyncJob.class, "projectSyncJob", Collections.singletonList(schedulerProjectTime));
|
||||
//
|
||||
// System.out.println("应用启动成功!已初始化两个Job:待办同步任务、项目同步任务");
|
||||
// }
|
||||
//}
|
||||
@@ -146,4 +146,10 @@ public class SimulationNode implements Serializable {
|
||||
@TableField("approval_status")
|
||||
private String approvalStatus;
|
||||
|
||||
@TableField("projectId")
|
||||
private Integer projectId;
|
||||
|
||||
@TableField("projectSource")
|
||||
private String projectSource;
|
||||
|
||||
}
|
||||
|
||||
@@ -123,6 +123,14 @@ public class SpdmAddDemandReq extends BaseEntity {
|
||||
@JsonProperty(value = "aMemberList")
|
||||
private String aMemberList;
|
||||
|
||||
/**
|
||||
* hash值,同步待办时判断是否需要更新
|
||||
*/
|
||||
private String contentHash;
|
||||
|
||||
/**
|
||||
* hash值,同步待办时判断是否需要更新
|
||||
*/
|
||||
private String demandSource;
|
||||
|
||||
}
|
||||
|
||||
@@ -133,4 +133,8 @@ public class SpdmProjectNodeEditReq extends BaseEntity {
|
||||
private List<SpdmNodeExtraReq> extras;
|
||||
private String englishName;
|
||||
private String parentId;
|
||||
|
||||
private Integer projectId;
|
||||
|
||||
private String projectSource = "";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.sdm.project.model.req.ep;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class EpProjectQueryReq {
|
||||
|
||||
private String projectNum;
|
||||
|
||||
private String projectName;
|
||||
|
||||
private String difficultyType;
|
||||
|
||||
private Integer current;
|
||||
|
||||
private Integer pageSize;
|
||||
|
||||
}
|
||||
@@ -124,4 +124,9 @@ public class SpdmDemandVo extends BaseEntity {
|
||||
@JsonProperty(value = "aMemberList")
|
||||
private List<CIDUserResp> aMemberList;
|
||||
|
||||
/**
|
||||
* hash值,同步待办时判断是否需要更新
|
||||
*/
|
||||
private String demandSource;
|
||||
|
||||
}
|
||||
|
||||
@@ -97,4 +97,7 @@ public class SpdmNodeVo extends BaseEntity {
|
||||
|
||||
private String parentId;
|
||||
|
||||
private Integer projectId;
|
||||
|
||||
private String projectSource;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.sdm.project.service;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.outbridge.mode.GetProcessDataReq;
|
||||
import com.sdm.project.model.req.PushReportReq;
|
||||
import com.sdm.project.model.req.ep.EpProjectQueryReq;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
public interface ILyricInternalService {
|
||||
@@ -13,6 +14,10 @@ public interface ILyricInternalService {
|
||||
|
||||
SdmResponse getTodoList();
|
||||
|
||||
SdmResponse getTodoListByProjectNum(String projectNum);
|
||||
|
||||
SdmResponse getMainPlanListByProjectId(Integer projectId,String projectUuid);
|
||||
|
||||
SdmResponse getProjectList();
|
||||
|
||||
SdmResponse queryProjectPdt(String projectId,Integer current,Integer size);
|
||||
@@ -24,4 +29,7 @@ public interface ILyricInternalService {
|
||||
SdmResponse queryProjectBatch(String projectId,Integer current,Integer size);
|
||||
|
||||
SdmResponse queryProjectInfo(String projectId);
|
||||
|
||||
SdmResponse queryProjectInfoList(EpProjectQueryReq req);
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -111,6 +111,11 @@ public class NodeServiceImpl extends ServiceImpl<SimulationNodeMapper, Simulatio
|
||||
@Autowired
|
||||
private SimulationProjectMapper projectMapper;
|
||||
|
||||
public static final String SYNC_PROJECT_SOURCE = "同步";
|
||||
|
||||
@Autowired
|
||||
private ILyricInternalService lyricInternalService;
|
||||
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
@@ -156,6 +161,16 @@ public class NodeServiceImpl extends ServiceImpl<SimulationNodeMapper, Simulatio
|
||||
SdmResponse updatePermissionResponse = dataFeignClient.updatePermission(updatePermissionReq);
|
||||
log.info("创建项目阶段时,更新用户权限的返回值为:{}",updatePermissionResponse);
|
||||
}
|
||||
for (SpdmProjectNodeEditReq addNode : addNodeList) {
|
||||
String projectSource = addNode.getProjectSource();
|
||||
String nodeType = addNode.getNodeType();
|
||||
if (SYNC_PROJECT_SOURCE.equals(projectSource) && NodeTypeEnum.PROJECT.getValue().equals(nodeType)) {
|
||||
// 同步待办信息
|
||||
lyricInternalService.getTodoListByProjectNum(addNode.getNodeCode());
|
||||
// TODO 同步主计划信息
|
||||
lyricInternalService.getMainPlanListByProjectId(addNode.getProjectId(),addNode.getUuid());
|
||||
}
|
||||
}
|
||||
return SdmResponse.success(addNodeList);
|
||||
}
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@
|
||||
</select>
|
||||
|
||||
<select id="getAllList" resultType="com.sdm.project.model.vo.SpdmDemandVo">
|
||||
select * from simulation_demand
|
||||
select * from simulation_demand where demandSource = '同步'
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -7,13 +7,13 @@
|
||||
<insert id="addNodeBatch" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into simulation_node
|
||||
(uuid,ownRootNodeUuid,nodeName,nodeCode,englishName,nodeType,nodeSubType,nodeStatus,parentId,folderId,nodeLevel,beginTime,endTime,finishTime,progress,
|
||||
achieveStatus,exe_status,tenantId,description,detailImgUrl,creator,create_time,tag1,tag2,tag3,tag4,tag5,tag6,tag7,tag8,tag9,tag10)
|
||||
achieveStatus,exe_status,tenantId,description,detailImgUrl,creator,create_time,tag1,tag2,tag3,tag4,tag5,tag6,tag7,tag8,tag9,tag10,projectId,projectSource)
|
||||
values
|
||||
<foreach collection='addNodeList' item='addNode' index='index' separator=','>
|
||||
(#{addNode.uuid},#{addNode.ownRootNodeUuid},#{addNode.nodeName},#{addNode.nodeCode},#{addNode.englishName},#{addNode.nodeType},#{addNode.nodeSubType},'0',#{addNode.pid},
|
||||
'',1,#{addNode.beginTime},#{addNode.endTime},'',#{addNode.progressStatus},#{addNode.achieveStatus},#{addNode.exeStatus},#{addNode.tenantId},#{addNode.description},
|
||||
#{addNode.detailImgUrl},#{addNode.creator},#{addNode.createTime},#{addNode.tag1},#{addNode.tag2},
|
||||
#{addNode.tag3},#{addNode.tag4},#{addNode.tag5},#{addNode.tag6},#{addNode.tag7},#{addNode.tag8},#{addNode.tag9},#{addNode.tag10})
|
||||
#{addNode.tag3},#{addNode.tag4},#{addNode.tag5},#{addNode.tag6},#{addNode.tag7},#{addNode.tag8},#{addNode.tag9},#{addNode.tag10},#{addNode.projectId},#{addNode.projectSource})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user