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 e2a7eb8e
authored
Jul 13, 2023
by
王力
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev_scheduleresult0713' into 'develop'
Dev scheduleresult0713 See merge request !224
2 parents
a2fe7924
111e7ddd
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
33 deletions
project-order/src/main/java/com/dituhui/pea/order/controller/ScheduleController.java
project-order/src/main/java/com/dituhui/pea/order/service/ScheduleService.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/ScheduleServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/controller/ScheduleController.java
View file @
e2a7eb8
...
...
@@ -36,8 +36,9 @@ public class ScheduleController {
public
Result
<?>
getScheduleOverview
(
@RequestParam
long
page
,
@RequestParam
long
size
,
@RequestParam
String
date
,
@RequestParam
String
levelType
,
@RequestParam
(
"levelValue"
)
List
<
String
>
levelIds
)
{
Result
<?>
res
=
null
;
LocalDate
localDate
=
TimeUtils
.
IsoDate2LocalDate
(
date
);
try
{
res
=
scheduleService
.
getScheduleOverview
(
page
,
size
,
d
ate
,
levelType
,
levelIds
);
res
=
scheduleService
.
getScheduleOverview
(
page
,
size
,
localD
ate
,
levelType
,
levelIds
);
}
catch
(
BusinessException
e
)
{
return
Result
.
failed
(
e
.
getMessage
());
}
...
...
@@ -47,8 +48,9 @@ public class ScheduleController {
@GetMapping
(
"/schedule/engineer/overview"
)
public
Result
<?>
getScheduleEngineerOverview
(
@RequestParam
String
date
,
@RequestParam
String
engineerCode
)
{
Result
<?>
res
=
null
;
LocalDate
localDate
=
TimeUtils
.
IsoDate2LocalDate
(
date
);
try
{
res
=
scheduleService
.
getScheduleEngineerOverview
(
d
ate
,
engineerCode
);
res
=
scheduleService
.
getScheduleEngineerOverview
(
localD
ate
,
engineerCode
);
}
catch
(
BusinessException
e
)
{
return
Result
.
failed
(
e
.
getMessage
());
}
...
...
project-order/src/main/java/com/dituhui/pea/order/service/ScheduleService.java
View file @
e2a7eb8
...
...
@@ -9,7 +9,7 @@ public interface ScheduleService {
Result
<?>
getScheduleSummary
(
LocalDate
date
,
String
levelType
,
List
<
String
>
levelIds
);
Result
<?>
getScheduleOverview
(
long
page
,
long
size
,
String
date
,
String
levelType
,
List
<
String
>
levelIds
);
Result
<?>
getScheduleOverview
(
long
page
,
long
size
,
LocalDate
date
,
String
levelType
,
List
<
String
>
levelIds
);
Result
<?>
getScheduleEngineerOverview
(
String
date
,
String
engineerCode
);
Result
<?>
getScheduleEngineerOverview
(
LocalDate
date
,
String
engineerCode
);
}
project-order/src/main/java/com/dituhui/pea/order/service/impl/ScheduleServiceImpl.java
View file @
e2a7eb8
...
...
@@ -3,9 +3,11 @@ 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
;
import
com.dituhui.pea.order.common.ListUtils
;
import
com.dituhui.pea.order.common.TimeUtils
;
import
com.dituhui.pea.order.dao.*
;
import
com.dituhui.pea.order.dto.*
;
...
...
@@ -68,14 +70,17 @@ public class ScheduleServiceImpl implements ScheduleService {
}
@Override
public
Result
<?>
getScheduleOverview
(
long
page
,
long
size
,
String
date
,
String
levelType
,
List
<
String
>
levelIds
)
{
public
Result
<?>
getScheduleOverview
(
long
page
,
long
size
,
LocalDate
date
,
String
levelType
,
List
<
String
>
levelIds
)
{
// 获取team列表
// 获取team列表
, 以team排序分页
IPage
<
OrgTeam
>
pg
=
this
.
queryOrgTeams
(
page
,
size
,
levelType
,
levelIds
);
List
<
OrgTeam
>
orgTeams
=
pg
.
getRecords
();
List
<
ScheduleOverviewResp
.
Team
>
teams
=
new
ArrayList
<>();
// 获取skill与skill_category的映射
HashMap
<
String
,
String
>
skillMapping
=
this
.
getSkillMapping
();
// 获取工单列表
for
(
OrgTeam
t
:
orgTeams
)
{
ScheduleOverviewResp
.
Team
team
=
new
ScheduleOverviewResp
.
Team
();
...
...
@@ -85,11 +90,11 @@ public class ScheduleServiceImpl implements ScheduleService {
// 获取改team订单列表
List
<
OrderRequest
>
orders
=
this
.
queryOrderRequests
(
t
.
getTeamId
(),
date
);
team
.
setOrder
(
this
.
getTeamOrderSum
(
orders
));
team
.
setOrder
(
this
.
getTeamOrderSum
(
orders
,
skillMapping
));
// 技术员指派单列表
Map
<
String
,
List
<
OrderAppointment
>>
engineerOrders
=
new
HashMap
<>();
if
(
orders
!=
null
&&
!
orders
.
isEmpty
(
))
{
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
));
...
...
@@ -97,9 +102,8 @@ public class ScheduleServiceImpl implements ScheduleService {
// 获取team技术员列表
List
<
OrgTeamEngineer
>
teamEngineers
=
this
.
queryOrgTeamEngineers
(
t
.
getTeamId
());
// 获取技术员列表
List
<
EngineerInfo
>
engineerInfoList
=
engineerInfoMPDao
.
selectByGroupId
(
t
.
getGroupId
());
List
<
String
>
engineerCodes
=
teamEngineers
.
stream
().
map
(
OrgTeamEngineer:
:
getEngineerCode
).
collect
(
Collectors
.
toList
());
List
<
EngineerInfo
>
engineerInfoList
=
engineerInfoMPDao
.
selectByEngineerCodes
(
engineerCodes
);
Map
<
String
,
List
<
EngineerInfo
>>
engineers
=
engineerInfoList
.
stream
().
collect
(
Collectors
.
groupingBy
(
EngineerInfo:
:
getEngineerCode
));
List
<
ScheduleOverviewResp
.
Item
>
children
=
new
ArrayList
<>();
...
...
@@ -107,6 +111,7 @@ public class ScheduleServiceImpl implements ScheduleService {
ScheduleOverviewResp
.
Item
child
=
new
ScheduleOverviewResp
.
Item
();
//技术员信息
String
engineerCode
=
entry
.
getKey
();
EngineerInfo
engineerInfo
=
entry
.
getValue
().
get
(
0
);
...
...
@@ -122,7 +127,7 @@ public class ScheduleServiceImpl implements ScheduleService {
child
.
setName
(
engineerInfo
.
getName
());
child
.
setValue
(
engineerCode
);
child
.
setLevel
(
"engineer"
);
child
.
setOrder
(
this
.
getTeamOrderSum
(
orders2
));
child
.
setOrder
(
this
.
getTeamOrderSum
(
orders2
,
skillMapping
));
child
.
setOrderDesc
(
Integer
.
toString
(
orders2
.
size
()));
child
.
setDistanceDesc
(
""
);
...
...
@@ -147,14 +152,14 @@ public class ScheduleServiceImpl implements ScheduleService {
}
@Override
public
Result
<?>
getScheduleEngineerOverview
(
String
date
,
String
engineerCode
)
throws
BusinessException
{
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
=
this
.
queryOrderAppointmentsByEngineerCode
(
engineerCode
,
date
);
List
<
OrderAppointment
>
orderAppointments
=
orderAppointmentMPDao
.
selectByEngineerCodeAndDt
(
engineerCode
,
date
);
List
<
TimeLineDTO
>
timelines
=
new
ArrayList
<>();
for
(
OrderAppointment
o
:
orderAppointments
)
{
TimeLineDTO
item
=
new
TimeLineDTO
();
...
...
@@ -173,7 +178,7 @@ public class ScheduleServiceImpl implements ScheduleService {
List
<
LabelValueDTO
>
dynamics
=
new
ArrayList
<>();
dynamics
.
add
(
new
LabelValueDTO
(
"姓名"
,
engineer
.
getName
()));
dynamics
.
add
(
new
LabelValueDTO
(
"日期"
,
date
));
dynamics
.
add
(
new
LabelValueDTO
(
"日期"
,
TimeUtils
.
IsoLocalDate2String
(
date
)
));
dynamics
.
add
(
new
LabelValueDTO
(
"状态"
,
"上班"
));
dynamics
.
add
(
new
LabelValueDTO
(
"待服务"
,
Integer
.
toString
(
countPending
)));
dynamics
.
add
(
new
LabelValueDTO
(
"服务中"
,
Integer
.
toString
(
statusGroup
.
getOrDefault
(
"STARTED"
,
empty
).
size
())));
...
...
@@ -250,46 +255,57 @@ public class ScheduleServiceImpl implements ScheduleService {
return
orgTeamEngineerMPDao
.
selectList
(
lqw
);
}
private
List
<
OrderRequest
>
queryOrderRequests
(
String
teamId
,
String
date
)
{
private
List
<
OrderRequest
>
queryOrderRequests
(
String
teamId
,
LocalDate
date
)
{
LambdaQueryWrapper
<
OrderRequest
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
eq
(
OrderRequest:
:
getDt
,
date
);
lqw
.
in
(
OrderRequest:
:
getOrgTeamId
,
teamId
);
lqw
.
eq
(
OrderRequest:
:
getAppointmentStatus
,
"ASSIGNED"
);
lqw
.
ge
(
OrderRequest:
:
getExpectTimeBegin
,
TimeUtils
.
IsoDateTime2Timestamp
(
String
.
format
(
"%s 00:00:00"
,
date
)));
lqw
.
le
(
OrderRequest:
:
getExpectTimeBegin
,
TimeUtils
.
IsoDateTime2Timestamp
(
String
.
format
(
"%s 23:59:59"
,
date
)));
return
orderRequestMPDao
.
selectList
(
lqw
);
}
private
List
<
OrderAppointment
>
queryOrderAppointments
(
List
<
String
>
orderIds
,
String
date
)
{
private
List
<
OrderAppointment
>
queryOrderAppointments
(
List
<
String
>
orderIds
,
LocalDate
date
)
{
LambdaQueryWrapper
<
OrderAppointment
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
in
(
OrderAppointment:
:
getOrderId
,
orderIds
);
lqw
.
ge
(
OrderAppointment:
:
getExpectStartTime
,
TimeUtils
.
IsoDateTime2Timestamp
(
String
.
format
(
"%s 00:00:00"
,
date
))
);
lqw
.
le
(
OrderAppointment:
:
getExpectEndTime
,
TimeUtils
.
IsoDateTime2Timestamp
(
String
.
format
(
"%s 23:59:59"
,
date
))
);
lqw
.
eq
(
OrderAppointment:
:
getDt
,
date
);
lqw
.
orderByAsc
(
OrderAppointment:
:
getEngineerCode
);
return
orderAppointmentMPDao
.
selectList
(
lqw
);
}
private
List
<
OrderAppointment
>
queryOrderAppointmentsByEngineerCode
(
String
engineerCode
,
String
date
)
{
LambdaQueryWrapper
<
OrderAppointment
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
in
(
OrderAppointment:
:
getEngineerCode
,
engineerCode
);
lqw
.
ge
(
OrderAppointment:
:
getExpectStartTime
,
TimeUtils
.
IsoDateTime2Timestamp
(
String
.
format
(
"%s 00:00:00"
,
date
)));
lqw
.
le
(
OrderAppointment:
:
getExpectEndTime
,
TimeUtils
.
IsoDateTime2Timestamp
(
String
.
format
(
"%s 23:59:59"
,
date
)));
return
orderAppointmentMPDao
.
selectList
(
lqw
);
}
private
ScheduleOverviewResp
.
OrderSum
getTeamOrderSum
(
List
<
OrderRequest
>
orders
,
HashMap
<
String
,
String
>
skillMapping
)
{
ScheduleOverviewResp
.
OrderSum
s
=
new
ScheduleOverviewResp
.
OrderSum
();
private
ScheduleOverviewResp
.
OrderSum
getTeamOrderSum
(
List
<
OrderRequest
>
orders
)
{
List
<
OrderRequest
>
emtpy
=
new
ArrayList
<>();
ScheduleOverviewResp
.
OrderSum
s
=
new
ScheduleOverviewResp
.
OrderSum
();
HashMap
<
String
,
Integer
>
skillCount
=
new
HashMap
<>
();
Map
<
String
,
List
<
OrderRequest
>>
cc
=
orders
.
stream
().
collect
(
Collectors
.
groupingBy
(
OrderRequest:
:
getSkill
));
List
<
OrderRequest
>
emtpy
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
String
,
List
<
OrderRequest
>>
entry:
cc
.
entrySet
()){
String
skill
=
entry
.
getKey
();
Integer
count
=
entry
.
getValue
().
size
();
String
skillCategory
=
skillMapping
.
get
(
skill
);
Integer
v
=
skillCount
.
getOrDefault
(
skillCategory
,
0
);
v
+=
count
;
skillCount
.
put
(
skillCategory
,
v
);
}
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
());
s
.
setDesignNum
(
cc
.
getOrDefault
(
"
整改
"
,
emtpy
).
size
());
s
.
setCleanNum
(
cc
.
getOrDefault
(
"清
洁保养
"
,
emtpy
).
size
());
return
s
;
}
private
HashMap
<
String
,
String
>
getSkillMapping
()
{
LambdaQueryWrapper
<
SkillInfo
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
select
(
SkillInfo:
:
getSkill
,
SkillInfo:
:
getSkillCategory
)
.
groupBy
(
SkillInfo:
:
getSkill
,
SkillInfo:
:
getSkillCategory
);
List
<
SkillInfo
>
skillList
=
skillInfoMPDao
.
selectList
(
queryWrapper
);
return
skillList
.
stream
().
collect
(
Collectors
.
toMap
(
SkillInfo:
:
getSkill
,
SkillInfo:
:
getSkillCategory
,
(
oldValue
,
newValue
)
->
newValue
,
HashMap:
:
new
));
}
private
HashMap
<
String
,
Integer
>
queryCountBySkill
(
LocalDate
date
,
String
levelType
,
List
<
String
>
levelValue
)
{
HashMap
<
String
,
Integer
>
map
=
new
HashMap
<>();
...
...
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