首页 > 其他分享 >钉钉开发之根据流程码获取流程表单schema

钉钉开发之根据流程码获取流程表单schema

时间:2022-12-08 09:46:47浏览次数:49  
标签:err 流程 表单 aliyun new message null com schema

一、环境:

1、钉钉oa审批流程中,已有“出差审批”流程,流程码为:PROC-48E207E5-EB8B-457C-BC3D-86CD5E5A50B3

2、开发环境:IDEA

二、代码

1、获取token

package sfccl.api;
import com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenResponse;
import com.aliyun.tea.TeaException;

public class Mytoken {
//    public static String accessToken;
    String AppKey = "ding**********kkq5";
    String AppSecret = "ZM1iVltcUHlS_***********************_plbobp";
    String accessToken = "";

    public static com.aliyun.dingtalkoauth2_1_0.Client createClient() throws Exception {
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
        config.protocol = "https";
        config.regionId = "central";
        return new com.aliyun.dingtalkoauth2_1_0.Client(config);
    }

    public String accessToken() throws Exception {
        //java.util.List<String> args = java.util.Arrays.asList(args_);
        com.aliyun.dingtalkoauth2_1_0.Client client = Mytoken.createClient();
        com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenRequest getAccessTokenRequest = new com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenRequest()
                .setAppKey(AppKey)
                .setAppSecret(AppSecret);
        try {
            GetAccessTokenResponse tokenResponse = client.getAccessToken(getAccessTokenRequest);
//            System.out.println(tokenResponse.body);
//            System.out.println(tokenResponse.getHeaders());
//            System.out.println(tokenResponse.getBody());
            System.out.println(tokenResponse.getBody().accessToken);
            System.out.println(tokenResponse.getBody().expireIn);
            accessToken = tokenResponse.getBody().accessToken;
        } catch (TeaException err) {
            if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                // err 中含有 code 和 message 属性,可帮助开发定位问题
                System.out.println("TeaException:"+err.message);
            }

        } catch (Exception _err) {
            TeaException err = new TeaException(_err.getMessage(), _err);
            if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                // err 中含有 code 和 message 属性,可帮助开发定位问题
                System.out.println("TeaException:" + err.message);
            }

        }
        return accessToken;
    }
}

2、获取表单schema

package sfccl.api;
import com.aliyun.tea.*;
import com.aliyun.teautil.*;
import com.aliyun.teautil.models.*;
import com.aliyun.dingtalkworkflow_1_0.*;
import com.aliyun.dingtalkworkflow_1_0.models.*;
import com.aliyun.teaopenapi.*;
import com.aliyun.teaopenapi.models.*;
import java.util.List;
public class GetSchema {
    /**
     * 使用 Token 初始化账号Client
     * @return Client
     * @throws Exception
     */
    public static com.aliyun.dingtalkworkflow_1_0.Client createClient() throws Exception {
        Config config = new Config();
        config.protocol = "https";
        config.regionId = "central";
        return new com.aliyun.dingtalkworkflow_1_0.Client(config);
    }
    public static void main(String[] args_) throws Exception{
        java.util.List<String> args = java.util.Arrays.asList(args_);
        Mytoken mytoken = new Mytoken();
        String token = mytoken.accessToken();
        com.aliyun.dingtalkworkflow_1_0.Client client = GetSchema.createClient();
        QuerySchemaByProcessCodeHeaders querySchemaByProcessCodeHeaders = new QuerySchemaByProcessCodeHeaders();
        querySchemaByProcessCodeHeaders.xAcsDingtalkAccessToken = token;
        QuerySchemaByProcessCodeRequest querySchemaByProcessCodeRequest = new QuerySchemaByProcessCodeRequest()
                .setProcessCode("PROC-48E207E5-EB8B-457C-BC3D-86CD5E5A50B3");
        try {
            QuerySchemaByProcessCodeResponse userResponse = client.querySchemaByProcessCodeWithOptions(querySchemaByProcessCodeRequest, querySchemaByProcessCodeHeaders, new RuntimeOptions());
            System.out.println(userResponse.getBody().toMap());   //注意:这里使用toMap()才能看到具体表单模板,若使用toString()只能看到类地址
        } catch (TeaException err) {
            if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                // err 中含有 code 和 message 属性,可帮助开发定位问题
                System.out.println(err.message);
            }
        } catch (Exception _err) {
            TeaException err = new TeaException(_err.getMessage(), _err);
            if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                // err 中含有 code 和 message 属性,可帮助开发定位问题
                System.out.println(err.message);
            }
        }
    }
}

 三、结果

1f997da77f873b49b2c3fa2653656762
7200
{result={creatorUserId=081944650937626047, gmtModified=2022-11-22T11:04Z, bizType=, formUuid=FORM-E4579C3A-30FA-41F4-9953-321259F1F23B, ownerIdType=orgId, formCode=PROC-48E207E5-EB8B-457C-BC3D-86CD5E5A50B3, icon=null, engineType=0, memo=测试001——api流程表单开发测试, gmtCreate=2022-11-22T10:44Z, schemaContent={icon=common, title=出差申请, items=[{children=[{componentName=TextField, props={bizAlias=, id=TextField-K2AD4O5B, label=出差地点(单行输入框, required=null}}, {componentName=DDPhotoField, props={bizAlias=null, id=DDPhotoField_1AWJR59S5BTS0, label=图片, required=false}}, {componentName=DDDateRangeField, props={bizAlias=null, id=DDDateRangeField_19TP9POJBE800, label=["开始时间","结束时间"], required=false}}, {componentName=NumberField, props={bizAlias=, id=NumberField_1WOIL8PMYE5C0, label=出差人数, required=false}}, {componentName=MoneyField, props={bizAlias=, id=MoneyField_KUPX9HK115O0, label=出差金额(元), required=false}}, {componentName=DDSelectField, props={bizAlias=, id=DDSelectField_21GQV9G2U9Z40, label=出差同伴(单选框), required=false}}, {componentName=TextField, props={bizAlias=, id=TextField_9RF2CYB4B380, label=出差工具, required=false}}, {componentName=TextareaField, props={bizAlias=, id=TextareaField_1WFOQXQCVGLC0, label=出差事由, required=false}}], componentName=TableField, props={staffStatusEnabled=false, bizType=null, hidden=null, payEnable=null, statField=null, link=null, align=null, durationLabel=null, pushToCalendar=null, required=null, duration=null, holidayOptions=[], appId=null, options=null, hiddenInApprovalDetail=null, useCalendar=null, disabled=null, id=TableField_16SENC2STKG00, placeholder=null, asyncCondition=null, behaviorLinkage=null, hideLabel=null, showAttendOptions=null, objOptions=null, notUpper=null, format=null, bizAlias=, label=行程明细, labelEditableFreeze=null, pushToAttendance=null, commonBizType=null, push={attendanceRule=null, pushSwitch=null, pushTag=null}, fieldsInfo=null, requiredEditableFreeze=null, unit=null, extract=null, verticalPrint=null, eSign=null, mainTitle=null, formula=null, notPrint=null, choice=null, childFieldVisible=null, actionName=添加, attendTypeLabel=null}}]}, appUuid=dingc2e467f9e6ed39aaf5bf40eda33b7ba0, appType=0, visibleRange=PRIVATE, listOrder=51, name=出差申请, customSetting=null, procType=, status=PUBLISHED}}

Process finished with exit code 0

 

标签:err,流程,表单,aliyun,new,message,null,com,schema
From: https://www.cnblogs.com/sfccl/p/16965225.html

相关文章

  • 1. 流程控制语句if基本概述
    1.流程控制语句if基本概述01.单分支结构if[如果你有房];then我就嫁给你fi#示例[root@qiudao~/shell]#catif-1.sh#!/usr/bin/bashifwhichls;thenecho"......
  • element-ui 表单组件的简单封装
    背景在管理系统中我们需要经常使用表单组件来收集用户的一些数据,如果按照官网的示例一个个表单项去填写不仅代码会变得很长而且麻烦,所以我们有必要去对组件进行再次的封装......
  • JS操作form表单倒计时自动提交
     只需要注意表单的id<formid="frm"action="http://www.baidu.com">考试还剩余<divid="time"></div></form><script>vartimes=45*60;//剩余时间,单位......
  • Java流程控制(4)选择结构
                  ......
  • 关于JQuery validate表单校验插件对级联下拉框的校验问题
         今天在使用JQueryvalidate表单校验插件时,遇见了一个非常诡异的问题了。在此记录一下:     问题描述:               ......
  • uboot启动流程
    编译完uboot,uboot源代码根目录会生成链接脚本:u-boot.lds,里面指明了执行的第一个函数是_start _start位于arch\arm\lib\vectors.S,其最开始的代码如下: 所以先跳转到......
  • 绿色版MySQL8.0.26安装流程
    下载 5.7 8.0 官网 https://dev.mysql.com/downloads/mysql/ 国内镜像网站 https://developer.aliyun.com/mirror/ ​ windows安装数据库 安装版: .......
  • Mysql加锁流程详解
    目录​​前言​​​​一、锁的内存结构​​​​二、加锁流程​​​​1、加锁的基本流程​​​​2、根据主键加锁​​​​3、根据二级索引加锁​​​​4、根据非索引字段查询......
  • 消息队列流程
     ......
  • 开源web自定义表单有哪几个特点?
    目前,市场正在蓬勃发展中,作为企业,采用传统表单的弊端也逐渐显现出来,面临比较大的问题就是办公效率得不到提升。在各行各业正积极筹备朝着数字化方向转型的背景下,采用开源web......