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 a200436d
authored
Jul 07, 2023
by
wangli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
1 parent
7b1c3c88
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
546 additions
and
515 deletions
project-order/src/main/java/com/dituhui/pea/order/controller/EngineerController.java
project-order/src/main/java/com/dituhui/pea/order/service/EngineerService.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/EngineerServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/controller/EngineerController.java
View file @
a200436
...
@@ -20,11 +20,16 @@ public class EngineerController {
...
@@ -20,11 +20,16 @@ public class EngineerController {
private
EngineerService
engineerService
;
private
EngineerService
engineerService
;
@GetMapping
(
"/engineer/info/list"
)
@GetMapping
(
"/engineer/info/list"
)
public
Result
<?>
getEngineerInfoList
(
@RequestParam
long
page
,
@RequestParam
long
size
)
{
public
Result
<?>
getEngineerInfoList
(
@RequestParam
String
levelType
,
@RequestParam
String
levelValue
,
@RequestParam
long
page
,
@RequestParam
long
size
,
@RequestParam
(
required
=
false
)
String
kind
,
@RequestParam
(
required
=
false
)
String
key
)
{
// 获取工程师基础信息列表
// 获取工程师基础信息列表
Result
<?>
res
=
null
;
Result
<?>
res
=
null
;
try
{
try
{
res
=
engineerService
.
getEngineerInfoList
(
page
,
size
);
res
=
engineerService
.
getEngineerInfoList
(
levelType
,
levelValue
,
page
,
size
,
kind
,
key
);
}
catch
(
BusinessException
e
)
{
}
catch
(
BusinessException
e
)
{
return
Result
.
failed
(
e
.
getMessage
());
return
Result
.
failed
(
e
.
getMessage
());
}
}
...
@@ -44,11 +49,16 @@ public class EngineerController {
...
@@ -44,11 +49,16 @@ public class EngineerController {
}
}
@GetMapping
(
"/engineer/skill/list"
)
@GetMapping
(
"/engineer/skill/list"
)
public
Result
<?>
getEngineerSkillList
(
@RequestParam
long
page
,
@RequestParam
long
size
)
{
public
Result
<?>
getEngineerSkillList
(
@RequestParam
String
levelType
,
@RequestParam
String
levelValue
,
@RequestParam
long
page
,
@RequestParam
long
size
,
@RequestParam
(
required
=
false
)
String
kind
,
@RequestParam
(
required
=
false
)
String
key
)
{
// 获取工程师技能信息列表
// 获取工程师技能信息列表
Result
<?>
res
=
null
;
Result
<?>
res
=
null
;
try
{
try
{
res
=
engineerService
.
getEngineerSkillList
(
page
,
size
);
res
=
engineerService
.
getEngineerSkillList
(
levelType
,
levelValue
,
page
,
size
,
kind
,
key
);
}
catch
(
BusinessException
e
)
{
}
catch
(
BusinessException
e
)
{
return
Result
.
failed
(
e
.
getMessage
());
return
Result
.
failed
(
e
.
getMessage
());
}
}
...
@@ -79,11 +89,16 @@ public class EngineerController {
...
@@ -79,11 +89,16 @@ public class EngineerController {
}
}
@GetMapping
(
"/engineer/business/list"
)
@GetMapping
(
"/engineer/business/list"
)
public
Result
<?>
getEngineerBusinessList
(
@RequestParam
long
page
,
@RequestParam
long
size
)
{
public
Result
<?>
getEngineerBusinessList
(
@RequestParam
String
levelType
,
@RequestParam
String
levelValue
,
@RequestParam
long
page
,
@RequestParam
long
size
,
@RequestParam
(
required
=
false
)
String
kind
,
@RequestParam
(
required
=
false
)
String
key
)
{
// 技术员业务属性配置列表
// 技术员业务属性配置列表
Result
<?>
res
=
null
;
Result
<?>
res
=
null
;
try
{
try
{
res
=
engineerService
.
getEngineerBusinessList
(
page
,
size
);
res
=
engineerService
.
getEngineerBusinessList
(
levelType
,
levelValue
,
page
,
size
,
kind
,
key
);
}
catch
(
BusinessException
e
)
{
}
catch
(
BusinessException
e
)
{
return
Result
.
failed
(
e
.
getMessage
());
return
Result
.
failed
(
e
.
getMessage
());
}
}
...
...
project-order/src/main/java/com/dituhui/pea/order/service/EngineerService.java
View file @
a200436
...
@@ -8,16 +8,16 @@ import java.util.List;
...
@@ -8,16 +8,16 @@ import java.util.List;
public
interface
EngineerService
{
public
interface
EngineerService
{
// 获取公司列表
// 获取公司列表
Result
<?>
getEngineerInfoList
(
long
page
,
long
size
);
Result
<?>
getEngineerInfoList
(
String
levelType
,
String
levelValue
,
long
page
,
long
size
,
String
kind
,
String
key
);
Result
<?>
getEngineerInfoDetail
(
String
engineerCode
);
Result
<?>
getEngineerInfoDetail
(
String
engineerCode
);
// 获取工程师技能列表
// 获取工程师技能列表
Result
<?>
getEngineerSkillList
(
long
page
,
long
size
);
Result
<?>
getEngineerSkillList
(
String
levelType
,
String
levelValue
,
long
page
,
long
size
,
String
kind
,
String
key
);
Result
<?>
getEngineerSkillDetail
(
String
engineerCode
);
Result
<?>
getEngineerSkillDetail
(
String
engineerCode
);
Result
<?>
engineerSkillUpdate
(
String
engineerCode
,
List
<
String
>
categoryIds
);
Result
<?>
engineerSkillUpdate
(
String
engineerCode
,
List
<
String
>
categoryIds
);
// 工程师业务属性配置列表
// 工程师业务属性配置列表
Result
<?>
getEngineerBusinessList
(
long
page
,
long
size
);
Result
<?>
getEngineerBusinessList
(
String
levelType
,
String
levelValue
,
long
page
,
long
size
,
String
kind
,
String
key
);
Result
<?>
getEngineerBusinessDetail
(
String
engineerCode
);
Result
<?>
getEngineerBusinessDetail
(
String
engineerCode
);
// 技术员业务属性配置修改
// 技术员业务属性配置修改
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/EngineerServiceImpl.java
View file @
a200436
package
com
.
dituhui
.
pea
.
order
.
service
.
impl
;
package
com
.
dituhui
.
pea
.
order
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
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.TimeUtils
;
import
com.dituhui.pea.order.common.TimeUtils
;
...
@@ -7,10 +11,6 @@ import com.dituhui.pea.order.dao.*;
...
@@ -7,10 +11,6 @@ import com.dituhui.pea.order.dao.*;
import
com.dituhui.pea.order.dto.*
;
import
com.dituhui.pea.order.dto.*
;
import
com.dituhui.pea.order.entity.*
;
import
com.dituhui.pea.order.entity.*
;
import
com.dituhui.pea.order.service.EngineerService
;
import
com.dituhui.pea.order.service.EngineerService
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -25,506 +25,522 @@ import java.util.stream.Collectors;
...
@@ -25,506 +25,522 @@ import java.util.stream.Collectors;
@Service
@Service
public
class
EngineerServiceImpl
implements
EngineerService
{
public
class
EngineerServiceImpl
implements
EngineerService
{
@Autowired
@Autowired
private
EngineerInfoMPDao
engineerInfoMPDao
;
private
EngineerInfoMPDao
engineerInfoMPDao
;
@Autowired
@Autowired
private
EngineerSkillMPDao
engineerSkillMPDao
;
private
EngineerSkillMPDao
engineerSkillMPDao
;
@Autowired
@Autowired
private
OrgGroupMPDao
orgGroupMPDao
;
private
OrgGroupMPDao
orgGroupMPDao
;
@Autowired
@Autowired
private
EngineerBusinessMPDao
engineerBusinessDao
;
private
EngineerBusinessMPDao
engineerBusinessDao
;
@Autowired
@Autowired
private
OrderRequestDao
orderRequestDao
;
private
OrderRequestDao
orderRequestDao
;
@Autowired
@Autowired
private
OrderAppointmentDao
orderAppointmentDao
;
private
OrderAppointmentDao
orderAppointmentDao
;
@Autowired
@Autowired
private
EngineerInfoDao
engineerInfoDao
;
private
EngineerInfoDao
engineerInfoDao
;
@Autowired
@Autowired
private
CapacityEngineerStatDao
capacityEngineerStatDao
;
private
CapacityEngineerStatDao
capacityEngineerStatDao
;
@Transactional
@Transactional
@Override
@Override
public
Result
<?>
getEngineerInfoList
(
long
page
,
long
size
)
{
public
Result
<?>
getEngineerInfoList
(
String
levelType
,
String
levelValue
,
long
page
,
long
size
,
String
kind
,
String
key
)
{
// 查询工程师信息
// 查询工程师信息
IPage
<
EngineerInfo
>
pg
=
this
.
queryEngineerInfoIPage
(
page
,
size
);
IPage
<
EngineerInfo
>
pg
=
this
.
queryEngineerInfoIPage
(
levelType
,
levelValue
,
page
,
size
,
kind
,
key
);
List
<
EngineerInfo
>
records
=
pg
.
getRecords
();
List
<
EngineerInfo
>
records
=
pg
.
getRecords
();
// 获取groupIds
// 获取groupIds
List
<
String
>
groupIds
=
records
.
stream
().
map
(
EngineerInfo:
:
getGroupId
).
collect
(
Collectors
.
toList
());
List
<
String
>
groupIds
=
records
.
stream
().
map
(
EngineerInfo:
:
getGroupId
).
collect
(
Collectors
.
toList
());
// 获取Map<groupId, groupName>
// 获取Map<groupId, groupName>
HashMap
<
String
,
String
>
groupNames
=
this
.
queryGroupNames
(
groupIds
);
HashMap
<
String
,
String
>
groupNames
=
this
.
queryGroupNames
(
groupIds
);
// 设置返回值
// 设置返回值
EngineerInfoListResp
res
=
new
EngineerInfoListResp
();
EngineerInfoListResp
res
=
new
EngineerInfoListResp
();
res
.
setContent
(
this
.
packEngineerInfos
(
records
,
groupNames
));
res
.
setContent
(
this
.
packEngineerInfos
(
records
,
groupNames
));
res
.
setTotal
(
pg
.
getTotal
());
res
.
setTotal
(
pg
.
getTotal
());
res
.
setPages
(
pg
.
getPages
());
res
.
setPages
(
pg
.
getPages
());
res
.
setPageCurrent
(
pg
.
getCurrent
());
res
.
setPageCurrent
(
pg
.
getCurrent
());
res
.
setPageSize
(
pg
.
getSize
());
res
.
setPageSize
(
pg
.
getSize
());
return
Result
.
success
(
res
);
return
Result
.
success
(
res
);
}
}
@Override
@Override
public
Result
<?>
getEngineerInfoDetail
(
String
engineerCode
)
throws
BusinessException
{
public
Result
<?>
getEngineerInfoDetail
(
String
engineerCode
)
throws
BusinessException
{
// 获取技术员基础信息详情
// 获取技术员基础信息详情
// 获取技术员列表
// 获取技术员列表
List
<
EngineerInfo
>
records
=
engineerInfoMPDao
.
selectByEngineerCode
(
engineerCode
);
List
<
EngineerInfo
>
records
=
engineerInfoMPDao
.
selectByEngineerCode
(
engineerCode
);
if
(
records
.
isEmpty
())
{
if
(
records
.
isEmpty
())
{
throw
new
BusinessException
(
"技术员不存在"
);
throw
new
BusinessException
(
"技术员不存在"
);
}
}
List
<
String
>
groupIds
=
records
.
stream
().
map
(
EngineerInfo:
:
getGroupId
).
collect
(
Collectors
.
toList
());
List
<
String
>
groupIds
=
records
.
stream
().
map
(
EngineerInfo:
:
getGroupId
).
collect
(
Collectors
.
toList
());
HashMap
<
String
,
String
>
groupNames
=
this
.
queryGroupNames
(
groupIds
);
HashMap
<
String
,
String
>
groupNames
=
this
.
queryGroupNames
(
groupIds
);
List
<
EngineerInfoListResp
.
EngineerInfo
>
items
=
this
.
packEngineerInfos
(
records
,
groupNames
);
List
<
EngineerInfoListResp
.
EngineerInfo
>
items
=
this
.
packEngineerInfos
(
records
,
groupNames
);
if
(
items
.
isEmpty
())
{
if
(
items
.
isEmpty
())
{
throw
new
BusinessException
(
"技术员不存在"
);
throw
new
BusinessException
(
"技术员不存在"
);
}
}
return
Result
.
success
(
items
.
get
(
0
));
return
Result
.
success
(
items
.
get
(
0
));
}
}
@Transactional
@Transactional
@Override
@Override
public
Result
<?>
getEngineerSkillList
(
long
page
,
long
size
)
{
public
Result
<?>
getEngineerSkillList
(
String
levelType
,
String
levelValue
,
long
page
,
long
size
,
String
kind
,
String
key
)
{
// 获取技术员技能列表
// 获取技术员技能列表
IPage
<
EngineerInfo
>
pg
=
this
.
queryEngineerInfoIPage
(
page
,
size
);
IPage
<
EngineerInfo
>
pg
=
this
.
queryEngineerInfoIPage
(
levelType
,
levelValue
,
page
,
size
,
kind
,
key
);
List
<
EngineerInfo
>
engineers
=
pg
.
getRecords
();
List
<
EngineerInfo
>
engineers
=
pg
.
getRecords
();
EngineerSkillListResp
res
=
new
EngineerSkillListResp
();
EngineerSkillListResp
res
=
new
EngineerSkillListResp
();
res
.
setTotal
(
pg
.
getTotal
());
res
.
setTotal
(
pg
.
getTotal
());
res
.
setPages
(
pg
.
getPages
());
res
.
setPages
(
pg
.
getPages
());
res
.
setPageCurrent
(
pg
.
getCurrent
());
res
.
setPageCurrent
(
pg
.
getCurrent
());
res
.
setPageSize
(
pg
.
getSize
());
res
.
setPageSize
(
pg
.
getSize
());
res
.
setContent
(
this
.
packEngineerSkills
(
engineers
));
res
.
setContent
(
this
.
packEngineerSkills
(
engineers
));
return
Result
.
success
(
res
);
return
Result
.
success
(
res
);
}
}
@Override
@Override
public
Result
<?>
getEngineerSkillDetail
(
String
engineerCode
)
throws
BusinessException
{
public
Result
<?>
getEngineerSkillDetail
(
String
engineerCode
)
throws
BusinessException
{
// 获取工程师技能详情
// 获取工程师技能详情
List
<
EngineerInfo
>
engineers
=
engineerInfoMPDao
.
selectByEngineerCode
(
engineerCode
);
List
<
EngineerInfo
>
engineers
=
engineerInfoMPDao
.
selectByEngineerCode
(
engineerCode
);
if
(
engineers
.
isEmpty
())
{
if
(
engineers
.
isEmpty
())
{
throw
new
BusinessException
(
"技术员不存在"
);
throw
new
BusinessException
(
"技术员不存在"
);
}
}
List
<
EngineerSkillListResp
.
EngineerSkill
>
items
=
this
.
packEngineerSkills
(
engineers
);
List
<
EngineerSkillListResp
.
EngineerSkill
>
items
=
this
.
packEngineerSkills
(
engineers
);
if
(
items
.
isEmpty
())
{
if
(
items
.
isEmpty
())
{
throw
new
BusinessException
(
"技术员不存在"
);
throw
new
BusinessException
(
"技术员不存在"
);
}
}
return
Result
.
success
(
items
.
get
(
0
));
return
Result
.
success
(
items
.
get
(
0
));
}
}
@Transactional
@Transactional
@Override
@Override
public
Result
<?>
engineerSkillUpdate
(
String
engineerCode
,
List
<
String
>
categoryIds
)
{
public
Result
<?>
engineerSkillUpdate
(
String
engineerCode
,
List
<
String
>
categoryIds
)
{
// 更新技术员技能
// 更新技术员技能
// 先将所有技能更新为0-不可用状态
// 先将所有技能更新为0-不可用状态
LambdaUpdateWrapper
<
EngineerSkill
>
wrapper
=
new
LambdaUpdateWrapper
<>();
LambdaUpdateWrapper
<
EngineerSkill
>
wrapper
=
new
LambdaUpdateWrapper
<>();
wrapper
.
eq
(
EngineerSkill:
:
getEngineerCode
,
engineerCode
).
set
(
EngineerSkill:
:
getStatus
,
0
);
wrapper
.
eq
(
EngineerSkill:
:
getEngineerCode
,
engineerCode
).
set
(
EngineerSkill:
:
getStatus
,
0
);
engineerSkillMPDao
.
update
(
null
,
wrapper
);
engineerSkillMPDao
.
update
(
null
,
wrapper
);
if
(
categoryIds
.
isEmpty
())
{
if
(
categoryIds
.
isEmpty
())
{
return
null
;
return
null
;
}
}
// 更新categoryIds状态为1
// 更新categoryIds状态为1
wrapper
.
eq
(
EngineerSkill:
:
getEngineerCode
,
engineerCode
);
wrapper
.
eq
(
EngineerSkill:
:
getEngineerCode
,
engineerCode
);
wrapper
.
in
(
EngineerSkill:
:
getCategoryId
,
categoryIds
);
wrapper
.
in
(
EngineerSkill:
:
getCategoryId
,
categoryIds
);
wrapper
.
set
(
EngineerSkill:
:
getStatus
,
1
);
wrapper
.
set
(
EngineerSkill:
:
getStatus
,
1
);
int
n
=
engineerSkillMPDao
.
update
(
null
,
wrapper
);
int
n
=
engineerSkillMPDao
.
update
(
null
,
wrapper
);
if
(
categoryIds
.
size
()
==
n
)
{
if
(
categoryIds
.
size
()
==
n
)
{
// 更新记录条数等于提交记录条数
// 更新记录条数等于提交记录条数
return
null
;
return
null
;
}
}
// 可能存在engineerSkill表不存在的记录,需要补充录入
// 可能存在engineerSkill表不存在的记录,需要补充录入
List
<
Integer
>
statuses
=
new
ArrayList
<
Integer
>(
Arrays
.
asList
(
1
,
0
));
List
<
Integer
>
statuses
=
new
ArrayList
<
Integer
>(
Arrays
.
asList
(
1
,
0
));
List
<
String
>
engineerCodes
=
new
ArrayList
<>(
Collections
.
singletonList
(
engineerCode
));
List
<
String
>
engineerCodes
=
new
ArrayList
<>(
Collections
.
singletonList
(
engineerCode
));
HashMap
<
String
,
List
<
String
>>
engineerSkills
=
this
.
queryEngineerSkills
(
engineerCodes
,
statuses
);
HashMap
<
String
,
List
<
String
>>
engineerSkills
=
this
.
queryEngineerSkills
(
engineerCodes
,
statuses
);
Set
<
String
>
sInput
=
new
HashSet
<>(
categoryIds
);
Set
<
String
>
sInput
=
new
HashSet
<>(
categoryIds
);
Set
<
String
>
sDB
=
new
HashSet
<>(
engineerSkills
.
get
(
engineerCode
));
Set
<
String
>
sDB
=
new
HashSet
<>(
engineerSkills
.
get
(
engineerCode
));
sInput
.
removeAll
(
sDB
);
sInput
.
removeAll
(
sDB
);
for
(
String
categoryId
:
sInput
)
{
for
(
String
categoryId
:
sInput
)
{
EngineerSkill
e
=
new
EngineerSkill
();
EngineerSkill
e
=
new
EngineerSkill
();
e
.
setEngineerCode
(
engineerCode
);
e
.
setEngineerCode
(
engineerCode
);
e
.
setCategoryId
(
categoryId
);
e
.
setCategoryId
(
categoryId
);
e
.
setStatus
(
1
);
e
.
setStatus
(
1
);
engineerSkillMPDao
.
insert
(
e
);
engineerSkillMPDao
.
insert
(
e
);
}
}
return
null
;
return
null
;
}
}
@Transactional
@Transactional
@Override
@Override
public
Result
<?>
getEngineerBusinessList
(
long
page
,
long
size
)
{
public
Result
<?>
getEngineerBusinessList
(
String
levelType
,
String
levelValue
,
long
page
,
long
size
,
String
kind
,
String
key
)
{
// 技术员业务属性配置列表
// 技术员业务属性配置列表
// 查询技术员列表
// 查询技术员列表
IPage
<
EngineerInfo
>
pg
=
this
.
queryEngineerInfoIPage
(
page
,
size
);
IPage
<
EngineerInfo
>
pg
=
this
.
queryEngineerInfoIPage
(
levelType
,
levelValue
,
page
,
size
,
kind
,
key
);
List
<
EngineerInfo
>
engineers
=
pg
.
getRecords
();
List
<
EngineerInfo
>
engineers
=
pg
.
getRecords
();
// 查询技术员业务属性
// 查询技术员业务属性
EngineerBusinessListResp
res
=
new
EngineerBusinessListResp
();
EngineerBusinessListResp
res
=
new
EngineerBusinessListResp
();
res
.
setTotal
(
pg
.
getTotal
());
res
.
setTotal
(
pg
.
getTotal
());
res
.
setPages
(
pg
.
getPages
());
res
.
setPages
(
pg
.
getPages
());
res
.
setPageCurrent
(
pg
.
getCurrent
());
res
.
setPageCurrent
(
pg
.
getCurrent
());
res
.
setPageSize
(
pg
.
getSize
());
res
.
setPageSize
(
pg
.
getSize
());
res
.
setContent
(
this
.
packEngineerBusinesses
(
engineers
));
res
.
setContent
(
this
.
packEngineerBusinesses
(
engineers
));
return
Result
.
success
(
res
);
return
Result
.
success
(
res
);
}
}
@Override
@Override
public
Result
<?>
getEngineerBusinessDetail
(
String
engineerCode
)
{
public
Result
<?>
getEngineerBusinessDetail
(
String
engineerCode
)
{
// 获取技术员业务熟悉详情
// 获取技术员业务熟悉详情
List
<
EngineerInfo
>
engineers
=
engineerInfoMPDao
.
selectByEngineerCode
(
engineerCode
);
List
<
EngineerInfo
>
engineers
=
engineerInfoMPDao
.
selectByEngineerCode
(
engineerCode
);
if
(
engineers
.
isEmpty
())
{
if
(
engineers
.
isEmpty
())
{
throw
new
BusinessException
(
"技术员不存在"
);
throw
new
BusinessException
(
"技术员不存在"
);
}
}
List
<?>
items
=
this
.
packEngineerBusinesses
(
engineers
);
List
<?>
items
=
this
.
packEngineerBusinesses
(
engineers
);
if
(
items
.
isEmpty
())
{
if
(
items
.
isEmpty
())
{
throw
new
BusinessException
(
"技术员不存在"
);
throw
new
BusinessException
(
"技术员不存在"
);
}
}
return
Result
.
success
(
items
.
get
(
0
));
return
Result
.
success
(
items
.
get
(
0
));
}
}
@Transactional
@Transactional
@Override
@Override
public
Result
<?>
engineerBusinessUpdate
(
String
engineerCode
,
Integer
maxNum
,
Integer
maxMinute
,
String
departure
,
String
priority
)
{
public
Result
<?>
engineerBusinessUpdate
(
String
engineerCode
,
Integer
maxNum
,
Integer
maxMinute
,
String
departure
,
String
priority
)
{
// 技术员业务属性配置修改
// 技术员业务属性配置修改
LambdaUpdateWrapper
<
EngineerBusiness
>
wrapper
=
new
LambdaUpdateWrapper
<>();
LambdaUpdateWrapper
<
EngineerBusiness
>
wrapper
=
new
LambdaUpdateWrapper
<>();
wrapper
.
eq
(
EngineerBusiness:
:
getEngineerCode
,
engineerCode
);
wrapper
.
eq
(
EngineerBusiness:
:
getEngineerCode
,
engineerCode
);
wrapper
.
set
(
maxNum
>=
0
,
EngineerBusiness:
:
getMaxNum
,
maxNum
);
wrapper
.
set
(
maxNum
>=
0
,
EngineerBusiness:
:
getMaxNum
,
maxNum
);
wrapper
.
set
(
maxMinute
>=
0
,
EngineerBusiness:
:
getMaxMinute
,
maxMinute
);
wrapper
.
set
(
maxMinute
>=
0
,
EngineerBusiness:
:
getMaxMinute
,
maxMinute
);
Integer
dep
=
(
departure
.
equals
(
"配件仓"
))
?
1
:
2
;
Integer
dep
=
(
departure
.
equals
(
"配件仓"
))
?
1
:
2
;
wrapper
.
set
(
EngineerBusiness:
:
getDeparture
,
dep
);
wrapper
.
set
(
EngineerBusiness:
:
getDeparture
,
dep
);
int
pri
;
int
pri
;
if
(
priority
.
equals
(
"高"
))
{
if
(
priority
.
equals
(
"高"
))
{
pri
=
3
;
pri
=
3
;
}
else
if
(
priority
.
equals
(
"中"
))
{
}
else
if
(
priority
.
equals
(
"中"
))
{
pri
=
2
;
pri
=
2
;
}
else
{
}
else
{
pri
=
1
;
pri
=
1
;
}
}
wrapper
.
set
(
EngineerBusiness:
:
getPriority
,
pri
);
wrapper
.
set
(
EngineerBusiness:
:
getPriority
,
pri
);
// 更新字段
// 更新字段
engineerBusinessDao
.
update
(
null
,
wrapper
);
engineerBusinessDao
.
update
(
null
,
wrapper
);
return
Result
.
success
(
null
);
return
Result
.
success
(
null
);
}
}
private
IPage
<
EngineerInfo
>
queryEngineerInfoIPage
(
long
page
,
long
size
)
{
private
IPage
<
EngineerInfo
>
queryEngineerInfoIPage
(
String
levelType
,
String
levelValue
,
long
page
,
long
size
,
String
kind
,
String
key
)
{
// 分页查询工程师基础信息
// 分页查询工程师基础信息
LambdaQueryWrapper
<
EngineerInfo
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
orderByAsc
(
EngineerInfo:
:
getGroupId
);
// 查询技术员所在的groupIds
lqw
.
orderByAsc
(
EngineerInfo:
:
getEngineerCode
);
LambdaQueryWrapper
<
OrgGroup
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
select
(
OrgGroup:
:
getGroupId
);
IPage
<
EngineerInfo
>
pg
=
new
Page
(
page
,
size
);
wrapper
.
eq
(
levelType
.
equals
(
"cluster"
),
OrgGroup:
:
getClusterId
,
levelValue
);
engineerInfoMPDao
.
selectPage
(
pg
,
lqw
);
wrapper
.
eq
(
levelType
.
equals
(
"branch"
),
OrgGroup:
:
getBranchId
,
levelValue
);
return
pg
;
wrapper
.
eq
(
levelType
.
equals
(
"group"
),
OrgGroup:
:
getGroupId
,
levelValue
);
}
List
<
String
>
groupIds
=
orgGroupMPDao
.
selectList
(
wrapper
).
stream
().
map
(
OrgGroup:
:
getGroupId
).
collect
(
Collectors
.
toList
());
private
HashMap
<
String
,
String
>
queryGroupNames
(
List
<
String
>
groupIds
)
{
LambdaQueryWrapper
<
EngineerInfo
>
lqw
=
new
LambdaQueryWrapper
<>();
//查询小组名称映射关系
lqw
.
in
(
groupIds
!=
null
&&
!
groupIds
.
isEmpty
(),
EngineerInfo:
:
getGroupId
,
groupIds
);
HashMap
<
String
,
String
>
map
=
new
HashMap
<>();
lqw
.
eq
(
kind
!=
null
&&
!
kind
.
isEmpty
(),
EngineerInfo:
:
getKind
,
(
kind
==
"fullJob"
)
?
1
:
2
);
if
(
key
!=
null
&&
!
key
.
isEmpty
())
{
if
(
groupIds
.
isEmpty
())
{
lqw
.
or
().
like
(
EngineerInfo:
:
getPhone
,
key
);
return
map
;
lqw
.
or
().
like
(
EngineerInfo:
:
getName
,
key
);
}
lqw
.
or
().
like
(
EngineerInfo:
:
getEngineerCode
,
key
);
LambdaQueryWrapper
<
OrgGroup
>
lqw
=
new
LambdaQueryWrapper
<>();
}
lqw
.
select
(
OrgGroup:
:
getGroupId
,
OrgGroup:
:
getGroupName
);
lqw
.
orderByAsc
(
EngineerInfo:
:
getGroupId
);
lqw
.
in
(
OrgGroup:
:
getGroupId
,
groupIds
);
lqw
.
orderByAsc
(
EngineerInfo:
:
getEngineerCode
);
List
<
OrgGroup
>
groups
=
orgGroupMPDao
.
selectList
(
lqw
);
for
(
OrgGroup
g
:
groups
)
{
IPage
<
EngineerInfo
>
pg
=
new
Page
(
page
,
size
);
map
.
put
(
g
.
getGroupId
(),
g
.
getGroupName
());
engineerInfoMPDao
.
selectPage
(
pg
,
lqw
);
}
return
pg
;
return
map
;
}
}
private
HashMap
<
String
,
String
>
queryGroupNames
(
List
<
String
>
groupIds
)
{
private
HashMap
<
String
,
List
<
String
>>
queryEngineerSkills
(
List
<
String
>
engineerCodes
,
List
<
Integer
>
statuses
)
{
//查询小组名称映射关系
// 获取engineerCode对应的技能表, HashMap<engineerCode, List<skillId>>
HashMap
<
String
,
String
>
map
=
new
HashMap
<>();
HashMap
<
String
,
List
<
String
>>
map
=
new
HashMap
<>();
if
(
groupIds
.
isEmpty
())
{
if
(
engineerCodes
.
isEmpty
())
{
return
map
;
return
map
;
}
}
LambdaQueryWrapper
<
OrgGroup
>
lqw
=
new
LambdaQueryWrapper
<>();
LambdaQueryWrapper
<
EngineerSkill
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
select
(
OrgGroup:
:
getGroupId
,
OrgGroup:
:
getGroupName
);
lqw
.
in
(
EngineerSkill:
:
getEngineerCode
,
engineerCodes
);
lqw
.
in
(
OrgGroup:
:
getGroupId
,
groupIds
);
lqw
.
in
(
EngineerSkill:
:
getStatus
,
statuses
);
List
<
OrgGroup
>
groups
=
orgGroupMPDao
.
selectList
(
lqw
);
List
<
EngineerSkill
>
records
=
engineerSkillMPDao
.
selectList
(
lqw
);
for
(
OrgGroup
g
:
groups
)
{
map
.
put
(
g
.
getGroupId
(),
g
.
getGroupName
());
Comparator
<
EngineerSkill
>
ec
=
Comparator
.
comparing
(
EngineerSkill:
:
getEngineerCode
,
String
.
CASE_INSENSITIVE_ORDER
);
}
List
<
EngineerSkill
>
results
=
records
.
stream
().
sorted
(
ec
).
collect
(
Collectors
.
toList
());
return
map
;
}
// 根据engineerCode分组
Map
<
String
,
List
<
EngineerSkill
>>
g
=
results
.
stream
().
collect
(
Collectors
.
groupingBy
(
EngineerSkill:
:
getEngineerCode
));
private
HashMap
<
String
,
List
<
String
>>
queryEngineerSkills
(
List
<
String
>
engineerCodes
,
List
<
Integer
>
statuses
)
{
// 获取engineerCode对应的技能表, HashMap<engineerCode, List<skillId>>
for
(
String
engineerCode
:
g
.
keySet
())
{
// 技术员技能ID列表
HashMap
<
String
,
List
<
String
>>
map
=
new
HashMap
<>();
List
<
String
>
skillIds
=
g
.
get
(
engineerCode
).
stream
().
map
(
EngineerSkill:
:
getCategoryId
).
collect
(
Collectors
.
toList
());
if
(
engineerCodes
.
isEmpty
())
{
map
.
put
(
engineerCode
,
skillIds
);
return
map
;
}
}
return
map
;
LambdaQueryWrapper
<
EngineerSkill
>
lqw
=
new
LambdaQueryWrapper
<>();
}
lqw
.
in
(
EngineerSkill:
:
getEngineerCode
,
engineerCodes
);
lqw
.
in
(
EngineerSkill:
:
getStatus
,
statuses
);
private
HashMap
<
String
,
EngineerBusiness
>
queryEngineerBusiness
(
List
<
String
>
engineerCodes
)
{
List
<
EngineerSkill
>
records
=
engineerSkillMPDao
.
selectList
(
lqw
);
HashMap
<
String
,
EngineerBusiness
>
map
=
new
HashMap
<>();
if
(
engineerCodes
.
isEmpty
())
{
Comparator
<
EngineerSkill
>
ec
=
Comparator
.
comparing
(
EngineerSkill:
:
getEngineerCode
,
String
.
CASE_INSENSITIVE_ORDER
);
return
map
;
List
<
EngineerSkill
>
results
=
records
.
stream
().
sorted
(
ec
).
collect
(
Collectors
.
toList
());
}
LambdaQueryWrapper
<
EngineerBusiness
>
lqw
=
new
LambdaQueryWrapper
<>();
// 根据engineerCode分组
lqw
.
in
(
EngineerBusiness:
:
getEngineerCode
,
engineerCodes
);
Map
<
String
,
List
<
EngineerSkill
>>
g
=
results
.
stream
().
collect
(
Collectors
.
groupingBy
(
EngineerSkill:
:
getEngineerCode
));
List
<
EngineerBusiness
>
records
=
engineerBusinessDao
.
selectList
(
lqw
);
for
(
EngineerBusiness
r
:
records
)
{
for
(
String
engineerCode
:
g
.
keySet
())
{
map
.
put
(
r
.
getEngineerCode
(),
r
);
// 技术员技能ID列表
}
List
<
String
>
skillIds
=
g
.
get
(
engineerCode
).
stream
().
map
(
EngineerSkill:
:
getCategoryId
).
collect
(
Collectors
.
toList
());
return
map
;
map
.
put
(
engineerCode
,
skillIds
);
}
}
return
map
;
private
List
<
EngineerInfoListResp
.
EngineerInfo
>
packEngineerInfos
(
List
<
EngineerInfo
>
engineers
,
HashMap
<
String
,
String
>
groups
)
{
}
String
groupName
,
age
,
kind
;
private
HashMap
<
String
,
EngineerBusiness
>
queryEngineerBusiness
(
List
<
String
>
engineerCodes
)
{
HashMap
<
String
,
EngineerBusiness
>
map
=
new
HashMap
<>();
List
<
EngineerInfoListResp
.
EngineerInfo
>
items
=
new
ArrayList
<>();
if
(
engineerCodes
.
isEmpty
())
{
for
(
EngineerInfo
e
:
engineers
)
{
return
map
;
EngineerInfoListResp
.
EngineerInfo
item
=
new
EngineerInfoListResp
.
EngineerInfo
();
}
item
.
setEngineerCode
(
e
.
getEngineerCode
());
LambdaQueryWrapper
<
EngineerBusiness
>
lqw
=
new
LambdaQueryWrapper
<>();
item
.
setNumber
(
e
.
getEngineerCode
());
lqw
.
in
(
EngineerBusiness:
:
getEngineerCode
,
engineerCodes
);
item
.
setName
(
e
.
getName
());
List
<
EngineerBusiness
>
records
=
engineerBusinessDao
.
selectList
(
lqw
);
item
.
setSex
(
e
.
getGender
());
for
(
EngineerBusiness
r
:
records
)
{
item
.
setPhone
(
e
.
getPhone
());
map
.
put
(
r
.
getEngineerCode
(),
r
);
item
.
setAddress
(
e
.
getAddress
());
}
item
.
setGrade
(
e
.
getGrade
());
return
map
;
}
// group name
groupName
=
groups
.
getOrDefault
(
e
.
getGroupId
(),
""
);
private
List
<
EngineerInfoListResp
.
EngineerInfo
>
packEngineerInfos
(
List
<
EngineerInfo
>
engineers
,
HashMap
<
String
,
String
>
groups
)
{
item
.
setGroupName
(
groupName
);
String
groupName
,
age
,
kind
;
// 年龄
age
=
this
.
getEngineerAge
(
e
.
getBirth
());
List
<
EngineerInfoListResp
.
EngineerInfo
>
items
=
new
ArrayList
<>();
item
.
setAge
(
age
);
for
(
EngineerInfo
e
:
engineers
)
{
EngineerInfoListResp
.
EngineerInfo
item
=
new
EngineerInfoListResp
.
EngineerInfo
();
// 工作类型:全职/兼职
item
.
setEngineerCode
(
e
.
getEngineerCode
());
kind
=
(
e
.
getKind
()
==
1
)
?
"fullJob"
:
"partJob"
;
item
.
setNumber
(
e
.
getEngineerCode
());
item
.
setKind
(
kind
);
item
.
setName
(
e
.
getName
());
item
.
setSex
(
e
.
getGender
());
if
(
e
.
getCredentials
()
!=
null
)
{
item
.
setPhone
(
e
.
getPhone
());
item
.
setCredentials
(
Arrays
.
asList
(
e
.
getCredentials
().
split
(
"、"
)));
item
.
setAddress
(
e
.
getAddress
());
}
else
{
item
.
setGrade
(
e
.
getGrade
());
item
.
setCredentials
(
new
ArrayList
<
String
>());
}
// group name
groupName
=
groups
.
getOrDefault
(
e
.
getGroupId
(),
""
);
// 标签
item
.
setGroupName
(
groupName
);
List
<
String
>
tags
=
new
ArrayList
<>();
if
(
e
.
getTags
()
!=
null
&&
!
e
.
getTags
().
isEmpty
())
{
// 年龄
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
e
.
getTags
().
entrySet
())
{
age
=
this
.
getEngineerAge
(
e
.
getBirth
());
tags
.
add
(
String
.
format
(
"%s+%s"
,
entry
.
getKey
(),
entry
.
getValue
().
toString
()));
item
.
setAge
(
age
);
}
}
// 工作类型:全职/兼职
item
.
setTags
(
tags
);
kind
=
(
e
.
getKind
()
==
1
)
?
"fullJob"
:
"partJob"
;
item
.
setKind
(
kind
);
items
.
add
(
item
);
}
if
(
e
.
getCredentials
()
!=
null
)
{
return
items
;
item
.
setCredentials
(
Arrays
.
asList
(
e
.
getCredentials
().
split
(
"、"
)));
}
}
else
{
item
.
setCredentials
(
new
ArrayList
<
String
>());
private
List
<
EngineerSkillListResp
.
EngineerSkill
>
packEngineerSkills
(
List
<
EngineerInfo
>
engineers
)
{
}
// 获取groupId类表
List
<
String
>
groupIds
=
engineers
.
stream
().
map
(
EngineerInfo:
:
getGroupId
).
collect
(
Collectors
.
toList
());
// 标签
HashMap
<
String
,
String
>
groupNames
=
this
.
queryGroupNames
(
groupIds
);
List
<
String
>
tags
=
new
ArrayList
<>();
if
(
e
.
getTags
()
!=
null
&&
!
e
.
getTags
().
isEmpty
())
{
// 获取技术员code列表
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
e
.
getTags
().
entrySet
())
{
List
<
String
>
engineerCodes
=
engineers
.
stream
().
map
(
EngineerInfo:
:
getEngineerCode
).
collect
(
Collectors
.
toList
());
tags
.
add
(
String
.
format
(
"%s+%s"
,
entry
.
getKey
(),
entry
.
getValue
().
toString
()));
}
// 获取技术员的可用技能列表
}
List
<
Integer
>
statuses
=
new
ArrayList
<
Integer
>(
List
.
of
(
1
));
item
.
setTags
(
tags
);
HashMap
<
String
,
List
<
String
>>
engineerSkills
=
this
.
queryEngineerSkills
(
engineerCodes
,
statuses
);
List
<
String
>
emptySkills
=
Collections
.
emptyList
();
items
.
add
(
item
);
}
List
<
EngineerSkillListResp
.
EngineerSkill
>
items
=
new
ArrayList
<>();
return
items
;
for
(
EngineerInfo
e
:
engineers
)
{
}
EngineerSkillListResp
.
EngineerSkill
skill
=
new
EngineerSkillListResp
.
EngineerSkill
();
skill
.
setEngineerCode
(
e
.
getEngineerCode
());
private
List
<
EngineerSkillListResp
.
EngineerSkill
>
packEngineerSkills
(
List
<
EngineerInfo
>
engineers
)
{
skill
.
setEngineerName
(
e
.
getName
());
// 获取groupId类表
skill
.
setGroupName
(
groupNames
.
getOrDefault
(
e
.
getGroupId
(),
""
));
List
<
String
>
groupIds
=
engineers
.
stream
().
map
(
EngineerInfo:
:
getGroupId
).
collect
(
Collectors
.
toList
());
skill
.
setUpdateTime
(
TimeUtils
.
IsoTimestamp2DateTime
(
e
.
getUpdateTime
()));
HashMap
<
String
,
String
>
groupNames
=
this
.
queryGroupNames
(
groupIds
);
// 获取一个工程师的技能列表
// 获取技术员code列表
skill
.
setCategoryIds
(
engineerSkills
.
getOrDefault
(
e
.
getEngineerCode
(),
emptySkills
));
List
<
String
>
engineerCodes
=
engineers
.
stream
().
map
(
EngineerInfo:
:
getEngineerCode
).
collect
(
Collectors
.
toList
());
items
.
add
(
skill
);
// 获取技术员的可用技能列表
}
List
<
Integer
>
statuses
=
new
ArrayList
<
Integer
>(
List
.
of
(
1
));
return
items
;
HashMap
<
String
,
List
<
String
>>
engineerSkills
=
this
.
queryEngineerSkills
(
engineerCodes
,
statuses
);
}
List
<
String
>
emptySkills
=
Collections
.
emptyList
();
private
List
<
EngineerBusinessListResp
.
EngineerBusiness
>
packEngineerBusinesses
(
List
<
EngineerInfo
>
engineers
)
{
List
<
EngineerSkillListResp
.
EngineerSkill
>
items
=
new
ArrayList
<>();
// 获取技术员code列表
for
(
EngineerInfo
e
:
engineers
)
{
List
<
String
>
engineerCodes
=
engineers
.
stream
().
map
(
EngineerInfo:
:
getEngineerCode
).
collect
(
Collectors
.
toList
());
EngineerSkillListResp
.
EngineerSkill
skill
=
new
EngineerSkillListResp
.
EngineerSkill
();
skill
.
setEngineerCode
(
e
.
getEngineerCode
());
List
<
String
>
groupIds
=
engineers
.
stream
().
map
(
EngineerInfo:
:
getGroupId
).
collect
(
Collectors
.
toList
());
skill
.
setEngineerName
(
e
.
getName
());
HashMap
<
String
,
String
>
groupNames
=
this
.
queryGroupNames
(
groupIds
);
skill
.
setGroupName
(
groupNames
.
getOrDefault
(
e
.
getGroupId
(),
""
));
skill
.
setUpdateTime
(
TimeUtils
.
IsoTimestamp2DateTime
(
e
.
getUpdateTime
()));
HashMap
<
String
,
EngineerBusiness
>
buss
=
this
.
queryEngineerBusiness
(
engineerCodes
);
// 获取一个工程师的技能列表
List
<
EngineerBusinessListResp
.
EngineerBusiness
>
items
=
new
ArrayList
<>();
skill
.
setCategoryIds
(
engineerSkills
.
getOrDefault
(
e
.
getEngineerCode
(),
emptySkills
));
for
(
EngineerInfo
e
:
engineers
)
{
EngineerBusinessListResp
.
EngineerBusiness
item
=
new
EngineerBusinessListResp
.
EngineerBusiness
();
items
.
add
(
skill
);
}
item
.
setEngineerCode
(
e
.
getEngineerCode
());
return
items
;
item
.
setGroupName
(
groupNames
.
getOrDefault
(
e
.
getGroupId
(),
""
));
}
item
.
setEngineerName
(
e
.
getName
());
item
.
setKind
((
e
.
getKind
()
==
1
)
?
"fullJob"
:
"partJob"
);
private
List
<
EngineerBusinessListResp
.
EngineerBusiness
>
packEngineerBusinesses
(
List
<
EngineerInfo
>
engineers
)
{
// 获取技术员code列表
EngineerBusiness
b
=
buss
.
getOrDefault
(
e
.
getEngineerCode
(),
null
);
List
<
String
>
engineerCodes
=
engineers
.
stream
().
map
(
EngineerInfo:
:
getEngineerCode
).
collect
(
Collectors
.
toList
());
if
(
b
==
null
)
{
item
.
setAddress
(
""
);
List
<
String
>
groupIds
=
engineers
.
stream
().
map
(
EngineerInfo:
:
getGroupId
).
collect
(
Collectors
.
toList
());
item
.
setLocation
(
""
);
HashMap
<
String
,
String
>
groupNames
=
this
.
queryGroupNames
(
groupIds
);
item
.
setDeparture
(
""
);
item
.
setMaxMinute
(
0
);
HashMap
<
String
,
EngineerBusiness
>
buss
=
this
.
queryEngineerBusiness
(
engineerCodes
);
item
.
setMaxNum
(
0
);
item
.
setPriority
(
"低"
);
List
<
EngineerBusinessListResp
.
EngineerBusiness
>
items
=
new
ArrayList
<>();
}
else
{
for
(
EngineerInfo
e
:
engineers
)
{
item
.
setAddress
(
b
.
getAddress
());
EngineerBusinessListResp
.
EngineerBusiness
item
=
new
EngineerBusinessListResp
.
EngineerBusiness
();
item
.
setLocation
(
String
.
format
(
"%s,%s"
,
b
.
getX
(),
b
.
getY
()));
item
.
setDeparture
((
b
.
getDeparture
()
==
1
)
?
"配件仓"
:
"住址"
);
item
.
setEngineerCode
(
e
.
getEngineerCode
());
item
.
setMaxMinute
(
b
.
getMaxMinute
());
item
.
setGroupName
(
groupNames
.
getOrDefault
(
e
.
getGroupId
(),
""
));
item
.
setMaxNum
(
b
.
getMaxNum
());
item
.
setEngineerName
(
e
.
getName
());
item
.
setKind
((
e
.
getKind
()
==
1
)
?
"fullJob"
:
"partJob"
);
String
priority
;
if
(
b
.
getPriority
()
==
3
)
{
EngineerBusiness
b
=
buss
.
getOrDefault
(
e
.
getEngineerCode
(),
null
);
priority
=
"高"
;
if
(
b
==
null
)
{
}
else
if
(
b
.
getPriority
()
==
2
)
{
item
.
setAddress
(
""
);
priority
=
"中"
;
item
.
setLocation
(
""
);
}
else
{
item
.
setDeparture
(
""
);
priority
=
"低"
;
item
.
setMaxMinute
(
0
);
}
item
.
setMaxNum
(
0
);
item
.
setPriority
(
priority
);
item
.
setPriority
(
"低"
);
}
}
else
{
items
.
add
(
item
);
item
.
setAddress
(
b
.
getAddress
());
}
item
.
setLocation
(
String
.
format
(
"%s,%s"
,
b
.
getX
(),
b
.
getY
()));
return
items
;
item
.
setDeparture
((
b
.
getDeparture
()
==
1
)
?
"配件仓"
:
"住址"
);
}
item
.
setMaxMinute
(
b
.
getMaxMinute
());
item
.
setMaxNum
(
b
.
getMaxNum
());
private
HashMap
<
String
,
Integer
>
getEngineerSkillIds
(
List
<
String
>
skillIds
,
HashMap
<
String
,
Integer
>
engineerSkillIds
)
{
String
priority
;
HashMap
<
String
,
Integer
>
map
=
new
HashMap
<>();
if
(
b
.
getPriority
()
==
3
)
{
for
(
String
skillId
:
skillIds
)
{
priority
=
"高"
;
map
.
put
(
skillId
,
engineerSkillIds
.
getOrDefault
(
skillId
,
0
));
}
else
if
(
b
.
getPriority
()
==
2
)
{
}
priority
=
"中"
;
return
map
;
}
else
{
}
priority
=
"低"
;
}
private
String
getEngineerAge
(
String
birth
)
{
item
.
setPriority
(
priority
);
// 获取工程师年龄
}
if
(
birth
.
isEmpty
())
{
items
.
add
(
item
);
return
""
;
}
}
return
items
;
int
age
;
}
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
try
{
Date
birthDate
=
dateFormat
.
parse
(
birth
);
private
HashMap
<
String
,
Integer
>
getEngineerSkillIds
(
List
<
String
>
skillIds
,
HashMap
<
String
,
Integer
>
engineerSkillIds
)
{
Calendar
birthCalendar
=
Calendar
.
getInstance
();
HashMap
<
String
,
Integer
>
map
=
new
HashMap
<>();
birthCalendar
.
setTime
(
birthDate
);
for
(
String
skillId
:
skillIds
)
{
Calendar
nowCalendar
=
Calendar
.
getInstance
();
map
.
put
(
skillId
,
engineerSkillIds
.
getOrDefault
(
skillId
,
0
));
age
=
nowCalendar
.
get
(
Calendar
.
YEAR
)
-
birthCalendar
.
get
(
Calendar
.
YEAR
);
}
if
(
nowCalendar
.
get
(
Calendar
.
DAY_OF_YEAR
)
<
birthCalendar
.
get
(
Calendar
.
DAY_OF_YEAR
))
{
return
map
;
age
--;
}
}
}
catch
(
Exception
e
)
{
private
String
getEngineerAge
(
String
birth
)
{
return
""
;
// 获取工程师年龄
}
if
(
birth
.
isEmpty
())
{
return
(
age
<=
0
)
?
""
:
Integer
.
toString
(
age
);
return
""
;
}
}
int
age
;
@Override
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
public
Result
<?>
getEngineersGanttList
(
EngineersGanttReqDTO
reqDTO
)
{
try
{
// 按日期返回技术员们当天的服务甘特图,不需要翻页
Date
birthDate
=
dateFormat
.
parse
(
birth
);
log
.
info
(
"getEngineersGanttList: {}"
,
reqDTO
);
Calendar
birthCalendar
=
Calendar
.
getInstance
();
List
<
OrderAppointmentEntity
>
orderAppointments
=
orderAppointmentDao
.
findByDateAndEngineerCodeIn
(
reqDTO
.
getDate
(),
reqDTO
.
getEngineerCodes
());
birthCalendar
.
setTime
(
birthDate
);
List
<
String
>
orderIds
=
orderAppointments
.
stream
().
map
(
OrderAppointmentEntity:
:
getOrderId
).
collect
(
Collectors
.
toList
());
Calendar
nowCalendar
=
Calendar
.
getInstance
();
Map
<
String
,
OrderRequestEntity
>
mapOrderRequest
=
getOrdersByOrderIds
(
orderIds
);
age
=
nowCalendar
.
get
(
Calendar
.
YEAR
)
-
birthCalendar
.
get
(
Calendar
.
YEAR
);
HashMap
<
String
,
List
<
EngineersGanttRespDTO
.
Order
>>
mapEngineers
=
new
HashMap
<>();
if
(
nowCalendar
.
get
(
Calendar
.
DAY_OF_YEAR
)
<
birthCalendar
.
get
(
Calendar
.
DAY_OF_YEAR
))
{
for
(
OrderAppointmentEntity
e
:
orderAppointments
)
{
age
--;
log
.
info
(
"===== order_id: [{}]"
,
e
.
getOrderId
());
}
EngineersGanttRespDTO
.
Order
order
=
new
EngineersGanttRespDTO
.
Order
();
}
catch
(
Exception
e
)
{
// todo 需要根据订单时间和状态,采用expectXXXX或者actualXXXX
return
""
;
order
.
setStartTime
(
e
.
getExpectStartTime
()).
setEndTime
(
e
.
getExpectEndTime
());
}
order
.
setOrderId
(
e
.
getOrderId
()).
setPreStatus
(
e
.
getPreStatus
());
return
(
age
<=
0
)
?
""
:
Integer
.
toString
(
age
);
order
.
setTips
(
getOrderTips
(
e
.
getOrderId
()));
}
order
.
setAppointmentStatus
(
mapOrderRequest
.
get
(
e
.
getOrderId
()).
getAppointmentStatus
());
List
<
EngineersGanttRespDTO
.
Order
>
orders
=
null
;
@Override
if
(
mapEngineers
.
containsKey
(
e
.
getEngineerCode
()))
{
public
Result
<?>
getEngineersGanttList
(
EngineersGanttReqDTO
reqDTO
)
{
orders
=
mapEngineers
.
get
(
e
.
getEngineerCode
());
// 按日期返回技术员们当天的服务甘特图,不需要翻页
}
else
{
log
.
info
(
"getEngineersGanttList: {}"
,
reqDTO
);
orders
=
new
ArrayList
<>();
List
<
OrderAppointmentEntity
>
orderAppointments
=
orderAppointmentDao
.
findByDateAndEngineerCodeIn
(
reqDTO
.
getDate
(),
reqDTO
.
getEngineerCodes
());
}
List
<
String
>
orderIds
=
orderAppointments
.
stream
().
map
(
OrderAppointmentEntity:
:
getOrderId
).
collect
(
Collectors
.
toList
());
orders
.
add
(
order
);
Map
<
String
,
OrderRequestEntity
>
mapOrderRequest
=
getOrdersByOrderIds
(
orderIds
);
mapEngineers
.
put
(
e
.
getEngineerCode
(),
orders
);
HashMap
<
String
,
List
<
EngineersGanttRespDTO
.
Order
>>
mapEngineers
=
new
HashMap
<>();
}
for
(
OrderAppointmentEntity
e
:
orderAppointments
)
{
log
.
info
(
"===== order_id: [{}]"
,
e
.
getOrderId
());
List
<
EngineersGanttRespDTO
.
GanttChart
>
engineers
=
new
ArrayList
<>();
EngineersGanttRespDTO
.
Order
order
=
new
EngineersGanttRespDTO
.
Order
();
for
(
String
engineerCode
:
reqDTO
.
getEngineerCodes
())
{
// todo 需要根据订单时间和状态,采用expectXXXX或者actualXXXX
EngineerInfoEntity
engineerInfo
=
engineerInfoDao
.
getByEngineerCode
(
engineerCode
);
order
.
setStartTime
(
e
.
getExpectStartTime
()).
setEndTime
(
e
.
getExpectEndTime
());
EngineersGanttRespDTO
.
GanttChart
engineer
=
new
EngineersGanttRespDTO
.
GanttChart
();
order
.
setOrderId
(
e
.
getOrderId
()).
setPreStatus
(
e
.
getPreStatus
());
engineer
.
setEngineerCode
(
engineerCode
)
order
.
setTips
(
getOrderTips
(
e
.
getOrderId
()));
.
setStartTime
(
String
.
format
(
"%s 08:00"
,
reqDTO
.
getDate
()))
order
.
setAppointmentStatus
(
mapOrderRequest
.
get
(
e
.
getOrderId
()).
getAppointmentStatus
());
.
setEndTime
(
String
.
format
(
"%s 18:00"
,
reqDTO
.
getDate
()))
List
<
EngineersGanttRespDTO
.
Order
>
orders
=
null
;
.
setHoliday
(
false
)
// todo
if
(
mapEngineers
.
containsKey
(
e
.
getEngineerCode
()))
{
.
setEngineerName
(
engineerInfo
.
getName
())
orders
=
mapEngineers
.
get
(
e
.
getEngineerCode
());
.
setGrade
(
engineerInfo
.
getGrade
());
}
else
{
orders
=
new
ArrayList
<>();
CapacityEngineerStatEntity
capacityEngineerStat
=
capacityEngineerStatDao
.
getByEngineerCodeAndWorkday
(
engineerCode
,
reqDTO
.
getDate
());
}
if
(
capacityEngineerStat
==
null
)
{
orders
.
add
(
order
);
log
.
warn
(
"技术员当日的容量数据不存在,{}{}"
,
engineerCode
,
reqDTO
.
getDate
());
mapEngineers
.
put
(
e
.
getEngineerCode
(),
orders
);
}
else
{
}
engineer
.
setCapTotal
(
capacityEngineerStat
.
getCapTotal
().
toString
()).
setCapUsed
(
capacityEngineerStat
.
getCapUsed
().
toString
());
}
List
<
EngineersGanttRespDTO
.
GanttChart
>
engineers
=
new
ArrayList
<>();
if
(
mapEngineers
.
containsKey
(
engineerCode
)){
for
(
String
engineerCode
:
reqDTO
.
getEngineerCodes
())
{
engineer
.
setOrders
(
mapEngineers
.
get
(
engineerCode
));
EngineerInfoEntity
engineerInfo
=
engineerInfoDao
.
getByEngineerCode
(
engineerCode
);
}
EngineersGanttRespDTO
.
GanttChart
engineer
=
new
EngineersGanttRespDTO
.
GanttChart
();
// engineer.setErrorTip(); todo
engineer
.
setEngineerCode
(
engineerCode
)
engineers
.
add
(
engineer
);
.
setStartTime
(
String
.
format
(
"%s 08:00"
,
reqDTO
.
getDate
()))
}
.
setEndTime
(
String
.
format
(
"%s 18:00"
,
reqDTO
.
getDate
()))
EngineersGanttRespDTO
data
=
new
EngineersGanttRespDTO
().
setDate
(
reqDTO
.
getDate
()).
setEngineers
(
engineers
);
.
setHoliday
(
false
)
// todo
return
Result
.
success
(
data
);
.
setEngineerName
(
engineerInfo
.
getName
())
}
.
setGrade
(
engineerInfo
.
getGrade
());
public
Map
<
String
,
OrderRequestEntity
>
getOrdersByOrderIds
(
List
<
String
>
orderIds
)
{
CapacityEngineerStatEntity
capacityEngineerStat
=
capacityEngineerStatDao
.
getByEngineerCodeAndWorkday
(
engineerCode
,
reqDTO
.
getDate
());
List
<
OrderRequestEntity
>
orders
=
orderRequestDao
.
findAllByOrderIdIn
(
orderIds
);
if
(
capacityEngineerStat
==
null
)
{
log
.
warn
(
"技术员当日的容量数据不存在,{}{}"
,
engineerCode
,
reqDTO
.
getDate
());
return
orders
.
stream
()
}
else
{
.
collect
(
Collectors
.
toMap
(
OrderRequestEntity:
:
getOrderId
,
order
->
order
));
engineer
.
setCapTotal
(
capacityEngineerStat
.
getCapTotal
().
toString
()).
setCapUsed
(
capacityEngineerStat
.
getCapUsed
().
toString
());
}
}
if
(
mapEngineers
.
containsKey
(
engineerCode
))
{
private
List
<?>
getOrderTips
(
String
orderId
)
{
engineer
.
setOrders
(
mapEngineers
.
get
(
engineerCode
));
log
.
info
(
"==> getOrderTips: orderId[{}]"
,
orderId
);
}
OrderRequestEntity
order
=
orderRequestDao
.
getByOrderId
(
orderId
);
// engineer.setErrorTip(); todo
if
(
order
==
null
)
{
engineers
.
add
(
engineer
);
log
.
error
(
"对应的订单不存在!{}"
,
orderId
);
}
return
null
;
EngineersGanttRespDTO
data
=
new
EngineersGanttRespDTO
().
setDate
(
reqDTO
.
getDate
()).
setEngineers
(
engineers
);
}
return
Result
.
success
(
data
);
List
<
LabelValueDTO
>
tips
=
new
ArrayList
<>();
}
tips
.
add
(
new
LabelValueDTO
().
setLabel
(
"工单号码"
).
setValue
(
orderId
));
tips
.
add
(
new
LabelValueDTO
().
setLabel
(
"类型/品牌"
).
setValue
(
String
.
format
(
"%s %s"
,
order
.
getBrand
(),
order
.
getType
())));
public
Map
<
String
,
OrderRequestEntity
>
getOrdersByOrderIds
(
List
<
String
>
orderIds
)
{
tips
.
add
(
new
LabelValueDTO
().
setLabel
(
"电话/地址"
).
setValue
(
String
.
format
(
"%s %s\n %s"
,
order
.
getName
(),
order
.
getPhone
(),
order
.
getAddress
())));
List
<
OrderRequestEntity
>
orders
=
orderRequestDao
.
findAllByOrderIdIn
(
orderIds
);
if
(
StringUtils
.
isNotBlank
(
order
.
getApplyNote
()))
{
tips
.
add
(
new
LabelValueDTO
().
setLabel
(
"备注"
).
setValue
(
order
.
getApplyNote
()));
return
orders
.
stream
()
}
.
collect
(
Collectors
.
toMap
(
OrderRequestEntity:
:
getOrderId
,
order
->
order
));
tips
.
add
(
new
LabelValueDTO
().
setLabel
(
"标签"
).
setValue
(
order
.
getTags
()));
}
return
tips
;
}
private
List
<?>
getOrderTips
(
String
orderId
)
{
log
.
info
(
"==> getOrderTips: orderId[{}]"
,
orderId
);
OrderRequestEntity
order
=
orderRequestDao
.
getByOrderId
(
orderId
);
if
(
order
==
null
)
{
log
.
error
(
"对应的订单不存在!{}"
,
orderId
);
return
null
;
}
List
<
LabelValueDTO
>
tips
=
new
ArrayList
<>();
tips
.
add
(
new
LabelValueDTO
().
setLabel
(
"工单号码"
).
setValue
(
orderId
));
tips
.
add
(
new
LabelValueDTO
().
setLabel
(
"类型/品牌"
).
setValue
(
String
.
format
(
"%s %s"
,
order
.
getBrand
(),
order
.
getType
())));
tips
.
add
(
new
LabelValueDTO
().
setLabel
(
"电话/地址"
).
setValue
(
String
.
format
(
"%s %s\n %s"
,
order
.
getName
(),
order
.
getPhone
(),
order
.
getAddress
())));
if
(
StringUtils
.
isNotBlank
(
order
.
getApplyNote
()))
{
tips
.
add
(
new
LabelValueDTO
().
setLabel
(
"备注"
).
setValue
(
order
.
getApplyNote
()));
}
tips
.
add
(
new
LabelValueDTO
().
setLabel
(
"标签"
).
setValue
(
order
.
getTags
()));
return
tips
;
}
}
}
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