Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
dj
/
rpc-dj-supervisor
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 a08de2fb
authored
Mar 23, 2026
by
zhouhaibao
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]驻店员工逻辑调整
1 parent
15cb2d36
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
91 deletions
rpc-dj-supervisor/src/main/java/cn/com/glsx/dj/supervisor/service/SupervisorDashboardService.java
rpc-dj-supervisor/src/test/java/cn/com/glsx/dj/supervisor/remote/SupervisorDashboardRemoteImplTest.java
rpc-dj-supervisor/src/main/java/cn/com/glsx/dj/supervisor/service/SupervisorDashboardService.java
View file @
a08de2f
...
...
@@ -2,6 +2,7 @@ package cn.com.glsx.dj.supervisor.service;
import
cn.com.glsx.dj.mindworkplate.model.EarlyWarningThresholdConfig
;
import
cn.com.glsx.dj.mindworkplate.remote.WarningMsgRemote
;
import
cn.com.glsx.dj.peanalysis.dto.res.output.ProvinceOutputResponse
;
import
cn.com.glsx.dj.smartcarlife.dto.ShopMerchantDirectorConfigDTO
;
import
cn.com.glsx.dj.smartcarlife.dto.merchantPerformanceConfig.StaffBaseInfoDTO
;
import
cn.com.glsx.dj.smartcarlife.enums.DirectorTypeEnum
;
...
...
@@ -46,6 +47,7 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
...
...
@@ -223,66 +225,30 @@ public class SupervisorDashboardService {
}
// 5. 员工排序
if
(
req
.
getSortField
()
!=
null
)
{
int
sortField
=
req
.
getSortField
();
// 注意:通常 1 代表升序,-1 代表降序?
// 你原代码注释写的是 "默认降序",但逻辑是: sortDirection == 1 ? -compareResult : compareResult
// 这意味着:如果 direction=1,结果取反(即降序);如果 direction!=1,结果不变(即升序)。
// 请确认你的业务定义:这里假设 1 = 降序,其他 = 升序
int
sortDirection
=
req
.
getSortDirection
()
!=
null
?
req
.
getSortDirection
()
:
1
;
storeAndEmployeePhoneList
.
sort
((
a
,
b
)
->
{
Comparator
<
Object
>
comparator
=
null
;
Comparator
<
EmployeeRanking
>
comparator
=
null
;
boolean
isDesc
=
(
req
.
getSortDirection
()
==
1
);
// true = DESC
// 1. 根据字段选择对应的比较器,并统一处理 null 值 (null 排最后)
switch
(
sortField
)
{
case
1
:
// 产值
comparator
=
Comparator
.
comparing
(
obj
->
((
EmployeeRanking
)
obj
).
getPersonalOutput
(),
Comparator
.
nullsLast
(
Comparator
.
naturalOrder
())
);
break
;
case
2
:
// 客单价
comparator
=
Comparator
.
comparing
(
obj
->
((
EmployeeRanking
)
obj
).
getPersonalUnitPrice
(),
Comparator
.
nullsLast
(
Comparator
.
naturalOrder
())
);
switch
(
req
.
getSortField
())
{
case
1
:
comparator
=
buildComparator
(
EmployeeRanking:
:
getPersonalOutput
,
isDesc
);
break
;
case
3
:
// 转化率
comparator
=
Comparator
.
comparing
(
obj
->
((
EmployeeRanking
)
obj
).
getPersonalConversion
(),
Comparator
.
nullsLast
(
Comparator
.
naturalOrder
())
);
case
2
:
comparator
=
buildComparator
(
EmployeeRanking:
:
getPersonalUnitPrice
,
isDesc
);
break
;
default
:
// 默认按产值
comparator
=
Comparator
.
comparing
(
obj
->
((
EmployeeRanking
)
obj
).
getPersonalOutput
(),
Comparator
.
nullsLast
(
Comparator
.
naturalOrder
())
);
case
3
:
comparator
=
buildComparator
(
EmployeeRanking:
:
getPersonalConversion
,
isDesc
);
break
;
}
// 2. 执行比较
int
result
=
comparator
.
compare
(
a
,
b
);
// 3. 根据方向调整顺序
// 原逻辑:direction == 1 (降序) -> 取反 (-result)
// 原逻辑:direction != 1 (升序) -> 不变 (result)
return
sortDirection
==
1
?
-
result
:
result
;
});
storeAndEmployeePhoneList
.
sort
(
comparator
);
}
else
{
//
原有逻辑保持不变,这部分已经是安全的
//
默认按产值降序,null 排最后
storeAndEmployeePhoneList
.
sort
(
Comparator
.
comparing
(
a
->
a
.
getPersonalOutput
()
,
EmployeeRanking:
:
getPersonalOutput
,
Comparator
.
nullsLast
(
Comparator
.
reverseOrder
())
// 注意:这里你之前用的是 reverseOrder() 直接降序。
// 为了和上面逻辑统一,建议上面用 naturalOrder() + 手动取反,或者这里也保持一致。
// 上面的 switch 逻辑是:先按自然顺序(升序)比,如果方向是降序再取反。
// 这里的 else 分支:直接用 reverseOrder() (降序)。
// 只要确保 "降序" 的定义在两端一致即可。
)
);
}
...
...
@@ -291,6 +257,17 @@ public class SupervisorDashboardService {
return
vo
;
}
private
<
T
extends
Comparable
<?
super
T
>>
Comparator
<
EmployeeRanking
>
buildComparator
(
Function
<
EmployeeRanking
,
T
>
keyExtractor
,
boolean
descending
)
{
Comparator
<
T
>
comp
=
Comparator
.
naturalOrder
();
if
(
descending
)
{
comp
=
comp
.
reversed
();
}
return
Comparator
.
comparing
(
keyExtractor
,
Comparator
.
nullsLast
(
comp
));
}
public
SupervisorDashboardVO
getDashboardBehaviorData
(
DashboardQueryReq
req
)
{
SupervisorDashboardVO
vo
=
new
SupervisorDashboardVO
();
...
...
@@ -346,56 +323,27 @@ public class SupervisorDashboardService {
// 5. 员工排序
// 5. 员工排序
if
(
req
.
getSortField
()
!=
null
)
{
int
sortField
=
req
.
getSortField
();
// 逻辑确认:1 = 降序 (取反), 其他 = 升序 (不变)
int
sortDirection
=
req
.
getSortDirection
()
!=
null
?
req
.
getSortDirection
()
:
1
;
// 定义基础比较器 (默认升序,且处理 null 值排在最后)
Comparator
<
EmployeeRanking
>
baseComparator
;
Comparator
<
EmployeeRanking
>
comparator
=
null
;
boolean
isDesc
=
(
req
.
getSortDirection
()
==
1
);
// true = DESC
switch
(
sortField
)
{
case
3
:
// 战败数
baseComparator
=
Comparator
.
comparing
(
EmployeeRanking:
:
getDefeatCount
,
Comparator
.
nullsLast
(
Comparator
.
naturalOrder
())
);
break
;
case
4
:
// 录音数
baseComparator
=
Comparator
.
comparing
(
EmployeeRanking:
:
getRecordingCount
,
Comparator
.
nullsLast
(
Comparator
.
naturalOrder
())
);
break
;
case
5
:
// 线索数
baseComparator
=
Comparator
.
comparing
(
EmployeeRanking:
:
getLeadCount
,
Comparator
.
nullsLast
(
Comparator
.
naturalOrder
())
);
switch
(
req
.
getSortField
())
{
case
4
:
comparator
=
buildComparator
(
EmployeeRanking:
:
getDealCount
,
isDesc
);
break
;
case
6
:
// 缺失率
baseComparator
=
Comparator
.
comparing
(
EmployeeRanking:
:
getMissingRate
,
Comparator
.
nullsLast
(
Comparator
.
naturalOrder
())
);
case
5
:
comparator
=
buildComparator
(
EmployeeRanking:
:
getDefeatCount
,
isDesc
);
break
;
default
:
// 成交数
baseComparator
=
Comparator
.
comparing
(
EmployeeRanking:
:
getDealCount
,
Comparator
.
nullsLast
(
Comparator
.
naturalOrder
())
);
case
6
:
comparator
=
buildComparator
(
EmployeeRanking:
:
getRecordingCount
,
isDesc
);
break
;
}
// 根据方向应用排序:如果是降序 (1),则反转比较器
Comparator
<
EmployeeRanking
>
finalComparator
=
(
sortDirection
==
1
)
?
baseComparator
.
reversed
()
:
baseComparator
;
storePhoneMap
.
sort
(
finalComparator
);
storePhoneMap
.
sort
(
comparator
);
}
else
{
// 默认
逻辑:按成交数降序,空值在
最后
// 默认
按产值降序,null 排
最后
storePhoneMap
.
sort
(
Comparator
.
comparing
(
EmployeeRanking:
:
getDealCount
,
...
...
rpc-dj-supervisor/src/test/java/cn/com/glsx/dj/supervisor/remote/SupervisorDashboardRemoteImplTest.java
View file @
a08de2f
...
...
@@ -34,10 +34,12 @@ public class SupervisorDashboardRemoteImplTest extends BaseServiceTest {
public
void
testGetDashboardData
()
{
DashboardQueryReq
req
=
new
DashboardQueryReq
();
req
.
setSupervisorId
(
"63c121922cba4956b2aac3f21dacd92f"
);
req
.
setStartDate
(
"2026-03-
20
"
);
req
.
setStartDate
(
"2026-03-
01
"
);
req
.
setEndDate
(
"2026-03-20"
);
req
.
setDateType
(
0
);
req
.
setNeedAiAnalysis
(
true
);
req
.
setSortField
(
1
);
req
.
setSortDirection
(
0
);
RpcResponse
<
SupervisorDashboardVO
>
response
=
supervisorDashboardRemote
.
getDashboardData
(
req
);
System
.
out
.
println
(
JSON
.
toJSONString
(
response
));
}
...
...
@@ -52,7 +54,7 @@ public class SupervisorDashboardRemoteImplTest extends BaseServiceTest {
req
.
setDateType
(
2
);
req
.
setNeedAiAnalysis
(
true
);
req
.
setSortField
(
4
);
req
.
setSortDirection
(
1
);
req
.
setSortDirection
(
0
);
RpcResponse
<
SupervisorDashboardVO
>
response
=
supervisorDashboardRemote
.
getDashboardBehaviorData
(
req
);
System
.
out
.
println
(
JSON
.
toJSONString
(
response
));
}
...
...
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