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
;
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.BusinessException
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.common.ResultEnum
;
import
com.dituhui.pea.common.ResultEnum
;
...
@@ -14,15 +12,19 @@ import com.dituhui.pea.order.feign.ISaaSRemoteService;
...
@@ -14,15 +12,19 @@ import com.dituhui.pea.order.feign.ISaaSRemoteService;
import
com.dituhui.pea.order.service.BusinessBlockService
;
import
com.dituhui.pea.order.service.BusinessBlockService
;
import
com.dituhui.pea.order.utils.RegionUtils
;
import
com.dituhui.pea.order.utils.RegionUtils
;
import
com.dituhui.pea.order.utils.TypeUtils
;
import
com.dituhui.pea.order.utils.TypeUtils
;
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
;
import
org.springframework.beans.factory.annotation.Value
;
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.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.persistence.EntityManager
;
import
javax.persistence.EntityManager
;
import
javax.persistence.criteria.Predicate
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -30,50 +32,39 @@ import java.util.stream.Collectors;
...
@@ -30,50 +32,39 @@ import java.util.stream.Collectors;
@Service
@Service
public
class
BusinessBlockServiceImpl
implements
BusinessBlockService
{
public
class
BusinessBlockServiceImpl
implements
BusinessBlockService
{
@Value
(
"${SaaS.ak}"
)
String
ak
;
@Value
(
"${SaaS.url}"
)
String
url
;
@Autowired
@Autowired
private
OrgTeamDao
orgTeamDao
;
private
OrgTeamDao
orgTeamDao
;
@Autowired
private
MapBlockInfoMPDao
mapBlockInfoMPDao
;
@Autowired
@Autowired
private
ISaaSRemoteService
saasRemoteService
;
private
ISaaSRemoteService
saasRemoteService
;
@Autowired
@Autowired
private
MapBlockInfoDao
mapBlockInfoDao
;
private
MapBlockInfoDao
mapBlockInfoDao
;
@Autowired
@Autowired
private
OrgGroupDao
orgGroupDao
;
private
OrgGroupDao
orgGroupDao
;
@Autowired
@Autowired
private
MapLayerDao
mapLayerDao
;
private
MapLayerDao
mapLayerDao
;
@Autowired
@Autowired
private
MapLayerCustomizeDao
mapLayerCustomizeDao
;
private
MapLayerCustomizeDao
mapLayerCustomizeDao
;
@Autowired
@Autowired
private
EntityManager
entityManager
;
private
EntityManager
entityManager
;
@Value
(
"${SaaS.ak}"
)
String
ak
;
@Value
(
"${SaaS.url}"
)
String
url
;
@Override
@Override
public
Result
<?>
businessServerBlocks
(
String
levelType
,
String
levelValue
,
int
page
,
int
size
,
String
layerId
,
String
teamId
)
{
public
Result
<?>
businessServerBlocks
(
String
levelType
,
String
levelValue
,
int
page
,
int
size
,
String
layerId
,
String
teamId
)
{
BusinessServerBlocksRespDTO
resp
=
new
BusinessServerBlocksRespDTO
();
BusinessServerBlocksRespDTO
resp
=
new
BusinessServerBlocksRespDTO
();
List
<
OrgTeamEntity
>
teams
=
new
ArrayList
<>();
List
<
OrgTeamEntity
>
teams
=
new
ArrayList
<>();
if
(
levelType
.
equals
(
"cluster"
))
{
if
(
levelType
.
equals
(
"cluster"
))
{
teams
=
orgTeamDao
.
findAllByClusterId
(
levelValue
);
teams
=
orgTeamDao
.
findAllByClusterId
(
levelValue
);
}
else
if
(
levelType
.
equals
(
"branch"
))
{
}
else
if
(
levelType
.
equals
(
"branch"
))
{
teams
=
orgTeamDao
.
findAllByBranchId
(
levelValue
);
teams
=
orgTeamDao
.
findAllByBranchId
(
levelValue
);
}
else
if
(
levelType
.
equals
(
"group"
))
{
}
else
if
(
levelType
.
equals
(
"group"
))
{
teams
=
orgTeamDao
.
findAllByGroupId
(
levelValue
);
teams
=
orgTeamDao
.
findAllByGroupId
(
levelValue
);
}
}
if
(
StringUtils
.
isNotEmpty
(
teamId
))
{
if
(
StringUtils
.
isNotEmpty
(
teamId
))
{
teams
=
teams
.
stream
().
filter
(
t
->
t
.
getTeamId
().
equals
(
teamId
)).
collect
(
Collectors
.
toList
());
teams
=
teams
.
stream
().
filter
(
t
->
t
.
getTeamId
().
equals
(
teamId
)).
collect
(
Collectors
.
toList
());
}
}
...
@@ -99,18 +90,28 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
...
@@ -99,18 +90,28 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
// 获取groupId集合
// 获取groupId集合
Set
<
String
>
groupIds
=
teams
.
stream
().
map
(
OrgTeamEntity:
:
getGroupId
).
collect
(
Collectors
.
toSet
());
Set
<
String
>
groupIds
=
teams
.
stream
().
map
(
OrgTeamEntity:
:
getGroupId
).
collect
(
Collectors
.
toSet
());
List
<
OrgGroupEntity
>
groups
=
orgGroupDao
.
findByGroupIdIn
(
new
ArrayList
<>(
groupIds
));
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
);
// 获取blocks
LambdaQueryWrapper
<
MapBlockInfo
>
lqwBlock
=
new
LambdaQueryWrapper
<>();
Specification
<
MapBlockInfoEntity
>
specification
=
(
root
,
query
,
criteriaBuilder
)
->
{
lqwBlock
.
eq
(
MapBlockInfo:
:
getStatus
,
1
);
Predicate
statusPredicate
=
criteriaBuilder
.
equal
(
root
.
get
(
"status"
),
1
);
lqwBlock
.
in
(
MapBlockInfo:
:
getTeamId
,
teamIds
);
Predicate
teamIdPredicate
=
root
.
get
(
"teamId"
).
in
(
teamIds
);
lqwBlock
.
eq
(
StringUtils
.
isNotEmpty
(
layerId
),
MapBlockInfo:
:
getLayerId
,
layerId
);
lqwBlock
.
orderByAsc
(
MapBlockInfo:
:
getTeamId
);
Predicate
layerIdPredicate
;
mapBlockInfoMPDao
.
selectPage
(
pg
,
lqwBlock
);
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
<>();
List
<
BusinessServerBlocksRespDTO
.
Block
>
blocks
=
new
ArrayList
<>();
for
(
MapBlockInfo
b
:
pg
.
getRecords
())
{
for
(
MapBlockInfo
Entity
b
:
pg
.
getContent
())
{
BusinessServerBlocksRespDTO
.
Block
block
=
new
BusinessServerBlocksRespDTO
.
Block
();
BusinessServerBlocksRespDTO
.
Block
block
=
new
BusinessServerBlocksRespDTO
.
Block
();
OrgTeamEntity
team
=
teamMapping
.
get
(
b
.
getTeamId
());
OrgTeamEntity
team
=
teamMapping
.
get
(
b
.
getTeamId
());
...
@@ -130,9 +131,9 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
...
@@ -130,9 +131,9 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
blocks
.
add
(
block
);
blocks
.
add
(
block
);
}
}
resp
.
setTotal
(
pg
.
getTotal
());
resp
.
setTotal
(
pg
.
getTotal
Elements
());
resp
.
setPages
(
pg
.
getPages
());
resp
.
setPages
(
pg
.
get
Total
Pages
());
resp
.
setPageCurrent
(
pg
.
get
Current
()
);
resp
.
setPageCurrent
(
pg
.
get
Number
()
+
1
);
resp
.
setPageSize
(
pg
.
getSize
());
resp
.
setPageSize
(
pg
.
getSize
());
resp
.
setTip
(
""
);
resp
.
setTip
(
""
);
resp
.
setContent
(
blocks
);
resp
.
setContent
(
blocks
);
...
@@ -148,7 +149,7 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
...
@@ -148,7 +149,7 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
// 获取layerName
// 获取layerName
MapLayerEntity
layer1
=
mapLayerDao
.
getByLayerId
(
layerId
);
MapLayerEntity
layer1
=
mapLayerDao
.
getByLayerId
(
layerId
);
if
(
layer1
==
null
)
{
if
(
layer1
==
null
)
{
MapLayerCustomizeEntity
layer2
=
mapLayerCustomizeDao
.
getByLayerId
(
layerId
);
MapLayerCustomizeEntity
layer2
=
mapLayerCustomizeDao
.
getByLayerId
(
layerId
);
if
(
layer2
==
null
)
{
if
(
layer2
==
null
)
{
throw
new
BusinessException
(
"图层标签不存在"
);
throw
new
BusinessException
(
"图层标签不存在"
);
...
@@ -163,7 +164,7 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
...
@@ -163,7 +164,7 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
if
(
team
==
null
)
{
if
(
team
==
null
)
{
throw
new
BusinessException
(
"关联小队不存在"
);
throw
new
BusinessException
(
"关联小队不存在"
);
}
}
// 重复检查layerId+teamId
// 重复检查layerId+teamId
MapBlockInfoEntity
existBlock
=
mapBlockInfoDao
.
findByTeamIdAndLayerId
(
teamId
,
layerId
);
MapBlockInfoEntity
existBlock
=
mapBlockInfoDao
.
findByTeamIdAndLayerId
(
teamId
,
layerId
);
if
(
null
!=
existBlock
)
{
if
(
null
!=
existBlock
)
{
...
@@ -179,17 +180,17 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
...
@@ -179,17 +180,17 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
if
(
StringUtils
.
isEmpty
(
saasLayerId
))
{
if
(
StringUtils
.
isEmpty
(
saasLayerId
))
{
return
Result
.
failure
(
"图层未配置"
);
return
Result
.
failure
(
"图层未配置"
);
}
}
String
result
=
saasRemoteService
.
addArea
(
ak
,
team
.
getTeamName
(),
saasLayerId
,
region
,
"gcj02mc"
);
String
result
=
saasRemoteService
.
addArea
(
ak
,
team
.
getTeamName
(),
saasLayerId
,
region
,
"gcj02mc"
);
log
.
info
(
"params:{} {} {} {} result:{}"
,
team
.
getTeamName
(),
saasLayerId
,
region
,
result
);
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
()))
{
if
(!
ResultEnum
.
SUCCESS
.
getCode
().
equals
(
saasResult
.
getCode
()))
{
return
Result
.
failure
(
"区块已存在或者裁剪为空"
);
return
Result
.
failure
(
"区块已存在或者裁剪为空"
);
}
}
String
blockId
=
saasResult
.
getResult
();
String
blockId
=
saasResult
.
getResult
();
String
blockName
=
String
.
format
(
"%s_%s"
,
layerName
,
team
.
getTeamName
());
//区块名称
String
blockName
=
String
.
format
(
"%s_%s"
,
layerName
,
team
.
getTeamName
());
//区块名称
MapBlockInfoEntity
block
=
new
MapBlockInfoEntity
();
MapBlockInfoEntity
block
=
new
MapBlockInfoEntity
();
block
.
setBlockId
(
blockId
);
block
.
setBlockId
(
blockId
);
block
.
setBlockName
(
blockName
);
block
.
setBlockName
(
blockName
);
...
@@ -206,7 +207,7 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
...
@@ -206,7 +207,7 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
/**
/**
* 获取saas图层id
* 获取saas图层id
*
*
* @param branchId
* @param branchId
* @param layerId
* @param layerId
* @return
* @return
...
@@ -241,11 +242,11 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
...
@@ -241,11 +242,11 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
// 同步删除saas区块
// 同步删除saas区块
String
result
=
saasRemoteService
.
deleteArea
(
ak
,
blockId
);
String
result
=
saasRemoteService
.
deleteArea
(
ak
,
blockId
);
log
.
info
(
"params:{} result:{}"
,
blockId
,
result
);
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
()))
{
if
(!
ResultEnum
.
SUCCESS
.
getCode
().
equals
(
saasResult
.
getCode
()))
{
return
Result
.
failure
(
"删除失败,请联系管理员"
);
return
Result
.
failure
(
"删除失败,请联系管理员"
);
}
}
return
Result
.
success
(
null
);
return
Result
.
success
(
null
);
}
}
...
@@ -275,7 +276,7 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
...
@@ -275,7 +276,7 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
// 获取通用图层
// 获取通用图层
List
<
MapLayerEntity
>
layers
=
mapLayerDao
.
findAll
();
List
<
MapLayerEntity
>
layers
=
mapLayerDao
.
findAll
();
for
(
MapLayerEntity
r:
layers
)
{
for
(
MapLayerEntity
r
:
layers
)
{
Map
<
String
,
String
>
m
=
new
HashMap
<>();
Map
<
String
,
String
>
m
=
new
HashMap
<>();
m
.
put
(
"layerId"
,
r
.
getLayerId
());
m
.
put
(
"layerId"
,
r
.
getLayerId
());
m
.
put
(
"layerName"
,
r
.
getLayer
());
m
.
put
(
"layerName"
,
r
.
getLayer
());
...
@@ -284,9 +285,9 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
...
@@ -284,9 +285,9 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
// 获取自定义图层(只有branch才能创建自定义图层)
// 获取自定义图层(只有branch才能创建自定义图层)
List
<
OrgGroupEntity
>
groups
=
new
ArrayList
<>();
List
<
OrgGroupEntity
>
groups
=
new
ArrayList
<>();
if
(
levelType
.
equals
(
"cluster"
))
{
if
(
levelType
.
equals
(
"cluster"
))
{
groups
=
orgGroupDao
.
findAllByClusterId
(
levelValue
);
groups
=
orgGroupDao
.
findAllByClusterId
(
levelValue
);
}
else
if
(
levelType
.
equals
(
"branch"
))
{
}
else
if
(
levelType
.
equals
(
"branch"
))
{
groups
=
orgGroupDao
.
findAllByBranchId
(
levelValue
);
groups
=
orgGroupDao
.
findAllByBranchId
(
levelValue
);
}
else
if
(
levelType
.
equals
(
"group"
))
{
}
else
if
(
levelType
.
equals
(
"group"
))
{
groups
=
orgGroupDao
.
findAllByGroupId
(
levelValue
);
groups
=
orgGroupDao
.
findAllByGroupId
(
levelValue
);
...
@@ -297,7 +298,7 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
...
@@ -297,7 +298,7 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
}
}
List
<
MapLayerCustomizeEntity
>
layerCustomizes
=
mapLayerCustomizeDao
.
findByBranchIdInAndStatus
(
new
ArrayList
<>(
branchIds
),
1
);
List
<
MapLayerCustomizeEntity
>
layerCustomizes
=
mapLayerCustomizeDao
.
findByBranchIdInAndStatus
(
new
ArrayList
<>(
branchIds
),
1
);
for
(
MapLayerCustomizeEntity
r
:
layerCustomizes
)
{
for
(
MapLayerCustomizeEntity
r
:
layerCustomizes
)
{
Map
<
String
,
String
>
m
=
new
HashMap
<>();
Map
<
String
,
String
>
m
=
new
HashMap
<>();
m
.
put
(
"layerId"
,
r
.
getLayerId
());
m
.
put
(
"layerId"
,
r
.
getLayerId
());
m
.
put
(
"layerName"
,
r
.
getLayer
());
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