自定义审批流程

涉及到的表:

1 workflow_type 流程类型表(用于流程类型分类 type_id关联)
 2  workflow_step 流程步骤表 (用于配置步骤以及步骤类型 type_id关联)

 3   workflow_step_relation 流程步骤关系表 (用于判断下一步走的步骤 type_id关联)

 4  workflow_record  流程明细表(记录每一步流程操作信息)

 5    workflow_info  流程表 (当前步 每个流水号只有一条信息)

 6  workflow_approve_opinion 流程审批意见表 (记录审批意见)

 7 workflow_file 流程附件表 (记录审批附件 关键 流程明细表id)

 8  workflow_approve_user  流程审批人表 (每一个审批步骤对应审批人和角色配置)


1 配置1.1流程类型 1.2步骤1.3 步骤关联关系1.4 流程审批人信息

2  创建流程实例

  2.1 判断流程类型是否存在

  2.2 判断流程步骤是否存在 存在取第一步

  2.3   创建流程实例信息

  2.4  创建流程审批记录

String recordTaskId = workProcessService.startProcessInstanceByKey(workflowTypeId, appGriderDto.getBusSerialno());
public String startProcessInstanceByKey(String processKey, String businessNo) {
    UserLoginVo user = userSystemService.getUserByToken();
    if (user == null) {
        throw new BusinessException("无法获取用户信息,无法进行流程创建!");
    }

    WorkflowType workflowType = workflowTypeService.searFloeType(processKey);
    if (Objects.isNull(workflowType)) {
        throw new BusinessException("无法获取流程信息!");
    }

    WorkflowStep firstStep = workflowStepService.getFirstStep(processKey);
    if (Objects.isNull(firstStep)) {
        throw new BusinessException("无法获取流程步骤信息!");
    }
    // 创建流程实例信息
    WorkflowInfo workflowInfo = WorkflowTranslator.createWorkflowInfo(user,processKey, workflowType.getWfTypeName(), businessNo, firstStep.getWfStepId());
    workflowInfo.setCurrentStepId(firstStep.getWfStepId());
    workflowInfoService.save(workflowInfo);

    // 创建流程审批记录
    WorkflowRecord workflowRecord = WorkflowTranslator.createWorkflowRecord(user, firstStep, workflowInfo);
    workflowRecord.setWfSerialno(workflowInfo.getWfSerialno());
    workflowRecordService.save(workflowRecord);
    return workflowRecord.getWfRecordId();
}
public WorkflowStep getFirstStep(String processKey) {
    LambdaQueryWrapper<WorkflowStep> wa = new LambdaQueryWrapper<>();
    wa.eq(WorkflowStep::getWfTypeId, processKey).orderByAsc(WorkflowStep::getWfStepSort).last("limit 1");
    return this.getOne(wa);
}
public static WorkflowInfo createWorkflowInfo(UserLoginVo user,String processKey, String wfTypeName, String businessNo, String wfStepIds) {
    WorkflowInfo workflowInfo = new WorkflowInfo();
    workflowInfo.setWfName(wfTypeName);
    workflowInfo.setWfTypeId(processKey);
    workflowInfo.setWfSerialno(UUIDUtils.getRandomUUID());
    workflowInfo.setBusSerialno(businessNo);
    workflowInfo.setWfStepIds(wfStepIds);
    workflowInfo.setCreateTime(LocalDateTime.now());
    workflowInfo.setUpdateTime(LocalDateTime.now());
    workflowInfo.setWfApplicantId(user.getUserId());
    workflowInfo.setWfApplicantName(user.getUsername());
    return workflowInfo;
}


public static WorkflowRecord createWorkflowRecord(UserLoginVo user, WorkflowStep firstStep, WorkflowInfo workflowInfo) {
    WorkflowRecord workflowRecord = new WorkflowRecord();
    workflowRecord.setWfTypeId(workflowInfo.getWfTypeId());
    workflowRecord.setCreateTime(new Date());
    workflowRecord.setUpdateTime(new Date());
    workflowRecord.setWfStepState(1);
    workflowRecord.setWfSerialno(workflowInfo.getWfSerialno());
    workflowRecord.setBusSerialno(workflowInfo.getBusSerialno());
    workflowRecord.setWfStepId(firstStep.getWfStepId());
    workflowRecord.setWfStepName(firstStep.getWfStepName());
    workflowRecord.setWfId(workflowInfo.getWfId());
    workflowRecord.setWfName(workflowInfo.getWfName());
    workflowRecord.setWfFinishUserid(user.getUserId());
    workflowRecord.setWfFinishUsername(user.getUsername());
    workflowRecord.setWfFinishDept(user.getDepartmentId());
    workflowRecord.setWfFinishDeptname(user.getDepartmentName());
    workflowRecord.setWfStarttime(new Date());
    workflowRecord.setWfFinishtime(new Date());
    return workflowRecord;
}


3   提交步骤

String recordTaskId = workProcessService.startProcessInstanceByKey(workflowTypeId, appGriderDto.getBusSerialno());
Map<String, Object> variableMap = new HashMap<>();
variableMap.put("linkText", "通过");
workProcessService.completeTask(recordTaskId, "", variableMap);


public List<String> completeTask(String recordTaskId, String opinion, Map<String, Object> variableMap) {
        WorkflowRecord workflowRecord = workflowRecordService.getBaseMapper().selectById(recordTaskId);
        if (Objects.isNull(workflowRecord)) {
            throw new BusinessException("无法获取流程实例记录信息!流程id"+recordTaskId);
        }
        UserLoginVo user = (UserLoginVo) variableMap.get("user");
        if (Objects.isNull(user)) {
            user = userSystemService.getUserByToken();
        }
        if (user == null) {
            throw new BusinessException("无法获取用户信息,无法执行流程操作!");
        }
        // 获取流程流水号
        String wfSerialno = workflowRecord.getWfSerialno();
        LambdaQueryWrapper<WorkflowInfo> wr = new LambdaQueryWrapper<>();
        WorkflowInfo workflowInfo = workflowInfoService.getOne(wr.eq(WorkflowInfo::getWfSerialno, wfSerialno));
        if (workflowInfo == null) {
            throw new BusinessException("任务流程实例已结束,无法完成任务!流水号:"+wfSerialno);
        }

        // 流程审批意见表,审批通过
        Object approveStatus = variableMap.get("approveStatus");
        Integer approveStatusIn = 1;
        if (Objects.nonNull(approveStatus)) {
            approveStatusIn = (Integer) approveStatus;
        }
        workflowApproveOpinionService.saveOpinion(opinion, workflowRecord.getWfId(), workflowRecord.getWfRecordId(), approveStatusIn, user);

        String wfStepIds = workflowInfo.getWfStepIds();

        // 就要更新节点信息
        if (approveStatusIn == 1) { // 审批通过
            workflowRecordService.finishRecord(workflowRecord.getWfRecordId(), 2, user);
        }
        if (approveStatusIn == 0) { // 审批不通过
            workflowRecordService.finishRecord(workflowRecord.getWfRecordId(), 3, user);
        }


        WorkflowStep workflowStep = workflowStepService.getBaseMapper().selectById(workflowRecord.getWfStepId());
//        checkCanApprove(user, workflowStep,workflowRecord.getWfTypeId());

        // 多节点审批是否能够往下走
        if (wfStepIds.contains(",")) {
            List<String> stepIds = Arrays.asList(wfStepIds.split(","));
            List<String> recordIds = workflowRecordService.searchRecord(workflowRecord.getWfId(), stepIds);
            // 查看所有节点是否审批通过
            List<WorkflowApproveOpinion> workflowApproveOpinions = workflowApproveOpinionService.searchOpinions(recordIds);
            long count = workflowApproveOpinions.stream().filter(op -> op.getWfApproveState() == 1).count();
            if (count != stepIds.size()) {
                return null;
            }
        }

        if ("end".equals(workflowStep.getWfStepType())) {
            throw new BusinessException("最后一个节点,任务流程实例已结束!流水号:"+wfSerialno);
        }

        List<String> nextStepList;
        if (workflowStep.getWfStepType().equals("Conditional")) {//"通过"
            nextStepList = workflowStepRelationService.nextStep(workflowInfo.getWfTypeId(), workflowRecord.getWfStepId(), (String) variableMap.get("linkText"));
        } else {
            nextStepList = workflowStepRelationService.nextStep(workflowInfo.getWfTypeId(), workflowRecord.getWfStepId(), null);
        }

        if (CollectionUtils.isEmpty(nextStepList)) {
            return null;
        }

        UserLoginVo finalUser = user;

        List<String> recordIds = new ArrayList<>();
        nextStepList.forEach(stepId -> {
            String recordId = handleSingleStep(finalUser, workflowInfo, stepId);
            recordIds.add(recordId);
        });
        // 更新workflowInfo
        workflowInfo.setWfStepIds(String.join(",", nextStepList));
        int i = nextStepList.size() - 1;
        String wfStepId = nextStepList.get(i);
        workflowInfo.setUpdateTime(LocalDateTime.now());
        workflowInfo.setCurrentStepId(wfStepId);
        workflowInfoService.getBaseMapper().updateById(workflowInfo);
        return recordIds;
    }


public void saveOpinion(String opinion, String wfId, String wfRecordId, Integer approveStatus, UserLoginVo user) {
    WorkflowApproveOpinion flowOpinion = new WorkflowApproveOpinion();
    flowOpinion.setWfOpinion(opinion);
    flowOpinion.setWfId(wfId);
    flowOpinion.setWfOpinionTime(new Date());
    flowOpinion.setWfRecordId(wfRecordId);
    flowOpinion.setWfApproveState(approveStatus);
    flowOpinion.setWfApproveUserid(user.getUserId());
    flowOpinion.setWfApproveUsername(user.getUsername());
  /*  LambdaQueryWrapper<WorkflowApproveOpinion> wwp = new LambdaQueryWrapper<>();
    wwp.eq(WorkflowApproveOpinion::getWfRecordId, wfRecordId);*/
    int count = workflowApproveOpinionMapper.selectCountByRecordId(wfRecordId);
    flowOpinion.setWfOpnionSort(count + 1);
    this.save(flowOpinion);
}
@Override
    public void finishRecord(String recordId, Integer approveState, UserLoginVo user) {
        LambdaQueryWrapper<WorkflowRecord> wd = new LambdaQueryWrapper<>();
        wd.eq(WorkflowRecord::getWfRecordId, recordId);
        WorkflowRecord workflowRecord = this.getOne(wd);

        workflowRecord.setUpdateTime(new Date());
        workflowRecord.setWfStepState(approveState);
        workflowRecord.setWfFinishUserid(user.getUserId());
        workflowRecord.setWfFinishUsername(user.getUsername());
        workflowRecord.setWfFinishDept(user.getDepartmentId());
        workflowRecord.setWfFinishDeptname(user.getDepartmentName());
        workflowRecord.setWfFinishtime(new Date());
        workflowRecord.setUpdateTime(new Date());
        this.saveOrUpdate(workflowRecord);
    }

 @Override
    public List<String> searchRecord(String wfId, List<String> stepIds) {
        LambdaQueryWrapper<WorkflowRecord> wd = new LambdaQueryWrapper<>();
        wd.eq(WorkflowRecord::getWfId, wfId);
        wd.in(WorkflowRecord::getWfStepId, stepIds);

        List<WorkflowRecord> workflowRecords = this.getBaseMapper().selectList(wd);
        if (CollectionUtils.isEmpty(workflowRecords)) {
            return null;
        }
        return workflowRecords.stream().map(WorkflowRecord::getWfRecordId).collect(Collectors.toList());
    }

 @Override
    public List<WorkflowApproveOpinion> searchOpinions(List<String> recordIds) {
        LambdaQueryWrapper<WorkflowApproveOpinion> wwp = new LambdaQueryWrapper<>();
        wwp.in(WorkflowApproveOpinion::getWfRecordId, recordIds);
        return this.baseMapper.selectList(wwp);
    }
   @Override
    public List<String> nextStep(String wfTypeId, String currentStep, String opinion) {
        LambdaQueryWrapper<WorkflowStepRelation> wa = new LambdaQueryWrapper<>();
        wa.eq(WorkflowStepRelation::getWfTypeId, wfTypeId).eq(WorkflowStepRelation::getWfStepId, currentStep);
        if (StringUtils.hasText(opinion)) {
            wa.eq(WorkflowStepRelation::getLinkText, opinion);
        }
        List<WorkflowStepRelation> srs = this.baseMapper.selectList(wa);
        if (CollectionUtils.isEmpty(srs)) {
            return null;
        }
        return srs.stream().map(WorkflowStepRelation::getWfNextstepId).collect(Collectors.toList());
    }

4 驳回
variableMap.put("linkText", "不通过");
            workProcessService.backTask(query.getRecordTaskId(), query.getOpinion(), variableMap);//


@Override
    @Transactional(rollbackFor = Exception.class)
    public void backTask(String recordTaskId, String opinion, Map<String, Object> variableMap) {
        WorkflowRecord workflowRecord = workflowRecordService.getBaseMapper().selectById(recordTaskId);
        if (Objects.isNull(workflowRecord)) {
            throw new BusinessException("无法获取流程实例记录信息!");
        }
        UserLoginVo user = (UserLoginVo) variableMap.get("user");
        if (Objects.isNull(variableMap.get("user"))) {
            user = userSystemService.getUserByToken();
        }
        if (user == null) {
            throw new BusinessException("无法获取用户信息,无法执行流程操作!");
        }
        // 获取流程流水号
        String wfSerialno = workflowRecord.getWfSerialno();
        LambdaQueryWrapper<WorkflowInfo> wr = new LambdaQueryWrapper<>();
        WorkflowInfo workflowInfo = workflowInfoService.getOne(wr.eq(WorkflowInfo::getWfSerialno, wfSerialno));
        if (workflowInfo == null) {
            throw new BusinessException("任务流程实例已结束,无法完成任务!");
        }

        // 流程审批意见表,审批通过
        workflowApproveOpinionService.saveOpinion(opinion, workflowRecord.getWfId(), workflowRecord.getWfRecordId(), 0, user);

        // 如果不是审批节点,无法回退, 审批节点回退一般只有一个父节点
        WorkflowStep workflowStep = workflowStepService.getBaseMapper().selectById(workflowRecord.getWfStepId());
//        checkCanApprove(user, workflowStep,workflowRecord.getWfTypeId());

        if (!workflowStep.getWfStepType().equals("Conditional")) {
            throw new BusinessException("当前任务节点不是审批节点,无法审批回退!");
        }
        // 如果只有一个流程节点,就要更新节点信息
        workflowRecordService.finishRecord(workflowRecord.getWfRecordId(), 3, user);

        List<String> nextSteps = workflowStepRelationService.nextStep(workflowInfo.getWfTypeId(), workflowRecord.getWfStepId(), (String) variableMap.get("linkText"));
//        WorkflowStep lastStep = workflowStepService.lastStep(workflowInfo.getWfTypeId(), workflowRecord.getWfStepId());
        if (CollectionUtils.isEmpty(nextSteps)) {
            throw new BusinessException("无法获取上一节点信息,无法审批回退!");
        }
        WorkflowStep nextStep = workflowStepService.getBaseMapper().selectById(nextSteps.get(0));
        WorkflowRecord workflowRecordNew = WorkflowTranslator.createWorkflowRecord(user, nextStep, workflowInfo);

        if ("end".equals(nextStep.getWfStepType())) {
            workflowRecordNew.setWfStepState(2);
            workflowInfo.setWfEndTime(LocalDateTime.now());
        }

        //设置主流程为归档
        LambdaUpdateWrapper<WorkflowInfo> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(WorkflowInfo::getBusSerialno, workflowInfo.getBusSerialno());
        workflowInfo.setWfStepIds(nextStep.getWfStepId());
        workflowInfo.setWfEndTime(LocalDateTime.now());
        workflowInfo.setCurrentStepId(nextStep.getWfStepId());

        workflowInfoService.update(workflowInfo, updateWrapper);
        workflowRecordService.save(workflowRecordNew);

        // 如果是最后一个节点
    }

@Override
    public void saveOpinion(String opinion, String wfId, String wfRecordId, Integer approveStatus, UserLoginVo user) {
        WorkflowApproveOpinion flowOpinion = new WorkflowApproveOpinion();
        flowOpinion.setWfOpinion(opinion);
        flowOpinion.setWfId(wfId);
        flowOpinion.setWfOpinionTime(new Date());
        flowOpinion.setWfRecordId(wfRecordId);
        flowOpinion.setWfApproveState(approveStatus);
        flowOpinion.setWfApproveUserid(user.getUserId());
        flowOpinion.setWfApproveUsername(user.getUsername());
      /*  LambdaQueryWrapper<WorkflowApproveOpinion> wwp = new LambdaQueryWrapper<>();
        wwp.eq(WorkflowApproveOpinion::getWfRecordId, wfRecordId);*/
        int count = workflowApproveOpinionMapper.selectCountByRecordId(wfRecordId);
        flowOpinion.setWfOpnionSort(count + 1);
        this.save(flowOpinion);
    }

 @Override
    public void finishRecord(String recordId, Integer approveState, UserLoginVo user) {
        LambdaQueryWrapper<WorkflowRecord> wd = new LambdaQueryWrapper<>();
        wd.eq(WorkflowRecord::getWfRecordId, recordId);
        WorkflowRecord workflowRecord = this.getOne(wd);

        workflowRecord.setUpdateTime(new Date());
        workflowRecord.setWfStepState(approveState);
        workflowRecord.setWfFinishUserid(user.getUserId());
        workflowRecord.setWfFinishUsername(user.getUsername());
        workflowRecord.setWfFinishDept(user.getDepartmentId());
        workflowRecord.setWfFinishDeptname(user.getDepartmentName());
        workflowRecord.setWfFinishtime(new Date());
        workflowRecord.setUpdateTime(new Date());
        this.saveOrUpdate(workflowRecord);
    }

    @Override
    public List<String> nextStep(String wfTypeId, String currentStep, String opinion) {
        LambdaQueryWrapper<WorkflowStepRelation> wa = new LambdaQueryWrapper<>();
        wa.eq(WorkflowStepRelation::getWfTypeId, wfTypeId).eq(WorkflowStepRelation::getWfStepId, currentStep);
        if (StringUtils.hasText(opinion)) {
            wa.eq(WorkflowStepRelation::getLinkText, opinion);
        }
        List<WorkflowStepRelation> srs = this.baseMapper.selectList(wa);
        if (CollectionUtils.isEmpty(srs)) {
            return null;
        }
        return srs.stream().map(WorkflowStepRelation::getWfNextstepId).collect(Collectors.toList());
    }

   /**
     * 创建流程记录
     */
    public static WorkflowRecord createWorkflowRecord(UserLoginVo user, WorkflowStep firstStep, WorkflowInfo workflowInfo) {
        WorkflowRecord workflowRecord = new WorkflowRecord();
        workflowRecord.setWfTypeId(workflowInfo.getWfTypeId());
        workflowRecord.setCreateTime(new Date());
        workflowRecord.setUpdateTime(new Date());
        workflowRecord.setWfStepState(1);
        workflowRecord.setWfSerialno(workflowInfo.getWfSerialno());
        workflowRecord.setBusSerialno(workflowInfo.getBusSerialno());
        workflowRecord.setWfStepId(firstStep.getWfStepId());
        workflowRecord.setWfStepName(firstStep.getWfStepName());
        workflowRecord.setWfId(workflowInfo.getWfId());
        workflowRecord.setWfName(workflowInfo.getWfName());
        workflowRecord.setWfFinishUserid(user.getUserId());
        workflowRecord.setWfFinishUsername(user.getUsername());
        workflowRecord.setWfFinishDept(user.getDepartmentId());
        workflowRecord.setWfFinishDeptname(user.getDepartmentName());
        workflowRecord.setWfStarttime(new Date());
        workflowRecord.setWfFinishtime(new Date());
        return workflowRecord;
    }
/**
     * 处理下个步骤信息
     *
     * @param stepId next step
     */
    public String handleSingleStep(UserLoginVo user, WorkflowInfo workflowInfo, String stepId) {
        WorkflowStep workflowStep = workflowStepService.getBaseMapper().selectById(stepId);
        WorkflowRecord workflowRecord = WorkflowTranslator.createWorkflowRecord(user, workflowStep, workflowInfo);
        Boolean existRecord = workflowRecordService.existRecord(workflowInfo.getWfSerialno(), stepId);
        // 结束节点直接完结
        if (!existRecord) {
            if ("end".equals(workflowStep.getWfStepType())) {
                workflowRecord.setWfStepState(2);
                workflowInfo.setWfEndTime(LocalDateTime.now());
            }
            workflowRecordService.save(workflowRecord);
            if ("end".equals(workflowStep.getWfStepType())) {
                workflowApproveOpinionService.saveOpinion("通过", workflowRecord.getWfId(), workflowRecord.getWfRecordId(), 1, user);
    

5 流程状态列表
  @PostMapping("/list")
    @Operation(summary = "查询人员变动管理列表")
    public JsonResponse<IPage<GriderChangeVo>> changList(@RequestBody GriderChangeQuery griderChangeQuery){
        return JsonResponse.ok(griderChangeService.changList(griderChangeQuery));
    }


@Override
    public IPage<GriderChangeVo> changList(GriderChangeQuery griderChangeQuery) {

        if(griderChangeQuery == null || griderChangeQuery.getQueryType()==null){
            throw new BusinessException("必须传入查询类型");
        }
        if (!(griderChangeQuery.getQueryType()==0||griderChangeQuery.getQueryType()==1)){
            throw new BusinessException("必须传入查询类型有误");
        }
        //校验登录用户是否有查看权限
        //获取当前登录用户信息
        UserLoginVo userLoginVo=userSystemService.getUserByToken();
        if(userLoginVo==null){
            throw new BusinessException("当前登录用户信息为空!");
        }
        /*if(CollectionUtils.isEmpty(userLoginVo.getRoleList())){
            log.warn("当前用户无查看权限");
             return new Page<>(griderChangeQuery.getPageNo(), griderChangeQuery.getPageSize(), 0);
        }
        boolean flag=false;
        for(UserRole userRole:userLoginVo.getRoleList()){
            if(userRole==null
                    || StringUtils.isBlank(userRole.getRoleCode())
                    || (!userRole.getRoleCode().equals(UserRoleEnum.DISTRICTTEAMBUILD.getRoleCode())
            && !userRole.getRoleCode().equals(UserRoleEnum.STREETTEAMBUILD.getRoleCode())
            && !userRole.getRoleCode().equals(UserRoleEnum.COMMUNITYTEAMBUILD.getRoleCode()))){
                flag=false;
            }else{
                flag=true;
                break;
            }
        }
        if(!flag){
            log.warn("当前用户无查看权限");
            return new Page<>(griderChangeQuery.getPageNo(), griderChangeQuery.getPageSize(), 0);
        }*/
        log.info("查询人员变动管理列表,请求参数:{}", JSON.toJSONString(griderChangeQuery));
        if(griderChangeQuery.getQueryType()!=0 && griderChangeQuery.getQueryType()!=1){
            throw new BusinessException("查询类型,必须是0或1");
        }
        //暂存,待审批,办理中,归档
        List<String> steps=new ArrayList<>();
        setFlowStatus(steps,griderChangeQuery);
        if(steps.size()>0){
            griderChangeQuery.setSteps(steps);
        }
        //没选就默认设置入职流程
        if(griderChangeQuery.getFlowTypeIds()==null || griderChangeQuery.getFlowTypeIds().size()==0){
            List<String> typeList= new ArrayList<>();
            if(StringUtils.isNotBlank(griderChangeQuery.getOperationTypeflag())
                    && (StringUtils.equals("3",griderChangeQuery.getOperationTypeflag()) || StringUtils.equals("4",griderChangeQuery.getOperationTypeflag()))) {
                typeList.add(griderChangeId);
                typeList.add(transferPositionId);
            } else if (StringUtils.isNotBlank(griderChangeQuery.getOperationTypeflag())&&StringUtils.equals("2",griderChangeQuery.getOperationTypeflag())){
                typeList.add(workflowTypeDepartId);
            }else {
                typeList.add(workflowTypeId);
            }
            griderChangeQuery.setFlowTypeIds(typeList);
        }

        //数据域权限处理
        if(griderChangeQuery.getQueryType()==0){//自己申请的
            griderChangeQuery.setApplyUserId(userLoginVo.getUserId());
        }else{//数据域
         if(CollectionUtils.isEmpty(userLoginVo.getDataList())){
                //没有数据域权限,返回空数据
                log.warn("该用户:{},的数据域权限为空",userLoginVo.getUserId());
                return new Page<>(griderChangeQuery.getPageNo(), griderChangeQuery.getPageSize(), 0);
            }
            List<UserData> dataList=userLoginVo.getDataList();
            //设置街道和社区数据权限
            Integer level=dataList.get(0).getPrecinctLevel();
            Map<Integer, List<UserData>> map = dataList.stream().collect(Collectors.groupingBy(UserData::getPrecinctLevel));
            if(level==6){
                griderChangeQuery.setStreetCodeList(map.get(6).stream().map(UserData::getPrecinctCode).collect(Collectors.toList()));
            }else if(level==7){
                griderChangeQuery.setCommunityCodeList(map.get(7).stream().map(UserData::getPrecinctCode).collect(Collectors.toList()));
            }
        }
        if(!CollectionUtils.isEmpty(griderChangeQuery.getStatusList())){
            List<Integer> statusList= new ArrayList<>();
            for(String status:griderChangeQuery.getStatusList()){
                if(StringUtils.isBlank(status)){
                    continue;
                }
                statusList.add(Integer.valueOf(status));
            }
            griderChangeQuery.setStatusIntList(statusList);
        }

        griderChangeQuery.setStartIndex((griderChangeQuery.getPageNo() - 1)*griderChangeQuery.getPageSize());
        int total = workflowInfoMapper.selectGriderApplyFlowCount(griderChangeQuery);
        IPage<GriderChangeVo> pageRs = new Page<>(griderChangeQuery.getPageNo(), griderChangeQuery.getPageSize(), total);
        if (total > 0) {
            List<GriderChangeVo> list = workflowInfoMapper.selectGriderApplyFlow(griderChangeQuery);
            for(GriderChangeVo change:list){
                if(change!=null && StringUtils.isNotBlank(change.getWfStepIds())){
                    if (StringUtils.isNotBlank(change.getCurrentStepId())){
                        if (StringUtils.equals("1",change.getCurrentStepId())){
                            change.setLinkState("入职申请");
                        }
                        if (StringUtils.equals("2",change.getCurrentStepId())){
                            change.setLinkState("资格审查");
                        }
                        if (StringUtils.equals("3",change.getCurrentStepId())){
                            change.setLinkState("区域分配");

                        }
                        if (StringUtils.equals("4",change.getCurrentStepId())){
                            change.setLinkState("物资分配");
                        }
                        if (StringUtils.equals("5",change.getCurrentStepId())){
                            change.setLinkState("政务微信开通");
                        }
                        if (StringUtils.equals("6",change.getCurrentStepId())){
                            change.setLinkState("岗前培训");
                        }
                        if (StringUtils.equals("7",change.getCurrentStepId())){
                            change.setLinkState("信息完善");
                        }
                        if (StringUtils.equals("26",change.getCurrentStepId())){
                            change.setLinkState("流程归档");
                        }
                    }
                    String stepStr=change.getWfStepIds();
                    if(StringUtils.isNotBlank(griderChangeQuery.getOperationTypeflag()) &&
                            (StringUtils.equals("4",griderChangeQuery.getOperationTypeflag()) || StringUtils.equals("3",griderChangeQuery.getOperationTypeflag()))){
                        if(StringUtils.equals("23",stepStr) || StringUtils.equals("19",stepStr)){
                            change.setWfState("待审批");
                        }
                        if(StringUtils.equals("24",stepStr) || StringUtils.equals("20",stepStr)){
                            change.setWfState("办理中");
                        }
                        if(StringUtils.equals("25",stepStr) || StringUtils.equals("21",stepStr)){
                            change.setWfState("归档");
                        }
                    } else if (StringUtils.isNotBlank(griderChangeQuery.getOperationTypeflag())&&StringUtils.equals("2",griderChangeQuery.getOperationTypeflag())) {//离职的时候处理
                        if(stepStr.contains("13")){
                            change.setWfState("待审批");
                        }
                        if(stepStr.contains("14")||stepStr.contains("15") ){
                            change.setWfState("办理中");
                        }
                        if(stepStr.contains("16")){
                            change.setWfState("归档");
                        }
                    }else {
                        if(stepStr.contains("1")){
                            change.setWfState("暂存");
                        }
                        if(stepStr.contains("2")){
                            change.setWfState("待审批");
                        }
                        if(stepStr.contains("3") ||stepStr.contains("4") ||stepStr.contains("5")||stepStr.contains("6")){
                            change.setWfState("办理中");
                        }
                        if(stepStr.contains("7")){
                            change.setWfState("办理中");
                        }
                        if(stepStr.contains("26")){
                            change.setWfState("归档");
                        }
                        if(change.getLastCommitTime()!=null && change.getWfStepIds().equals("1")){
                            change.setWfState("已驳回");
                        }
                    }

                    if (StringUtils.isNotBlank(griderChangeQuery.getOperationTypeflag())&&StringUtils.equals("2",griderChangeQuery.getOperationTypeflag())){//离职的时候处理
                    String businessNo = change.getBusinessNo();
                    AppGriderQuery appGriderQuery1 =new AppGriderQuery();
                    appGriderQuery1.setBusSerialno(businessNo);
                    GriderBusinessFlow busSerialnoByGriderBusinessFlow = griderBusinessFlowService.getBusSerialnoByGriderBusinessFlow(appGriderQuery1);
                    if (busSerialnoByGriderBusinessFlow!=null){
                        LocalDateTime rejectionTime = busSerialnoByGriderBusinessFlow.getRejectionTime();
                        if (rejectionTime!=null&& change.getWfStepIds().equals("12")){
                            change.setWfState("已驳回");
                            change.setRejectionFlag("1");//驳回标记
                        }
                        String griderId = change.getGriderId();
                        AppGriderQuery appGriderQuery =new AppGriderQuery();
                        appGriderQuery.setGriderId(griderId);
                        AppGrider griderIdByAppGrider = appGriderService.getGriderIdByAppGrider(appGriderQuery);
                        if (griderIdByAppGrider!=null) {
                            change.setDepartDate(griderIdByAppGrider.getDepartDate());
                            change.setDepartReason(griderIdByAppGrider.getDepartReason());
                            change.setDepartRemark(griderIdByAppGrider.getDepartRemark());
                            change.setDepartDesOther(griderIdByAppGrider.getDepartDesOther());
                            List<Integer> departDesType = new ArrayList<>();
                            if (griderIdByAppGrider.getDepartDesStatus() != null) {
                                Integer departDesStatus = griderIdByAppGrider.getDepartDesStatus();
                                departDesType.add(departDesStatus);
                            }

                            String departDesType1 = griderIdByAppGrider.getDepartDesType();
                            int departDesType1num = 0;
                            if (StringUtils.isNotBlank(departDesType1)) {
                                departDesType1num = Integer.parseInt(departDesType1);
                                departDesType.add(departDesType1num);
                                change.setDepartDesType(departDesType);
                            }


                            String departDesDesc1 = griderIdByAppGrider.getDepartDesDesc();
                            if (StringUtils.isNotBlank(departDesDesc1)) {
                                List<String> collect = Arrays.stream(departDesDesc1.split(",")).collect(Collectors.toList());
                                change.setDepartDesDesc(collect);
                            }
                            String busSerialno = change.getBusinessNo();
                            List<WorkflowRecord> workflowRecords = workflowRecordService.getnewRecordIdList(busSerialno);

                            if (!CollectionUtils.isEmpty(workflowRecords)){
                                for (int i = 0; i <workflowRecords.size() ; i++) {
                                    String recordId = workflowRecords.get(i).getWfRecordId();
                                        LambdaQueryWrapper<WorkflowApproveOpinion> query = new LambdaQueryWrapper<>();
                                        query.eq(WorkflowApproveOpinion::getWfRecordId, recordId);
                                        List<WorkflowApproveOpinion> workflowApproveOpinions = workflowApproveOpinionMapper.selectList(query);
                                        if (!CollectionUtils.isEmpty(workflowApproveOpinions)) {
                                            WorkflowApproveOpinion workflowApproveOpinion = workflowApproveOpinions.get(0);
                                            if (workflowApproveOpinion != null) {
                                                change.setOpinion(workflowApproveOpinion.getWfOpinion());
                                                if (StringUtils.isNotBlank(change.getOpinion())){
                                                    break;
                                                }
                                            }
                                        }
                                }

                            }


                        }

                        }
                    }

                }
            }
            pageRs.setRecords(list);
        }
        return pageRs;
    }

<select id="selectGriderApplyFlowCount" resultType="int" parameterType="com.sf.gis.common.domain.dto.GriderChangeQuery">
        select
        count(1) from
        (
        select
        distinct
        wf.wf_id wfId,
        wf.wf_name wfName,
        wf.wf_type_id wfTypeId,
        wt.wf_type_name wfTypeName,
        wf.bus_serialno businessNo,
        wf.wf_step_ids wfStepIds,
        wf.wf_applicant_id wfApplicantId,
        wf.wf_applicant_name wfApplicantName,
        gf.start_time wfStartTime,
        gf.end_time wfEndTime,
        gd.grider_name name
        from workflow_info wf
        left join workflow_type wt on wf.wf_type_id=wt.wf_type_id
        left join grider_business_flow gf on wf.bus_serialno=gf.bus_serialno
        left join app_grider gd on gf.grider_id=gd.grider_id
        <where>
            wf.deleted is null
            <if test="data.flowTypeIds !=null  and data.flowTypeIds.size()>0 ">
                and wf.wf_type_id in
                <foreach collection="data.flowTypeIds" index = "index" item = "item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="data.businessNo !=null and data.businessNo!=''">
                and  wf.bus_serialno  like concat('%', #{data.businessNo},'%')
            </if>
            <if test="data.applyUserId !=null and data.applyUserId!=''">
                and  wf.wf_applicant_id=#{data.applyUserId}
            </if>
            <if test="data.initiateStartTime !=null ">
                and  gf.start_time  <![CDATA[>=]]> #{data.initiateStartTime}
            </if>
            <if test="data.initiateEndTime !=null ">
                and  gf.start_time  <![CDATA[<=]]> #{data.initiateEndTime}
            </if>
            <if test="data.finishStartTime !=null ">
                and  gf.end_time  <![CDATA[>=]]> #{data.finishStartTime}
            </if>
            <if test="data.finishEndTime !=null ">
                and  gf.end_time  <![CDATA[<=]]> #{data.finishEndTime}
            </if>
            <if test="data.streetCodeList !=null and data.streetCodeList.size()>0">
               and gd.street_code in
                <foreach collection="data.streetCodeList" index = "index" item = "item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="data.statusIntList !=null and data.statusIntList.size()>0">
                and wt.wf_type_sort in
                <foreach collection="data.statusIntList" index = "index" item = "item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="data.communityCodeList !=null  and data.communityCodeList.size()>0">
               and gd.community_code in
                <foreach collection="data.communityCodeList" index = "index" item = "item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>

            <if test="data.steps != null and data.steps.size()>0">
                <foreach collection="data.steps" index="index" item="item" open="and (" separator=" or " close=")">
                    wf.wf_step_ids like concat('%', #{item},'%')
                </foreach>
            </if>
            <if test="data.userName != null and data.userName!=''">
                and gd.grider_name like concat('%', #{data.userName},'%')
            </if>
            <if test="data.linkStates !=null  and data.linkStates.size()>0 ">
                and  wf.current_step_id in
                <foreach collection="data.linkStates" index = "index" item = "item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="data.streetCodes !=null  and data.streetCodes.size()>0 ">
                and gd.street_code in
                <foreach collection="data.streetCodes" index = "index" item = "item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
        </where>) tt


    </select>

 <select id="selectGriderApplyFlow" resultType="com.sf.gis.common.domain.vo.GriderChangeVo" parameterType="com.sf.gis.common.domain.dto.GriderChangeQuery">
       select * from (
        select
        distinct
        wf.wf_id wfId,
        wf.wf_name wfName,
        wf.wf_type_id wfTypeId,
        wt.wf_type_name wfTypeName,
        wf.bus_serialno businessNo,
        wf.wf_step_ids wfStepIds,
        (select string_agg(ws.wf_step_name , ', ') from workflow_step ws where wf_step_id in (SELECT unnest(string_to_array(wf.wf_step_ids, ',')))) as wfStepName,
        wf.wf_applicant_id wfApplicantId,
        wf.wf_applicant_name wfApplicantName,
        gf.start_time wfStartTime,
        gf.end_time wfEndTime,
        gf.last_commit_time lastCommitTime,
        gd.grider_name name,
        gd.grider_id griderId,
        wf.create_time createTime,
        wf.current_step_id currentStepId
        from workflow_info wf
        left join workflow_type wt on wf.wf_type_id=wt.wf_type_id
        left join grider_business_flow gf on wf.bus_serialno=gf.bus_serialno
        left join app_grider gd on gf.grider_id=gd.grider_id
        <where>
            wf.deleted is null
            <if test="data.flowTypeIds !=null and data.flowTypeIds.size()>0 ">
                and wf.wf_type_id in
                <foreach collection="data.flowTypeIds" index = "index" item = "item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="data.businessNo !=null and data.businessNo!=''">
                and  wf.bus_serialno  like concat('%', #{data.businessNo},'%')
            </if>
            <if test="data.applyUserId !=null and data.applyUserId!=''">
                and  wf.wf_applicant_id=#{data.applyUserId}
            </if>
            <if test="data.initiateStartTime !=null ">
                and  gf.start_time  <![CDATA[>=]]> #{data.initiateStartTime}
            </if>
            <if test="data.initiateEndTime !=null ">
                and  gf.start_time  <![CDATA[<=]]> #{data.initiateEndTime}
            </if>
            <if test="data.finishStartTime !=null ">
                and  gf.end_time  <![CDATA[>=]]> #{data.finishStartTime}
            </if>
            <if test="data.finishEndTime !=null ">
                and  gf.end_time  <![CDATA[<=]]> #{data.finishEndTime}
            </if>
            <if test="data.statusIntList !=null and data.statusIntList.size()>0">
                and wt.wf_type_sort in
                <foreach collection="data.statusIntList" index = "index" item = "item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="data.streetCodeList !=null and data.streetCodeList.size()>0">
                and gd.street_code in
                <foreach collection="data.streetCodeList" index = "index" item = "item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="data.communityCodeList !=null  and data.communityCodeList.size()>0">
                and gd.community_code in
                <foreach collection="data.communityCodeList" index = "index" item = "item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="data.steps != null and data.steps.size()>0">
                <foreach collection="data.steps" index="index" item="item" open="and (" separator=" or " close=")">
                    wf.wf_step_ids like concat('%', #{item},'%')
                </foreach>
            </if>
            <if test="data.userName != null and data.userName!=''">
                and gd.grider_name like concat('%', #{data.userName},'%')
            </if>
            <if test="data.linkStates !=null  and data.linkStates.size()>0 ">
                and  wf.current_step_id in
                <foreach collection="data.linkStates" index = "index" item = "item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="data.streetCodes !=null  and data.streetCodes.size()>0 ">
                and gd.street_code in
                <foreach collection="data.streetCodes" index = "index" item = "item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
        </where>) tt
        ORDER BY tt.createTime desc
        LIMIT #{data.pageSize} OFFSET #{data.startIndex}
    </select>

  @Override
    public GriderBusinessFlow getBusSerialnoByGriderBusinessFlow(AppGriderQuery appGriderQuery) {
        LambdaQueryWrapper<GriderBusinessFlow> query = Wrappers.lambdaQuery();
        query.eq(GriderBusinessFlow::getBusSerialno, appGriderQuery.getBusSerialno());
        GriderBusinessFlow griderBusinessFlow = this.baseMapper.selectOne(query);
        if (griderBusinessFlow == null) {
            return null;
        }
        return griderBusinessFlow;
    }
 @Override
    public List<WorkflowRecord> getnewRecordIdList(String busSerialno) {
        LambdaQueryWrapper<WorkflowRecord> wd = new LambdaQueryWrapper<>();
        wd.eq(WorkflowRecord::getBusSerialno,busSerialno).orderByDesc(WorkflowRecord::getCreateTime);
        List<WorkflowRecord> list = this.list(wd);
        return list;
    }

6 审批列表
 @PostMapping("/list")
    public JsonResponse<IPage<AllocationDto>> list(@RequestBody AllocationListQuery allocationListQuery){
        return JsonResponse.ok(griderAllocationService.list(allocationListQuery));
    }

  @Override
    public IPage<AllocationDto> list(AllocationListQuery allocationListQuery) {
        if (allocationListQuery == null || allocationListQuery.getQueryType() == null
                || (allocationListQuery.getQueryType() != 1
                && allocationListQuery.getQueryType() != 2
                && allocationListQuery.getQueryType() != 3
                && allocationListQuery.getQueryType() != 4
                && allocationListQuery.getQueryType() != 5
                && allocationListQuery.getQueryType() != 6)) {
            throw new BusinessException("必须传入查询类型");
        }
        //校验登录用户是否有查看权限
        //获取当前登录用户信息
        UserLoginVo userLoginVo = userSystemService.getUserByToken();
        if (userLoginVo == null) {
            throw new BusinessException("当前登录用户信息为空!");
        }
        /*if (CollectionUtils.isEmpty(userLoginVo.getRoleList())) {
            log.warn("当前用户无查看权限");
            return new Page<>(allocationListQuery.getPageNo(), allocationListQuery.getPageSize(), 0);
        }
        boolean flag = false;
        for (UserRole userRole : userLoginVo.getRoleList()) {
            if (allocationListQuery.getQueryType() == 5 || allocationListQuery.getQueryType() == 6) {
                if (userRole.getRoleCode().equals(UserRoleEnum.DISTRICTTEAMBUILD.getRoleCode())) {
                    flag = true;
                    break;
                }
            } else {
                if (userRole == null
                        || StringUtils.isBlank(userRole.getRoleCode())
                        || (!userRole.getRoleCode().equals(UserRoleEnum.DISTRICTTEAMBUILD.getRoleCode())
                        && !userRole.getRoleCode().equals(UserRoleEnum.STREETTEAMBUILD.getRoleCode())
                        && !userRole.getRoleCode().equals(UserRoleEnum.COMMUNITYTEAMBUILD.getRoleCode()))) {
                    flag = false;
                } else {
                    flag = true;
                    break;
                }
            }
        }
        if (!flag) {
            log.warn("当前用户无查看权限");
            return new Page<>(allocationListQuery.getPageNo(), allocationListQuery.getPageSize(), 0);
        }*/
        allocationListQuery.setWfTypeId(workflowTypeId);

        //没选就默认设置入职流程
        if (allocationListQuery.getFlowTypeIds() == null || allocationListQuery.getFlowTypeIds().size() == 0) {
            List<String> typeList = new ArrayList<>();
            typeList.add(workflowTypeId);
            allocationListQuery.setFlowTypeIds(typeList);
        }
        //待入格
        if (allocationListQuery.getQueryType() == 1) {
            allocationListQuery.setStepName(EntryStepEnum.GRID.getValue());
            allocationListQuery.setStepState("1");
            //已入格
        } else if (allocationListQuery.getQueryType() == 2) {
            allocationListQuery.setStepName(EntryStepEnum.GRID.getValue());
            allocationListQuery.setStepState("2");
            //待分配
        } else if (allocationListQuery.getQueryType() == 3) {
            allocationListQuery.setStepName(EntryStepEnum.MATERIALS.getValue());
            allocationListQuery.setStepState("1");
            //已分配
        } else if (allocationListQuery.getQueryType() == 4) {
            allocationListQuery.setStepName(EntryStepEnum.MATERIALS.getValue());
            allocationListQuery.setStepState("2");
            //待审批
        } else if (allocationListQuery.getQueryType() == 5) {
            allocationListQuery.setStepName(EntryStepEnum.APPROVE.getValue());
            allocationListQuery.setStepState("1");
            //已审批
        } else if (allocationListQuery.getQueryType() == 6) {
            allocationListQuery.setStepName(EntryStepEnum.APPROVE.getValue());
            allocationListQuery.setApprove("approve");
        }
        IPage<AllocationDto> pageRs = null;
        List<UserData> dataList = userLoginVo.getDataList();
        if (CollectionUtils.isEmpty(dataList)) {
            pageRs = new Page<>(allocationListQuery.getPageNo(), allocationListQuery.getPageSize(), 0);
            log.warn("用户:{},数据域权限为空!", userLoginVo.getUsername());
            return pageRs;
        }
        //设置街道和社区数据权限
        Integer level = dataList.get(0).getPrecinctLevel();
        Map<Integer, List<UserData>> map = dataList.stream().collect(Collectors.groupingBy(UserData::getPrecinctLevel));
        if (level == GridLevelFieldEnum.JIEDAO.getGridLevel()) {
            allocationListQuery.setStreetCodeList(map.get(6).stream().map(UserData::getPrecinctCode).collect(Collectors.toList()));
        } else if (level == GridLevelFieldEnum.SHEQU.getGridLevel()) {
            allocationListQuery.setCommunityCodeList(map.get(7).stream().map(UserData::getPrecinctCode).collect(Collectors.toList()));
        }
        allocationListQuery.setStartIndex((allocationListQuery.getPageNo() - 1) * allocationListQuery.getPageSize());
        if(StringUtils.isNotBlank(allocationListQuery.getStepState())){
            allocationListQuery.setStepStateInt(Integer.parseInt(allocationListQuery.getStepState()));
        }
        int total = griderBusinessFlowMapper.selectAllocationCount(allocationListQuery);
        pageRs = new Page<>(allocationListQuery.getPageNo(), allocationListQuery.getPageSize(), total);
        if (total > 0) {
            List<AllocationDto> list = griderBusinessFlowMapper.selectAllocationList(allocationListQuery);
            for (AllocationDto ao : list) {
                if ("1".equals(allocationListQuery.getStepState())) {
                    ao.setFinishTime(null);
                    ao.setFinishUsername(null);
                }
                //查询网格
                LambdaQueryWrapper<AppGeriderGrid> wrapper = new LambdaQueryWrapper<>();
                wrapper.eq(AppGeriderGrid::getGriderId, ao.getGriderId());
                List<AppGeriderGrid> grids = appGeriderGridService.list(wrapper);
                if (!CollectionUtils.isEmpty(grids)) {
                    StringBuffer sb = new StringBuffer("");
                    AppGeriderGrid appGeriderGrid = grids.get(0);
                    String gridCode = appGeriderGrid.getGridCode();
                    if (StringUtils.isNotBlank(gridCode)){
                        for (AppGeriderGrid gd : grids) {
                            sb.append(gd.getGridName());
                            sb.append(";");
                        }
                        String grid = grids.stream().map(AppGeriderGrid::getGridCode).filter(StringUtils::isNotEmpty).distinct().collect(Collectors.joining(";"));
                        String str = sb.toString();

                        ao.setGridCode(grid);
                        ao.setGrid(str.substring(0, str.length() - 1));
                    }else {

                        if (grids.size()>1){

                            if (StringUtils.equals(grids.get(0).getHouseStreetCode(),grids.get(1).getHouseStreetCode())){
                                ao.setStreetCode(grids.get(0).getHouseStreetCode());
                                ao.setStreet(grids.get(0).getHouseStreetName());
                            }else {
                                String collect = grids.stream().map(AppGeriderGrid::getHouseStreetCode).collect(Collectors.joining(","));
                                ao.setStreetCode(collect);
                                String collectName = grids.stream().map(AppGeriderGrid::getHouseStreetName).collect(Collectors.joining(","));
                                ao.setStreet(collectName);

                            }
                        }else {
                            String collect = grids.stream().map(AppGeriderGrid::getHouseStreetCode).collect(Collectors.joining(","));
                            ao.setStreetCode(collect);
                            String collectName = grids.stream().map(AppGeriderGrid::getHouseStreetName).collect(Collectors.joining(","));
                            ao.setStreet(collectName);

                        }


                    }

                }

            }
            pageRs.setRecords(list);
        }
        return pageRs;
    }
 <select id="selectAllocationCount" resultType="int" parameterType="com.sf.gis.common.domain.dto.AllocationListQuery">
        SELECT
        count(1)
        FROM workflow_record wr
        INNER JOIN grider_business_flow gb ON wr.bus_serialno = gb.bus_serialno
        INNER JOIN app_grider ag ON  gb.grider_id = ag.grider_id
        WHERE
        wr.wf_step_name = #{data.stepName}
        <if test="data.approve=='approve'">
         and (wr.wf_step_state=2 or wr.wf_step_state=3)
        </if>
        <if test="data.approve==null or data.approve==''">
         and wr.wf_step_state = #{data.stepStateInt}
        </if>
        <if test="data.flowTypeIds !=null">
            and
            wr.wf_type_id in
            <foreach collection="data.flowTypeIds" index = "index" item = "item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="data.businessNo != null and data.businessNo!=''">
            and  wr.bus_serialno like concat('%', #{data.businessNo},'%')
        </if>
        <if test="data.name != null and data.name!=''">
            and  ag.grider_name like concat('%', #{data.name},'%')
        </if>
        <if test="data.finishStartTime !=null ">
            and  wr.wf_finishtime  <![CDATA[>=]]> #{data.finishStartTime}
        </if>
        <if test="data.finishEndTime !=null ">
            and  wr.wf_finishtime  <![CDATA[<=]]> #{data.finishEndTime}
        </if>
        <if test="data.stepState==1 and data.finishStartTime !=null">
            and 1=2
        </if>
        <if test="data.streetCodeList !=null and data.streetCodeList.size()>0">
            and
            <foreach collection="data.streetCodeList" index = "index" item = "item" open="(" separator="or" close=")">
                ag.street_code like concat('%', #{item},'%')
            </foreach>
        </if>
        <if test="data.communityCodeList !=null  and data.communityCodeList.size()>0">
            and ag.community_code in
            <foreach collection="data.communityCodeList" index = "index" item = "item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="data.griderPositionCodeList != null and data.griderPositionCodeList.size()>0">
            <foreach collection="data.griderPositionCodeList" index="index" item="item" open="and (" separator=" or " close=")">
                ag.grider_position_code like concat('%', #{item},'%')
            </foreach>
        </if>


    </select>

 <select id="selectAllocationList" resultType="com.sf.gis.common.domain.dto.AllocationDto" parameterType="com.sf.gis.common.domain.dto.AllocationListQuery">
        SELECT
        wr.wf_record_id recordId,
        wr.bus_serialno businessNo,
        wr.wf_finish_username finishUsername,
        wr.wf_finishtime finishTime,
        wr.wf_step_id wfStepId,
        wr.wf_step_name wfStepName,
        ag.grider_name name,
        ag.grider_position_type positionType,
        ag.grider_position_code griderPositionCode,
        ag.street_name street,
        ag.community_name community,
        ag.community_code communityCode,
        ag.grider_id griderId,
        wr.wf_step_state wfStepState,
        ag.street_code streetCode
        FROM workflow_record wr
        INNER JOIN grider_business_flow gb ON wr.bus_serialno = gb.bus_serialno
        INNER JOIN app_grider ag ON  gb.grider_id = ag.grider_id
        WHERE
        wr.wf_step_name = #{data.stepName}
        <if test="data.approve=='approve'">
            and (wr.wf_step_state=2 or wr.wf_step_state=3)
        </if>
        <if test="data.approve==null or data.approve==''">
            and wr.wf_step_state = #{data.stepStateInt}
        </if>
        <if test="data.flowTypeIds !=null">
            and
            wr.wf_type_id in
            <foreach collection="data.flowTypeIds" index = "index" item = "item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="data.businessNo != null and data.businessNo!=''">
            and  wr.bus_serialno like concat('%', #{data.businessNo},'%')
        </if>
        <if test="data.id != null and data.id!=''">
            and  ag.grider_id like concat('%', #{data.id},'%')
        </if>
        <if test="data.name != null and data.name!=''">
            and  ag.grider_name like concat('%', #{data.name},'%')
        </if>
        <if test="data.finishStartTime !=null ">
            and  wr.wf_finishtime  <![CDATA[>=]]> #{data.finishStartTime}
        </if>
        <if test="data.finishEndTime !=null ">
            and  wr.wf_finishtime  <![CDATA[<=]]> #{data.finishEndTime}
        </if>
        <if test="data.stepState==1 and data.finishStartTime !=null">
            and 1=2
        </if>
        <if test="data.streetCodeList !=null and data.streetCodeList.size()>0">
            and
            <foreach collection="data.streetCodeList" index = "index" item = "item" open="(" separator="or" close=")">
                ag.street_code like concat('%', #{item},'%')
            </foreach>
        </if>

        <if test="data.communityCodeList !=null  and data.communityCodeList.size()>0">
            and ag.community_code in
            <foreach collection="data.communityCodeList" index = "index" item = "item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="data.griderPositionCodeList != null and data.griderPositionCodeList.size()>0">
            <foreach collection="data.griderPositionCodeList" index="index" item="item" open="and (" separator=" or " close=")">
                ag.grider_position_code like concat('%', #{item},'%')
            </foreach>
        </if>

        order by wr.wf_finishtime desc
        LIMIT #{data.pageSize} OFFSET #{data.startIndex}
    </select>

7 查询流程显示列表
@Override
    public List<WorkflowRecordVo> getWorkflowRecordList(GriderChangeQuery griderChangeQuery) {
        if (griderChangeQuery == null || griderChangeQuery.getBusinessNo() == null) {
            throw new BusinessException("必须传入查询流水号");
        }
        List<WorkflowRecord> workflowRecordList = workflowRecordService.getWorkflowRecordList(griderChangeQuery);

        if (CollectionUtils.isEmpty(workflowRecordList)) {
            throw new BusinessException("流程为空!");
        }
        List<WorkflowRecordVo> workflowRecordVosList = new ArrayList<>();
        for(WorkflowRecord wd:workflowRecordList ){
            WorkflowRecordVo wv=new WorkflowRecordVo();
            BeanUtils.copyProperties(wd,wv);
            workflowRecordVosList.add(wv);
        }
        if (workflowRecordVosList == null) {
            throw new BusinessException("workflowRecordVosList 详细步骤对象为空 ");
        }
//            String businessNo = griderChangeQuery.getBusinessNo();
//        WorkflowInfo workflowInfoByWfSerialno = workflowInfoService.getWorkflowInfoByBfSerialno(businessNo);
        for(WorkflowRecordVo wo: workflowRecordVosList){
            if (StringUtils.isNotBlank(wo.getWfRecordId())) {
                LambdaQueryWrapper<WorkflowApproveOpinion> wr = new LambdaQueryWrapper<>();
                wr.eq(WorkflowApproveOpinion::getWfRecordId, wo.getWfRecordId()).orderByAsc(WorkflowApproveOpinion::getWfOpnionSort).last("limit 1");
                WorkflowApproveOpinion wop = workflowApproveOpinionService.getOne(wr);
                if (wop != null) {
                    wo.setOpnion(wop.getWfOpinion());
                    wo.setOpnionApproveState(wop.getWfApproveState() == 0 ? "不通过" : "通过");
                }
            }
      /*      if (EntryStepEnum.APPLY.getValue().equals(wo.getWfStepName())) {
                //只有第一步时候取info表申请人
                wo.setWfApplicantName(workflowInfoByWfSerialno.getWfApplicantName());//申请人名称
            } else {*/
            if((wo.getWfTypeId().equals(griderChangeId) || wo.getWfTypeId().equals(transferPositionId))
                    && (wo.getWfStepId().equals("20") || wo.getWfStepId().equals("21") || wo.getWfStepId().equals("24") || wo.getWfStepId().equals("25"))){
                wo.setWfApplicantName("系统");
                wo.setWfFinishDeptname(null);
            }else{
                wo.setWfApplicantName(wo.getWfFinishUsername());//完成人
            }
            /*  }*/
            if (wo.getWfStepState() != null) {
                if (wo.getWfStepState() == 1) {
                    wo.setWfStepStateName("在办");
                    wo.setWfFinishtime(null);
                    wo.setWfFinishUsername("");
                    wo.setWfFinishDeptname("");
                    wo.setWfApplicantName("");
                    wo.setWfFinishDept("");
                }
                if (wo.getWfStepState() == 2) {
                    wo.setWfStepStateName("通过");
                }
                if (wo.getWfStepState() == 3) {
                    wo.setWfStepStateName("驳回");
                    if ("3".equals(griderChangeQuery.getOperationTypeflag())) {
                        wo.setWfStepStateName("不通过");
                    }
                }
            }
        }
        String id="";
        if (StringUtils.isBlank(griderChangeQuery.getOperationTypeflag())){
            id=workflowTypeId;
        }else if (StringUtils.equals("2",griderChangeQuery.getOperationTypeflag())){
            id = workflowTypeDepartId;
            String businessNo1 = griderChangeQuery.getBusinessNo();
            AppGriderQuery appGriderQuery = new AppGriderQuery();
            appGriderQuery.setBusSerialno(businessNo1);
            GriderBusinessFlow busSerialnoByGriderBusinessFlow = griderBusinessFlowService.getBusSerialnoByGriderBusinessFlow(appGriderQuery);
            if (busSerialnoByGriderBusinessFlow != null) {
                AppGriderQuery appGriderQuery1 = new AppGriderQuery();
                appGriderQuery1.setGriderId(busSerialnoByGriderBusinessFlow.getGriderId());
                AppGrider griderIdByAppGrider = appGriderService.getGriderIdByAppGrider(appGriderQuery1);
                workflowRecordVosList.forEach(info -> {
                    info.setGoodsAndMaterials(griderIdByAppGrider.getGoodsAndMaterials()); //1是 2否
                    info.setGoodsAndMaterialsRemark(griderIdByAppGrider.getGoodsAndMaterialsRemark());//物资备注
                });
            }
        } else if (StringUtils.equals("3",griderChangeQuery.getOperationTypeflag())) {
            id=griderChangeId;
        } else if(StringUtils.equals("4",griderChangeQuery.getOperationTypeflag())){
            id=transferPositionId;
        }
        List<WorkflowStep> step = workflowStepService.getStep(id);

        if (CollUtil.isEmpty(step)) {
            throw new BusinessException("WorkflowStepList 详细步骤对象为空 ");
        }
        boolean aflag=false;
        boolean bflag=false;
        for(WorkflowRecordVo wrc:workflowRecordVosList){
            //
            if(1==wrc.getWfStepState()){
                aflag=true;
                break;
            }

        }
        for(WorkflowRecordVo wrc:workflowRecordVosList){
            if(EntryStepEnum.END.getValue().equals(wrc.getWfStepName())){
                bflag=true;
                break;
            }
        }
        if(aflag && bflag){
            List<WorkflowRecordVo> wo = new ArrayList<>();
            for(WorkflowRecordVo wrc:workflowRecordVosList){
                if(wrc.getWfStepState()!=1){
                    wo.add(wrc);
                }
            }
            return wo;
        }
        //查询最后一个节点
        WorkflowRecordVo we=workflowRecordVosList.get(workflowRecordVosList.size()-1);
        LambdaQueryWrapper<WorkflowStep> wr = new LambdaQueryWrapper<>();
        wr.eq(WorkflowStep::getWfStepId, we.getWfStepId());
        WorkflowStep st = workflowStepService.getOne(wr);
        if("end".equals(st.getWfStepType())){
            return workflowRecordVosList;
        }else{
            List<WorkflowRecordVo> workflowRecordVos = new ArrayList<>();
            wr = new LambdaQueryWrapper<>();
            wr.eq(WorkflowStep::getWfTypeId, id).gt(WorkflowStep::getWfStepSort,st.getWfStepSort()).orderByAsc(WorkflowStep::getWfStepSort);
            List<WorkflowStep> alist = workflowStepService.list(wr);
            if(CollectionUtils.isEmpty(alist)){
                return workflowRecordVosList;
            }else{
                LambdaQueryWrapper<WorkflowStepRelation> lw = new LambdaQueryWrapper<>();
                lw.eq(WorkflowStepRelation::getWfStepId,st.getWfStepId()).last("limit 1");
                WorkflowStepRelation wwr=  workflowStepRelationService.getOne(lw);
                for(WorkflowStep ste:alist){
                    lw = new LambdaQueryWrapper<>();
                    lw.eq(WorkflowStepRelation::getWfStepId,ste.getWfStepId()).last("limit 1");
                    WorkflowStepRelation wwrr=  workflowStepRelationService.getOne(lw);
                    if("end".equals(ste.getWfStepType())){
                        WorkflowRecordVo wv2=new WorkflowRecordVo();
                        wv2.setWfStepName(ste.getWfStepName());
                        wv2.setWfStepId(ste.getWfStepId());
                        workflowRecordVosList.add(wv2);
                        break;
                    }
                    if (wwrr!=null){
                        if(!wwrr.getWfNextstepId().equals(wwr.getWfNextstepId())){
                            WorkflowRecordVo wv2=new WorkflowRecordVo();
                            wv2.setWfStepName(ste.getWfStepName());
                            wv2.setWfStepId(ste.getWfStepId());
                            workflowRecordVosList.add(wv2);
                        }
                    }

                }
            }
     /*       //离职发起人重新组装
            if (StringUtils.equals("2",griderChangeQuery.getOperationTypeflag())){
                if(!CollectionUtils.isEmpty(workflowRecordVosList)){
                    workflowRecordVosList.forEach(info->{
                         String wfRecordId =info.getWfRecordId();
                         WorkflowRecord workflowRecord = workflowRecordService.getWorkflowRecord(wfRecordId);
                         if (workflowRecord!=null){
                             info.setWfApplicantName(workflowRecord.getWfFinishUsername());
                         }
                    });
                }
            }*/

        }
        return workflowRecordVosList;
    }
  public List<WorkflowRecord> getWorkflowRecordList(GriderChangeQuery griderChangeQuery) {
        List<WorkflowRecord> list=new ArrayList<>();
        list=workflowRecordMapper.selectWorkflowRecordCountByTime(griderChangeQuery.getBusinessNo());
        List<WorkflowRecord> list2=new ArrayList<>();
        list2=workflowRecordMapper.selectWorkflowRecordCountByTime2(griderChangeQuery.getBusinessNo());
        list.addAll(list2);
        return list;
    }
  <select id="selectWorkflowRecordCountByTime" parameterType="string" resultMap="BaseResultMap">
       select <include refid="Base_Column_List"/>
        from workflow_record
        where bus_serialno=#{buSerialno} and (wf_step_state=2 or wf_step_state=3) order by update_time

    </select>
  <select id="selectWorkflowRecordCountByTime2" parameterType="string" resultMap="BaseResultMap">
        select <include refid="Base_Column_List"/>
        from workflow_record where bus_serialno=#{buSerialno} and wf_step_state=1 order by update_time
    </select>

    @Override
    public GriderBusinessFlow getBusSerialnoByGriderBusinessFlow(AppGriderQuery appGriderQuery) {
        LambdaQueryWrapper<GriderBusinessFlow> query = Wrappers.lambdaQuery();
        query.eq(GriderBusinessFlow::getBusSerialno, appGriderQuery.getBusSerialno());
        GriderBusinessFlow griderBusinessFlow = this.baseMapper.selectOne(query);
        if (griderBusinessFlow == null) {
            return null;
        }
        return griderBusinessFlow;
    }

-- public.grider_business_flow definition

-- Drop table

-- DROP TABLE public.grider_business_flow;

CREATE TABLE public.grider_business_flow (
    business_id varchar(32) NOT NULL,
    grider_id varchar(32) NULL,
    start_time timestamp(6) NULL,
    end_time timestamp(6) NULL,
    update_time timestamp(6) NULL,
    create_time timestamp(6) NULL,
    create_by varchar(32) NULL,
    update_by varchar(32) NULL,
    bus_serialno varchar(32) NULL,
    last_commit_time timestamp(6) NULL,
    updater_id varchar(32) NULL,
    creator_id varchar(32) NULL,
    is_initiate_study int2 NULL,
    rejection_time timestamp(6) NULL,
    modify_grid_reason varchar(600) NULL,
    work_status int2 NULL,
    remark varchar(512) NULL
);

-- Drop table

-- DROP TABLE public.workflow_approve_opinion;

CREATE TABLE public.workflow_approve_opinion (
    wf_ao_id varchar(32) NOT NULL,
    wf_id varchar(32) NULL,
    wf_record_id varchar(32) NULL,
    wf_opinion_time timestamp(6) NULL,
    wf_opinion varchar(1024) NULL,
    wf_approve_userid varchar(32) NULL,
    wf_approve_username varchar(64) NULL,
    wf_opnion_sort int4 NULL,
    wf_approve_state int4 NULL,
    CONSTRAINT workflow_approve_opinion_pk PRIMARY KEY (wf_ao_id)
);
CREATE INDEX idx_opinion_wf_record_id ON public.workflow_approve_opinion USING btree (wf_record_id);
CREATE UNIQUE INDEX pk_workflow_approve_opinion ON public.workflow_approve_opinion USING btree (wf_ao_id);
-- public.workflow_approve_user definition

-- Drop table

-- DROP TABLE public.workflow_approve_user;

CREATE TABLE public.workflow_approve_user (
    wf_approveuser_id varchar(32) NOT NULL,
    wf_step_id varchar(32) NULL,
    user_id varchar(64) NULL,
    user_name varchar(64) NULL,
    approve_type int4 NULL,
    roles varchar(32) NULL,
    wf_type_id varchar(64) NULL,
    CONSTRAINT workflow_approve_user_pk PRIMARY KEY (wf_approveuser_id)
);
CREATE INDEX "WORKFLOW_APPROVE_USER_WF_STEP_ID_IDX" ON public.workflow_approve_user USING btree (wf_step_id);
CREATE UNIQUE INDEX pk_workflow_approve_user ON public.workflow_approve_user USING btree (wf_approveuser_id);

-- public.workflow_file definition

-- Drop table

-- DROP TABLE public.workflow_file;

CREATE TABLE public.workflow_file (
    wf_file_id varchar(32) NOT NULL,
    wf_record_id varchar(32) NULL,
    wf_ao_id varchar(32) NULL,
    wf_file_path varchar(256) NULL,
    wf_file_name varchar(128) NULL,
    wf_file_sort int4 NULL,
    CONSTRAINT workflow_file_pk PRIMARY KEY (wf_file_id)
);
CREATE UNIQUE INDEX p

-- public.workflow_info definition

-- Drop table

-- DROP TABLE public.workflow_info;

CREATE TABLE public.workflow_info (
    wf_id varchar(32) NOT NULL,
    wf_name varchar(128) NULL,
    wf_type_id varchar(32) NULL,
    wf_serialno varchar(128) NULL,
    wf_step_ids varchar(2048) NULL,
    create_time timestamp(6) NULL,
    update_time timestamp(6) NULL,
    bus_serialno varchar(64) NULL,
    wf_end_time timestamp(6) NULL,
    wf_applicant_name varchar(32) NULL,
    wf_applicant_id varchar(32) NULL,
    current_step_id varchar(8) NULL,
    deleted int4 NULL,
    CONSTRAINT workflow_info_pk PRIMARY KEY (wf_id)
);
CREATE INDEX "WORKFLOW_INFO_WF_SERIALNO_IDX" ON public.workflow_info USING btree (wf_serialno);
CREATE INDEX idx_info_wf_type_id ON public.workflow_info USING btree (wf_type_id);
CREATE UNIQUE INDEX pk_workflow_info ON public.workflow_info USING btree (wf_id);
CREATE INDEX workflow_info_bus_serialno_idx ON public.workflow_info USING btree (bus_serialno);

-- public.workflow_record definition

-- Drop table

-- DROP TABLE public.workflow_record;

CREATE TABLE public.workflow_record (
    wf_record_id varchar(32) NOT NULL,
    wf_id varchar(32) NULL,
    wf_name varchar(128) NULL,
    wf_type_id varchar(32) NULL,
    wf_serialno varchar(128) NULL,
    wf_step_id varchar(32) NULL,
    wf_step_name varchar(32) NULL,
    wf_finish_userid varchar(32) NULL,
    wf_finish_username varchar(32) NULL,
    wf_starttime timestamp(6) NULL,
    wf_finishtime timestamp(6) NULL,
    wf_step_state int4 NULL,
    wf_overtime numeric NULL,
    create_time timestamp(6) NULL,
    update_time timestamp(6) NULL,
    wf_finish_dept varchar(64) NULL,
    wf_finish_deptname varchar(64) NULL,
    bus_serialno varchar(32) NULL,
    CONSTRAINT workflow_record_pk PRIMARY KEY (wf_record_id)
);
CREATE INDEX "WORKFLOW_RECORD_WF_ID_IDX" ON public.workflow_record USING btree (wf_id);
CREATE INDEX "WORKFLOW_RECORD_WF_TYPE_ID_IDX" ON public.workflow_record USING btree (wf_type_id);
CREATE INDEX idx_record_bus_serialno ON public.workflow_record USING btree (bus_serialno);
CREATE INDEX idx_record_wf_serialno ON public.workflow_record USING btree (wf_serialno);
CREATE INDEX idx_record_wf_step_name ON public.workflow_record USING btree (wf_step_name);
CREATE UNIQUE INDEX pk_workflow_record ON public.workflow_record USING btree (wf_record_id);


-- public.workflow_step definition

-- Drop table

-- DROP TABLE public.workflow_step;

CREATE TABLE public.workflow_step (
    wf_step_id varchar(32) NOT NULL,
    wf_type_id varchar(32) NULL,
    wf_step_name varchar(64) NULL,
    wf_step_sort int4 NULL,
    wf_step_type varchar(64) NULL,
    wf_step_loc varchar(64) NULL,
    wf_step_color varchar(32) NULL,
    wf_step_duetype int4 NULL,
    wf_step_edit int4 NULL,
    wf_step_hour int4 NULL,
    CONSTRAINT workflow_step_pk PRIMARY KEY (wf_step_id)
);
CREATE INDEX "WORKFLOW_STEP_WF_TYPE_ID_IDX" ON public.workflow_step USING btree (wf_type_id);
CREATE UNIQUE INDEX pk_workflow_step ON public.workflow_step USING btree (wf_step_id);

-- public.workflow_step_relation definition

-- Drop table

-- DROP TABLE public.workflow_step_relation;

CREATE TABLE public.workflow_step_relation (
    wf_step_relation_id varchar(32) NOT NULL,
    wf_step_id varchar(32) NULL,
    wf_nextstep_id varchar(32) NULL,
    wf_type_id varchar(32) NULL,
    link_text varchar(64) NULL,
    from_point varchar(8) NULL,
    to_point varchar(8) NULL,
    points varchar(256) NULL,
    visible int4 NULL,
    CONSTRAINT workflow_step_relation_pk PRIMARY KEY (wf_step_relation_id)
);
CREATE INDEX "WORKFLOW_STEP_RELATION_WF_STEP_ID_IDX" ON public.workflow_step_relation USING btree (wf_step_id);
CREATE INDEX "WORKFLOW_STEP_RELATION_WF_TYPE_ID_IDX" ON public.workflow_step_relation USING btree (wf_type_id);
CREATE UNIQUE INDEX pk_workflow_step_relation ON public.workflow_step_relation USING btree (wf_step_relation_id);


-- public.workflow_type definition

-- Drop table

-- DROP TABLE public.workflow_type;

CREATE TABLE public.workflow_type (
    wf_type_id varchar(32) NOT NULL,
    wf_type_name varchar(128) NULL,
    wf_type_desc varchar(512) NULL,
    wf_type_sort int4 NULL,
    wf_type_use int4 NULL,
    CONSTRAINT workflow_type_pk PRIMARY KEY (wf_type_id)
);
CREATE UNIQUE INDEX pk_workflow_type ON public.workflow_type USING btree (wf_type_id);


INSERT INTO public.workflow_type
(wf_type_id, wf_type_name, wf_type_desc, wf_type_sort, wf_type_use)
VALUES('17FD1D8F324E11B28B2F6849C41BFF6A', '入职', '网格员入职申请流程', 1, 1);
INSERT INTO public.workflow_type
(wf_type_id, wf_type_name, wf_type_desc, wf_type_sort, wf_type_use)
VALUES('8E19BA1E7C5EB2116D915A91FFCDF55F', '任务', '网格员任务流转', 2, 1);
INSERT INTO public.workflow_type
(wf_type_id, wf_type_name, wf_type_desc, wf_type_sort, wf_type_use)
VALUES('8E19BA1E7C5EB2116D915A91FFCDF55G', '离职', '网格员离职申请流程', 3, 1);
INSERT INTO public.workflow_type
(wf_type_id, wf_type_name, wf_type_desc, wf_type_sort, wf_type_use)
VALUES('17FD1D8F324E11B28B2F6849C41BFF7T', '替岗', '网格员离职申请流程', 5, 1);
INSERT INTO public.workflow_type
(wf_type_id, wf_type_name, wf_type_desc, wf_type_sort, wf_type_use)
VALUES('17FD1D8F324E11B28B2F6849C41BFF7H', '换格', '网格员换格申请流程', 6, 1);
INSERT INTO public.workflow_type
(wf_type_id, wf_type_name, wf_type_desc, wf_type_sort, wf_type_use)
VALUES('8E19BA1E7C5EB2116D915A91FFCDF55R', '调岗', '网格员调岗申请流程', 4, 1);    

INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('8', '8E19BA1E7C5EB2116D915A91FFCDF55F', '签收', 1, 'start', NULL, NULL, NULL, 0, NULL);
INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('9', '8E19BA1E7C5EB2116D915A91FFCDF55F', '退回', 2, 'Conditional', NULL, NULL, NULL, 0, NULL);
INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('10', '8E19BA1E7C5EB2116D915A91FFCDF55F', '提交', 3, 'step', NULL, NULL, NULL, 0, NULL);
INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('11', '8E19BA1E7C5EB2116D915A91FFCDF55F', '归档', 4, 'end', NULL, NULL, NULL, 0, NULL);
INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('1', '17FD1D8F324E11B28B2F6849C41BFF6A', '发起申请', 1, 'start', NULL, NULL, NULL, 0, NULL);
INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('2', '17FD1D8F324E11B28B2F6849C41BFF6A', '资格审批', 2, 'Conditional', NULL, NULL, NULL, 0, NULL);
INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('3', '17FD1D8F324E11B28B2F6849C41BFF6A', '政务微信账号开通', 3, 'step', NULL, NULL, NULL, 0, NULL);
INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('4', '17FD1D8F324E11B28B2F6849C41BFF6A', '入格分配', 4, 'step', NULL, NULL, NULL, 0, NULL);
INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('5', '17FD1D8F324E11B28B2F6849C41BFF6A', '物资分配', 5, 'step', NULL, NULL, NULL, 0, NULL);
INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('6', '17FD1D8F324E11B28B2F6849C41BFF6A', '入职培训', 6, 'Conditional', NULL, NULL, NULL, 0, NULL);
INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('12', '8E19BA1E7C5EB2116D915A91FFCDF55G', '发起申请', 1, 'start', NULL, NULL, NULL, 0, NULL);
INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('13', '8E19BA1E7C5EB2116D915A91FFCDF55G', '离职审批', 2, 'Conditional', NULL, NULL, NULL, 0, NULL);
INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('14', '8E19BA1E7C5EB2116D915A91FFCDF55G', '物资回收', 3, 'step', NULL, NULL, NULL, 0, NULL);
INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('15', '8E19BA1E7C5EB2116D915A91FFCDF55G', '账号注销', 4, 'step', NULL, NULL, NULL, 0, NULL);
INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('16', '8E19BA1E7C5EB2116D915A91FFCDF55G', '流程归档', 5, 'step', NULL, NULL, NULL, 0, NULL);
INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('18', '17FD1D8F324E11B28B2F6849C41BFF7H', '换格申请', 1, 'start', NULL, NULL, NULL, 0, NULL);
INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('19', '17FD1D8F324E11B28B2F6849C41BFF7H', '换格审批', 2, 'Conditional', NULL, NULL, NULL, 0, NULL);
INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('20', '17FD1D8F324E11B28B2F6849C41BFF7H', '更新网格员花名册', 3, 'step', NULL, NULL, NULL, 0, NULL);
INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('21', '17FD1D8F324E11B28B2F6849C41BFF7H', '流程归档', 4, 'end', NULL, NULL, NULL, 0, NULL);
INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('22', '8E19BA1E7C5EB2116D915A91FFCDF55R', '调岗申请', 1, 'start', NULL, NULL, NULL, 0, NULL);
INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('23', '8E19BA1E7C5EB2116D915A91FFCDF55R', '调岗审批', 2, 'Conditional', NULL, NULL, NULL, 0, NULL);
INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('24', '8E19BA1E7C5EB2116D915A91FFCDF55R', '更新网格员花名册', 3, 'step', NULL, NULL, NULL, 0, NULL);
INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('25', '8E19BA1E7C5EB2116D915A91FFCDF55R', '流程归档', 4, 'end', NULL, NULL, NULL, 0, NULL);
INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('7', '17FD1D8F324E11B28B2F6849C41BFF6A', '信息完善', 7, 'step', NULL, NULL, NULL, 0, NULL);
INSERT INTO public.workflow_step
(wf_step_id, wf_type_id, wf_step_name, wf_step_sort, wf_step_type, wf_step_loc, wf_step_color, wf_step_duetype, wf_step_edit, wf_step_hour)
VALUES('26', '17FD1D8F324E11B28B2F6849C41BFF6A', '流程归档', 26, 'end', NULL, NULL, NULL, 0, NULL);

INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('10', '8', '9', '8E19BA1E7C5EB2116D915A91FFCDF55F', NULL, NULL, NULL, NULL, 0);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('11', '9', '8', '8E19BA1E7C5EB2116D915A91FFCDF55F', '退回', NULL, NULL, NULL, 0);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('12', '9', '10', '8E19BA1E7C5EB2116D915A91FFCDF55F', '不退回', NULL, NULL, NULL, 1);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('13', '10', '11', '8E19BA1E7C5EB2116D915A91FFCDF55F', NULL, NULL, NULL, NULL, 1);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('1', '1', '2', '17FD1D8F324E11B28B2F6849C41BFF6A', NULL, NULL, NULL, NULL, 0);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('2', '2', '3', '17FD1D8F324E11B28B2F6849C41BFF6A', '通过', NULL, NULL, NULL, 1);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('3', '2', '4', '17FD1D8F324E11B28B2F6849C41BFF6A', '通过', NULL, NULL, NULL, 1);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('4', '2', '5', '17FD1D8F324E11B28B2F6849C41BFF6A', '通过', NULL, NULL, NULL, 1);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('5', '2', '1', '17FD1D8F324E11B28B2F6849C41BFF6A', '不通过', NULL, NULL, NULL, 1);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('6', '3', '6', '17FD1D8F324E11B28B2F6849C41BFF6A', NULL, NULL, NULL, NULL, 0);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('7', '4', '6', '17FD1D8F324E11B28B2F6849C41BFF6A', NULL, NULL, NULL, NULL, 0);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('8', '5', '6', '17FD1D8F324E11B28B2F6849C41BFF6A', NULL, NULL, NULL, NULL, 0);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('9', '6', '7', '17FD1D8F324E11B28B2F6849C41BFF6A', '通过', NULL, NULL, NULL, 1);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('15', '12', '13', '8E19BA1E7C5EB2116D915A91FFCDF55G', NULL, NULL, NULL, NULL, 0);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('16', '13', '14', '8E19BA1E7C5EB2116D915A91FFCDF55G', '通过', NULL, NULL, NULL, 1);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('17', '13', '15', '8E19BA1E7C5EB2116D915A91FFCDF55G', '通过', NULL, NULL, NULL, 1);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('18', '13', '12', '8E19BA1E7C5EB2116D915A91FFCDF55G', '不通过', NULL, NULL, NULL, 1);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('19', '14', '16', '8E19BA1E7C5EB2116D915A91FFCDF55G', NULL, NULL, NULL, NULL, 0);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('20', '15', '16', '8E19BA1E7C5EB2116D915A91FFCDF55G', NULL, NULL, NULL, NULL, 0);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('21', '18', '19', '17FD1D8F324E11B28B2F6849C41BFF7H', '', NULL, NULL, NULL, 0);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('22', '19', '20', '17FD1D8F324E11B28B2F6849C41BFF7H', '通过', NULL, NULL, NULL, 0);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('23', '19', '21', '17FD1D8F324E11B28B2F6849C41BFF7H', '不通过', NULL, NULL, NULL, 0);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('24', '20', '21', '17FD1D8F324E11B28B2F6849C41BFF7H', NULL, NULL, NULL, NULL, 0);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('25', '22', '23', '8E19BA1E7C5EB2116D915A91FFCDF55R', NULL, NULL, NULL, NULL, 0);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('26', '23', '24', '8E19BA1E7C5EB2116D915A91FFCDF55R', '通过', NULL, NULL, NULL, 0);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('27', '23', '25', '8E19BA1E7C5EB2116D915A91FFCDF55R', '不通过', NULL, NULL, NULL, 0);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('28', '24', '25', '8E19BA1E7C5EB2116D915A91FFCDF55R', NULL, NULL, NULL, NULL, 0);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('14', '6', '26', '17FD1D8F324E11B28B2F6849C41BFF6A', '不通过', NULL, NULL, NULL, 1);
INSERT INTO public.workflow_step_relation
(wf_step_relation_id, wf_step_id, wf_nextstep_id, wf_type_id, link_text, from_point, to_point, points, visible)
VALUES('99', '7', '26', '17FD1D8F324E11B28B2F6849C41BFF6A', NULL, NULL, NULL, NULL, 0);

INSERT INTO public.workflow_approve_user
(wf_approveuser_id, wf_step_id, user_id, user_name, approve_type, roles, wf_type_id)
VALUES('2', '2', NULL, NULL, 1, 'districtTeamBuild', '17FD1D8F324E11B28B2F6849C41BFF6A');
INSERT INTO public.workflow_approve_user
(wf_approveuser_id, wf_step_id, user_id, user_name, approve_type, roles, wf_type_id)
VALUES('3', '4', NULL, NULL, 1, 'streetTeamBuild', '17FD1D8F324E11B28B2F6849C41BFF6A');
INSERT INTO public.workflow_approve_user
(wf_approveuser_id, wf_step_id, user_id, user_name, approve_type, roles, wf_type_id)
VALUES('4', '5', NULL, NULL, 1, 'streetTeamBuild', '17FD1D8F324E11B28B2F6849C41BFF6A');
INSERT INTO public.workflow_approve_user
(wf_approveuser_id, wf_step_id, user_id, user_name, approve_type, roles, wf_type_id)
VALUES('5', '13', NULL, NULL, 1, 'streetTeamBuild', '8E19BA1E7C5EB2116D915A91FFCDF55G');
INSERT INTO public.workflow_approve_user
(wf_approveuser_id, wf_step_id, user_id, user_name, approve_type, roles, wf_type_id)
VALUES('6', '12', NULL, NULL, 1, 'communityTeamBuild', '8E19BA1E7C5EB2116D915A91FFCDF55G');
INSERT INTO public.workflow_approve_user
(wf_approveuser_id, wf_step_id, user_id, user_name, approve_type, roles, wf_type_id)
VALUES('7', '18', NULL, NULL, 1, 'communityTeamBuild', '17FD1D8F324E11B28B2F6849C41BFF7H');
INSERT INTO public.workflow_approve_user
(wf_approveuser_id, wf_step_id, user_id, user_name, approve_type, roles, wf_type_id)
VALUES('8', '18', NULL, NULL, 1, 'streetTeamBuild', '17FD1D8F324E11B28B2F6849C41BFF7H');
INSERT INTO public.workflow_approve_user
(wf_approveuser_id, wf_step_id, user_id, user_name, approve_type, roles, wf_type_id)
VALUES('9', '19', NULL, NULL, 1, 'streetTeamBuild', '17FD1D8F324E11B28B2F6849C41BFF7H');
 

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值