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 c10c1782
authored
Jun 05, 2023
by
wangli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现服务单动态
1 parent
1923bf1f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
6 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 @
c10c178
...
...
@@ -2,9 +2,7 @@ package com.alibaba.cloud.integration.order.service.impl;
import
com.alibaba.cloud.integration.common.Result
;
import
com.alibaba.cloud.integration.order.dao.*
;
import
com.alibaba.cloud.integration.order.dto.KV
;
import
com.alibaba.cloud.integration.order.dto.OrderAppointmentListResp
;
import
com.alibaba.cloud.integration.order.dto.OrderServiceDetailResp
;
import
com.alibaba.cloud.integration.order.dto.*
;
import
com.alibaba.cloud.integration.order.entity.*
;
import
com.alibaba.cloud.integration.order.service.OrderServiceDetail
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
...
...
@@ -12,6 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.sql.Timestamp
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
import
java.util.stream.Collectors
;
...
...
@@ -33,6 +33,9 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
@Autowired
private
OrderTimelineDao
orderTimelineDao
;
@Autowired
private
OrderEventDao
orderEventDao
;
@Transactional
@Override
public
Result
<?>
getOrderServiceDetail
(
String
orderId
)
{
...
...
@@ -55,7 +58,17 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
@Transactional
@Override
public
Result
<?>
getOrderServiceDynamics
(
String
orderId
)
{
return
null
;
// 获取服务单动态
List
<
OrderEvent
>
events
=
this
.
queryOrderEvents
(
orderId
);
// pack 动态items
List
<
OrderServiceDynamicsResp
.
Dynamics
>
dynamics
=
this
.
packOrderDynamics
(
events
);
OrderServiceDynamicsResp
res
=
new
OrderServiceDynamicsResp
();
res
.
setOrderId
(
orderId
);
res
.
setDynamics
(
dynamics
);
return
Result
.
success
(
res
);
}
@Transactional
...
...
@@ -130,8 +143,6 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
return
orderRequestDao
.
selectOne
(
lqw
);
}
private
List
<
OrderAppointment
>
queryOrderAppointments
(
String
orderId
)
{
// 获取指派单记录列表
LambdaQueryWrapper
<
OrderAppointment
>
lqw
=
new
LambdaQueryWrapper
<>();
...
...
@@ -139,6 +150,12 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
return
orderAppointmentDao
.
selectList
(
lqw
);
}
private
List
<
OrderEvent
>
queryOrderEvents
(
String
orderId
)
{
LambdaQueryWrapper
<
OrderEvent
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
eq
(
OrderEvent:
:
getOrderId
,
orderId
);
return
orderEventDao
.
selectList
(
lqw
);
}
private
HashMap
<
String
,
EngineerInfo
>
getEngineerInfos
(
List
<
String
>
egCodes
){
// 获取工程师信息列表
HashMap
<
String
,
EngineerInfo
>
map
=
new
HashMap
<>();
...
...
@@ -226,6 +243,23 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
return
items
;
}
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
)
{
OrderServiceDynamicsResp
.
Dynamics
d
=
new
OrderServiceDynamicsResp
.
Dynamics
();
d
.
setTitle
(
o
.
getEvent
());
d
.
setSubTitle
(
String
.
format
(
"操作人: %s"
,
o
.
getOperatorName
()));
d
.
setTime
(
this
.
Timestamp2Datetime
(
o
.
getHappen
(),
"yyyy-mm-dd HH:MM"
));
d
.
setMemo
(
o
.
getMemo
());
dynamics
.
add
(
d
);
}
return
dynamics
;
}
private
List
<
KV
>
packOrderTimeline
(
List
<
OrderTimeline
>
timelines
)
{
List
<
KV
>
items
=
new
ArrayList
<>();
if
(
timelines
==
null
)
{
...
...
@@ -258,4 +292,9 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
item
.
setParams
(
params
);
return
item
;
}
private
String
Timestamp2Datetime
(
Timestamp
t
,
String
pattern
)
{
DateTimeFormatter
df
=
DateTimeFormatter
.
ofPattern
(
pattern
);
return
df
.
format
(
t
.
toLocalDateTime
());
}
}
\ No newline at end of file
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