提交 fdf1e93d 编写于 作者: tangyaolong's avatar tangyaolong

回退

上级 36f53b3b
......@@ -33,6 +33,7 @@ import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.history.ProcessInstanceHistoryLog;
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.engine.task.Comment;
import org.flowable.identitylink.api.IdentityLink;
......@@ -587,11 +588,101 @@ public class WFCoreService
setTaskWayForm(sequenceFlow,way);
taskWays.add(way);
}
LinkedHashMap rollBackMap = getTaskProcessForm(userTask);
if(rollBackMap.size()>0){
WFTaskWay rollBackWay = new WFTaskWay();
rollBackWay.set("rollback",rollBackMap.get("rollback"));
taskWays.add(rollBackWay);
}
}
}
return taskWays;
}
public static LinkedHashMap getTaskProcessForm(UserTask userTask){
if(ObjectUtils.isEmpty(userTask)){
return null;
}
List<ExtensionElement> elements = userTask.getExtensionElements().get("form");
if(ObjectUtils.isEmpty(elements)){
return null;
}
LinkedHashMap processMap = new LinkedHashMap();
for (ExtensionElement element : elements) {
List<ExtensionAttribute> extensionAttributes = element.getAttributes().get("process-form");
if(!ObjectUtils.isEmpty(extensionAttributes)){
for (ExtensionAttribute attribute : extensionAttributes) {
String[] keyValue = attribute.getValue().split(":");
if(keyValue.length > 1){
processMap.put(keyValue[0],keyValue[1]);
}
}
}
}
return processMap;
}
/**
* @param taskId 当前需要回退的节点
* @return 回退上一个节点
*/
public boolean wfback(String system,String appname,String entity,String taskId) {
try {
Boolean flag = true;
String sourceRef = null;
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
String taskDefinitionKey = task.getTaskDefinitionKey();
if (taskDefinitionKey == null) {
log.debug("taskDefinitionKey不存在");
return false;
}
String processInstanceId = task.getProcessInstanceId();
if (processInstanceId == null) {
log.debug("processInstanceId不存在");
return false;
}
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(task.getProcessDefinitionId()).singleResult();
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(task.getTaskDefinitionKey());
// 获取历史路径
WFProcessInstance instance = getWFHistory(system, appname, entity, taskDefinitionKey, task.getProcessInstanceId());
if (!ObjectUtils.isEmpty(flowNode) && !ObjectUtils.isEmpty(instance)) {
List<WFProcessNode> usertasks = new ArrayList((Collection<? extends WFProcessNode>) instance.getExtensionparams().get("usertasks"));
for (WFProcessNode node : usertasks) {
for (SequenceFlow flow : flowNode.getIncomingFlows()) {
if (node.getUsertaskid().equals(flow.getSourceRef())&&flow.getSourceRef().startsWith("tid")) {
sourceRef = flow.getSourceRef();
flag = false;
break;
}
}
if (!flag) {
break;
}
}
} else {
return false;
}
// 执行回退
runtimeService.createChangeActivityStateBuilder().processInstanceId(processInstanceId).moveActivityIdTo(taskDefinitionKey, sourceRef).changeState();
} catch (Exception e) {
throw new BadRequestAlertException("回退失败","WFCoreService","wfback");
}
return true;
}
// public void delegateTask(String taskId,String delegater) {
// String userId = SecurityUtils.getCurrentUserObject().getId();
// Task task = permissionService.validateDelegatePermissionOnTask(taskId, userId, delegater);
// taskService.addComment(taskId, processInstanceId, type.toString(), message);
// taskService.delegateTask(task.getId(), delegater);
// }
public WFProcessInstance wfsubmit(String system,String appname,
String entity,String businessKey,String taskId,WFTaskWay taskWay) {
......@@ -1028,7 +1119,7 @@ public class WFCoreService
bpmnLayout.execute();
byte[] bs= bpmnXMLConverter.convertToXML(entitymodel);
bmpmfileId=DigestUtils.md5DigestAsHex(bs);
if(bmpmfileId.equals(old.getMd5check()))
if(bmpmfileId.equals(1))
{
log.warn("部署流程没有变化,忽略 name:" + curProcess.getName() + " key " + processDefinitionKey + " deploy " + bmpmfileId);
deployInfo+=curProcess.getName()+" key:" + processDefinitionKey +",流程配置没有变化,忽略发布"+"\r\n";
......
......@@ -149,6 +149,14 @@ public class WFCoreResource
return ResponseEntity.ok(wfCoreService.wfsubmit(system,appname,entity,businessKey,taskId,taskWay));
}
@ApiOperation(value = "wfback", tags = {"wfback" }, notes = "工作流回退")
@RequestMapping(method = RequestMethod.POST, value = "/{system}-app-{appname}/{entity}/{taskId}/back")
public ResponseEntity<Boolean> wfback(@PathVariable("system") String system,@PathVariable("appname") String appname,
@PathVariable("entity") String entity,
@PathVariable("taskId") String taskId){
return ResponseEntity.ok(wfCoreService.wfback(system,appname,entity,taskId));
}
//@PreAuthorize("hasPermission(#entity,'WFSTART',this.getEntity())")
@ApiOperation(value = "wfsubmitbatch", tags = {"SubmitBatch" }, notes = "批量工作流执行步骤")
@RequestMapping(method = RequestMethod.POST, value = "/{system}-app-{appname}/{entity}/process-definitions/{processDefinitionKey}/usertasks/{taskDefinitionKey}/ways/{sequenceFlowId}/submit")
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册