Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzwf
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzwf
提交
f1233299
提交
f1233299
编写于
5月 05, 2020
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
工作流部署
上级
eabffe5e
变更
3
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
213 行增加
和
7 行删除
+213
-7
WFCoreService.java
...ava/cn/ibizlab/core/extensions/service/WFCoreService.java
+131
-7
WFProcessDefinitionServicePublishImpl.java
...s/service/impl/WFProcessDefinitionServicePublishImpl.java
+67
-0
WFCoreResource.java
...n/java/cn/ibizlab/api/rest/extensions/WFCoreResource.java
+15
-0
未找到文件。
ibzwf-core/src/main/java/cn/ibizlab/core/extensions/service/WFCoreService.java
浏览文件 @
f1233299
package
cn
.
ibizlab
.
core
.
extensions
.
service
;
import
cn.ibizlab.core.workflow.domain.WFProcessDefinition
;
import
cn.ibizlab.core.workflow.domain.WFProcessInstance
;
import
cn.ibizlab.core.workflow.domain.WFProcessNode
;
import
cn.ibizlab.core.workflow.domain.WFTaskWay
;
import
cn.ibizlab.core.workflow.domain.*
;
import
cn.ibizlab.core.workflow.service.IWFGroupService
;
import
cn.ibizlab.core.workflow.service.IWFProcessDefinitionService
;
import
cn.ibizlab.util.domain.EntityBase
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
org.flowable.bpmn.model.FlowElement
;
import
org.flowable.bpmn.model.SequenceFlow
;
import
org.flowable.bpmn.model.UserTask
;
import
lombok.extern.slf4j.Slf4j
;
import
org.flowable.bpmn.converter.BpmnXMLConverter
;
import
org.flowable.bpmn.model.*
;
import
org.flowable.bpmn.model.Process
;
import
org.flowable.common.engine.impl.identity.Authentication
;
import
org.flowable.engine.HistoryService
;
import
org.flowable.engine.RepositoryService
;
import
org.flowable.engine.RuntimeService
;
import
org.flowable.engine.TaskService
;
import
org.flowable.engine.delegate.DelegateExecution
;
import
org.flowable.engine.repository.Deployment
;
import
org.flowable.engine.repository.DeploymentBuilder
;
import
org.flowable.engine.repository.ProcessDefinition
;
import
org.flowable.engine.runtime.ProcessInstance
;
import
org.flowable.task.api.Task
;
import
org.flowable.task.api.TaskQuery
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.DigestUtils
;
import
org.springframework.util.StringUtils
;
import
javax.xml.stream.XMLInputFactory
;
import
javax.xml.stream.XMLStreamReader
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.InputStream
;
import
java.sql.Timestamp
;
import
java.util.*
;
@Service
@Slf4j
public
class
WFCoreService
{
...
...
@@ -45,6 +54,12 @@ public class WFCoreService
@Autowired
private
WFModelService
wfModelService
;
@Autowired
private
IWFGroupService
iwfGroupService
;
@Autowired
private
IWFProcessDefinitionService
iwfProcessDefinitionService
;
public
List
<
WFProcessDefinition
>
getWorkflow
(
String
system
,
String
appname
,
String
entity
)
{
return
wfModelService
.
getWorkflow
(
system
,
entity
);
...
...
@@ -271,6 +286,115 @@ public class WFCoreService
return
instance
;
}
public
synchronized
boolean
wfdeploy
(
File
bpmnFile
)
{
XMLStreamReader
reader
=
null
;
InputStream
inputStream
=
null
;
try
{
BpmnXMLConverter
bpmnXMLConverter
=
new
BpmnXMLConverter
();
XMLInputFactory
factory
=
XMLInputFactory
.
newInstance
();
inputStream
=
new
FileInputStream
(
bpmnFile
);
reader
=
factory
.
createXMLStreamReader
(
inputStream
);
BpmnModel
model
=
bpmnXMLConverter
.
convertToBpmnModel
(
reader
);
List
<
Process
>
processes
=
model
.
getProcesses
();
Process
curProcess
=
null
;
if
(
CollectionUtils
.
isEmpty
(
processes
))
{
return
false
;
}
curProcess
=
processes
.
get
(
0
);
String
bookings
=
""
;
String
refgroups
=
""
;
if
(!
curProcess
.
getExtensionElements
().
containsKey
(
"field"
))
{
log
.
error
(
bpmnFile
.
getName
()+
"没有实体订阅"
);
return
false
;
}
for
(
ExtensionElement
field:
curProcess
.
getExtensionElements
().
get
(
"field"
))
{
if
(
"bookings"
.
equals
(
field
.
getAttributes
().
get
(
"name"
).
get
(
0
).
getValue
()))
bookings
=
field
.
getChildElements
().
get
(
"string"
).
get
(
0
).
getElementText
();
if
(
"refgroups"
.
equals
(
field
.
getAttributes
().
get
(
"name"
).
get
(
0
).
getValue
()))
refgroups
=
field
.
getChildElements
().
get
(
"string"
).
get
(
0
).
getElementText
();
}
if
(
StringUtils
.
isEmpty
(
bookings
))
{
log
.
error
(
bpmnFile
.
getName
()+
"没有实体订阅"
);
return
false
;
}
if
(!
StringUtils
.
isEmpty
(
refgroups
))
{
List
<
WFGroup
>
listGroup
=
new
ArrayList
<>();
for
(
String
refgroup:
refgroups
.
split
(
","
))
{
String
[]
groupParam
=
refgroup
.
split
(
"[\\|]"
);
if
(
groupParam
.
length
==
3
)
{
WFGroup
wfGroup
=
new
WFGroup
();
wfGroup
.
setId
(
groupParam
[
0
]);
wfGroup
.
setName
(
groupParam
[
1
]);
wfGroup
.
setGroupscope
(
groupParam
[
2
]);
listGroup
.
add
(
wfGroup
);
}
}
if
(
listGroup
.
size
()>
0
)
iwfGroupService
.
saveBatch
(
listGroup
);
}
String
[]
params
=
curProcess
.
getId
().
split
(
"-"
);
if
(
params
.
length
!=
2
)
{
log
.
error
(
bpmnFile
.
getName
()+
"没有系统名称"
);
return
false
;
}
String
system
=
params
[
0
];
Integer
version
=
Integer
.
parseInt
(
params
[
1
].
substring
(
params
[
1
].
lastIndexOf
(
"v"
)+
1
));
inputStream
=
new
FileInputStream
(
bpmnFile
);
String
md5
=
DigestUtils
.
md5DigestAsHex
(
inputStream
);
for
(
String
booking:
bookings
.
split
(
","
))
{
String
processDefinitionKey
=
system
+
"-"
+
booking
+
"-"
+
params
[
1
];
WFProcessDefinition
old
=
iwfProcessDefinitionService
.
get
(
processDefinitionKey
);
if
(
md5
.
equals
(
old
.
getMd5check
()))
continue
;
WFProcessDefinition
wfProcessDefinition
=
new
WFProcessDefinition
();
wfProcessDefinition
.
setDefinitionkey
(
processDefinitionKey
);
wfProcessDefinition
.
setDeploykey
(
processDefinitionKey
);
wfProcessDefinition
.
setPssystemid
(
system
);
wfProcessDefinition
.
setModelenable
(
1
);
wfProcessDefinition
.
setModelversion
(
version
);
wfProcessDefinition
.
setDefinitionname
(
curProcess
.
getName
());
wfProcessDefinition
.
setBpmnfile
(
"[{\"id\":\""
+
md5
+
"\",\"name\":\""
+
bpmnFile
.
getName
()+
"\"}]"
);
wfProcessDefinition
.
setMd5check
(
md5
);
iwfProcessDefinitionService
.
save
(
wfProcessDefinition
);
inputStream
=
new
FileInputStream
(
bpmnFile
);
DeploymentBuilder
deploymentBuilder
=
repositoryService
.
createDeployment
().
name
(
curProcess
.
getName
()).
key
(
processDefinitionKey
)
.
addInputStream
(
bpmnFile
.
getPath
(),
inputStream
);
Deployment
deployment
=
deploymentBuilder
.
deploy
();
// wfProcessDefinition.setMd5check(md5);
// iwfProcessDefinitionService.update(wfProcessDefinition);
log
.
warn
(
"部署流程 name:"
+
curProcess
.
getName
()+
" key "
+
deployment
.
getKey
()
+
" deploy "
+
deployment
);
}
return
true
;
}
catch
(
Exception
e
){
log
.
error
(
bpmnFile
.
getName
()+
"BPMN模型创建流程异常"
,
e
);
return
false
;
}
finally
{
try
{
reader
.
close
();
}
catch
(
Exception
e
)
{
log
.
error
(
bpmnFile
.
getName
()+
"关闭异常"
,
e
);
}
}
}
public
void
execute
(
DelegateExecution
delegateExecution
,
Object
activedata
)
throws
Exception
{
String
entity
=
(
String
)
delegateExecution
.
getVariable
(
"pass"
);
...
...
ibzwf-core/src/main/java/cn/ibizlab/core/extensions/service/impl/WFProcessDefinitionServicePublishImpl.java
0 → 100644
浏览文件 @
f1233299
package
cn
.
ibizlab
.
core
.
extensions
.
service
.
impl
;
import
cn.ibizlab.core.extensions.service.WFCoreService
;
import
cn.ibizlab.core.workflow.domain.WFProcessDefinition
;
import
cn.ibizlab.core.workflow.service.impl.WFProcessDefinitionServiceImpl
;
import
cn.ibizlab.util.domain.FileItem
;
import
cn.ibizlab.util.service.FileService
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
java.io.File
;
import
java.util.List
;
@Service
@Primary
public
class
WFProcessDefinitionServicePublishImpl
extends
WFProcessDefinitionServiceImpl
{
@Override
public
boolean
create
(
WFProcessDefinition
et
)
{
if
(!
super
.
create
(
et
))
return
false
;
publish
(
et
);
return
true
;
}
@Override
public
boolean
update
(
WFProcessDefinition
et
)
{
if
(!
super
.
update
(
et
))
return
false
;
publish
(
et
);
return
true
;
}
@Autowired
private
FileService
fileService
;
@Autowired
@Lazy
private
WFCoreService
wfCoreService
;
public
void
publish
(
WFProcessDefinition
et
)
{
if
(
StringUtils
.
isEmpty
(
et
.
getBpmnfile
()))
return
;
String
oldMd5
=
""
;
if
(!
StringUtils
.
isEmpty
(
et
.
getMd5check
()))
oldMd5
=
et
.
getMd5check
();
List
<
FileItem
>
items
=
JSONArray
.
parseArray
(
et
.
getBpmnfile
(),
FileItem
.
class
);
if
(
items
.
size
()==
0
)
return
;
FileItem
item
=
items
.
get
(
items
.
size
()-
1
);
if
(
item
.
getId
().
equals
(
oldMd5
))
return
;
File
bpmnFile
=
fileService
.
getFile
(
item
.
getId
());
if
(!
bpmnFile
.
exists
())
return
;
wfCoreService
.
wfdeploy
(
bpmnFile
);
}
}
ibzwf-provider/ibzwf-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/WFCoreResource.java
浏览文件 @
f1233299
...
...
@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
...
...
@@ -76,5 +77,19 @@ public class WFCoreResource
}
@ApiOperation
(
value
=
"getBusinessKeys"
,
tags
=
{
"String"
},
notes
=
"根据流程步骤查询我的待办主键清单"
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/{system}-app-{appname}/{entity}/process-definitions/{taskDefinitionKey}/usertasks/{taskDefinitionKey}/tasks"
)
public
ResponseEntity
<
List
<
String
>>
getbusinesskeys
(
@PathVariable
(
"system"
)
String
system
,
@PathVariable
(
"appname"
)
String
appname
,
@PathVariable
(
"entity"
)
String
entity
,
@PathVariable
(
"taskDefinitionKey"
)
String
processDefinitionKey
,
@PathVariable
(
"taskDefinitionKey"
)
String
taskDefinitionKey
)
{
if
(
StringUtils
.
isEmpty
(
appname
)||
"null"
.
equals
(
appname
)||
"alls"
.
equals
(
appname
))
appname
=
""
;
if
(
StringUtils
.
isEmpty
(
processDefinitionKey
)||
"null"
.
equals
(
processDefinitionKey
)||
"alls"
.
equals
(
processDefinitionKey
))
processDefinitionKey
=
""
;
if
(
StringUtils
.
isEmpty
(
taskDefinitionKey
)||
"null"
.
equals
(
taskDefinitionKey
)||
"alls"
.
equals
(
taskDefinitionKey
))
taskDefinitionKey
=
""
;
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
wfCoreService
.
getBusinessKeys
(
system
,
appname
,
entity
,
processDefinitionKey
,
taskDefinitionKey
));
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录