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 459e363c
authored
Jan 04, 2024
by
zhouhaibao
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'v2.0.1' of
http://192.168.3.233:8090/platform/platform-process-server
into v2.0.1
2 parents
868c1e00
1e49919f
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
17 deletions
platform-process-api/src/main/java/cn/com/glsx/process/modules/model/SopDataOperatorDTO.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/SopDataController.java
platform-process/src/main/java/cn/com/glsx/process/modules/service/SopDataService.java
platform-process/src/test/java/cn/com/glsx/test/service/TestSopService.java
platform-process-api/src/main/java/cn/com/glsx/process/modules/model/SopDataOperatorDTO.java
View file @
459e363
package
cn
.
com
.
glsx
.
process
.
modules
.
model
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.TypeReference
;
import
lombok.Data
;
import
org.springframework.util.StringUtils
;
import
java.util.Arrays
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* 操作符
...
...
@@ -16,4 +23,21 @@ public class SopDataOperatorDTO {
// from SopDataConditionDTO
private
String
unit
;
private
String
style
;
/**
* 一般value存储多值,用,分隔
* desc字段存储value的一些描述数据
*/
public
String
getDescByValue
()
{
if
(!
StringUtils
.
hasLength
(
this
.
getValue
())
||
!
StringUtils
.
hasLength
(
this
.
getDesc
()))
{
return
this
.
getValue
();
}
String
[]
values
=
this
.
getValue
().
split
(
","
);
if
(
values
.
length
==
0
)
{
return
this
.
getValue
();
}
Map
<
String
,
String
>
descValueMap
=
JSON
.
parseObject
(
this
.
getDesc
(),
new
TypeReference
<
Map
<
String
,
String
>>()
{
});
return
Arrays
.
stream
(
values
).
map
(
p
->
descValueMap
.
getOrDefault
(
p
,
p
)).
collect
(
Collectors
.
joining
(
","
));
}
}
\ No newline at end of file
platform-process/src/main/java/cn/com/glsx/process/modules/assembler/KeHuLvChengAssembler.java
View file @
459e363
...
...
@@ -126,6 +126,7 @@ public class KeHuLvChengAssembler {
SopTplNode
stageNode
=
PROTO_CONVERTER
.
proto2tpl
(
stageProto
);
stageNode
.
setNodeId
(
tplNodeLastNum
++);
stageNode
.
setNodeName
(
String
.
format
(
"%s-%s"
,
stageValue
,
stageNode
.
getNodeName
()));
stageNode
.
setNodeParamDef
(
JacksonUtil
.
jsonStrDeepSub
(
STAGE_TPL_NODE_PARAM_DEF_TPL
,
String
.
format
(
"{\"stage\":{\"defaultValue\":\"%s\"}}"
,
stageValue
)));
stageNode
.
setNodeKey
(
String
.
format
(
"%s%d"
,
stageProto
.
getNodeKey
(),
stageOrder
));
...
...
@@ -209,6 +210,10 @@ public class KeHuLvChengAssembler {
notifyTplNode
.
setNodeId
(
nodeId
);
notifyTplNode
.
setNodeKey
(
String
.
format
(
"%s%d"
,
tplNodeProto
.
getNodeKey
(),
notifyTplNode
.
getNodeId
()));
String
stageName
=
JacksonUtil
.
getStrValueInJsonStrByPath
(
nodeParamDef
,
"stage/defaultValue"
);
String
dayStr
=
JacksonUtil
.
getStrValueInJsonStrByPath
(
nodeParamDef
,
"day/defaultValue"
);
notifyTplNode
.
setNodeName
(
String
.
format
(
"%s-第%s天-%s"
,
stageName
,
dayStr
,
notifyTplNode
.
getNodeName
()));
nodeParamDef
=
JacksonUtil
.
jsonStrDeepSub
(
notifyTplNode
.
getNodeParamDef
(),
nodeParamDef
);
nodeParamDef
=
JacksonUtil
.
jsonStrDeepSub
(
nodeParamDef
,
String
.
format
(
"{\"stageid\": {\"defaultValue\": %d}}"
,
stageid
));
notifyTplNode
.
setNodeParamDef
(
nodeParamDef
);
...
...
@@ -287,7 +292,7 @@ public class KeHuLvChengAssembler {
// 获取阶段更新的sql
SopInst
sopInst
=
SopInstConverter
.
INSTANCE
.
dto2do
(
instDTO
);
Map
<
String
,
String
>
stageSqlMap
=
sopDataService
.
parseSQL
(
sopInst
);
String
updateSql
=
String
.
join
(
"
\n
"
,
stageSqlMap
.
values
());
String
updateSql
=
String
.
join
(
"
"
,
stageSqlMap
.
values
());
String
nodeContent
=
updateStageNode
.
getNodeContent
();
Map
<
String
,
Object
>
nodeContentMap
=
JSON
.
parseObject
(
nodeContent
,
Map
.
class
);
...
...
platform-process/src/main/java/cn/com/glsx/process/modules/controller/SopDataController.java
View file @
459e363
...
...
@@ -8,9 +8,7 @@ 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.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.util.List
;
...
...
@@ -30,4 +28,10 @@ public class SopDataController extends BaseController {
public
List
<
SopDataActionDTO
>
listCondition
(
SopDataActionSearch
search
)
{
return
sopDataService
.
listCondition
(
search
);
}
@Operation
(
summary
=
"根据某一阶段条件获取条件名称"
,
description
=
"根据某一阶段条件获取条件名称"
)
@PostMapping
(
"/condition/getConditionTitle"
)
public
String
parseParamRemarkTitle
(
@RequestBody
SopDataActionDTO
actionDTO
)
{
return
sopDataService
.
parseParamRemarkTitle
(
actionDTO
);
}
}
platform-process/src/main/java/cn/com/glsx/process/modules/service/SopDataService.java
View file @
459e363
...
...
@@ -22,6 +22,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
java.text.MessageFormat
;
import
java.util.*
;
import
java.util.stream.Collectors
;
...
...
@@ -123,7 +124,7 @@ public class SopDataService {
*
* @param action 所属条件
*/
p
rivate
String
parseParamRemarkTitle
(
SopDataActionDTO
action
)
{
p
ublic
String
parseParamRemarkTitle
(
SopDataActionDTO
action
)
{
if
(!
StringUtils
.
hasLength
(
action
.
getParamRemark
()))
{
return
action
.
getParamRemark
();
}
...
...
@@ -138,26 +139,30 @@ public class SopDataService {
if
(
CollectionUtils
.
isEmpty
(
conditions
))
{
return
subTitle
;
}
List
<
String
>
subC
onditionTitleList
=
new
ArrayList
<>();
List
<
String
>
c
onditionTitleList
=
new
ArrayList
<>();
for
(
SopDataConditionDTO
condition
:
conditions
)
{
String
subConditionTitle
=
StringUtils
.
hasLength
(
condition
.
getParamRemark
())
?
JSON
.
parseObject
(
condition
.
getParamRemark
()).
getString
(
"title"
)
:
""
;
String
conditionTitle
=
""
;
if
(
StringUtils
.
hasLength
(
condition
.
getParamRemark
()))
{
conditionTitle
=
JSON
.
parseObject
(
condition
.
getParamRemark
()).
getString
(
"title"
);
// 将占位符替换真实数据,占位符采用[]包裹
if
(!
CollectionUtils
.
isEmpty
(
condition
.
getOperators
()))
{
Map
<
String
,
String
>
map
=
condition
.
getOperators
().
stream
()
.
filter
(
p
->
StringUtils
.
hasLength
(
p
.
getValue
()))
.
collect
(
Collectors
.
groupingBy
(
o
->
o
.
getName
(),
Collectors
.
mapping
(
o
->
o
.
get
Value
(),
Collectors
.
joining
(
","
))));
.
collect
(
Collectors
.
groupingBy
(
o
->
o
.
getName
(),
Collectors
.
mapping
(
o
->
o
.
getDescBy
Value
(),
Collectors
.
joining
(
","
))));
for
(
Map
.
Entry
<
String
,
String
>
e
:
map
.
entrySet
())
{
subConditionTitle
=
subC
onditionTitle
conditionTitle
=
c
onditionTitle
.
replaceFirst
(
"\\[([^\\]]+)\\]"
,
e
.
getKey
())
.
replaceFirst
(
"\\[([^\\]]+)\\]"
,
e
.
getValue
());
}
}
}
if
(!
CollectionUtils
.
isEmpty
(
condition
.
getSubConditions
()))
{
subC
onditionTitle
+=
parseParamRemarkTitle
(
condition
.
getSubConditions
());
c
onditionTitle
+=
parseParamRemarkTitle
(
condition
.
getSubConditions
());
}
subConditionTitleList
.
add
(
subC
onditionTitle
);
conditionTitleList
.
add
(
c
onditionTitle
);
}
subTitle
+=
joinWithDelimiter
(
", 且"
,
subC
onditionTitleList
);
subTitle
+=
joinWithDelimiter
(
", 且"
,
c
onditionTitleList
);
return
subTitle
;
}
...
...
@@ -229,9 +234,20 @@ public class SopDataService {
if
(
CollectionUtils
.
isEmpty
(
condition
.
getOperators
()))
{
return
condStr
;
}
// 针对“页面配置”等这种条件(type=1)进行特殊处理,对value值进行拆分,放在sql的占位中
if
(
"页面配置"
.
equals
(
condition
.
getName
()))
{
SopDataOperatorDTO
operator
=
condition
.
getOperators
().
get
(
0
);
String
[]
vals
=
operator
.
getValue
().
split
(
"\\+"
);
if
(
vals
.
length
==
0
)
{
return
""
;
}
return
MessageFormat
.
format
(
condStr
,
vals
);
}
List
<
String
>
operatorStrList
=
new
ArrayList
<>();
for
(
SopDataOperatorDTO
operator
:
condition
.
getOperators
())
{
if
(
StringUtils
.
hasLength
(
operator
.
getValue
()))
{
if
(!
StringUtils
.
hasLength
(
operator
.
getValue
()))
{
continue
;
}
String
value
;
if
(
"in"
.
equals
(
operator
.
getKey
())
||
"nin"
.
equals
(
operator
.
getKey
()))
{
value
=
"("
+
Arrays
.
stream
(
operator
.
getValue
().
split
(
","
)).
map
(
p
->
"'"
+
p
+
"'"
).
collect
(
Collectors
.
joining
(
","
))
+
")"
;
...
...
@@ -240,7 +256,6 @@ public class SopDataService {
}
operatorStrList
.
add
(
condStr
+
" "
+
operator
.
getKey
()
+
" "
+
value
);
}
}
condStr
=
joinWithDelimiter
(
" and "
,
operatorStrList
);
return
condStr
;
}
...
...
platform-process/src/test/java/cn/com/glsx/test/service/TestSopService.java
View file @
459e363
...
...
@@ -79,9 +79,10 @@ public class TestSopService {
.
put
(
"paramRemark"
,
"{\"title\": \"天数[xx][X]天\"}"
)
.
put
(
"operators"
,
Lists
.
newArrayList
(
ImmutableMap
.
builder
()
.
put
(
"id"
,
"1"
)
.
put
(
"name"
,
"等于"
)
.
put
(
"key"
,
"="
)
.
put
(
"value"
,
"11"
)
.
put
(
"name"
,
"包含"
)
.
put
(
"key"
,
"in"
)
.
put
(
"value"
,
"a,b,c"
)
.
put
(
"desc"
,
"{\"a\":\"A\", \"b\":\"B\"}"
)
.
build
()))
.
build
()))
.
build
())).
build
()).
build
();
...
...
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