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 06b95e5c
authored
Aug 10, 2023
by
wangli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
1 parent
cc38a216
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
50 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 @
06b95e5
...
@@ -2,8 +2,6 @@ package com.dituhui.pea.order.service.impl;
...
@@ -2,8 +2,6 @@ package com.dituhui.pea.order.service.impl;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.dituhui.pea.common.BusinessException
;
import
com.dituhui.pea.common.BusinessException
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.common.ListUtils
;
import
com.dituhui.pea.order.common.ListUtils
;
...
@@ -13,8 +11,13 @@ import com.dituhui.pea.order.dto.*;
...
@@ -13,8 +11,13 @@ import com.dituhui.pea.order.dto.*;
import
com.dituhui.pea.order.entity.*
;
import
com.dituhui.pea.order.entity.*
;
import
com.dituhui.pea.order.service.ScheduleService
;
import
com.dituhui.pea.order.service.ScheduleService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.persistence.criteria.Predicate
;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -30,22 +33,19 @@ public class ScheduleServiceImpl implements ScheduleService {
...
@@ -30,22 +33,19 @@ public class ScheduleServiceImpl implements ScheduleService {
private
OrderInfoDao
orderInfoDao
;
private
OrderInfoDao
orderInfoDao
;
@Autowired
@Autowired
private
OrgTeam
MPDao
orgTeamMP
Dao
;
private
OrgTeam
Dao
orgTeam
Dao
;
@Autowired
@Autowired
private
OrgTeamEngineerDao
orgTeamEngineerDao
;
private
OrgTeamEngineerDao
orgTeamEngineerDao
;
@Autowired
@Autowired
private
OrgGroupMPDao
orgGroupMPDao
;
@Autowired
private
OrgGroupDao
orgGroupDao
;
private
OrgGroupDao
orgGroupDao
;
@Autowired
@Autowired
private
EngineerInfoDao
engineerInfoDao
;
private
EngineerInfoDao
engineerInfoDao
;
@Autowired
@Autowired
private
SkillInfo
MPDao
skillInfoMP
Dao
;
private
SkillInfo
Dao
skillInfo
Dao
;
@Override
@Override
public
Result
<?>
getScheduleSummary
(
LocalDate
date
,
String
levelType
,
List
<
String
>
levelValue
)
{
public
Result
<?>
getScheduleSummary
(
LocalDate
date
,
String
levelType
,
List
<
String
>
levelValue
)
{
...
@@ -76,8 +76,8 @@ public class ScheduleServiceImpl implements ScheduleService {
...
@@ -76,8 +76,8 @@ public class ScheduleServiceImpl implements ScheduleService {
// 排班结果
// 排班结果
// 获取team列表, 以team排序分页
// 获取team列表, 以team排序分页
IPage
<
OrgTeam
>
pg
=
this
.
queryOrgTeams
(
page
,
size
,
levelType
,
levelIds
);
Page
<
OrgTeamEntity
>
pg
=
this
.
queryOrgTeams
(
page
,
size
,
levelType
,
levelIds
);
List
<
OrgTeam
>
orgTeams
=
pg
.
getRecords
();
List
<
OrgTeam
Entity
>
orgTeams
=
pg
.
getContent
();
List
<
ScheduleOverviewResp
.
Team
>
teams
=
new
ArrayList
<>();
List
<
ScheduleOverviewResp
.
Team
>
teams
=
new
ArrayList
<>();
...
@@ -85,7 +85,7 @@ public class ScheduleServiceImpl implements ScheduleService {
...
@@ -85,7 +85,7 @@ public class ScheduleServiceImpl implements ScheduleService {
HashMap
<
String
,
String
>
skillMapping
=
this
.
getSkillMapping
();
HashMap
<
String
,
String
>
skillMapping
=
this
.
getSkillMapping
();
// 获取工单列表
// 获取工单列表
for
(
OrgTeam
t
:
orgTeams
)
{
for
(
OrgTeam
Entity
t
:
orgTeams
)
{
ScheduleOverviewResp
.
Team
team
=
new
ScheduleOverviewResp
.
Team
();
ScheduleOverviewResp
.
Team
team
=
new
ScheduleOverviewResp
.
Team
();
team
.
setName
(
t
.
getTeamName
());
team
.
setName
(
t
.
getTeamName
());
team
.
setValue
(
t
.
getTeamId
());
team
.
setValue
(
t
.
getTeamId
());
...
@@ -137,12 +137,11 @@ public class ScheduleServiceImpl implements ScheduleService {
...
@@ -137,12 +137,11 @@ public class ScheduleServiceImpl implements ScheduleService {
teams
.
add
(
team
);
teams
.
add
(
team
);
}
}
ScheduleOverviewResp
res
=
new
ScheduleOverviewResp
();
ScheduleOverviewResp
res
=
new
ScheduleOverviewResp
();
res
.
setTotal
(
pg
.
getTotal
());
res
.
setTotal
(
pg
.
getTotal
Elements
());
res
.
setPages
(
pg
.
getPages
());
res
.
setPages
(
pg
.
get
Total
Pages
());
res
.
setPageSize
(
pg
.
getSize
());
res
.
setPageSize
(
pg
.
getSize
());
res
.
setPageCurrent
(
pg
.
get
Current
()
);
res
.
setPageCurrent
(
pg
.
get
Number
()
+
1
);
res
.
setContent
(
teams
);
res
.
setContent
(
teams
);
return
Result
.
success
(
res
);
return
Result
.
success
(
res
);
}
}
...
@@ -230,20 +229,25 @@ public class ScheduleServiceImpl implements ScheduleService {
...
@@ -230,20 +229,25 @@ public class ScheduleServiceImpl implements ScheduleService {
return
Result
.
success
(
res
);
return
Result
.
success
(
res
);
}
}
p
rivate
IPage
<
OrgTeam
>
queryOrgTeams
(
long
page
,
long
size
,
String
levelType
,
List
<
String
>
levelIds
)
{
p
ublic
Page
<
OrgTeamEntity
>
queryOrgTeams
(
long
page
,
long
size
,
String
levelType
,
List
<
String
>
levelIds
)
{
IPage
<
OrgTeam
>
pg
=
new
Page
<>(
page
,
size
);
Pageable
pageable
=
PageRequest
.
of
((
int
)
page
,
(
int
)
size
);
LambdaQueryWrapper
<
OrgTeam
>
lqw
=
new
LambdaQueryWrapper
<>();
Specification
<
OrgTeamEntity
>
spec
=
(
root
,
query
,
cb
)
->
{
lqw
.
eq
(
OrgTeam:
:
getStatus
,
1
);
Predicate
statusPredicate
=
cb
.
equal
(
root
.
get
(
"status"
),
1
);
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排序
Predicate
levelPredicate
=
null
;
if
(
"cluster"
.
equals
(
levelType
))
{
levelPredicate
=
root
.
get
(
"clusterId"
).
in
(
levelIds
);
}
else
if
(
"branch"
.
equals
(
levelType
))
{
levelPredicate
=
root
.
get
(
"branchId"
).
in
(
levelIds
);
}
else
if
(
"group"
.
equals
(
levelType
))
{
levelPredicate
=
root
.
get
(
"groupId"
).
in
(
levelIds
);
}
orgTeamMPDao
.
selectPage
(
pg
,
lqw
);
return
cb
.
and
(
statusPredicate
,
levelPredicate
);
};
return
pg
;
return
orgTeamDao
.
findAll
(
spec
,
pageable
)
;
}
}
private
List
<
OrderInfo
>
queryOrderRequests
(
String
teamId
,
LocalDate
date
)
{
private
List
<
OrderInfo
>
queryOrderRequests
(
String
teamId
,
LocalDate
date
)
{
...
@@ -281,13 +285,9 @@ public class ScheduleServiceImpl implements ScheduleService {
...
@@ -281,13 +285,9 @@ public class ScheduleServiceImpl implements ScheduleService {
}
}
private
HashMap
<
String
,
String
>
getSkillMapping
()
{
private
HashMap
<
String
,
String
>
getSkillMapping
()
{
LambdaQueryWrapper
<
SkillInfo
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
List
<
SkillInfoEntity
>
skills
=
skillInfoDao
.
findAll
();
queryWrapper
.
select
(
SkillInfo:
:
getSkill
,
SkillInfo:
:
getSkillCategory
)
return
skills
.
stream
().
collect
(
Collectors
.
toMap
(
.
groupBy
(
SkillInfo:
:
getSkill
,
SkillInfo:
:
getSkillCategory
);
SkillInfoEntity:
:
getSkill
,
SkillInfoEntity:
:
getSkillCategory
,
(
oldValue
,
newValue
)
->
newValue
,
HashMap:
:
new
));
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
)
{
private
HashMap
<
String
,
Integer
>
queryCountBySkill
(
LocalDate
date
,
String
levelType
,
List
<
String
>
levelValue
)
{
...
@@ -384,29 +384,23 @@ public class ScheduleServiceImpl implements ScheduleService {
...
@@ -384,29 +384,23 @@ public class ScheduleServiceImpl implements ScheduleService {
private
HashMap
<
String
,
String
>
getSkillCategoryMapping
()
{
private
HashMap
<
String
,
String
>
getSkillCategoryMapping
()
{
// 获取skill与skillCategory(面向前端)的映射
// 获取skill与skillCategory(面向前端)的映射
HashMap
<
String
,
String
>
skillMap
=
new
HashMap
<>();
List
<
SkillInfoEntity
>
skillList
=
skillInfoDao
.
findAll
();
QueryWrapper
<
SkillInfo
>
wrapper
=
new
QueryWrapper
<>();
return
skillList
.
stream
()
wrapper
.
select
(
"skill, skill_category"
)
.
collect
(
Collectors
.
toMap
(
.
lambda
()
SkillInfoEntity:
:
getSkill
,
SkillInfoEntity:
:
getSkillCategory
,
(
oldValue
,
newValue
)
->
newValue
,
HashMap:
:
new
));
.
groupBy
(
SkillInfo:
:
getSkill
,
SkillInfo:
:
getSkillCategory
);
List
<
Map
<
String
,
Object
>>
results
=
skillInfoMPDao
.
selectMaps
(
wrapper
);
for
(
Map
<
String
,
Object
>
result
:
results
)
{
String
skill
=
(
String
)
result
.
get
(
"skill"
);
String
skillCategory
=
(
String
)
result
.
get
(
"skill_category"
);
skillMap
.
put
(
skill
,
skillCategory
);
}
return
skillMap
;
}
}
private
HashMap
<
String
,
Integer
>
getGroupCategoryMapping
(
String
levelType
,
List
<
String
>
levelValue
)
{
private
HashMap
<
String
,
Integer
>
getGroupCategoryMapping
(
String
levelType
,
List
<
String
>
levelValue
)
{
HashMap
<
String
,
Integer
>
map
=
new
HashMap
<>();
HashMap
<
String
,
Integer
>
map
=
new
HashMap
<>();
LambdaQueryWrapper
<
OrgGroup
>
lqw
=
new
LambdaQueryWrapper
<>();
List
<
OrgGroupEntity
>
groups
=
new
ArrayList
<>();
lqw
.
select
(
OrgGroup:
:
getGroupId
,
OrgGroup:
:
getCategory
);
if
(
levelType
.
equals
(
"cluster"
)){
lqw
.
in
(
levelType
.
equals
(
"cluster"
),
OrgGroup:
:
getClusterId
,
levelValue
);
groups
=
orgGroupDao
.
findAllByClusterIdIn
(
levelValue
);
lqw
.
in
(
levelType
.
equals
(
"branch"
),
OrgGroup:
:
getBranchId
,
levelValue
);
}
else
if
(
levelType
.
equals
(
"branch"
)){
lqw
.
in
(
levelType
.
equals
(
"group"
),
OrgGroup:
:
getGroupId
,
levelValue
);
groups
=
orgGroupDao
.
findAllByBranchIdIn
(
levelValue
);
List
<
OrgGroup
>
groups
=
orgGroupMPDao
.
selectList
(
lqw
);
}
else
if
(
levelType
.
equals
(
"group"
)){
for
(
OrgGroup
g
:
groups
)
{
groups
=
orgGroupDao
.
findAllByGroupIdIn
(
levelValue
);
}
for
(
OrgGroupEntity
g
:
groups
)
{
map
.
put
(
g
.
getGroupId
(),
g
.
getCategory
());
map
.
put
(
g
.
getGroupId
(),
g
.
getCategory
());
}
}
return
map
;
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