Browse Source

车辆外采流程办理

master
yxt_djz 3 years ago
parent
commit
71d645024a
  1. 246
      anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow/FlowableRest.java
  2. 12
      anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow/FlowableService.java
  3. 4
      anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowdefinition/FlowDefinitionService.java
  4. 45
      anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowtask/FlowTaskController.java
  5. 109
      anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowtask/FlowTaskService.java

246
anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow/FlowableRest.java

@ -26,17 +26,35 @@
package com.yxt.anrui.flowable.biz.flow;
import com.yxt.anrui.flowable.api.flow.FlowTaskQuery;
import com.yxt.anrui.flowable.api.flow.FlowTaskVo;
import com.yxt.anrui.flowable.api.flow.FlowableFeign;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.yxt.anrui.flowable.api.flow.*;
import com.yxt.anrui.flowable.api.flowtask.LatestTaskVo;
import com.yxt.anrui.flowable.api.sysformlink.SysFormLinkFlowStateEnum;
import com.yxt.anrui.flowable.api.utils.ProcDefEnum;
import com.yxt.anrui.flowable.api.utils.ProcessStateEnum;
import com.yxt.anrui.flowable.biz.flowtask.FlowTaskService;
import com.yxt.anrui.flowable.common.FlowComment;
import com.yxt.anrui.flowable.sqloperationsymbol.BusinessVariables;
import com.yxt.anrui.portal.api.sysuser.SysUserFeign;
import com.yxt.anrui.portal.api.sysuser.SysUserVo;
import com.yxt.anrui.portal.api.sysuser.UserQuery;
import com.yxt.common.base.utils.StringUtils;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.flowable.engine.TaskService;
import org.flowable.task.api.DelegationState;
import org.flowable.task.api.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* Project: anrui-parent <br/>
@ -58,6 +76,12 @@ public class FlowableRest implements FlowableFeign {
@Autowired
private FlowableService flowableService;
@Autowired
private FlowTaskService flowtaskService;
@Autowired
private SysUserFeign sysUserFeign;
@Resource
protected TaskService taskService;
@Override
public ResultBean businessStart(@ApiParam(value = "流程定义id") @PathVariable(value = "procDefId") String procDefId,
@ -89,4 +113,220 @@ public class FlowableRest implements FlowableFeign {
flowableService.deleteProcess(procInsId);
return ResultBean.fireSuccess();
}
@Override
public ResultBean<String> getNextNodeUserSidsOfCreate(Map<String, Object> variables) {
String orgSidPath=(String)variables.get("orgSidPath");
//根据业务参数取流程流转的环节 信息
List<Map<String, Object>> list = (List<Map<String, Object>>) flowtaskService.getProcessCirculationNodesByMap(variables).getData();
//取第二个环节的配置角色
Object o = list.get(1).get("candidateGroups");
JSONArray jsonArray = JSONArray.parseArray(JSON.toJSONString(o));
String roleSid = jsonArray.get(0).toString();
//根据组织架构、角色两个参数取相关符合条件的用户信息
UserQuery userQuery = new UserQuery();
userQuery.setRoleSid(roleSid);
userQuery.setOrgSidPath(orgSidPath);
List<SysUserVo> sysUserVos = sysUserFeign.getUserByRole(userQuery).getData();
StringBuilder nextNodeUserSids = new StringBuilder();
for (SysUserVo su : sysUserVos) {
nextNodeUserSids.append(su.getSid()).append(",");
}
//符合条件的用户的sid,拼接的字符串
String nextNodeUserSids_ = nextNodeUserSids.toString();
nextNodeUserSids_ = nextNodeUserSids_.substring(0, nextNodeUserSids_.length() - 1);
ResultBean rb = ResultBean.fireSuccess();
return rb.setData(nextNodeUserSids_);
}
@Override
public ResultBean getNextNodeUserSidsOfSubmit(Map<String, Object> variables) {
ResultBean rb = ResultBean.fireSuccess();
String orgSidPath=(String)variables.get("orgSidPath");
String taskDefKey=(String)variables.get("taskDefKey");
//根据业务参数取流程流转的环节 信息
List<Map<String, Object>> list = (List<Map<String, Object>>) flowtaskService.getProcessCirculationNodesByMap(variables).getData();
Map<String, Object> task_map=new HashMap<>();
//取第二个环节的配置角色
boolean endTask=true;
for (int i=0;i< list.size();i++){
String id=list.get(i).get("id").toString();
if(id.equals(taskDefKey)){
task_map=list.get(i+1);
endTask=false;
}
}
if(endTask){
task_map.put("name","结束");
return rb.setData("");
}else{
//如果不是最后一个环节 要取下一个环节的角色sid
List<String> candidateGroups= (List<String>) task_map.get("candidateGroups");
String roleSid=candidateGroups.get(0);
//根据组织架构、角色两个参数取相关符合条件的用户信息
UserQuery userQuery = new UserQuery();
userQuery.setRoleSid(roleSid);
userQuery.setOrgSidPath(orgSidPath);
List<SysUserVo> sysUserVos = sysUserFeign.getUserByRole(userQuery).getData();
StringBuilder nextNodeUserSids = new StringBuilder();
for (SysUserVo su : sysUserVos) {
nextNodeUserSids.append(su.getSid()).append(",");
}
//符合条件的用户的sid,拼接的字符串
String nextNodeUserSids_ = nextNodeUserSids.toString();
nextNodeUserSids_ = nextNodeUserSids_.substring(0, nextNodeUserSids_.length() - 1);
return rb.setData(nextNodeUserSids_);
}
}
@Override
public ResultBean<UpdateFlowFieldVo> startProcess(StartProcessDto dto) {
ResultBean rb = ResultBean.fireFail();
String nextNodeUserSids_=getNextNodeUserSidsOfCreate(dto.getVariables()).getData();
dto.getVariables().put("nextNodeUserSids",nextNodeUserSids_);
ResultBean resultBean1 = flowableService.businessStart(ProcDefEnum.BASEOUTSOURCINGAPPLICATION.getProDefId(), dto.getUserSid(), dto.getVariables());
UpdateFlowFieldVo vo = new UpdateFlowFieldVo();
if (resultBean1.getSuccess() && resultBean1.getData() != null) {
vo.setSid("" + dto.getVariables().get("businessSid"));
Map<String, String> map = (Map<String, String>) resultBean1.getData();
vo.setProcDefId(ProcDefEnum.BASEOUTSOURCINGAPPLICATION.getProDefId());
vo.setNodeState(map.get("nodeState"));
vo.setProcInsId(map.get("procInsId"));
vo.setTaskDefKey(map.get("taskDefKey"));
vo.setTaskId(map.get("taskId"));
vo.setNextNodeUserSids(nextNodeUserSids_);
}
return rb.success().setData(vo);
}
@Override
public ResultBean handleProsess(BusinessVariables dto) {
UpdateFlowFieldVo vo = new UpdateFlowFieldVo();
ResultBean rb = ResultBean.fireFail();
Map<String, Object> formVariables = dto.getFormVariables();
String taskId = (String) formVariables.get("taskId");
if (StringUtils.isBlank(taskId)) {
return rb.setMsg("taskId 不能为空!");
}
String procInsId = (String) formVariables.get("instanceId");
ResultBean<String> resultBean = getNextNodeUserSidsOfSubmit(dto.getFormVariables());
String nextUserSid=resultBean.getData();
String comment = (String) formVariables.get("comment");
if (StringUtils.isBlank(comment)) {
return rb.setMsg("comment 不能为空!");
}
String instanceId = (String) formVariables.get("instanceId");
if (StringUtils.isBlank(instanceId)) {
return rb.setMsg("instanceId 不能为空!");
}
String userSid = (String) formVariables.get("userSid");
if (StringUtils.isBlank(userSid)) {
return rb.setMsg("userSid 不能为空!");
}
String businessSid = (String) formVariables.get("businessSid");
if (StringUtils.isBlank(businessSid)) {
return rb.setMsg("业务sid 不能为空!");
}
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
if (Objects.isNull(task)) {
return rb.setMsg("任务不存在");
}
String nodeState = "";
String taskDefKey = "";
vo.setSid(businessSid);
if (DelegationState.PENDING.equals(task.getDelegationState())) {
taskService.addComment(taskId, instanceId,
FlowComment.DELEGATE.getType(), comment);
// Map<String,Object> values =(Map<String,Object>) formVariables.get("values");
taskService.resolveTask(taskId, formVariables);
} else {
taskService.addComment(taskId, instanceId,
FlowComment.NORMAL.getType(), comment);
//taskService.setAssignee(taskId, userSid);
//formVariables.remove("userSid");
taskService.complete(taskId, formVariables);
//根据流程实例的id取最新的待办环节,给环节设置上用户sid
ResultBean<List<LatestTaskVo>> ll = flowtaskService.getLatestTasksNew(procInsId);
if (ll.getData().size() > 0) {
LatestTaskVo latestTaskVo = ll.getData().get(0);
String id_ = latestTaskVo.getId_();
taskService.setAssignee(id_, nextUserSid);
vo.setTaskId(id_);
nodeState = latestTaskVo.getName_();
taskDefKey = latestTaskVo.getTask_def_key_();
} else {
nodeState = ProcessStateEnum.FINISHED.getStateName();
taskDefKey = "Event_end";
vo.setNodeState(SysFormLinkFlowStateEnum.FINISH.getCode());
}
}
vo.setProcInsId(instanceId);
vo.setProcDefId(task.getProcessDefinitionId());
vo.setNodeState(nodeState);
vo.setTaskDefKey(taskDefKey);
vo.setNextNodeUserSids(nextUserSid);
return rb.setData(vo).success();
}
@Override
public ResultBean revokeProcess(com.yxt.anrui.flowable.api.flowtask.FlowTaskVo fl) {
ResultBean rb = ResultBean.fireFail();
UpdateFlowFieldVo vo = new UpdateFlowFieldVo();
ResultBean<List<LatestTaskVo>> resultBean = flowtaskService.revokeProcess(fl);
if (!resultBean.getSuccess()) {
return rb;
}
String nodeState = resultBean.getData().get(0).getName_();
String taskDefKey = resultBean.getData().get(0).getTask_def_key_();
String incomingSourceRef = resultBean.getData().get(0).getIncomingSourceRef();
vo.setSid(fl.getBusinessSid());
if (incomingSourceRef.contains("start")) {
vo.setNodeState(SysFormLinkFlowStateEnum.UNCOMMITTED.getState());
vo.setTaskDefKey(taskDefKey);
} else {
vo.setNodeState( nodeState);
vo.setTaskDefKey( taskDefKey);
}
return rb.setData(vo).setSuccess(true);
}
@Override
public ResultBean<UpdateFlowFieldVo> taskReject(com.yxt.anrui.flowable.api.flowtask.FlowTaskVo fl) {
ResultBean rb = ResultBean.fireFail();
UpdateFlowFieldVo vo = new UpdateFlowFieldVo();
ResultBean<List<LatestTaskVo>> resultBean = flowtaskService.taskReject(fl);
if (!resultBean.getSuccess()) {
return rb;
}
String nodeState = resultBean.getData().get(0).getName_();
String taskDefKey = resultBean.getData().get(0).getTask_def_key_();
String incomingSourceRef = resultBean.getData().get(0).getIncomingSourceRef();
vo.setSid(fl.getBusinessSid());
vo.setNodeState( nodeState);
vo.setTaskDefKey( taskDefKey);
if (incomingSourceRef.contains("start")) {
vo.setNodeState( SysFormLinkFlowStateEnum.REJECT.getCode());
}
return rb.setData(vo).setSuccess(true);
}
@Override
public ResultBean breakProcess(com.yxt.anrui.flowable.api.flowtask.FlowTaskVo fl) {
ResultBean rb = ResultBean.fireFail();
UpdateFlowFieldVo vo = new UpdateFlowFieldVo();
ResultBean resultBean = flowableService.breakProcess(fl);
if (!resultBean.getSuccess()) {
return resultBean;
}
vo.setSid(fl.getBusinessSid());
vo.setNodeState( String.valueOf(resultBean.getData()));
vo.setTaskDefKey( "Event_end");
return rb.setData(vo).setSuccess(true);
}
}

12
anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow/FlowableService.java

@ -43,8 +43,6 @@ public class FlowableService extends MybatisBaseService<FlowableMapper, Flowable
variables.put("procDefId", procDefId);
variables.put("userSid", userSid);
BusinessVariables bv = BusinessVariables.builder().build();
bv.setDetailUrl("");
bv.setHandleUrl("");
bv.setFormVariables(variables);
ResultBean<FlowTask> rb = flowDefinitionService.businessStart(bv);
if (!rb.getSuccess()) {
@ -177,8 +175,6 @@ public class FlowableService extends MybatisBaseService<FlowableMapper, Flowable
*/
public ResultBean complete(Map<String, Object> variables) {
BusinessVariables bv = BusinessVariables.builder().build();
bv.setDetailUrl("");
bv.setHandleUrl("");
bv.setFormVariables(variables);
ResultBean<FlowTask> resultBean = flowTaskService.businessComplete(bv);
if (!resultBean.getSuccess()) {
@ -242,10 +238,10 @@ public class FlowableService extends MybatisBaseService<FlowableMapper, Flowable
* @param flowTaskVo
* @return
*/
public ResultBean breakProcess(FlowTaskVo flowTaskVo) {
com.yxt.anrui.flowable.api.flowtask.FlowTaskVo fl = new com.yxt.anrui.flowable.api.flowtask.FlowTaskVo();
BeanUtil.copyProperties(flowTaskVo, fl);
ResultBean resultBean = flowTaskService.breakProcess(fl);
public ResultBean breakProcess(com.yxt.anrui.flowable.api.flowtask.FlowTaskVo flowTaskVo) {
/* com.yxt.anrui.flowable.api.flowtask.FlowTaskVo fl = new com.yxt.anrui.flowable.api.flowtask.FlowTaskVo();
BeanUtil.copyProperties(flowTaskVo, fl);*/
ResultBean resultBean = flowTaskService.breakProcess(flowTaskVo);
if (!resultBean.getSuccess()) {
return resultBean;
}

4
anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowdefinition/FlowDefinitionService.java

@ -198,7 +198,7 @@ public class FlowDefinitionService extends FlowServiceFactory {
List<LatestTaskVo> data = latestTasksNew.getData();
LatestTaskVo latestTaskVo = data.get(0);
String id_ = latestTaskVo.getId_();
taskService.setAssignee(id_, userSid);
taskService.setAssignee(id_, variables.get("nextNodeUserSids").toString());
ResultBean<FlowTask> rb = new ResultBean<>();
FlowTask flowTask = new FlowTask();
flowTask.setTaskId(task.getId());
@ -231,8 +231,6 @@ public class FlowDefinitionService extends FlowServiceFactory {
public ResultBean<FlowTask> businessStart(BusinessVariables dto) {
ResultBean<FlowTask> resultBean = new ResultBean<>();
Map<String, Object> variables = dto.getFormVariables();
variables.put("handleUrl", dto.getHandleUrl());
variables.put("detailUrl", dto.getDetailUrl());
Object procDefId_obj = variables.get("procDefId");
Object userSid_obj = variables.get("userSid");
String procDefId = null;

45
anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowtask/FlowTaskController.java

@ -278,50 +278,7 @@ public class FlowTaskController implements FlowTaskFeign {
@Override
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<FlowElement>> rb = new ResultBean<List<FlowElement>>();
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(flowElements);
return flowTaskService.getProcessCirculationNodesByMap(variables);
}
@Override

109
anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowtask/FlowTaskService.java

@ -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;
}
}
Loading…
Cancel
Save