|
|
@ -1,5 +1,7 @@ |
|
|
|
package com.yxt.anrui.flowable.biz.flowtask; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.yxt.anrui.flowable.biz.process.ProcessService; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserInfoVo; |
|
|
|
import org.apache.commons.io.IOUtils; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
@ -79,6 +81,8 @@ import java.util.stream.Collectors; |
|
|
|
@Service |
|
|
|
@Slf4j |
|
|
|
public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask> { |
|
|
|
@Resource |
|
|
|
private ProcessService processService; |
|
|
|
@Autowired |
|
|
|
FlowTaskMapper flowTaskMapper; |
|
|
|
@Resource |
|
|
@ -104,6 +108,53 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
@Resource |
|
|
|
private AppSubsetVersionFeign appSubsetVersionFeign; |
|
|
|
|
|
|
|
public ResultBean getProcessCirculationNodesByMap(Map<String, Object> variables) { |
|
|
|
String modelId = null; |
|
|
|
if (variables.get("modelId") != null) { |
|
|
|
modelId = variables.get("modelId").toString(); |
|
|
|
} |
|
|
|
String procId = null; |
|
|
|
if (variables.get("procId") != null) { |
|
|
|
procId = variables.get("procId").toString(); |
|
|
|
} |
|
|
|
List<FlowElement> flowElements = processService.calApprovePath(procId, modelId, variables); |
|
|
|
List<FlowElement> collect = flowElements.stream().filter(item -> item.getId().length() > 0).collect(Collectors.toList()); |
|
|
|
for (int i = 0; i < collect.size(); i++) { |
|
|
|
if (collect.get(i).getId().equals(modelId)) { |
|
|
|
FlowElement item = collect.get(i + 1); |
|
|
|
log.info("flowElement:{}", item); |
|
|
|
log.info("nodeName:{}", item.getName()); |
|
|
|
log.info("nodeId:{}", item.getId()); |
|
|
|
String s = JSON.toJSONString(item); |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(s); |
|
|
|
log.info("item:{}", jsonObject); |
|
|
|
Object candidateGroups = jsonObject.get("candidateGroups"); |
|
|
|
JSONArray candidateGroups_arr = new JSONArray(); |
|
|
|
if (candidateGroups != null) { |
|
|
|
candidateGroups_arr = JSONArray.parseArray(candidateGroups.toString()); |
|
|
|
} |
|
|
|
if (candidateGroups_arr.size() > 0) { |
|
|
|
log.info("candidateGroups_sid:{}", candidateGroups_arr.get(0)); |
|
|
|
} |
|
|
|
log.info("candidateGroups:{}", candidateGroups_arr); |
|
|
|
} |
|
|
|
} |
|
|
|
ResultBean<List<Map<String, Object>>> rb = new ResultBean<List<Map<String, Object>>>(); |
|
|
|
List<Map<String, Object>> list = new ArrayList<>(); |
|
|
|
for (FlowElement f : flowElements) { |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("name", f.getName()); |
|
|
|
map.put("id", f.getId()); |
|
|
|
String s = JSON.toJSONString(f); |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(s); |
|
|
|
log.info("item:{}", jsonObject); |
|
|
|
Object candidateGroups = jsonObject.get("candidateGroups"); |
|
|
|
map.put("candidateGroups", candidateGroups); |
|
|
|
list.add(map); |
|
|
|
} |
|
|
|
return rb.setData(list); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 流程历史流转记录 |
|
|
|
* |
|
|
@ -366,7 +417,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
} |
|
|
|
} |
|
|
|
// 用户角色sid
|
|
|
|
// List<String> roleSidList = sysUserRoleFeign.getUserRoleSidByUserSid(userSid).getData();
|
|
|
|
// List<String> roleSidList = sysUserRoleFeign.getUserRoleSidByUserSid(userSid).getData();
|
|
|
|
/* if (CollectionUtils.isEmpty(roleSidList)) { |
|
|
|
return new ResultBean().fail().setMsg("请先设置用户角色"); |
|
|
|
}*/ |
|
|
@ -374,7 +425,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
.includeProcessVariables() |
|
|
|
.or() |
|
|
|
//.taskCandidateGroupIn(roleSidList)
|
|
|
|
.taskAssignee(userSid) |
|
|
|
.taskAssigneeLike("%" + userSid + "%") |
|
|
|
.endOr() |
|
|
|
.orderByTaskCreateTime().desc(); |
|
|
|
// 查询筛选条件
|
|
|
@ -662,7 +713,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
Date date = new Date(time); |
|
|
|
flowTask.setCreateTime(date); |
|
|
|
flowTask.setAssigneeSid(histTask.get("ASSIGNEE_") == null ? "" : histTask.get("ASSIGNEE_").toString()); |
|
|
|
if(histTask.get("ASSIGNEE_")!=null&&StringUtils.isNotBlank(histTask.get("ASSIGNEE_").toString())){ |
|
|
|
if (histTask.get("ASSIGNEE_") != null && StringUtils.isNotBlank(histTask.get("ASSIGNEE_").toString())) { |
|
|
|
ResultBean<SysUserInfoVo> assignee_ = sysUserFeign.selectUserInfoByUserSid(histTask.get("ASSIGNEE_").toString()); |
|
|
|
flowTask.setAssigneeName(assignee_.getData().getStaffName()); |
|
|
|
} |
|
|
@ -750,24 +801,18 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
* |
|
|
|
* @param dto 请求实体参数 |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
// @Transactional(rollbackFor = Exception.class)
|
|
|
|
public ResultBean<FlowTask> businessComplete(BusinessVariables dto) { |
|
|
|
|
|
|
|
ResultBean<FlowTask> rb = new ResultBean<>(); |
|
|
|
ResultBean<FlowTask> rb = ResultBean.fireFail(); |
|
|
|
Map<String, Object> formVariables = dto.getFormVariables(); |
|
|
|
// formVariables.put("handleUrl", dto.getHandleUrl());
|
|
|
|
// formVariables.put("detailUrl", dto.getDetailUrl());
|
|
|
|
Object taskId_obj = formVariables.get("taskId"); |
|
|
|
String procInsId= formVariables.get("instanceId").toString(); |
|
|
|
String nextUserSid= formVariables.get("nextUserSid").toString(); |
|
|
|
String taskId = null; |
|
|
|
if (taskId_obj == null) { |
|
|
|
return rb.fail().setMsg("taskId 不能为空!").setData(new FlowTask()); |
|
|
|
} else { |
|
|
|
taskId = (String) taskId_obj; |
|
|
|
if (StringUtils.isBlank(taskId)) { |
|
|
|
return rb.fail().setMsg("taskId 不能为空!").setData(new FlowTask()); |
|
|
|
} |
|
|
|
String taskId = (String) formVariables.get("taskId"); |
|
|
|
String procInsId = (String) formVariables.get("instanceId"); |
|
|
|
String nextUserSid = (String) formVariables.get("nextUserSid"); |
|
|
|
if (StringUtils.isBlank(taskId)) { |
|
|
|
return rb.setMsg("taskId 不能为空!").setData(new FlowTask()); |
|
|
|
} |
|
|
|
Object comment_obj = formVariables.get("comment"); |
|
|
|
String comment = null; |
|
|
@ -802,7 +847,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
Object businessSid_obj = formVariables.get("businessSid"); |
|
|
|
String businessSid = null; |
|
|
|
if (businessSid_obj == null) { |
|
|
|
return rb.fail().setMsg("业务sid 不能为空!").setData(new FlowTask()); |
|
|
|
return rb.setMsg("业务sid 不能为空!").setData(new FlowTask()); |
|
|
|
} else { |
|
|
|
businessSid = (String) businessSid_obj; |
|
|
|
if (StringUtils.isBlank(businessSid)) { |
|
|
@ -811,7 +856,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
} |
|
|
|
Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); |
|
|
|
if (Objects.isNull(task)) { |
|
|
|
return rb.fail().setMsg("任务不存在").setData(new FlowTask()); |
|
|
|
return rb.setMsg("任务不存在").setData(new FlowTask()); |
|
|
|
} |
|
|
|
if (DelegationState.PENDING.equals(task.getDelegationState())) { |
|
|
|
taskService.addComment(taskId, instanceId, |
|
|
@ -823,9 +868,11 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
FlowComment.NORMAL.getType(), comment); |
|
|
|
taskService.setAssignee(taskId, userSid); |
|
|
|
taskService.complete(taskId, formVariables); |
|
|
|
ResultBean<List<LatestTaskVo>> l= getLatestTasksNew(procInsId); |
|
|
|
if(l.getData().size()>0){ |
|
|
|
LatestTaskVo latestTaskVo = l.getData().get(0); |
|
|
|
|
|
|
|
//根据流程实例的id取最新的待办环节,给环节设置上用户sid
|
|
|
|
ResultBean<List<LatestTaskVo>> ll = getLatestTasksNew(procInsId); |
|
|
|
if (ll.getData().size() > 0) { |
|
|
|
LatestTaskVo latestTaskVo = ll.getData().get(0); |
|
|
|
String id_ = latestTaskVo.getId_(); |
|
|
|
taskService.setAssignee(id_, nextUserSid); |
|
|
|
} |
|
|
@ -879,7 +926,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
* |
|
|
|
* @param flowTaskVo 请求实体参数 |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
// @Transactional(rollbackFor = Exception.class)
|
|
|
|
public void taskReturn(FlowTaskVo flowTaskVo) { |
|
|
|
if (taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult().isSuspended()) { |
|
|
|
throw new CustomException("任务处于挂起状态"); |
|
|
@ -1054,7 +1101,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
// 设置驳回意见
|
|
|
|
currentTaskIds.forEach(item -> { |
|
|
|
taskService.addComment(item, task.getProcessInstanceId(), FlowComment.REJECT.getType(), flowTaskVo.getComment()); |
|
|
|
taskService.setAssignee(item, flowTaskVo.getUserSid()); |
|
|
|
//taskService.setAssignee(item, flowTaskVo.getUserSid());
|
|
|
|
}); |
|
|
|
|
|
|
|
// 最近环节
|
|
|
@ -1079,11 +1126,11 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
LatestTaskVo latestTaskVo = new LatestTaskVo(); |
|
|
|
latestTaskVo.setASSIGNEE_(item.getAssignee()); |
|
|
|
latestTaskVo.setId_(item.getId()); |
|
|
|
Map<String,Object> map= flowTaskMapper.getHistTaskByID(task.getProcessInstanceId(),targetIds.get(0)); |
|
|
|
Map<String,Object> map2= flowTaskMapper.getTaskByDefKey(task.getProcessInstanceId(),targetIds.get(0)); |
|
|
|
Map<String, Object> map = flowTaskMapper.getHistTaskByID(task.getProcessInstanceId(), targetIds.get(0)); |
|
|
|
Map<String, Object> map2 = flowTaskMapper.getTaskByDefKey(task.getProcessInstanceId(), targetIds.get(0)); |
|
|
|
String id_ = map2.get("id_").toString(); |
|
|
|
String assignee_ = map.get("ASSIGNEE_").toString(); |
|
|
|
taskService.setAssignee(id_,assignee_); |
|
|
|
taskService.setAssignee(id_, assignee_); |
|
|
|
latestTaskVo.setName_(item.getName()); |
|
|
|
latestTaskVo.setTask_def_key_(item.getId()); |
|
|
|
latestTaskVo.setIncomingSourceRef(item.getIncomingFlows().get(0).getSourceRef()); |
|
|
@ -1176,7 +1223,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
return historicActivityInstance.getTaskId(); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
// @Transactional(rollbackFor = Exception.class)
|
|
|
|
public ResultBean<List<LatestTaskVo>> revokeProcess(FlowTaskVo flowTaskVo) { |
|
|
|
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(flowTaskVo.getTaskId()).singleResult(); |
|
|
|
Execution execution = runtimeService.createExecutionQuery().executionId(historicTaskInstance.getExecutionId()).singleResult(); |
|
|
@ -1325,6 +1372,8 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
latestTaskVo.setTask_def_key_(item.getId()); |
|
|
|
latestTaskVo.setIncomingSourceRef(item.getIncomingFlows().get(0).getSourceRef()); |
|
|
|
latestTaskList.add(latestTaskVo); |
|
|
|
Map<String, Object> task_map = flowTaskMapper.getTaskByDefKey(historicTaskInstance.getProcessInstanceId(), item.getId()); |
|
|
|
taskService.setAssignee(task_map.get("id_").toString(), userSid); |
|
|
|
}); |
|
|
|
} catch (FlowableObjectNotFoundException e) { |
|
|
|
throw new CustomException("未找到流程实例,流程可能已发生变化"); |
|
|
@ -1470,7 +1519,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("id", targetFlow.getId()); |
|
|
|
map.put("name", targetFlow.getName()); |
|
|
|
// map.put("assignee", ((UserTask) targetFlow).getAssignee());
|
|
|
|
// map.put("assignee", ((UserTask) targetFlow).getAssignee());
|
|
|
|
lists.add(map); |
|
|
|
} |
|
|
|
if (targetFlow instanceof Gateway) {// 如果下个审批节点为结束节点
|
|
|
@ -1512,7 +1561,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
return ResultBean.fireSuccess(); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean readXml(String deployId) { |
|
|
|
public ResultBean readXml(String deployId) { |
|
|
|
ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult(); |
|
|
|
InputStream inputStream = repositoryService.getResourceAsStream(definition.getDeploymentId(), definition.getResourceName()); |
|
|
|
String result = null; |
|
|
@ -1521,7 +1570,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
ResultBean r=ResultBean.fireSuccess().setData(result); |
|
|
|
ResultBean r = ResultBean.fireSuccess().setData(result); |
|
|
|
return r; |
|
|
|
} |
|
|
|
} |