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 cfc5e307
authored
Aug 09, 2023
by
王力
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev_mp2jpa0803' into 'develop'
Dev mp2jpa0803 See merge request !324
2 parents
ce9530f3
a44aca0c
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
227 additions
and
152 deletions
project-order/src/main/java/com/dituhui/pea/order/controller/BusinessBlockController.java
project-order/src/main/java/com/dituhui/pea/order/controller/BusinessLayerController.java
project-order/src/main/java/com/dituhui/pea/order/dao/MapBlockInfoDao.java
project-order/src/main/java/com/dituhui/pea/order/dao/MapLayerCustomizeDao.java
project-order/src/main/java/com/dituhui/pea/order/dao/MapLayerCustomizeSkillDao.java
project-order/src/main/java/com/dituhui/pea/order/entity/MapLayerCustomizeEntity.java
project-order/src/main/java/com/dituhui/pea/order/entity/MapLayerCustomizeSkillEntity.java
project-order/src/main/java/com/dituhui/pea/order/service/BusinessBlockService.java
project-order/src/main/java/com/dituhui/pea/order/service/BusinessLayerService.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/BusinessBlockServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/BusinessLayerServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/controller/BusinessBlockController.java
View file @
cfc5e30
...
...
@@ -29,7 +29,7 @@ public class BusinessBlockController {
*/
@GetMapping
(
"/business/service/block/list"
)
public
Result
<?>
businessSeverBlocks
(
@RequestParam
String
levelType
,
@RequestParam
String
levelValue
,
@RequestParam
long
page
,
@RequestParam
long
size
,
@RequestParam
int
page
,
@RequestParam
int
size
,
@RequestParam
(
required
=
false
)
String
layerId
,
@RequestParam
(
required
=
false
)
String
teamId
)
{
Result
<?>
res
=
null
;
...
...
project-order/src/main/java/com/dituhui/pea/order/controller/BusinessLayerController.java
View file @
cfc5e30
...
...
@@ -43,7 +43,7 @@ public class BusinessLayerController {
* @return
*/
@GetMapping
(
"/business/layer/custom/list"
)
public
Result
<?>
businessCustomLayers
(
String
levelType
,
String
levelValue
,
long
page
,
long
size
)
{
public
Result
<?>
businessCustomLayers
(
String
levelType
,
String
levelValue
,
int
page
,
int
size
)
{
// 自定义图层列表
Result
<?>
res
=
null
;
try
{
...
...
project-order/src/main/java/com/dituhui/pea/order/dao/MapBlockInfoDao.java
View file @
cfc5e30
package
com
.
dituhui
.
pea
.
order
.
dao
;
import
java.util.List
;
import
com.dituhui.pea.order.entity.MapBlockInfoEntity
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.stereotype.Repository
;
import
com.dituhui.pea.order.entity.MapBlockInfoEntity
;
import
java.util.List
;
@Repository
public
interface
MapBlockInfoDao
extends
JpaRepository
<
MapBlockInfoEntity
,
Integer
>
{
public
interface
MapBlockInfoDao
extends
JpaRepository
<
MapBlockInfoEntity
,
Integer
>
,
JpaSpecificationExecutor
<
MapBlockInfoEntity
>
{
List
<
MapBlockInfoEntity
>
findByBlockIdInAndLayerIdIn
(
List
<
String
>
blockIds
,
List
<
String
>
layerIds
);
...
...
project-order/src/main/java/com/dituhui/pea/order/dao/MapLayerCustomizeDao.java
View file @
cfc5e30
...
...
@@ -2,10 +2,11 @@ package com.dituhui.pea.order.dao;
import
com.dituhui.pea.order.entity.MapLayerCustomizeEntity
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
java.util.List
;
public
interface
MapLayerCustomizeDao
extends
JpaRepository
<
MapLayerCustomizeEntity
,
Long
>
{
public
interface
MapLayerCustomizeDao
extends
JpaRepository
<
MapLayerCustomizeEntity
,
Long
>
,
JpaSpecificationExecutor
<
MapLayerCustomizeEntity
>
{
public
MapLayerCustomizeEntity
findByBranchIdAndLayerIdAndStatus
(
String
branchId
,
String
layerId
,
int
status
);
...
...
project-order/src/main/java/com/dituhui/pea/order/dao/MapLayerCustomizeSkillDao.java
0 → 100644
View file @
cfc5e30
package
com
.
dituhui
.
pea
.
order
.
dao
;
import
com.dituhui.pea.order.entity.MapLayerCustomizeSkillEntity
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
@Repository
public
interface
MapLayerCustomizeSkillDao
extends
JpaRepository
<
MapLayerCustomizeSkillEntity
,
Long
>{
List
<
MapLayerCustomizeSkillEntity
>
findByLayerId
(
String
layerId
);
@Modifying
@Query
(
"UPDATE MapLayerCustomizeSkill s SET s.status = :status WHERE s.layerId = :layerId"
)
void
updateStatusByLayerId
(
int
status
,
String
layerId
);
@Modifying
@Query
(
"UPDATE MapLayerCustomizeSkill s SET s.status = :status WHERE s.layerId = :layerId and s.skillCode IN :skillCodes"
)
void
updateStatusByLayerIdAndSkillCodeIn
(
int
status
,
String
layerId
,
List
<
String
>
skillCodes
);
}
project-order/src/main/java/com/dituhui/pea/order/entity/MapLayerCustomizeEntity.java
View file @
cfc5e30
...
...
@@ -3,6 +3,7 @@ package com.dituhui.pea.order.entity;
import
lombok.Data
;
import
javax.persistence.*
;
import
java.time.LocalDateTime
;
import
java.util.Date
;
@Entity
...
...
@@ -36,10 +37,10 @@ public class MapLayerCustomizeEntity {
private
String
memo
;
@Column
(
name
=
"create_time"
,
nullable
=
false
)
private
Dat
e
createTime
;
private
LocalDateTim
e
createTime
;
@Column
(
name
=
"update_time"
,
nullable
=
false
)
private
Dat
e
updateTime
;
private
LocalDateTim
e
updateTime
;
// Getters and Setters
// ...
...
...
project-order/src/main/java/com/dituhui/pea/order/entity/MapLayerCustomizeSkillEntity.java
0 → 100644
View file @
cfc5e30
package
com
.
dituhui
.
pea
.
order
.
entity
;
import
lombok.Data
;
import
javax.persistence.Column
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
java.time.LocalDateTime
;
@Data
public
class
MapLayerCustomizeSkillEntity
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
int
id
;
@Column
(
name
=
"layer_id"
,
length
=
32
)
private
String
layerId
;
@Column
(
name
=
"skill_code"
,
length
=
32
)
private
String
skillCode
;
@Column
(
name
=
"description"
,
length
=
50
)
private
String
description
;
@Column
(
name
=
"status"
,
length
=
1
)
private
Integer
status
;
@Column
(
name
=
"memo"
,
length
=
100
)
private
String
memo
;
@Column
(
name
=
"create_time"
,
nullable
=
false
,
columnDefinition
=
"datetime DEFAULT CURRENT_TIMESTAMP"
)
private
LocalDateTime
createTime
;
@Column
(
name
=
"update_time"
,
nullable
=
false
,
columnDefinition
=
"datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
)
private
LocalDateTime
updateTime
;
}
project-order/src/main/java/com/dituhui/pea/order/service/BusinessBlockService.java
View file @
cfc5e30
...
...
@@ -4,7 +4,7 @@ import com.dituhui.pea.common.Result;
public
interface
BusinessBlockService
{
Result
<?>
businessServerBlocks
(
String
levelType
,
String
levelValue
,
long
page
,
long
size
,
String
layerId
,
String
teamId
);
Result
<?>
businessServerBlocks
(
String
levelType
,
String
levelValue
,
int
page
,
int
size
,
String
layerId
,
String
teamId
);
Result
<?>
businessServiceBlockAdd
(
String
layerId
,
String
teamId
);
...
...
project-order/src/main/java/com/dituhui/pea/order/service/BusinessLayerService.java
View file @
cfc5e30
...
...
@@ -8,7 +8,7 @@ import java.util.List;
public
interface
BusinessLayerService
{
Result
<?>
businessLayerUniversal
();
Result
<?>
businessCustomLayers
(
String
levelType
,
String
levelValue
,
long
page
,
long
size
);
Result
<?>
businessCustomLayers
(
String
levelType
,
String
levelValue
,
int
page
,
int
size
);
Result
<?>
businessCustomLayer
(
String
layerId
);
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/BusinessBlockServiceImpl.java
View file @
cfc5e30
package
com
.
dituhui
.
pea
.
order
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.dituhui.pea.common.BusinessException
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.common.ResultEnum
;
...
...
@@ -14,13 +12,19 @@ import com.dituhui.pea.order.feign.ISaaSRemoteService;
import
com.dituhui.pea.order.service.BusinessBlockService
;
import
com.dituhui.pea.order.utils.RegionUtils
;
import
com.dituhui.pea.order.utils.TypeUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.persistence.EntityManager
;
import
javax.persistence.criteria.Predicate
;
import
java.util.*
;
import
java.util.stream.Collectors
;
...
...
@@ -28,49 +32,42 @@ import java.util.stream.Collectors;
@Service
public
class
BusinessBlockServiceImpl
implements
BusinessBlockService
{
@Value
(
"${SaaS.ak}"
)
String
ak
;
@Value
(
"${SaaS.url}"
)
String
url
;
@Autowired
private
OrgTeamMPDao
orgTeamMPDao
;
@Autowired
private
MapBlockInfoMPDao
mapBlockInfoMPDao
;
@Autowired
private
OrgGroupMPDao
orgGroupMPDao
;
@Autowired
private
MapLayerMPDao
mapLayerMPDao
;
@Autowired
private
MapLayerCustomizeMPDao
mapLayerCustomizeMPDao
;
private
OrgTeamDao
orgTeamDao
;
@Autowired
private
ISaaSRemoteService
saasRemoteService
;
@Autowired
private
MapBlockInfoDao
mapBlockInfoDao
;
@Autowired
private
OrgGroupDao
orgGroupDao
;
@Autowired
private
MapLayerDao
mapLayerDao
;
@Autowired
private
MapLayerCustomizeDao
mapLayerCustomizeDao
;
@Value
(
"${SaaS.ak}"
)
String
ak
;
@Value
(
"${SaaS.url}"
)
String
url
;
@Autowired
private
EntityManager
entityManager
;
@Override
public
Result
<?>
businessServerBlocks
(
String
levelType
,
String
levelValue
,
long
page
,
long
size
,
String
layerId
,
String
teamId
)
{
public
Result
<?>
businessServerBlocks
(
String
levelType
,
String
levelValue
,
int
page
,
int
size
,
String
layerId
,
String
teamId
)
{
BusinessServerBlocksRespDTO
resp
=
new
BusinessServerBlocksRespDTO
();
LambdaQueryWrapper
<
OrgTeam
>
lqwTeam
=
new
LambdaQueryWrapper
<>();
lqwTeam
.
eq
(
levelType
.
equals
(
"cluster"
),
OrgTeam:
:
getClusterId
,
levelValue
);
lqwTeam
.
eq
(
levelType
.
equals
(
"branch"
),
OrgTeam:
:
getBranchId
,
levelValue
);
lqwTeam
.
eq
(
levelType
.
equals
(
"group"
),
OrgTeam:
:
getGroupId
,
levelValue
);
lqwTeam
.
eq
(
StringUtils
.
isNotEmpty
(
teamId
),
OrgTeam:
:
getTeamId
,
teamId
);
List
<
OrgTeam
>
teams
=
orgTeamMPDao
.
selectList
(
lqwTeam
);
List
<
OrgTeamEntity
>
teams
=
new
ArrayList
<>();
if
(
levelType
.
equals
(
"cluster"
))
{
teams
=
orgTeamDao
.
findAllByClusterId
(
levelValue
);
}
else
if
(
levelType
.
equals
(
"branch"
))
{
teams
=
orgTeamDao
.
findAllByBranchId
(
levelValue
);
}
else
if
(
levelType
.
equals
(
"group"
))
{
teams
=
orgTeamDao
.
findAllByGroupId
(
levelValue
);
}
if
(
StringUtils
.
isNotEmpty
(
teamId
))
{
teams
=
teams
.
stream
().
filter
(
t
->
t
.
getTeamId
().
equals
(
teamId
)).
collect
(
Collectors
.
toList
());
}
if
(
ListUtils
.
isEmpty
(
teams
))
{
resp
.
setTotal
(
0
);
resp
.
setPages
(
1
);
...
...
@@ -82,32 +79,42 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
}
// 获得teamId与team的映射
Map
<
String
,
OrgTeam
>
teamMapping
=
new
HashMap
<>();
for
(
OrgTeam
t
:
teams
)
{
Map
<
String
,
OrgTeam
Entity
>
teamMapping
=
new
HashMap
<>();
for
(
OrgTeam
Entity
t
:
teams
)
{
teamMapping
.
put
(
t
.
getTeamId
(),
t
);
}
// teamId列表
List
<
String
>
teamIds
=
teams
.
stream
().
map
(
OrgTeam:
:
getTeamId
).
collect
(
Collectors
.
toList
());
List
<
String
>
teamIds
=
teams
.
stream
().
map
(
OrgTeam
Entity
:
:
getTeamId
).
collect
(
Collectors
.
toList
());
// 获取groupId集合
Set
<
String
>
groupIds
=
teams
.
stream
().
map
(
OrgTeam:
:
getGroupId
).
collect
(
Collectors
.
toSet
());
List
<
OrgGroup
>
groups
=
orgGroupMPDao
.
selectByGroupIds
(
new
ArrayList
<>(
groupIds
));
Map
<
String
,
String
>
groupMapping
=
groups
.
stream
().
collect
(
Collectors
.
toMap
(
OrgGroup:
:
getGroupId
,
OrgGroup:
:
getGroupName
));
Page
<
MapBlockInfo
>
pg
=
new
Page
<>(
page
,
size
);
LambdaQueryWrapper
<
MapBlockInfo
>
lqwBlock
=
new
LambdaQueryWrapper
<>();
lqwBlock
.
eq
(
MapBlockInfo:
:
getStatus
,
1
);
lqwBlock
.
in
(
MapBlockInfo:
:
getTeamId
,
teamIds
);
lqwBlock
.
eq
(
StringUtils
.
isNotEmpty
(
layerId
),
MapBlockInfo:
:
getLayerId
,
layerId
);
lqwBlock
.
orderByAsc
(
MapBlockInfo:
:
getTeamId
);
mapBlockInfoMPDao
.
selectPage
(
pg
,
lqwBlock
);
Set
<
String
>
groupIds
=
teams
.
stream
().
map
(
OrgTeamEntity:
:
getGroupId
).
collect
(
Collectors
.
toSet
());
List
<
OrgGroupEntity
>
groups
=
orgGroupDao
.
findByGroupIdIn
(
new
ArrayList
<>(
groupIds
));
Map
<
String
,
String
>
groupMapping
=
groups
.
stream
().
collect
(
Collectors
.
toMap
(
OrgGroupEntity:
:
getGroupId
,
OrgGroupEntity:
:
getGroupName
));
// 获取blocks
Specification
<
MapBlockInfoEntity
>
specification
=
(
root
,
query
,
criteriaBuilder
)
->
{
Predicate
statusPredicate
=
criteriaBuilder
.
equal
(
root
.
get
(
"status"
),
1
);
Predicate
teamIdPredicate
=
root
.
get
(
"teamId"
).
in
(
teamIds
);
Predicate
layerIdPredicate
;
if
(
StringUtils
.
isNotEmpty
(
layerId
))
{
layerIdPredicate
=
criteriaBuilder
.
equal
(
root
.
get
(
"layerId"
),
layerId
);
}
else
{
layerIdPredicate
=
criteriaBuilder
.
conjunction
();
}
return
criteriaBuilder
.
and
(
statusPredicate
,
teamIdPredicate
,
layerIdPredicate
);
};
Sort
sort
=
Sort
.
by
(
Sort
.
Order
.
asc
(
"teamId"
));
PageRequest
pageRequest
=
PageRequest
.
of
(
page
-
1
,
size
,
sort
);
Page
<
MapBlockInfoEntity
>
pg
=
mapBlockInfoDao
.
findAll
(
specification
,
pageRequest
);
List
<
BusinessServerBlocksRespDTO
.
Block
>
blocks
=
new
ArrayList
<>();
for
(
MapBlockInfo
b
:
pg
.
getRecords
())
{
for
(
MapBlockInfo
Entity
b
:
pg
.
getContent
())
{
BusinessServerBlocksRespDTO
.
Block
block
=
new
BusinessServerBlocksRespDTO
.
Block
();
OrgTeam
team
=
teamMapping
.
get
(
b
.
getTeamId
());
OrgTeam
Entity
team
=
teamMapping
.
get
(
b
.
getTeamId
());
String
groupId
=
team
.
getGroupId
();
String
groupName
=
groupMapping
.
get
(
groupId
);
...
...
@@ -124,9 +131,9 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
blocks
.
add
(
block
);
}
resp
.
setTotal
(
pg
.
getTotal
());
resp
.
setPages
(
pg
.
getPages
());
resp
.
setPageCurrent
(
pg
.
get
Current
()
);
resp
.
setTotal
(
pg
.
getTotal
Elements
());
resp
.
setPages
(
pg
.
get
Total
Pages
());
resp
.
setPageCurrent
(
pg
.
get
Number
()
+
1
);
resp
.
setPageSize
(
pg
.
getSize
());
resp
.
setTip
(
""
);
resp
.
setContent
(
blocks
);
...
...
@@ -134,15 +141,16 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
return
Result
.
success
(
resp
);
}
@Transactional
@Override
public
Result
<?>
businessServiceBlockAdd
(
String
layerId
,
String
teamId
)
throws
BusinessException
{
String
layerName
;
// 获取layerName
MapLayer
layer1
=
mapLayerMP
Dao
.
getByLayerId
(
layerId
);
if
(
layer1
==
null
)
{
MapLayerCustomize
layer2
=
mapLayerCustomizeMP
Dao
.
getByLayerId
(
layerId
);
MapLayer
Entity
layer1
=
mapLayer
Dao
.
getByLayerId
(
layerId
);
if
(
layer1
==
null
)
{
MapLayerCustomize
Entity
layer2
=
mapLayerCustomize
Dao
.
getByLayerId
(
layerId
);
if
(
layer2
==
null
)
{
throw
new
BusinessException
(
"图层标签不存在"
);
}
else
{
...
...
@@ -152,13 +160,13 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
layerName
=
layer1
.
getLayer
();
}
OrgTeam
team
=
orgTeamMP
Dao
.
getByTeamId
(
teamId
);
OrgTeam
Entity
team
=
orgTeam
Dao
.
getByTeamId
(
teamId
);
if
(
team
==
null
)
{
throw
new
BusinessException
(
"关联小队不存在"
);
}
// 重复检查layerId+teamId
MapBlockInfo
existBlock
=
mapBlockInfoMPDao
.
get
ByTeamIdAndLayerId
(
teamId
,
layerId
);
MapBlockInfo
Entity
existBlock
=
mapBlockInfoDao
.
find
ByTeamIdAndLayerId
(
teamId
,
layerId
);
if
(
null
!=
existBlock
)
{
return
Result
.
failure
(
"区块已存在"
);
}
...
...
@@ -175,7 +183,7 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
String
result
=
saasRemoteService
.
addArea
(
ak
,
team
.
getTeamName
(),
saasLayerId
,
region
,
"gcj02mc"
);
log
.
info
(
"params:{} {} {} {} result:{}"
,
team
.
getTeamName
(),
saasLayerId
,
region
,
result
);
Result
<
String
>
saasResult
=
TypeUtils
.
<
String
>
convertResult
(
result
);
Result
<
String
>
saasResult
=
TypeUtils
.
convertResult
(
result
);
if
(!
ResultEnum
.
SUCCESS
.
getCode
().
equals
(
saasResult
.
getCode
()))
{
return
Result
.
failure
(
"区块已存在或者裁剪为空"
);
}
...
...
@@ -183,7 +191,7 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
String
blockName
=
String
.
format
(
"%s_%s"
,
layerName
,
team
.
getTeamName
());
//区块名称
MapBlockInfo
block
=
new
MapBlockInfo
();
MapBlockInfo
Entity
block
=
new
MapBlockInfoEntity
();
block
.
setBlockId
(
blockId
);
block
.
setBlockName
(
blockName
);
block
.
setBranchId
(
team
.
getBranchId
());
...
...
@@ -191,8 +199,8 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
block
.
setTeamId
(
teamId
);
block
.
setLayerId
(
layerId
);
block
.
setLayer
(
layerName
);
block
.
setStatus
(
1
);
mapBlockInfoMPDao
.
inser
t
(
block
);
block
.
setStatus
(
true
);
entityManager
.
persis
t
(
block
);
return
Result
.
success
(
null
);
}
...
...
@@ -221,19 +229,20 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
return
saasLayerId
;
}
@Transactional
@Override
public
Result
<?>
businessServiceBlockRemove
(
String
blockId
)
throws
BusinessException
{
MapBlockInfo
block
=
mapBlockInfoMPDao
.
get
ByBlockId
(
blockId
);
MapBlockInfo
Entity
block
=
mapBlockInfoDao
.
find
ByBlockId
(
blockId
);
if
(
block
==
null
)
{
throw
new
BusinessException
(
"区块不存在"
);
}
block
.
setStatus
(
0
);
mapBlockInfoMPDao
.
updateById
(
block
);
block
.
setStatus
(
false
);
entityManager
.
merge
(
block
);
// 同步删除saas区块
String
result
=
saasRemoteService
.
deleteArea
(
ak
,
blockId
);
log
.
info
(
"params:{} result:{}"
,
blockId
,
result
);
Result
<
Boolean
>
saasResult
=
TypeUtils
.
<
Boolean
>
convertResult
(
result
);
Result
<
Boolean
>
saasResult
=
TypeUtils
.
convertResult
(
result
);
if
(!
ResultEnum
.
SUCCESS
.
getCode
().
equals
(
saasResult
.
getCode
()))
{
return
Result
.
failure
(
"删除失败,请联系管理员"
);
}
...
...
@@ -243,7 +252,7 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
@Override
public
Result
<?>
saasBaseDataLayerUrl
(
String
blockId
)
throws
BusinessException
{
MapBlockInfo
block
=
mapBlockInfoMPDao
.
get
ByBlockId
(
blockId
);
MapBlockInfo
Entity
block
=
mapBlockInfoDao
.
find
ByBlockId
(
blockId
);
if
(
block
==
null
)
{
throw
new
BusinessException
(
"区块不存在"
);
}
...
...
@@ -266,8 +275,8 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
List
<
Map
<
String
,
String
>>
items
=
new
ArrayList
<>();
// 获取通用图层
List
<
MapLayer
>
layers
=
mapLayerMPDao
.
selectList
(
null
);
for
(
MapLayer
r:
layers
)
{
List
<
MapLayer
Entity
>
layers
=
mapLayerDao
.
findAll
(
);
for
(
MapLayerEntity
r
:
layers
)
{
Map
<
String
,
String
>
m
=
new
HashMap
<>();
m
.
put
(
"layerId"
,
r
.
getLayerId
());
m
.
put
(
"layerName"
,
r
.
getLayer
());
...
...
@@ -275,20 +284,21 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
}
// 获取自定义图层(只有branch才能创建自定义图层)
LambdaQueryWrapper
<
OrgGroup
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
eq
(
levelType
.
equals
(
"cluster"
),
OrgGroup:
:
getClusterId
,
levelValue
);
lqw
.
eq
(
levelType
.
equals
(
"branch"
),
OrgGroup:
:
getBranchId
,
levelValue
);
lqw
.
eq
(
levelType
.
equals
(
"group"
),
OrgGroup:
:
getGroupId
,
levelValue
);
Set
<
String
>
branchIds
=
orgGroupMPDao
.
selectList
(
lqw
).
stream
().
map
(
OrgGroup:
:
getBranchId
).
collect
(
Collectors
.
toSet
());
List
<
OrgGroupEntity
>
groups
=
new
ArrayList
<>();
if
(
levelType
.
equals
(
"cluster"
))
{
groups
=
orgGroupDao
.
findAllByClusterId
(
levelValue
);
}
else
if
(
levelType
.
equals
(
"branch"
))
{
groups
=
orgGroupDao
.
findAllByBranchId
(
levelValue
);
}
else
if
(
levelType
.
equals
(
"group"
))
{
groups
=
orgGroupDao
.
findAllByGroupId
(
levelValue
);
}
Set
<
String
>
branchIds
=
groups
.
stream
().
map
(
OrgGroupEntity:
:
getBranchId
).
collect
(
Collectors
.
toSet
());
if
(
branchIds
.
isEmpty
())
{
return
Result
.
success
(
items
);
}
LambdaQueryWrapper
<
MapLayerCustomize
>
lqwLayer
=
new
LambdaQueryWrapper
<>();
lqwLayer
.
eq
(
MapLayerCustomize:
:
getStatus
,
1
);
lqwLayer
.
in
(
MapLayerCustomize:
:
getBranchId
,
new
ArrayList
<>(
branchIds
));
List
<
MapLayerCustomize
>
layerCustomizes
=
mapLayerCustomizeMPDao
.
selectList
(
lqwLayer
);
for
(
MapLayerCustomize
r:
layerCustomizes
)
{
List
<
MapLayerCustomizeEntity
>
layerCustomizes
=
mapLayerCustomizeDao
.
findByBranchIdInAndStatus
(
new
ArrayList
<>(
branchIds
),
1
);
for
(
MapLayerCustomizeEntity
r
:
layerCustomizes
)
{
Map
<
String
,
String
>
m
=
new
HashMap
<>();
m
.
put
(
"layerId"
,
r
.
getLayerId
());
m
.
put
(
"layerName"
,
r
.
getLayer
());
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/BusinessLayerServiceImpl.java
View file @
cfc5e30
package
com
.
dituhui
.
pea
.
order
.
service
.
impl
;
import
com.alibaba.nacos.common.utils.CollectionUtils
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.dituhui.pea.common.BusinessException
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.common.ResultEnum
;
...
...
@@ -13,17 +10,21 @@ import com.dituhui.pea.order.dto.BusinessCustomLayerRespDTO;
import
com.dituhui.pea.order.dto.BusinessCustomLayersRespDTO
;
import
com.dituhui.pea.order.entity.*
;
import
com.dituhui.pea.order.feign.ISaaSRemoteService
;
import
com.dituhui.pea.order.feign.dto.LayerDTO
;
import
com.dituhui.pea.order.service.BusinessLayerService
;
import
com.dituhui.pea.order.utils.TypeUtils
;
import
com.google.gson.internal.LinkedTreeMap
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.persistence.EntityManager
;
import
javax.persistence.criteria.Predicate
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.stream.Collectors
;
...
...
@@ -35,19 +36,21 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
@Value
(
"${SaaS.ak}"
)
String
ak
;
@Autowired
private
MapLayerCustomize
MPDao
mapLayerCustomizeMP
Dao
;
private
MapLayerCustomize
Dao
mapLayerCustomize
Dao
;
@Autowired
private
MapLayerCustomizeSkill
MPDao
mapLayerCustomizeSkillMP
Dao
;
private
MapLayerCustomizeSkill
Dao
mapLayerCustomizeSkill
Dao
;
@Autowired
private
OrgGroup
MPDao
orgGroupMP
Dao
;
private
OrgGroup
Dao
orgGroup
Dao
;
@Autowired
private
OrgBranch
MPDao
orgBranchMP
Dao
;
private
OrgBranch
Dao
orgBranch
Dao
;
@Autowired
private
SkillInfo
MPDao
skillInfoMP
Dao
;
private
SkillInfo
Dao
skillInfo
Dao
;
@Autowired
private
ISaaSRemoteService
saasRemoteService
;
@Autowired
private
MapBlockInfoDao
mapBlockInfoDao
;
@Autowired
private
EntityManager
entityManager
;
@Override
public
Result
<?>
businessLayerUniversal
()
{
...
...
@@ -55,39 +58,47 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
}
@Override
public
Result
<?>
businessCustomLayers
(
String
levelType
,
String
levelValue
,
long
page
,
long
size
)
throws
BusinessException
{
public
Result
<?>
businessCustomLayers
(
String
levelType
,
String
levelValue
,
int
page
,
int
size
)
throws
BusinessException
{
// 获取branchIds
LambdaQueryWrapper
<
OrgGroup
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
eq
(
levelType
.
equals
(
"cluster"
),
OrgGroup:
:
getClusterId
,
levelValue
);
lqw
.
eq
(
levelType
.
equals
(
"branch"
),
OrgGroup:
:
getBranchId
,
levelValue
);
lqw
.
eq
(
levelType
.
equals
(
"group"
),
OrgGroup:
:
getGroupId
,
levelValue
);
List
<
OrgGroup
>
groups
=
orgGroupMPDao
.
selectList
(
lqw
);
List
<
OrgGroupEntity
>
groups
=
new
ArrayList
<>();
if
(
levelType
.
equals
(
"cluster"
))
{
groups
=
orgGroupDao
.
findAllByClusterId
(
levelValue
);
}
else
if
(
levelType
.
equals
(
"branch"
))
{
groups
=
orgGroupDao
.
findAllByBranchId
(
levelValue
);
}
else
if
(
levelType
.
equals
(
"group"
))
{
groups
=
orgGroupDao
.
findAllByGroupId
(
levelValue
);
}
if
(
ListUtils
.
isEmpty
(
groups
))
{
throw
new
BusinessException
(
"大区/分部/小组组织结构配置可能错误或缺失,请联系管理员/研发"
);
}
List
<
String
>
branchIds
=
new
ArrayList
<>(
groups
.
stream
().
map
(
OrgGroup:
:
getBranchId
).
collect
(
Collectors
.
toSet
()));
List
<
String
>
branchIds
=
new
ArrayList
<>(
groups
.
stream
().
map
(
OrgGroup
Entity
:
:
getBranchId
).
collect
(
Collectors
.
toSet
()));
// 获取skillCode与skillName映射信息
List
<
SkillInfo
>
skills
=
skillInfoMPDao
.
selectList
(
null
);
Map
<
String
,
String
>
skillMapping
=
skills
.
stream
().
collect
(
Collectors
.
toMap
(
SkillInfo:
:
getSkillCode
,
SkillInfo:
:
getSkillCode
));
Page
<
MapLayerCustomize
>
pg
=
new
Page
(
page
,
size
);
LambdaQueryWrapper
<
MapLayerCustomize
>
mapWrapper
=
new
LambdaQueryWrapper
<>();
mapWrapper
.
eq
(
MapLayerCustomize:
:
getStatus
,
1
);
mapWrapper
.
in
(
MapLayerCustomize:
:
getBranchId
,
branchIds
);
mapWrapper
.
orderByAsc
(
MapLayerCustomize:
:
getLayerId
);
mapLayerCustomizeMPDao
.
selectPage
(
pg
,
mapWrapper
);
List
<
SkillInfoEntity
>
skills
=
skillInfoDao
.
findAll
();
Map
<
String
,
String
>
skillMapping
=
skills
.
stream
().
collect
(
Collectors
.
toMap
(
SkillInfoEntity:
:
getSkillCode
,
SkillInfoEntity:
:
getSkillCode
));
//获取分页列表
Specification
<
MapLayerCustomizeEntity
>
specification
=
(
root
,
query
,
criteriaBuilder
)
->
{
Predicate
statusPredicate
=
criteriaBuilder
.
equal
(
root
.
get
(
"status"
),
1
);
Predicate
branchIdPredicate
=
root
.
get
(
"branchId"
).
in
(
branchIds
);
return
criteriaBuilder
.
and
(
statusPredicate
,
branchIdPredicate
);
};
Sort
sort
=
Sort
.
by
(
Sort
.
Order
.
asc
(
"layerId"
));
PageRequest
pageRequest
=
PageRequest
.
of
(
page
-
1
,
size
,
sort
);
Page
<
MapLayerCustomizeEntity
>
pg
=
mapLayerCustomizeDao
.
findAll
(
specification
,
pageRequest
);
// pack
List
<
BusinessCustomLayersRespDTO
.
LayerItem
>
items
=
new
ArrayList
<>();
for
(
MapLayerCustomize
layer
:
pg
.
getRecords
())
{
for
(
MapLayerCustomize
Entity
layer
:
pg
.
getContent
())
{
BusinessCustomLayersRespDTO
.
LayerItem
item
=
new
BusinessCustomLayersRespDTO
.
LayerItem
();
item
.
setLayerId
(
layer
.
getLayerId
());
item
.
setLayerName
(
layer
.
getLayer
());
item
.
setLayerDesc
(
layer
.
getLayerDescribe
());
OrgBranch
branch
=
orgBranchMP
Dao
.
getByBranchId
(
layer
.
getBranchId
());
OrgBranch
Entity
branch
=
orgBranch
Dao
.
getByBranchId
(
layer
.
getBranchId
());
if
(
branch
!=
null
)
{
item
.
setBranchName
(
branch
.
getBranchName
());
}
...
...
@@ -103,9 +114,9 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
}
BusinessCustomLayersRespDTO
res
=
new
BusinessCustomLayersRespDTO
();
res
.
setTotal
(
pg
.
getTotal
());
res
.
setPages
(
pg
.
getPages
());
res
.
setPageCurrent
(
pg
.
get
Current
()
);
res
.
setTotal
(
pg
.
getTotal
Elements
());
res
.
setPages
(
pg
.
get
Total
Pages
());
res
.
setPageCurrent
(
pg
.
get
Number
()
+
1
);
res
.
setPageSize
(
pg
.
getSize
());
res
.
setContent
(
items
);
...
...
@@ -115,19 +126,19 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
@Override
public
Result
<?>
businessCustomLayer
(
String
layerId
)
{
MapLayerCustomize
layer
=
mapLayerCustomizeMP
Dao
.
getByLayerId
(
layerId
);
MapLayerCustomize
Entity
layer
=
mapLayerCustomize
Dao
.
getByLayerId
(
layerId
);
if
(
layer
==
null
)
{
throw
new
BusinessException
(
"图层不存在"
);
}
// 获取技能code列表
List
<
MapLayerCustomizeSkill
>
skills
=
mapLayerCustomizeSkillMPDao
.
select
ByLayerId
(
layerId
);
List
<
MapLayerCustomizeSkill
Entity
>
skills
=
mapLayerCustomizeSkillDao
.
find
ByLayerId
(
layerId
);
List
<
String
>
skillCodes
=
skills
.
stream
().
filter
(
s
->
s
.
getStatus
()
==
1
).
map
(
MapLayerCustomizeSkill:
:
getSkillCode
).
collect
(
Collectors
.
toList
());
MapLayerCustomizeSkill
Entity
:
:
getSkillCode
).
collect
(
Collectors
.
toList
());
// 获取branchName
String
branchName
=
""
;
OrgBranch
branch
=
orgBranchMP
Dao
.
getByBranchId
(
layer
.
getBranchId
());
OrgBranch
Entity
branch
=
orgBranch
Dao
.
getByBranchId
(
layer
.
getBranchId
());
if
(
branch
!=
null
)
{
branchName
=
branch
.
getBranchName
();
}
...
...
@@ -147,7 +158,7 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
@Override
public
Result
<?>
businessCustomLayerAdd
(
String
branchId
,
String
layerName
,
String
layerDesc
,
List
<
String
>
skillCodes
)
{
if
(
orgBranch
MP
Dao
.
getByBranchId
(
branchId
)
==
null
)
{
if
(
orgBranchDao
.
getByBranchId
(
branchId
)
==
null
)
{
throw
new
BusinessException
(
"分部参数错误,请联系管理员/研发"
);
}
...
...
@@ -163,7 +174,7 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
String
layerId
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
// 入库保存
MapLayerCustomize
m
=
new
MapLayerCustomize
();
MapLayerCustomize
Entity
m
=
new
MapLayerCustomizeEntity
();
m
.
setLayerId
(
layerId
);
m
.
setSaasLayerId
(
saasLayerId
);
m
.
setLayer
(
layerName
);
...
...
@@ -171,7 +182,7 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
m
.
setBranchId
(
branchId
);
m
.
setStatus
(
1
);
m
.
setCreateTime
(
LocalDateTime
.
now
());
mapLayerCustomizeMPDao
.
inser
t
(
m
);
entityManager
.
persis
t
(
m
);
// 更新技能
this
.
updateLayerSkills
(
layerId
,
new
HashSet
<>(
skillCodes
));
...
...
@@ -183,14 +194,13 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
@Override
public
Result
<?>
businessCustomLayerUpdate
(
String
layerId
,
String
layerDesc
,
List
<
String
>
skillCodes
)
throws
BusinessException
{
MapLayerCustomize
layer
=
mapLayerCustomizeMP
Dao
.
getByLayerId
(
layerId
);
MapLayerCustomize
Entity
layer
=
mapLayerCustomize
Dao
.
getByLayerId
(
layerId
);
if
(
layer
==
null
)
{
throw
new
BusinessException
(
"图层不存在"
);
}
// 更新描述信息
layer
.
setLayerDescribe
(
layerDesc
);
mapLayerCustomizeMPDao
.
updateById
(
layer
);
entityManager
.
merge
(
layer
);
// 更新技能
this
.
updateLayerSkills
(
layerId
,
new
HashSet
<>(
skillCodes
));
...
...
@@ -201,7 +211,7 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
@Override
public
Result
<?>
businessCustomLayerRemove
(
String
layerId
)
throws
BusinessException
{
MapLayerCustomize
layer
=
mapLayerCustomizeMP
Dao
.
getByLayerId
(
layerId
);
MapLayerCustomize
Entity
layer
=
mapLayerCustomize
Dao
.
getByLayerId
(
layerId
);
if
(
layer
==
null
)
{
throw
new
BusinessException
(
"图层不存在"
);
}
...
...
@@ -222,7 +232,7 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
// 更新状态为删除状态
layer
.
setStatus
(
0
);
mapLayerCustomizeMPDao
.
updateById
(
layer
);
entityManager
.
merge
(
layer
);
return
Result
.
success
(
null
);
}
...
...
@@ -231,48 +241,41 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
// 更新技能信息
// 更新状态为0
LambdaUpdateWrapper
<
MapLayerCustomizeSkill
>
wrapper
=
new
LambdaUpdateWrapper
<>();
wrapper
.
set
(
MapLayerCustomizeSkill:
:
getStatus
,
0
);
wrapper
.
eq
(
MapLayerCustomizeSkill:
:
getLayerId
,
layerId
);
mapLayerCustomizeSkillMPDao
.
update
(
null
,
wrapper
);
mapLayerCustomizeSkillDao
.
updateStatusByLayerId
(
0
,
layerId
);
List
<
MapLayerCustomizeSkill
>
skills
=
mapLayerCustomizeSkillMPDao
.
select
ByLayerId
(
layerId
);
Set
<
String
>
db
=
skills
.
stream
().
map
(
MapLayerCustomizeSkill:
:
getSkillCode
).
collect
(
Collectors
.
toSet
());
List
<
MapLayerCustomizeSkill
Entity
>
skills
=
mapLayerCustomizeSkillDao
.
find
ByLayerId
(
layerId
);
Set
<
String
>
db
=
skills
.
stream
().
map
(
MapLayerCustomizeSkill
Entity
:
:
getSkillCode
).
collect
(
Collectors
.
toSet
());
// 需要更新为有效的
Set
<
String
>
updates
=
new
HashSet
<>(
db
);
updates
.
retainAll
(
skillCodes
);
if
(!
updates
.
isEmpty
())
{
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
);
if
(!
updates
.
isEmpty
())
{
mapLayerCustomizeSkillDao
.
updateStatusByLayerIdAndSkillCodeIn
(
1
,
layerId
,
new
ArrayList
<>(
updates
));
}
// 需要新增插入的
Set
<
String
>
adds
=
new
HashSet
<>(
skillCodes
);
adds
.
removeAll
(
db
);
for
(
String
skillCode
:
adds
)
{
MapLayerCustomizeSkill
c
=
new
MapLayerCustomizeSkill
();
MapLayerCustomizeSkill
Entity
c
=
new
MapLayerCustomizeSkillEntity
();
c
.
setLayerId
(
layerId
);
c
.
setSkillCode
(
skillCode
);
c
.
setStatus
(
1
);
c
.
setMemo
(
""
);
c
.
setCreateTime
(
LocalDateTime
.
now
());
mapLayerCustomizeSkillMPDao
.
inser
t
(
c
);
entityManager
.
persis
t
(
c
);
}
}
private
List
<
String
>
queryLayerSkill
(
String
layerId
)
{
List
<
String
>
items
=
new
ArrayList
<>();
List
<
SkillInfo
>
skills
=
skillInfoMPDao
.
selectList
(
null
);
Map
<
String
,
String
>
skillMap
=
skills
.
stream
().
collect
(
Collectors
.
toMap
(
SkillInfo:
:
getSkillCode
,
SkillInfo:
:
getSkill
));
List
<
SkillInfoEntity
>
skills
=
skillInfoDao
.
findAll
();
Map
<
String
,
String
>
skillMap
=
skills
.
stream
().
collect
(
Collectors
.
toMap
(
SkillInfoEntity:
:
getSkillCode
,
SkillInfoEntity:
:
getSkill
));
List
<
MapLayerCustomizeSkill
>
laySkills
=
mapLayerCustomizeSkillMPDao
.
select
ByLayerId
(
layerId
);
for
(
MapLayerCustomizeSkill
s
:
laySkills
)
{
List
<
MapLayerCustomizeSkill
Entity
>
laySkills
=
mapLayerCustomizeSkillDao
.
find
ByLayerId
(
layerId
);
for
(
MapLayerCustomizeSkill
Entity
s
:
laySkills
)
{
if
(
s
.
getStatus
()
==
0
)
{
continue
;
}
...
...
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