|
@@ -1809,7 +1809,7 @@ public class TaskController extends BladeController {
|
|
|
if (CollectionUtil.isNotEmpty(processInstanceIds)) {
|
|
|
String idsStr = processInstanceIds.stream().map(id -> "'" + id + "'").collect(Collectors.joining(","));
|
|
|
taskParallelGroupMap = jdbcTemplate.query(
|
|
|
- "select process_instance_id,task_user,task_user_name,e_visa_status,e_visa_content,parallel_process_instance_id,status from u_task_parallel where process_instance_id in(" + idsStr + ") order by id",
|
|
|
+ "select process_instance_id,task_user,task_user_name,e_visa_status,e_visa_content,parallel_process_instance_id,status,sort from u_task_parallel where process_instance_id in(" + idsStr + ") order by id",
|
|
|
new BeanPropertyRowMapper<>(TaskParallel.class)
|
|
|
).stream().collect(Collectors.groupingBy(TaskParallel::getProcessInstanceId));
|
|
|
}
|
|
@@ -1832,11 +1832,37 @@ public class TaskController extends BladeController {
|
|
|
}
|
|
|
|
|
|
// 6. 对原始数据执行业务过滤(核心:垂直签待办任务可见性判断)
|
|
|
+ //根据条件过滤出可审批的数据(流程审批-非自定义流程) flowid为0的是自定义审批的流程
|
|
|
+ Map<Long, List<Task>> flowIdMaps = allResultList.stream().filter(task->!"0".equals(task.getFixedFlowId().toString())).collect(Collectors.groupingBy(Task::getFixedFlowId));
|
|
|
+ Map<Long, List<FixedFlowLink>> fixedsMap;
|
|
|
+ if(ObjectUtil.isNotEmpty(flowIdMaps)){
|
|
|
+ String join = StringUtils.join(flowIdMaps.keySet(), ",");
|
|
|
+ //结果集所有数据
|
|
|
+ String sql = "select fixed_flow_id ,fixed_flow_branch_sort,fixed_flow_link_type,fixed_flow_link_sort from u_fixed_flow_link where is_deleted = 0 and fixed_flow_id in ( "+join+")";
|
|
|
+ List<FixedFlowLink> fixedFlowLinks = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(FixedFlowLink.class));
|
|
|
+ fixedsMap = fixedFlowLinks.stream().collect(Collectors.groupingBy(FixedFlowLink::getFixedFlowId));
|
|
|
+ } else {
|
|
|
+ fixedsMap = new HashMap<>();
|
|
|
+ }
|
|
|
Map<String, List<TaskParallel>> finalTaskParallelGroupMap = taskParallelGroupMap;
|
|
|
List<Task> filteredList = allResultList.stream()
|
|
|
.filter(task -> {
|
|
|
+ // 获取任务流程信息,判断是否是垂直签
|
|
|
+ if (task.getFixedFlowId() != null && fixedsMap.containsKey(task.getFixedFlowId())) {
|
|
|
+ // 预设流程
|
|
|
+ List<FixedFlowLink> fixedFlowLinks = fixedsMap.get(task.getFixedFlowId());
|
|
|
+ List<FixedFlowLink> linkList = fixedFlowLinks.stream().filter(link -> link.getFixedFlowLinkType() == null).collect(Collectors.toList());
|
|
|
+ if (linkList.isEmpty()) {
|
|
|
+ // 获取垂直流程
|
|
|
+ List<FixedFlowLink> collect = fixedFlowLinks.stream().filter(link -> link.getFixedFlowLinkType() != null && link.getFixedFlowLinkType() == 1).collect(Collectors.toList());
|
|
|
+ if (!collect.isEmpty()) {
|
|
|
+ // 走垂直审批逻辑
|
|
|
+ return handleTaskParallel(fixedFlowLinks, finalTaskParallelGroupMap.get(task.getProcessInstanceId()), SecureUtil.getUserId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
// 仅处理垂直签+待办页面的过滤逻辑
|
|
|
- if (projectInfo != null && projectInfo.getApprovalType() == 1 && dto.getSelectedType() == 1) {
|
|
|
+ if (((projectInfo != null && projectInfo.getApprovalType() == 1)) && dto.getSelectedType() == 1) {
|
|
|
List<TaskParallel> parallelList = finalTaskParallelGroupMap.get(task.getProcessInstanceId());
|
|
|
if (CollectionUtil.isEmpty(parallelList)) {
|
|
|
return false;
|
|
@@ -1982,11 +2008,18 @@ public class TaskController extends BladeController {
|
|
|
return R.data(page);
|
|
|
}
|
|
|
|
|
|
- private void handleTaskParallel1(Task task, Map<Long, List<FixedFlowLink>> fixedsMap, Map<String, List<TaskParallel>> taskParallelMap, Long userId, List<Task> resultList) {
|
|
|
- Long fixedFlowId = task.getFixedFlowId();
|
|
|
- String processInstanceId = task.getProcessInstanceId();
|
|
|
+ private boolean handleTaskParallel(List<FixedFlowLink> fixedFlowLinks, List<TaskParallel> taskParallels, Long userId) {
|
|
|
+ taskParallels.sort(Comparator.comparing(TaskParallel::getSort, Comparator.nullsLast(Comparator.naturalOrder())));
|
|
|
+ for (int i = 0; i < taskParallels.size(); i++) {
|
|
|
+ TaskParallel parallel = taskParallels.get(i);
|
|
|
+ parallel.setSort(i);
|
|
|
+ }
|
|
|
+ fixedFlowLinks.sort(Comparator.comparing(FixedFlowLink::getFixedFlowBranchSort, Comparator.nullsLast(Comparator.naturalOrder())));
|
|
|
+ for (int i = 0; i < fixedFlowLinks.size(); i++) {
|
|
|
+ FixedFlowLink link = fixedFlowLinks.get(i);
|
|
|
+ link.setFixedFlowBranchSort(i);
|
|
|
+ }
|
|
|
//查出当前电签到的节点sort
|
|
|
- List<TaskParallel> taskParallels = taskParallelMap.get(processInstanceId);
|
|
|
Optional<Integer> sortDq = taskParallels.stream()
|
|
|
.filter(t -> t.getStatus() == 1)
|
|
|
.min(Comparator.comparing(TaskParallel::getSort))
|
|
@@ -2001,54 +2034,42 @@ public class TaskController extends BladeController {
|
|
|
List<Integer> list1 = userSort.stream().filter(a -> dqSort.compareTo(a) <= 0).collect(Collectors.toList());
|
|
|
if(ObjectUtil.isEmpty(list1)){
|
|
|
//当前用户已经签字过
|
|
|
- resultList.remove(task);
|
|
|
+ return false;
|
|
|
}else {
|
|
|
//筛选出最近的一条没有电签的当前用户的sort
|
|
|
Integer userMinSort = Collections.min(list1);
|
|
|
if(userMinSort.toString().equals(dqSort.toString())){
|
|
|
//当前用户就是下一个电签用户 可审批 放行
|
|
|
- return;
|
|
|
+ return true;
|
|
|
}
|
|
|
- List<FixedFlowLink> fixedFlowLinks = fixedsMap.get(fixedFlowId);
|
|
|
- Optional<FixedFlowLink> dqFlowLink = fixedFlowLinks.stream().filter(f -> f.getFixedFlowBranchSort().equals(dqSort)).findFirst();
|
|
|
- Optional<FixedFlowLink> userFlowLink = fixedFlowLinks.stream().filter(f -> f.getFixedFlowBranchSort().equals(userMinSort)).findFirst();
|
|
|
- if(dqFlowLink.get().getFixedFlowLinkSort() == userFlowLink.get().getFixedFlowLinkSort()){
|
|
|
- //在同一个小流程里面去判断是否垂直还是水平
|
|
|
- if(dqFlowLink.get().getFixedFlowLinkType() == 2){//平行
|
|
|
- //通过
|
|
|
- return;
|
|
|
- }else {
|
|
|
- resultList.remove(task);
|
|
|
+ FixedFlowLink dqFlowLink = null;
|
|
|
+ FixedFlowLink userFlowLink = null;
|
|
|
+ for (FixedFlowLink fixedFlowLink : fixedFlowLinks) {
|
|
|
+ if (fixedFlowLink.getFixedFlowBranchSort() != null && fixedFlowLink.getFixedFlowBranchSort() >= dqSort && dqFlowLink == null) {
|
|
|
+ dqFlowLink = fixedFlowLink;
|
|
|
}
|
|
|
+ if (fixedFlowLink.getFixedFlowBranchSort() != null && fixedFlowLink.getFixedFlowBranchSort() >= userMinSort && userFlowLink == null) {
|
|
|
+ userFlowLink = fixedFlowLink;
|
|
|
+ }
|
|
|
+ if (dqFlowLink != null && userFlowLink != null) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (dqFlowLink == null || userFlowLink == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(Objects.equals(dqFlowLink.getFixedFlowLinkSort(), userFlowLink.getFixedFlowLinkSort())){
|
|
|
+ //在同一个小流程里面去判断是否垂直还是水平
|
|
|
+ //平行 通过
|
|
|
+ return dqFlowLink.getFixedFlowLinkType() == 2;
|
|
|
}else {
|
|
|
//不在一个小流程 不可审批
|
|
|
- resultList.remove(task);
|
|
|
+ return false;
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
//全部签完了 肯定不是可审批
|
|
|
- resultList.remove(task);
|
|
|
- }
|
|
|
- }
|
|
|
- //判断当前任务当前用户是否可审批 如果不可审批则从resultList中删除
|
|
|
- private void handleTaskParallel(Task task,Map<String, List<TaskParallel>> map, Long userId, List<Task> resultList) {
|
|
|
- String processInstanceId = task.getProcessInstanceId();
|
|
|
- List<TaskParallel> taskParallels = map.get(processInstanceId);
|
|
|
- //按照sort升序排序
|
|
|
- taskParallels.sort(Comparator.comparingInt(TaskParallel::getSort));
|
|
|
- boolean isApprove = true;
|
|
|
- for (TaskParallel taskParallel : taskParallels) {
|
|
|
- if(taskParallel.getTaskUser().equals(userId.toString())){
|
|
|
- break;
|
|
|
- }else {
|
|
|
- if(taskParallel.getStatus() != 2){//不为2说明 还未审批 流程未到当前用户 不可审批
|
|
|
- isApprove = false;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if(!isApprove){//不可审批的数据
|
|
|
- resultList.remove(task);
|
|
|
+ return false;
|
|
|
}
|
|
|
}
|
|
|
|