Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
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 d2916970
authored
Jun 13, 2023
by
wangli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
1 parent
935d4bdf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
112 additions
and
43 deletions
project-order/src/main/java/com/alibaba/cloud/integration/order/service/impl/OrderServiceDetailImpl.java
project-order/src/main/java/com/alibaba/cloud/integration/order/service/impl/OrderServiceDetailImpl.java
View file @
d291697
...
...
@@ -36,6 +36,12 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
@Autowired
private
OrderEventMPDao
orderEventMPDao
;
@Autowired
private
OrgGroupMPDao
orgGroupMPDao
;
@Autowired
private
ProductCategoryMPDao
productCategoryMPDao
;
@Transactional
@Override
public
Result
<?>
getOrderServiceDetail
(
String
orderId
)
{
...
...
@@ -81,7 +87,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
// 查询预约单列表
List
<
OrderAppointment
>
appoints
=
this
.
queryOrderAppointments
(
orderId
);
if
(
appoints
.
isEmpty
())
{
if
(
appoints
.
isEmpty
())
{
// 没有指派单列表,返回
res
.
setOrderId
(
orderId
);
res
.
setOrders
(
List
.
of
());
...
...
@@ -94,8 +100,15 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
// 获取工程师基础信息列表
HashMap
<
String
,
EngineerInfo
>
egInfo
=
this
.
getEngineerInfos
(
egCodes
);
// 获取groupIds 和 group信息
List
<
String
>
groupIds
=
egInfo
.
values
().
stream
().
map
(
EngineerInfo:
:
getGroupId
).
collect
(
Collectors
.
toList
());
HashMap
<
String
,
OrgGroup
>
groups
=
this
.
queryOrgGroups
(
groupIds
);
// 获取工程师技能列表
HashMap
<
String
,
EngineerSkill
>
egSkill
=
this
.
getEngineerSkills
(
egCodes
);
Map
<
String
,
List
<
EngineerSkill
>>
egSkill
=
this
.
getEngineerSkills
(
egCodes
);
// 获取所有技能列表
HashMap
<
String
,
String
>
skills
=
this
.
queryAllSkills
();
// 获取subOrder订单timeline
Map
<
String
,
List
<
OrderTimeline
>>
timelines
=
this
.
getOrderTimelines
(
orderId
);
...
...
@@ -103,36 +116,38 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
// 对指派单列表按照subOrderId降序排序, 获取排序的subOrderId列表, 然后根据subOrderId分组
Comparator
<
OrderAppointment
>
sbDesc
=
Comparator
.
comparing
(
OrderAppointment:
:
getSuborderId
,
String
.
CASE_INSENSITIVE_ORDER
).
reversed
();
List
<
OrderAppointment
>
results
=
appoints
.
stream
().
sorted
(
sbDesc
).
collect
(
Collectors
.
toList
());
// 根据subOrderId分组
// Map<String, List<OrderAppointment>> appointOrders = results.stream().collect(Collectors.groupingBy(OrderAppointment::getSuborderId));
/*
String
lastSubOrderId
=
results
.
get
(
0
).
getSuborderId
();
for(OrderAppointment o: results) {
List
<
OrderAppointmentListResp
.
OrderAppointment
>
items
=
new
ArrayList
<>();
for
(
OrderAppointment
o
:
results
)
{
String
subOrderId
=
o
.
getSuborderId
();
EngineerInfo
eg
=
egInfo
.
getOrDefault
(
o
.
getEngineerCode
(),
null
);
EngineerSkill
es = egSkill.getOrDefault(o.getEngineerCode(), null);
List
<
EngineerSkill
>
es
=
egSkill
.
getOrDefault
(
o
.
getEngineerCode
(),
null
);
// 获取工程师姓名
String engineerName = (eg != null) ? eg.getName(): o.getEngineerCode();
String
engineerName
=
(
eg
!=
null
)
?
eg
.
getName
()
:
o
.
getEngineerCode
();
// 获取title
String
title
=
engineerName
;
if (lastSubOrderId.equals(subOrderId)) {
if
(
!
lastSubOrderId
.
equals
(
subOrderId
))
{
title
=
String
.
format
(
"%s_%s"
,
engineerName
,
this
.
Timestamp2Datetime
(
o
.
getExpectTime
(),
"yyyyMMdd"
));
}
OrderAppointmentListResp.OrderAppointment op = new OrderAppointmentListResp.OrderAppointment();
op.setTitle(title);
op.setEngineerCode(o.getEngineerCode());
op.setExpectTime(o.getExpectTime().toString());
op.setTimelines(this.packOrderTimeline(timelines.get(subOrderId)));
op.setItems(this.packEngineerInfos(eg, es));
OrderAppointmentListResp
.
OrderAppointment
item
=
new
OrderAppointmentListResp
.
OrderAppointment
();
item
.
setTitle
(
title
);
item
.
setEngineerCode
(
o
.
getEngineerCode
());
item
.
setExpectTime
(
o
.
getExpectTime
().
toString
());
item
.
setTimelines
(
this
.
packOrderTimeline
(
timelines
.
get
(
subOrderId
)));
item
.
setItems
(
this
.
packEngineerItems
(
eg
,
es
,
groups
.
get
(
eg
.
getGroupId
()),
skills
));
items
.
add
(
item
);
}
*/
return
null
;
res
.
setOrderId
(
orderId
);
res
.
setOrders
(
items
);
return
Result
.
success
(
res
);
}
@Transactional
...
...
@@ -171,39 +186,56 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
return
orderEventMPDao
.
selectList
(
lqw
);
}
private
HashMap
<
String
,
EngineerInfo
>
getEngineerInfos
(
List
<
String
>
egCodes
){
private
HashMap
<
String
,
OrgGroup
>
queryOrgGroups
(
List
<
String
>
groupIds
)
{
HashMap
<
String
,
OrgGroup
>
map
=
new
HashMap
<>();
if
(
groupIds
.
isEmpty
())
{
return
map
;
}
LambdaQueryWrapper
<
OrgGroup
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
in
(
OrgGroup:
:
getGroupId
,
groupIds
);
List
<
OrgGroup
>
records
=
orgGroupMPDao
.
selectList
(
lqw
);
for
(
OrgGroup
r
:
records
)
{
map
.
put
(
r
.
getGroupId
(),
r
);
}
return
map
;
}
private
HashMap
<
String
,
EngineerInfo
>
getEngineerInfos
(
List
<
String
>
egCodes
)
{
// 获取工程师信息列表
HashMap
<
String
,
EngineerInfo
>
map
=
new
HashMap
<>();
if
(
egCodes
.
isEmpty
())
{
return
map
;
}
LambdaQueryWrapper
<
EngineerInfo
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
in
(
EngineerInfo:
:
getEngineerCode
,
egCodes
);
List
<
EngineerInfo
>
rows
=
engineerInfoMPDao
.
selectList
(
lqw
);
for
(
EngineerInfo
row
:
rows
)
{
for
(
EngineerInfo
row
:
rows
)
{
map
.
put
(
row
.
getEngineerCode
(),
row
);
}
return
map
;
}
private
HashMap
<
String
,
EngineerSkill
>
getEngineerSkills
(
List
<
String
>
egCodes
)
{
private
Map
<
String
,
List
<
EngineerSkill
>
>
getEngineerSkills
(
List
<
String
>
egCodes
)
{
// 获取工程师技能列表
HashMap
<
String
,
EngineerSkill
>
map
=
new
HashMap
<>();
Map
<
String
,
List
<
EngineerSkill
>
>
map
=
new
HashMap
<>();
if
(
egCodes
.
isEmpty
())
{
return
map
;
}
LambdaQueryWrapper
<
EngineerSkill
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
in
(
EngineerSkill:
:
getEngineerCode
,
egCodes
);
lqw
.
eq
(
EngineerSkill:
:
getBean_status
,
1
);
lqw
.
eq
(
EngineerSkill:
:
getStatus
,
1
);
List
<
EngineerSkill
>
rows
=
engineerSkillMPDao
.
selectList
(
lqw
);
for
(
EngineerSkill
row:
rows
){
map
.
put
(
row
.
getEngineerCode
(),
row
);
}
return
map
;
// 根据engineerCode排序
Comparator
<
EngineerSkill
>
cmp
=
Comparator
.
comparing
(
EngineerSkill:
:
getEngineerCode
);
List
<
EngineerSkill
>
results
=
rows
.
stream
().
sorted
(
cmp
).
collect
(
Collectors
.
toList
());
// 根据engineerCode分组
return
results
.
stream
().
collect
(
Collectors
.
groupingBy
(
EngineerSkill:
:
getEngineerCode
));
}
private
Map
<
String
,
List
<
OrderTimeline
>>
getOrderTimelines
(
String
orderId
)
{
...
...
@@ -213,7 +245,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
lqw
.
eq
(
OrderTimeline:
:
getOrderId
,
orderId
);
List
<
OrderTimeline
>
timelines
=
orderTimelineMPDao
.
selectList
(
lqw
);
// 根据subOrderId + happen
d
字段排序
// 根据subOrderId + happen字段排序
Comparator
<
OrderTimeline
>
sb
=
Comparator
.
comparing
(
OrderTimeline:
:
getSuborderId
,
String
.
CASE_INSENSITIVE_ORDER
);
Comparator
<
OrderTimeline
>
happen
=
Comparator
.
comparing
(
OrderTimeline:
:
getHappen
);
Comparator
<
OrderTimeline
>
comp
=
sb
.
thenComparing
(
happen
);
...
...
@@ -223,31 +255,68 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
return
results
.
stream
().
collect
(
Collectors
.
groupingBy
(
OrderTimeline:
:
getSuborderId
));
}
private
List
<
KV
>
packEngineerInfos
(
EngineerInfo
eg
,
EngineerSkill
skill
)
{
private
HashMap
<
String
,
String
>
queryAllSkills
()
{
HashMap
<
String
,
String
>
map
=
new
HashMap
<>();
List
<
ProductCategory
>
records
=
productCategoryMPDao
.
selectList
(
null
);
for
(
ProductCategory
r
:
records
)
{
map
.
put
(
r
.
getProductCategoryId
(),
String
.
format
(
"%s%s"
,
r
.
getType
(),
r
.
getSkill
()));
}
return
map
;
}
private
List
<
KV
>
packEngineerItems
(
EngineerInfo
eg
,
List
<
EngineerSkill
>
egSkill
,
OrgGroup
group
,
HashMap
<
String
,
String
>
skills
)
{
// 获取工程师信息
List
<
KV
>
items
=
new
ArrayList
<>();
if
(
eg
==
null
&&
s
kill
==
null
)
{
if
(
eg
==
null
&&
egS
kill
==
null
)
{
return
items
;
}
if
(
eg
!=
null
)
{
String
groupName
=
""
;
String
kind
=
""
;
if
(
group
!=
null
)
{
groupName
=
group
.
getGroupName
();
switch
(
group
.
getKind
())
{
case
1
:
kind
=
"分站"
;
break
;
case
2
:
kind
=
"外围"
;
break
;
case
3
:
kind
=
"小组"
;
break
;
case
4
:
kind
=
"网点"
;
break
;
case
5
:
kind
=
"自保点"
;
break
;
default
:
break
;
}
}
items
.
add
(
this
.
packEngineer
(
"技术员:"
,
eg
.
getName
(),
"engineer"
));
items
.
add
(
this
.
packEngineer
(
"工号:"
,
eg
.
getEngineerCode
(),
""
));
items
.
add
(
this
.
packEngineer
(
"类型:"
,
(
eg
.
getKind
()
==
1
)
?
"全职"
:
"兼职"
,
""
));
items
.
add
(
this
.
packEngineer
(
"小组:"
,
groupName
,
""
));
items
.
add
(
this
.
packEngineer
(
"类型:"
,
kind
,
""
));
items
.
add
(
this
.
packEngineer
(
"性别:"
,
eg
.
getGender
(),
""
));
items
.
add
(
this
.
packEngineer
(
"工号:"
,
eg
.
getEngineerCode
(),
""
));
items
.
add
(
this
.
packEngineer
(
"手机号:"
,
eg
.
getPhone
(),
""
));
}
String
age
=
""
;
if
(
age
.
isEmpty
())
{
age
=
"未知"
;
}
else
{
age
=
eg
.
getBirth
();
if
(
egSkill
!=
null
)
{
List
<
String
>
rows
=
new
ArrayList
<>();
for
(
EngineerSkill
s
:
egSkill
)
{
String
skill
=
skills
.
getOrDefault
(
s
.
getCategoryId
(),
""
);
if
(
skill
.
isEmpty
())
{
continue
;
}
rows
.
add
(
skill
);
}
items
.
add
(
this
.
packEngineer
(
"技能"
,
String
.
join
(
"、"
,
rows
),
""
));
}
items
.
add
(
this
.
packEngineer
(
"小组:"
,
"老王组"
,
""
));
items
.
add
(
this
.
packEngineer
(
"性别/年龄:"
,
eg
.
getGender
()+
"/"
+
age
,
""
));
items
.
add
(
this
.
packEngineer
(
"技能:"
,
"TODO"
,
""
));
// TODO
return
items
;
}
...
...
@@ -266,13 +335,13 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
return
items
;
}
private
List
<
OrderServiceDynamicsResp
.
Dynamics
>
packOrderDynamics
(
List
<
OrderEvent
>
events
){
private
List
<
OrderServiceDynamicsResp
.
Dynamics
>
packOrderDynamics
(
List
<
OrderEvent
>
events
)
{
List
<
OrderServiceDynamicsResp
.
Dynamics
>
dynamics
=
new
ArrayList
<>();
// 根据happen排序
Comparator
<
OrderEvent
>
happen
=
Comparator
.
comparing
(
OrderEvent:
:
getHappen
);
List
<
OrderEvent
>
results
=
events
.
stream
().
sorted
(
happen
).
collect
(
Collectors
.
toList
());
for
(
OrderEvent
o
:
results
)
{
for
(
OrderEvent
o
:
results
)
{
OrderServiceDynamicsResp
.
Dynamics
d
=
new
OrderServiceDynamicsResp
.
Dynamics
();
d
.
setTitle
(
o
.
getEvent
());
d
.
setSubTitle
(
String
.
format
(
"操作人: %s"
,
o
.
getOperatorName
()));
...
...
@@ -288,7 +357,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
if
(
timelines
==
null
)
{
return
items
;
}
for
(
OrderTimeline
o
:
timelines
)
{
for
(
OrderTimeline
o
:
timelines
)
{
items
.
add
(
this
.
packTimeline
(
o
.
getEvent
(),
o
.
getHappen
(),
o
.
getStatus
().
toString
()));
}
return
items
;
...
...
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