创建申请
<p><strong>简要描述:</strong> </p>
<ul>
<li>创建申请</li>
</ul>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>https://approval.mingdao.com/api/addReq</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>POST </li>
</ul>
<p><strong>参数:</strong> </p>
<table>
<thead>
<tr>
<th style="text-align: left;">参数名</th>
<th style="text-align: left;">必选</th>
<th style="text-align: left;">类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">无</td>
<td style="text-align: left;">是</td>
<td style="text-align: left;">body</td>
<td>审批申请信息(需用payload方式提交数据,需先获取审批表单详情)([获取审批表单详情点击这里](<a href="https://www.showdoc.cc/mingdao?page_id=337099714086518">https://www.showdoc.cc/mingdao?page_id=337099714086518</a> "获取审批表单详情请点击这里"))</td>
</tr>
<tr>
<td style="text-align: left;">accountId</td>
<td style="text-align: left;">是</td>
<td style="text-align: left;">string</td>
<td>创建人编号</td>
</tr>
<tr>
<td style="text-align: left;">appKey</td>
<td style="text-align: left;">是</td>
<td style="text-align: left;">string</td>
<td>AppKey</td>
</tr>
<tr>
<td style="text-align: left;">sign</td>
<td style="text-align: left;">是</td>
<td style="text-align: left;">string</td>
<td>签名信息([签名算法请点击这里](<a href="https://www.showdoc.cc/mingdao?page_id=15539798">https://www.showdoc.cc/mingdao?page_id=15539798</a> "签名算法请点击这里"))</td>
</tr>
<tr>
<td style="text-align: left;">timestamp</td>
<td style="text-align: left;">是</td>
<td style="text-align: left;">long</td>
<td>Unix时间戳(与签名所用时间戳一致,精度为毫秒)</td>
</tr>
</tbody>
</table>
<p><strong>提交数据示例(JSON格式)</strong></p>
<pre><code> {
&quot;createBy&quot;: &quot;string&quot;,
&quot;data&quot;: {
RFormData
},
&quot;formId&quot;: &quot;string&quot;,
&quot;reqTitle&quot;: &quot;string&quot;,
&quot;setTop&quot;: true,
&quot;start&quot;: true
}</code></pre>
<p><strong>提交数据示例(RFormData格式)</strong></p>
<pre><code> {
&quot;reqTitle&quot;: &quot;母校(我是用户姓名)发起的供应商支付方式修改&quot;,
&quot;formId&quot;: &quot;59142dcf68e5115922e96aa6&quot;,
&quot;data&quot;: {
&quot;controls&quot;: [
{
&quot;5a3a386429a1e11f74900cc9&quot;: &quot;母校(我是用户姓名)&quot;//控件Id:值
},
{
&quot;5a3a386429a1e11f74900cca&quot;: &quot;2018-04-25 15:47:23&quot;
},
{
&quot;5a3a386429a1e11f74900cd2&quot;: 1
}
],
&quot;formControls&quot;: [
{
&quot;5a41eac429a1e10798fdcb20&quot;: [//明细表Id
[//明细表第1条数据
{
&quot;5a41eac429a1e10798fdcb21&quot;: &quot;100&quot;//控件Id:值
},
{
&quot;5a41eac429a1e10798fdcb22&quot;: &quot;test&quot;
},
{
&quot;5a41eac429a1e10798fdcb23&quot;: &quot;备注&quot;
}
],
[//明细表第2条数据
{
&quot;5a41eac429a1e10798fdcb21&quot;: &quot;100&quot;
},
{
&quot;5a41eac429a1e10798fdcb22&quot;: &quot;test&quot;
},
{
&quot;5a41eac429a1e10798fdcb23&quot;: &quot;备注&quot;
}
]
]
}
]
}
}</code></pre>
<p><strong>提交参数说明</strong> </p>
<p><strong>apiReqInfo</strong> </p>
<table>
<thead>
<tr>
<th style="text-align: left;">参数名</th>
<th style="text-align: left;">类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">createBy</td>
<td style="text-align: left;">string</td>
<td>创建人ID(填accountId)</td>
</tr>
<tr>
<td style="text-align: left;">data</td>
<td style="text-align: left;">RFormData</td>
<td>表单数据</td>
</tr>
<tr>
<td style="text-align: left;">formId</td>
<td style="text-align: left;">string</td>
<td>表单ID</td>
</tr>
<tr>
<td style="text-align: left;">reqTitle</td>
<td style="text-align: left;">string</td>
<td>申请标题</td>
</tr>
<tr>
<td style="text-align: left;">setTop</td>
<td style="text-align: left;">boolean</td>
<td>是否置顶在审批人的待审批列表中</td>
</tr>
</tbody>
</table>
<p><strong>RFormData</strong> </p>
<table>
<thead>
<tr>
<th style="text-align: left;">参数名</th>
<th style="text-align: left;">类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">controls</td>
<td style="text-align: left;">Array[Map<string,object>]</td>
<td>控件数据,格式:[{控件Id:值},{控件Id:值}...]</td>
</tr>
<tr>
<td style="text-align: left;">formControls</td>
<td style="text-align: left;">Array[Map<string,List<List<Map<string,object>>>>]</td>
<td>明细控件值,格式:[{明细表Id:[[{控件Id:值},{控件Id:值}...],[{控件Id:值},{控件Id:值}...]...]}]</td>
</tr>
</tbody>
</table>
<p><strong>返回数据示例(JSON格式)</strong></p>
<pre><code>{
&quot;reqId&quot;:&quot;string&quot;
}</code></pre>
<p><strong>返回参数说明</strong> </p>
<table>
<thead>
<tr>
<th style="text-align: left;">参数名</th>
<th style="text-align: left;">类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">reqId</td>
<td style="text-align: left;">string</td>
<td>审批申请ID</td>
</tr>
</tbody>
</table>
<p><strong>DEMO</strong></p>
<pre><code> //获取审批表单详情
String url = host + &quot;/api/getFormDetailData/&quot; + formId + &quot;?accountId=&quot; + accountId + &quot;&amp;appKey=&quot; + appKey + &quot;&amp;timestamp=&quot; + m + &quot;&amp;sign=&quot; + sign;
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url(url).get().build();
Response response = client.newCall(request).execute();
if (response.isSuccessful()) {
Map&lt;String, Object&gt; postMap = new HashMap&lt;&gt;();
List&lt;Map&lt;String, Object&gt;&gt; postControls = new ArrayList&lt;&gt;();//主表数据
List&lt;Map&lt;Object, List&lt;List&lt;Map&lt;String, Object&gt;&gt;&gt;&gt;&gt; postFormControls = new ArrayList&lt;&gt;();//明细表数据
String string = response.body().string();
Map apiFormListDtoList = new Gson().fromJson(string, Map.class);
apiFormListDtoList.isEmpty();
List&lt;Map&gt; controls = (List&lt;Map&gt;) apiFormListDtoList.get(&quot;controls&quot;);
for (Map control : controls) {
Map postControl = new HashMap&lt;&gt;();
postControl.put(control.get(&quot;controlId&quot;), control.get(&quot;value&quot;));// TODO 主表数据 value可改为需要的值
postControls.add(postControl);
}
List&lt;Map&gt; formControls = (List&lt;Map&gt;) apiFormListDtoList.get(&quot;formControls&quot;);
for (Map formControlMap : formControls) {
Map&lt;Object, List&lt;List&lt;Map&lt;String, Object&gt;&gt;&gt;&gt; postFormControlMap = new HashMap&lt;&gt;();//明细表
List&lt;List&lt;Map&lt;String, Object&gt;&gt;&gt; postFormControlRowList = new ArrayList&lt;&gt;();//明细表行数据
List&lt;Map&gt; formControlList = (List&lt;Map&gt;) formControlMap.get(&quot;tempControls&quot;);
List&lt;Map&lt;String, Object&gt;&gt; postFormControlList = new ArrayList&lt;&gt;();// 第1行数据
for (Map formControl : formControlList) {
Map postFormControl = new HashMap&lt;&gt;();
postFormControl.put(formControl.get(&quot;controlId&quot;), formControl.get(&quot;value&quot;));//TODO 第1行数据 value可改为需要的值
postFormControlList.add(postFormControl);
}
List&lt;Map&lt;String, Object&gt;&gt; postFormControlList2 = new ArrayList&lt;&gt;();// 第2行数据
for (Map formControl : formControlList) {
Map postFormControl = new HashMap&lt;&gt;();
postFormControl.put(formControl.get(&quot;controlId&quot;), formControl.get(&quot;value&quot;));//TODO 第2行数据 value可改为需要的值
postFormControlList2.add(postFormControl);
}
postFormControlRowList.add(postFormControlList);
postFormControlMap.put(formControlMap.get(&quot;formId&quot;), postFormControlRowList);
postFormControls.add(postFormControlMap);
}
Map rFormData = new HashMap();
rFormData.put(&quot;controls&quot;, postControls);
rFormData.put(&quot;formControls&quot;, postFormControls);
postMap.put(&quot;createBy&quot;, accountId);//TODO 创建人ID(填accountId)
postMap.put(&quot;data&quot;, rFormData);//表单数据
postMap.put(&quot;formId&quot;, formId);//表单ID
postMap.put(&quot;reqTitle&quot;, &quot;string&quot;);//TODO 申请标题
postMap.put(&quot;setTop&quot;, false);//是否置顶在审批人的待审批列表中
//创建申请
String url1 = host + &quot;/api/addReq?accountId=&quot; + accountId + &quot;&amp;appKey=&quot; + appKey + &quot;&amp;timestamp=&quot; + m + &quot;&amp;sign=&quot; + sign;
RequestBody body = RequestBody.create(MediaType.parse(&quot;application/json; charset=utf-8&quot;), new Gson().toJson(postMap));
Request request1 = new Request.Builder().url(url1).post(body).build();
Response response1 = client.newCall(request1).execute();
if (response1.isSuccessful()) {
String string1 = response1.body().string();
System.out.println(string1);
} else {
System.out.println(response1.body().string());
}
}else {
System.out.println(response.body().string());
}</code></pre>