Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzwf
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzwf
提交
00b63a89
提交
00b63a89
编写于
5月 06, 2020
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dep
上级
602efb45
变更
1
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
80 行增加
和
19 行删除
+80
-19
WFCoreService.java
...ava/cn/ibizlab/core/extensions/service/WFCoreService.java
+80
-19
未找到文件。
ibzwf-core/src/main/java/cn/ibizlab/core/extensions/service/WFCoreService.java
浏览文件 @
00b63a89
...
@@ -6,7 +6,6 @@ import cn.ibizlab.core.workflow.service.IWFProcessDefinitionService;
...
@@ -6,7 +6,6 @@ import cn.ibizlab.core.workflow.service.IWFProcessDefinitionService;
import
cn.ibizlab.util.domain.EntityBase
;
import
cn.ibizlab.util.domain.EntityBase
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.flowable.bpmn.converter.BpmnXMLConverter
;
import
org.flowable.bpmn.converter.BpmnXMLConverter
;
import
org.flowable.bpmn.model.*
;
import
org.flowable.bpmn.model.*
;
...
@@ -19,11 +18,11 @@ import org.flowable.engine.TaskService;
...
@@ -19,11 +18,11 @@ import org.flowable.engine.TaskService;
import
org.flowable.engine.delegate.DelegateExecution
;
import
org.flowable.engine.delegate.DelegateExecution
;
import
org.flowable.engine.repository.Deployment
;
import
org.flowable.engine.repository.Deployment
;
import
org.flowable.engine.repository.DeploymentBuilder
;
import
org.flowable.engine.repository.DeploymentBuilder
;
import
org.flowable.engine.repository.ProcessDefinition
;
import
org.flowable.engine.runtime.ProcessInstance
;
import
org.flowable.engine.runtime.ProcessInstance
;
import
org.flowable.task.api.Task
;
import
org.flowable.task.api.Task
;
import
org.flowable.task.api.TaskQuery
;
import
org.flowable.task.api.TaskQuery
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.DigestUtils
;
import
org.springframework.util.DigestUtils
;
...
@@ -31,9 +30,7 @@ import org.springframework.util.StringUtils;
...
@@ -31,9 +30,7 @@ import org.springframework.util.StringUtils;
import
javax.xml.stream.XMLInputFactory
;
import
javax.xml.stream.XMLInputFactory
;
import
javax.xml.stream.XMLStreamReader
;
import
javax.xml.stream.XMLStreamReader
;
import
java.io.File
;
import
java.io.*
;
import
java.io.FileInputStream
;
import
java.io.InputStream
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
import
java.util.*
;
import
java.util.*
;
...
@@ -145,7 +142,7 @@ public class WFCoreService
...
@@ -145,7 +142,7 @@ public class WFCoreService
throw
new
BadRequestAlertException
(
"未找到对应的工作流配置"
,
entity
,
businessKey
);
throw
new
BadRequestAlertException
(
"未找到对应的工作流配置"
,
entity
,
businessKey
);
processDefinitionKey
=
definitionKeys
.
get
(
0
);
processDefinitionKey
=
definitionKeys
.
get
(
0
);
}
}
String
processInstanceBusinessKey
=
system
+
":"
+
entity
+
":
srfkey
-"
+
businessKey
;
String
processInstanceBusinessKey
=
system
+
":"
+
entity
+
":
k
-"
+
businessKey
;
Map
<
String
,
Object
>
variables
=
new
LinkedHashMap
<>();
Map
<
String
,
Object
>
variables
=
new
LinkedHashMap
<>();
variables
.
put
(
"businessKey"
,
businessKey
);
variables
.
put
(
"businessKey"
,
businessKey
);
variables
.
put
(
"activedata"
,
instance
.
get
(
"activedata"
));
variables
.
put
(
"activedata"
,
instance
.
get
(
"activedata"
));
...
@@ -169,7 +166,7 @@ public class WFCoreService
...
@@ -169,7 +166,7 @@ public class WFCoreService
public
List
<
WFTaskWay
>
getWFLink
(
String
system
,
String
appname
,
public
List
<
WFTaskWay
>
getWFLink
(
String
system
,
String
appname
,
String
entity
,
String
businessKey
,
String
taskDefinitionKey
)
{
String
entity
,
String
businessKey
,
String
taskDefinitionKey
)
{
List
<
WFTaskWay
>
taskWays
=
new
ArrayList
<>();
List
<
WFTaskWay
>
taskWays
=
new
ArrayList
<>();
String
processInstanceBusinessKey
=
system
+
":"
+
entity
+
":
srfkey
-"
+
businessKey
;
String
processInstanceBusinessKey
=
system
+
":"
+
entity
+
":
k
-"
+
businessKey
;
String
userId
=
AuthenticationUser
.
getAuthenticationUser
().
getUserid
();
String
userId
=
AuthenticationUser
.
getAuthenticationUser
().
getUserid
();
if
(
StringUtils
.
isEmpty
(
userId
))
if
(
StringUtils
.
isEmpty
(
userId
))
return
taskWays
;
return
taskWays
;
...
@@ -187,7 +184,8 @@ public class WFCoreService
...
@@ -187,7 +184,8 @@ public class WFCoreService
WFTaskWay
way
=
new
WFTaskWay
();
WFTaskWay
way
=
new
WFTaskWay
();
way
.
setSequenceflowid
(
sequenceFlow
.
getId
());
way
.
setSequenceflowid
(
sequenceFlow
.
getId
());
way
.
setSequenceflowname
(
sequenceFlow
.
getName
());
way
.
setSequenceflowname
(
sequenceFlow
.
getName
());
way
.
setProcessdefinitionkey
(
task
.
getProcessDefinitionId
().
split
(
":"
)[
0
]);
if
(
task
.
getProcessDefinitionId
().
indexOf
(
":"
)>
0
)
way
.
setProcessdefinitionkey
(
task
.
getProcessDefinitionId
().
split
(
":"
)[
0
]);
way
.
setTaskid
(
task
.
getId
());
way
.
setTaskid
(
task
.
getId
());
way
.
setProcessinstanceid
(
task
.
getProcessInstanceId
());
way
.
setProcessinstanceid
(
task
.
getProcessInstanceId
());
way
.
setTaskprocessdefinitionkey
(
task
.
getTaskDefinitionKey
());
way
.
setTaskprocessdefinitionkey
(
task
.
getTaskDefinitionKey
());
...
@@ -201,7 +199,7 @@ public class WFCoreService
...
@@ -201,7 +199,7 @@ public class WFCoreService
public
List
<
WFTaskWay
>
getTaskLink
(
String
system
,
String
appname
,
String
entity
,
String
businessKey
,
String
taskId
)
{
public
List
<
WFTaskWay
>
getTaskLink
(
String
system
,
String
appname
,
String
entity
,
String
businessKey
,
String
taskId
)
{
List
<
WFTaskWay
>
taskWays
=
new
ArrayList
<>();
List
<
WFTaskWay
>
taskWays
=
new
ArrayList
<>();
String
processInstanceBusinessKey
=
system
+
":"
+
entity
+
":
srfkey
-"
+
businessKey
;
String
processInstanceBusinessKey
=
system
+
":"
+
entity
+
":
k
-"
+
businessKey
;
String
userId
=
AuthenticationUser
.
getAuthenticationUser
().
getUserid
();
String
userId
=
AuthenticationUser
.
getAuthenticationUser
().
getUserid
();
if
(
StringUtils
.
isEmpty
(
userId
))
if
(
StringUtils
.
isEmpty
(
userId
))
return
taskWays
;
return
taskWays
;
...
@@ -217,7 +215,8 @@ public class WFCoreService
...
@@ -217,7 +215,8 @@ public class WFCoreService
WFTaskWay
way
=
new
WFTaskWay
();
WFTaskWay
way
=
new
WFTaskWay
();
way
.
setSequenceflowid
(
sequenceFlow
.
getId
());
way
.
setSequenceflowid
(
sequenceFlow
.
getId
());
way
.
setSequenceflowname
(
sequenceFlow
.
getName
());
way
.
setSequenceflowname
(
sequenceFlow
.
getName
());
way
.
setProcessdefinitionkey
(
task
.
getProcessDefinitionId
().
split
(
":"
)[
0
]);
if
(
task
.
getProcessDefinitionId
().
indexOf
(
":"
)>
0
)
way
.
setProcessdefinitionkey
(
task
.
getProcessDefinitionId
().
split
(
":"
)[
0
]);
way
.
setTaskid
(
task
.
getId
());
way
.
setTaskid
(
task
.
getId
());
way
.
setProcessinstanceid
(
task
.
getProcessInstanceId
());
way
.
setProcessinstanceid
(
task
.
getProcessInstanceId
());
way
.
setTaskprocessdefinitionkey
(
task
.
getTaskDefinitionKey
());
way
.
setTaskprocessdefinitionkey
(
task
.
getTaskDefinitionKey
());
...
@@ -233,7 +232,7 @@ public class WFCoreService
...
@@ -233,7 +232,7 @@ public class WFCoreService
public
List
<
String
>
getBusinessKeys
(
String
system
,
String
appname
,
String
entity
,
String
processDefinitionKey
,
String
taskDefinitionKey
)
public
List
<
String
>
getBusinessKeys
(
String
system
,
String
appname
,
String
entity
,
String
processDefinitionKey
,
String
taskDefinitionKey
)
{
{
List
<
String
>
businessKeys
=
new
ArrayList
<>();
List
<
String
>
businessKeys
=
new
ArrayList
<>();
String
processInstanceBusinessKeyLike
=
system
+
":"
+
entity
+
":
srfkey
-"
;
String
processInstanceBusinessKeyLike
=
system
+
":"
+
entity
+
":
k
-"
;
String
userId
=
AuthenticationUser
.
getAuthenticationUser
().
getUserid
();
String
userId
=
AuthenticationUser
.
getAuthenticationUser
().
getUserid
();
if
(
StringUtils
.
isEmpty
(
userId
))
if
(
StringUtils
.
isEmpty
(
userId
))
return
businessKeys
;
return
businessKeys
;
...
@@ -250,8 +249,8 @@ public class WFCoreService
...
@@ -250,8 +249,8 @@ public class WFCoreService
Object
key
=
task
.
getProcessVariables
().
get
(
"businessKey"
);
Object
key
=
task
.
getProcessVariables
().
get
(
"businessKey"
);
if
(
key
!=
null
)
{
if
(
key
!=
null
)
{
String
str
=
key
.
toString
();
String
str
=
key
.
toString
();
if
(
str
.
indexOf
(
":
srfkey
-"
)>
0
)
if
(
str
.
indexOf
(
":
k
-"
)>
0
)
str
=
str
.
split
(
":
srfkey
-"
)[
1
];
str
=
str
.
split
(
":
k
-"
)[
1
];
businessKeys
.
add
(
str
);
businessKeys
.
add
(
str
);
}
}
}
}
...
@@ -267,7 +266,7 @@ public class WFCoreService
...
@@ -267,7 +266,7 @@ public class WFCoreService
if
(
StringUtils
.
isEmpty
(
taskId
)){
if
(
StringUtils
.
isEmpty
(
taskId
)){
taskId
=
taskWay
.
getTaskid
();
taskId
=
taskWay
.
getTaskid
();
}
}
String
processInstanceBusinessKey
=
system
+
":"
+
entity
+
":
srfkey
-"
+
businessKey
;
String
processInstanceBusinessKey
=
system
+
":"
+
entity
+
":
k
-"
+
businessKey
;
Map
<
String
,
Object
>
variables
=
new
LinkedHashMap
<>();
Map
<
String
,
Object
>
variables
=
new
LinkedHashMap
<>();
variables
.
put
(
"businessKey"
,
businessKey
);
variables
.
put
(
"businessKey"
,
businessKey
);
variables
.
put
(
"sequenceFlowId"
,
taskWay
.
getSequenceflowid
());
variables
.
put
(
"sequenceFlowId"
,
taskWay
.
getSequenceflowid
());
...
@@ -286,6 +285,9 @@ public class WFCoreService
...
@@ -286,6 +285,9 @@ public class WFCoreService
return
instance
;
return
instance
;
}
}
@Value
(
"${ibiz.filePath:/app/file/}"
)
private
String
fileRoot
;
public
synchronized
boolean
wfdeploy
(
File
bpmnFile
)
public
synchronized
boolean
wfdeploy
(
File
bpmnFile
)
{
{
XMLStreamReader
reader
=
null
;
XMLStreamReader
reader
=
null
;
...
@@ -366,18 +368,77 @@ public class WFCoreService
...
@@ -366,18 +368,77 @@ public class WFCoreService
wfProcessDefinition
.
setModelenable
(
1
);
wfProcessDefinition
.
setModelenable
(
1
);
wfProcessDefinition
.
setModelversion
(
version
);
wfProcessDefinition
.
setModelversion
(
version
);
wfProcessDefinition
.
setDefinitionname
(
curProcess
.
getName
());
wfProcessDefinition
.
setDefinitionname
(
curProcess
.
getName
());
wfProcessDefinition
.
setBpmnfile
(
"[{\"id\":\""
+
md5
+
"\",\"name\":\""
+
bpmnFile
.
getName
()+
"\"}]"
);
wfProcessDefinition
.
setMd5check
(
md5
);
iwfProcessDefinitionService
.
save
(
wfProcessDefinition
);
inputStream
=
new
FileInputStream
(
bpmnFile
);
OutputStream
out
=
null
;
InputStream
is
=
null
;
XMLStreamReader
reader2
=
null
;
InputStream
inputStream2
=
null
;
String
bmpmfileId
=
""
;
String
fileFullPath
=
""
;
try
{
inputStream2
=
new
FileInputStream
(
bpmnFile
);
reader2
=
factory
.
createXMLStreamReader
(
inputStream2
);
BpmnModel
entitymodel
=
bpmnXMLConverter
.
convertToBpmnModel
(
reader2
);
entitymodel
.
getProcesses
().
get
(
0
).
setId
(
processDefinitionKey
);
byte
[]
bs
=
bpmnXMLConverter
.
convertToXML
(
entitymodel
);
bmpmfileId
=
DigestUtils
.
md5DigestAsHex
(
bs
);
fileFullPath
=
this
.
fileRoot
+
"ibizutil"
+
File
.
separator
+
bmpmfileId
+
File
.
separator
+
processDefinitionKey
+
".bpmn20.xml"
;
is
=
new
ByteArrayInputStream
(
bs
);
File
file
=
new
File
(
fileFullPath
);
File
parent
=
new
File
(
file
.
getParent
());
if
(!
parent
.
exists
())
parent
.
mkdirs
();
out
=
new
FileOutputStream
(
fileFullPath
);
byte
[]
buff
=
new
byte
[
1024
];
int
len
=
0
;
while
((
len
=
is
.
read
(
buff
))!=-
1
){
out
.
write
(
buff
,
0
,
len
);
}
}
catch
(
Exception
ex
){}
finally
{
try
{
if
(
reader2
!=
null
)
reader2
.
close
();
}
catch
(
Exception
e
)
{
}
try
{
if
(
is
!=
null
)
is
.
close
();
}
catch
(
Exception
exis
){}
try
{
if
(
out
!=
null
)
out
.
close
();
}
catch
(
Exception
exis
){}
}
inputStream
=
new
FileInputStream
(
new
File
(
fileFullPath
));
DeploymentBuilder
deploymentBuilder
=
repositoryService
.
createDeployment
().
name
(
curProcess
.
getName
()).
key
(
processDefinitionKey
)
DeploymentBuilder
deploymentBuilder
=
repositoryService
.
createDeployment
().
name
(
curProcess
.
getName
()).
key
(
processDefinitionKey
)
.
addInputStream
(
bpmnFile
.
getPath
()
,
inputStream
);
.
addInputStream
(
fileFullPath
,
inputStream
);
Deployment
deployment
=
deploymentBuilder
.
deploy
();
Deployment
deployment
=
deploymentBuilder
.
deploy
();
wfProcessDefinition
.
setBpmnfile
(
"[{\"id\":\""
+
bmpmfileId
+
"\",\"name\":\""
+
processDefinitionKey
+
".bpmn20.xml\"}]"
);
wfProcessDefinition
.
setMd5check
(
bmpmfileId
);
iwfProcessDefinitionService
.
save
(
wfProcessDefinition
);
// wfProcessDefinition.setMd5check(md5);
// wfProcessDefinition.setMd5check(md5);
// iwfProcessDefinitionService.update(wfProcessDefinition);
// iwfProcessDefinitionService.update(wfProcessDefinition);
log
.
warn
(
"部署流程 name:"
+
curProcess
.
getName
()+
" key "
+
deployment
.
getKey
()
+
" deploy "
+
deployment
);
log
.
warn
(
"部署流程 name:"
+
curProcess
.
getName
()+
" key "
+
deployment
.
getKey
()
+
" deploy "
+
deployment
);
}
}
return
true
;
return
true
;
}
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录