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 1bc188dc
authored
May 11, 2023
by
wangli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增服务端详情接口
1 parent
4475259d
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
403 additions
and
0 deletions
project-order/src/main/java/com/alibaba/cloud/integration/order/controller/OrderServiceDetailController.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/EngineerInfoDao.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/EngineerSkillDao.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/OrderTimelineDao.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/KV.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/OrderServiceDetailResp.java
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/EngineerInfo.java
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/EngineerSkill.java
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/OrderTimeline.java
project-order/src/main/java/com/alibaba/cloud/integration/order/service/OrderServiceDetail.java
project-order/src/main/java/com/alibaba/cloud/integration/order/service/impl/OrderServiceDetailImpl.java
project-order/src/main/java/com/alibaba/cloud/integration/order/controller/OrderServiceDetailController.java
0 → 100644
View file @
1bc188d
package
com
.
alibaba
.
cloud
.
integration
.
order
.
controller
;
import
com.alibaba.cloud.integration.common.Result
;
import
com.alibaba.cloud.integration.order.service.OrderServiceDetail
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
public
class
OrderServiceDetailController
{
@Autowired
private
OrderServiceDetail
orderServiceDetail
;
@GetMapping
(
"/order/service/detail"
)
public
Result
<?>
GetOrderServiceDetail
(
@RequestParam
String
orderId
)
{
return
orderServiceDetail
.
GetOrderServiceDetail
(
orderId
);
}
}
\ No newline at end of file
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/EngineerInfoDao.java
0 → 100644
View file @
1bc188d
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dao
;
import
com.alibaba.cloud.integration.order.entity.EngineerInfo
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
@Mapper
public
interface
EngineerInfoDao
extends
BaseMapper
<
EngineerInfo
>
{
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/EngineerSkillDao.java
0 → 100644
View file @
1bc188d
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dao
;
import
com.alibaba.cloud.integration.order.entity.EngineerSkill
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
@Mapper
public
interface
EngineerSkillDao
extends
BaseMapper
<
EngineerSkill
>
{
}
\ No newline at end of file
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/OrderTimelineDao.java
0 → 100644
View file @
1bc188d
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dao
;
import
com.alibaba.cloud.integration.order.entity.OrderTimeline
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
@Mapper
public
interface
OrderTimelineDao
extends
BaseMapper
<
OrderTimeline
>
{
}
\ No newline at end of file
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/KV.java
0 → 100644
View file @
1bc188d
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dto
;
import
lombok.Data
;
@Data
public
class
KV
{
private
String
title
;
private
String
value
;
private
String
type
;
private
String
status
;
private
Object
params
;
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/OrderServiceDetailResp.java
0 → 100644
View file @
1bc188d
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dto
;
import
lombok.Data
;
import
java.util.List
;
@Data
public
class
OrderServiceDetailResp
{
private
String
orderId
;
private
String
status
;
private
String
statusDesc
;
private
String
risk
;
private
String
riskDesc
;
private
List
<
KV
>
orderServiceItems
;
private
List
<
OrderAppointment
>
orderAppointments
;
@Data
public
static
class
OrderAppointment
{
private
String
title
;
private
String
expectTime
;
private
List
<
List
<
KV
>>
engineers
;
private
List
<
KV
>
timelines
;
}
}
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/EngineerInfo.java
0 → 100644
View file @
1bc188d
package
com
.
alibaba
.
cloud
.
integration
.
order
.
entity
;
import
lombok.Data
;
import
java.sql.Timestamp
;
@Data
public
class
EngineerInfo
{
private
Integer
engineerId
;
private
Integer
subsectionId
;
private
String
code
;
private
String
name
;
private
String
cosmosId
;
private
String
gender
;
private
String
birth
;
private
String
phone
;
private
String
addr
;
private
Integer
kind
;
private
String
grade
;
private
String
credentials
;
private
String
vehicle
;
private
String
vehicleNo
;
private
String
beanStatus
;
private
String
memo
;
private
Timestamp
createTime
;
private
Timestamp
updateTime
;
}
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/EngineerSkill.java
0 → 100644
View file @
1bc188d
package
com
.
alibaba
.
cloud
.
integration
.
order
.
entity
;
import
lombok.Data
;
import
java.sql.Timestamp
;
@Data
public
class
EngineerSkill
{
private
Integer
id
;
private
Integer
engineerId
;
private
String
categoryId
;
private
String
brand
;
private
String
kind
;
private
String
skill
;
private
Integer
status
;
private
String
memo
;
private
Timestamp
createTime
;
private
Timestamp
updateTime
;
}
\ No newline at end of file
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/OrderTimeline.java
0 → 100644
View file @
1bc188d
package
com
.
alibaba
.
cloud
.
integration
.
order
.
entity
;
import
lombok.Data
;
import
java.sql.Timestamp
;
@Data
public
class
OrderTimeline
{
private
String
orderId
;
private
String
suborderId
;
private
String
event
;
private
String
happen
;
private
Integer
status
;
private
Timestamp
createTime
;
private
Timestamp
updateTime
;
}
project-order/src/main/java/com/alibaba/cloud/integration/order/service/OrderServiceDetail.java
0 → 100644
View file @
1bc188d
package
com
.
alibaba
.
cloud
.
integration
.
order
.
service
;
import
com.alibaba.cloud.integration.common.Result
;
public
interface
OrderServiceDetail
{
Result
<?>
GetOrderServiceDetail
(
String
orderId
);
}
project-order/src/main/java/com/alibaba/cloud/integration/order/service/impl/OrderServiceDetailImpl.java
0 → 100644
View file @
1bc188d
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.OrderServiceDetailResp
;
import
com.alibaba.cloud.integration.order.entity.OrderService
;
import
com.alibaba.cloud.integration.order.entity.OrderAppointment
;
import
com.alibaba.cloud.integration.order.entity.EngineerInfo
;
import
com.alibaba.cloud.integration.order.entity.EngineerSkill
;
import
com.alibaba.cloud.integration.order.entity.OrderTimeline
;
import
com.alibaba.cloud.integration.order.service.OrderServiceDetail
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Service
public
class
OrderServiceDetailImpl
implements
OrderServiceDetail
{
@Autowired
private
OrderServiceDao
orderServiceDao
;
@Autowired
private
OrderAppointmentDao
orderAppointmentDao
;
@Autowired
private
EngineerSkillDao
engineerSkillDao
;
@Autowired
private
EngineerInfoDao
engineerInfoDao
;
@Autowired
private
OrderTimelineDao
orderTimelineDao
;
@Transactional
@Override
public
Result
<?>
GetOrderServiceDetail
(
String
orderId
)
{
// 查询订单详情
OrderService
detail
=
this
.
GetOrderDetail
(
orderId
);
// 查询指派列表
List
<
OrderServiceDetailResp
.
OrderAppointment
>
items
=
new
ArrayList
<>();
List
<
OrderAppointment
>
appoints
=
this
.
GetOrderAppointments
(
orderId
);
// 工程师ID列表
List
<
Integer
>
egIds
=
new
ArrayList
<>();
for
(
OrderAppointment
o:
appoints
)
{
egIds
.
add
(
o
.
getEngineerId
());
}
// 获取工程师基础信息列表
HashMap
<
Integer
,
EngineerInfo
>
egInfo
=
this
.
GetEngineerInfos
(
egIds
);
// 获取工程师技能列表
HashMap
<
Integer
,
EngineerSkill
>
egSkill
=
this
.
GetEngineerSkills
(
egIds
);
// 获取订单timeline
Map
<
String
,
List
<
OrderTimeline
>>
timelines
=
this
.
GetOrderTimelines
(
orderId
);
// 对指派单列表按照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
));
// 获取排序的subOrderId(降序)
List
<
String
>
subOrderIds
=
new
ArrayList
<>();
for
(
String
k:
appointOrders
.
keySet
()){
subOrderIds
.
add
(
k
);
}
Collections
.
reverse
(
subOrderIds
);
System
.
out
.
println
(
subOrderIds
);
for
(
String
subOrderId:
subOrderIds
){
List
<
OrderAppointment
>
orders
=
appointOrders
.
get
(
subOrderId
);
OrderAppointment
order
=
orders
.
get
(
0
);
// 第一个订单
OrderServiceDetailResp
.
OrderAppointment
op
=
new
OrderServiceDetailResp
.
OrderAppointment
();
// 获取工程师列表信息
List
<
List
<
KV
>>
egInfos
=
new
ArrayList
<>();
for
(
OrderAppointment
o:
orders
)
{
Integer
egId
=
o
.
getEngineerId
();
egInfos
.
add
(
this
.
PackEngineerInfos
(
egInfo
.
get
(
egId
),
egSkill
.
get
(
egId
)));
}
op
.
setEngineers
(
egInfos
);
//获取timeline信息
op
.
setTimelines
(
this
.
PackOrderTimeline
(
timelines
.
get
(
subOrderId
)));
op
.
setTitle
(
order
.
getSuborderId
());
op
.
setExpectTime
(
order
.
getExpectTime
().
toString
());
items
.
add
(
op
);
}
// 返回结果
OrderServiceDetailResp
res
=
new
OrderServiceDetailResp
();
res
.
setOrderId
(
orderId
);
res
.
setStatus
(
detail
.
getStatus
());
res
.
setOrderServiceItems
(
this
.
PackOrderDetail
(
detail
));
res
.
setOrderAppointments
(
items
);
return
Result
.
success
(
res
);
}
private
OrderService
GetOrderDetail
(
String
orderId
)
{
// 获取服务单记录
LambdaQueryWrapper
<
OrderService
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
eq
(
OrderService:
:
getOrderId
,
orderId
);
return
orderServiceDao
.
selectOne
(
lqw
);
}
private
List
<
OrderAppointment
>
GetOrderAppointments
(
String
orderId
)
{
// 获取指派单记录列表
LambdaQueryWrapper
<
OrderAppointment
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
eq
(
OrderAppointment:
:
getOrderId
,
orderId
);
return
orderAppointmentDao
.
selectList
(
lqw
);
}
private
HashMap
<
Integer
,
EngineerInfo
>
GetEngineerInfos
(
List
<
Integer
>
egIds
){
// 获取工程师信息列表
HashMap
<
Integer
,
EngineerInfo
>
map
=
new
HashMap
<>();
LambdaQueryWrapper
<
EngineerInfo
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
in
(
EngineerInfo:
:
getEngineerId
,
egIds
);
List
<
EngineerInfo
>
rows
=
engineerInfoDao
.
selectList
(
lqw
);
for
(
EngineerInfo
row:
rows
){
map
.
put
(
row
.
getEngineerId
(),
row
);
}
return
map
;
}
private
HashMap
<
Integer
,
EngineerSkill
>
GetEngineerSkills
(
List
<
Integer
>
egIds
)
{
// 获取工程师技能列表
HashMap
<
Integer
,
EngineerSkill
>
map
=
new
HashMap
<>();
LambdaQueryWrapper
<
EngineerSkill
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
in
(
EngineerSkill:
:
getEngineerId
,
egIds
);
List
<
EngineerSkill
>
rows
=
engineerSkillDao
.
selectList
(
lqw
);
for
(
EngineerSkill
row:
rows
){
map
.
put
(
row
.
getEngineerId
(),
row
);
}
return
map
;
}
private
Map
<
String
,
List
<
OrderTimeline
>>
GetOrderTimelines
(
String
orderId
)
{
HashMap
<
String
,
List
<
OrderTimeline
>>
map
=
new
HashMap
<>();
LambdaQueryWrapper
<
OrderTimeline
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
eq
(
OrderTimeline:
:
getOrderId
,
orderId
);
List
<
OrderTimeline
>
timelines
=
orderTimelineDao
.
selectList
(
lqw
);
// 根据subOrderId + happend字段排序
Comparator
<
OrderTimeline
>
sb
=
Comparator
.
comparing
(
OrderTimeline:
:
getSuborderId
,
String
.
CASE_INSENSITIVE_ORDER
);
Comparator
<
OrderTimeline
>
happen
=
Comparator
.
comparing
(
OrderTimeline:
:
getHappen
);
Comparator
<
OrderTimeline
>
comp
=
sb
.
thenComparing
(
happen
);
List
<
OrderTimeline
>
results
=
timelines
.
stream
().
sorted
(
comp
).
collect
(
Collectors
.
toList
());
// 根据subOrderId分组
return
results
.
stream
().
collect
(
Collectors
.
groupingBy
(
OrderTimeline:
:
getSuborderId
));
}
private
List
<
KV
>
PackOrderDetail
(
OrderService
order
)
{
List
<
KV
>
items
=
new
ArrayList
<>();
items
.
add
(
this
.
PackOrderItem
(
"客户姓名:"
,
order
.
getName
()));
items
.
add
(
this
.
PackOrderItem
(
"标签:"
,
order
.
getTags
()));
items
.
add
(
this
.
PackOrderItem
(
"客户电话:"
,
order
.
getPhone
()));
items
.
add
(
this
.
PackOrderItem
(
"设备:"
,
order
.
getType
()));
items
.
add
(
this
.
PackOrderItem
(
"服务:"
,
order
.
getSkill
()));
items
.
add
(
this
.
PackOrderItem
(
"故障描述:"
,
order
.
getFaultDescribe
()));
items
.
add
(
this
.
PackOrderItem
(
"备注:"
,
order
.
getApplyNote
()));
items
.
add
(
this
.
PackOrderItem
(
"意向时间:"
,
""
));
items
.
add
(
this
.
PackOrderItem
(
"时间要求:"
,
order
.
getExpectTimeDesc
()));
items
.
add
(
this
.
PackOrderItem
(
"预约方式:"
,
order
.
getSource
()));
return
items
;
}
private
List
<
KV
>
PackEngineerInfos
(
EngineerInfo
eg
,
EngineerSkill
skill
)
{
// 获取工程师信息
String
kind
=
""
;
String
age
=
""
;
if
(
eg
.
getKind
()
==
1
)
{
kind
=
"全职"
;
}
else
{
kind
=
"兼职"
;
}
if
(
age
.
isEmpty
())
{
age
=
"未知"
;
}
else
{
age
=
eg
.
getBirth
();
}
List
<
KV
>
items
=
new
ArrayList
<>();
items
.
add
(
this
.
PackEngineer
(
"技术员:"
,
eg
.
getName
(),
"engineer"
));
items
.
add
(
this
.
PackEngineer
(
"小组:"
,
"老王组"
,
""
));
items
.
add
(
this
.
PackEngineer
(
"类型:"
,
kind
,
""
));
items
.
add
(
this
.
PackEngineer
(
"性别/年龄:"
,
eg
.
getGender
()+
"/"
+
age
,
""
));
items
.
add
(
this
.
PackEngineer
(
"手机号:"
,
eg
.
getPhone
(),
""
));
items
.
add
(
this
.
PackEngineer
(
"工号:"
,
eg
.
getCode
(),
""
));
items
.
add
(
this
.
PackEngineer
(
"技能:"
,
skill
.
getSkill
(),
""
));
return
items
;
}
private
List
<
KV
>
PackOrderTimeline
(
List
<
OrderTimeline
>
timelines
)
{
List
<
KV
>
items
=
new
ArrayList
<>();
if
(
timelines
==
null
)
{
return
items
;
}
for
(
OrderTimeline
o:
timelines
)
{
items
.
add
(
this
.
PackTimeline
(
o
.
getEvent
(),
o
.
getHappen
(),
o
.
getStatus
().
toString
()));
}
return
items
;
}
private
KV
PackOrderItem
(
String
title
,
String
value
)
{
return
this
.
PackKV
(
title
,
value
,
null
,
null
,
null
);
}
private
KV
PackEngineer
(
String
title
,
String
value
,
Object
params
)
{
return
this
.
PackKV
(
title
,
value
,
null
,
null
,
params
);
}
private
KV
PackTimeline
(
String
title
,
String
value
,
String
status
)
{
return
this
.
PackKV
(
title
,
value
,
null
,
status
,
null
);
}
private
KV
PackKV
(
String
title
,
String
value
,
String
type
,
String
status
,
Object
params
)
{
KV
item
=
new
KV
();
item
.
setTitle
(
title
);
item
.
setValue
(
value
);
item
.
setType
(
type
);
item
.
setStatus
(
status
);
item
.
setParams
(
params
);
return
item
;
}
}
\ 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