|
|
@ -14,6 +14,7 @@ import com.yxt.anrui.flowable.biz.sysprourl.SysProUrlService; |
|
|
|
import com.yxt.anrui.flowable.common.FlowComment; |
|
|
|
import com.yxt.anrui.flowable.exception.CustomException; |
|
|
|
import com.yxt.anrui.flowable.sqloperationsymbol.BusinessTaskParam; |
|
|
|
import com.yxt.anrui.flowable.sqloperationsymbol.BusinessTaskQuery; |
|
|
|
import com.yxt.anrui.flowable.sqloperationsymbol.BusinessVariables; |
|
|
|
import com.yxt.anrui.flowable.sqloperationsymbol.SQLOperationSymbol; |
|
|
|
import com.yxt.anrui.flowable.utils.FlowableUtils; |
|
|
@ -27,6 +28,7 @@ import com.yxt.common.base.config.component.FileUploadComponent; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
|
import com.yxt.common.base.utils.DateUtils; |
|
|
|
import com.yxt.common.base.utils.StringUtils; |
|
|
|
import com.yxt.common.core.query.PagerQuery; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
@ -92,6 +94,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
private SysProUrlService sysProUrlService; |
|
|
|
@Resource |
|
|
|
private AppSubsetVersionFeign appSubsetVersionFeign; |
|
|
|
|
|
|
|
/** |
|
|
|
* 流程历史流转记录 |
|
|
|
* |
|
|
@ -164,6 +167,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
} |
|
|
|
return ResultBean.fireSuccess().setData(map); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 流程历史流转记录 |
|
|
|
* |
|
|
@ -191,7 +195,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
SysUserVo data = sysUserVoResultBean.getData(); |
|
|
|
// flowTask.setAssigneeId(data.getSid());
|
|
|
|
flowTask.setAssigneeName(data.getName()); |
|
|
|
flowTask.setAssigneeHeadImage(fileUploadComponent.getUrlPrefix()+data.getHeadImage()); |
|
|
|
flowTask.setAssigneeHeadImage(fileUploadComponent.getUrlPrefix() + data.getHeadImage()); |
|
|
|
//flowTask.setDeptName(sysUser.getDept().getDeptName());
|
|
|
|
} |
|
|
|
// 展示审批人员
|
|
|
@ -230,6 +234,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
} |
|
|
|
return ResultBean.fireSuccess().setData(map); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取流程执行过程 |
|
|
|
* |
|
|
@ -302,9 +307,10 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
flowList.add(flowTask); |
|
|
|
} |
|
|
|
page.setRecords(flowList); |
|
|
|
ResultBean<Page<FlowTaskDto>> rb=new ResultBean<Page<FlowTaskDto>>().fireFail(); |
|
|
|
ResultBean<Page<FlowTaskDto>> rb = new ResultBean<Page<FlowTaskDto>>().fireFail(); |
|
|
|
return rb.setData(page); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 代办任务列表 |
|
|
|
* |
|
|
@ -323,7 +329,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
// 流程参数
|
|
|
|
Map<String, Object> paramMap = new HashMap<>(); |
|
|
|
// 挂载表单参数
|
|
|
|
for(BusinessTaskParam btq:params){ |
|
|
|
for (BusinessTaskParam btq : params) { |
|
|
|
paramMap.put(btq.getField(), btq.getValue()); |
|
|
|
// if(btq.getSqlOperationSymbol().equals(SQLOperationSymbol.EQUAL)){
|
|
|
|
// taskQuery.processVariableValueEquals(btq.getField(),btq.getValue());
|
|
|
@ -336,15 +342,15 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
// taskQuery.processDefinitionId(btq.getValue());
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
if(btq.getSqlOperationSymbol().equals(SQLOperationSymbol.NONE)){ |
|
|
|
if("orgSid".equals(btq.getField())){ |
|
|
|
if (btq.getSqlOperationSymbol().equals(SQLOperationSymbol.NONE)) { |
|
|
|
if ("orgSid".equals(btq.getField())) { |
|
|
|
String value = btq.getValue(); |
|
|
|
String[] split = value.split(","); |
|
|
|
for(int i=0;i<split.length;i++){ |
|
|
|
if(i!=0){ |
|
|
|
taskQuery.or().processVariableValueLike("orgSid",split[i]+"%"); |
|
|
|
}else{ |
|
|
|
taskQuery.processVariableValueLike("orgSid",split[0]+"%"); |
|
|
|
for (int i = 0; i < split.length; i++) { |
|
|
|
if (i != 0) { |
|
|
|
taskQuery.or().processVariableValueLike("orgSid", split[i] + "%"); |
|
|
|
} else { |
|
|
|
taskQuery.processVariableValueLike("orgSid", split[0] + "%"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -373,7 +379,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
taskQuery.processDefinitionNameLike("%" + paramMap.get("proDefName") + "%"); |
|
|
|
} |
|
|
|
page.setTotal(taskQuery.count()); |
|
|
|
int p=(pageNum-1)*pageSize; |
|
|
|
int p = (pageNum - 1) * pageSize; |
|
|
|
List<Task> taskList = taskQuery.listPage(p, pageSize); |
|
|
|
List<FlowTaskDto> flowList = new ArrayList<>(); |
|
|
|
for (Task task : taskList) { |
|
|
@ -421,12 +427,13 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
flowList.add(flowTask); |
|
|
|
} |
|
|
|
page.setRecords(flowList); |
|
|
|
ResultBean<Page<FlowTaskDto>> rb=new ResultBean<Page<FlowTaskDto>>(); |
|
|
|
return rb .success().setData(page); |
|
|
|
ResultBean<Page<FlowTaskDto>> rb = new ResultBean<Page<FlowTaskDto>>(); |
|
|
|
return rb.success().setData(page); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 业务系统查询待办任务列表数量 |
|
|
|
* |
|
|
|
* @param userSid |
|
|
|
* @return |
|
|
|
*/ |
|
|
@ -437,6 +444,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询app或pc需要的参数 --( 废弃) |
|
|
|
* |
|
|
|
* @param task |
|
|
|
* @return |
|
|
|
*/ |
|
|
@ -588,9 +596,10 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
// Map<String, Object> result = new HashMap<>();
|
|
|
|
// result.put("result",page);
|
|
|
|
// result.put("finished",true);
|
|
|
|
ResultBean<Page<FlowTaskDto>> rb=new ResultBean<Page<FlowTaskDto>>().fireFail(); |
|
|
|
ResultBean<Page<FlowTaskDto>> rb = new ResultBean<Page<FlowTaskDto>>().fireFail(); |
|
|
|
return rb.setData(page); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 已办任务列表 |
|
|
|
* |
|
|
@ -598,24 +607,24 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
* @param pageSize 每页条数 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean<Page<FlowTaskDto>> businessFinishedList(String userSid, List<BusinessTaskParam> params,Integer pageNum, Integer pageSize) { |
|
|
|
public ResultBean<Page<FlowTaskDto>> businessFinishedList(String userSid, List<BusinessTaskParam> params, Integer pageNum, Integer pageSize) { |
|
|
|
|
|
|
|
Page<FlowTaskDto> page = new Page<>(); |
|
|
|
Map<String, Object> paraMap = new HashMap<>(); |
|
|
|
List< Map<String,Object>> ll=new ArrayList<>(); |
|
|
|
for(BusinessTaskParam btq:params){ |
|
|
|
List<Map<String, Object>> ll = new ArrayList<>(); |
|
|
|
for (BusinessTaskParam btq : params) { |
|
|
|
paraMap.put(btq.getField(), btq.getValue()); |
|
|
|
|
|
|
|
Map<String,Object> mapss=new HashMap<>(); |
|
|
|
if(btq.getSqlOperationSymbol().equals(SQLOperationSymbol.EQUAL)){ |
|
|
|
mapss.put("symbol","="); |
|
|
|
mapss.put("value",btq.getValue()); |
|
|
|
mapss.put("filed",btq.getField()); |
|
|
|
Map<String, Object> mapss = new HashMap<>(); |
|
|
|
if (btq.getSqlOperationSymbol().equals(SQLOperationSymbol.EQUAL)) { |
|
|
|
mapss.put("symbol", "="); |
|
|
|
mapss.put("value", btq.getValue()); |
|
|
|
mapss.put("filed", btq.getField()); |
|
|
|
} |
|
|
|
if(btq.getSqlOperationSymbol().equals(SQLOperationSymbol.LIKE)){ |
|
|
|
mapss.put("symbol","like"); |
|
|
|
mapss.put("value","%"+btq.getValue()+"%"); |
|
|
|
mapss.put("filed",btq.getField()); |
|
|
|
if (btq.getSqlOperationSymbol().equals(SQLOperationSymbol.LIKE)) { |
|
|
|
mapss.put("symbol", "like"); |
|
|
|
mapss.put("value", "%" + btq.getValue() + "%"); |
|
|
|
mapss.put("filed", btq.getField()); |
|
|
|
} |
|
|
|
/* if(btq.getSqlOperationSymbol().equals(SQLOperationSymbol.NONE)){ |
|
|
|
if("processDefinitionId".equals(btq.getField())){ |
|
|
@ -627,13 +636,13 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
|
|
|
|
paraMap.put("userSid", userSid); |
|
|
|
paraMap.put("list", ll); |
|
|
|
paraMap.put("page", (pageNum-1)*pageSize); |
|
|
|
paraMap.put("page", (pageNum - 1) * pageSize); |
|
|
|
paraMap.put("size", pageSize); |
|
|
|
// List<Map<String, Object>> maps = baseMapper.finishedList(userSid, ll ,(pageNum-1)*pageSize,pageSize);
|
|
|
|
List<Map<String, Object>> maps = baseMapper.finishedList1(paraMap); |
|
|
|
int count = baseMapper.finishedListCount(paraMap); |
|
|
|
|
|
|
|
List<FlowTaskDto> hisTaskList=new ArrayList(); |
|
|
|
List<FlowTaskDto> hisTaskList = new ArrayList(); |
|
|
|
for (Map<String, Object> histTask : maps) { |
|
|
|
FlowTaskDto flowTask = new FlowTaskDto(); |
|
|
|
// 当前流程信息
|
|
|
@ -675,14 +684,14 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().taskId(flowTask.getTaskId()).singleResult(); |
|
|
|
flowTask.setProcessVariables(historicTaskInstance.getProcessVariables()); |
|
|
|
Object end_act_id = histTask.get("end_act_id_"); |
|
|
|
if(end_act_id!=null){ |
|
|
|
flowTask.setEndActId((String)end_act_id); |
|
|
|
if (end_act_id != null) { |
|
|
|
flowTask.setEndActId((String) end_act_id); |
|
|
|
} |
|
|
|
Object end_time = histTask.get("end_time"); |
|
|
|
if(end_time!=null){ |
|
|
|
if (end_time != null) { |
|
|
|
Timestamp end_time_t = (Timestamp) end_time; |
|
|
|
long end_time_t_l = end_time_t.getTime(); |
|
|
|
flowTask.setEndTime( new Date(end_time_t_l)); |
|
|
|
flowTask.setEndTime(new Date(end_time_t_l)); |
|
|
|
} |
|
|
|
flowTask.setProcessVariables(historicTaskInstance.getProcessVariables()); |
|
|
|
|
|
|
@ -695,9 +704,10 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
} |
|
|
|
page.setTotal(count); |
|
|
|
page.setRecords(hisTaskList); |
|
|
|
ResultBean<Page<FlowTaskDto>> rb=new ResultBean<Page<FlowTaskDto>>(); |
|
|
|
ResultBean<Page<FlowTaskDto>> rb = new ResultBean<Page<FlowTaskDto>>(); |
|
|
|
return rb.success().setData(page); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 完成任务 |
|
|
|
* |
|
|
@ -706,7 +716,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public ResultBean complete(FlowTaskVo taskVo) { |
|
|
|
Task task = taskService.createTaskQuery().taskId(taskVo.getTaskId()).singleResult(); |
|
|
|
if (Objects.isNull(task)){ |
|
|
|
if (Objects.isNull(task)) { |
|
|
|
return ResultBean.fireFail().setMsg("任务不存在"); |
|
|
|
} |
|
|
|
if (DelegationState.PENDING.equals(task.getDelegationState())) { |
|
|
@ -720,6 +730,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
} |
|
|
|
return ResultBean.fireSuccess(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 完成任务 |
|
|
|
* |
|
|
@ -729,60 +740,60 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
public ResultBean<FlowTask> businessComplete(BusinessVariables dto) { |
|
|
|
ResultBean<FlowTask> rb = new ResultBean<>(); |
|
|
|
Map<String, Object> formVariables = dto.getFormVariables(); |
|
|
|
formVariables.put("handleUrl",dto.getHandleUrl()); |
|
|
|
formVariables.put("detailUrl",dto.getDetailUrl()); |
|
|
|
formVariables.put("handleUrl", dto.getHandleUrl()); |
|
|
|
formVariables.put("detailUrl", dto.getDetailUrl()); |
|
|
|
Object taskId_obj = formVariables.get("taskId"); |
|
|
|
String taskId=null; |
|
|
|
if(taskId_obj==null){ |
|
|
|
String taskId = null; |
|
|
|
if (taskId_obj == null) { |
|
|
|
return rb.fail().setMsg("taskId 不能为空!").setData(new FlowTask()); |
|
|
|
}else{ |
|
|
|
taskId=(String) taskId_obj; |
|
|
|
if(StringUtils.isBlank(taskId)){ |
|
|
|
} else { |
|
|
|
taskId = (String) taskId_obj; |
|
|
|
if (StringUtils.isBlank(taskId)) { |
|
|
|
return rb.fail().setMsg("taskId 不能为空!").setData(new FlowTask()); |
|
|
|
} |
|
|
|
} |
|
|
|
Object comment_obj = formVariables.get("comment"); |
|
|
|
String comment=null; |
|
|
|
if(comment_obj==null){ |
|
|
|
String comment = null; |
|
|
|
if (comment_obj == null) { |
|
|
|
return rb.fail().setMsg("comment 不能为空!").setData(new FlowTask()); |
|
|
|
}else{ |
|
|
|
comment=(String) comment_obj; |
|
|
|
if(StringUtils.isBlank(comment)){ |
|
|
|
} else { |
|
|
|
comment = (String) comment_obj; |
|
|
|
if (StringUtils.isBlank(comment)) { |
|
|
|
return rb.fail().setMsg("comment 不能为空!").setData(new FlowTask()); |
|
|
|
} |
|
|
|
} |
|
|
|
Object instanceId_obj = formVariables.get("instanceId"); |
|
|
|
String instanceId=null; |
|
|
|
if(instanceId_obj==null){ |
|
|
|
String instanceId = null; |
|
|
|
if (instanceId_obj == null) { |
|
|
|
return rb.fail().setMsg("instanceId 不能为空!").setData(new FlowTask()); |
|
|
|
}else{ |
|
|
|
instanceId=(String) instanceId_obj; |
|
|
|
if(StringUtils.isBlank(instanceId)){ |
|
|
|
} else { |
|
|
|
instanceId = (String) instanceId_obj; |
|
|
|
if (StringUtils.isBlank(instanceId)) { |
|
|
|
return rb.fail().setMsg("instanceId 不能为空!").setData(new FlowTask()); |
|
|
|
} |
|
|
|
} |
|
|
|
Object userSid_obj = formVariables.get("userSid"); |
|
|
|
String userSid=null; |
|
|
|
if(userSid_obj==null){ |
|
|
|
String userSid = null; |
|
|
|
if (userSid_obj == null) { |
|
|
|
return rb.fail().setMsg("userSid 不能为空!").setData(new FlowTask()); |
|
|
|
}else{ |
|
|
|
userSid=(String) userSid_obj; |
|
|
|
if(StringUtils.isBlank(userSid)){ |
|
|
|
} else { |
|
|
|
userSid = (String) userSid_obj; |
|
|
|
if (StringUtils.isBlank(userSid)) { |
|
|
|
return rb.fail().setMsg("userSid 不能为空!").setData(new FlowTask()); |
|
|
|
} |
|
|
|
} |
|
|
|
Object businessSid_obj = formVariables.get("businessSid"); |
|
|
|
String businessSid=null; |
|
|
|
if(businessSid_obj==null){ |
|
|
|
String businessSid = null; |
|
|
|
if (businessSid_obj == null) { |
|
|
|
return rb.fail().setMsg("业务sid 不能为空!").setData(new FlowTask()); |
|
|
|
}else{ |
|
|
|
businessSid=(String) businessSid_obj; |
|
|
|
if(StringUtils.isBlank(businessSid)){ |
|
|
|
} else { |
|
|
|
businessSid = (String) businessSid_obj; |
|
|
|
if (StringUtils.isBlank(businessSid)) { |
|
|
|
return rb.fail().setMsg("业务sid 不能为空!").setData(new FlowTask()); |
|
|
|
} |
|
|
|
} |
|
|
|
Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); |
|
|
|
if (Objects.isNull(task)){ |
|
|
|
if (Objects.isNull(task)) { |
|
|
|
return rb.fail().setMsg("任务不存在").setData(new FlowTask()); |
|
|
|
} |
|
|
|
if (DelegationState.PENDING.equals(task.getDelegationState())) { |
|
|
@ -796,7 +807,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
taskService.setAssignee(taskId, userSid); |
|
|
|
taskService.complete(taskId, formVariables); |
|
|
|
} |
|
|
|
FlowTask flowTask=new FlowTask(); |
|
|
|
FlowTask flowTask = new FlowTask(); |
|
|
|
flowTask.setTaskId(task.getId()); |
|
|
|
flowTask.setTaskName(task.getName()); |
|
|
|
flowTask.setProcInsId(task.getProcessInstanceId()); |
|
|
@ -804,6 +815,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
rb.success().setData(flowTask); |
|
|
|
return rb; |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean findReturnTaskList(FlowTaskVo flowTaskVo) { |
|
|
|
// 当前任务 task
|
|
|
|
Task task = taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult(); |
|
|
@ -838,6 +850,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
} |
|
|
|
return ResultBean.fireSuccess().setData(userTaskList); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 退回任务 |
|
|
|
* |
|
|
@ -1053,21 +1066,28 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
return new ResultBean<List<LatestTaskVo>>().success().setData(latestTaskList); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean businessMyprocessNew(String userSid, PagerQuery<BusinessTaskQuery> businessTaskQuery) { |
|
|
|
int size = Integer.valueOf(businessTaskQuery.getSize() + ""); |
|
|
|
int current = Integer.valueOf(businessTaskQuery.getCurrent() + ""); |
|
|
|
List<BusinessTaskParam> fields = businessTaskQuery.getParams().getFields(); |
|
|
|
return businessMyprocess(userSid, fields, current, size); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean businessMyprocess(String userSid, List<BusinessTaskParam> params, int current, int size) { |
|
|
|
Page<FlowTaskDto> page = new Page<>(); |
|
|
|
HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery(); |
|
|
|
for(BusinessTaskParam btq:params){ |
|
|
|
if(btq.getSqlOperationSymbol().equals(SQLOperationSymbol.EQUAL)){ |
|
|
|
historicProcessInstanceQuery.variableValueEquals(btq.getField(),btq.getValue()); |
|
|
|
for (BusinessTaskParam btq : params) { |
|
|
|
if (btq.getSqlOperationSymbol().equals(SQLOperationSymbol.EQUAL)) { |
|
|
|
historicProcessInstanceQuery.variableValueEquals(btq.getField(), btq.getValue()); |
|
|
|
} |
|
|
|
if(btq.getSqlOperationSymbol().equals(SQLOperationSymbol.LIKE)){ |
|
|
|
historicProcessInstanceQuery.variableValueLike(btq.getField(),"%"+btq.getValue()+"%"); |
|
|
|
if (btq.getSqlOperationSymbol().equals(SQLOperationSymbol.LIKE)) { |
|
|
|
historicProcessInstanceQuery.variableValueLike(btq.getField(), "%" + btq.getValue() + "%"); |
|
|
|
} |
|
|
|
} |
|
|
|
historicProcessInstanceQuery.startedBy(userSid).notDeleted() |
|
|
|
.orderByProcessInstanceStartTime() |
|
|
|
.desc(); |
|
|
|
List<HistoricProcessInstance> historicProcessInstances =historicProcessInstanceQuery .listPage((current - 1) * size, size); |
|
|
|
List<HistoricProcessInstance> historicProcessInstances = historicProcessInstanceQuery.listPage((current - 1) * size, size); |
|
|
|
long count = historicProcessInstanceQuery.count(); |
|
|
|
page.setTotal(count); |
|
|
|
List<FlowTaskDto> flowList = new ArrayList<>(); |
|
|
@ -1108,9 +1128,10 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
page.setRecords(flowList); |
|
|
|
return ResultBean.fireSuccess().setData(page); |
|
|
|
} |
|
|
|
private String getTaskId(String currentActivityId,String processInstanceId,String processDefinitionId){ |
|
|
|
|
|
|
|
private String getTaskId(String currentActivityId, String processInstanceId, String processDefinitionId) { |
|
|
|
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId); |
|
|
|
FlowNode flowNode = (FlowNode)bpmnModel.getFlowElement(currentActivityId); |
|
|
|
FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(currentActivityId); |
|
|
|
SequenceFlow sequenceFlow = flowNode.getIncomingFlows().get(0); |
|
|
|
// 获取上一个节点的activityId
|
|
|
|
String sourceRef = sequenceFlow.getSourceRef(); |
|
|
@ -1118,8 +1139,8 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
.processInstanceId(processInstanceId).orderByHistoricActivityInstanceStartTime().desc().list().get(0);//singleResult();
|
|
|
|
String activityType = historicActivityInstance.getActivityType(); |
|
|
|
String historicActivityInstanceActivityId = historicActivityInstance.getActivityId(); |
|
|
|
if(!"userTask".equals(activityType)){ |
|
|
|
return getTaskId(historicActivityInstanceActivityId,processInstanceId,processDefinitionId); |
|
|
|
if (!"userTask".equals(activityType)) { |
|
|
|
return getTaskId(historicActivityInstanceActivityId, processInstanceId, processDefinitionId); |
|
|
|
} |
|
|
|
return historicActivityInstance.getTaskId(); |
|
|
|
} |
|
|
@ -1128,17 +1149,17 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
public ResultBean<List<LatestTaskVo>> revokeProcess(FlowTaskVo flowTaskVo) { |
|
|
|
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(flowTaskVo.getTaskId()).singleResult(); |
|
|
|
Execution execution = runtimeService.createExecutionQuery().executionId(historicTaskInstance.getExecutionId()).singleResult(); |
|
|
|
DelegateExecution delegateExecution=(DelegateExecution)execution; |
|
|
|
DelegateExecution delegateExecution = (DelegateExecution) execution; |
|
|
|
// 获取当前节点的activityId,即xml中每个标签的ID
|
|
|
|
String currentActivityId = delegateExecution.getCurrentActivityId(); |
|
|
|
// List<Task> list1 = taskService.createTaskQuery().processInstanceId(historicTaskInstance.getProcessInstanceId()).list();
|
|
|
|
// taskService.addComment(currentTask.getId(), execution.getProcessInstanceId(), body.get("msg").toString());
|
|
|
|
// FlowNode flowNode2 = (FlowNode)bpmnModel.getFlowElement(sourceRef);
|
|
|
|
String taskId = getTaskId(currentActivityId, historicTaskInstance.getProcessInstanceId(),historicTaskInstance.getProcessDefinitionId()); |
|
|
|
String taskId = getTaskId(currentActivityId, historicTaskInstance.getProcessInstanceId(), historicTaskInstance.getProcessDefinitionId()); |
|
|
|
HistoricTaskInstance historicTaskInstance1 = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult(); |
|
|
|
String assignee = historicTaskInstance1.getAssignee(); |
|
|
|
String userSid = flowTaskVo.getUserSid(); |
|
|
|
if(!assignee.equals(userSid)){ |
|
|
|
if (!assignee.equals(userSid)) { |
|
|
|
return new ResultBean<List<LatestTaskVo>>().fail().setMsg("您不是上一环节处理人,不能进行撤回操作!").setData(new ArrayList<>()); |
|
|
|
} |
|
|
|
// 流程回退到上一个节点,审批人继续审批
|
|
|
@ -1158,12 +1179,12 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
FlowableUtils.getAllElements(process.getFlowElements(), null); |
|
|
|
// 获取当前任务节点元素
|
|
|
|
FlowElement source = null; |
|
|
|
if(allElements!=null){ |
|
|
|
for(FlowElement flowElement:allElements){ |
|
|
|
if (allElements != null) { |
|
|
|
for (FlowElement flowElement : allElements) { |
|
|
|
//类型为用户节点
|
|
|
|
if(flowElement.getId().equals(task.getTaskDefinitionKey())){ |
|
|
|
if (flowElement.getId().equals(task.getTaskDefinitionKey())) { |
|
|
|
//获取节点信息
|
|
|
|
source=flowElement; |
|
|
|
source = flowElement; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1171,13 +1192,13 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
// 获取当前节点的所有父级用户任务节点
|
|
|
|
// 深度优先算法思想:延边迭代深入
|
|
|
|
List<UserTask> parentUserTaskList = FlowableUtils.iteratorFindParentUserTasks(source, null, null); |
|
|
|
if(parentUserTaskList==null || parentUserTaskList.size()==0){ |
|
|
|
if (parentUserTaskList == null || parentUserTaskList.size() == 0) { |
|
|
|
// throw new CustomException("当前节点为");
|
|
|
|
return new ResultBean<List<LatestTaskVo>>().fail().setMsg("当前节点为").setData(new ArrayList<>()); |
|
|
|
} |
|
|
|
// 如果流程已经结束,则得到结束节点
|
|
|
|
if(historyService.createHistoricProcessInstanceQuery().finished() |
|
|
|
.processInstanceId(task.getProcessInstanceId()).count() > 0){ |
|
|
|
if (historyService.createHistoricProcessInstanceQuery().finished() |
|
|
|
.processInstanceId(task.getProcessInstanceId()).count() > 0) { |
|
|
|
return new ResultBean<List<LatestTaskVo>>().fail().setMsg("当前已经结束不能撤回").setData(new ArrayList<>()); |
|
|
|
} |
|
|
|
// 获取活动 ID 即节点 Key
|
|
|
@ -1284,6 +1305,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
|
|
|
|
/** |
|
|
|
* 终止流程 |
|
|
|
* |
|
|
|
* @param flowTaskVo |
|
|
|
* @return |
|
|
|
*/ |
|
|
@ -1308,7 +1330,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
comment = "终止"; |
|
|
|
} |
|
|
|
taskService.setAssignee(flowTaskVo.getTaskId(), flowTaskVo.getUserSid()); |
|
|
|
taskService.addComment(flowTaskVo.getTaskId(), processInstanceId,FlowComment.STOP.getType(), comment); |
|
|
|
taskService.addComment(flowTaskVo.getTaskId(), processInstanceId, FlowComment.STOP.getType(), comment); |
|
|
|
runtimeService.createChangeActivityStateBuilder().moveExecutionsToSingleActivityId(executionIds, endId).changeState(); |
|
|
|
return new ResultBean().success().setMsg("终止成功").setData(SysFormLinkFlowStateEnum.BREAK.getState()); |
|
|
|
} else { |
|
|
@ -1325,7 +1347,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
return list.stream().filter(f -> f instanceof EndEvent).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
public void stopProcess(String userSid,FlowTaskVo flowTaskVo) { |
|
|
|
public void stopProcess(String userSid, FlowTaskVo flowTaskVo) { |
|
|
|
List<Task> task = taskService.createTaskQuery().processInstanceId(flowTaskVo.getInstanceId()).list(); |
|
|
|
if (CollectionUtils.isEmpty(task)) { |
|
|
|
throw new CustomException("流程未启动或已执行完成,取消申请失败"); |
|
|
@ -1353,6 +1375,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* instId 流程实例ID |
|
|
|
* delReason 删除原因 |
|
|
@ -1363,35 +1386,38 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
|
|
|
|
public ResultBean getNextTasks(String taskId) { |
|
|
|
Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); |
|
|
|
String node="next"; |
|
|
|
String processDefinitionId=task.getProcessDefinitionId(); |
|
|
|
return getNextUserTasks(processDefinitionId,task.getExecutionId(),node); |
|
|
|
String node = "next"; |
|
|
|
String processDefinitionId = task.getProcessDefinitionId(); |
|
|
|
return getNextUserTasks(processDefinitionId, task.getExecutionId(), node); |
|
|
|
} |
|
|
|
private ResultBean getNextUserTasks(String processDefinitionId,String executionId,String node){ |
|
|
|
|
|
|
|
private ResultBean getNextUserTasks(String processDefinitionId, String executionId, String node) { |
|
|
|
ExecutionEntity ee = (ExecutionEntity) runtimeService.createExecutionQuery() |
|
|
|
.executionId(executionId).singleResult(); |
|
|
|
// 当前审批节点
|
|
|
|
String crruentActivityId = ee.getActivityId(); |
|
|
|
BpmnModel bpmnModel =repositoryService.getBpmnModel(processDefinitionId); |
|
|
|
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId); |
|
|
|
FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(crruentActivityId); |
|
|
|
// 输出连线
|
|
|
|
List<SequenceFlow> outFlows = flowNode.getOutgoingFlows(); |
|
|
|
Map<String,String> nodeMap=new HashMap<>(); |
|
|
|
List< Map<String,String>> lists=new ArrayList<>(); |
|
|
|
getNodes(outFlows, node,lists); |
|
|
|
Map<String, String> nodeMap = new HashMap<>(); |
|
|
|
List<Map<String, String>> lists = new ArrayList<>(); |
|
|
|
getNodes(outFlows, node, lists); |
|
|
|
System.out.println(JSON.toJSONString(lists)); |
|
|
|
return ResultBean.fireSuccess().setData(lists); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据流程实例的id查询最新的待办环节 |
|
|
|
* |
|
|
|
* @param procId |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public List<LatestTaskVo> getLatestTasks(String procId){ |
|
|
|
public List<LatestTaskVo> getLatestTasks(String procId) { |
|
|
|
return baseMapper.getLatestTasks(procId); |
|
|
|
} |
|
|
|
public void getNodes( List<SequenceFlow> outFlows,String node, List<Map<String,String>> lists){ |
|
|
|
|
|
|
|
public void getNodes(List<SequenceFlow> outFlows, String node, List<Map<String, String>> lists) { |
|
|
|
for (SequenceFlow sequenceFlow : outFlows) { |
|
|
|
//当前审批节点
|
|
|
|
if ("now".equals(node)) { |
|
|
@ -1402,26 +1428,56 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
FlowElement targetFlow = sequenceFlow.getTargetFlowElement(); |
|
|
|
if (targetFlow instanceof UserTask) { |
|
|
|
System.out.println("下一节点: id=" + targetFlow.getId() + ",name=" + targetFlow.getName()); |
|
|
|
Map<String,String> map=new HashMap<>(); |
|
|
|
map.put("id",targetFlow.getId()); |
|
|
|
map.put("name",targetFlow.getName()); |
|
|
|
Map<String, String> map = new HashMap<>(); |
|
|
|
map.put("id", targetFlow.getId()); |
|
|
|
map.put("name", targetFlow.getName()); |
|
|
|
map.put("assignee", ((UserTask) targetFlow).getAssignee()); |
|
|
|
lists.add(map); |
|
|
|
} |
|
|
|
if (targetFlow instanceof EndEvent) {// 如果下个审批节点为结束节点
|
|
|
|
System.out.println("下一节点为结束节点:id=" + targetFlow.getId() + ",name=" + targetFlow.getName()); |
|
|
|
Map<String,String> map=new HashMap<>(); |
|
|
|
map.put("id",targetFlow.getId()); |
|
|
|
map.put("name",targetFlow.getName()); |
|
|
|
Map<String, String> map = new HashMap<>(); |
|
|
|
map.put("id", targetFlow.getId()); |
|
|
|
map.put("name", targetFlow.getName()); |
|
|
|
map.put("assignee", ((UserTask) targetFlow).getAssignee()); |
|
|
|
lists.add(map); |
|
|
|
} |
|
|
|
if (targetFlow instanceof Gateway) {// 如果下个审批节点为结束节点
|
|
|
|
List<SequenceFlow> outgoingFlows = ((Gateway) targetFlow).getOutgoingFlows(); |
|
|
|
getNodes(outgoingFlows,node,lists); |
|
|
|
getNodes(outgoingFlows, node, lists); |
|
|
|
System.out.println("下一节点为结束节点:id=" + targetFlow.getId() + ",name=" + targetFlow.getName()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<List<LatestTaskVo>> getLatestTasksNew(String procId) { |
|
|
|
List<LatestTaskVo> latestTasks = getLatestTasks(procId); |
|
|
|
return new ResultBean<List<LatestTaskVo>>().success().setData(latestTasks); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean businessTodoListNew(String userSid, PagerQuery<BusinessTaskQuery> businessTaskQuery) { |
|
|
|
int size = Integer.valueOf(businessTaskQuery.getSize() + ""); |
|
|
|
int current = Integer.valueOf(businessTaskQuery.getCurrent() + ""); |
|
|
|
List<BusinessTaskParam> fields = businessTaskQuery.getParams().getFields(); |
|
|
|
ResultBean<Page<FlowTaskDto>> resultBean = businessTodoList(userSid, fields, current, size); |
|
|
|
return resultBean; |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean businessDoneListNew(String userSid, PagerQuery<BusinessTaskQuery> taskQueryPagerQuery) { |
|
|
|
int size = Integer.valueOf(taskQueryPagerQuery.getSize() + ""); |
|
|
|
int current = Integer.valueOf(taskQueryPagerQuery.getCurrent() + ""); |
|
|
|
List<BusinessTaskParam> fields = taskQueryPagerQuery.getParams().getFields(); |
|
|
|
return businessFinishedList(userSid, fields, current, size); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean stopProcessNew(String userSid, FlowTaskVo flowTaskVo) { |
|
|
|
stopProcess(userSid, flowTaskVo); |
|
|
|
return ResultBean.fireSuccess(); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean deleteProcessNew(String procInsId) { |
|
|
|
deleteProcess(procInsId, "删除"); |
|
|
|
return ResultBean.fireSuccess(); |
|
|
|
} |
|
|
|
} |