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 550021ef
authored
Dec 27, 2023
by
谢海旭
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
新增模板接口:增加触达节点key处理
1 parent
6f201f61
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
8 deletions
platform-process/src/main/java/cn/com/glsx/process/modules/assembler/KeHuLvChengAssembler.java
platform-process/src/main/java/cn/com/glsx/process/util/CronUtil.java
platform-process/src/main/java/cn/com/glsx/process/modules/assembler/KeHuLvChengAssembler.java
View file @
550021e
...
...
@@ -8,11 +8,10 @@ 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.CronUtil
;
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
;
...
...
@@ -87,23 +86,34 @@ public class KeHuLvChengAssembler {
//有阶段
SopTplNodeProto
stageProto
=
getGroupFirstProto
(
tplNodeProtos
,
dataTypeCode
,
"stage"
);
Map
<
String
,
Map
<
String
,
Object
>>
stages
=
JacksonUtils
.
fromJson
(
stagesStr
,
new
TypeReference
<
Map
<
String
,
Map
<
String
,
Object
>>>()
{});;
Map
<
String
,
Map
<
String
,
Object
>>
stages
=
JacksonUtils
.
fromJson
(
stagesStr
,
new
TypeReference
<
Map
<
String
,
Map
<
String
,
Object
>>>()
{
});
;
//阶段与其生成的节点的对应关系
HashMap
<
String
,
SopTplNode
>
stageNodeMap
=
new
HashMap
<>();
Map
<
String
,
SopTplNode
>
stageNodeMap
=
new
HashMap
<>();
//阶段与其排序后的序号的对应关系
Map
<
String
,
Integer
>
stageOrderMap
=
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
);
List
<
String
>
stageSortedKeys
=
new
ArrayList
<>(
stages
.
keySet
());
Collections
.
sort
(
stageSortedKeys
);
int
stageSize
=
stageSortedKeys
.
size
();
for
(
int
i
=
0
;
i
<
stageSize
;
i
++)
{
int
stageOrder
=
i
+
1
;
Map
<
String
,
Object
>
stageSettingMap
=
stages
.
get
(
stageSortedKeys
.
get
(
i
));
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
)));
stageNode
.
setNodeKey
(
String
.
format
(
"%s%d"
,
stageProto
.
getNodeKey
(),
stageOrder
));
tplNodes
.
add
(
stageNode
);
addLink
(
getDataTplNode
,
stageNode
,
tplNodeLinks
);
stageNodeMap
.
put
(
stageValue
,
stageNode
);
stageOrderMap
.
put
(
stageValue
,
stageOrder
);
}
List
<
SopTplNode
>
notifyNodes
=
sopTplDTO
.
getNodes
();
...
...
@@ -127,7 +137,14 @@ public class KeHuLvChengAssembler {
SopTplNode
notifyTplNode
=
protoConverter
.
proto2tpl
(
sopTplNodeProto
);
notifyTplNode
.
setNodeId
(
tplNodeLastNum
++);
notifyTplNode
.
setNodeParamDef
(
JacksonUtil
.
jsonStrDeepSub
(
notifyTplNode
.
getNodeParamDef
(),
sopTplNode
.
getNodeParamDef
()));
notifyTplNode
.
setNodeKey
(
String
.
format
(
"%s%d"
,
sopTplNodeProto
.
getNodeKey
(),
notifyTplNode
.
getNodeId
()));
String
nodeParamDef
=
JacksonUtil
.
jsonStrDeepSub
(
notifyTplNode
.
getNodeParamDef
(),
sopTplNode
.
getNodeParamDef
());
nodeParamDef
=
JacksonUtil
.
jsonStrDeepSub
(
nodeParamDef
,
String
.
format
(
"{\"stageid\": {\"defaultValue\": %d}}"
,
stageOrderMap
.
get
(
key
)));
notifyTplNode
.
setNodeParamDef
(
nodeParamDef
);
String
timeStr
=
JacksonUtil
.
getStrValueInJsonStrByPath
(
notifyTplNode
.
getNodeParamDef
(),
"time/defaultValue"
);
notifyTplNode
.
setNodeCron
(
CronUtil
.
timeStr2Cron
(
timeStr
,
CronUtil
.
TIME_PATTERN_HM
));
tplNodes
.
add
(
notifyTplNode
);
addLink
(
stageNodeMap
.
get
(
key
),
notifyTplNode
,
tplNodeLinks
);
...
...
platform-process/src/main/java/cn/com/glsx/process/util/CronUtil.java
0 → 100644
View file @
550021e
package
cn
.
com
.
glsx
.
process
.
util
;
import
cn.com.glsx.process.common.sysenum.ResultEnum
;
import
cn.com.glsx.process.exception.AdminException
;
import
lombok.experimental.UtilityClass
;
import
lombok.extern.slf4j.Slf4j
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
/**
* cron表达式工具
*/
@Slf4j
@UtilityClass
public
class
CronUtil
{
public
static
final
String
TIME_PATTERN_HM
=
"HH:mm"
;
public
static
final
String
TIME_PATTERN_HMS
=
"HH:mm:ss"
;
/**
* 时间转cron表达式
*
* @param timeStr 时间字符串
* @param pattern 时间字符串格式 如"HH:mm"或"HH:mm:ss"
* @return
*/
public
String
timeStr2Cron
(
String
timeStr
,
String
pattern
)
{
try
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
pattern
);
Date
time
=
sdf
.
parse
(
timeStr
);
// 将时间转换成克隆表达式的格式
SimpleDateFormat
cronSdf
=
new
SimpleDateFormat
(
"s m H * * ?"
);
return
cronSdf
.
format
(
time
);
}
catch
(
ParseException
e
)
{
log
.
error
(
"时间字符串转cron表达式失败 time:{} pattern:{}, msg:{}"
,
timeStr
,
pattern
,
e
.
getMessage
());
throw
new
AdminException
(
ResultEnum
.
PARAM_ERROR
.
getCode
(),
"时间字符串转cron表达式失败"
);
}
}
}
\ 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