Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
dj
/
rpc-mindworkplate
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 17871725
authored
Jun 25, 2026
by
章家宝
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:新增定时任务传参
1 parent
323670b1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
29 deletions
rpc-dj-mindworkplate/src/main/java/cn/com/glsx/dj/mindworkplate/job/HistoricalCustomerTagJob.java
rpc-dj-mindworkplate/src/main/java/cn/com/glsx/dj/mindworkplate/service/InspectionCustomerTagService.java
rpc-dj-mindworkplate/src/main/java/cn/com/glsx/dj/mindworkplate/job/HistoricalCustomerTagJob.java
View file @
1787172
...
...
@@ -4,10 +4,8 @@ import cn.com.glsx.dj.mindworkplate.service.InspectionCustomerTagService;
import
com.dangdang.ddframe.job.api.ShardingContext
;
import
com.dangdang.ddframe.job.api.simple.SimpleJob
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
/**
* 历史客户标签分析定时任务
...
...
@@ -18,36 +16,18 @@ import org.springframework.core.env.Environment;
public
class
HistoricalCustomerTagJob
implements
SimpleJob
{
@Autowired
private
Environment
environment
;
@Autowired
private
InspectionCustomerTagService
inspectionCustomerTagService
;
@Override
public
void
execute
(
ShardingContext
shardingContext
)
{
log
.
info
(
"----------历史客户标签分析任务开始----------"
);
// 读取配置参数
String
enabled
=
environment
.
getProperty
(
"historical.customer.tag.job.enabled"
);
String
startTime
=
environment
.
getProperty
(
"historical.customer.tag.job.startTime"
);
String
endTime
=
environment
.
getProperty
(
"historical.customer.tag.job.endTime"
);
// 检查是否启用
if
(!
"true"
.
equalsIgnoreCase
(
enabled
))
{
log
.
info
(
"历史客户标签分析任务未启用,跳过执行。配置项:historical.customer.tag.job.enabled={}"
,
enabled
);
return
;
}
// 检查时间范围参数
if
(
StringUtils
.
isEmpty
(
startTime
)
||
StringUtils
.
isEmpty
(
endTime
))
{
log
.
warn
(
"历史客户标签分析任务配置不完整,startTime={}, endTime={},跳过执行"
,
startTime
,
endTime
);
return
;
}
log
.
info
(
"历史客户标签分析任务配置:startTime={}, endTime={}"
,
startTime
,
endTime
);
try
{
int
processedCount
=
inspectionCustomerTagService
.
processHistoricalTags
(
startTime
,
endTime
);
// 自定义参数如:指定开始、截止日期范围{"startDate":"2026-06-01","endDate":"2026-06-22"}
String
jobParameter
=
shardingContext
.
getJobParameter
();
log
.
info
(
"历史客户标签分析任务参数:{}"
,
jobParameter
);
int
processedCount
=
inspectionCustomerTagService
.
processHistoricalTags
(
jobParameter
);
log
.
info
(
"----------历史客户标签分析任务结束,处理批次数量:{}----------"
,
processedCount
);
}
catch
(
Exception
e
)
{
log
.
error
(
"历史客户标签分析任务执行异常"
,
e
);
...
...
rpc-dj-mindworkplate/src/main/java/cn/com/glsx/dj/mindworkplate/service/InspectionCustomerTagService.java
View file @
1787172
...
...
@@ -11,9 +11,11 @@ import cn.com.glsx.dj.mindworkplate.model.ConversationDetail;
import
cn.com.glsx.dj.mindworkplate.model.InspectionCustomerTag
;
import
cn.com.glsx.framework.core.beans.rpc.RpcPagination
;
import
cn.com.glsx.scrm.equity.enums.DeleteFlagEnum
;
import
com.alibaba.fastjson.JSONObject
;
import
com.github.pagehelper.Page
;
import
com.github.pagehelper.PageHelper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -172,12 +174,33 @@ public class InspectionCustomerTagService {
* 处理历史客户标签分析
* 查询指定时间范围内未处理的批次,并提交客户标签分析任务
*
* @param startTime 开始时间(格式:yyyy-MM-dd HH:mm:ss)
* @param endTime 结束时间(格式:yyyy-MM-dd HH:mm:ss)
* @param jobParameter JSON格式参数,如:{"startDate":"2026-06-01","endDate":"2026-06-22"}
* @return 处理的批次数量
*/
public
int
processHistoricalTags
(
String
startTime
,
String
endTime
)
{
log
.
info
(
"开始处理历史客户标签分析,时间范围:{} ~ {}"
,
startTime
,
endTime
);
public
int
processHistoricalTags
(
String
jobParameter
)
{
log
.
info
(
"开始处理历史客户标签分析,参数:{}"
,
jobParameter
);
// 解析JSON参数
String
startTime
=
null
;
String
endTime
=
null
;
if
(
StringUtils
.
isNotBlank
(
jobParameter
))
{
try
{
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
jobParameter
);
startTime
=
jsonObject
.
getString
(
"startDate"
);
endTime
=
jsonObject
.
getString
(
"endDate"
);
}
catch
(
Exception
e
)
{
log
.
error
(
"解析任务参数失败:{}"
,
jobParameter
,
e
);
return
0
;
}
}
// 检查时间范围参数
if
(
StringUtils
.
isEmpty
(
startTime
)
||
StringUtils
.
isEmpty
(
endTime
))
{
log
.
warn
(
"历史客户标签分析任务参数不完整,startDate={}, endDate={},跳过执行"
,
startTime
,
endTime
);
return
0
;
}
log
.
info
(
"历史客户标签分析时间范围:{} ~ {}"
,
startTime
,
endTime
);
// 查询未处理的批次
List
<
ConversationBatch
>
unprocessedBatches
=
inspectionCustomerTagMapper
.
findUnprocessedBatchesByTimeRange
(
startTime
,
endTime
);
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment