提交 8a35ca51 编写于 作者: zhouweidong's avatar zhouweidong

流程表单

上级 3a843875
......@@ -60,6 +60,7 @@ import org.springframework.data.domain.PageImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.DigestUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
......@@ -232,9 +233,10 @@ public class WFCoreService
public List<WFTaskWay> getWFLinkByStep(String system,String appname,
String entity, String processDefinitionKey,String taskDefinitionKey) {
List<WFTaskWay> taskWays=new ArrayList<>();
if((!StringUtils.isEmpty(processDefinitionKey))&&(!StringUtils.isEmpty(taskDefinitionKey))) {
UserTask userTask = wfModelService.getModelStepByKey(processDefinitionKey).get(taskDefinitionKey);
//设置流程表单
setProcessForm(userTask);
if(userTask!=null&&userTask.getOutgoingFlows()!=null) {
for(SequenceFlow sequenceFlow:userTask.getOutgoingFlows()) {
WFTaskWay way=new WFTaskWay();
......@@ -242,6 +244,8 @@ public class WFCoreService
way.setSequenceflowname(sequenceFlow.getName());
way.setProcessdefinitionkey(processDefinitionKey);
way.setTaskdefinitionkey(taskDefinitionKey);
//设置流程交互表单
setTaskWayForm(sequenceFlow,way);
taskWays.add(way);
}
}
......@@ -397,6 +401,8 @@ public class WFCoreService
Task task=list.get(0);
if((!StringUtils.isEmpty(task.getProcessDefinitionId()))&&(!StringUtils.isEmpty(task.getTaskDefinitionKey()))) {
UserTask userTask = wfModelService.getModelStepById(task.getProcessDefinitionId()).get(task.getTaskDefinitionKey());
//设置流程表单
setProcessForm(userTask);
if(userTask!=null&&userTask.getOutgoingFlows()!=null) {
for(SequenceFlow sequenceFlow:userTask.getOutgoingFlows()) {
WFTaskWay way=new WFTaskWay();
......@@ -408,6 +414,8 @@ public class WFCoreService
way.setProcessinstanceid(task.getProcessInstanceId());
way.setTaskdefinitionkey(task.getTaskDefinitionKey());
way.setProcessinstancebusinesskey(processInstanceBusinessKey);
//设置流程交互表单
setTaskWayForm(sequenceFlow,way);
taskWays.add(way);
}
}
......@@ -428,6 +436,8 @@ public class WFCoreService
Task task=list.get(0);
if((!StringUtils.isEmpty(task.getProcessDefinitionId()))&&(!StringUtils.isEmpty(task.getTaskDefinitionKey()))) {
UserTask userTask = wfModelService.getModelStepById(task.getProcessDefinitionId()).get(task.getTaskDefinitionKey());
//设置流程表单
setProcessForm(userTask);
if(userTask!=null&&userTask.getOutgoingFlows()!=null) {
for(SequenceFlow sequenceFlow:userTask.getOutgoingFlows()) {
WFTaskWay way=new WFTaskWay();
......@@ -439,6 +449,8 @@ public class WFCoreService
way.setProcessinstanceid(task.getProcessInstanceId());
way.setTaskdefinitionkey(task.getTaskDefinitionKey());
way.setProcessinstancebusinesskey(processInstanceBusinessKey);
//设置流程交互表单
setTaskWayForm(sequenceFlow,way);
taskWays.add(way);
}
}
......@@ -1156,4 +1168,58 @@ public class WFCoreService
return null;
}
}
/**
* 设置流程表单
* @param sequenceFlow
* @param way
*/
private void setTaskWayForm(SequenceFlow sequenceFlow,WFTaskWay way){
if(!ObjectUtils.isEmpty(sequenceFlow.getExtensionElements())){
List<ExtensionElement> formProps=sequenceFlow.getExtensionElements().get("form");
if(!ObjectUtils.isEmpty(formProps)){
for(ExtensionElement prop : formProps){
if(!ObjectUtils.isEmpty(prop.getAttributes())){
for(String attribute : prop.getAttributes().keySet()){
List<ExtensionAttribute> attributes=prop.getAttributes().get(attribute);
if(!ObjectUtils.isEmpty(attributes)){
for(ExtensionAttribute param:attributes){
way.set(param.getName(),param.getValue());
}
}
}
}
}
}
}
}
/**
* 将流程表单设置到请求头中
* @param userTask
*/
private void setProcessForm(UserTask userTask){
Object objReq=RequestContextHolder.currentRequestAttributes();
if(!ObjectUtils.isEmpty(objReq) && objReq instanceof ServletRequestAttributes){
ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
HttpServletRequest req = attr.getRequest();
if(!ObjectUtils.isEmpty(userTask) && !ObjectUtils.isEmpty(userTask.getExtensionElements())){
List<ExtensionElement> formProps=userTask.getExtensionElements().get("form");
if(!ObjectUtils.isEmpty(formProps)){
for(ExtensionElement prop : formProps){
if(!ObjectUtils.isEmpty(prop.getAttributes())){
for(String attribute : prop.getAttributes().keySet()){
List<ExtensionAttribute> attributes=prop.getAttributes().get(attribute);
if(!ObjectUtils.isEmpty(attributes)){
for(ExtensionAttribute param:attributes){
req.setAttribute(param.getName(),param.getValue());
}
}
}
}
}
}
}
}
}
}
......@@ -14,8 +14,11 @@ import org.springframework.data.domain.Page;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -28,6 +31,14 @@ import java.util.Map;
@RequestMapping("")
public class WFCoreResource
{
/**
* 流程PC表单标记
*/
private static final String formTag="process-form";
/**
* 流程移动端表单标记
*/
private static final String mobFormTag="process-mobform";
@Autowired
private WFCoreService wfCoreService;
......@@ -35,7 +46,6 @@ public class WFCoreResource
@Autowired
private IWFTaskService taskService;
@ApiOperation(value = "getWFProcessDefinition", tags = {"WFProcessDefinition" }, notes = "根据系统实体查找当前适配的工作流模型")
@RequestMapping(method = RequestMethod.GET, value = "/{system}-app-{appname}/{entity}/process-definitions")
public ResponseEntity<List<WFProcessDefinition>> getworkflow(@PathVariable("system") String system,@PathVariable("appname") String appname,
......@@ -65,7 +75,8 @@ public class WFCoreResource
public ResponseEntity<List<WFTaskWay>> getwflink(@PathVariable("system") String system,@PathVariable("appname") String appname,
@PathVariable("entity") String entity,
@PathVariable("businessKey") String businessKey,@PathVariable("taskDefinitionKey") String taskDefinitionKey) {
return ResponseEntity.status(HttpStatus.OK).body(wfCoreService.getWFLink(system,appname,entity,businessKey,taskDefinitionKey));
List<WFTaskWay> taskWays=wfCoreService.getWFLink(system,appname,entity,businessKey,taskDefinitionKey);
return ResponseEntity.status(HttpStatus.OK).headers(getHeader()).body(taskWays);
}
@ApiOperation(value = "getWayByProcessDefinitionKey", tags = {"WFStepWay" }, notes = "根据流程和当前步骤获取操作路径")
......@@ -73,7 +84,8 @@ public class WFCoreResource
public ResponseEntity<List<WFTaskWay>> getWayByDefKey(@PathVariable("system") String system,@PathVariable("appname") String appname,
@PathVariable("entity") String entity,
@PathVariable("processDefinitionKey") String processDefinitionKey,@PathVariable("taskDefinitionKey") String taskDefinitionKey) {
return ResponseEntity.status(HttpStatus.OK).body(wfCoreService.getWFLinkByStep(system,appname,entity,processDefinitionKey,taskDefinitionKey));
List<WFTaskWay> taskWays=wfCoreService.getWFLinkByStep(system,appname,entity,processDefinitionKey,taskDefinitionKey);
return ResponseEntity.status(HttpStatus.OK).headers(getHeader()).body(taskWays);
}
@ApiOperation(value = "getWayByTaskId", tags = {"WFTaskWay" }, notes = "根据业务主键和当前步骤获取操作路径")
......@@ -81,7 +93,8 @@ public class WFCoreResource
public ResponseEntity<List<WFTaskWay>> gettasklink(@PathVariable("system") String system,@PathVariable("appname") String appname,
@PathVariable("entity") String entity,
@PathVariable("businessKey") String businessKey,@PathVariable("taskId") String taskId) {
return ResponseEntity.status(HttpStatus.OK).body(wfCoreService.getTaskLink(system,appname,entity,businessKey,taskId));
List<WFTaskWay> taskWays=wfCoreService.getTaskLink(system,appname,entity,businessKey,taskId);
return ResponseEntity.status(HttpStatus.OK).headers(getHeader()).body(taskWays);
}
@ApiOperation(value = "getWFHistory", tags = {"getWFHistory" }, notes = "根据业务主键获取审批意见记录")
......@@ -194,4 +207,23 @@ public class WFCoreResource
return ResponseEntity.status(HttpStatus.OK).body(wfCoreService.wfdeploybpmns(bpmnfiles));
}
/**
* 将流程表单设置到响应头中
*/
private HttpHeaders getHeader() {
Object objReq= RequestContextHolder.currentRequestAttributes();
HttpHeaders headers=new HttpHeaders();
if(!ObjectUtils.isEmpty(objReq) && objReq instanceof ServletRequestAttributes){
ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
HttpServletRequest req = attr.getRequest();
Object form=req.getAttribute(formTag);
Object mobForm=req.getAttribute(mobFormTag);
if(!ObjectUtils.isEmpty(form))
headers.set(formTag,String.valueOf(form));
if(!ObjectUtils.isEmpty(mobForm))
headers.set(mobFormTag,String.valueOf(mobForm));
}
return headers;
}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册