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 3c9980d8
authored
Jul 24, 2023
by
wangli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
1 parent
c279415f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
72 deletions
project-order/src/main/java/com/dituhui/pea/order/service/impl/ScheduleServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/ScheduleServiceImpl.java
View file @
3c9980d
...
...
@@ -3,7 +3,6 @@ package com.dituhui.pea.order.service.impl;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.dituhui.pea.common.BusinessException
;
import
com.dituhui.pea.common.Result
;
...
...
@@ -25,6 +24,9 @@ import java.util.stream.Collectors;
public
class
ScheduleServiceImpl
implements
ScheduleService
{
@Autowired
private
OrderInfoMPDao
orderInfoMPDao
;
@Autowired
private
OrgTeamMPDao
orgTeamMPDao
;
@Autowired
...
...
@@ -34,12 +36,6 @@ public class ScheduleServiceImpl implements ScheduleService {
private
OrgGroupMPDao
orgGroupMPDao
;
@Autowired
private
OrderRequestMPDao
orderRequestMPDao
;
@Autowired
private
OrderAppointmentMPDao
orderAppointmentMPDao
;
@Autowired
private
EngineerInfoMPDao
engineerInfoMPDao
;
@Autowired
...
...
@@ -71,6 +67,7 @@ public class ScheduleServiceImpl implements ScheduleService {
@Override
public
Result
<?>
getScheduleOverview
(
long
page
,
long
size
,
LocalDate
date
,
String
levelType
,
List
<
String
>
levelIds
)
{
// 排班结果
// 获取team列表, 以team排序分页
IPage
<
OrgTeam
>
pg
=
this
.
queryOrgTeams
(
page
,
size
,
levelType
,
levelIds
);
...
...
@@ -89,15 +86,16 @@ public class ScheduleServiceImpl implements ScheduleService {
team
.
setLevel
(
"team"
);
// 获取改team订单列表
List
<
Order
Request
>
orders
=
this
.
queryOrderRequests
(
t
.
getTeamId
(),
date
);
List
<
Order
Info
>
orders
=
this
.
queryOrderRequests
(
t
.
getTeamId
(),
date
);
team
.
setOrder
(
this
.
getTeamOrderSum
(
orders
,
skillMapping
));
// 技术员指派单列表
Map
<
String
,
List
<
Order
Appointment
>>
engineerOrders
=
new
HashMap
<>();
Map
<
String
,
List
<
Order
Info
>>
engineerOrders
=
new
HashMap
<>();
if
(
ListUtils
.
isNotEmpty
(
orders
))
{
List
<
String
>
orderRequestIds
=
orders
.
stream
().
map
(
OrderRequest:
:
getOrderId
).
collect
(
Collectors
.
toList
());
List
<
OrderAppointment
>
orderAppointments
=
this
.
queryOrderAppointments
(
orderRequestIds
,
date
);
engineerOrders
=
orderAppointments
.
stream
().
collect
(
Collectors
.
groupingBy
(
OrderAppointment:
:
getEngineerCode
));
List
<
String
>
orderRequestIds
=
orders
.
stream
().
map
(
OrderInfo:
:
getOrderId
).
collect
(
Collectors
.
toList
());
List
<
OrderInfo
>
orderAppointments
=
orderInfoMPDao
.
selectByDtAndOrderIds
(
date
,
orderRequestIds
);
orderAppointments
.
sort
(
Comparator
.
comparing
(
OrderInfo:
:
getEngineerCode
));
engineerOrders
=
orderAppointments
.
stream
().
collect
(
Collectors
.
groupingBy
(
OrderInfo:
:
getEngineerCode
));
}
// 获取team技术员列表
...
...
@@ -115,10 +113,10 @@ public class ScheduleServiceImpl implements ScheduleService {
String
engineerCode
=
entry
.
getKey
();
EngineerInfo
engineerInfo
=
entry
.
getValue
().
get
(
0
);
List
<
String
>
orderIds
=
engineerOrders
.
getOrDefault
(
engineerCode
,
new
ArrayList
<>()).
stream
().
map
(
Order
Appointment
:
:
getOrderId
).
collect
(
Collectors
.
toList
());
List
<
String
>
orderIds
=
engineerOrders
.
getOrDefault
(
engineerCode
,
new
ArrayList
<>()).
stream
().
map
(
Order
Info
:
:
getOrderId
).
collect
(
Collectors
.
toList
());
List
<
Order
Request
>
orders2
=
new
ArrayList
<>();
for
(
Order
Request
o
:
orders
)
{
List
<
Order
Info
>
orders2
=
new
ArrayList
<>();
for
(
Order
Info
o
:
orders
)
{
if
(
orderIds
.
contains
(
o
.
getOrderId
()))
{
orders2
.
add
(
o
);
}
...
...
@@ -153,28 +151,29 @@ public class ScheduleServiceImpl implements ScheduleService {
@Override
public
Result
<?>
getScheduleEngineerOverview
(
LocalDate
date
,
String
engineerCode
)
throws
BusinessException
{
// 获取技术员已排班概况
EngineerInfo
engineer
=
engineerInfoMPDao
.
getByEngineerCode
(
engineerCode
);
if
(
engineer
==
null
)
{
throw
new
BusinessException
(
"分销员不存在"
);
}
List
<
LabelValueDTO
>
emptyTips
=
new
ArrayList
<>();
List
<
OrderAppointment
>
orderAppointments
=
orderAppointmentMPDao
.
selectByEngineerCodeAndDt
(
engineerCode
,
date
);
List
<
OrderInfo
>
orderAppointments
=
orderInfoMPDao
.
selectByEngineerCodeAndDtAndAppointmentStatus
(
engineerCode
,
date
,
"CONFIRM"
);
List
<
TimeLineDTO
>
timelines
=
new
ArrayList
<>();
for
(
Order
Appointment
o
:
orderAppointments
)
{
for
(
Order
Info
o
:
orderAppointments
)
{
TimeLineDTO
item
=
new
TimeLineDTO
();
item
.
setOrderId
(
o
.
getOrderId
());
item
.
setPreStatus
(
o
.
getPreStatus
());
item
.
setAppointmentStatus
(
o
.
getStatus
());
item
.
setStartTime
(
TimeUtils
.
IsoTimestamp2DateTime
(
o
.
getExpectStartTime
()));
item
.
setEndTime
(
TimeUtils
.
IsoTimestamp2DateTime
(
o
.
getExpectEndTime
()));
item
.
setAppointmentStatus
(
o
.
getAppointmentStatus
());
item
.
setStartTime
(
TimeUtils
.
IsoTimestamp2DateTime
(
o
.
getPlanStartTime
()));
item
.
setEndTime
(
TimeUtils
.
IsoTimestamp2DateTime
(
o
.
getPlanEndTime
()));
item
.
setTips
(
emptyTips
);
timelines
.
add
(
item
);
}
Map
<
String
,
List
<
Order
Appointment
>>
statusGroup
=
orderAppointments
.
stream
().
collect
(
Collectors
.
groupingBy
(
OrderAppointment:
:
get
Status
));
List
<
Order
Appointment
>
empty
=
new
ArrayList
<>();
Integer
countPending
=
statusGroup
.
getOrDefault
(
"
ASSIGNED"
,
empty
).
size
()
+
statusGroup
.
getOrDefault
(
"CONTACTED"
,
empty
).
size
()
+
statusGroup
.
getOrDefault
(
"DEPARTED
"
,
empty
).
size
();
Map
<
String
,
List
<
Order
Info
>>
statusGroup
=
orderAppointments
.
stream
().
collect
(
Collectors
.
groupingBy
(
OrderInfo:
:
getService
Status
));
List
<
Order
Info
>
empty
=
new
ArrayList
<>();
Integer
countPending
=
statusGroup
.
getOrDefault
(
"
INIT"
,
empty
).
size
()
+
statusGroup
.
getOrDefault
(
"CONTACTED"
,
empty
).
size
()
+
statusGroup
.
getOrDefault
(
"PENDING
"
,
empty
).
size
();
List
<
LabelValueDTO
>
dynamics
=
new
ArrayList
<>();
dynamics
.
add
(
new
LabelValueDTO
(
"姓名"
,
engineer
.
getName
()));
...
...
@@ -190,13 +189,13 @@ public class ScheduleServiceImpl implements ScheduleService {
dynamics
.
add
(
new
LabelValueDTO
(
"工作时间"
,
"08:00-18:00"
));
dynamics
.
add
(
new
LabelValueDTO
(
"交通工具"
,
"电动车"
));
List
<
String
>
orderIds
=
orderAppointments
.
stream
().
map
(
Order
Appointment
:
:
getOrderId
).
collect
(
Collectors
.
toList
());
List
<
Order
Request
>
orderRequests
=
new
ArrayList
<>();
List
<
String
>
orderIds
=
orderAppointments
.
stream
().
map
(
Order
Info
:
:
getOrderId
).
collect
(
Collectors
.
toList
());
List
<
Order
Info
>
orderRequests
=
new
ArrayList
<>();
if
(
orderIds
!=
null
&&
!
orderIds
.
isEmpty
())
{
orderRequests
=
order
RequestMPDao
.
selectByOrderIds
(
orderIds
);
orderRequests
=
order
InfoMPDao
.
selectByDtAndOrderIds
(
date
,
orderIds
);
}
List
<
ScheduleEngineerOverviewResp
.
Order
>
orders
=
new
ArrayList
<>();
for
(
Order
Request
o
:
orderRequests
)
{
for
(
Order
Info
o
:
orderRequests
)
{
ScheduleEngineerOverviewResp
.
Order
item
=
new
ScheduleEngineerOverviewResp
.
Order
();
item
.
setOrderId
(
o
.
getOrderId
());
item
.
setLocation
(
String
.
format
(
"%s,%s"
,
o
.
getX
(),
o
.
getY
()));
...
...
@@ -255,31 +254,23 @@ public class ScheduleServiceImpl implements ScheduleService {
return
orgTeamEngineerMPDao
.
selectList
(
lqw
);
}
private
List
<
Order
Request
>
queryOrderRequests
(
String
teamId
,
LocalDate
date
)
{
LambdaQueryWrapper
<
Order
Request
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
eq
(
Order
Request
:
:
getDt
,
date
);
lqw
.
in
(
Order
Request
:
:
getOrgTeamId
,
teamId
);
lqw
.
eq
(
Order
Request:
:
getAppointmentStatus
,
"ASSIGNED
"
);
return
order
Request
MPDao
.
selectList
(
lqw
);
private
List
<
Order
Info
>
queryOrderRequests
(
String
teamId
,
LocalDate
date
)
{
LambdaQueryWrapper
<
Order
Info
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
eq
(
Order
Info
:
:
getDt
,
date
);
lqw
.
in
(
Order
Info
:
:
getOrgTeamId
,
teamId
);
lqw
.
eq
(
Order
Info:
:
getAppointmentStatus
,
"CONFIRM
"
);
return
order
Info
MPDao
.
selectList
(
lqw
);
}
private
List
<
OrderAppointment
>
queryOrderAppointments
(
List
<
String
>
orderIds
,
LocalDate
date
)
{
LambdaQueryWrapper
<
OrderAppointment
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
in
(
OrderAppointment:
:
getOrderId
,
orderIds
);
lqw
.
eq
(
OrderAppointment:
:
getDt
,
date
);
lqw
.
orderByAsc
(
OrderAppointment:
:
getEngineerCode
);
return
orderAppointmentMPDao
.
selectList
(
lqw
);
}
private
ScheduleOverviewResp
.
OrderSum
getTeamOrderSum
(
List
<
OrderRequest
>
orders
,
HashMap
<
String
,
String
>
skillMapping
)
{
private
ScheduleOverviewResp
.
OrderSum
getTeamOrderSum
(
List
<
OrderInfo
>
orders
,
HashMap
<
String
,
String
>
skillMapping
)
{
ScheduleOverviewResp
.
OrderSum
s
=
new
ScheduleOverviewResp
.
OrderSum
();
List
<
Order
Request
>
emtpy
=
new
ArrayList
<>();
List
<
Order
Info
>
emtpy
=
new
ArrayList
<>();
HashMap
<
String
,
Integer
>
skillCounter
=
new
HashMap
<>();
Map
<
String
,
List
<
Order
Request
>>
cc
=
orders
.
stream
().
collect
(
Collectors
.
groupingBy
(
OrderRequest
:
:
getSkill
));
for
(
Map
.
Entry
<
String
,
List
<
OrderRequest
>>
entry:
cc
.
entrySet
())
{
Map
<
String
,
List
<
Order
Info
>>
cc
=
orders
.
stream
().
collect
(
Collectors
.
groupingBy
(
OrderInfo
:
:
getSkill
));
for
(
Map
.
Entry
<
String
,
List
<
OrderInfo
>>
entry
:
cc
.
entrySet
())
{
String
skill
=
entry
.
getKey
();
Integer
count
=
entry
.
getValue
().
size
();
String
skillCategory
=
skillMapping
.
get
(
skill
);
...
...
@@ -313,15 +304,15 @@ public class ScheduleServiceImpl implements ScheduleService {
// 获取skill映射
HashMap
<
String
,
String
>
skillMap
=
this
.
getSkillCategoryMapping
();
QueryWrapper
<
Order
Request
>
wrapper
=
new
QueryWrapper
<>();
QueryWrapper
<
Order
Info
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
select
(
"skill, COUNT(*) as count"
)
.
lambda
()
.
eq
(
Order
Request
:
:
getDt
,
date
)
.
in
(
levelType
.
equals
(
"cluster"
),
Order
Request
:
:
getOrgClusterId
,
levelValue
)
.
in
(
levelType
.
equals
(
"branch"
),
Order
Request
:
:
getOrgBranchId
,
levelValue
)
.
in
(
levelType
.
equals
(
"group"
),
Order
Request
:
:
getOrgGroupId
,
levelValue
)
.
groupBy
(
Order
Request
:
:
getSkill
);
List
<
Map
<
String
,
Object
>>
results
=
order
Request
MPDao
.
selectMaps
(
wrapper
);
.
eq
(
Order
Info
:
:
getDt
,
date
)
.
in
(
levelType
.
equals
(
"cluster"
),
Order
Info
:
:
getOrgClusterId
,
levelValue
)
.
in
(
levelType
.
equals
(
"branch"
),
Order
Info
:
:
getOrgBranchId
,
levelValue
)
.
in
(
levelType
.
equals
(
"group"
),
Order
Info
:
:
getOrgGroupId
,
levelValue
)
.
groupBy
(
Order
Info
:
:
getSkill
);
List
<
Map
<
String
,
Object
>>
results
=
order
Info
MPDao
.
selectMaps
(
wrapper
);
for
(
Map
<
String
,
Object
>
result
:
results
)
{
String
skill
=
(
String
)
result
.
get
(
"skill"
);
Long
countValue
=
(
Long
)
result
.
get
(
"count"
);
...
...
@@ -340,15 +331,15 @@ public class ScheduleServiceImpl implements ScheduleService {
HashMap
<
String
,
Integer
>
groupCategoryMapping
=
this
.
getGroupCategoryMapping
(
levelType
,
levelValue
);
QueryWrapper
<
Order
Request
>
wrapper
=
new
QueryWrapper
<>();
QueryWrapper
<
Order
Info
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
select
(
"org_group_id, COUNT(*) as count"
)
.
lambda
()
.
eq
(
Order
Request
:
:
getDt
,
date
)
.
in
(
levelType
.
equals
(
"cluster"
),
Order
Request
:
:
getOrgClusterId
,
levelValue
)
.
in
(
levelType
.
equals
(
"branch"
),
Order
Request
:
:
getOrgBranchId
,
levelValue
)
.
in
(
levelType
.
equals
(
"group"
),
Order
Request
:
:
getOrgGroupId
,
levelValue
)
.
groupBy
(
Order
Request
:
:
getOrgGroupId
);
List
<
Map
<
String
,
Object
>>
results
=
order
Request
MPDao
.
selectMaps
(
wrapper
);
.
eq
(
Order
Info
:
:
getDt
,
date
)
.
in
(
levelType
.
equals
(
"cluster"
),
Order
Info
:
:
getOrgClusterId
,
levelValue
)
.
in
(
levelType
.
equals
(
"branch"
),
Order
Info
:
:
getOrgBranchId
,
levelValue
)
.
in
(
levelType
.
equals
(
"group"
),
Order
Info
:
:
getOrgGroupId
,
levelValue
)
.
groupBy
(
Order
Info
:
:
getOrgGroupId
);
List
<
Map
<
String
,
Object
>>
results
=
order
Info
MPDao
.
selectMaps
(
wrapper
);
for
(
Map
<
String
,
Object
>
result
:
results
)
{
String
groupId
=
(
String
)
result
.
get
(
"org_group_id"
);
Long
countValue
=
(
Long
)
result
.
get
(
"count"
);
...
...
@@ -364,15 +355,15 @@ public class ScheduleServiceImpl implements ScheduleService {
private
HashMap
<
String
,
Integer
>
queryCountByAppointment
(
LocalDate
date
,
String
levelType
,
List
<
String
>
levelValue
)
{
HashMap
<
String
,
Integer
>
map
=
new
HashMap
<>();
QueryWrapper
<
Order
Request
>
wrapper
=
new
QueryWrapper
<>();
QueryWrapper
<
Order
Info
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
select
(
"appointment_method, appointment_status, COUNT(*) as count"
)
.
lambda
()
.
eq
(
Order
Request
:
:
getDt
,
date
)
.
in
(
levelType
.
equals
(
"cluster"
),
Order
Request
:
:
getOrgClusterId
,
levelValue
)
.
in
(
levelType
.
equals
(
"branch"
),
Order
Request
:
:
getOrgBranchId
,
levelValue
)
.
in
(
levelType
.
equals
(
"group"
),
Order
Request
:
:
getOrgGroupId
,
levelValue
)
.
groupBy
(
Order
Request:
:
getAppointmentMethod
,
OrderRequest
:
:
getAppointmentStatus
);
List
<
Map
<
String
,
Object
>>
results
=
order
Request
MPDao
.
selectMaps
(
wrapper
);
.
eq
(
Order
Info
:
:
getDt
,
date
)
.
in
(
levelType
.
equals
(
"cluster"
),
Order
Info
:
:
getOrgClusterId
,
levelValue
)
.
in
(
levelType
.
equals
(
"branch"
),
Order
Info
:
:
getOrgBranchId
,
levelValue
)
.
in
(
levelType
.
equals
(
"group"
),
Order
Info
:
:
getOrgGroupId
,
levelValue
)
.
groupBy
(
Order
Info:
:
getAppointmentMethod
,
OrderInfo
:
:
getAppointmentStatus
);
List
<
Map
<
String
,
Object
>>
results
=
order
Info
MPDao
.
selectMaps
(
wrapper
);
Integer
autoTotal
=
0
;
Integer
manualTotal
=
0
;
...
...
@@ -480,12 +471,10 @@ public class ScheduleServiceImpl implements ScheduleService {
return
items
;
}
private
<
T
>
HashMap
<
String
,
List
<
T
>>
packParams
(
String
key
,
T
...
values
)
{
private
<
T
>
HashMap
<
String
,
List
<
T
>>
packParams
(
String
key
,
T
...
values
)
{
HashMap
<
String
,
List
<
T
>>
map
=
new
HashMap
<>();
List
<
T
>
value
=
new
ArrayList
<>();
for
(
T
v:
values
){
value
.
add
(
v
);
}
Collections
.
addAll
(
value
,
values
);
map
.
put
(
key
,
value
);
return
map
;
}
...
...
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