|
@@ -2,14 +2,8 @@ package net.chenlin.dp.modules.api.controller;
|
|
|
|
|
|
import com.dingtalk.api.DefaultDingTalkClient;
|
|
|
import com.dingtalk.api.DingTalkClient;
|
|
|
-import com.dingtalk.api.request.OapiGettokenRequest;
|
|
|
-import com.dingtalk.api.request.OapiProcessinstanceGetRequest;
|
|
|
-import com.dingtalk.api.request.OapiProcessinstanceListidsRequest;
|
|
|
-import com.dingtalk.api.request.OapiSsoGettokenRequest;
|
|
|
-import com.dingtalk.api.response.OapiGettokenResponse;
|
|
|
-import com.dingtalk.api.response.OapiProcessinstanceGetResponse;
|
|
|
-import com.dingtalk.api.response.OapiProcessinstanceListidsResponse;
|
|
|
-import com.dingtalk.api.response.OapiSsoGettokenResponse;
|
|
|
+import com.dingtalk.api.request.*;
|
|
|
+import com.dingtalk.api.response.*;
|
|
|
import com.taobao.api.ApiException;
|
|
|
import net.chenlin.dp.common.utils.DateUtils;
|
|
|
import net.chenlin.dp.common.utils.JSONUtils;
|
|
@@ -34,42 +28,58 @@ public class interfaceTest {
|
|
|
|
|
|
* 获取企业内部应用的access_token
|
|
|
*/
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
|
|
|
+ OapiGettokenRequest req = new OapiGettokenRequest();
|
|
|
+ req.setHttpMethod("GET");
|
|
|
+ req.setAppkey("ding1h54xhh2cyh90hgk");
|
|
|
+ req.setAppsecret("EZMYVfZn_yBBj2Mr_qfZPtJvVErJqdQKVHQvHGk9s3LLuAZxdwAsqdnXIuSy6uVx");
|
|
|
+ OapiGettokenResponse rsp = client.execute(req);
|
|
|
|
|
|
|
|
|
|
|
|
+ if(toMap(rsp.getBody()).get("errcode").equals("0")){
|
|
|
+ gettoken = (String) toMap(rsp.getBody()).get("access_token");
|
|
|
+
|
|
|
+ }else{
|
|
|
+ System.out.println("access_token获取失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ System.out.println("access_token获取:"+gettoken);
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ } catch (ApiException | JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/process/get_by_name");
|
|
|
+ OapiProcessGetByNameRequest req = new OapiProcessGetByNameRequest();
|
|
|
+ req.setName("销售订单测试");
|
|
|
+ OapiProcessGetByNameResponse rsp = client.execute(req, gettoken);
|
|
|
+ System.out.println(rsp.getBody());
|
|
|
+*/
|
|
|
|
|
|
|
|
|
- * 获取审批实例ID列表(备用金列表获取)
|
|
|
- * 备用金process_code:PROC-9331671D-265D-4A79-A6F2-93326D727673
|
|
|
+ * 获取审批实例ID列表
|
|
|
+ * 备用金process_code:PROC-9331671D-265D-4A79-A6F2-93326D727673(备用金列表获取)
|
|
|
+ * 备用金process_code:PROC-40356B7F-6825-4DC3-83B9-8AD6D0D2CA49(销售订单列表获取)
|
|
|
* 钉钉接口仅支持120天内数据
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -84,10 +94,15 @@ public class interfaceTest {
|
|
|
try {
|
|
|
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/processinstance/get");
|
|
|
OapiProcessinstanceGetRequest req = new OapiProcessinstanceGetRequest();
|
|
|
- req.setProcessInstanceId("bfb52963-17dd-4476-b557-da71a5b8ff68");
|
|
|
- OapiProcessinstanceGetResponse rsp = client.execute(req, "5237b03a68b13fec9c351473efed2a11");
|
|
|
-
|
|
|
- System.out.println(JSONUtils.jsonToMap(rsp.getBody()));
|
|
|
+ req.setProcessInstanceId("e3fa7ef4-645a-4238-9ea4-125d00160304");
|
|
|
+ OapiProcessinstanceGetResponse rsp = client.execute(req, "b63175b83675374682f76130b4790323");
|
|
|
+ System.out.println(rsp.getBody());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
} catch (ApiException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|