泛微E9二开>通过Java代码创建流程

返回值释义
0创建流程成功,返回请求id
-1创建流程失败
-2用户没有流程创建权限
-3创建流程基本信息失败
-4保存表单主表信息失败
-5更新紧急程度失败
-6流程操作者失败
-7流转至下一节点失败
-8节点附加操作失败
/**
     * @param workflowId  发起的流程id
     * @param creator     流程发起人
     * @param title       系统流程标题 request name
     * @param isNext      是否直接流转至下一个节点
     * @param mainInfo    主表数据
     * @param detailInfos 明细表数据, 数组下标与明细表orderid对应, 从1开始,
     *                    任何元素可以为null, 下标为0的元素应该永远为空
     * @return requestId
     * @throws Exception 创建流程时可能出现的各种问题?
     * @since 1.1.4
     */
    public static int createWorkflow(int workflowId,
                                     int creator,
                                     String title,
                                     boolean isNext,
                                     Map<String, String> mainInfo,
                                     List<Map<String, String>>[] detailInfos) throws Exception {
        if (title == null) {
            String pathName = getWorkflowPathName(workflowId);
            String creatorName = creator == 1 ? "系统管理员" : HrmAPI.queryHrmName(creator);
            String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
            title = pathName + "-" + creatorName + "-" + date;
        }

        RequestInfo requestInfo = new RequestInfo();
        requestInfo.setCreatorid(String.valueOf(creator));// 流程创建人
        requestInfo.setWorkflowid(String.valueOf(workflowId));// 流程ID
        requestInfo.setDescription(title);// request name
        requestInfo.setIsNextFlow(isNext ? "1" : "0");// 是否提交下个节点 0: 否 | 非0: 是
        requestInfo.setRequestlevel("0");
        requestInfo.setRemindtype("0");

        // 主表信息录入
        MainTableInfo mainTableInfo = new MainTableInfo();
        requestInfo.setMainTableInfo(mainTableInfo);
        if (mainInfo != null) {
            Set<Map.Entry<String, String>> entrySet = mainInfo.entrySet();
            for (Map.Entry<String, String> entry : entrySet) {
                String key = entry.getKey();
                String value = entry.getValue();

                if (key == null || key.equals("")
                        || value == null || value.equals(""))
                    continue;

                Property property = new Property();
                property.setName(key);
                property.setValue(value);
                mainTableInfo.addProperty(property);
            }
        }

        // 明细表信息录入
        DetailTableInfo detailTableInfos = new DetailTableInfo();
        requestInfo.setDetailTableInfo(detailTableInfos);
        if (detailInfos != null) {
            // 明细表1到明细表n, 下标0默认为null
            for (int i = 1; i < detailInfos.length; i++) {
                List<Map<String, String>> detailInfo = detailInfos[i];
                if (detailInfo != null) {
                    DetailTable detailTable = new DetailTable();
                    // 调用createRequest时需要设置此项
                    detailTable.setId(String.valueOf(i));// orderId
                    // 调用saveRequest方法时需要设置此项
                    //detailTable.setTableDBName("");

                    // 创建明细行
                    for (Map<String, String> detailRow : detailInfo) {
                        Row row = new Row();

                        // 构造明细行中每一列
                        Set<Map.Entry<String, String>> entrySet = detailRow.entrySet();
                        for (Map.Entry<String, String> entry : entrySet) {
                            String key = entry.getKey();
                            String value = entry.getValue();

                            if (key == null || key.equals("")
                                    || value == null || value.equals(""))
                                continue;

                            Cell cell = new Cell();
                            cell.setName(key);
                            cell.setValue(value);
                            row.addCell(cell);
                        }

                        detailTable.addRow(row);
                    }
                    detailTableInfos.addDetailTable(detailTable);
                }
            }
        }

        return Util.getIntValue(new RequestService().createRequest(requestInfo));
    }
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值