فهرست منبع

质检任务流程优化

lvy 1 هفته پیش
والد
کامیت
95f2a7f873

+ 191 - 6
blade-service/blade-business/src/main/java/org/springblade/business/controller/FixedFlowController.java

@@ -16,17 +16,23 @@ import org.springblade.business.service.IFixedFlowService;
 import org.springblade.business.vo.FixedFlowVO;
 import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.boot.ctrl.BladeController;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.ObjectUtil;
 import org.springblade.manager.dto.SaveUserInfoByProjectDTO;
+import org.springblade.manager.entity.ProjectInfo;
 import org.springblade.manager.entity.SignPfxFile;
 import org.springblade.manager.feign.ContractClient;
 import org.springblade.manager.feign.ProjectAssignmentUserClient;
+import org.springblade.manager.feign.ProjectClient;
+import org.springblade.manager.feign.SignPfxClient;
 import org.springblade.manager.vo.RoleSignPfxUserVO;
 import org.springblade.manager.vo.RoleSignPfxUserVO1;
 import org.springblade.manager.vo.RoleSignPfxUserVO2;
 import org.springblade.manager.vo.RoleSignPfxUserVO3;
+import org.springblade.meter.dto.SaveFixedFlowDTO;
 import org.springblade.system.feign.ISysClient;
 import org.springblade.system.user.entity.User;
 import org.springblade.system.user.feign.IUserClient;
@@ -34,12 +40,12 @@ import org.springblade.system.vo.RoleVO;
 import org.springframework.beans.BeanUtils;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 控制器
@@ -67,14 +73,14 @@ public class FixedFlowController extends BladeController {
 
     private final JdbcTemplate jdbcTemplate;
 
+    private final ProjectClient projectClient;
     /**
      * 获取系统所有角色划分
      */
     @GetMapping("/queryAllRoleList")
     @ApiOperationSupport(order = 9)
     @ApiOperation(value = "获取系统所有角色划分")
-    public R<List<RoleSignPfxUserVO>> queryAllRoleList(@RequestParam String contractId) {
-        RoleSignPfxUserVO1 vo1 = new RoleSignPfxUserVO1();
+    public R<List<RoleSignPfxUserVO>> queryAllRoleList(@RequestParam String contractId, @RequestParam(required = false, defaultValue = "0") Integer  type) {
         //获取当前系统配置的角色划分
         List<RoleVO> roleVOS = this.sysClient.search().getData();
         //获取项目人员
@@ -95,6 +101,15 @@ public class FixedFlowController extends BladeController {
         //返回结果
         List<RoleSignPfxUserVO> result = new ArrayList<>();
         for (RoleVO vo : roleVOS) {
+            if (type != null && type == 1) {
+                // 除“超级管理员”外,其余只展示“业主方”、“监理方”、“施工方”。“超级管理员”只有用户角色为“超级管理员”时才展示。其余角色均不展示;
+                if (vo.getRoleName() == null || (!vo.getRoleName().contains("管理员") && !vo.getRoleName().contains("业主方") && !vo.getRoleName().contains("施工方") && !vo.getRoleName().contains("监理方"))) {
+                    continue;
+                }
+                if (!"administrator".equals(AuthUtil.getUserRole()) && vo.getRoleName() != null && "administrator".equals(vo.getRoleAlias())) {
+                    continue;
+                }
+            }
             //设置实体
             RoleSignPfxUserVO pfxUserVo = new RoleSignPfxUserVO();
             pfxUserVo.setRoleId(vo.getId());
@@ -129,6 +144,9 @@ public class FixedFlowController extends BladeController {
                         }
                     }
                     //设置子集
+                    if (childPfxUserVo.getSignPfxFileList() ==  null || childPfxUserVo.getSignPfxFileList().isEmpty()) {
+                        continue;
+                    }
                     pfxUserVo.getChildRoleList().add(childPfxUserVo);
                     pfxUserVo.getSignPfxFileList().addAll(childPfxUserVo.getSignPfxFileList());
                 }
@@ -174,7 +192,28 @@ public class FixedFlowController extends BladeController {
         if (vo.getCurrent() == null || vo.getSize() == null) {
             return R.data(-1, null, "缺少size或current参数");
         }
-        return R.data(this.fixedFlowService.selectFixedFlowPage(vo));
+        IPage<FixedFlowVO> page = this.fixedFlowService.selectFixedFlowPage(vo);
+        List<FixedFlowVO> records = page.getRecords();
+        if (records != null && !records.isEmpty()) {
+            Map<Boolean, List<FixedFlowVO>> groupMap = records.stream().collect(Collectors.groupingBy(record -> record.getFixedFlowName() != null && record.getFixedFlowName().contains("_")));
+            List<FixedFlowVO> copyFixedFlowVOS = groupMap.get(true);
+            List<FixedFlowVO> fixedFlowVOS = groupMap.get(false);
+            if (copyFixedFlowVOS ==  null || copyFixedFlowVOS.isEmpty() || fixedFlowVOS ==  null || fixedFlowVOS.isEmpty()) {
+                return R.data(page);
+            }
+            Map<String, List<FixedFlowVO>> nameMap = copyFixedFlowVOS.stream().collect(Collectors.groupingBy(record -> record.getFixedFlowName().split("_")[0]));
+            List<FixedFlowVO> newData = new ArrayList<>();
+            for (FixedFlowVO flowVO : fixedFlowVOS) {
+                newData.add(flowVO);
+                List<FixedFlowVO> flowVOS = nameMap.get(flowVO.getFixedFlowName());
+                if (flowVOS != null && !flowVOS.isEmpty()) {
+                    flowVOS.sort(Comparator.comparing(FixedFlow::getFixedFlowName));
+                    newData.addAll(flowVOS);
+                }
+            }
+            page.setRecords(newData);
+        }
+        return R.data(page);
     }
 
     /**
@@ -282,5 +321,151 @@ public class FixedFlowController extends BladeController {
         return R.status(false);
     }
 
+    /**
+     * 复制
+     */
+    @PostMapping("/copy")
+    @ApiOperationSupport(order = 6)
+    @ApiOperation(value = "复制", notes = "传入fixedFlow id")
+    @Transactional(rollbackFor = Exception.class)
+    public R<Boolean> copy(String ids) {
+        if (StringUtils.isBlank(ids)) {
+            return R.fail("请选择要复制的流程");
+        }
+        List<Long> idList = Func.toLongList(ids);
+        List<FixedFlow> fixedFlowList = this.fixedFlowService.listByIds(idList);
+        if (fixedFlowList.isEmpty()) {
+            return R.fail("选择的流程不存在");
+        }
+        List<FixedFlowLink> fixedFlowLinkList = this.fixedFlowLinkService.list(Wrappers.<FixedFlowLink>lambdaQuery().in(FixedFlowLink::getFixedFlowId, idList));
+        Map<Long, List<FixedFlowLink>> linkMap = fixedFlowLinkList.stream().collect(Collectors.groupingBy(FixedFlowLink::getFixedFlowId));
+        List<FixedFlowLink> newFixedFolwLinkList = new ArrayList<>();
+        Map<String, Long> nameCountMap = new HashMap<>();
+        fixedFlowList.forEach(fixedFlow -> {
+            //生成主表主键
+            long fixedFlowId = SnowFlakeUtil.getId();
+            List<FixedFlowLink> sourceFixedFolwLinkList = linkMap.get(fixedFlow.getId());
+            if (sourceFixedFolwLinkList != null && !sourceFixedFolwLinkList.isEmpty()) {
+                for (FixedFlowLink fixedFlowLink : sourceFixedFolwLinkList) {
+                    FixedFlowLink newLink = new FixedFlowLink();
+                    BeanUtils.copyProperties(fixedFlowLink, newLink);
+                    newLink.setId(SnowFlakeUtil.getId());
+                    newLink.setFixedFlowId(fixedFlowId);
+                    newLink.setCreateUser(AuthUtil.getUserId());
+                    newLink.setCreateTime(new Date());
+                    newFixedFolwLinkList.add(newLink);
+                }
+            }
+            Long number = nameCountMap.get(fixedFlow.getFixedFlowName());
+            if (number == null) {
+                number = this.fixedFlowService.count(Wrappers.<FixedFlow>lambdaQuery().likeRight(FixedFlow::getFixedFlowName, fixedFlow.getFixedFlowName()).eq(FixedFlow::getContractId, fixedFlow.getContractId()).ne(FixedFlow::getId, fixedFlow.getId()));
+            }
+            nameCountMap.put(fixedFlow.getFixedFlowName(), number + 1);
+            fixedFlow.setId(fixedFlowId);
+            fixedFlow.setFixedFlowName(fixedFlow.getFixedFlowName() + "_" + (number + 1));
+            fixedFlow.setCreateTime(new Date());
+            fixedFlow.setUpdateTime(new Date());
+            fixedFlow.setCreateUser(AuthUtil.getUserId());
+        });
+        boolean flow = this.fixedFlowService.saveBatch(fixedFlowList);
+        if (flow && !newFixedFolwLinkList.isEmpty()) {
+            flow = this.fixedFlowLinkService.saveBatch(newFixedFolwLinkList);
+        }
+        return R.data(flow);
+    }
+
+    @PostMapping("/saveFixedFlow")
+    @ApiOperationSupport(order = 7)
+    @ApiOperation(value = "新增任务流程", notes = "传入dto")
+    public R<Object> saveFixedFlow(@RequestBody SaveFixedFlowDTO dto) {
+        if (ObjectUtil.isEmpty(dto.getFixedBranchList())) {
+            return R.fail("请选择任务流程人员");
+        }
+        if (ObjectUtil.isNotEmpty(dto.getFixedName()) && ObjectUtil.isNotEmpty(dto.getProjectId()) && ObjectUtil.isNotEmpty(dto.getContractId())) {
+            ProjectInfo projectInfo = projectClient.getById(dto.getProjectId() + "");
+            if (projectInfo == null) {
+                return R.fail("暂未找到项目信息,请稍后再试");
+            }
+            List<String> userIds = dto.getFixedBranchList().stream().map(SaveFixedFlowDTO.FixedBranch::getUserIds).collect(Collectors.toList());
+            List<User> users = jdbcTemplate.query("select id,name,acc_code,real_name from blade_user where is_deleted = 0 and id in (" + StringUtils.join(userIds, ",") + ")", new BeanPropertyRowMapper<>(User.class));
+            Map<Long, User> userMap = users.stream().collect(Collectors.toMap(User::getId, item -> item));
+            if (ObjectUtil.isEmpty( users)) {
+                return R.fail("请选择任务流程人员");
+            }
+            if (Objects.equals(projectInfo.getRemarkType(), 1)) {
+                //安心签,校验证书 检查签字证书信息
+                Set<String> notCertificateUserInfoSet = new HashSet<>();
+                //获取用户的证书信息
+                String ids = users.stream().map(user -> user.getId() + "").collect(Collectors.joining(","));
+                List<SignPfxFile> signPfxFiles = jdbcTemplate.query("select * from m_sign_pfx_file where is_register = 1 and certificate_user_id in ( " + ids + " )", new BeanPropertyRowMapper<>(SignPfxFile.class));
+                Map<String, List<SignPfxFile>> collect = signPfxFiles.stream().collect(Collectors.groupingBy(signPfxFile -> signPfxFile.getCertificateUserId() + ""));
+                for (String userId : userIds) {
+                    List<SignPfxFile> userPfxList = collect.get(userId);
+                    if (userPfxList == null || userPfxList.isEmpty()) {
+                        notCertificateUserInfoSet.add(userId);
+                    }
+                }
+                if (!notCertificateUserInfoSet.isEmpty()) {
+                    List<String> names = new ArrayList<>();
+                    for (String userId : notCertificateUserInfoSet) {
+                        User user = userMap.get(Long.parseLong(userId));
+                        if (user != null && user.getName() != null && !user.getName().isEmpty()) {
+                            names.add(user.getName());
+                        }
+                    }
+                    throw new ServiceException("未获取到用户【" + StringUtils.join(names, "、") + "】的签字证书信息");
+                }
+            } else {
+                // 东方中讯,校验用户 accCode
+                List<String> names = new ArrayList<>();
+                for (User user : users) {
+                    if (user.getAccCode() == null || user.getAccCode().isEmpty() || user.getAccCode().equals("null")) {
+                        names.add(user.getName());
+                    }
+                }
+                if (!names.isEmpty()) {
+                    throw new ServiceException("未获取到用户【" + StringUtils.join(names, "、") + "】的签字证书信息");
+                }
+            }
+            Long fixedFlowId = SnowFlakeUtil.getId();
+            FixedFlow fixedFlow = new FixedFlow();
+            fixedFlow.setId(fixedFlowId);
+            fixedFlow.setFixedFlowName(dto.getFixedName());
+            fixedFlow.setProjectId(dto.getProjectId());
+            fixedFlow.setContractId(dto.getContractId());
+            fixedFlow.setStatus(1);
+            fixedFlow.setIsMeter(0);
+            fixedFlow.setCreateTime(new Date());
+            boolean save = fixedFlowService.save(fixedFlow);
+            if (save) {
+                int userSort = 0;
+                for (int i = 0; i < dto.getFixedBranchList().size(); i++) {
+                    SaveFixedFlowDTO.FixedBranch fixedBranch = dto.getFixedBranchList().get(i);
+                    if(i>0){
+                        userSort += Func.toLongList(dto.getFixedBranchList().get(i-1).getUserIds()).size();
+                    }
+                    for (String userId : fixedBranch.getUserIds().split(",")) {
+                        User user = userMap.get(Long.parseLong(userId));
+                        if (user == null) {
+                            continue;
+                        }
+                        FixedFlowLink fixedFlowLink = new FixedFlowLink();
+                        fixedFlowLink.setFixedFlowId(fixedFlowId);
+                        fixedFlowLink.setFixedFlowLink(dto.getFixedName());
+                        fixedFlowLink.setFixedFlowLinkType(projectInfo.getApprovalType());
+                        fixedFlowLink.setFixedFlowLinkUser(Long.parseLong(userId));
+                        fixedFlowLink.setFixedFlowLinkUserName(user.getRealName());
+                        fixedFlowLink.setFixedFlowLinkSort(i+1);
+                        fixedFlowLink.setProjectId(dto.getProjectId());
+                        fixedFlowLink.setContractId(dto.getContractId());
+                        fixedFlowLink.setFixedFlowBranchSort(userSort+=1);
+                        fixedFlowLink.setFlowTaskType(fixedBranch.getFlowTaskType());
+                    }
+                }
+                return R.success("操作成功");
+            }
+        }
+        return R.fail("操作失败");
+    }
 
 }

+ 106 - 3
blade-service/blade-business/src/main/java/org/springblade/business/controller/TaskController.java

@@ -1257,6 +1257,36 @@ public class TaskController extends BladeController {
         if (task == null || (task.getStatus() != null && task.getStatus() == 3)) {
             return R.fail("任务已被撤回或者驳回");
         }
+        //校验当前项目是否为垂直审批
+        if (ObjectUtil.isEmpty(task.getProjectId())) {
+            throw new ServiceException("未获取到任务【" + task.getTaskName() + "】对应的项目信息");
+        }
+        ProjectInfo projectInfo = jdbcTemplate.query("select approval_type from m_project_info where id = " + task.getProjectId(), new BeanPropertyRowMapper<>(ProjectInfo.class)).stream().findAny().orElse(null);
+        //如果是垂直审批,那么检查当前用户是否符合当前顺序
+        if (projectInfo != null && projectInfo.getApprovalType() != null && new Integer(1).equals(projectInfo.getApprovalType())) {
+            List<TaskParallel> taskParallelList = jdbcTemplate.query("select id,process_instance_id,task_user,task_user_name,status from u_task_parallel where process_instance_id ='" + task.getProcessInstanceId() + "'", new BeanPropertyRowMapper<>(TaskParallel.class));
+            taskParallelList.sort(Comparator.comparing(TaskParallel::getId)); //根据id排序
+            Map<String, List<TaskParallel>> taskParallelGroup = taskParallelList.stream().collect(Collectors.groupingBy(TaskParallel::getProcessInstanceId));
+            for (Map.Entry<String, List<TaskParallel>> taskObj : taskParallelGroup.entrySet()) {
+                //获取当前审批人前面的审批人信息
+                List<TaskParallel> frontTaskUser = new LinkedList<>();
+                for (TaskParallel taskParallel : taskObj.getValue()) {
+                    Long userId = SecureUtil.getUserId();
+                    if (!userId.toString().equals(taskParallel.getTaskUser())) {
+                        frontTaskUser.add(taskParallel);
+                    } else {
+                        //如果是当前的审批人,那么直接跳过
+                        break;
+                    }
+                }
+                List<TaskParallel> resultTaskStatus = frontTaskUser.stream().filter(f -> !f.getStatus().equals(2)).collect(Collectors.toList());
+                if (!resultTaskStatus.isEmpty()) {
+                    String names = resultTaskStatus.stream().map(TaskParallel::getTaskUserName).collect(Collectors.joining("、"));
+                    throw new ServiceException("当前任务【" + task.getTaskName() + "】还有【" + names + "】未完成审批,请您稍后再试");
+                }
+            }
+        }
+        //正常流程(平行签直接执行,垂直签会校验完再执行)
         this.taskService.batchCompleteApprovalTask(taskApprovalVOS);
         if (!taskApprovalVO.isPass()) {
             JSONObject json = new JSONObject();
@@ -1644,8 +1674,12 @@ public class TaskController extends BladeController {
         }
         // 3.2 任务状态过滤
         if (ObjectUtil.isNotEmpty(dto.getStatusValue())) {
-            sqlString.append(" AND status = ?");
-            params.add(dto.getStatusValue());
+            if(dto.getStatusValue() .equals(4) ){//----先查询出所有待审批的 然后根据条件进行过滤出任务已经到当前登陆人的任务为可审批
+                sqlString.append(" AND status = 1");
+            }else {
+                sqlString.append(" AND status = ?");
+                params.add(dto.getStatusValue());
+            }
         }
         // 3.3 合同段过滤(区分合同类型)
         if (contractInfo != null && contractInfo.getContractType().equals(1)) {
@@ -1838,7 +1872,6 @@ public class TaskController extends BladeController {
         if (startIndex < endIndex && CollectionUtil.isNotEmpty(filteredList)) {
             currentPageTaskList = filteredList.subList(startIndex, endIndex);
         }
-
         // 8. 转换当前页数据为VO(复用原逻辑,补充已废除任务日志信息)
         Map<String, List<TaskParallel>> finalTaskParallelGroupMap1 = taskParallelGroupMap;
         Map<String, List<OperationLog>> finalOperationLogMap = operationLogMap;
@@ -1949,6 +1982,76 @@ 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();
+        //查出当前电签到的节点sort
+        List<TaskParallel> taskParallels = taskParallelMap.get(processInstanceId);
+        Optional<Integer> sortDq = taskParallels.stream()
+                .filter(t -> t.getStatus() == 1)
+                .min(Comparator.comparing(TaskParallel::getSort))
+                .map(TaskParallel::getSort);
+        //获取当前用户的sort值
+        List<Integer> userSort = taskParallels.stream()
+                .filter(t -> t.getTaskUser().equals(userId.toString()))
+                .sorted(Comparator.comparing(TaskParallel::getSort))
+                .map(TaskParallel::getSort).collect(Collectors.toList());
+        Integer dqSort = sortDq.orElse(null);
+        if(ObjectUtil.isNotEmpty(dqSort)){
+            List<Integer> list1 = userSort.stream().filter(a -> dqSort.compareTo(a) <= 0).collect(Collectors.toList());
+            if(ObjectUtil.isEmpty(list1)){
+                //当前用户已经签字过
+                resultList.remove(task);
+            }else {
+                //筛选出最近的一条没有电签的当前用户的sort
+                Integer userMinSort = Collections.min(list1);
+                if(userMinSort.toString().equals(dqSort.toString())){
+                    //当前用户就是下一个电签用户 可审批 放行
+                    return;
+                }
+                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);
+                    }
+                }else {
+                    //不在一个小流程 不可审批
+                    resultList.remove(task);
+                }
+            }
+        }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);
+        }
+    }
+
     @PostMapping("/pageset")
     @ApiOperationSupport(order = 1)
     @ApiOperation(value = "电签显示等待 batch中没有 用于跑电签数据的接口 手动调用", notes = "传入BusinessTaskDTO")

+ 5 - 41
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TaskServiceImpl.java

@@ -1491,26 +1491,8 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
             vo.setStartTime(DateUtil.format(nowTime, "yyyy-MM-dd"));
             vo.setEndTime(DateUtil.format(DateUtils.addDays(nowTime, vo.getRestrictDay()), "yyyy-MM-dd"));
 
-//            Query query = new Query();
-//            query.setCurrent(1);
-//            query.setSize(999);
-            //获取流程
-//            List<FlowProcessVO> modeProcessVOS = this.newFlowClient.startFlowList("", query, 1);
-//            if (modeProcessVOS == null || modeProcessVOS.size() == 0) {
-//                return false;
-//            }
             //获取当中的审批流程
             String taskFlowId = SnowFlakeUtil.getId() + "";
-//            for (FlowProcessVO processVO : modeProcessVOS) {
-//                if ("approval".equals(processVO.getKey())) {
-//                    taskFlowId = processVO.getId();
-//                    break;
-//                }
-//            }
-//            //如果没有对应流程,直接返回
-//            if (StringUtils.isEmpty(taskFlowId)) {
-//                return false;
-//            }
             //获取选择的固定流程
             List<FixedFlowLink> links = new ArrayList<>();
             if (Long.valueOf("0").equals(vo.getFixedFlowId())) {
@@ -1529,33 +1511,15 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
                 }
             }
 
-            //启动主流程
-//            R<BladeFlow> result = this.flowClient.startProcessInstanceById(taskFlowId, FlowUtil.getBusinessKey(businessTable, String.valueOf(vo.getId())),
-//                    Kv.create().set(ProcessConstant.TASK_VARIABLE_CREATE_USER, AuthUtil.getUserName()).set("taskUser", TaskUtil.getTaskUser("")));
-//            if (result.isSuccess()) {
-//                log.debug("主流程已启动,流程ID:" + result.getData().getProcessInstanceId());
-//                //拼接并行的实例ID
-//                vo.setProcessInstanceId(result.getData().getProcessInstanceId());
-//            } else {
-//                throw new ServiceException("开启主流程失败");
-//            }
             vo.setProcessInstanceId(SnowFlakeUtil.getId() + "");
 
             //根据所选择的固定流程所含有的环节发起审批任务
             List<TaskParallel> taskParallelArray = new ArrayList<>();
-            for (FixedFlowLink link : links) {
-                //启动并行流程
-//                Kv variables = Kv.create()
-//                        //下一步流程审批人
-//                        .set("taskUser", TaskUtil.getTaskUser(link.getFixedFlowLinkUser().toString()));
-//                R<BladeFlow> linkResult = this.flowClient.startProcessInstanceById(taskFlowId, FlowUtil.getBusinessKey(businessTable, String.valueOf(vo.getId())), variables);
-//                if (linkResult.isSuccess()) {
-//                    log.debug("并行流程已启动,流程ID:" + linkResult.getData().getProcessInstanceId());
-//                    taskParallelArray.add(new TaskParallel(vo.getProcessInstanceId(), linkResult.getData().getProcessInstanceId(), link.getFixedFlowLinkUser().toString(), link.getFixedFlowLinkUserName()));
-//                } else {
-//                    throw new ServiceException("开启并行流程失败");
-//                }
-                taskParallelArray.add(new TaskParallel(vo.getProcessInstanceId(), SnowFlakeUtil.getId() + "", link.getFixedFlowLinkUser().toString(), link.getFixedFlowLinkUserName()));
+            for (int i = 0, linksSize = links.size(); i < linksSize; i++) {
+                FixedFlowLink link = links.get(i);
+                TaskParallel parallel = new TaskParallel(vo.getProcessInstanceId(), SnowFlakeUtil.getId() + "", link.getFixedFlowLinkUser().toString(), link.getFixedFlowLinkUserName());
+                parallel.setSort(link.getFixedFlowBranchSort() == null ? i : link.getFixedFlowBranchSort());
+                taskParallelArray.add(parallel);
             }
             //设置流程信息
             vo.setProcessDefinitionId(taskFlowId);