Commit 8b7d102b by 章家宝

feat:新增自定义参数

1 parent 957d6d1e
......@@ -29,7 +29,8 @@ public class InspectionCustomerTagJob implements SimpleJob {
public void execute(ShardingContext shardingContext) {
log.info("AI客户标签同步定时任务开始执行");
try {
inspectionCustomerTagSyncService.syncCustomerTagFromInspection();
// 自定义参数如:指定开始、截止日期范围{"startDate":"2026-06-01","endDate":"2026-06-22"}
inspectionCustomerTagSyncService.syncCustomerTagFromInspection(shardingContext.getJobParameter());
} catch (Exception e) {
log.error("AI客户标签同步定时任务执行异常", e);
}
......
......@@ -97,19 +97,42 @@ public class InspectionCustomerTagSyncService {
private volatile Map<Integer, String> categoryCodeCache;
/**
* 同步昨天的 AI 客户标签数据
* 同步 AI 客户标签数据
*
* @param jobParameter 任务参数,JSON格式,如:{"startDate":"2026-06-01","endDate":"2026-06-22"}。
* 为空时默认跑昨天的数据
* @since 2026/06/26
*/
public void syncCustomerTagFromInspection() {
log.info("AI客户标签同步任务开始执行");
public void syncCustomerTagFromInspection(String jobParameter) {
log.info("AI客户标签同步任务开始执行, jobParameter={}", jobParameter);
try {
// 初始化维度和枚举缓存
initTagCache();
// 计算昨天的日期范围
Date yesterday = DateUtil.offsetDay(new Date(), -1);
String startTime = DateUtil.beginOfDay(yesterday).toString("yyyy-MM-dd HH:mm:ss");
String endTime = DateUtil.endOfDay(yesterday).toString("yyyy-MM-dd HH:mm:ss");
// 计算日期范围
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate startLocalDate;
LocalDate endLocalDate;
if (StrUtil.isBlank(jobParameter)) {
// 空参默认:昨天
LocalDate yesterday = LocalDate.now().minusDays(1);
startLocalDate = yesterday;
endLocalDate = yesterday;
} else {
JSONObject params = JSONUtil.parseObj(jobParameter);
String startDateStr = params.getStr("startDate");
String endDateStr = params.getStr("endDate");
startLocalDate = LocalDate.parse(startDateStr, dateFormatter);
endLocalDate = LocalDate.parse(endDateStr, dateFormatter);
}
// 开始时间补全为 0 点 0 分 0 秒,结束时间补全为 23 点 59 分 59 秒
Date startTimeDate = cn.com.glsx.dj.strategy.util.DateUtil.getStartOfDay(startLocalDate);
Date endTimeDate = cn.com.glsx.dj.strategy.util.DateUtil.getEndOfDay(endLocalDate);
String startTime = DateUtil.format(startTimeDate, "yyyy-MM-dd HH:mm:ss");
String endTime = DateUtil.format(endTimeDate, "yyyy-MM-dd HH:mm:ss");
log.info("同步时间范围:{} - {}", startTime, endTime);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!