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 397c64c6
authored
Jun 15, 2023
by
wangli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现排班结果列表
1 parent
cfdacfc0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
147 additions
and
1 deletions
project-order/src/main/java/com/alibaba/cloud/integration/order/service/impl/ScheduleServiceImpl.java
project-order/src/main/java/com/alibaba/cloud/integration/order/service/impl/ScheduleServiceImpl.java
View file @
397c64c
package
com
.
alibaba
.
cloud
.
integration
.
order
.
service
.
impl
;
import
com.alibaba.cloud.integration.common.Result
;
import
com.alibaba.cloud.integration.order.dao.OrderAppointmentMPDao
;
import
com.alibaba.cloud.integration.order.dao.OrderRequestMPDao
;
import
com.alibaba.cloud.integration.order.dao.OrgTeamEngineerMPDao
;
import
com.alibaba.cloud.integration.order.dao.OrgTeamMPDao
;
import
com.alibaba.cloud.integration.order.dto.ScheduleOverviewResp
;
import
com.alibaba.cloud.integration.order.entity.OrderAppointment
;
import
com.alibaba.cloud.integration.order.entity.OrderRequest
;
import
com.alibaba.cloud.integration.order.entity.OrgTeam
;
import
com.alibaba.cloud.integration.order.entity.OrgTeamEngineer
;
import
com.alibaba.cloud.integration.order.service.ScheduleService
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
@Service
public
class
ScheduleServiceImpl
implements
ScheduleService
{
@Autowired
private
OrgTeamMPDao
orgTeamMPDao
;
@Autowired
private
OrgTeamEngineerMPDao
orgTeamEngineerMPDao
;
@Autowired
private
OrderRequestMPDao
orderRequestMPDao
;
@Autowired
private
OrderAppointmentMPDao
orderAppointmentMPDao
;
@Override
public
Result
<?>
getScheduleOverview
(
long
page
,
long
size
,
String
date
,
String
levelType
,
List
<
String
>
levelIds
)
{
return
null
;
// 获取team列表
IPage
<
OrgTeam
>
pg
=
this
.
queryOrgTeams
(
page
,
size
,
levelType
,
levelIds
);
List
<
OrgTeam
>
orgTeams
=
pg
.
getRecords
();
List
<
ScheduleOverviewResp
.
Team
>
items
=
new
ArrayList
<>();
// 获取工单列表
for
(
OrgTeam
t
:
orgTeams
)
{
ScheduleOverviewResp
.
Team
item
=
new
ScheduleOverviewResp
.
Team
();
item
.
setName
(
t
.
getTeamName
());
item
.
setValue
(
t
.
getTeamId
());
item
.
setLevel
(
"team"
);
// 获取改team订单列表
List
<
OrderRequest
>
orders
=
this
.
queryOrderRequests
(
t
.
getTeamId
(),
date
);
item
.
setOrder
(
this
.
getTeamOrderSum
(
orders
));
// 获取team技术员列表
List
<
OrgTeamEngineer
>
teamEngineers
=
this
.
queryOrgTeamEngineers
(
t
.
getTeamId
());
// 获取技术员对应的订单
List
<
String
>
orderRequestIds
=
orders
.
stream
().
map
(
OrderRequest:
:
getOrderId
).
collect
(
Collectors
.
toList
());
List
<
OrderAppointment
>
orderAppointments
=
this
.
queryOrderAppointments
(
orderRequestIds
,
date
);
Map
<
String
,
List
<
OrderAppointment
>>
engineerOrders
=
orderAppointments
.
stream
().
collect
(
Collectors
.
groupingBy
(
OrderAppointment:
:
getEngineerCode
));
List
<
ScheduleOverviewResp
.
Item
>
children
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
String
,
List
<
OrderAppointment
>>
entry
:
engineerOrders
.
entrySet
())
{
ScheduleOverviewResp
.
Item
child
=
new
ScheduleOverviewResp
.
Item
();
String
engineerCode
=
entry
.
getKey
();
List
<
String
>
orderIds
=
entry
.
getValue
().
stream
().
map
(
OrderAppointment:
:
getOrderId
).
collect
(
Collectors
.
toList
());
List
<
OrderRequest
>
orders2
=
new
ArrayList
<>();
for
(
OrderRequest
o
:
orders
)
{
if
(
orderIds
.
contains
(
o
.
getOrderId
()))
{
orders
.
add
(
o
);
}
}
child
.
setName
(
""
);
child
.
setValue
(
engineerCode
);
child
.
setLevel
(
"engineer"
);
child
.
setOrder
(
this
.
getTeamOrderSum
(
orders2
));
child
.
setOrderDesc
(
Integer
.
toString
(
orders2
.
size
()));
child
.
setDistanceDes
(
""
);
children
.
add
(
child
);
}
item
.
setChildren
(
children
);
item
.
setOrderDesc
(
String
.
format
(
"人均:%d"
,
orders
.
size
()
/
teamEngineers
.
size
()));
item
.
setDistanceDes
(
""
);
}
ScheduleOverviewResp
res
=
new
ScheduleOverviewResp
();
res
.
setTotal
(
pg
.
getTotal
());
res
.
setPages
(
pg
.
getPages
());
res
.
setPageSize
(
pg
.
getSize
());
res
.
setPageCurrent
(
pg
.
getCurrent
());
res
.
setContent
(
items
);
return
Result
.
success
(
res
);
}
@Override
public
Result
<?>
getScheduleEngineerOverview
(
String
date
,
String
engineerCode
)
{
return
null
;
}
private
IPage
<
OrgTeam
>
queryOrgTeams
(
long
page
,
long
size
,
String
levelType
,
List
<
String
>
levelIds
)
{
IPage
<
OrgTeam
>
pg
=
new
Page
<>(
page
,
size
);
LambdaQueryWrapper
<
OrgTeam
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
in
(
levelType
.
equals
(
"cluster"
),
OrgTeam:
:
getClusterId
,
levelIds
);
lqw
.
in
(
levelType
.
equals
(
"branch"
),
OrgTeam:
:
getBranchId
,
levelIds
);
lqw
.
in
(
levelType
.
equals
(
"group"
),
OrgTeam:
:
getGroupId
,
levelIds
);
lqw
.
orderByAsc
(
OrgTeam:
:
getTeamId
);
// 根据teamId排序
orgTeamMPDao
.
selectPage
(
pg
,
lqw
);
return
pg
;
}
private
List
<
OrgTeamEngineer
>
queryOrgTeamEngineers
(
String
teamId
)
{
LambdaQueryWrapper
<
OrgTeamEngineer
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
eq
(
OrgTeamEngineer:
:
getTeamId
,
teamId
);
lqw
.
eq
(
OrgTeamEngineer:
:
getStatus
,
1
);
return
orgTeamEngineerMPDao
.
selectList
(
lqw
);
}
private
List
<
OrderRequest
>
queryOrderRequests
(
String
teamId
,
String
date
)
{
LambdaQueryWrapper
<
OrderRequest
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
in
(
OrderRequest:
:
getOrgTeamId
,
teamId
);
lqw
.
eq
(
OrderRequest:
:
getAppointmentStatus
,
"ASSIGNED"
);
lqw
.
gt
(
OrderRequest:
:
getExpectTimeBegin
,
this
.
getTimestampFromDate
(
date
,
"00:00:00"
));
lqw
.
lt
(
OrderRequest:
:
getExpectTimeBegin
,
this
.
getTimestampFromDate
(
date
,
"23:59:59"
));
return
orderRequestMPDao
.
selectList
(
lqw
);
}
private
List
<
OrderAppointment
>
queryOrderAppointments
(
List
<
String
>
orderIds
,
String
date
)
{
LambdaQueryWrapper
<
OrderAppointment
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
in
(
OrderAppointment:
:
getOrderId
,
orderIds
);
lqw
.
ge
(
OrderAppointment:
:
getExpectStartTime
,
this
.
getTimestampFromDate
(
date
,
"00:00:00"
));
return
orderAppointmentMPDao
.
selectList
(
lqw
);
}
private
ScheduleOverviewResp
.
OrderSum
getTeamOrderSum
(
List
<
OrderRequest
>
orders
)
{
ScheduleOverviewResp
.
OrderSum
s
=
new
ScheduleOverviewResp
.
OrderSum
();
Map
<
String
,
List
<
OrderRequest
>>
cc
=
orders
.
stream
().
collect
(
Collectors
.
groupingBy
(
OrderRequest:
:
getSkill
));
List
<
OrderRequest
>
emtpy
=
new
ArrayList
<>();
s
.
setTotal
(
orders
.
size
());
s
.
setInstallNum
(
cc
.
getOrDefault
(
"安装"
,
emtpy
).
size
());
s
.
setFixNum
(
cc
.
getOrDefault
(
"维修"
,
emtpy
).
size
());
s
.
setDesignNum
(
cc
.
getOrDefault
(
"设计"
,
emtpy
).
size
());
s
.
setCleanNum
(
cc
.
getOrDefault
(
"清洗"
,
emtpy
).
size
());
return
s
;
}
public
Timestamp
getTimestampFromDate
(
String
date
,
String
t
)
{
return
Timestamp
.
valueOf
(
date
+
" "
+
t
);
}
}
\ 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