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 {
* @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/MapLayerCustomizeDao.java
View file @
4f344c2
package
com
.
dituhui
.
pea
.
order
.
dao
;
import
com.dituhui.pea.order.entity.MapBlockInfoEntity
;
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/entity/MapLayerCustomizeEntity.java
View file @
4f344c2
...
...
@@ -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/service/BusinessLayerService.java
View file @
4f344c2
...
...
@@ -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/BusinessLayerServiceImpl.java
View file @
4f344c2
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,7 +11,6 @@ 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
;
...
...
@@ -21,9 +18,15 @@ 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
;
...
...
@@ -37,6 +40,8 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
@Autowired
private
MapLayerCustomizeMPDao
mapLayerCustomizeMPDao
;
@Autowired
private
MapLayerCustomizeDao
mapLayerCustomizeDao
;
@Autowired
private
MapLayerCustomizeSkillMPDao
mapLayerCustomizeSkillMPDao
;
@Autowired
private
OrgGroupDao
orgGroupDao
;
...
...
@@ -48,6 +53,8 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
private
ISaaSRemoteService
saasRemoteService
;
@Autowired
private
MapBlockInfoDao
mapBlockInfoDao
;
@Autowired
private
EntityManager
entityManager
;
@Override
public
Result
<?>
businessLayerUniversal
()
{
...
...
@@ -55,7 +62,7 @@ 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
List
<
OrgGroupEntity
>
groups
=
new
ArrayList
<>();
...
...
@@ -76,15 +83,19 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
Map
<
String
,
String
>
skillMapping
=
skills
.
stream
().
collect
(
Collectors
.
toMap
(
SkillInfoEntity:
:
getSkillCode
,
SkillInfoEntity:
:
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
);
//获取分页列表
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
());
...
...
@@ -107,9 +118,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
);
...
...
@@ -119,7 +130,7 @@ 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
(
"图层不存在"
);
}
...
...
@@ -167,7 +178,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
);
...
...
@@ -175,7 +186,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
));
...
...
@@ -187,14 +198,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
));
...
...
@@ -205,7 +215,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
(
"图层不存在"
);
}
...
...
@@ -226,7 +236,7 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
// 更新状态为删除状态
layer
.
setStatus
(
0
);
mapLayerCustomizeMPDao
.
updateById
(
layer
);
entityManager
.
merge
(
layer
);
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