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 9203cb82
authored
Aug 09, 2023
by
wangli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mp2jpa
1 parent
413634a1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
32 deletions
project-order/src/main/java/com/dituhui/pea/order/service/impl/DispatchServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/DispatchServiceImpl.java
View file @
9203cb8
...
...
@@ -17,9 +17,11 @@ import com.dituhui.pea.order.service.DispatchService;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.persistence.criteria.Predicate
;
import
java.sql.Timestamp
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
...
...
@@ -41,16 +43,19 @@ public class DispatchServiceImpl implements DispatchService {
private
OrderInfoMPDao
orderInfoMPDao
;
@Autowired
private
OrgTeam
MPDao
orgTeamMP
Dao
;
private
OrgTeam
Dao
orgTeam
Dao
;
@Autowired
private
EngineerInfoMPDao
engineerInfoMPDao
;
@Autowired
private
SkillInfoMPDao
skillInfoMP
Dao
;
private
EngineerInfoDao
engineerInfo
Dao
;
@Autowired
private
CapacityEngineerStatMPDao
capacityEngineerStatMPDao
;
private
SkillInfoDao
skillInfoDao
;
@Autowired
private
CapacityEngineerStatDao
capacityEngineerStatDao
;
@Transactional
@Override
...
...
@@ -58,7 +63,7 @@ public class DispatchServiceImpl implements DispatchService {
// 获取派工台订单列表
// 获取技能信息
HashMap
<
String
,
SkillInfo
>
skillInfo
=
this
.
querySkillInfo
();
HashMap
<
String
,
SkillInfo
Entity
>
skillInfo
=
this
.
querySkillInfo
();
// 获取工单列表
List
<
OrderInfo
>
orders
=
this
.
queryOrders
(
reqDTO
);
...
...
@@ -80,7 +85,7 @@ public class DispatchServiceImpl implements DispatchService {
item
.
setApplyNote
(
o
.
getApplyNote
());
String
key
=
String
.
format
(
"%s%s%s"
,
o
.
getBrand
(),
o
.
getType
(),
o
.
getSkill
());
SkillInfo
skill
=
skillInfo
.
get
(
key
);
SkillInfo
Entity
skill
=
skillInfo
.
get
(
key
);
if
(
skill
!=
null
)
{
item
.
setDuration
(
skill
.
getTakeTime
());
item
.
setSkillCategory
(
skill
.
getSkillCategory
());
...
...
@@ -125,7 +130,7 @@ public class DispatchServiceImpl implements DispatchService {
LocalDate
date
=
TimeUtils
.
IsoDate2LocalDate
(
reqDTO
.
getDate
());
// 获取技能信息
HashMap
<
String
,
SkillInfo
>
skillInfo
=
this
.
querySkillInfo
();
HashMap
<
String
,
SkillInfo
Entity
>
skillInfo
=
this
.
querySkillInfo
();
// 获取teamIds
List
<
String
>
teamIds
=
this
.
queryOrgTeamIds
(
reqDTO
.
getLevelType
(),
reqDTO
.
getLevelValue
(),
reqDTO
.
getBranchIds
(),
...
...
@@ -152,7 +157,7 @@ public class DispatchServiceImpl implements DispatchService {
Map
<
String
,
List
<
OrderInfo
>>
engineerOrders
=
this
.
queryEngineerOrders
(
engineerCodes
,
date
);
// 获取技术员的容量
HashMap
<
String
,
CapacityEngineerStat
>
engineerCap
=
this
.
queryCapacityEngineerStat
(
engineerCodes
,
reqDTO
.
getDate
());
HashMap
<
String
,
CapacityEngineerStat
Entity
>
engineerCap
=
this
.
queryCapacityEngineerStat
(
engineerCodes
,
reqDTO
.
getDate
());
// 获取技术员已指派单列表
List
<
DispatchEngineerOrderListResp
.
EngineerInfo
>
egs
=
new
ArrayList
<>();
...
...
@@ -175,7 +180,7 @@ public class DispatchServiceImpl implements DispatchService {
item
.
setApplyNote
(
o
.
getApplyNote
());
String
key
=
String
.
format
(
"%s%s%s"
,
o
.
getBrand
(),
o
.
getType
(),
o
.
getSkill
());
SkillInfo
skill
=
skillInfo
.
get
(
key
);
SkillInfo
Entity
skill
=
skillInfo
.
get
(
key
);
if
(
skill
!=
null
)
{
item
.
setDuration
(
skill
.
getTakeTime
());
item
.
setSkillCategory
(
skill
.
getSkillCategory
());
...
...
@@ -213,7 +218,7 @@ public class DispatchServiceImpl implements DispatchService {
int
capUsed
=
0
;
int
capTotal
=
0
;
String
capacityStatus
=
"less"
;
CapacityEngineerStat
cap
=
engineerCap
.
get
(
e
.
getEngineerCode
());
CapacityEngineerStat
Entity
cap
=
engineerCap
.
get
(
e
.
getEngineerCode
());
if
(
cap
!=
null
)
{
capUsed
=
cap
.
getCapUsed
();
capTotal
=
cap
.
getCapTotal
();
...
...
@@ -243,7 +248,7 @@ public class DispatchServiceImpl implements DispatchService {
LocalDate
localDate
=
TimeUtils
.
IsoDate2LocalDate
(
date
);
EngineerInfo
engineer
=
engineerInfoMP
Dao
.
getByEngineerCode
(
engineerCode
);
EngineerInfo
Entity
engineer
=
engineerInfo
Dao
.
getByEngineerCode
(
engineerCode
);
if
(
engineer
==
null
)
{
throw
new
BusinessException
(
"技术员不存在"
);
}
...
...
@@ -385,46 +390,56 @@ public class DispatchServiceImpl implements DispatchService {
}
private
List
<
String
>
queryOrgTeamIds
(
String
levelType
,
String
levelIds
,
List
<
String
>
branchIds
,
List
<
String
>
groupIds
,
List
<
String
>
teamIds
)
{
LambdaQueryWrapper
<
OrgTeam
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
eq
(
levelType
.
equals
(
"cluster"
),
OrgTeam:
:
getClusterId
,
levelIds
);
lqw
.
eq
(
levelType
.
equals
(
"branch"
),
OrgTeam:
:
getBranchId
,
levelIds
);
lqw
.
eq
(
levelType
.
equals
(
"group"
),
OrgTeam:
:
getGroupId
,
levelIds
);
lqw
.
in
(
ListUtils
.
isNotEmpty
(
branchIds
),
OrgTeam:
:
getBranchId
,
branchIds
);
lqw
.
in
(
ListUtils
.
isNotEmpty
(
groupIds
),
OrgTeam:
:
getGroupId
,
groupIds
);
lqw
.
in
(
ListUtils
.
isNotEmpty
(
teamIds
),
OrgTeam:
:
getTeamId
,
teamIds
);
List
<
OrgTeam
>
teams
=
orgTeamMPDao
.
selectList
(
lqw
);
return
teams
.
stream
().
map
(
OrgTeam:
:
getTeamId
).
collect
(
Collectors
.
toList
());
Specification
<
OrgTeamEntity
>
specification
=
(
root
,
query
,
criteriaBuilder
)
->
{
List
<
Predicate
>
predicates
=
new
ArrayList
<>();
if
(
"cluster"
.
equals
(
levelType
))
{
predicates
.
add
(
criteriaBuilder
.
in
(
root
.
get
(
"clusterId"
)).
value
(
levelIds
));
}
else
if
(
"branch"
.
equals
(
levelType
))
{
predicates
.
add
(
criteriaBuilder
.
in
(
root
.
get
(
"branchId"
)).
value
(
levelIds
));
}
else
if
(
"group"
.
equals
(
levelType
))
{
predicates
.
add
(
criteriaBuilder
.
in
(
root
.
get
(
"groupId"
)).
value
(
levelIds
));
}
if
(
ListUtils
.
isNotEmpty
(
branchIds
))
{
predicates
.
add
(
root
.
get
(
"branchId"
).
in
(
branchIds
));
}
if
(
ListUtils
.
isNotEmpty
(
groupIds
))
{
predicates
.
add
(
root
.
get
(
"groupId"
).
in
(
groupIds
));
}
if
(
ListUtils
.
isNotEmpty
(
teamIds
))
{
predicates
.
add
(
root
.
get
(
"teamId"
).
in
(
teamIds
));
}
return
criteriaBuilder
.
and
(
predicates
.
toArray
(
new
Predicate
[
0
]));
};
List
<
OrgTeamEntity
>
teams
=
orgTeamDao
.
findAll
(
specification
);
return
teams
.
stream
().
map
(
OrgTeamEntity:
:
getTeamId
).
collect
(
Collectors
.
toList
());
}
private
HashMap
<
String
,
Integer
>
querySkillTakeTime
()
{
HashMap
<
String
,
Integer
>
map
=
new
HashMap
<>();
List
<
SkillInfo
>
records
=
skillInfoMPDao
.
selectList
(
null
);
for
(
SkillInfo
r
:
records
)
{
List
<
SkillInfo
Entity
>
records
=
skillInfoDao
.
findAll
(
);
for
(
SkillInfo
Entity
r
:
records
)
{
String
key
=
String
.
format
(
"%s%s%s"
,
r
.
getBrand
(),
r
.
getType
(),
r
.
getSkill
());
map
.
put
(
key
,
r
.
getTakeTime
());
}
return
map
;
}
private
HashMap
<
String
,
SkillInfo
>
querySkillInfo
()
{
HashMap
<
String
,
SkillInfo
>
map
=
new
HashMap
<>();
List
<
SkillInfo
>
records
=
skillInfoMPDao
.
selectList
(
null
);
for
(
SkillInfo
r
:
records
)
{
private
HashMap
<
String
,
SkillInfo
Entity
>
querySkillInfo
()
{
HashMap
<
String
,
SkillInfo
Entity
>
map
=
new
HashMap
<>();
List
<
SkillInfo
Entity
>
records
=
skillInfoDao
.
findAll
(
);
for
(
SkillInfo
Entity
r
:
records
)
{
String
key
=
String
.
format
(
"%s%s%s"
,
r
.
getBrand
(),
r
.
getType
(),
r
.
getSkill
());
map
.
put
(
key
,
r
);
}
return
map
;
}
private
HashMap
<
String
,
CapacityEngineerStat
>
queryCapacityEngineerStat
(
List
<
String
>
engineerCodes
,
String
date
)
{
LambdaQueryWrapper
<
CapacityEngineerStat
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
eq
(
CapacityEngineerStat:
:
getWorkday
,
date
);
lqw
.
in
(
CapacityEngineerStat:
:
getEngineerCode
,
engineerCodes
);
List
<
CapacityEngineerStat
>
records
=
capacityEngineerStatMPDao
.
selectList
(
lqw
);
private
HashMap
<
String
,
CapacityEngineerStatEntity
>
queryCapacityEngineerStat
(
List
<
String
>
engineerCodes
,
String
date
)
{
List
<
CapacityEngineerStatEntity
>
records
=
capacityEngineerStatDao
.
getByWorkdayAndEngineerCodeIn
(
date
,
engineerCodes
);
HashMap
<
String
,
CapacityEngineerStat
>
map
=
new
HashMap
<>();
for
(
CapacityEngineerStat
r
:
records
)
{
HashMap
<
String
,
CapacityEngineerStat
Entity
>
map
=
new
HashMap
<>();
for
(
CapacityEngineerStat
Entity
r
:
records
)
{
map
.
put
(
r
.
getEngineerCode
(),
r
);
}
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