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 63344de1
authored
Oct 17, 2023
by
huangjinxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:1:图层派单优先级相关添加
2:分单基础类
1 parent
927d130d
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
792 additions
and
268 deletions
project-interface/src/main/java/com/dituhui/pea/common/SaasWebResult.java
project-interface/src/main/java/com/dituhui/pea/pojo/fendan/APIAddressMatchResult.java
project-interface/src/main/java/com/dituhui/pea/pojo/fendan/FenDanEsResult.java
project-interface/src/main/java/com/dituhui/pea/pojo/fendan/FendanDTO.java
project-order/src/main/java/com/dituhui/pea/order/common/CapacityUtils.java
project-order/src/main/java/com/dituhui/pea/order/common/SaasUtils.java
project-order/src/main/java/com/dituhui/pea/order/controller/BusinessLayerController.java
project-order/src/main/java/com/dituhui/pea/order/dao/SkillInfoDao.java
project-order/src/main/java/com/dituhui/pea/order/dto/BusinessCustomLayerRespDTO.java
project-order/src/main/java/com/dituhui/pea/order/dto/BusinessCustomLayerUpdateReqDTO.java
project-order/src/main/java/com/dituhui/pea/order/entity/MapLayerCustomizeEntity.java
project-order/src/main/java/com/dituhui/pea/order/feign/ISaaSRemoteService.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-interface/src/main/java/com/dituhui/pea/common/SaasWebResult.java
0 → 100644
View file @
63344de
package
com
.
dituhui
.
pea
.
common
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
java.io.Serializable
;
/**
* WEB接口响应封装对象
*/
public
class
SaasWebResult
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
code
;
//响应状态码
private
Object
result
;
//响应内容
private
Object
info
;
//其他信息
private
String
message
;
// 返回消息
/**
* 统计数据不做返回
*/
@JsonIgnore
private
Object
logBeans
;
public
Object
getInfo
()
{
return
info
;
}
public
void
setInfo
(
Object
info
)
{
this
.
info
=
info
;
}
/**
* 构造函数
*
* @param code 状态码
* @param result 响应内容
*/
public
SaasWebResult
(
String
code
,
Object
result
)
{
this
.
code
=
code
;
this
.
result
=
result
;
}
public
SaasWebResult
(
String
code
,
Object
result
,
String
message
)
{
this
.
code
=
code
;
this
.
result
=
result
;
this
.
message
=
message
;
}
/**
* 存在统计数据
*
* @param code
* @param result
* @param logBeans 统计数据
*/
public
SaasWebResult
(
String
code
,
Object
result
,
Object
logBeans
)
{
this
.
code
=
code
;
this
.
result
=
result
;
this
.
logBeans
=
logBeans
;
}
/**
* @return 状态码
*/
public
String
getCode
()
{
return
code
;
}
/**
* 状态码
*
* @param code
*/
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
/**
* @return 结果
*/
public
Object
getResult
()
{
return
result
;
}
/**
* 结果
*
* @param result
*/
public
void
setResult
(
Object
result
)
{
this
.
result
=
result
;
}
/**
* 统计数据
* @return
*/
public
Object
getLogBeans
()
{
return
logBeans
;
}
/**
* @param logBeans required "? extends LogBean" or "List<? extends LogBean>"
*/
public
void
setLogBeans
(
Object
logBeans
)
{
this
.
logBeans
=
logBeans
;
}
@Override
public
String
toString
()
{
return
"WebResult{"
+
"code='"
+
code
+
'\''
+
", result="
+
result
+
", info="
+
info
+
", message='"
+
message
+
'\''
+
", logBeans="
+
logBeans
+
'}'
;
}
}
project-interface/src/main/java/com/dituhui/pea/pojo/fendan/APIAddressMatchResult.java
0 → 100644
View file @
63344de
package
com
.
dituhui
.
pea
.
pojo
.
fendan
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
java.io.Serializable
;
/**
* 地址解析返回结果
*/
public
class
APIAddressMatchResult
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
/**
* ID
*/
private
String
id
;
/**
* x坐标
*/
private
double
x
;
/**
* y坐标
*/
private
double
y
;
/**
* 结果类型:1代表成功,2代表地址解析失败,3代表点查面失败
*/
private
int
resultType
;
/**
* 结果内容
*/
@JsonIgnore
private
String
resultInfo
;
/**
* 省
*/
private
String
province
;
/**
* 市
*/
private
String
city
;
/**
* 区
*/
private
String
county
;
/**
* ADMINCODE
*/
private
String
admincode
;
/**
* town
*/
private
String
town
;
/**
* 区号
*/
private
String
aCode
;
/**
* 评分
*/
@JsonIgnore
private
double
score
=
0
;
/**
* 逆地址解析的地址
*/
private
String
address
;
private
String
village
;
public
String
getAddress
()
{
return
address
;
}
public
void
setAddress
(
String
address
)
{
this
.
address
=
address
;
}
public
int
getResultType
()
{
return
resultType
;
}
public
void
setResultType
(
int
resultType
)
{
this
.
resultType
=
resultType
;
}
public
String
getResultInfo
()
{
return
resultInfo
;
}
public
void
setResultInfo
(
String
resultInfo
)
{
this
.
resultInfo
=
resultInfo
;
}
public
String
getProvince
()
{
return
province
;
}
public
void
setProvince
(
String
province
)
{
this
.
province
=
province
;
}
public
String
getCity
()
{
return
city
;
}
public
void
setCity
(
String
city
)
{
this
.
city
=
city
;
}
public
String
getCounty
()
{
return
county
;
}
public
void
setCounty
(
String
county
)
{
this
.
county
=
county
;
}
public
String
getTown
()
{
return
town
;
}
public
void
setTown
(
String
town
)
{
this
.
town
=
town
;
}
public
String
getaCode
()
{
return
aCode
;
}
public
void
setaCode
(
String
aCode
)
{
this
.
aCode
=
aCode
;
}
public
String
getAdmincode
()
{
return
admincode
;
}
public
void
setAdmincode
(
String
admincode
)
{
this
.
admincode
=
admincode
;
}
public
double
getScore
()
{
return
score
;
}
public
void
setScore
(
double
score
)
{
this
.
score
=
score
;
}
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
double
getX
()
{
return
x
;
}
public
void
setX
(
double
x
)
{
this
.
x
=
x
;
}
public
double
getY
()
{
return
y
;
}
public
void
setY
(
double
y
)
{
this
.
y
=
y
;
}
public
String
getVillage
()
{
return
village
;
}
public
void
setVillage
(
String
village
)
{
this
.
village
=
village
;
}
public
APIAddressMatchResult
(
String
id
)
{
this
.
id
=
id
;
}
@Override
public
String
toString
()
{
return
"APIAddressMatchResult{"
+
"id='"
+
id
+
'\''
+
", x="
+
x
+
", y="
+
y
+
", resultType="
+
resultType
+
", resultInfo='"
+
resultInfo
+
'\''
+
", province='"
+
province
+
'\''
+
", city='"
+
city
+
'\''
+
", county='"
+
county
+
'\''
+
", village='"
+
village
+
'\''
+
", admincode='"
+
admincode
+
'\''
+
", score="
+
score
+
'}'
;
}
public
APIAddressMatchResult
()
{
}
}
project-interface/src/main/java/com/dituhui/pea/pojo/fendan/FenDanEsResult.java
0 → 100644
View file @
63344de
package
com
.
dituhui
.
pea
.
pojo
.
fendan
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.Map
;
/**
* FenDanResult 加上es扩展字段
*
* @author guoping
*/
@Data
public
class
FenDanEsResult
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 地址解析
*/
private
APIAddressMatchResult
addressResult
;
/**
* 分单面列表
*/
private
List
<
Map
<
String
,
Object
>>
areaResults
;
@JsonIgnore
public
String
statusCode
=
"S001"
;
// 状态码,默认成功
}
project-interface/src/main/java/com/dituhui/pea/pojo/fendan/FendanDTO.java
0 → 100644
View file @
63344de
package
com
.
dituhui
.
pea
.
pojo
.
fendan
;
import
lombok.Data
;
@Data
public
class
FendanDTO
{
/**
* 经纬度
*/
private
String
xy
;
/**
* 区划样式
*/
private
Boolean
isShowStyle
=
false
;
/**
* 需要行政区划
*/
private
Boolean
needDistrict
=
false
;
}
project-order/src/main/java/com/dituhui/pea/order/common/CapacityUtils.java
View file @
63344de
...
@@ -5,6 +5,7 @@ import com.dituhui.pea.order.dao.SkillInfoDao;
...
@@ -5,6 +5,7 @@ import com.dituhui.pea.order.dao.SkillInfoDao;
import
com.dituhui.pea.order.entity.MapBlockInfoEntity
;
import
com.dituhui.pea.order.entity.MapBlockInfoEntity
;
import
com.dituhui.pea.order.entity.SkillInfoEntity
;
import
com.dituhui.pea.order.entity.SkillInfoEntity
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -37,4 +38,24 @@ public class CapacityUtils {
...
@@ -37,4 +38,24 @@ public class CapacityUtils {
return
layers
;
return
layers
;
}
}
/**
* 根据服务品牌,产品类型,服务类型匹配查询匹配图层
*
* @param brand
* @param type
* @param skillCode
* @return
*/
public
List
<
String
>
getLayersBySkillCode
(
String
brand
,
String
type
,
String
skillCode
)
{
List
<
String
>
layers
=
new
ArrayList
<>();
List
<
SkillInfoEntity
>
entitys
=
skillInfoDao
.
getByBrandAndTypeAndsAndSkillCode
(
brand
,
type
,
skillCode
);
if
(
CollectionUtils
.
isNotEmpty
(
entitys
))
{
for
(
SkillInfoEntity
entity
:
entitys
)
{
layers
.
add
(
entity
.
getLayerId
());
}
}
return
layers
;
}
}
}
project-order/src/main/java/com/dituhui/pea/order/common/SaasUtils.java
View file @
63344de
package
com
.
dituhui
.
pea
.
order
.
common
;
package
com
.
dituhui
.
pea
.
order
.
common
;
import
com.alibaba.fastjson.JSONObject
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.common.SaasWebResult
;
import
com.dituhui.pea.order.dto.SaasFendanDTO
;
import
com.dituhui.pea.order.dto.SaasFendanDTO
;
import
com.dituhui.pea.order.dto.SaasXyFendanDTO
;
import
com.dituhui.pea.order.dto.SaasXyFendanDTO
;
import
com.dituhui.pea.order.feign.ISaaSRemoteService
;
import
com.dituhui.pea.order.feign.ISaaSRemoteService
;
import
com.dituhui.pea.pojo.fendan.FenDanEsResult
;
import
com.dituhui.pea.pojo.fendan.FendanDTO
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
lombok.experimental.Accessors
;
import
lombok.experimental.Accessors
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.ObjectUtils
;
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.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
@Component
@Component
@Slf4j
@Slf4j
...
@@ -69,6 +76,33 @@ public class SaasUtils {
...
@@ -69,6 +76,33 @@ public class SaasUtils {
return
blocks
;
return
blocks
;
}
}
/**
* 根据提供的地址信息,获取对应的片区图层
*/
public
List
<
BlockInfo
>
queryBlocksByXy
(
FendanDTO
fendanDTO
)
{
long
t
=
System
.
currentTimeMillis
();
log
.
info
(
"===> queryBlocksByXySingleT({})"
,
t
);
SaasWebResult
webResult
=
saasRemoteService
.
single
(
ak
,
String
.
valueOf
(
t
),
fendanDTO
);
log
.
info
(
"queryBlocksByXySingle返回结果: ===> {}"
,
webResult
.
getResult
());
List
<
BlockInfo
>
blocks
=
new
ArrayList
<>();
if
(!
webResult
.
getCode
().
equals
(
"S001"
))
{
return
blocks
;
}
//调用saas分单接口
FenDanEsResult
fenDanEsResult
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
webResult
.
getResult
()),
FenDanEsResult
.
class
);
if
(
ObjectUtils
.
isEmpty
(
fenDanEsResult
))
{
return
blocks
;
}
for
(
Map
<
String
,
Object
>
areaMap
:
fenDanEsResult
.
getAreaResults
())
{
if
(
areaMap
.
containsKey
(
"id"
)
&&
areaMap
.
containsKey
(
"areaName"
))
{
blocks
.
add
(
new
BlockInfo
()
.
setBlockId
(
areaMap
.
get
(
"id"
).
toString
())
.
setBlockName
(
areaMap
.
get
(
"areaName"
).
toString
()));
}
}
return
blocks
;
}
public
List
<
BlockInfo
>
queryBlocksByAddress
(
String
address
)
{
public
List
<
BlockInfo
>
queryBlocksByAddress
(
String
address
)
{
// 根据坐标 查询分单接口,获得区块、图层列表 ===> 查询map_block_info表,根据优先级,确定 工作队;
// 根据坐标 查询分单接口,获得区块、图层列表 ===> 查询map_block_info表,根据优先级,确定 工作队;
...
...
project-order/src/main/java/com/dituhui/pea/order/controller/BusinessLayerController.java
View file @
63344de
...
@@ -106,7 +106,7 @@ public class BusinessLayerController {
...
@@ -106,7 +106,7 @@ public class BusinessLayerController {
// 自定义图层修改
// 自定义图层修改
Result
<?>
res
=
null
;
Result
<?>
res
=
null
;
try
{
try
{
res
=
businessLayerService
.
businessCustomLayerUpdate
(
reqDTO
.
getLayerId
(),
reqDTO
.
getLayerDesc
(),
reqDTO
.
getSkills
()
);
res
=
businessLayerService
.
businessCustomLayerUpdate
(
reqDTO
);
}
catch
(
BusinessException
e
)
{
}
catch
(
BusinessException
e
)
{
return
Result
.
failed
(
e
.
getMessage
());
return
Result
.
failed
(
e
.
getMessage
());
}
}
...
...
project-order/src/main/java/com/dituhui/pea/order/dao/SkillInfoDao.java
View file @
63344de
...
@@ -9,6 +9,10 @@ import java.util.List;
...
@@ -9,6 +9,10 @@ import java.util.List;
public
interface
SkillInfoDao
extends
JpaRepository
<
SkillInfoEntity
,
Long
>
{
public
interface
SkillInfoDao
extends
JpaRepository
<
SkillInfoEntity
,
Long
>
{
List
<
SkillInfoEntity
>
findAll
();
List
<
SkillInfoEntity
>
findAll
();
Page
<
SkillInfoEntity
>
findAll
(
Pageable
pageable
);
Page
<
SkillInfoEntity
>
findAll
(
Pageable
pageable
);
SkillInfoEntity
getByBrandAndTypeAndSkill
(
String
brand
,
String
type
,
String
skill
);
SkillInfoEntity
getByBrandAndTypeAndSkill
(
String
brand
,
String
type
,
String
skill
);
List
<
SkillInfoEntity
>
getByBrandAndTypeAndsAndSkillCode
(
String
brand
,
String
type
,
String
skillCode
);
}
}
project-order/src/main/java/com/dituhui/pea/order/dto/BusinessCustomLayerRespDTO.java
View file @
63344de
...
@@ -6,10 +6,16 @@ import java.util.List;
...
@@ -6,10 +6,16 @@ import java.util.List;
@Data
@Data
public
class
BusinessCustomLayerRespDTO
{
public
class
BusinessCustomLayerRespDTO
{
private
String
layerId
;
private
String
layerId
;
private
String
layerName
;
private
String
layerName
;
private
String
layerDesc
;
private
String
layerDesc
;
private
String
branchId
;
private
String
branchId
;
private
String
branchName
;
private
String
branchName
;
private
List
<
String
>
skills
;
private
List
<
String
>
skills
;
/**
* 派单优先级(1-10,数值越小表示优先级越高,默认10)
*/
private
Integer
priority
;
}
}
project-order/src/main/java/com/dituhui/pea/order/dto/BusinessCustomLayerUpdateReqDTO.java
View file @
63344de
...
@@ -9,4 +9,10 @@ public class BusinessCustomLayerUpdateReqDTO {
...
@@ -9,4 +9,10 @@ public class BusinessCustomLayerUpdateReqDTO {
private
String
layerId
;
private
String
layerId
;
private
String
layerDesc
;
private
String
layerDesc
;
private
List
<
String
>
skills
;
private
List
<
String
>
skills
;
/**
* 派单优先级(1-10,数值越小表示优先级越高,默认10)
*/
private
Integer
priority
;
}
}
project-order/src/main/java/com/dituhui/pea/order/entity/MapLayerCustomizeEntity.java
View file @
63344de
...
@@ -20,7 +20,7 @@ public class MapLayerCustomizeEntity {
...
@@ -20,7 +20,7 @@ public class MapLayerCustomizeEntity {
@Column
(
name
=
"layer_id"
,
length
=
32
)
@Column
(
name
=
"layer_id"
,
length
=
32
)
private
String
layerId
;
private
String
layerId
;
@Column
(
name
=
"saas_layer_id"
,
length
=
32
)
@Column
(
name
=
"saas_layer_id"
,
length
=
32
)
private
String
saasLayerId
;
private
String
saasLayerId
;
...
@@ -45,4 +45,9 @@ public class MapLayerCustomizeEntity {
...
@@ -45,4 +45,9 @@ public class MapLayerCustomizeEntity {
// Getters and Setters
// Getters and Setters
// ...
// ...
/**
* 派单优先级(1-10,数值越小表示优先级越高,默认10)
*/
@Column
(
name
=
"priority"
,
nullable
=
false
)
private
Integer
priority
=
10
;
}
}
project-order/src/main/java/com/dituhui/pea/order/feign/ISaaSRemoteService.java
View file @
63344de
package
com
.
dituhui
.
pea
.
order
.
feign
;
package
com
.
dituhui
.
pea
.
order
.
feign
;
import
com.dituhui.pea.common.SaasWebResult
;
import
com.dituhui.pea.pojo.fendan.FenDanEsResult
;
import
com.dituhui.pea.pojo.fendan.FendanDTO
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
@FeignClient
(
url
=
"${SaaS.url}"
,
name
=
"saasService"
)
@FeignClient
(
url
=
"${SaaS.url}"
,
name
=
"saasService"
)
...
@@ -30,4 +34,8 @@ public interface ISaaSRemoteService {
...
@@ -30,4 +34,8 @@ public interface ISaaSRemoteService {
@GetMapping
(
"/v2/fendan"
)
@GetMapping
(
"/v2/fendan"
)
public
String
blockByAddress
(
@RequestParam
String
ak
,
@RequestParam
String
addresses
,
public
String
blockByAddress
(
@RequestParam
String
ak
,
@RequestParam
String
addresses
,
@RequestParam
Boolean
need_district
,
@RequestParam
Boolean
need_layer
,
@RequestParam
String
area_fields
);
@RequestParam
Boolean
need_district
,
@RequestParam
Boolean
need_layer
,
@RequestParam
String
area_fields
);
@PostMapping
(
"/saas/fendan/distribute/single"
)
public
SaasWebResult
single
(
@RequestParam
String
ak
,
@RequestParam
String
t
,
@RequestBody
FendanDTO
fendanDTO
);
}
}
project-order/src/main/java/com/dituhui/pea/order/service/BusinessLayerService.java
View file @
63344de
...
@@ -2,19 +2,22 @@ package com.dituhui.pea.order.service;
...
@@ -2,19 +2,22 @@ package com.dituhui.pea.order.service;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.dto.BusinessCustomLayerUpdateReqDTO
;
import
java.util.List
;
import
java.util.List
;
public
interface
BusinessLayerService
{
public
interface
BusinessLayerService
{
Result
<?>
businessLayerUniversal
();
Result
<?>
businessLayerUniversal
();
Result
<?>
businessCustomLayers
(
String
levelType
,
String
levelValue
,
int
page
,
int
size
);
Result
<?>
businessCustomLayers
(
String
levelType
,
String
levelValue
,
int
page
,
int
size
);
Result
<?>
businessCustomLayer
(
String
layerId
);
Result
<?>
businessCustomLayer
(
String
layerId
);
Result
<?>
businessCustomLayerAdd
(
String
branchId
,
String
layerName
,
String
layerDesc
,
List
<
String
>
skillCodes
);
Result
<?>
businessCustomLayerAdd
(
String
branchId
,
String
layerName
,
String
layerDesc
,
List
<
String
>
skillCodes
);
Result
<?>
businessCustomLayerUpdate
(
String
layerId
,
String
layerDesc
,
List
<
String
>
skillCodes
);
Result
<?>
businessCustomLayerUpdate
(
String
layerId
,
String
layerDesc
,
List
<
String
>
skillCodes
);
Result
<?>
businessCustomLayerRemove
(
String
layerId
);
Result
<?>
businessCustomLayerUpdate
(
BusinessCustomLayerUpdateReqDTO
reqDTO
);
Result
<?>
businessCustomLayerRemove
(
String
layerId
);
}
}
project-order/src/main/java/com/dituhui/pea/order/service/impl/BusinessLayerServiceImpl.java
View file @
63344de
...
@@ -7,6 +7,7 @@ import com.dituhui.pea.common.ResultEnum;
...
@@ -7,6 +7,7 @@ import com.dituhui.pea.common.ResultEnum;
import
com.dituhui.pea.order.common.ListUtils
;
import
com.dituhui.pea.order.common.ListUtils
;
import
com.dituhui.pea.order.dao.*
;
import
com.dituhui.pea.order.dao.*
;
import
com.dituhui.pea.order.dto.BusinessCustomLayerRespDTO
;
import
com.dituhui.pea.order.dto.BusinessCustomLayerRespDTO
;
import
com.dituhui.pea.order.dto.BusinessCustomLayerUpdateReqDTO
;
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
;
...
@@ -14,6 +15,7 @@ import com.dituhui.pea.order.service.BusinessLayerService;
...
@@ -14,6 +15,7 @@ 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
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.ObjectUtils
;
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.Page
;
...
@@ -33,258 +35,282 @@ import java.util.stream.Collectors;
...
@@ -33,258 +35,282 @@ import java.util.stream.Collectors;
@Service
@Service
public
class
BusinessLayerServiceImpl
implements
BusinessLayerService
{
public
class
BusinessLayerServiceImpl
implements
BusinessLayerService
{
@Value
(
"${SaaS.ak}"
)
@Value
(
"${SaaS.ak}"
)
String
ak
;
String
ak
;
@Autowired
@Autowired
private
MapLayerCustomizeDao
mapLayerCustomizeDao
;
private
MapLayerCustomizeDao
mapLayerCustomizeDao
;
@Autowired
@Autowired
private
MapLayerCustomizeSkillDao
mapLayerCustomizeSkillDao
;
private
MapLayerCustomizeSkillDao
mapLayerCustomizeSkillDao
;
@Autowired
@Autowired
private
OrgGroupDao
orgGroupDao
;
private
OrgGroupDao
orgGroupDao
;
@Autowired
@Autowired
private
OrgBranchDao
orgBranchDao
;
private
OrgBranchDao
orgBranchDao
;
@Autowired
@Autowired
private
SkillInfoDao
skillInfoDao
;
private
SkillInfoDao
skillInfoDao
;
@Autowired
@Autowired
private
ISaaSRemoteService
saasRemoteService
;
private
ISaaSRemoteService
saasRemoteService
;
@Autowired
@Autowired
private
MapBlockInfoDao
mapBlockInfoDao
;
private
MapBlockInfoDao
mapBlockInfoDao
;
@Autowired
@Autowired
private
EntityManager
entityManager
;
private
EntityManager
entityManager
;
@Autowired
@Autowired
private
MapLayerDao
mapLayerDao
;
private
MapLayerDao
mapLayerDao
;
@Override
@Override
public
Result
<?>
businessLayerUniversal
()
{
public
Result
<?>
businessLayerUniversal
()
{
List
<
MapLayerEntity
>
layers
=
mapLayerDao
.
findAll
();
List
<
MapLayerEntity
>
layers
=
mapLayerDao
.
findAll
();
return
Result
.
success
(
layers
);
return
Result
.
success
(
layers
);
}
}
@Override
@Override
public
Result
<?>
businessCustomLayers
(
String
levelType
,
String
levelValue
,
int
page
,
int
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
<>();
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
);
}
}
if
(
ListUtils
.
isEmpty
(
groups
))
{
if
(
ListUtils
.
isEmpty
(
groups
))
{
throw
new
BusinessException
(
"大区/分部/小组组织结构配置可能错误或缺失,请联系管理员/研发"
);
throw
new
BusinessException
(
"大区/分部/小组组织结构配置可能错误或缺失,请联系管理员/研发"
);
}
}
List
<
String
>
branchIds
=
new
ArrayList
<>(
groups
.
stream
().
map
(
OrgGroupEntity:
:
getBranchId
).
collect
(
Collectors
.
toSet
()));
List
<
String
>
branchIds
=
new
ArrayList
<>(
groups
.
stream
().
map
(
OrgGroupEntity:
:
getBranchId
).
collect
(
Collectors
.
toSet
()));
// 获取skillCode与skillName映射信息
// 获取skillCode与skillName映射信息
List
<
SkillInfoEntity
>
skills
=
skillInfoDao
.
findAll
();
List
<
SkillInfoEntity
>
skills
=
skillInfoDao
.
findAll
();
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
));
//获取分页列表
//获取分页列表
Specification
<
MapLayerCustomizeEntity
>
specification
=
(
root
,
query
,
criteriaBuilder
)
->
{
Specification
<
MapLayerCustomizeEntity
>
specification
=
(
root
,
query
,
criteriaBuilder
)
->
{
Predicate
statusPredicate
=
criteriaBuilder
.
equal
(
root
.
get
(
"status"
),
1
);
Predicate
statusPredicate
=
criteriaBuilder
.
equal
(
root
.
get
(
"status"
),
1
);
Predicate
branchIdPredicate
=
root
.
get
(
"branchId"
).
in
(
branchIds
);
Predicate
branchIdPredicate
=
root
.
get
(
"branchId"
).
in
(
branchIds
);
return
criteriaBuilder
.
and
(
statusPredicate
,
branchIdPredicate
);
return
criteriaBuilder
.
and
(
statusPredicate
,
branchIdPredicate
);
};
};
Sort
sort
=
Sort
.
by
(
Sort
.
Order
.
asc
(
"layerId"
));
Sort
sort
=
Sort
.
by
(
Sort
.
Order
.
asc
(
"layerId"
));
PageRequest
pageRequest
=
PageRequest
.
of
(
page
-
1
,
size
,
sort
);
PageRequest
pageRequest
=
PageRequest
.
of
(
page
-
1
,
size
,
sort
);
Page
<
MapLayerCustomizeEntity
>
pg
=
mapLayerCustomizeDao
.
findAll
(
specification
,
pageRequest
);
Page
<
MapLayerCustomizeEntity
>
pg
=
mapLayerCustomizeDao
.
findAll
(
specification
,
pageRequest
);
// pack
// pack
List
<
BusinessCustomLayersRespDTO
.
LayerItem
>
items
=
new
ArrayList
<>();
List
<
BusinessCustomLayersRespDTO
.
LayerItem
>
items
=
new
ArrayList
<>();
for
(
MapLayerCustomizeEntity
layer
:
pg
.
getContent
())
{
for
(
MapLayerCustomizeEntity
layer
:
pg
.
getContent
())
{
BusinessCustomLayersRespDTO
.
LayerItem
item
=
new
BusinessCustomLayersRespDTO
.
LayerItem
();
BusinessCustomLayersRespDTO
.
LayerItem
item
=
new
BusinessCustomLayersRespDTO
.
LayerItem
();
item
.
setLayerId
(
layer
.
getLayerId
());
item
.
setLayerId
(
layer
.
getLayerId
());
item
.
setLayerName
(
layer
.
getLayer
());
item
.
setLayerName
(
layer
.
getLayer
());
item
.
setLayerDesc
(
layer
.
getLayerDescribe
());
item
.
setLayerDesc
(
layer
.
getLayerDescribe
());
OrgBranchEntity
branch
=
orgBranchDao
.
getByBranchId
(
layer
.
getBranchId
());
OrgBranchEntity
branch
=
orgBranchDao
.
getByBranchId
(
layer
.
getBranchId
());
if
(
branch
!=
null
)
{
if
(
branch
!=
null
)
{
item
.
setBranchName
(
branch
.
getBranchName
());
item
.
setBranchName
(
branch
.
getBranchName
());
}
}
List
<
String
>
skillItems
=
this
.
queryLayerSkill
(
layer
.
getLayerId
());
List
<
String
>
skillItems
=
this
.
queryLayerSkill
(
layer
.
getLayerId
());
item
.
setSkillNum
(
skillItems
.
size
());
item
.
setSkillNum
(
skillItems
.
size
());
List
<
String
>
skillNames
=
skillItems
.
stream
().
map
(
s
->
skillMapping
.
getOrDefault
(
s
,
""
)).
collect
(
Collectors
.
toList
());
List
<
String
>
skillNames
=
skillItems
.
stream
().
map
(
s
->
skillMapping
.
getOrDefault
(
s
,
""
)).
collect
(
Collectors
.
toList
());
String
skillDesc
=
String
.
join
(
"、"
,
new
ArrayList
<>(
new
HashSet
<>(
skillNames
)));
String
skillDesc
=
String
.
join
(
"、"
,
new
ArrayList
<>(
new
HashSet
<>(
skillNames
)));
item
.
setSkillList
(
skillDesc
);
item
.
setSkillList
(
skillDesc
);
items
.
add
(
item
);
items
.
add
(
item
);
}
}
BusinessCustomLayersRespDTO
res
=
new
BusinessCustomLayersRespDTO
();
BusinessCustomLayersRespDTO
res
=
new
BusinessCustomLayersRespDTO
();
res
.
setTotal
(
pg
.
getTotalElements
());
res
.
setTotal
(
pg
.
getTotalElements
());
res
.
setPages
(
pg
.
getTotalPages
());
res
.
setPages
(
pg
.
getTotalPages
());
res
.
setPageCurrent
(
pg
.
getNumber
()
+
1
);
res
.
setPageCurrent
(
pg
.
getNumber
()
+
1
);
res
.
setPageSize
(
pg
.
getSize
());
res
.
setPageSize
(
pg
.
getSize
());
res
.
setContent
(
items
);
res
.
setContent
(
items
);
return
Result
.
success
(
res
);
return
Result
.
success
(
res
);
}
}
@Override
@Override
public
Result
<?>
businessCustomLayer
(
String
layerId
)
{
public
Result
<?>
businessCustomLayer
(
String
layerId
)
{
MapLayerCustomizeEntity
layer
=
mapLayerCustomizeDao
.
getByLayerId
(
layerId
);
MapLayerCustomizeEntity
layer
=
mapLayerCustomizeDao
.
getByLayerId
(
layerId
);
if
(
layer
==
null
)
{
if
(
layer
==
null
)
{
throw
new
BusinessException
(
"图层不存在"
);
throw
new
BusinessException
(
"图层不存在"
);
}
}
// 获取技能code列表
// 获取技能code列表
List
<
MapLayerCustomizeSkillEntity
>
skills
=
mapLayerCustomizeSkillDao
.
findByLayerId
(
layerId
);
List
<
MapLayerCustomizeSkillEntity
>
skills
=
mapLayerCustomizeSkillDao
.
findByLayerId
(
layerId
);
List
<
String
>
skillCodes
=
skills
.
stream
().
filter
(
s
->
s
.
getStatus
()
==
1
).
map
(
List
<
String
>
skillCodes
=
skills
.
stream
().
filter
(
s
->
s
.
getStatus
()
==
1
).
map
(
MapLayerCustomizeSkillEntity:
:
getSkillCode
).
collect
(
Collectors
.
toList
());
MapLayerCustomizeSkillEntity:
:
getSkillCode
).
collect
(
Collectors
.
toList
());
// 获取branchName
// 获取branchName
String
branchName
=
""
;
String
branchName
=
""
;
OrgBranchEntity
branch
=
orgBranchDao
.
getByBranchId
(
layer
.
getBranchId
());
OrgBranchEntity
branch
=
orgBranchDao
.
getByBranchId
(
layer
.
getBranchId
());
if
(
branch
!=
null
)
{
if
(
branch
!=
null
)
{
branchName
=
branch
.
getBranchName
();
branchName
=
branch
.
getBranchName
();
}
}
BusinessCustomLayerRespDTO
resp
=
new
BusinessCustomLayerRespDTO
();
BusinessCustomLayerRespDTO
resp
=
new
BusinessCustomLayerRespDTO
();
resp
.
setLayerId
(
layerId
);
resp
.
setLayerId
(
layerId
);
resp
.
setLayerName
(
layer
.
getLayer
());
resp
.
setLayerName
(
layer
.
getLayer
());
resp
.
setLayerDesc
(
layer
.
getLayerDescribe
());
resp
.
setLayerDesc
(
layer
.
getLayerDescribe
());
resp
.
setBranchId
(
layer
.
getBranchId
());
resp
.
setBranchId
(
layer
.
getBranchId
());
resp
.
setBranchName
(
branchName
);
resp
.
setBranchName
(
branchName
);
resp
.
setSkills
(
skillCodes
);
resp
.
setSkills
(
skillCodes
);
resp
.
setPriority
(
layer
.
getPriority
());
return
Result
.
success
(
resp
);
}
return
Result
.
success
(
resp
);
}
@Transactional
@Override
@Transactional
public
Result
<?>
businessCustomLayerAdd
(
String
branchId
,
String
layerName
,
String
layerDesc
,
List
<
String
>
skillCodes
)
{
@Override
public
Result
<?>
businessCustomLayerAdd
(
String
branchId
,
String
layerName
,
String
layerDesc
,
List
<
String
>
skillCodes
)
{
if
(
orgBranchDao
.
getByBranchId
(
branchId
)
==
null
)
{
throw
new
BusinessException
(
"分部参数错误,请联系管理员/研发"
);
if
(
orgBranchDao
.
getByBranchId
(
branchId
)
==
null
)
{
}
throw
new
BusinessException
(
"分部参数错误,请联系管理员/研发"
);
}
// 同步创建saas图层,返回layerId
String
result
=
saasRemoteService
.
addLayer
(
ak
,
layerName
,
1
,
1
);
// 同步创建saas图层,返回layerId
log
.
info
(
"addLayer params:{} result:{}"
,
layerName
,
result
);
String
result
=
saasRemoteService
.
addLayer
(
ak
,
layerName
,
1
,
1
);
Result
<
LinkedTreeMap
<
String
,
Object
>>
saasResult
=
TypeUtils
.
convertResult
(
result
);
log
.
info
(
"addLayer params:{} result:{}"
,
layerName
,
result
);
if
(!
ResultEnum
.
SUCCESS
.
getCode
().
equals
(
saasResult
.
getCode
()))
{
Result
<
LinkedTreeMap
<
String
,
Object
>>
saasResult
=
TypeUtils
.
convertResult
(
result
);
return
Result
.
failure
(
saasResult
.
getMessage
());
if
(!
ResultEnum
.
SUCCESS
.
getCode
().
equals
(
saasResult
.
getCode
()))
{
}
return
Result
.
failure
(
saasResult
.
getMessage
());
String
saasLayerId
=
(
String
)
saasResult
.
getResult
().
get
(
"id"
);
// 存入pea
}
String
saasLayerId
=
(
String
)
saasResult
.
getResult
().
get
(
"id"
);
// 存入pea
String
layerId
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
String
layerId
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
// 入库保存
MapLayerCustomizeEntity
m
=
new
MapLayerCustomizeEntity
();
// 入库保存
m
.
setLayerId
(
layerId
);
MapLayerCustomizeEntity
m
=
new
MapLayerCustomizeEntity
();
m
.
setSaasLayerId
(
saasLayerId
);
m
.
setLayerId
(
layerId
);
m
.
setLayer
(
layerName
);
m
.
setSaasLayerId
(
saasLayerId
);
m
.
setLayerDescribe
(
layerDesc
);
m
.
setLayer
(
layerName
);
m
.
setBranchId
(
branchId
);
m
.
setLayerDescribe
(
layerDesc
);
m
.
setStatus
(
1
);
m
.
setBranchId
(
branchId
);
m
.
setCreateTime
(
LocalDateTime
.
now
());
m
.
setStatus
(
1
);
entityManager
.
persist
(
m
);
m
.
setCreateTime
(
LocalDateTime
.
now
());
entityManager
.
persist
(
m
);
// 更新技能
this
.
updateLayerSkills
(
layerId
,
new
HashSet
<>(
skillCodes
));
// 更新技能
this
.
updateLayerSkills
(
layerId
,
new
HashSet
<>(
skillCodes
));
return
Result
.
success
(
null
);
}
return
Result
.
success
(
null
);
}
@Transactional
@Override
@Transactional
public
Result
<?>
businessCustomLayerUpdate
(
String
layerId
,
String
layerDesc
,
List
<
String
>
skillCodes
)
throws
BusinessException
{
@Override
public
Result
<?>
businessCustomLayerUpdate
(
String
layerId
,
String
layerDesc
,
List
<
String
>
skillCodes
)
throws
BusinessException
{
MapLayerCustomizeEntity
layer
=
mapLayerCustomizeDao
.
getByLayerId
(
layerId
);
if
(
layer
==
null
)
{
MapLayerCustomizeEntity
layer
=
mapLayerCustomizeDao
.
getByLayerId
(
layerId
);
throw
new
BusinessException
(
"图层不存在"
);
if
(
layer
==
null
)
{
}
throw
new
BusinessException
(
"图层不存在"
);
// 更新描述信息
}
layer
.
setLayerDescribe
(
layerDesc
);
// 更新描述信息
entityManager
.
merge
(
layer
);
layer
.
setLayerDescribe
(
layerDesc
);
entityManager
.
merge
(
layer
);
// 更新技能
this
.
updateLayerSkills
(
layerId
,
new
HashSet
<>(
skillCodes
));
// 更新技能
this
.
updateLayerSkills
(
layerId
,
new
HashSet
<>(
skillCodes
));
return
Result
.
success
(
null
);
}
return
Result
.
success
(
null
);
}
@Override
public
Result
<?>
businessCustomLayerRemove
(
String
layerId
)
throws
BusinessException
{
@Transactional
MapLayerCustomizeEntity
layer
=
mapLayerCustomizeDao
.
getByLayerId
(
layerId
);
@Override
if
(
layer
==
null
)
{
public
Result
<?>
businessCustomLayerUpdate
(
BusinessCustomLayerUpdateReqDTO
reqDTO
)
throws
BusinessException
{
throw
new
BusinessException
(
"图层不存在"
);
}
MapLayerCustomizeEntity
layer
=
mapLayerCustomizeDao
.
getByLayerId
(
reqDTO
.
getLayerId
());
if
(
layer
==
null
)
{
// 检查下面是否还有区块
throw
new
BusinessException
(
"图层不存在"
);
List
<
MapBlockInfoEntity
>
blocks
=
mapBlockInfoDao
.
findByLayerId
(
layerId
);
}
if
(
CollectionUtils
.
isNotEmpty
(
blocks
))
{
// 更新描述信息
return
Result
.
failure
(
"该图层下面还有区块"
);
layer
.
setLayerDescribe
(
reqDTO
.
getLayerDesc
());
}
if
(
ObjectUtils
.
isNotEmpty
(
reqDTO
))
{
layer
.
setPriority
(
reqDTO
.
getPriority
());
// 同步删除saas图层
}
String
result
=
saasRemoteService
.
deleteLayer
(
ak
,
layer
.
getSaasLayerId
());
layer
.
setLayerDescribe
(
reqDTO
.
getLayerDesc
());
log
.
info
(
"deleteLayer params:{} result:{}"
,
layerId
,
result
);
entityManager
.
merge
(
layer
);
Result
<
Boolean
>
saasResult
=
TypeUtils
.
convertResult
(
result
);
if
(!
ResultEnum
.
SUCCESS
.
getCode
().
equals
(
saasResult
.
getCode
()))
{
// 更新技能
return
Result
.
failure
(
saasResult
.
getMessage
());
this
.
updateLayerSkills
(
reqDTO
.
getLayerId
(),
new
HashSet
<>(
reqDTO
.
getSkills
()));
}
return
Result
.
success
(
null
);
// 更新状态为删除状态
}
layer
.
setStatus
(
0
);
entityManager
.
merge
(
layer
);
@Override
public
Result
<?>
businessCustomLayerRemove
(
String
layerId
)
throws
BusinessException
{
return
Result
.
success
(
null
);
}
MapLayerCustomizeEntity
layer
=
mapLayerCustomizeDao
.
getByLayerId
(
layerId
);
if
(
layer
==
null
)
{
private
void
updateLayerSkills
(
String
layerId
,
Set
<
String
>
skillCodes
)
{
throw
new
BusinessException
(
"图层不存在"
);
// 更新技能信息
}
// 更新状态为0
// 检查下面是否还有区块
mapLayerCustomizeSkillDao
.
updateStatusByLayerId
(
0
,
layerId
);
List
<
MapBlockInfoEntity
>
blocks
=
mapBlockInfoDao
.
findByLayerId
(
layerId
);
if
(
CollectionUtils
.
isNotEmpty
(
blocks
))
{
List
<
MapLayerCustomizeSkillEntity
>
skills
=
mapLayerCustomizeSkillDao
.
findByLayerId
(
layerId
);
return
Result
.
failure
(
"该图层下面还有区块"
);
Set
<
String
>
db
=
skills
.
stream
().
map
(
MapLayerCustomizeSkillEntity:
:
getSkillCode
).
collect
(
Collectors
.
toSet
());
}
// 需要更新为有效的
// 同步删除saas图层
Set
<
String
>
updates
=
new
HashSet
<>(
db
);
String
result
=
saasRemoteService
.
deleteLayer
(
ak
,
layer
.
getSaasLayerId
());
updates
.
retainAll
(
skillCodes
);
log
.
info
(
"deleteLayer params:{} result:{}"
,
layerId
,
result
);
if
(!
updates
.
isEmpty
())
{
Result
<
Boolean
>
saasResult
=
TypeUtils
.
convertResult
(
result
);
mapLayerCustomizeSkillDao
.
updateStatusByLayerIdAndSkillCodeIn
(
1
,
layerId
,
new
ArrayList
<>(
updates
));
if
(!
ResultEnum
.
SUCCESS
.
getCode
().
equals
(
saasResult
.
getCode
()))
{
}
return
Result
.
failure
(
saasResult
.
getMessage
());
}
// 需要新增插入的
Set
<
String
>
adds
=
new
HashSet
<>(
skillCodes
);
// 更新状态为删除状态
adds
.
removeAll
(
db
);
layer
.
setStatus
(
0
);
for
(
String
skillCode
:
adds
)
{
entityManager
.
merge
(
layer
);
MapLayerCustomizeSkillEntity
c
=
new
MapLayerCustomizeSkillEntity
();
c
.
setLayerId
(
layerId
);
return
Result
.
success
(
null
);
c
.
setSkillCode
(
skillCode
);
}
c
.
setStatus
(
1
);
c
.
setMemo
(
""
);
private
void
updateLayerSkills
(
String
layerId
,
Set
<
String
>
skillCodes
)
{
c
.
setCreateTime
(
LocalDateTime
.
now
());
// 更新技能信息
entityManager
.
persist
(
c
);
}
// 更新状态为0
}
mapLayerCustomizeSkillDao
.
updateStatusByLayerId
(
0
,
layerId
);
private
List
<
String
>
queryLayerSkill
(
String
layerId
)
{
List
<
MapLayerCustomizeSkillEntity
>
skills
=
mapLayerCustomizeSkillDao
.
findByLayerId
(
layerId
);
List
<
String
>
items
=
new
ArrayList
<>();
Set
<
String
>
db
=
skills
.
stream
().
map
(
MapLayerCustomizeSkillEntity:
:
getSkillCode
).
collect
(
Collectors
.
toSet
());
List
<
SkillInfoEntity
>
skills
=
skillInfoDao
.
findAll
();
// 需要更新为有效的
Map
<
String
,
String
>
skillMap
=
skills
.
stream
().
collect
(
Collectors
.
toMap
(
Set
<
String
>
updates
=
new
HashSet
<>(
db
);
SkillInfoEntity:
:
getSkillCode
,
SkillInfoEntity:
:
getSkill
));
updates
.
retainAll
(
skillCodes
);
if
(!
updates
.
isEmpty
())
{
List
<
MapLayerCustomizeSkillEntity
>
laySkills
=
mapLayerCustomizeSkillDao
.
findByLayerId
(
layerId
);
mapLayerCustomizeSkillDao
.
updateStatusByLayerIdAndSkillCodeIn
(
1
,
layerId
,
new
ArrayList
<>(
updates
));
for
(
MapLayerCustomizeSkillEntity
s
:
laySkills
)
{
}
if
(
s
.
getStatus
()
==
0
)
{
continue
;
// 需要新增插入的
}
Set
<
String
>
adds
=
new
HashSet
<>(
skillCodes
);
String
skill
=
skillMap
.
getOrDefault
(
s
.
getSkillCode
(),
""
);
adds
.
removeAll
(
db
);
items
.
add
(
skill
);
for
(
String
skillCode
:
adds
)
{
}
MapLayerCustomizeSkillEntity
c
=
new
MapLayerCustomizeSkillEntity
();
return
items
;
c
.
setLayerId
(
layerId
);
}
c
.
setSkillCode
(
skillCode
);
c
.
setStatus
(
1
);
c
.
setMemo
(
""
);
c
.
setCreateTime
(
LocalDateTime
.
now
());
entityManager
.
persist
(
c
);
}
}
private
List
<
String
>
queryLayerSkill
(
String
layerId
)
{
List
<
String
>
items
=
new
ArrayList
<>();
List
<
SkillInfoEntity
>
skills
=
skillInfoDao
.
findAll
();
Map
<
String
,
String
>
skillMap
=
skills
.
stream
().
collect
(
Collectors
.
toMap
(
SkillInfoEntity:
:
getSkillCode
,
SkillInfoEntity:
:
getSkill
));
List
<
MapLayerCustomizeSkillEntity
>
laySkills
=
mapLayerCustomizeSkillDao
.
findByLayerId
(
layerId
);
for
(
MapLayerCustomizeSkillEntity
s
:
laySkills
)
{
if
(
s
.
getStatus
()
==
0
)
{
continue
;
}
String
skill
=
skillMap
.
getOrDefault
(
s
.
getSkillCode
(),
""
);
items
.
add
(
skill
);
}
return
items
;
}
}
}
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