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 1d36356d
authored
Jun 07, 2023
by
wangli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增技术员技能修改接口实现
1 parent
fdb953b7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
4 deletions
project-order/src/main/java/com/alibaba/cloud/integration/order/controller/EngineerController.java
project-order/src/main/java/com/alibaba/cloud/integration/order/service/EngineerService.java
project-order/src/main/java/com/alibaba/cloud/integration/order/service/impl/EngineerServiceImpl.java
project-order/src/main/java/com/alibaba/cloud/integration/order/controller/EngineerController.java
View file @
1d36356
...
...
@@ -7,6 +7,8 @@ import org.apache.ibatis.annotations.Mapper;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
@RestController
@RequestMapping
(
"/pea-order"
)
public
class
EngineerController
{
...
...
@@ -38,6 +40,17 @@ public class EngineerController {
return
res
;
}
@GetMapping
(
"/engineer/skill/update"
)
public
Result
<?>
engineerSkillUpdate
(
@RequestBody
String
engineerCode
,
@RequestBody
List
<
String
>
categoryIds
)
{
// 获取工程师技能信息修改
try
{
engineerService
.
engineerSkillUpdate
(
engineerCode
,
categoryIds
);
}
catch
(
BusinessException
e
)
{
Result
.
failed
(
e
.
getMessage
());
}
return
Result
.
success
(
null
);
}
@GetMapping
(
"/engineer/business/list"
)
public
Result
<?>
getEngineerBusinessList
(
@RequestParam
long
page
,
@RequestParam
long
size
)
{
// 技术员业务属性配置列表
...
...
project-order/src/main/java/com/alibaba/cloud/integration/order/service/EngineerService.java
View file @
1d36356
...
...
@@ -2,6 +2,8 @@ package com.alibaba.cloud.integration.order.service;
import
com.alibaba.cloud.integration.common.Result
;
import
java.util.List
;
public
interface
EngineerService
{
// 获取公司列表
...
...
@@ -9,6 +11,7 @@ public interface EngineerService {
// 获取工程师技能列表
Result
<?>
getEngineerSkillList
(
long
page
,
long
size
);
Result
<?>
engineerSkillUpdate
(
String
engineerCode
,
List
<
String
>
categoryIds
);
// 工程师业务属性配置列表
Result
<?>
getEngineerBusinessList
(
long
page
,
long
size
);
...
...
project-order/src/main/java/com/alibaba/cloud/integration/order/service/impl/EngineerServiceImpl.java
View file @
1d36356
...
...
@@ -78,7 +78,8 @@ public class EngineerServiceImpl implements EngineerService {
List
<
String
>
engineerCodes
=
engineers
.
stream
().
map
(
EngineerInfo:
:
getEngineerCode
).
collect
(
Collectors
.
toList
());
// 获取技术员的可用技能列表
HashMap
<
String
,
List
<
String
>>
engineerSkills
=
this
.
queryEngineerSkills
(
engineerCodes
);
List
<
Integer
>
statuses
=
new
ArrayList
<
Integer
>(
Arrays
.
asList
(
1
));
HashMap
<
String
,
List
<
String
>>
engineerSkills
=
this
.
queryEngineerSkills
(
engineerCodes
,
statuses
);
List
<
String
>
emptySkills
=
Collections
.
emptyList
();
List
<
EngineerSkillListResp
.
EngineerSkill
>
items
=
new
ArrayList
<>();
...
...
@@ -89,7 +90,7 @@ public class EngineerServiceImpl implements EngineerService {
skill
.
setGroupName
(
groupNames
.
getOrDefault
(
e
.
getGroupId
(),
""
));
// 获取一个工程师的技能列表
skill
.
set
Skill
s
(
engineerSkills
.
getOrDefault
(
e
.
getEngineerCode
(),
emptySkills
));
skill
.
set
CategoryId
s
(
engineerSkills
.
getOrDefault
(
e
.
getEngineerCode
(),
emptySkills
));
items
.
add
(
skill
);
}
...
...
@@ -104,6 +105,47 @@ public class EngineerServiceImpl implements EngineerService {
@Transactional
@Override
public
Result
<?>
engineerSkillUpdate
(
String
engineerCode
,
List
<
String
>
categoryIds
)
{
// 更新技术员技能
// 先将所有技能更新为0-不可用状态
LambdaUpdateWrapper
<
EngineerSkill
>
wrapper
=
new
LambdaUpdateWrapper
<>();
wrapper
.
eq
(
EngineerSkill:
:
getEngineerCode
,
engineerCode
).
set
(
EngineerSkill:
:
getStatus
,
0
);
engineerSkillDao
.
update
(
null
,
wrapper
);
if
(
categoryIds
.
isEmpty
()){
return
null
;
}
// 更新categoryIds状态为1
wrapper
.
eq
(
EngineerSkill:
:
getEngineerCode
,
engineerCode
);
wrapper
.
in
(
EngineerSkill:
:
getCategoryId
,
categoryIds
);
wrapper
.
set
(
EngineerSkill:
:
getStatus
,
1
);
int
n
=
engineerSkillDao
.
update
(
null
,
wrapper
);
if
(
categoryIds
.
size
()
==
n
)
{
// 更新记录条数等于提交记录条数
return
null
;
}
// 可能存在engineerSkill表不存在的记录,需要补充录入
List
<
Integer
>
statuses
=
new
ArrayList
<
Integer
>(
Arrays
.
asList
(
1
,
0
));
List
<
String
>
engineerCodes
=
new
ArrayList
<>(
Arrays
.
asList
(
engineerCode
));
HashMap
<
String
,
List
<
String
>>
engineerSkills
=
this
.
queryEngineerSkills
(
engineerCodes
,
statuses
);
Set
<
String
>
sInput
=
new
HashSet
<>(
categoryIds
);
Set
<
String
>
sDB
=
new
HashSet
<>(
engineerSkills
.
get
(
engineerCode
));
sInput
.
removeAll
(
sDB
);
for
(
String
categoryId:
sInput
)
{
EngineerSkill
e
=
new
EngineerSkill
();
e
.
setEngineerCode
(
engineerCode
);
e
.
setCategoryId
(
categoryId
);
e
.
setStatus
(
1
);
engineerSkillDao
.
insert
(
e
);
}
return
null
;
}
@Transactional
@Override
public
Result
<?>
getEngineerBusinessList
(
long
page
,
long
size
)
{
// 技术员业务属性配置列表
...
...
@@ -221,7 +263,7 @@ public class EngineerServiceImpl implements EngineerService {
return
map
;
}
private
HashMap
<
String
,
List
<
String
>>
queryEngineerSkills
(
List
<
String
>
engineerCodes
)
{
private
HashMap
<
String
,
List
<
String
>>
queryEngineerSkills
(
List
<
String
>
engineerCodes
,
List
<
Integer
>
statuses
)
{
// 获取engineerCode对应的技能表, HashMap<engineerCode, List<skillId>>
HashMap
<
String
,
List
<
String
>>
map
=
new
HashMap
<>();
...
...
@@ -230,7 +272,7 @@ public class EngineerServiceImpl implements EngineerService {
}
LambdaQueryWrapper
<
EngineerSkill
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
in
(
EngineerSkill:
:
getEngineerCode
,
engineerCodes
);
lqw
.
eq
(
EngineerSkill:
:
getStatus
,
1
);
lqw
.
in
(
EngineerSkill:
:
getStatus
,
statuses
);
List
<
EngineerSkill
>
records
=
engineerSkillDao
.
selectList
(
lqw
);
Comparator
<
EngineerSkill
>
ec
=
Comparator
.
comparing
(
EngineerSkill:
:
getEngineerCode
,
String
.
CASE_INSENSITIVE_ORDER
);
...
...
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