Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
dj
/
rpc-staff
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 68855379
authored
Jun 26, 2026
by
潘诗林
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix:预学习周报支持传参
1 parent
60fc4aff
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
9 deletions
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/job/prelearn/PreLearnWeeklyReportJob.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/prelearn/PreLearnReportService.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/job/prelearn/PreLearnWeeklyReportJob.java
View file @
6885537
...
@@ -8,19 +8,48 @@ import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
...
@@ -8,19 +8,48 @@ import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.time.LocalDate
;
import
java.time.format.DateTimeFormatter
;
/**
* 预学习周报定时任务
* <p>
* 支持传参指定日期范围,参数格式:startDate,endDate(如 2026-06-15,2026-06-21)
* 无参数时默认统计上周一至上周日。
*/
@Service
@Service
@Slf4j
@Slf4j
@ElasticJobConf
(
name
=
"PreLearnWeeklyReportJob"
,
cron
=
"0 0 10 ? * MON"
,
description
=
"预学习周报定时任务,每周一上午10:00执行"
,
overwrite
=
true
)
@ElasticJobConf
(
name
=
"PreLearnWeeklyReportJob"
,
cron
=
"0 0 10 ? * MON"
,
description
=
"预学习周报定时任务,每周一上午10:00执行"
,
overwrite
=
true
)
public
class
PreLearnWeeklyReportJob
implements
SimpleJob
{
public
class
PreLearnWeeklyReportJob
implements
SimpleJob
{
private
static
final
DateTimeFormatter
PARAM_DATE_FMT
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
);
@Autowired
@Autowired
private
PreLearnReportService
preLearnReportService
;
private
PreLearnReportService
preLearnReportService
;
@Override
@Override
public
void
execute
(
ShardingContext
shardingContext
)
{
public
void
execute
(
ShardingContext
shardingContext
)
{
log
.
info
(
"[预学习周报] 任务开始
"
);
log
.
info
(
"[预学习周报] 任务开始
, jobParameter={}"
,
shardingContext
.
getJobParameter
()
);
try
{
try
{
String
param
=
shardingContext
.
getJobParameter
();
if
(
param
!=
null
&&
!
param
.
trim
().
isEmpty
())
{
// 传参模式:解析日期范围 "startDate,endDate"
String
[]
parts
=
param
.
trim
().
split
(
","
);
if
(
parts
.
length
==
2
)
{
LocalDate
startDate
=
LocalDate
.
parse
(
parts
[
0
].
trim
(),
PARAM_DATE_FMT
);
LocalDate
endDate
=
LocalDate
.
parse
(
parts
[
1
].
trim
(),
PARAM_DATE_FMT
);
log
.
info
(
"[预学习周报] 使用指定日期: {} ~ {}"
,
startDate
,
endDate
);
preLearnReportService
.
generateAndPushWeeklyReport
(
startDate
,
endDate
);
}
else
{
log
.
warn
(
"[预学习周报] 参数格式错误,期望 startDate,endDate,实际={}"
,
param
);
preLearnReportService
.
generateAndPushWeeklyReport
();
preLearnReportService
.
generateAndPushWeeklyReport
();
}
}
else
{
// 无参数:默认上周一至上周日
log
.
info
(
"[预学习周报] 无参数,使用默认上周范围"
);
preLearnReportService
.
generateAndPushWeeklyReport
();
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"[预学习周报] 执行异常"
,
e
);
log
.
error
(
"[预学习周报] 执行异常"
,
e
);
}
}
...
...
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/prelearn/PreLearnReportService.java
View file @
6885537
...
@@ -69,17 +69,27 @@ public class PreLearnReportService {
...
@@ -69,17 +69,27 @@ public class PreLearnReportService {
private
static
final
DateTimeFormatter
DATE_FMT
=
DateTimeFormatter
.
ofPattern
(
"yyyyMMdd"
);
private
static
final
DateTimeFormatter
DATE_FMT
=
DateTimeFormatter
.
ofPattern
(
"yyyyMMdd"
);
public
void
generateAndPushWeeklyReport
()
{
public
void
generateAndPushWeeklyReport
()
{
LocalDate
lastMonday
=
DateUtils
.
getLastWeekMonday
(
LocalDate
.
now
());
LocalDate
lastSunday
=
DateUtils
.
getLastWeekSunday
(
LocalDate
.
now
());
generateAndPushWeeklyReport
(
lastMonday
,
lastSunday
);
}
/**
* 生成并推送指定日期范围的周报
*
* @param startDate 统计开始日期(含)
* @param endDate 统计结束日期(含)
*/
public
void
generateAndPushWeeklyReport
(
LocalDate
startDate
,
LocalDate
endDate
)
{
log
.
info
(
"[预学习周报] 开始生成周报"
);
log
.
info
(
"[预学习周报] 开始生成周报"
);
try
{
try
{
// 1. 日期范围
// 1. 日期范围
LocalDate
lastMonday
=
DateUtils
.
getLastWeekMonday
(
LocalDate
.
now
());
Date
startTime
=
java
.
sql
.
Timestamp
.
valueOf
(
startDate
.
atStartOfDay
());
LocalDate
lastSunday
=
DateUtils
.
getLastWeekSunday
(
LocalDate
.
now
());
Date
endTime
=
java
.
sql
.
Timestamp
.
valueOf
(
endDate
.
atTime
(
23
,
59
,
59
));
Date
startTime
=
java
.
sql
.
Timestamp
.
valueOf
(
lastMonday
.
atStartOfDay
());
Date
endTime
=
java
.
sql
.
Timestamp
.
valueOf
(
lastSunday
.
atTime
(
23
,
59
,
59
));
String
weekRange
=
lastMonday
.
format
(
DATE_FMT
)
+
"-"
+
lastSunday
.
format
(
DATE_FMT
);
String
weekRange
=
startDate
.
format
(
DATE_FMT
)
+
"-"
+
endDate
.
format
(
DATE_FMT
);
String
fileName
=
"预学习周报_"
+
weekRange
;
String
fileName
=
"预学习周报_"
+
weekRange
;
log
.
info
(
"[预学习周报] 周期: {}~{}, 文件: {}"
,
lastMonday
,
lastSunday
,
fileName
);
log
.
info
(
"[预学习周报] 周期: {}~{}, 文件: {}"
,
startDate
,
endDate
,
fileName
);
// 2. 一次性查询上周生效的活动(含商品+门店)
// 2. 一次性查询上周生效的活动(含商品+门店)
MarketingActivityPageReqDTO
reqDTO
=
new
MarketingActivityPageReqDTO
();
MarketingActivityPageReqDTO
reqDTO
=
new
MarketingActivityPageReqDTO
();
...
@@ -145,7 +155,7 @@ public class PreLearnReportService {
...
@@ -145,7 +155,7 @@ public class PreLearnReportService {
String
fileUrl
=
aliOssUploadClient
.
uploadFileSimple4InputStream
(
String
fileUrl
=
aliOssUploadClient
.
uploadFileSimple4InputStream
(
bucketName
,
fileName
+
".xlsx"
,
inputStream
,
null
);
bucketName
,
fileName
+
".xlsx"
,
inputStream
,
null
);
log
.
info
(
"[预学习周报] 上传成功, url={}"
,
fileUrl
);
log
.
info
(
"[预学习周报] 上传成功, url={}"
,
fileUrl
);
sendToRobot
(
fileName
,
fileUrl
,
storeList
.
size
(),
staffList
.
size
(),
lastMonday
,
lastSunday
);
sendToRobot
(
fileName
,
fileUrl
,
storeList
.
size
(),
staffList
.
size
(),
startDate
,
endDate
);
}
else
{
}
else
{
log
.
warn
(
"[预学习周报] AliOSS未配置,跳过上传"
);
log
.
warn
(
"[预学习周报] AliOSS未配置,跳过上传"
);
}
}
...
...
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