Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
dj
/
rop-dj-supervisor-mini
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 ecd7f089
authored
Mar 22, 2026
by
范富荣
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化录音复盘生成接口
1 parent
7c8608ec
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
12 deletions
src/main/java/cn/com/glsx/dj/supervisor/controller/SupervisorTaskInfoController.java
src/main/java/cn/com/glsx/dj/supervisor/controller/SupervisorTaskInfoController.java
View file @
ecd7f08
...
@@ -234,28 +234,38 @@ public class SupervisorTaskInfoController {
...
@@ -234,28 +234,38 @@ public class SupervisorTaskInfoController {
}
}
/**
/**
* 生成最近
3 年所有周一到周日
* 生成最近
N 年所有周一到周日(默认为 3 年)
*
*
* @return
* @param request 请求对象
* @return 返回每周的日期范围列表
*/
*/
@ApiOperation
(
value
=
"生成最近
3
年所有周一到周日"
)
@ApiOperation
(
value
=
"生成最近
N
年所有周一到周日"
)
@ServiceMethod
(
method
=
"dj.api.supervisor.mini.get.generateWeeklyRanges"
,
needInSession
=
NeedInSessionType
.
NO
)
@ServiceMethod
(
method
=
"dj.api.supervisor.mini.get.generateWeeklyRanges"
,
needInSession
=
NeedInSessionType
.
NO
)
public
RopResponse
<
List
<
Map
<
String
,
String
>>>
generateWeeklyRanges
(
AbstractRopRequest
request
)
{
public
RopResponse
<
List
<
Map
<
String
,
String
>>>
generateWeeklyRanges
(
AbstractRopRequest
request
)
{
int
yearCount
=
Integer
.
parseInt
(
environment
.
getProperty
(
"supervisor.weekly.range.years"
,
"3"
));
LocalDate
now
=
LocalDate
.
now
();
LocalDate
now
=
LocalDate
.
now
();
// 获取当前周的周一
LocalDate
currentMonday
=
now
.
with
(
TemporalAdjusters
.
previousOrSame
(
DayOfWeek
.
MONDAY
));
LocalDate
currentMonday
=
now
.
with
(
TemporalAdjusters
.
previousOrSame
(
DayOfWeek
.
MONDAY
));
LocalDate
endMonday
=
now
.
minusYears
(
yearCount
).
with
(
TemporalAdjusters
.
previousOrSame
(
DayOfWeek
.
MONDAY
));
// 从配置中获取年数,默认为 3 年
int
yearCount
=
Integer
.
parseInt
(
environment
.
getProperty
(
"supervisor.weekly.range.years"
,
"3"
));
// 计算起始限制日期(N 年前的周一)
LocalDate
startDateLimit
=
now
.
minusYears
(
yearCount
).
with
(
TemporalAdjusters
.
previousOrSame
(
DayOfWeek
.
MONDAY
));
// 预估
容量:每年约 53 周,避免底层数组频繁扩容
// 预估
周数以优化 ArrayList 容量 (每年约 52 周)
List
<
Map
<
String
,
String
>>
result
=
new
ArrayList
<>(
yearCount
*
53
+
1
);
List
<
Map
<
String
,
String
>>
result
=
new
ArrayList
<>(
yearCount
*
53
);
while
(!
currentMonday
.
isBefore
(
endMonday
))
{
while
(!
currentMonday
.
isBefore
(
startDateLimit
))
{
Map
<
String
,
String
>
weekRange
=
new
HashMap
<>(
4
);
// 初始化容量为 4
LocalDate
sunday
=
currentMonday
.
plusDays
(
6
);
weekRange
.
put
(
"startDate"
,
currentMonday
.
toString
());
// 周一
weekRange
.
put
(
"endDate"
,
currentMonday
.
plusDays
(
6
).
toString
());
// 周日
Map
<
String
,
String
>
weekRange
=
new
HashMap
<>(
4
);
weekRange
.
put
(
"startDate"
,
currentMonday
.
toString
());
// 周一
weekRange
.
put
(
"endDate"
,
sunday
.
toString
());
// 周日
result
.
add
(
weekRange
);
result
.
add
(
weekRange
);
currentMonday
=
currentMonday
.
minusWeeks
(
1
);
// 上一周
// 往前推一周
currentMonday
=
currentMonday
.
minusWeeks
(
1
);
}
}
return
RopResponse
.
success
(
result
);
return
RopResponse
.
success
(
result
);
}
}
...
...
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