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 d36e3961
authored
Jul 31, 2023
by
wangli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
1 parent
b723a628
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
24 deletions
project-order/src/main/java/com/dituhui/pea/order/service/BusinessLayerService.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/BusinessLayerServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/BusinessLayerService.java
View file @
d36e396
...
...
@@ -3,18 +3,18 @@ package com.dituhui.pea.order.service;
import
com.dituhui.pea.common.Result
;
public
interface
BusinessLayerService
{
Result
<?>
businessLayers
();
import
java.util.List
;
public
interface
BusinessLayerService
{
Result
<?>
businessLayerUniversal
();
Result
<?>
businessCustomLayers
();
Result
<?>
businessCustomLayers
(
String
levelType
,
String
levelValue
,
long
page
,
long
size
);
Result
<?>
businessCustomLayer
();
Result
<?>
businessCustomLayer
(
String
layerId
);
Result
<?>
businessCustomLayerAdd
();
Result
<?>
businessCustomLayerAdd
(
String
branchId
,
String
layerName
,
String
layerDesc
,
List
<
String
>
skillCodes
);
Result
<?>
businessCustomLayerUpdate
();
Result
<?>
businessCustomLayerUpdate
(
String
layerId
,
String
layerDesc
,
List
<
String
>
skillCodes
);
Result
<?>
businessCustomLayerRemove
();
Result
<?>
businessCustomLayerRemove
(
String
layerId
);
}
project-order/src/main/java/com/dituhui/pea/order/service/impl/BusinessLayerServiceImpl.java
View file @
d36e396
package
com
.
dituhui
.
pea
.
order
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.dituhui.pea.common.BusinessException
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.common.ResultEnum
;
import
com.dituhui.pea.order.dao.MapLayerCustomizeMPDao
;
import
com.dituhui.pea.order.dao.MapLayerCustomizeSkillMPDao
;
import
com.dituhui.pea.order.entity.MapLayerCustomize
;
import
com.dituhui.pea.order.entity.MapLayerCustomizeSkill
;
import
com.dituhui.pea.order.feign.ISaaSRemoteService
;
import
com.dituhui.pea.order.feign.dto.LayerDTO
;
import
com.dituhui.pea.order.service.BusinessLayerService
;
...
...
@@ -9,13 +15,28 @@ import com.dituhui.pea.order.utils.TypeUtils;
import
lombok.extern.slf4j.Slf4j
;
import
org.checkerframework.checker.units.qual.A
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
@Slf4j
@Service
public
class
BusinessLayerServiceImpl
implements
BusinessLayerService
{
@Autowired
private
MapLayerCustomizeMPDao
mapLayerCustomizeMPDao
;
@Autowired
private
MapLayerCustomizeSkillMPDao
mapLayerCustomizeSkillMPDao
;
@Autowired
private
ISaaSRemoteService
saasRemoteService
;
...
...
@@ -24,29 +45,24 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
String
ak
;
@Override
public
Result
<?>
businessLayers
()
{
return
null
;
}
@Override
public
Result
<?>
businessLayerUniversal
()
{
return
null
;
}
@Override
public
Result
<?>
businessCustomLayers
()
{
public
Result
<?>
businessCustomLayers
(
String
levelType
,
String
leveValue
,
long
page
,
long
size
)
{
return
null
;
}
@Override
public
Result
<?>
businessCustomLayer
()
{
public
Result
<?>
businessCustomLayer
(
String
layerId
)
{
return
null
;
}
@Transactional
@Override
public
Result
<?>
businessCustomLayerAdd
()
{
String
layerName
=
"上海大区苏州分部基础技能"
;
public
Result
<?>
businessCustomLayerAdd
(
String
branchId
,
String
layerName
,
String
layerDesc
,
List
<
String
>
skillCodes
)
{
// 同步创建saas图层,返回layerId
String
result
=
saasRemoteService
.
addLayer
(
ak
,
layerName
,
1
,
1
);
log
.
info
(
"addLayer params:{} result:{}"
,
layerName
,
result
);
...
...
@@ -59,15 +75,36 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
return
Result
.
success
(
null
);
}
@Transactional
@Override
public
Result
<?>
businessCustomLayerUpdate
()
{
return
null
;
public
Result
<?>
businessCustomLayerUpdate
(
String
layerId
,
String
layerDesc
,
List
<
String
>
skillCodes
)
throws
BusinessException
{
MapLayerCustomize
layer
=
mapLayerCustomizeMPDao
.
getByLayerId
(
layerId
);
if
(
layer
==
null
)
{
throw
new
BusinessException
(
"图层不存在"
);
}
// 更新描述信息
layer
.
setLayerDescribe
(
layerDesc
);
mapLayerCustomizeMPDao
.
updateById
(
layer
);
// 更新技能
this
.
updateLayerSkills
(
layerId
,
new
HashSet
<>(
skillCodes
));
return
Result
.
success
(
null
);
}
@Override
public
Result
<?>
businessCustomLayerRemove
()
{
String
layerId
=
""
;
public
Result
<?>
businessCustomLayerRemove
(
String
layerId
)
throws
BusinessException
{
MapLayerCustomize
layer
=
mapLayerCustomizeMPDao
.
getByLayerId
(
layerId
);
if
(
layer
==
null
)
{
throw
new
BusinessException
(
"图层不存在"
);
}
// 更新状态为删除状态
layer
.
setStatus
(
0
);
mapLayerCustomizeMPDao
.
updateById
(
layer
);
// 同步创建saas图层,返回layerId
String
result
=
saasRemoteService
.
deleteLayer
(
ak
,
layerId
);
log
.
info
(
"deleteLayer params:{} result:{}"
,
layerId
,
result
);
...
...
@@ -75,7 +112,44 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
if
(!
ResultEnum
.
SUCCESS
.
getCode
().
equals
(
saasResult
.
getCode
()))
{
return
Result
.
failure
(
saasResult
.
getMessage
());
}
return
null
;
return
Result
.
success
(
null
);
}
private
void
updateLayerSkills
(
String
layerId
,
Set
<
String
>
skillCodes
){
// 更新技能信息
// 更新状态为0
LambdaUpdateWrapper
<
MapLayerCustomizeSkill
>
wrapper
=
new
LambdaUpdateWrapper
<>();
wrapper
.
set
(
MapLayerCustomizeSkill:
:
getStatus
,
0
);
wrapper
.
eq
(
MapLayerCustomizeSkill:
:
getLayerId
,
layerId
);
mapLayerCustomizeSkillMPDao
.
update
(
null
,
wrapper
);
List
<
MapLayerCustomizeSkill
>
skills
=
mapLayerCustomizeSkillMPDao
.
selectByLayerId
(
layerId
);
Set
<
String
>
db
=
skills
.
stream
().
map
(
MapLayerCustomizeSkill:
:
getSkillCode
).
collect
(
Collectors
.
toSet
());
// 需要更新为有效的
Set
<
String
>
updates
=
new
HashSet
<>(
db
);
updates
.
retainAll
(
skillCodes
);
LambdaUpdateWrapper
<
MapLayerCustomizeSkill
>
updateWrapper
=
new
LambdaUpdateWrapper
<>();
updateWrapper
.
set
(
MapLayerCustomizeSkill:
:
getStatus
,
1
);
updateWrapper
.
eq
(
MapLayerCustomizeSkill:
:
getLayerId
,
layerId
);
updateWrapper
.
in
(
MapLayerCustomizeSkill:
:
getSkillCode
,
new
ArrayList
<>(
updates
));
mapLayerCustomizeSkillMPDao
.
update
(
null
,
updateWrapper
);
// 需要新增插入的
Set
<
String
>
adds
=
new
HashSet
<>(
skillCodes
);
adds
.
removeAll
(
db
);
for
(
String
skillCode:
adds
){
MapLayerCustomizeSkill
c
=
new
MapLayerCustomizeSkill
();
c
.
setLayerId
(
layerId
);
c
.
setSkillCode
(
skillCode
);
c
.
setStatus
(
1
);
c
.
setMemo
(
""
);
c
.
setCreateTime
(
LocalDateTime
.
now
());
mapLayerCustomizeSkillMPDao
.
insert
(
c
);
}
}
}
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