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 7c4946f8
authored
Aug 04, 2023
by
wangli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mp2jpa
1 parent
718b1918
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
46 deletions
project-order/src/main/java/com/dituhui/pea/order/service/impl/BusinessBlockServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/BusinessBlockServiceImpl.java
View file @
7c4946f
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,15 +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
;
...
...
@@ -30,50 +32,39 @@ import java.util.stream.Collectors;
@Service
public
class
BusinessBlockServiceImpl
implements
BusinessBlockService
{
@Value
(
"${SaaS.ak}"
)
String
ak
;
@Value
(
"${SaaS.url}"
)
String
url
;
@Autowired
private
OrgTeamDao
orgTeamDao
;
@Autowired
private
MapBlockInfoMPDao
mapBlockInfoMPDao
;
@Autowired
private
ISaaSRemoteService
saasRemoteService
;
@Autowired
private
MapBlockInfoDao
mapBlockInfoDao
;
@Autowired
private
OrgGroupDao
orgGroupDao
;
@Autowired
private
MapLayerDao
mapLayerDao
;
@Autowired
private
MapLayerCustomizeDao
mapLayerCustomizeDao
;
@Autowired
private
EntityManager
entityManager
;
@Value
(
"${SaaS.ak}"
)
String
ak
;
@Value
(
"${SaaS.url}"
)
String
url
;
@Override
public
Result
<?>
businessServerBlocks
(
String
levelType
,
String
levelValue
,
int
page
,
int
size
,
String
layerId
,
String
teamId
)
{
BusinessServerBlocksRespDTO
resp
=
new
BusinessServerBlocksRespDTO
();
List
<
OrgTeamEntity
>
teams
=
new
ArrayList
<>();
if
(
levelType
.
equals
(
"cluster"
))
{
if
(
levelType
.
equals
(
"cluster"
))
{
teams
=
orgTeamDao
.
findAllByClusterId
(
levelValue
);
}
else
if
(
levelType
.
equals
(
"branch"
))
{
}
else
if
(
levelType
.
equals
(
"branch"
))
{
teams
=
orgTeamDao
.
findAllByBranchId
(
levelValue
);
}
else
if
(
levelType
.
equals
(
"group"
))
{
}
else
if
(
levelType
.
equals
(
"group"
))
{
teams
=
orgTeamDao
.
findAllByGroupId
(
levelValue
);
}
if
(
StringUtils
.
isNotEmpty
(
teamId
))
{
if
(
StringUtils
.
isNotEmpty
(
teamId
))
{
teams
=
teams
.
stream
().
filter
(
t
->
t
.
getTeamId
().
equals
(
teamId
)).
collect
(
Collectors
.
toList
());
}
...
...
@@ -99,18 +90,28 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
// 获取groupId集合
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
));
Map
<
String
,
String
>
groupMapping
=
groups
.
stream
().
collect
(
Collectors
.
toMap
(
OrgGroupEntity:
:
getGroupId
,
OrgGroupEntity:
:
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
);
// 获取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
();
OrgTeamEntity
team
=
teamMapping
.
get
(
b
.
getTeamId
());
...
...
@@ -130,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
);
...
...
@@ -148,7 +149,7 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
// 获取layerName
MapLayerEntity
layer1
=
mapLayerDao
.
getByLayerId
(
layerId
);
if
(
layer1
==
null
)
{
if
(
layer1
==
null
)
{
MapLayerCustomizeEntity
layer2
=
mapLayerCustomizeDao
.
getByLayerId
(
layerId
);
if
(
layer2
==
null
)
{
throw
new
BusinessException
(
"图层标签不存在"
);
...
...
@@ -163,7 +164,7 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
if
(
team
==
null
)
{
throw
new
BusinessException
(
"关联小队不存在"
);
}
// 重复检查layerId+teamId
MapBlockInfoEntity
existBlock
=
mapBlockInfoDao
.
findByTeamIdAndLayerId
(
teamId
,
layerId
);
if
(
null
!=
existBlock
)
{
...
...
@@ -179,17 +180,17 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
if
(
StringUtils
.
isEmpty
(
saasLayerId
))
{
return
Result
.
failure
(
"图层未配置"
);
}
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
(
"区块已存在或者裁剪为空"
);
}
String
blockId
=
saasResult
.
getResult
();
String
blockName
=
String
.
format
(
"%s_%s"
,
layerName
,
team
.
getTeamName
());
//区块名称
MapBlockInfoEntity
block
=
new
MapBlockInfoEntity
();
block
.
setBlockId
(
blockId
);
block
.
setBlockName
(
blockName
);
...
...
@@ -206,7 +207,7 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
/**
* 获取saas图层id
*
*
* @param branchId
* @param layerId
* @return
...
...
@@ -241,11 +242,11 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
// 同步删除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
(
"删除失败,请联系管理员"
);
}
return
Result
.
success
(
null
);
}
...
...
@@ -275,7 +276,7 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
// 获取通用图层
List
<
MapLayerEntity
>
layers
=
mapLayerDao
.
findAll
();
for
(
MapLayerEntity
r:
layers
)
{
for
(
MapLayerEntity
r
:
layers
)
{
Map
<
String
,
String
>
m
=
new
HashMap
<>();
m
.
put
(
"layerId"
,
r
.
getLayerId
());
m
.
put
(
"layerName"
,
r
.
getLayer
());
...
...
@@ -284,9 +285,9 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
// 获取自定义图层(只有branch才能创建自定义图层)
List
<
OrgGroupEntity
>
groups
=
new
ArrayList
<>();
if
(
levelType
.
equals
(
"cluster"
))
{
if
(
levelType
.
equals
(
"cluster"
))
{
groups
=
orgGroupDao
.
findAllByClusterId
(
levelValue
);
}
else
if
(
levelType
.
equals
(
"branch"
))
{
}
else
if
(
levelType
.
equals
(
"branch"
))
{
groups
=
orgGroupDao
.
findAllByBranchId
(
levelValue
);
}
else
if
(
levelType
.
equals
(
"group"
))
{
groups
=
orgGroupDao
.
findAllByGroupId
(
levelValue
);
...
...
@@ -297,7 +298,7 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
}
List
<
MapLayerCustomizeEntity
>
layerCustomizes
=
mapLayerCustomizeDao
.
findByBranchIdInAndStatus
(
new
ArrayList
<>(
branchIds
),
1
);
for
(
MapLayerCustomizeEntity
r
:
layerCustomizes
)
{
for
(
MapLayerCustomizeEntity
r
:
layerCustomizes
)
{
Map
<
String
,
String
>
m
=
new
HashMap
<>();
m
.
put
(
"layerId"
,
r
.
getLayerId
());
m
.
put
(
"layerName"
,
r
.
getLayer
());
...
...
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