Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzwf
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzwf
提交
243aa39b
提交
243aa39b
编写于
8月 12, 2020
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
待办跳转
上级
9a813d59
变更
4
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
191 行增加
和
45 行删除
+191
-45
WFCoreService.java
...izlab/core/workflow/extensions/service/WFCoreService.java
+155
-34
WFCoreResource.java
...n/java/cn/ibizlab/api/rest/extensions/WFCoreResource.java
+22
-11
IBZUAAFallback.java
.../src/main/java/cn/ibizlab/util/client/IBZUAAFallback.java
+6
-0
IBZUAAFeignClient.java
...c/main/java/cn/ibizlab/util/client/IBZUAAFeignClient.java
+8
-0
未找到文件。
ibzwf-core/src/main/java/cn/ibizlab/core/workflow/extensions/service/WFCoreService.java
浏览文件 @
243aa39b
...
...
@@ -7,11 +7,14 @@ import cn.ibizlab.core.workflow.mapper.WFCoreMapper;
import
cn.ibizlab.core.workflow.service.IWFGroupService
;
import
cn.ibizlab.core.workflow.service.IWFProcessDefinitionService
;
import
cn.ibizlab.core.workflow.service.IWFUserService
;
import
cn.ibizlab.util.client.IBZUAAFeignClient
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.helper.RuleUtils
;
import
cn.ibizlab.util.security.AuthTokenUtil
;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
cn.ibizlab.util.service.RemoteService
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.io.IOUtils
;
...
...
@@ -52,6 +55,8 @@ import org.flowable.ui.modeler.serviceapi.AppDefinitionService;
import
org.flowable.ui.modeler.serviceapi.ModelService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.DigestUtils
;
...
...
@@ -74,10 +79,13 @@ public class WFCoreService
@Autowired
private
RepositoryService
repositoryService
;
@Autowired
private
HistoryService
historyService
;
@Autowired
private
TaskService
taskService
;
@Autowired
private
RuntimeService
runtimeService
;
...
...
@@ -90,7 +98,6 @@ public class WFCoreService
@Autowired
private
IWFUserService
iwfUserService
;
@Autowired
protected
AppDefinitionService
appDefinitionService
;
...
...
@@ -103,6 +110,12 @@ public class WFCoreService
@Autowired
private
AuthTokenUtil
jwtTokenUtil
;
@Autowired
private
WFCoreMapper
wfCoreMapper
;
@Autowired
private
IBZUAAFeignClient
ibzuaaFeignClient
;
private
AuthenticationContext
createAuthenticationContext
()
{
UserIdAuthenticationContext
context
=
new
UserIdAuthenticationContext
();
...
...
@@ -140,9 +153,6 @@ public class WFCoreService
return
definitionKeys
;
}
@Autowired
private
WFCoreMapper
wfCoreMapper
;
public
List
<
WFProcessNode
>
getWFStep
(
String
system
,
String
appname
,
String
entity
)
{
List
<
WFProcessNode
>
rt
=
new
ArrayList
<>();
for
(
WFProcessDefinition
wfdef:
wfModelService
.
getWorkflow
(
system
,
entity
))
{
...
...
@@ -212,6 +222,95 @@ public class WFCoreService
return
wfStepCnt
;
}
public
Page
<
WFTask
>
searchMyTask
(
WFTaskSearchContext
context
)
{
context
.
setSort
(
"createtime,desc"
);
com
.
baomidou
.
mybatisplus
.
extension
.
plugins
.
pagination
.
Page
<
WFTask
>
pages
=
wfCoreMapper
.
searchMyTask
(
context
.
getPages
(),
context
,
context
.
getSelectCond
());
return
new
PageImpl
<
WFTask
>(
pages
.
getRecords
(),
context
.
getPageable
(),
pages
.
getTotal
());
}
public
String
getTaskUrl
(
String
type
,
String
processDefinitionKey
,
String
processInstanceId
,
String
businessKey
,
String
taskDefinitionKey
)
{
JSONObject
app
=
ibzuaaFeignClient
.
getAppSwitcher
(
"default"
,
AuthenticationUser
.
getAuthenticationUser
().
getUserid
());
String
[]
arr
=
processDefinitionKey
.
split
(
"-"
);
String
systemId
=
arr
[
0
];
String
entity
=
arr
[
1
];
if
(
app
!=
null
&&
app
.
containsKey
(
"model"
))
{
List
<
Map
>
array
=
app
.
getObject
(
"model"
,
ArrayList
.
class
);
int
cnt
=
0
;
Map
<
String
,
String
>
serviceAddrs
=
new
HashMap
<>();
String
addr
=
""
;
for
(
Map
item:
array
)
{
if
(
item
.
get
(
"systemId"
)!=
null
&&
systemId
.
equalsIgnoreCase
(
item
.
get
(
"systemId"
).
toString
()))
{
cnt
++;
if
(!
StringUtils
.
isEmpty
(
item
.
get
(
"addr"
)))
{
addr
=
item
.
get
(
"addr"
).
toString
();
if
(!
addr
.
endsWith
(
"/"
))
addr
+=
"/"
;
if
(!
StringUtils
.
isEmpty
(
item
.
get
(
"id"
)))
serviceAddrs
.
put
(
item
.
get
(
"id"
).
toString
(),
addr
);
}
}
}
if
(
cnt
==
1
&&(!
StringUtils
.
isEmpty
(
addr
)))
{
addr
+=
String
.
format
(
"#/appwfdataredirectview?srfappde=%1$s;srfappkey=%2$s;userTaskId=%3$s"
,
entity
,
businessKey
,
taskDefinitionKey
);
return
addr
;
}
String
serviceIds
=
""
;
WFProcessDefinition
definition
=
iwfProcessDefinitionService
.
get
(
processDefinitionKey
);
if
((!
StringUtils
.
isEmpty
(
type
))&&
type
.
toUpperCase
().
startsWith
(
"mob"
))
serviceIds
=
definition
.
getMobileserviceids
();
else
serviceIds
=
definition
.
getWebserviceids
();
if
(!
StringUtils
.
isEmpty
(
serviceIds
))
{
for
(
String
serviceId:
serviceIds
.
split
(
","
))
{
if
(
serviceAddrs
.
containsKey
(
serviceId
))
{
addr
=
serviceAddrs
.
get
(
serviceId
);
break
;
}
}
if
(!
StringUtils
.
isEmpty
(
addr
))
{
addr
+=
String
.
format
(
"#/appwfdataredirectview?srfappde=%1$s;srfappkey=%2$s;userTaskId=%3$s"
,
entity
,
businessKey
,
taskDefinitionKey
);
return
addr
;
}
}
}
return
""
;
}
public
List
<
String
>
getBusinessKeys
(
String
system
,
String
appname
,
String
entity
,
String
processDefinitionKey
,
String
taskDefinitionKey
,
String
userId
)
{
List
<
String
>
businessKeys
=
new
ArrayList
<>();
String
processInstanceBusinessKeyLike
=
system
+
":"
+
entity
+
":k-"
;
if
(
StringUtils
.
isEmpty
(
userId
))
userId
=
AuthenticationUser
.
getAuthenticationUser
().
getUserid
();
if
(
StringUtils
.
isEmpty
(
userId
))
return
businessKeys
;
TaskQuery
query
=
taskService
.
createTaskQuery
().
taskCandidateOrAssigned
(
userId
);
if
(!
StringUtils
.
isEmpty
(
processDefinitionKey
))
query
.
processDefinitionKey
(
processDefinitionKey
);
else
{
query
.
processDefinitionKeyIn
(
this
.
getWorkflowKey
(
system
,
appname
,
entity
));
}
if
(!
StringUtils
.
isEmpty
(
taskDefinitionKey
))
query
.
taskDefinitionKey
(
taskDefinitionKey
);
List
<
Task
>
tasks
=
query
.
listPage
(
0
,
500
);
for
(
Task
task:
tasks
)
{
Object
key
=
task
.
getCategory
();
if
(
key
!=
null
)
{
String
str
=
key
.
toString
();
if
(
str
.
indexOf
(
":k-"
)>
0
)
str
=
str
.
split
(
":k-"
)[
1
];
businessKeys
.
add
(
str
);
}
}
return
businessKeys
;
}
public
WFProcessInstance
wfStart
(
String
system
,
String
appname
,
String
entity
,
String
businessKey
,
WFProcessInstance
instance
)
{
String
userId
=
AuthenticationUser
.
getAuthenticationUser
().
getUserid
();
...
...
@@ -326,36 +425,6 @@ public class WFCoreService
return
taskWays
;
}
public
List
<
String
>
getBusinessKeys
(
String
system
,
String
appname
,
String
entity
,
String
processDefinitionKey
,
String
taskDefinitionKey
,
String
userId
)
{
List
<
String
>
businessKeys
=
new
ArrayList
<>();
String
processInstanceBusinessKeyLike
=
system
+
":"
+
entity
+
":k-"
;
if
(
StringUtils
.
isEmpty
(
userId
))
userId
=
AuthenticationUser
.
getAuthenticationUser
().
getUserid
();
if
(
StringUtils
.
isEmpty
(
userId
))
return
businessKeys
;
TaskQuery
query
=
taskService
.
createTaskQuery
().
taskCandidateOrAssigned
(
userId
);
if
(!
StringUtils
.
isEmpty
(
processDefinitionKey
))
query
.
processDefinitionKey
(
processDefinitionKey
);
else
{
query
.
processDefinitionKeyIn
(
this
.
getWorkflowKey
(
system
,
appname
,
entity
));
}
if
(!
StringUtils
.
isEmpty
(
taskDefinitionKey
))
query
.
taskDefinitionKey
(
taskDefinitionKey
);
List
<
Task
>
tasks
=
query
.
listPage
(
0
,
500
);
for
(
Task
task:
tasks
)
{
Object
key
=
task
.
getCategory
();
if
(
key
!=
null
)
{
String
str
=
key
.
toString
();
if
(
str
.
indexOf
(
":k-"
)>
0
)
str
=
str
.
split
(
":k-"
)[
1
];
businessKeys
.
add
(
str
);
}
}
return
businessKeys
;
}
public
WFProcessInstance
wfsubmit
(
String
system
,
String
appname
,
String
entity
,
String
businessKey
,
String
taskId
,
WFTaskWay
taskWay
)
{
...
...
@@ -609,12 +678,36 @@ public class WFCoreService
wfreModel
.
setName
(
deployInfo
);
return
false
;
}
Map
<
String
,
String
>
bookingapps
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
bookingmobs
=
new
HashMap
<
String
,
String
>();
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
(
field
.
getAttributes
().
get
(
"name"
).
get
(
0
).
getValue
().
startsWith
(
"bookingapps_"
))
{
String
bookingapp
=
field
.
getChildElements
().
get
(
"string"
).
get
(
0
).
getElementText
();
if
(!
StringUtils
.
isEmpty
(
bookingapp
))
{
String
[]
arr
=
field
.
getAttributes
().
get
(
"name"
).
get
(
0
).
getValue
().
split
(
"_"
);
if
(
arr
.
length
>
1
)
bookingapps
.
put
(
arr
[
1
],
bookingapp
);
}
}
if
(
field
.
getAttributes
().
get
(
"name"
).
get
(
0
).
getValue
().
startsWith
(
"bookingmobs_"
))
{
String
bookingmob
=
field
.
getChildElements
().
get
(
"string"
).
get
(
0
).
getElementText
();
if
(!
StringUtils
.
isEmpty
(
bookingmob
))
{
String
[]
arr
=
field
.
getAttributes
().
get
(
"name"
).
get
(
0
).
getValue
().
split
(
"_"
);
if
(
arr
.
length
>
1
)
bookingmobs
.
put
(
arr
[
1
],
bookingmob
);
}
}
}
if
(
StringUtils
.
isEmpty
(
bookings
))
{
...
...
@@ -682,6 +775,34 @@ public class WFCoreService
wfProcessDefinition
.
setModelenable
(
1
);
wfProcessDefinition
.
setModelversion
(
version
);
wfProcessDefinition
.
setDefinitionname
(
curProcess
.
getName
());
if
(
bookingapps
.
containsKey
(
booking
))
{
String
[]
arr
=
bookingapps
.
get
(
booking
).
split
(
","
);
String
serviceIds
=
""
;
for
(
String
str:
arr
)
{
if
(
StringUtils
.
isEmpty
(
str
))
continue
;
if
(!
StringUtils
.
isEmpty
(
serviceIds
))
serviceIds
+=
","
;
serviceIds
=
serviceIds
+
system
+
"-"
+
str
;
}
wfProcessDefinition
.
setWebserviceids
(
serviceIds
);
}
if
(
bookingmobs
.
containsKey
(
booking
))
{
String
[]
arr
=
bookingmobs
.
get
(
booking
).
split
(
","
);
String
serviceIds
=
""
;
for
(
String
str:
arr
)
{
if
(
StringUtils
.
isEmpty
(
str
))
continue
;
if
(!
StringUtils
.
isEmpty
(
serviceIds
))
serviceIds
+=
","
;
serviceIds
=
serviceIds
+
system
+
"-"
+
str
;
}
wfProcessDefinition
.
setMobileserviceids
(
serviceIds
);
}
OutputStream
out
=
null
;
InputStream
is
=
null
;
...
...
ibzwf-provider/ibzwf-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/WFCoreResource.java
浏览文件 @
243aa39b
...
...
@@ -5,6 +5,7 @@ import cn.ibizlab.core.workflow.domain.*;
import
cn.ibizlab.core.workflow.extensions.service.WFCoreService
;
import
cn.ibizlab.core.workflow.filter.WFTaskSearchContext
;
import
cn.ibizlab.core.workflow.service.IWFTaskService
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -15,6 +16,8 @@ import org.springframework.http.ResponseEntity;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -107,7 +110,6 @@ public class WFCoreResource
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
wfCoreService
.
getBusinessKeys
(
system
,
appname
,
entity
,
processDefinitionKey
,
taskDefinitionKey
,
""
));
}
@ApiOperation
(
value
=
"getBusinessKeys"
,
tags
=
{
"String"
},
notes
=
"根据流程步骤查询我的待办主键清单"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/{system}-user-{userId}/{entity}/process-definitions/{processDefinitionKey}/usertasks/{taskDefinitionKey}/tasks"
)
public
ResponseEntity
<
List
<
String
>>
getbusinesskeysByUserId
(
@PathVariable
(
"system"
)
String
system
,
@PathVariable
(
"userId"
)
String
userId
,
...
...
@@ -123,8 +125,7 @@ public class WFCoreResource
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/{system}-app-{appname}/mytasks"
)
public
ResponseEntity
<
List
<
WFTask
>>
fetchDefault
(
@PathVariable
(
"system"
)
String
system
,
WFTaskSearchContext
context
)
{
context
.
setN_definitionkey_leftlike
(
system
);
context
.
setSort
(
"createtime,desc"
);
Page
<
WFTask
>
domains
=
taskService
.
searchDefault
(
context
)
;
Page
<
WFTask
>
domains
=
wfCoreService
.
searchMyTask
(
context
)
;
return
ResponseEntity
.
status
(
HttpStatus
.
OK
)
.
header
(
"x-page"
,
String
.
valueOf
(
context
.
getPageable
().
getPageNumber
()))
.
header
(
"x-per-page"
,
String
.
valueOf
(
context
.
getPageable
().
getPageSize
()))
...
...
@@ -132,17 +133,10 @@ public class WFCoreResource
.
body
(
domains
.
getContent
());
}
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/deploybpmn"
)
public
ResponseEntity
<
Boolean
>
deployBpmnFile
(
@RequestBody
List
<
Map
<
String
,
Object
>>
bpmnfiles
){
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
wfCoreService
.
wfdeploybpmns
(
bpmnfiles
));
}
@ApiOperation
(
value
=
"获取我的全部待办"
,
tags
=
{
"工作流任务"
}
,
notes
=
"获取我的全部待办"
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/mytasks"
)
public
ResponseEntity
<
List
<
WFTask
>>
fetchMyTasks
(
WFTaskSearchContext
context
)
{
context
.
setSort
(
"createtime,desc"
);
Page
<
WFTask
>
domains
=
taskService
.
searchDefault
(
context
)
;
Page
<
WFTask
>
domains
=
wfCoreService
.
searchMyTask
(
context
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
)
.
header
(
"x-page"
,
String
.
valueOf
(
context
.
getPageable
().
getPageNumber
()))
.
header
(
"x-per-page"
,
String
.
valueOf
(
context
.
getPageable
().
getPageSize
()))
...
...
@@ -150,4 +144,21 @@ public class WFCoreResource
.
body
(
domains
.
getContent
());
}
@RequestMapping
(
value
=
"/mytasks/{processDefinitionKey}/{type}/{businessKey}/usertasks/{taskDefinitionKey}"
,
method
=
RequestMethod
.
GET
)
@ResponseStatus
(
HttpStatus
.
FOUND
)
public
void
openTask
(
@PathVariable
(
"processDefinitionKey"
)
final
String
processDefinitionKey
,
@PathVariable
(
"type"
)
final
String
type
,
@PathVariable
(
"businessKey"
)
final
String
businessKey
,
@PathVariable
(
"taskDefinitionKey"
)
final
String
taskDefinitionKey
,
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
String
path
=
wfCoreService
.
getTaskUrl
(
type
,
processDefinitionKey
,
""
,
businessKey
,
taskDefinitionKey
);
if
(
StringUtils
.
isEmpty
(
path
))
throw
new
BadRequestAlertException
(
"未找到待办任务处理页"
,
""
,
""
);
response
.
setHeader
(
"Location"
,
path
);
}
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/deploybpmn"
)
public
ResponseEntity
<
Boolean
>
deployBpmnFile
(
@RequestBody
List
<
Map
<
String
,
Object
>>
bpmnfiles
){
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
wfCoreService
.
wfdeploybpmns
(
bpmnfiles
));
}
}
ibzwf-util/src/main/java/cn/ibizlab/util/client/IBZUAAFallback.java
浏览文件 @
243aa39b
...
...
@@ -4,6 +4,7 @@ import cn.ibizlab.util.security.AuthenticationUser;
import
cn.ibizlab.util.security.AuthorizationLogin
;
import
org.springframework.stereotype.Component
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.web.bind.annotation.PathVariable
;
@Component
public
class
IBZUAAFallback
implements
IBZUAAFeignClient
{
...
...
@@ -27,4 +28,9 @@ public class IBZUAAFallback implements IBZUAAFeignClient {
public
String
getPublicKey
()
{
return
null
;
}
@Override
public
JSONObject
getAppSwitcher
(
String
id
,
String
userId
)
{
return
null
;
}
}
ibzwf-util/src/main/java/cn/ibizlab/util/client/IBZUAAFeignClient.java
浏览文件 @
243aa39b
...
...
@@ -7,6 +7,8 @@ import org.springframework.cloud.openfeign.FeignClient;
import
org.springframework.web.bind.annotation.*
;
import
com.alibaba.fastjson.JSONObject
;
import
javax.servlet.http.HttpServletRequest
;
@FeignClient
(
value
=
"${ibiz.ref.service.uaa:ibzuaa-api}"
,
fallback
=
IBZUAAFallback
.
class
)
public
interface
IBZUAAFeignClient
{
...
...
@@ -33,4 +35,10 @@ public interface IBZUAAFeignClient
@Cacheable
(
value
=
"ibzuaa_publickey"
)
@GetMapping
(
value
=
"/uaa/publickey"
)
String
getPublicKey
();
@Cacheable
(
value
=
"ibzuaa_switcher"
,
key
=
"'id:'+#p0+'||'+#p1"
)
@GetMapping
(
value
=
"/uaa/access-center/app-switcher/{id}"
)
JSONObject
getAppSwitcher
(
@PathVariable
(
"id"
)
String
id
,
String
userId
);
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录