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 4f344c2a
authored
Aug 04, 2023
by
wangli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mp2jpa
1 parent
14fd1c29
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
28 deletions
project-order/src/main/java/com/dituhui/pea/order/controller/BusinessLayerController.java
project-order/src/main/java/com/dituhui/pea/order/dao/MapLayerCustomizeDao.java
project-order/src/main/java/com/dituhui/pea/order/entity/MapLayerCustomizeEntity.java
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/controller/BusinessLayerController.java
View file @
4f344c2
...
@@ -43,7 +43,7 @@ public class BusinessLayerController {
...
@@ -43,7 +43,7 @@ public class BusinessLayerController {
* @return
* @return
*/
*/
@GetMapping
(
"/business/layer/custom/list"
)
@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
;
Result
<?>
res
=
null
;
try
{
try
{
...
...
project-order/src/main/java/com/dituhui/pea/order/dao/MapLayerCustomizeDao.java
View file @
4f344c2
package
com
.
dituhui
.
pea
.
order
.
dao
;
package
com
.
dituhui
.
pea
.
order
.
dao
;
import
com.dituhui.pea.order.entity.MapBlockInfoEntity
;
import
com.dituhui.pea.order.entity.MapLayerCustomizeEntity
;
import
com.dituhui.pea.order.entity.MapLayerCustomizeEntity
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
java.util.List
;
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
);
public
MapLayerCustomizeEntity
findByBranchIdAndLayerIdAndStatus
(
String
branchId
,
String
layerId
,
int
status
);
...
...
project-order/src/main/java/com/dituhui/pea/order/entity/MapLayerCustomizeEntity.java
View file @
4f344c2
...
@@ -3,6 +3,7 @@ package com.dituhui.pea.order.entity;
...
@@ -3,6 +3,7 @@ package com.dituhui.pea.order.entity;
import
lombok.Data
;
import
lombok.Data
;
import
javax.persistence.*
;
import
javax.persistence.*
;
import
java.time.LocalDateTime
;
import
java.util.Date
;
import
java.util.Date
;
@Entity
@Entity
...
@@ -36,10 +37,10 @@ public class MapLayerCustomizeEntity {
...
@@ -36,10 +37,10 @@ public class MapLayerCustomizeEntity {
private
String
memo
;
private
String
memo
;
@Column
(
name
=
"create_time"
,
nullable
=
false
)
@Column
(
name
=
"create_time"
,
nullable
=
false
)
private
Dat
e
createTime
;
private
LocalDateTim
e
createTime
;
@Column
(
name
=
"update_time"
,
nullable
=
false
)
@Column
(
name
=
"update_time"
,
nullable
=
false
)
private
Dat
e
updateTime
;
private
LocalDateTim
e
updateTime
;
// Getters and Setters
// Getters and Setters
// ...
// ...
...
...
project-order/src/main/java/com/dituhui/pea/order/service/BusinessLayerService.java
View file @
4f344c2
...
@@ -8,7 +8,7 @@ import java.util.List;
...
@@ -8,7 +8,7 @@ import java.util.List;
public
interface
BusinessLayerService
{
public
interface
BusinessLayerService
{
Result
<?>
businessLayerUniversal
();
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
);
Result
<?>
businessCustomLayer
(
String
layerId
);
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/BusinessLayerServiceImpl.java
View file @
4f344c2
package
com
.
dituhui
.
pea
.
order
.
service
.
impl
;
package
com
.
dituhui
.
pea
.
order
.
service
.
impl
;
import
com.alibaba.nacos.common.utils.CollectionUtils
;
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.core.conditions.update.LambdaUpdateWrapper
;
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
;
...
@@ -13,7 +11,6 @@ import com.dituhui.pea.order.dto.BusinessCustomLayerRespDTO;
...
@@ -13,7 +11,6 @@ import com.dituhui.pea.order.dto.BusinessCustomLayerRespDTO;
import
com.dituhui.pea.order.dto.BusinessCustomLayersRespDTO
;
import
com.dituhui.pea.order.dto.BusinessCustomLayersRespDTO
;
import
com.dituhui.pea.order.entity.*
;
import
com.dituhui.pea.order.entity.*
;
import
com.dituhui.pea.order.feign.ISaaSRemoteService
;
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.service.BusinessLayerService
;
import
com.dituhui.pea.order.utils.TypeUtils
;
import
com.dituhui.pea.order.utils.TypeUtils
;
import
com.google.gson.internal.LinkedTreeMap
;
import
com.google.gson.internal.LinkedTreeMap
;
...
@@ -21,9 +18,15 @@ import com.google.gson.internal.LinkedTreeMap;
...
@@ -21,9 +18,15 @@ import com.google.gson.internal.LinkedTreeMap;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
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.criteria.Predicate
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -37,6 +40,8 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
...
@@ -37,6 +40,8 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
@Autowired
@Autowired
private
MapLayerCustomizeMPDao
mapLayerCustomizeMPDao
;
private
MapLayerCustomizeMPDao
mapLayerCustomizeMPDao
;
@Autowired
@Autowired
private
MapLayerCustomizeDao
mapLayerCustomizeDao
;
@Autowired
private
MapLayerCustomizeSkillMPDao
mapLayerCustomizeSkillMPDao
;
private
MapLayerCustomizeSkillMPDao
mapLayerCustomizeSkillMPDao
;
@Autowired
@Autowired
private
OrgGroupDao
orgGroupDao
;
private
OrgGroupDao
orgGroupDao
;
...
@@ -48,6 +53,8 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
...
@@ -48,6 +53,8 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
private
ISaaSRemoteService
saasRemoteService
;
private
ISaaSRemoteService
saasRemoteService
;
@Autowired
@Autowired
private
MapBlockInfoDao
mapBlockInfoDao
;
private
MapBlockInfoDao
mapBlockInfoDao
;
@Autowired
private
EntityManager
entityManager
;
@Override
@Override
public
Result
<?>
businessLayerUniversal
()
{
public
Result
<?>
businessLayerUniversal
()
{
...
@@ -55,7 +62,7 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
...
@@ -55,7 +62,7 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
}
}
@Override
@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
// 获取branchIds
List
<
OrgGroupEntity
>
groups
=
new
ArrayList
<>();
List
<
OrgGroupEntity
>
groups
=
new
ArrayList
<>();
...
@@ -76,15 +83,19 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
...
@@ -76,15 +83,19 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
Map
<
String
,
String
>
skillMapping
=
skills
.
stream
().
collect
(
Collectors
.
toMap
(
Map
<
String
,
String
>
skillMapping
=
skills
.
stream
().
collect
(
Collectors
.
toMap
(
SkillInfoEntity:
:
getSkillCode
,
SkillInfoEntity:
:
getSkillCode
));
SkillInfoEntity:
:
getSkillCode
,
SkillInfoEntity:
:
getSkillCode
));
Page
<
MapLayerCustomize
>
pg
=
new
Page
(
page
,
size
);
//获取分页列表
LambdaQueryWrapper
<
MapLayerCustomize
>
mapWrapper
=
new
LambdaQueryWrapper
<>();
Specification
<
MapLayerCustomizeEntity
>
specification
=
(
root
,
query
,
criteriaBuilder
)
->
{
mapWrapper
.
eq
(
MapLayerCustomize:
:
getStatus
,
1
);
Predicate
statusPredicate
=
criteriaBuilder
.
equal
(
root
.
get
(
"status"
),
1
);
mapWrapper
.
in
(
MapLayerCustomize:
:
getBranchId
,
branchIds
);
Predicate
branchIdPredicate
=
root
.
get
(
"branchId"
).
in
(
branchIds
);
mapWrapper
.
orderByAsc
(
MapLayerCustomize:
:
getLayerId
);
return
criteriaBuilder
.
and
(
statusPredicate
,
branchIdPredicate
);
mapLayerCustomizeMPDao
.
selectPage
(
pg
,
mapWrapper
);
};
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
<>();
List
<
BusinessCustomLayersRespDTO
.
LayerItem
>
items
=
new
ArrayList
<>();
for
(
MapLayerCustomize
layer
:
pg
.
getRecords
())
{
for
(
MapLayerCustomize
Entity
layer
:
pg
.
getContent
())
{
BusinessCustomLayersRespDTO
.
LayerItem
item
=
new
BusinessCustomLayersRespDTO
.
LayerItem
();
BusinessCustomLayersRespDTO
.
LayerItem
item
=
new
BusinessCustomLayersRespDTO
.
LayerItem
();
item
.
setLayerId
(
layer
.
getLayerId
());
item
.
setLayerId
(
layer
.
getLayerId
());
...
@@ -107,9 +118,9 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
...
@@ -107,9 +118,9 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
}
}
BusinessCustomLayersRespDTO
res
=
new
BusinessCustomLayersRespDTO
();
BusinessCustomLayersRespDTO
res
=
new
BusinessCustomLayersRespDTO
();
res
.
setTotal
(
pg
.
getTotal
());
res
.
setTotal
(
pg
.
getTotal
Elements
());
res
.
setPages
(
pg
.
getPages
());
res
.
setPages
(
pg
.
get
Total
Pages
());
res
.
setPageCurrent
(
pg
.
get
Current
()
);
res
.
setPageCurrent
(
pg
.
get
Number
()
+
1
);
res
.
setPageSize
(
pg
.
getSize
());
res
.
setPageSize
(
pg
.
getSize
());
res
.
setContent
(
items
);
res
.
setContent
(
items
);
...
@@ -119,7 +130,7 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
...
@@ -119,7 +130,7 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
@Override
@Override
public
Result
<?>
businessCustomLayer
(
String
layerId
)
{
public
Result
<?>
businessCustomLayer
(
String
layerId
)
{
MapLayerCustomize
layer
=
mapLayerCustomizeMP
Dao
.
getByLayerId
(
layerId
);
MapLayerCustomize
Entity
layer
=
mapLayerCustomize
Dao
.
getByLayerId
(
layerId
);
if
(
layer
==
null
)
{
if
(
layer
==
null
)
{
throw
new
BusinessException
(
"图层不存在"
);
throw
new
BusinessException
(
"图层不存在"
);
}
}
...
@@ -167,7 +178,7 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
...
@@ -167,7 +178,7 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
String
layerId
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
String
layerId
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
// 入库保存
// 入库保存
MapLayerCustomize
m
=
new
MapLayerCustomize
();
MapLayerCustomize
Entity
m
=
new
MapLayerCustomizeEntity
();
m
.
setLayerId
(
layerId
);
m
.
setLayerId
(
layerId
);
m
.
setSaasLayerId
(
saasLayerId
);
m
.
setSaasLayerId
(
saasLayerId
);
m
.
setLayer
(
layerName
);
m
.
setLayer
(
layerName
);
...
@@ -175,7 +186,7 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
...
@@ -175,7 +186,7 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
m
.
setBranchId
(
branchId
);
m
.
setBranchId
(
branchId
);
m
.
setStatus
(
1
);
m
.
setStatus
(
1
);
m
.
setCreateTime
(
LocalDateTime
.
now
());
m
.
setCreateTime
(
LocalDateTime
.
now
());
mapLayerCustomizeMPDao
.
inser
t
(
m
);
entityManager
.
persis
t
(
m
);
// 更新技能
// 更新技能
this
.
updateLayerSkills
(
layerId
,
new
HashSet
<>(
skillCodes
));
this
.
updateLayerSkills
(
layerId
,
new
HashSet
<>(
skillCodes
));
...
@@ -187,14 +198,13 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
...
@@ -187,14 +198,13 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
@Override
@Override
public
Result
<?>
businessCustomLayerUpdate
(
String
layerId
,
String
layerDesc
,
List
<
String
>
skillCodes
)
throws
BusinessException
{
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
)
{
if
(
layer
==
null
)
{
throw
new
BusinessException
(
"图层不存在"
);
throw
new
BusinessException
(
"图层不存在"
);
}
}
// 更新描述信息
// 更新描述信息
layer
.
setLayerDescribe
(
layerDesc
);
layer
.
setLayerDescribe
(
layerDesc
);
mapLayerCustomizeMPDao
.
updateById
(
layer
);
entityManager
.
merge
(
layer
);
// 更新技能
// 更新技能
this
.
updateLayerSkills
(
layerId
,
new
HashSet
<>(
skillCodes
));
this
.
updateLayerSkills
(
layerId
,
new
HashSet
<>(
skillCodes
));
...
@@ -205,7 +215,7 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
...
@@ -205,7 +215,7 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
@Override
@Override
public
Result
<?>
businessCustomLayerRemove
(
String
layerId
)
throws
BusinessException
{
public
Result
<?>
businessCustomLayerRemove
(
String
layerId
)
throws
BusinessException
{
MapLayerCustomize
layer
=
mapLayerCustomizeMP
Dao
.
getByLayerId
(
layerId
);
MapLayerCustomize
Entity
layer
=
mapLayerCustomize
Dao
.
getByLayerId
(
layerId
);
if
(
layer
==
null
)
{
if
(
layer
==
null
)
{
throw
new
BusinessException
(
"图层不存在"
);
throw
new
BusinessException
(
"图层不存在"
);
}
}
...
@@ -226,7 +236,7 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
...
@@ -226,7 +236,7 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
// 更新状态为删除状态
// 更新状态为删除状态
layer
.
setStatus
(
0
);
layer
.
setStatus
(
0
);
mapLayerCustomizeMPDao
.
updateById
(
layer
);
entityManager
.
merge
(
layer
);
return
Result
.
success
(
null
);
return
Result
.
success
(
null
);
}
}
...
...
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