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 9791b4c2
authored
Mar 21, 2026
by
zhouhaibao
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]驻店员工逻辑调整
1 parent
5656e840
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
29 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 @
9791b4c
...
@@ -223,34 +223,66 @@ public class SupervisorDashboardService {
...
@@ -223,34 +223,66 @@ public class SupervisorDashboardService {
}
}
// 5. 员工排序
// 5. 员工排序
if
(
req
.
getSortField
()
!=
null
)
{
if
(
req
.
getSortField
()
!=
null
)
{
int
sortField
=
req
.
getSortField
();
int
sortField
=
req
.
getSortField
();
int
sortDirection
=
req
.
getSortDirection
()
!=
null
?
req
.
getSortDirection
()
:
1
;
// 默认降序
// 注意:通常 1 代表升序,-1 代表降序?
// 你原代码注释写的是 "默认降序",但逻辑是: sortDirection == 1 ? -compareResult : compareResult
// 这意味着:如果 direction=1,结果取反(即降序);如果 direction!=1,结果不变(即升序)。
// 请确认你的业务定义:这里假设 1 = 降序,其他 = 升序
int
sortDirection
=
req
.
getSortDirection
()
!=
null
?
req
.
getSortDirection
()
:
1
;
storeAndEmployeePhoneList
.
sort
((
a
,
b
)
->
{
storeAndEmployeePhoneList
.
sort
((
a
,
b
)
->
{
int
compareResult
=
0
;
Comparator
<
Object
>
comparator
=
null
;
// 1. 根据字段选择对应的比较器,并统一处理 null 值 (null 排最后)
switch
(
sortField
)
{
switch
(
sortField
)
{
case
1
:
// 产值
case
1
:
// 产值
compareResult
=
a
.
getPersonalOutput
().
compareTo
(
b
.
getPersonalOutput
());
comparator
=
Comparator
.
comparing
(
obj
->
((
EmployeeRanking
)
obj
).
getPersonalOutput
(),
Comparator
.
nullsLast
(
Comparator
.
naturalOrder
())
);
break
;
break
;
case
2
:
// 客单价
case
2
:
// 客单价
compareResult
=
a
.
getPersonalUnitPrice
().
compareTo
(
b
.
getPersonalUnitPrice
());
comparator
=
Comparator
.
comparing
(
obj
->
((
EmployeeRanking
)
obj
).
getPersonalUnitPrice
(),
Comparator
.
nullsLast
(
Comparator
.
naturalOrder
())
);
break
;
break
;
case
3
:
// 转化率
case
3
:
// 转化率
compareResult
=
a
.
getPersonalConversion
().
compareTo
(
b
.
getPersonalConversion
());
comparator
=
Comparator
.
comparing
(
obj
->
((
EmployeeRanking
)
obj
).
getPersonalConversion
(),
Comparator
.
nullsLast
(
Comparator
.
naturalOrder
())
);
break
;
break
;
default
:
// 默认按产值
default
:
// 默认按产值
compareResult
=
a
.
getPersonalOutput
().
compareTo
(
b
.
getPersonalOutput
());
comparator
=
Comparator
.
comparing
(
obj
->
((
EmployeeRanking
)
obj
).
getPersonalOutput
(),
Comparator
.
nullsLast
(
Comparator
.
naturalOrder
())
);
break
;
break
;
}
}
return
sortDirection
==
1
?
-
compareResult
:
compareResult
;
// 降序时取反
// 2. 执行比较
int
result
=
comparator
.
compare
(
a
,
b
);
// 3. 根据方向调整顺序
// 原逻辑:direction == 1 (降序) -> 取反 (-result)
// 原逻辑:direction != 1 (升序) -> 不变 (result)
return
sortDirection
==
1
?
-
result
:
result
;
});
});
}
else
{
}
else
{
//
假设 getPersonalOutput() 返回的是 BigDecimal 或 Integer 等实现了 Comparable 的类型
//
原有逻辑保持不变,这部分已经是安全的
storeAndEmployeePhoneList
.
sort
(
storeAndEmployeePhoneList
.
sort
(
Comparator
.
comparing
(
Comparator
.
comparing
(
a
->
a
.
getPersonalOutput
(),
a
->
a
.
getPersonalOutput
(),
Comparator
.
nullsLast
(
Comparator
.
reverseOrder
())
// nullsLast 保证空值在最后,reverseOrder 实现降序
Comparator
.
nullsLast
(
Comparator
.
reverseOrder
())
// 注意:这里你之前用的是 reverseOrder() 直接降序。
// 为了和上面逻辑统一,建议上面用 naturalOrder() + 手动取反,或者这里也保持一致。
// 上面的 switch 逻辑是:先按自然顺序(升序)比,如果方向是降序再取反。
// 这里的 else 分支:直接用 reverseOrder() (降序)。
// 只要确保 "降序" 的定义在两端一致即可。
)
)
);
);
}
}
...
@@ -313,44 +345,61 @@ public class SupervisorDashboardService {
...
@@ -313,44 +345,61 @@ public class SupervisorDashboardService {
}
}
// 5. 员工排序
// 5. 员工排序
if
(
req
.
getSortField
()
!=
null
)
{
if
(
req
.
getSortField
()
!=
null
)
{
int
sortField
=
req
.
getSortField
();
int
sortField
=
req
.
getSortField
();
int
sortDirection
=
req
.
getSortDirection
()
!=
null
?
req
.
getSortDirection
()
:
1
;
// 默认降序
// 逻辑确认:1 = 降序 (取反), 其他 = 升序 (不变)
int
sortDirection
=
req
.
getSortDirection
()
!=
null
?
req
.
getSortDirection
()
:
1
;
// 定义基础比较器 (默认升序,且处理 null 值排在最后)
Comparator
<
EmployeeRanking
>
baseComparator
;
storePhoneMap
.
sort
((
a
,
b
)
->
{
int
compareResult
=
0
;
switch
(
sortField
)
{
switch
(
sortField
)
{
case
1
:
// 产值
compareResult
=
a
.
getPersonalOutput
().
compareTo
(
b
.
getPersonalOutput
());
break
;
case
2
:
// 成交数
compareResult
=
a
.
getDealCount
().
compareTo
(
b
.
getDealCount
());
break
;
case
3
:
// 战败数
case
3
:
// 战败数
compareResult
=
a
.
getDefeatCount
().
compareTo
(
b
.
getDefeatCount
());
baseComparator
=
Comparator
.
comparing
(
EmployeeRanking:
:
getDefeatCount
,
Comparator
.
nullsLast
(
Comparator
.
naturalOrder
())
);
break
;
break
;
case
4
:
// 录音数
case
4
:
// 录音数
compareResult
=
a
.
getRecordingCount
().
compareTo
(
b
.
getRecordingCount
());
baseComparator
=
Comparator
.
comparing
(
EmployeeRanking:
:
getRecordingCount
,
Comparator
.
nullsLast
(
Comparator
.
naturalOrder
())
);
break
;
break
;
case
5
:
// 线索数
case
5
:
// 线索数
compareResult
=
a
.
getLeadCount
().
compareTo
(
b
.
getLeadCount
());
baseComparator
=
Comparator
.
comparing
(
EmployeeRanking:
:
getLeadCount
,
Comparator
.
nullsLast
(
Comparator
.
naturalOrder
())
);
break
;
break
;
case
6
:
// 缺失率
case
6
:
// 缺失率
compareResult
=
a
.
getMissingRate
().
compareTo
(
b
.
getMissingRate
());
baseComparator
=
Comparator
.
comparing
(
EmployeeRanking:
:
getMissingRate
,
Comparator
.
nullsLast
(
Comparator
.
naturalOrder
())
);
break
;
break
;
default
:
// 成交数
default
:
// 成交数
compareResult
=
a
.
getDealCount
().
compareTo
(
b
.
getDealCount
());
baseComparator
=
Comparator
.
comparing
(
EmployeeRanking:
:
getDealCount
,
Comparator
.
nullsLast
(
Comparator
.
naturalOrder
())
);
break
;
break
;
}
}
return
sortDirection
==
1
?
-
compareResult
:
compareResult
;
// 降序时取反
});
// 根据方向应用排序:如果是降序 (1),则反转比较器
Comparator
<
EmployeeRanking
>
finalComparator
=
(
sortDirection
==
1
)
?
baseComparator
.
reversed
()
:
baseComparator
;
storePhoneMap
.
sort
(
finalComparator
);
}
else
{
}
else
{
// 默认按产值降序排序
// 默认逻辑:按成交数降序,空值在最后
// 假设 getPersonalOutput() 返回的是 BigDecimal 或 Integer 等实现了 Comparable 的类型
storePhoneMap
.
sort
(
storePhoneMap
.
sort
(
Comparator
.
comparing
(
Comparator
.
comparing
(
a
->
a
.
getDealCount
()
,
EmployeeRanking:
:
getDealCount
,
Comparator
.
nullsLast
(
Comparator
.
reverseOrder
())
// nullsLast 保证空值在最后,reverseOrder 实现降序
Comparator
.
nullsLast
(
Comparator
.
reverseOrder
())
)
)
);
);
}
}
...
...
rpc-dj-supervisor/src/test/java/cn/com/glsx/dj/supervisor/remote/SupervisorDashboardRemoteImplTest.java
View file @
9791b4c
...
@@ -51,6 +51,8 @@ public class SupervisorDashboardRemoteImplTest extends BaseServiceTest {
...
@@ -51,6 +51,8 @@ public class SupervisorDashboardRemoteImplTest extends BaseServiceTest {
req
.
setBizs
(
2
);
req
.
setBizs
(
2
);
req
.
setDateType
(
2
);
req
.
setDateType
(
2
);
req
.
setNeedAiAnalysis
(
true
);
req
.
setNeedAiAnalysis
(
true
);
req
.
setSortField
(
4
);
req
.
setSortDirection
(
1
);
RpcResponse
<
SupervisorDashboardVO
>
response
=
supervisorDashboardRemote
.
getDashboardBehaviorData
(
req
);
RpcResponse
<
SupervisorDashboardVO
>
response
=
supervisorDashboardRemote
.
getDashboardBehaviorData
(
req
);
System
.
out
.
println
(
JSON
.
toJSONString
(
response
));
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