WZ Internal--Process Node Configuration

1. Configuration flow chart

 1Log in to the system

  1. Log in to the system, select the menu User Organization Permissions---Model Management ---》Add Model

 2. Configuration process

Configure user role managers, etc. on user tasks

Configure process conditions in the review process process arrow configuration

Configure a mutually exclusive gateway at the point of approval and rejection

2. Configure database data

The process configuration finds the table pm_s_flowinfo. After the process is added to the system, the table will automatically add a piece of data but only has the primary key id. You need to configure the table information yourself.

WF_NODE_FIELD: Business table where the process is to be carried out. Process node record field

PROCESS_FIELD: Business table where the process is to be carried out. Process instance record field

BUSINESS_KEY_FIELD: The business table to be processed. The primary key name generally has no ID.

BUSINESS_TABLE_NAME: Business table name of the business table to be processed

AUDIT_FLAG: Audit type identifier, generally consistent with the business surface (audit type identifier, used in use_object of table pm_base_audit)

FLOW_CODE: unified code, the unique code of the process cannot be repeated

CUS_NODE_FIELD: The custom node ID is currently written as cus_node_id.

3. Write process code

 3.1 Process startup code

 public PmXxhProjectPreEvaluation insert(PmXxhProjectPreEvaluation pmXxhProjectPreEvaluation, LoginUser user) {
        pmXxhProjectPreEvaluation.setId(UUID.randomUUID().toString());
        pmXxhProjectPreEvaluation.setStatus("1");
        pmXxhProjectPreEvaluation.setIsDelete("0");
        pmXxhProjectPreEvaluation.setCreateDepId(user.getOrgCode());
        pmXxhProjectPreEvaluation.setCreateUser(user.getUserId());
        pmXxhProjectPreEvaluation.setCreateTime(new Date());
        pmXxhProjectPreEvaluation.setUpdateUser(user.getUserId());
        pmXxhProjectPreEvaluation.setUpdateTime(pmXxhProjectPreEvaluation.getCreateTime());
        pmXxhProjectPreEvaluation.setMofDivCode(user.getMofDivCode());
        pmXxhProjectPreEvaluation.setFiscalYear(user.getFiscalYear());
        pmXxhProjectPreEvaluationDao.insert(pmXxhProjectPreEvaluation);
        Map<String, Object> params = 
        ConvertBeanUtils.transBean2Map(pmXxhProjectPreEvaluation);
       
        //上面新增数据把实体转成Map
        //流程启动代码                  project-pre-evaluation-workflow流程唯一Code
        prjFlowFactory.getFlowOperator("project-pre-evaluation-workflow")
                .startFlow(pmXxhProjectPreEvaluation.getId(), user.getUserId(), params);
        return pmXxhProjectPreEvaluation;
    }

3.2 Self-rewritten process reporting and approval interfaces

public Object batchReport(EscalationVo escalationVo, LoginUser user) {
        if (escalationVo.getIds().isEmpty() || StringUtils.isEmpty(escalationVo.getFlowKey())) {
            return null;
        }
        Map<String, String> flowInfo = auditsDao.selectFlow(escalationVo.getFlowKey());
        if (flowInfo == null || StringUtils.isEmpty(flowInfo.get("BUSINESS_TABLE_NAME"))) {
            return null;
        }
        List<String> ids = escalationVo.getIds();
        if (ids != null && !ids.isEmpty()) {
            ids.forEach(id -> {
                Map<String, Object> params = auditsDao.selectEntity(id, flowInfo.get("BUSINESS_TABLE_NAME"), flowInfo.get("BUSINESS_KEY_FIELD"));
                if (params != null) {
                    params.put("prjId", id);
                    params.put("taskId", id);
                    params.put("auditResult", 1);
                    String useObject = escalationVo.getFlowKey();
                    if (escalationVo.getAuditStatus() != null) {
                        params.put("status", escalationVo.getAuditStatus());
                    }

                    FlowStatus status = prjFlowFactory.getFlowOperator(useObject).commit(id, user.getUserId(), params);
                    PmBaseAuditWithBLOBs auditRecord = new PmBaseAuditWithBLOBs();
                    auditRecord.setJobId(id);
                    auditRecord.setPrjId(id);
                    auditRecord.setUseObject(useObject);
                    auditRecord.setAuditType(1);
                    auditRecord.setAuditResultCode("0");
                    auditRecord.setAuditResult(escalationVo.getAuditStatusContent());
                    auditRecord.setImproveContent("----");
                    auditRecord.setConclusionName(escalationVo.getAuditStatusContent());
                    this.pmBaseAuditService.auditHandle(auditRecord, params, status.getProcessInstanceId(), user, false);

                    try {
                        auditsDao.updateStatus(id,flowInfo.get("BUSINESS_TABLE_NAME"), escalationVo.getAuditStatus(), flowInfo.get("BUSINESS_KEY_FIELD"));
                    } catch (Exception E) {
                        E.printStackTrace();
                    }
                }
            });

        }
        return null;
    }

 Entity type

package com.wenzheng.xxh.audit.vo;

import lombok.Data;

import java.util.List;
import java.util.Map;

/**
 * @Author ZRP
 * @Date 2023/12/8 9:31
 */
@Data
public class EscalationVo {

    /**
     * 走流程业务表-->主键id 集合
     */
    private List<String> ids;

    /**
     * 流程key
     * 例:project-pre-evaluation-workflow流程唯一Code
     */
    private String flowKey;

    /**
     * 审核状态 目前自定义 根据自己的业务来
     * 状态 1: 未上报 2:部门审核中 3:部门审核退回 4:部门审核通过 5:待整改(部门发起)
     * 6:业务科室审核退回 7:业务科室审核通过 8:待整改(业务科室发起)
     * 9:绩效中心审核退回 10:绩效中心审核通过
     */
    private Integer auditStatus;

    /**
     * 审核状态内容-->用于做审批记录存放用
     * 上报成功  主管通过  主管驳回  财政通过 财政驳回 等
     */
    private String auditStatusContent;
}

3.3 Interface calling API

address http://10.30.4.96:8412/audits/batchReport
Request header

Content-Type:application/json

Wz-Token:token

Passing on parameters

{

    "auditStatus": 10,

    "auditStatusContent": "Finance passed",

    "flowKey": "project-construction-workflow-test",

    "ids": ["02c4951c-bbdf-48b3-b913-794c4ab2e9bf"]

}

Guess you like

Origin blog.csdn.net/qq_38092788/article/details/134810407