Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
platform
/
platform-process-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit b6bc4379
authored
Dec 22, 2023
by
谢海旭
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
触达方式查询、圈人方式查询、新增模板 接口
1 parent
08f066f7
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
527 additions
and
9 deletions
platform-process-api/src/main/java/cn/com/glsx/process/modules/entity/SopDataType.java
platform-process-api/src/main/java/cn/com/glsx/process/modules/entity/SopTplNode.java
platform-process-api/src/main/java/cn/com/glsx/process/modules/entity/SopTplNodeProto.java
platform-process-api/src/main/java/cn/com/glsx/process/modules/mapper/SopDataTypeMapper.java
platform-process-api/src/main/java/cn/com/glsx/process/modules/mapper/SopTplNodeProtoMapper.java
platform-process-api/src/main/java/cn/com/glsx/process/modules/model/SopTplNodeProtoSearch.java
platform-process/src/main/java/cn/com/glsx/process/modules/assembler/KeHuLvChengAssembler.java
platform-process/src/main/java/cn/com/glsx/process/modules/controller/SopDataTypeController.java
platform-process/src/main/java/cn/com/glsx/process/modules/controller/SopTplController.java
platform-process/src/main/java/cn/com/glsx/process/modules/controller/SopTplNodeProtoController.java
platform-process/src/main/java/cn/com/glsx/process/modules/converter/SopTplNodeProtoConverter.java
platform-process/src/main/java/cn/com/glsx/process/modules/service/SopDataTypeService.java
platform-process/src/main/java/cn/com/glsx/process/modules/service/SopTplNodeProtoService.java
platform-process/src/main/java/cn/com/glsx/process/modules/service/SopTplService.java
platform-process/src/main/java/cn/com/glsx/process/util/JacksonUtil.java
platform-process/src/main/resources/mapper/SopTplNodeProtoMapper.xml
platform-process-api/src/main/java/cn/com/glsx/process/modules/entity/SopDataType.java
View file @
b6bc437
...
@@ -12,6 +12,7 @@ public class SopDataType {
...
@@ -12,6 +12,7 @@ public class SopDataType {
/**
/**
* 名称
* 名称
*/
*/
@Column
(
name
=
"`name`"
)
private
String
name
;
private
String
name
;
/**
/**
...
@@ -27,12 +28,13 @@ public class SopDataType {
...
@@ -27,12 +28,13 @@ public class SopDataType {
/**
/**
* 圈人方式简介
* 圈人方式简介
*/
*/
@Column
(
name
=
"`desc`"
)
private
String
desc
;
private
String
desc
;
@Column
(
name
=
"updated_time"
)
@Column
(
name
=
"updated_time"
,
insertable
=
false
,
updatable
=
false
)
private
Date
updatedTime
;
private
Date
updatedTime
;
@Column
(
name
=
"created_time"
)
@Column
(
name
=
"created_time"
,
insertable
=
false
,
updatable
=
false
)
private
Date
createdTime
;
private
Date
createdTime
;
/**
/**
...
...
platform-process-api/src/main/java/cn/com/glsx/process/modules/entity/SopTplNode.java
View file @
b6bc437
...
@@ -14,6 +14,12 @@ public class SopTplNode {
...
@@ -14,6 +14,12 @@ public class SopTplNode {
@Column
(
name
=
"id"
)
@Column
(
name
=
"id"
)
private
Integer
id
;
private
Integer
id
;
/**
* 模板节点原型id
*/
@Column
(
name
=
"node_proto_id"
)
private
Integer
nodeProtoId
;
@Column
(
name
=
"node_id"
)
@Column
(
name
=
"node_id"
)
private
Integer
nodeId
;
private
Integer
nodeId
;
...
@@ -115,6 +121,14 @@ public class SopTplNode {
...
@@ -115,6 +121,14 @@ public class SopTplNode {
this
.
id
=
id
;
this
.
id
=
id
;
}
}
public
Integer
getNodeProtoId
()
{
return
nodeProtoId
;
}
public
void
setNodeProtoId
(
Integer
nodeProtoId
)
{
this
.
nodeProtoId
=
nodeProtoId
;
}
/**
/**
* 获取节点id
* 获取节点id
*
*
...
...
platform-process-api/src/main/java/cn/com/glsx/process/modules/entity/SopTplNodeProto.java
View file @
b6bc437
...
@@ -96,18 +96,19 @@ public class SopTplNodeProto {
...
@@ -96,18 +96,19 @@ public class SopTplNodeProto {
/**
/**
* 节点描述
* 节点描述
*/
*/
@Column
(
name
=
"`desc`"
)
private
String
desc
;
private
String
desc
;
/**
/**
* 更新时间
* 更新时间
*/
*/
@Column
(
name
=
"updated_time"
)
@Column
(
name
=
"updated_time"
,
insertable
=
false
,
updatable
=
false
)
private
Date
updatedTime
;
private
Date
updatedTime
;
/**
/**
* 创建时间
* 创建时间
*/
*/
@Column
(
name
=
"created_time"
)
@Column
(
name
=
"created_time"
,
insertable
=
false
,
updatable
=
false
)
private
Date
createdTime
;
private
Date
createdTime
;
/**
/**
...
...
platform-process-api/src/main/java/cn/com/glsx/process/modules/mapper/SopDataTypeMapper.java
View file @
b6bc437
...
@@ -2,6 +2,8 @@ package cn.com.glsx.process.modules.mapper;
...
@@ -2,6 +2,8 @@ package cn.com.glsx.process.modules.mapper;
import
cn.com.glsx.process.modules.entity.SopDataType
;
import
cn.com.glsx.process.modules.entity.SopDataType
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
@Mapper
public
interface
SopDataTypeMapper
extends
CommonBaseMapper
<
SopDataType
>
{
public
interface
SopDataTypeMapper
extends
CommonBaseMapper
<
SopDataType
>
{
}
}
\ No newline at end of file
\ No newline at end of file
platform-process-api/src/main/java/cn/com/glsx/process/modules/mapper/SopTplNodeProtoMapper.java
View file @
b6bc437
...
@@ -2,6 +2,11 @@ package cn.com.glsx.process.modules.mapper;
...
@@ -2,6 +2,11 @@ package cn.com.glsx.process.modules.mapper;
import
cn.com.glsx.process.modules.entity.SopTplNodeProto
;
import
cn.com.glsx.process.modules.entity.SopTplNodeProto
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
java.util.List
;
@Mapper
public
interface
SopTplNodeProtoMapper
extends
CommonBaseMapper
<
SopTplNodeProto
>
{
public
interface
SopTplNodeProtoMapper
extends
CommonBaseMapper
<
SopTplNodeProto
>
{
List
<
SopTplNodeProto
>
list
(
SopTplNodeProto
search
);
}
}
\ No newline at end of file
\ No newline at end of file
platform-process-api/src/main/java/cn/com/glsx/process/modules/model/SopTplNodeProtoSearch.java
0 → 100644
View file @
b6bc437
package
cn
.
com
.
glsx
.
process
.
modules
.
model
;
import
cn.hutool.db.Page
;
/**
* @Title:
* @Description:
* @Author xiehx
* @Date 2023/12/21
**/
public
class
SopTplNodeProtoSearch
extends
Page
{
@Override
public
int
getPageNumber
()
{
int
pageNumber
=
super
.
getPageNumber
();
return
pageNumber
==
0
?
1
:
pageNumber
;
}
}
platform-process/src/main/java/cn/com/glsx/process/modules/assembler/KeHuLvChengAssembler.java
0 → 100644
View file @
b6bc437
package
cn
.
com
.
glsx
.
process
.
modules
.
assembler
;
import
cn.com.glsx.process.common.sysenum.ResultEnum
;
import
cn.com.glsx.process.exception.AdminException
;
import
cn.com.glsx.process.modules.converter.SopTplNodeProtoConverter
;
import
cn.com.glsx.process.modules.entity.SopTplLink
;
import
cn.com.glsx.process.modules.entity.SopTplNode
;
import
cn.com.glsx.process.modules.entity.SopTplNodeProto
;
import
cn.com.glsx.process.modules.mapper.SopTplNodeProtoMapper
;
import
cn.com.glsx.process.modules.model.SopTplDTO
;
import
cn.com.glsx.process.util.JacksonUtil
;
import
cn.com.glsx.process.util.JacksonUtils
;
import
cn.hutool.core.util.StrUtil
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.glsx.plat.common.utils.SnowFlake
;
import
com.google.common.collect.Lists
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
tk.mybatis.mapper.entity.Example
;
import
tk.mybatis.mapper.util.Sqls
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
* @Title:
* @Description:
* @Author xiehx
* @Date 2023/12/21
**/
@Slf4j
@Component
public
class
KeHuLvChengAssembler
{
@Autowired
private
SopTplNodeProtoMapper
sopTplNodeProtoMapper
;
/**
* 客户旅程模板组装
*
* @param sopTplDTO
*/
public
void
assemble
(
SopTplDTO
sopTplDTO
)
{
String
tplParamDef
=
sopTplDTO
.
getTplParamDef
();
String
dataTypeCode
=
JacksonUtil
.
getStrValueInJsonStrByPath
(
tplParamDef
,
"dataTypeCode/defaultValue"
);
String
stagesStr
=
JacksonUtil
.
getStrValueInJsonStrByPath
(
tplParamDef
,
"stages/defaultValue"
);
sopTplDTO
.
setTplId
(
StrUtil
.
sub
(
SnowFlake
.
nextSerialNumber
(),
0
,
8
));
sopTplDTO
.
setTplCron
(
"10 20 7 * * ?"
);
sopTplDTO
.
setTplRemark
(
"运营端新增模板"
);
sopTplDTO
.
setTplStatus
((
byte
)
1
);
sopTplDTO
.
setTplSingleton
((
byte
)
1
);
sopTplDTO
.
setTplParamDef
(
JacksonUtil
.
jsonStrDeepSub
(
getTplParamDef
(
dataTypeCode
),
tplParamDef
));
List
<
SopTplNodeProto
>
tplNodeProtos
=
sopTplNodeProtoMapper
.
selectByExample
(
Example
.
builder
(
SopTplNodeProto
.
class
).
where
(
Sqls
.
custom
().
andEqualTo
(
"dataTypeCode"
,
dataTypeCode
).
orIsNull
(
"dataTypeCode"
)).
build
());
if
(
CollectionUtils
.
isEmpty
(
tplNodeProtos
)
||
tplNodeProtos
.
size
()
<
3
)
{
log
.
error
(
"客户旅程 模板node节点原型配置错误,该模板至少三种节点原型"
);
throw
new
AdminException
(
ResultEnum
.
PARAM_ERROR
.
getCode
(),
"模板node节点原型配置错误"
);
}
//给模板node节点标记位置标识即模板中唯一标识
int
tplNodeLastNum
=
1
;
List
<
SopTplNode
>
tplNodes
=
Lists
.
newArrayList
();
List
<
SopTplLink
>
tplNodeLinks
=
Lists
.
newArrayList
();
//选择对应开始节点
SopTplNodeProto
startProto
=
getGroupFirstProto
(
tplNodeProtos
,
dataTypeCode
,
"start"
);
SopTplNodeProtoConverter
protoConverter
=
SopTplNodeProtoConverter
.
INSTANCE
;
SopTplNode
startTplNode
=
protoConverter
.
proto2tpl
(
startProto
);
startTplNode
.
setNodeId
(
tplNodeLastNum
++);
tplNodes
.
add
(
startTplNode
);
//选择圈人节点
SopTplNodeProto
getDataProto
=
getGroupFirstProto
(
tplNodeProtos
,
dataTypeCode
,
"get_data"
);
SopTplNode
getDataTplNode
=
protoConverter
.
proto2tpl
(
getDataProto
);
getDataTplNode
.
setNodeId
(
tplNodeLastNum
++);
tplNodes
.
add
(
getDataTplNode
);
addLink
(
startTplNode
,
getDataTplNode
,
tplNodeLinks
);
if
(
StringUtils
.
hasLength
(
stagesStr
))
{
//有阶段
SopTplNodeProto
stageProto
=
getGroupFirstProto
(
tplNodeProtos
,
dataTypeCode
,
"stage"
);
Map
<
String
,
Map
<
String
,
Object
>>
stages
=
JacksonUtils
.
fromJson
(
stagesStr
,
new
TypeReference
<
Map
<
String
,
Map
<
String
,
Object
>>>()
{});;
//阶段与其生成的节点的对应关系
HashMap
<
String
,
SopTplNode
>
stageNodeMap
=
new
HashMap
<>();
//创建阶段对应的节点
String
stageNodeParamDefModel
=
"{\\\"stage\\\":{\\\"paramKey\\\":\\\"stage\\\",\\\"defaultValue\\\":\\\"潜在客户\\\",\\\"required\\\":true,\\\"paramDesc\\\":\\\"stage\\\",\\\"valueType\\\":\\\"String\\\"}}"
;
for
(
String
key
:
stages
.
keySet
())
{
Map
<
String
,
Object
>
stageSettingMap
=
stages
.
get
(
key
);
String
stageValue
=
(
String
)
stageSettingMap
.
get
(
"value"
);
//TODO 可能需要定义node的key属性
SopTplNode
stageNode
=
protoConverter
.
proto2tpl
(
stageProto
);
stageNode
.
setNodeId
(
tplNodeLastNum
++);
stageNode
.
setNodeParamDef
(
JacksonUtil
.
jsonStrDeepSub
(
stageNodeParamDefModel
,
String
.
format
(
"{\\\"stage\\\":{\\\"defaultValue\\\":\\\"%s\\\"}}"
,
stageValue
)));
tplNodes
.
add
(
stageNode
);
addLink
(
getDataTplNode
,
stageNode
,
tplNodeLinks
);
stageNodeMap
.
put
(
stageValue
,
stageNode
);
}
List
<
SopTplNode
>
notifyNodes
=
sopTplDTO
.
getNodes
();
List
<
SopTplNode
>
beforeUpdateStageNodes
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
notifyNodes
))
{
Map
<
Integer
,
SopTplNodeProto
>
nodeProtoMap
=
tplNodeProtos
.
stream
().
filter
(
nodeProto
->
nodeProto
.
getGroupCode
().
equals
(
"notify"
))
.
collect
(
Collectors
.
toMap
(
SopTplNodeProto:
:
getId
,
nodeProto
->
nodeProto
));
for
(
String
key
:
stageNodeMap
.
keySet
())
{
// 阶段下的节点
List
<
SopTplNode
>
stageNotifyNodes
=
notifyNodes
.
stream
().
filter
(
sopTplNode
->
{
String
nodeStage
=
JacksonUtil
.
getStrValueInJsonStrByPath
(
sopTplNode
.
getNodeParamDef
(),
"stage/stages"
);
return
key
.
equals
(
nodeStage
);
}).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isEmpty
(
stageNotifyNodes
))
{
beforeUpdateStageNodes
.
add
(
stageNodeMap
.
get
(
key
));
}
else
{
for
(
SopTplNode
sopTplNode
:
stageNotifyNodes
)
{
SopTplNodeProto
sopTplNodeProto
=
nodeProtoMap
.
get
(
sopTplNode
.
getNodeProtoId
());
SopTplNode
notifyTplNode
=
protoConverter
.
proto2tpl
(
sopTplNodeProto
);
notifyTplNode
.
setNodeId
(
tplNodeLastNum
++);
notifyTplNode
.
setNodeParamDef
(
JacksonUtil
.
jsonStrDeepSub
(
notifyTplNode
.
getNodeParamDef
(),
sopTplNode
.
getNodeParamDef
()));
tplNodes
.
add
(
notifyTplNode
);
addLink
(
stageNodeMap
.
get
(
key
),
notifyTplNode
,
tplNodeLinks
);
beforeUpdateStageNodes
.
add
(
notifyTplNode
);
}
}
}
}
else
{
stageNodeMap
.
keySet
().
forEach
(
key
->
beforeUpdateStageNodes
.
add
(
stageNodeMap
.
get
(
key
)));
}
SopTplNodeProto
updateStageProto
=
getGroupFirstProto
(
tplNodeProtos
,
dataTypeCode
,
"update_stage"
);
SopTplNode
updateStageTplNode
=
protoConverter
.
proto2tpl
(
updateStageProto
);
updateStageTplNode
.
setNodeId
(
tplNodeLastNum
++);
tplNodes
.
add
(
updateStageTplNode
);
beforeUpdateStageNodes
.
forEach
(
sopTplNode
->
addLink
(
sopTplNode
,
updateStageTplNode
,
tplNodeLinks
));
// 添加结束节点
SopTplNodeProto
endProto
=
getGroupFirstProto
(
tplNodeProtos
,
dataTypeCode
,
"end"
);
SopTplNode
endTplNode
=
protoConverter
.
proto2tpl
(
endProto
);
endTplNode
.
setNodeId
(
tplNodeLastNum
++);
tplNodes
.
add
(
endTplNode
);
addLink
(
updateStageTplNode
,
endTplNode
,
tplNodeLinks
);
}
else
{
// 无阶段
// 添加结束节点
SopTplNodeProto
endProto
=
getGroupFirstProto
(
tplNodeProtos
,
dataTypeCode
,
"end"
);
SopTplNode
endTplNode
=
protoConverter
.
proto2tpl
(
endProto
);
endTplNode
.
setNodeId
(
tplNodeLastNum
++);
tplNodes
.
add
(
endTplNode
);
addLink
(
getDataTplNode
,
endTplNode
,
tplNodeLinks
);
}
}
/**
* 根据圈人方式获取预定义初始化参数 tplParamDef
*
* @param dataTypeCode
* @return
*/
private
String
getTplParamDef
(
String
dataTypeCode
)
{
if
(
"xbpzj"
.
equals
(
dataTypeCode
))
{
return
"{\\\"customData\\\":{\\\"paramKey\\\":\\\"customData\\\",\\\"defaultValue\\\":{\\\"textMessage\\\":null,\\\"activityName\\\":null,\\\"activityId\\\":null,\\\"activityUrl\\\":null,\\\"aiSpeech\\\":null},\\\"required\\\":true,\\\"paramDesc\\\":\\\"customData\\\",\\\"valueType\\\":\\\"Map\\\"},\\\"merchantId\\\":{\\\"paramKey\\\":\\\"merchantId\\\",\\\"defaultValue\\\":\\\"\\\",\\\"required\\\":true,\\\"paramDesc\\\":\\\"merchantId\\\",\\\"valueType\\\":\\\"String\\\"},\\\"stages\\\":{\\\"paramKey\\\":\\\"stages\\\",\\\"defaultValue\\\":{},\\\"required\\\":true,\\\"paramDesc\\\":\\\"stages\\\",\\\"valueType\\\":\\\"Map\\\"},\\\"dataTypeCode\\\":{\\\"paramKey\\\":\\\"dataTypeCode\\\",\\\"defaultValue\\\":\\\"圈人方式标识码\\\",\\\"required\\\":true,\\\"paramDesc\\\":\\\"dataTypeCode\\\",\\\"valueType\\\":\\\"String\\\"}}"
;
}
else
{
return
"{\\\"merchantId\\\":{\\\"paramKey\\\":\\\"merchantId\\\",\\\"defaultValue\\\":\\\"\\\",\\\"required\\\":true,\\\"paramDesc\\\":\\\"merchantId\\\",\\\"valueType\\\":\\\"String\\\"},\\\"stages\\\":{\\\"paramKey\\\":\\\"stages\\\",\\\"defaultValue\\\":{},\\\"required\\\":true,\\\"paramDesc\\\":\\\"stages\\\",\\\"valueType\\\":\\\"Map\\\"},\\\"dataTypeCode\\\":{\\\"paramKey\\\":\\\"dataTypeCode\\\",\\\"defaultValue\\\":\\\"圈人方式标识码\\\",\\\"required\\\":true,\\\"paramDesc\\\":\\\"dataTypeCode\\\",\\\"valueType\\\":\\\"String\\\"}}"
;
}
}
/**
* 获取指定节点原型组第一个节点原型
*
* @param tplNodeProtos
* @param dataTypeCodeStr
* @param groupCode
* @return
*/
private
static
SopTplNodeProto
getGroupFirstProto
(
List
<
SopTplNodeProto
>
tplNodeProtos
,
String
dataTypeCodeStr
,
String
groupCode
)
{
SopTplNodeProto
endProto
=
tplNodeProtos
.
stream
().
filter
(
sopTplNodeProto
->
sopTplNodeProto
.
getDataTypeCode
().
equals
(
dataTypeCodeStr
)
&&
sopTplNodeProto
.
getGroupCode
().
equals
(
groupCode
)).
findFirst
().
get
();
if
(
Objects
.
isNull
(
endProto
))
{
endProto
=
tplNodeProtos
.
stream
().
filter
(
sopTplNodeProto
->
Objects
.
isNull
(
sopTplNodeProto
.
getDataTypeCode
())
&&
sopTplNodeProto
.
getGroupCode
().
equals
(
groupCode
)).
findFirst
().
get
();
}
return
endProto
;
}
/**
* 添加链接
*
* @param sourceTplNode
* @param targetTplNode
* @param tplNodeLinks
*/
private
static
void
addLink
(
SopTplNode
sourceTplNode
,
SopTplNode
targetTplNode
,
List
<
SopTplLink
>
tplNodeLinks
)
{
SopTplLink
sopTplLink
=
new
SopTplLink
();
sopTplLink
.
setSourceId
(
sourceTplNode
.
getNodeId
());
sopTplLink
.
setTargetId
(
targetTplNode
.
getNodeId
());
tplNodeLinks
.
add
(
sopTplLink
);
}
}
platform-process/src/main/java/cn/com/glsx/process/modules/controller/SopDataTypeController.java
0 → 100644
View file @
b6bc437
package
cn
.
com
.
glsx
.
process
.
modules
.
controller
;
import
cn.com.glsx.process.modules.entity.SopDataType
;
import
cn.com.glsx.process.modules.service.SopDataTypeService
;
import
com.glsx.plat.core.annotation.ResponseResultBody
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
/**
* @Title:
* @Description:
* @Author xiehx
* @Date 2023/12/20
**/
@Slf4j
@Tag
(
name
=
"SOP圈人方式开放接口"
)
@RestController
@RequestMapping
(
value
=
"/sop/api/sopDataTypes"
)
@ResponseResultBody
public
class
SopDataTypeController
{
@Autowired
private
SopDataTypeService
sopDataTypeService
;
@Operation
(
summary
=
"圈人方式全部列表"
,
description
=
"圈人方式全部列表"
)
@GetMapping
(
"/list"
)
public
List
<
SopDataType
>
list
()
{
return
sopDataTypeService
.
list
();
}
}
platform-process/src/main/java/cn/com/glsx/process/modules/controller/SopTplController.java
View file @
b6bc437
...
@@ -4,10 +4,7 @@ import java.util.List;
...
@@ -4,10 +4,7 @@ import java.util.List;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
import
com.glsx.plat.core.annotation.ResponseResultBody
;
import
com.glsx.plat.core.annotation.ResponseResultBody
;
...
@@ -48,4 +45,10 @@ public class SopTplController extends BaseController {
...
@@ -48,4 +45,10 @@ public class SopTplController extends BaseController {
public
SopTplDTO
getById
(
@PathVariable
(
"tplId"
)
String
tplId
)
{
public
SopTplDTO
getById
(
@PathVariable
(
"tplId"
)
String
tplId
)
{
return
sopTplService
.
getById
(
tplId
);
return
sopTplService
.
getById
(
tplId
);
}
}
@Operation
(
summary
=
"新增模板"
,
description
=
"新增模板"
)
@PostMapping
public
SopTpl
add
(
@RequestBody
SopTplDTO
sopTplDTO
)
{
return
sopTplService
.
add
(
sopTplDTO
);
}
}
}
platform-process/src/main/java/cn/com/glsx/process/modules/controller/SopTplNodeProtoController.java
0 → 100644
View file @
b6bc437
package
cn
.
com
.
glsx
.
process
.
modules
.
controller
;
import
cn.com.glsx.process.modules.entity.SopTplNodeProto
;
import
cn.com.glsx.process.modules.service.SopTplNodeProtoService
;
import
com.glsx.plat.core.annotation.ResponseResultBody
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
/**
* @Title:
* @Description:
* @Author xiehx
* @Date 2023/12/21
**/
@Slf4j
@Tag
(
name
=
"SOP触达类型开放接口"
)
@RestController
@RequestMapping
(
value
=
"/sop/api/SopTplNodeProtos"
)
@ResponseResultBody
public
class
SopTplNodeProtoController
{
@Autowired
private
SopTplNodeProtoService
sopTplNodeProtoService
;
@Operation
(
summary
=
"触达类型列表"
,
description
=
"触达类型列表"
)
@GetMapping
(
"/list"
)
public
List
<
SopTplNodeProto
>
list
(
SopTplNodeProto
search
)
{
return
sopTplNodeProtoService
.
list
(
search
);
}
}
platform-process/src/main/java/cn/com/glsx/process/modules/converter/SopTplNodeProtoConverter.java
0 → 100644
View file @
b6bc437
package
cn
.
com
.
glsx
.
process
.
modules
.
converter
;
import
cn.com.glsx.process.modules.entity.SopTplNode
;
import
cn.com.glsx.process.modules.entity.SopTplNodeProto
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.Mapping
;
import
org.mapstruct.Mappings
;
import
org.mapstruct.factory.Mappers
;
@Mapper
public
interface
SopTplNodeProtoConverter
{
SopTplNodeProtoConverter
INSTANCE
=
Mappers
.
getMapper
(
SopTplNodeProtoConverter
.
class
);
//TODO 添加必要的字段映射
// @Mappings({
// @Mapping(source = "nodeAsync", target = "nodeAsync"),
// @Mapping(source = "nodeParamDef", target = "nodeParam"),
// @Mapping(source = "nodeContentDef", target = "nodeContent")})
SopTplNode
proto2tpl
(
SopTplNodeProto
nodeProto
);
}
platform-process/src/main/java/cn/com/glsx/process/modules/service/SopDataTypeService.java
0 → 100644
View file @
b6bc437
package
cn
.
com
.
glsx
.
process
.
modules
.
service
;
import
cn.com.glsx.process.modules.entity.SopDataType
;
import
cn.com.glsx.process.modules.mapper.SopDataTypeMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* @Title:
* @Description:
* @Author xiehx
* @Date 2023/12/21
**/
@Service
public
class
SopDataTypeService
{
@Autowired
private
SopDataTypeMapper
sopDataTypeMapper
;
public
List
<
SopDataType
>
list
()
{
return
sopDataTypeMapper
.
selectAll
();
}
}
platform-process/src/main/java/cn/com/glsx/process/modules/service/SopTplNodeProtoService.java
0 → 100644
View file @
b6bc437
package
cn
.
com
.
glsx
.
process
.
modules
.
service
;
import
cn.com.glsx.process.modules.entity.SopTplNodeProto
;
import
cn.com.glsx.process.modules.mapper.SopTplNodeProtoMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* @Title:
* @Description:
* @Author xiehx
* @Date 2023/12/21
**/
@Service
public
class
SopTplNodeProtoService
{
@Autowired
private
SopTplNodeProtoMapper
sopTplNodeProtoMapper
;
public
List
<
SopTplNodeProto
>
list
(
SopTplNodeProto
search
)
{
return
sopTplNodeProtoMapper
.
list
(
search
);
}
}
platform-process/src/main/java/cn/com/glsx/process/modules/service/SopTplService.java
View file @
b6bc437
...
@@ -5,7 +5,10 @@ import java.util.Objects;
...
@@ -5,7 +5,10 @@ import java.util.Objects;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
cn.com.glsx.process.modules.assembler.KeHuLvChengAssembler
;
import
cn.com.glsx.process.modules.converter.SopTplConverter
;
import
cn.com.glsx.process.modules.entity.SopTpl
;
import
cn.com.glsx.process.modules.entity.SopTpl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageHelper
;
...
@@ -18,6 +21,7 @@ import cn.com.glsx.process.modules.mapper.SopTplMapper;
...
@@ -18,6 +21,7 @@ import cn.com.glsx.process.modules.mapper.SopTplMapper;
import
cn.com.glsx.process.modules.mapper.SopTplNodeMapper
;
import
cn.com.glsx.process.modules.mapper.SopTplNodeMapper
;
import
cn.com.glsx.process.modules.model.SopTplDTO
;
import
cn.com.glsx.process.modules.model.SopTplDTO
;
import
cn.com.glsx.process.modules.model.SopTplSearch
;
import
cn.com.glsx.process.modules.model.SopTplSearch
;
import
org.springframework.transaction.annotation.Transactional
;
@Service
@Service
public
class
SopTplService
{
public
class
SopTplService
{
...
@@ -31,6 +35,9 @@ public class SopTplService {
...
@@ -31,6 +35,9 @@ public class SopTplService {
@Resource
@Resource
private
SopTplLinkMapper
sopTplLinkMapper
;
private
SopTplLinkMapper
sopTplLinkMapper
;
@Autowired
private
KeHuLvChengAssembler
keHuLvChengAssembler
;
public
PageInfo
<
SopTplDTO
>
page
(
SopTplSearch
search
)
{
public
PageInfo
<
SopTplDTO
>
page
(
SopTplSearch
search
)
{
PageHelper
.
startPage
(
search
.
getPageNumber
(),
search
.
getPageSize
());
PageHelper
.
startPage
(
search
.
getPageNumber
(),
search
.
getPageSize
());
List
<
SopTplDTO
>
list
=
sopTplMapper
.
page
(
search
);
List
<
SopTplDTO
>
list
=
sopTplMapper
.
page
(
search
);
...
@@ -69,4 +76,23 @@ public class SopTplService {
...
@@ -69,4 +76,23 @@ public class SopTplService {
public
List
<
SopTpl
>
list
()
{
public
List
<
SopTpl
>
list
()
{
return
sopTplMapper
.
selectAll
();
return
sopTplMapper
.
selectAll
();
}
}
@Transactional
public
SopTpl
add
(
SopTplDTO
sopTplDTO
)
{
keHuLvChengAssembler
.
assemble
(
sopTplDTO
);
SopTpl
sopTpl
=
SopTplConverter
.
INSTANCE
.
dto2do
(
sopTplDTO
);
sopTplMapper
.
insert
(
sopTpl
);
String
tplId
=
sopTpl
.
getTplId
();
List
<
SopTplNode
>
nodes
=
sopTplDTO
.
getNodes
();
nodes
.
forEach
(
sopTplNode
->
sopTplNode
.
setTplId
(
tplId
));
sopTplNodeMapper
.
insertList
(
nodes
);
List
<
SopTplLink
>
links
=
sopTplDTO
.
getLinks
();
links
.
forEach
(
sopTplLink
->
sopTplLink
.
setTplId
(
tplId
));
sopTplLinkMapper
.
insertList
(
links
);
return
sopTpl
;
}
}
}
platform-process/src/main/java/cn/com/glsx/process/util/JacksonUtil.java
View file @
b6bc437
...
@@ -2,6 +2,9 @@ package cn.com.glsx.process.util;
...
@@ -2,6 +2,9 @@ package cn.com.glsx.process.util;
import
java.io.IOException
;
import
java.io.IOException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -82,4 +85,72 @@ public class JacksonUtil {
...
@@ -82,4 +85,72 @@ public class JacksonUtil {
}
}
return
null
;
return
null
;
}
}
/**
* 通过路径获取json字符串里对应的值
*
* @param json
* @param path json路径,如 aaa/bbb/ccc
* @return
*/
public
static
String
getStrValueInJsonStrByPath
(
String
json
,
String
path
)
{
try
{
ObjectMapper
mapper
=
new
ObjectMapper
();
JsonNode
rootNode
=
mapper
.
readTree
(
json
);
String
[]
keys
=
path
.
split
(
"/"
);
JsonNode
currentNode
=
rootNode
;
for
(
String
key
:
keys
)
{
currentNode
=
currentNode
.
get
(
key
);
if
(
currentNode
==
null
)
{
return
null
;
}
}
return
currentNode
.
asText
();
}
catch
(
JsonProcessingException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
/**
* json字符串深度替换
* 存在就更新,不存在就新增
*
* @param original 原值json字符串
* @param update 新值json字符串
* @return
* @throws Exception
*/
public
static
String
jsonStrDeepSub
(
String
original
,
String
update
)
{
try
{
ObjectMapper
mapper
=
new
ObjectMapper
();
JsonNode
originalNode
=
mapper
.
readTree
(
original
);
JsonNode
updateNode
=
mapper
.
readTree
(
update
);
updateJson
((
ObjectNode
)
originalNode
,
(
ObjectNode
)
updateNode
);
return
originalNode
.
toString
();
}
catch
(
JsonProcessingException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
// 递归更新JSON节点
private
static
void
updateJson
(
ObjectNode
original
,
ObjectNode
update
)
{
update
.
fields
().
forEachRemaining
(
entry
->
{
String
key
=
entry
.
getKey
();
JsonNode
value
=
entry
.
getValue
();
if
(
original
.
has
(
key
)
&&
original
.
get
(
key
).
isObject
()
&&
value
.
isObject
())
{
updateJson
((
ObjectNode
)
original
.
get
(
key
),
(
ObjectNode
)
value
);
}
else
{
original
.
set
(
key
,
value
);
}
});
}
}
}
platform-process/src/main/resources/mapper/SopTplNodeProtoMapper.xml
View file @
b6bc437
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
-->
-->
id, node_name, node_type, node_label, node_show, node_key, node_visible, node_cron,
id, node_name, node_type, node_label, node_show, node_key, node_visible, node_cron,
node_expire_cron, node_skipable, node_async, daily_limit, data_type_code, group_code,
node_expire_cron, node_skipable, node_async, daily_limit, data_type_code, group_code,
action_code,
desc
, updated_time, created_time
action_code,
`desc`
, updated_time, created_time
</sql>
</sql>
<sql
id=
"Blob_Column_List"
>
<sql
id=
"Blob_Column_List"
>
<!--
<!--
...
@@ -46,4 +46,22 @@
...
@@ -46,4 +46,22 @@
-->
-->
node_param_def, node_content_def, node_result_def
node_param_def, node_content_def, node_result_def
</sql>
</sql>
<select
id=
"list"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from sop_tpl_node_proto
<where>
<if
test=
"dataTypeCode != null and dataTypeCode != ''"
>
and data_type_code = #{dataTypeCode}
</if>
<if
test=
"groupCode != null and groupCode != ''"
>
and group_code = #{groupCode}
</if>
<if
test=
"actionCode != null and actionCode != ''"
>
and action_code = #{actionCode}
</if>
</where>
</select>
</mapper>
</mapper>
\ No newline at end of file
\ No newline at end of file
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