|
@@ -0,0 +1,752 @@
|
|
|
|
|
+package com.muzhi.tianpai.APITest;
|
|
|
|
|
+
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.aliyun.dingtalkhrm_1_0.models.GetEmployeeRosterByFieldResponse;
|
|
|
|
|
+import com.aliyun.dingtalkyida_1_0.models.GetOpenUrlResponse;
|
|
|
|
|
+import com.aliyun.dingtalkyida_1_0.models.SearchFormDatasResponse;
|
|
|
|
|
+import com.aliyun.dingtalkyida_2_0.models.CreateOrUpdateFormDataResponse;
|
|
|
|
|
+import com.aliyun.dingtalkyida_2_0.models.GetFormDataByIDResponse;
|
|
|
|
|
+import com.aliyun.ocr_api20210707.Client;
|
|
|
|
|
+import com.aliyun.ocr_api20210707.models.RecognizeAllTextRequest;
|
|
|
|
|
+import com.aliyun.ocr_api20210707.models.RecognizeAllTextResponse;
|
|
|
|
|
+import com.aliyun.tea.TeaException;
|
|
|
|
|
+import com.aliyun.teaopenapi.models.Config;
|
|
|
|
|
+import com.aliyun.teautil.models.RuntimeOptions;
|
|
|
|
|
+import com.dingtalk.api.DefaultDingTalkClient;
|
|
|
|
|
+import com.dingtalk.api.request.OapiGettokenRequest;
|
|
|
|
|
+import com.dingtalk.api.response.OapiGettokenResponse;
|
|
|
|
|
+import com.muzhi.tianpai.common.dingtalkyida.YiDaFormData;
|
|
|
|
|
+import com.muzhi.tianpai.service.AccessTokenService;
|
|
|
|
|
+import com.taobao.api.ApiException;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import okhttp3.*;
|
|
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
|
+
|
|
|
|
|
+import java.io.File;
|
|
|
|
|
+import java.io.IOException;
|
|
|
|
|
+import java.nio.file.Files;
|
|
|
|
|
+import java.nio.file.Path;
|
|
|
|
|
+import java.nio.file.Paths;
|
|
|
|
|
+import java.nio.file.StandardCopyOption;
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+
|
|
|
|
|
+@SpringBootTest
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+public class Test1 {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private AccessTokenService accessTokenService;
|
|
|
|
|
+
|
|
|
|
|
+ public static com.aliyun.dingtalkworkflow_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.dingtalkworkflow_1_0.Client(config);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static com.aliyun.dingtalkyida_2_0.Client createClient2() throws Exception {
|
|
|
|
|
+ com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
|
|
|
|
|
+ config.protocol = "https";
|
|
|
|
|
+ config.regionId = "central";
|
|
|
|
|
+ return new com.aliyun.dingtalkyida_2_0.Client(config);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static com.aliyun.dingtalkyida_1_0.Client createClient3() throws Exception {
|
|
|
|
|
+ com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
|
|
|
|
|
+ config.protocol = "https";
|
|
|
|
|
+ config.regionId = "central";
|
|
|
|
|
+ return new com.aliyun.dingtalkyida_1_0.Client(config);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static com.aliyun.dingtalkhrm_1_0.Client createClient4() throws Exception {
|
|
|
|
|
+ com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
|
|
|
|
|
+ config.protocol = "https";
|
|
|
|
|
+ config.regionId = "central";
|
|
|
|
|
+ return new com.aliyun.dingtalkhrm_1_0.Client(config);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void test1(){
|
|
|
|
|
+ JSONObject jsonObject2 = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ com.aliyun.dingtalkyida_2_0.Client client = createClient2();
|
|
|
|
|
+ com.aliyun.dingtalkyida_2_0.models.CreateOrUpdateFormDataHeaders createOrUpdateFormDataHeaders = new com.aliyun.dingtalkyida_2_0.models.CreateOrUpdateFormDataHeaders();
|
|
|
|
|
+ createOrUpdateFormDataHeaders.xAcsDingtalkAccessToken = accessTokenService.getAccessToken();
|
|
|
|
|
+ com.aliyun.dingtalkyida_2_0.models.CreateOrUpdateFormDataRequest createOrUpdateFormDataRequest = new com.aliyun.dingtalkyida_2_0.models.CreateOrUpdateFormDataRequest()
|
|
|
|
|
+ .setSystemToken("JB966E91RQZUKPPFFNOKBB86G3GH38VSN42AMGV")
|
|
|
|
|
+ .setFormUuid("FORM-BD31E2C07C7448DD931F686A5D881E96DQV8")
|
|
|
|
|
+ .setUserId("yida_pub_account")
|
|
|
|
|
+ .setSearchCondition("[{\"componentName\":\"TextField\",\"type\":\"TEXT\",\"value\":\"BC2000029\",\"key\":\"textField_maw7b9k0\",\"operator\":\"eq\"}]")
|
|
|
|
|
+ .setAppType("APP_FJSLK9BJ20K1NL3G2PUW")
|
|
|
|
|
+ .setFormDataJson("{\"selectField_lqesy4t1\":\"D\",\"textField_maw7b9k0\":\"BC2000029\",\"textField_lqesy4sy\":\"KETTLER Alu-Rad GmbH\",\"textField_mh8j17hy\":\"袁铷玥\"}");
|
|
|
|
|
+
|
|
|
|
|
+ CreateOrUpdateFormDataResponse orUpdateFormDataWithOptions = client.createOrUpdateFormDataWithOptions(createOrUpdateFormDataRequest, createOrUpdateFormDataHeaders, new RuntimeOptions());
|
|
|
|
|
+ String s = JSON.toJSONString(orUpdateFormDataWithOptions.getBody());
|
|
|
|
|
+ jsonObject2 = JSON.parseObject(s);
|
|
|
|
|
+ System.out.println("【创建或更新】表单object对象:" + jsonObject2);
|
|
|
|
|
+ } catch (TeaException err) {
|
|
|
|
|
+ if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
|
|
|
|
+ // err 中含有 code 和 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 属性,可帮助开发定位问题
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void test2(){
|
|
|
|
|
+ try {
|
|
|
|
|
+ com.aliyun.dingtalkyida_2_0.Client client = createClient2();
|
|
|
|
|
+ com.aliyun.dingtalkyida_2_0.models.GetFormDataByIDHeaders getFormDataByIDHeaders = new com.aliyun.dingtalkyida_2_0.models.GetFormDataByIDHeaders();
|
|
|
|
|
+ getFormDataByIDHeaders.xAcsDingtalkAccessToken = accessTokenService.getAccessToken();
|
|
|
|
|
+ com.aliyun.dingtalkyida_2_0.models.GetFormDataByIDRequest getFormDataByIDRequest = new com.aliyun.dingtalkyida_2_0.models.GetFormDataByIDRequest()
|
|
|
|
|
+ .setSystemToken("JB966E91RQZUKPPFFNOKBB86G3GH38VSN42AMGV")
|
|
|
|
|
+ .setUserId("yida_pub_account")
|
|
|
|
|
+ .setAppType("APP_FJSLK9BJ20K1NL3G2PUW");
|
|
|
|
|
+
|
|
|
|
|
+ GetFormDataByIDResponse formDataByIDWithOptions = client.getFormDataByIDWithOptions("FINST-R8E66381FS30I83TKR2W4DO14O8V35TY6QBHM5NH", getFormDataByIDRequest, getFormDataByIDHeaders, new RuntimeOptions());
|
|
|
|
|
+ String s = JSON.toJSONString(formDataByIDWithOptions.getBody());
|
|
|
|
|
+ JSONObject jsonObject = JSON.parseObject(s);
|
|
|
|
|
+ System.out.println("【查询】表单object对象:" + jsonObject);
|
|
|
|
|
+ } catch (TeaException err) {
|
|
|
|
|
+ if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
|
|
|
|
+ // err 中含有 code 和 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 属性,可帮助开发定位问题
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void test3(){
|
|
|
|
|
+ try {
|
|
|
|
|
+ com.aliyun.dingtalkyida_2_0.Client client = createClient2();
|
|
|
|
|
+ com.aliyun.dingtalkyida_2_0.models.UpdateSubTableHeaders updateSubTableHeaders = new com.aliyun.dingtalkyida_2_0.models.UpdateSubTableHeaders();
|
|
|
|
|
+ updateSubTableHeaders.xAcsDingtalkAccessToken = accessTokenService.getAccessToken();
|
|
|
|
|
+ com.aliyun.dingtalkyida_2_0.models.UpdateSubTableRequest updateSubTableRequest = new com.aliyun.dingtalkyida_2_0.models.UpdateSubTableRequest()
|
|
|
|
|
+ .setSystemToken("JB966E91RQZUKPPFFNOKBB86G3GH38VSN42AMGV")
|
|
|
|
|
+ .setFormInstanceId("FINST-R8E66381FS30I83TKR2W4DO14O8V35TY6QBHM5NH")
|
|
|
|
|
+ .setUserId("yida_pub_account")
|
|
|
|
|
+ .setTableFieldIds("tableField_lqesy4t4")
|
|
|
|
|
+ .setUpdateFormDataJson("{ \"tableField_lqesy4t4\": [ { \"textField_makozait\": \"0519-68198299\", \"textField_lqesy4t7\": \"\", \"textField_lqesy4t6\": \"\" } ] }")
|
|
|
|
|
+ .setAppType("APP_FJSLK9BJ20K1NL3G2PUW");
|
|
|
|
|
+
|
|
|
|
|
+ client.updateSubTableWithOptions(updateSubTableRequest, updateSubTableHeaders, new com.aliyun.teautil.models.RuntimeOptions());
|
|
|
|
|
+ } catch (TeaException err) {
|
|
|
|
|
+ if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
|
|
|
|
+ // err 中含有 code 和 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 属性,可帮助开发定位问题
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void test4(){
|
|
|
|
|
+ try {
|
|
|
|
|
+ com.aliyun.dingtalkyida_1_0.Client client = createClient3();
|
|
|
|
|
+ com.aliyun.dingtalkyida_1_0.models.GetOpenUrlHeaders getOpenUrlHeaders = new com.aliyun.dingtalkyida_1_0.models.GetOpenUrlHeaders();
|
|
|
|
|
+ getOpenUrlHeaders.xAcsDingtalkAccessToken = accessTokenService.getAccessToken();
|
|
|
|
|
+ com.aliyun.dingtalkyida_1_0.models.GetOpenUrlRequest getOpenUrlRequest = new com.aliyun.dingtalkyida_1_0.models.GetOpenUrlRequest()
|
|
|
|
|
+ .setSystemToken("333")
|
|
|
|
|
+ .setFileUrl("555")
|
|
|
|
|
+ .setUserId("444");
|
|
|
|
|
+
|
|
|
|
|
+ client.getOpenUrlWithOptions("222", getOpenUrlRequest, getOpenUrlHeaders, new com.aliyun.teautil.models.RuntimeOptions());
|
|
|
|
|
+ } catch (TeaException err) {
|
|
|
|
|
+ if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
|
|
|
|
+ // err 中含有 code 和 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 属性,可帮助开发定位问题
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void test5(){
|
|
|
|
|
+
|
|
|
|
|
+ String url = "https://www.aliwork.com/ossFileHandle?appType=APP_XV6ZGK1162TI1Z1FE17D&fileName=APP_XV6ZGK1162TI1Z1FE17D_MTU3MzExMjA5XzMyRDY2Q0ExNEY2MUtLT0RIMDRIWTNDM0pLRjIySVhLOUtSSU1NNA$$.xml&instId=&type=download";
|
|
|
|
|
+
|
|
|
|
|
+ String fileUrl = "";
|
|
|
|
|
+ JSONObject jsonObject = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ com.aliyun.dingtalkyida_1_0.Client client = createClient3();
|
|
|
|
|
+ com.aliyun.dingtalkyida_1_0.models.GetOpenUrlHeaders getOpenUrlHeaders = new com.aliyun.dingtalkyida_1_0.models.GetOpenUrlHeaders();
|
|
|
|
|
+ getOpenUrlHeaders.xAcsDingtalkAccessToken = accessTokenService.getAccessToken();
|
|
|
|
|
+ com.aliyun.dingtalkyida_1_0.models.GetOpenUrlRequest getOpenUrlRequest = new com.aliyun.dingtalkyida_1_0.models.GetOpenUrlRequest()
|
|
|
|
|
+ .setSystemToken("USC66V61YG8ZMBM5E8JQFBZQ6W0G3V1L6J0GMXE")
|
|
|
|
|
+ .setFileUrl(url)//宜搭附件url
|
|
|
|
|
+ .setUserId("yida_pub_account")
|
|
|
|
|
+ .setTimeout(86400000L);//最大值: 86400000 , 即24小时。不填则默认60000,即1分钟。填0或者负数无效。
|
|
|
|
|
+
|
|
|
|
|
+ GetOpenUrlResponse appA1U3R89IHBD21BJZVX06 = client.getOpenUrlWithOptions("APP_XV6ZGK1162TI1Z1FE17D", getOpenUrlRequest, getOpenUrlHeaders, new RuntimeOptions());
|
|
|
|
|
+ String s = JSON.toJSONString(appA1U3R89IHBD21BJZVX06.getBody());
|
|
|
|
|
+ jsonObject = JSON.parseObject(s);
|
|
|
|
|
+ System.out.println("获取宜搭附件免登地址:" + jsonObject);
|
|
|
|
|
+
|
|
|
|
|
+ fileUrl = jsonObject.getString("result");
|
|
|
|
|
+ } catch (TeaException err) {
|
|
|
|
|
+ if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
|
|
|
|
+ // err 中含有 code 和 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("获取宜搭附件免登地址:" + fileUrl);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void test6(){
|
|
|
|
|
+ String instanceId = "FINST-L3D66Z8197X1EX7NHEMMCDBF7JJV26UGWBZJMOWH";
|
|
|
|
|
+ JSONObject jsonObject = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ com.aliyun.dingtalkyida_2_0.Client client = createClient2();
|
|
|
|
|
+ com.aliyun.dingtalkyida_2_0.models.GetFormDataByIDHeaders getFormDataByIDHeaders = new com.aliyun.dingtalkyida_2_0.models.GetFormDataByIDHeaders();
|
|
|
|
|
+ getFormDataByIDHeaders.xAcsDingtalkAccessToken = accessTokenService.getAccessToken();
|
|
|
|
|
+ com.aliyun.dingtalkyida_2_0.models.GetFormDataByIDRequest getFormDataByIDRequest = new com.aliyun.dingtalkyida_2_0.models.GetFormDataByIDRequest()
|
|
|
|
|
+ .setSystemToken("USC66V61YG8ZMBM5E8JQFBZQ6W0G3V1L6J0GMXE")
|
|
|
|
|
+ .setUserId("yida_pub_account")
|
|
|
|
|
+ .setAppType("APP_XV6ZGK1162TI1Z1FE17D");
|
|
|
|
|
+ GetFormDataByIDResponse formDataByIDWithOptions = client.getFormDataByIDWithOptions(instanceId, getFormDataByIDRequest, getFormDataByIDHeaders, new RuntimeOptions());
|
|
|
|
|
+ String s = JSON.toJSONString(formDataByIDWithOptions.getBody());
|
|
|
|
|
+ jsonObject = JSON.parseObject(s);
|
|
|
|
|
+// System.out.println("宜搭实例id查询【工时填报】接口object对象:" + jsonObject);
|
|
|
|
|
+ } catch (TeaException err) {
|
|
|
|
|
+ if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
|
|
|
|
+ // err 中含有 code 和 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 属性,可帮助开发定位问题
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ JSONObject formData = jsonObject.getJSONObject("formData");
|
|
|
|
|
+ System.out.println("宜搭实例id查询【工时填报】接口formData对象:" + formData);
|
|
|
|
|
+ if (formData != null){
|
|
|
|
|
+ //填报单号
|
|
|
|
|
+ String tianbaodanhao = formData.getString("serialNumberField_lmiltutx");
|
|
|
|
|
+ System.out.println("填报单号:" + tianbaodanhao);
|
|
|
|
|
+ //填报日期
|
|
|
|
|
+ long tianbaoriqi = formData.getLong("dateField_mgt1sluh");
|
|
|
|
|
+ System.out.println("填报日期:" + tianbaoriqi);
|
|
|
|
|
+ //填报总工时
|
|
|
|
|
+ float tianbaozonggongshi = formData.getFloat("numberField_llunq7e2") != null ? formData.getFloat("numberField_llunq7e2") : 0;
|
|
|
|
|
+ System.out.println("填报总工时:" + tianbaozonggongshi);
|
|
|
|
|
+ //填报人员userid
|
|
|
|
|
+ String tianbaorenyuanUserId = formData.getJSONArray("employeeField_mhiv3pjk_id").getString(0);
|
|
|
|
|
+ System.out.println("填报人员userid:" + tianbaorenyuanUserId);
|
|
|
|
|
+ //当日已填报总工时
|
|
|
|
|
+ float dangriyitianbaozonggongshi = formData.getFloat("numberField_mhiun888") != null ? formData.getFloat("numberField_mhiun888") : 0;
|
|
|
|
|
+ System.out.println("填报人员userid:" + dangriyitianbaozonggongshi);
|
|
|
|
|
+ //工时填报明细
|
|
|
|
|
+ JSONArray jsonArray = formData.getJSONArray("tableField_mhbs93eh");
|
|
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
|
|
+ JSONObject jsonObject1 = jsonArray.getJSONObject(i);
|
|
|
|
|
+ //工时填报明细-总工时
|
|
|
|
|
+ float mx_zonggongshi = jsonObject1.getFloat("numberField_mhbs93e3") != null ? jsonObject1.getFloat("numberField_mhbs93e3") : 0;
|
|
|
|
|
+ System.out.println("工时填报明细-总工时:" + mx_zonggongshi);
|
|
|
|
|
+ //工时填报明细-已填报工时
|
|
|
|
|
+ float mx_yitianbaogongshi = jsonObject1.getFloat("numberField_mhbs93e4") != null ? jsonObject1.getFloat("numberField_mhbs93e4") : 0;
|
|
|
|
|
+ System.out.println("工时填报明细-已填报工时:" + mx_yitianbaogongshi);
|
|
|
|
|
+ //工时填报明细-填报总工时
|
|
|
|
|
+ float mx_tianbaozonggongshi = jsonObject1.getFloat("numberField_mhbs93e5") != null ? jsonObject1.getFloat("numberField_mhbs93e5") : 0;
|
|
|
|
|
+ System.out.println("工时填报明细-填报总工时:" + mx_tianbaozonggongshi);
|
|
|
|
|
+
|
|
|
|
|
+ //工时填报明细-类型
|
|
|
|
|
+ String mx_leixing = jsonObject1.getString("radioField_mhbs93e6");
|
|
|
|
|
+ System.out.println("工时填报明细-类型:" + mx_leixing);
|
|
|
|
|
+ //工时填报明细-负责人userId
|
|
|
|
|
+ String mx_fuzerenUserId = jsonObject1.getJSONArray("employeeField_mhbs93e9_id").getString(0);
|
|
|
|
|
+ System.out.println("工时填报明细-负责人userId:" + mx_fuzerenUserId);
|
|
|
|
|
+ //工时填报明细-编号
|
|
|
|
|
+ String mx_bianhao = jsonObject1.getString("textField_mhbs93ea");
|
|
|
|
|
+ System.out.println("工时填报明细-编号:" + mx_bianhao);
|
|
|
|
|
+ //工时填报明细-客户名称
|
|
|
|
|
+ String mx_kehumingcheng = jsonObject1.getString("textField_mhbs93eb");
|
|
|
|
|
+ System.out.println("工时填报明细-客户名称:" + mx_kehumingcheng);
|
|
|
|
|
+ //工时填报明细-工时
|
|
|
|
|
+ float mx_gongshi = jsonObject1.getFloat("numberField_mhbs93ec") != null ? jsonObject1.getFloat("numberField_mhbs93ec") : 0;
|
|
|
|
|
+ System.out.println("工时填报明细-工时:" + mx_gongshi);
|
|
|
|
|
+ //工时填报明细-工作内容
|
|
|
|
|
+ String mx_gongzuoneirong = jsonObject1.getString("textareaField_mhbs93ed");
|
|
|
|
|
+ System.out.println("工时填报明细-工作内容:" + mx_gongzuoneirong);
|
|
|
|
|
+ //工时填报明细-备注
|
|
|
|
|
+ String mx_beizhu = jsonObject1.getString("textareaField_mhbs93ee");
|
|
|
|
|
+ System.out.println("工时填报明细-备注:" + mx_beizhu);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //TODO 指定代收邮箱地址
|
|
|
|
|
+ public static String emailAddress = "postmaster@fnsx.xyz";
|
|
|
|
|
+
|
|
|
|
|
+ /*阿里邮箱列出邮件的全部附件*/
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void test000() {
|
|
|
|
|
+ String emailId = "DzzzzzzNqZC";//邮件id
|
|
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
|
|
+ try {
|
|
|
|
|
+ OkHttpClient client = new OkHttpClient().newBuilder()
|
|
|
|
|
+ .build();
|
|
|
|
|
+ MediaType mediaType = MediaType.parse("text/plain");
|
|
|
|
|
+ Request request = new Request.Builder()
|
|
|
|
|
+ .url("https://alimail-cn.aliyuncs.com/v2/users/"+ emailAddress +"/messages/"+ emailId +"/attachments")
|
|
|
|
|
+ .method("GET", null)
|
|
|
|
|
+ .addHeader("Authorization", "Bearer " + accessTokenService.getAlibabaMailboxAccessToken())
|
|
|
|
|
+ .build();
|
|
|
|
|
+ Response response = client.newCall(request).execute();
|
|
|
|
|
+ String resStr = response.body().string();
|
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(resStr);
|
|
|
|
|
+ jsonArray = jsonObject.getJSONArray("attachments") != null ? jsonObject.getJSONArray("attachments") : new JSONArray();
|
|
|
|
|
+ System.out.println("列出邮件的发票附件列表[]:" + jsonArray);
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ log.error("该邮件的发票附件获取异常:{}", e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*阿里邮箱文件下载*/
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void test7() {
|
|
|
|
|
+
|
|
|
|
|
+ String emailId = "DzzzzzzNqZC";//邮件id
|
|
|
|
|
+ String emailFileId = "8319daf3-7388-49f9-87fc-2bd8818179f5";//邮件附件id
|
|
|
|
|
+ try {
|
|
|
|
|
+ OkHttpClient client = new OkHttpClient().newBuilder()
|
|
|
|
|
+ .build();
|
|
|
|
|
+ MediaType mediaType = MediaType.parse("text/plain");
|
|
|
|
|
+ Request request = new Request.Builder()
|
|
|
|
|
+ .url("https://alimail-cn.aliyuncs.com/v2/users/"+ emailAddress +"/messages/"+ emailId +"/attachments/"+ emailFileId +"/$value")
|
|
|
|
|
+ .method("GET", null)
|
|
|
|
|
+ .addHeader("Authorization", "Bearer " + accessTokenService.getAlibabaMailboxAccessToken())
|
|
|
|
|
+ .build();
|
|
|
|
|
+ try (Response response = client.newCall(request).execute()) {
|
|
|
|
|
+ if (!response.isSuccessful()) {
|
|
|
|
|
+ System.err.println("下载失败: " + response.code() + " - " + response.message());
|
|
|
|
|
+ // 打印错误 body(可能是 JSON 错误信息)
|
|
|
|
|
+ if (response.body() != null) {
|
|
|
|
|
+ System.err.println("Error body: " + response.body().string());
|
|
|
|
|
+ }
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String destinationDir = "invoice"; // Linux 路径
|
|
|
|
|
+
|
|
|
|
|
+ //获取当前日期,用于创建文件保存目录中增加当前日期的文件夹作区分
|
|
|
|
|
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式 yyyy-MM-dd HH:mm:ss
|
|
|
|
|
+ String format = df.format(new Date());
|
|
|
|
|
+ System.out.println(format);// new Date()为获取当前系统时间
|
|
|
|
|
+
|
|
|
|
|
+ String fileName = "测试发票-001.pdf";
|
|
|
|
|
+
|
|
|
|
|
+ String path = destinationDir + File.separatorChar + format + File.separatorChar + fileName;// 指定存放位置,此处使用的是全局变量的文件名称
|
|
|
|
|
+
|
|
|
|
|
+ // 确保目录存在
|
|
|
|
|
+ Path dir = Paths.get(path);
|
|
|
|
|
+ Files.createDirectories(dir);
|
|
|
|
|
+
|
|
|
|
|
+ // 构建完整文件路径
|
|
|
|
|
+ Path filePath = dir.resolve("测试发票-001.pdf");
|
|
|
|
|
+
|
|
|
|
|
+ // 从响应流直接写入文件(高效,不加载全内存)
|
|
|
|
|
+ try (ResponseBody body = response.body()) {
|
|
|
|
|
+ if (body == null) {
|
|
|
|
|
+ throw new IOException("响应体为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ Files.copy(body.byteStream(), filePath, StandardCopyOption.REPLACE_EXISTING);
|
|
|
|
|
+ }
|
|
|
|
|
+ System.out.println("✅ 附件已保存至: " + filePath.toAbsolutePath());
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ System.err.println("下载异常: " + e.getMessage());
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void test8() {
|
|
|
|
|
+
|
|
|
|
|
+ String email = "test@qq.com";
|
|
|
|
|
+ String fileName = "测试发票-001.pdf";
|
|
|
|
|
+ float fileSize = 1024;
|
|
|
|
|
+ String fileNewUrl = "https://poc.cloudpure.cn/changguchuan/invoice/2026-02-05/25317000003383776933-pdf.pdf";
|
|
|
|
|
+
|
|
|
|
|
+ Map formMap = new HashMap<>();
|
|
|
|
|
+ formMap.put("textField_ml9154m5", fileName);//发票文件名称
|
|
|
|
|
+ formMap.put("textField_ml7hkag3", email);//收件人邮箱地址
|
|
|
|
|
+ formMap.put("textField_ml9154ma", fileNewUrl);//文件转存url地址
|
|
|
|
|
+
|
|
|
|
|
+ Map fileMap = new HashMap();
|
|
|
|
|
+ fileMap.put("previewUrl",fileNewUrl);
|
|
|
|
|
+ fileMap.put("size",fileSize);
|
|
|
|
|
+ fileMap.put("name",fileName);
|
|
|
|
|
+ fileMap.put("downloadUrl",fileNewUrl);
|
|
|
|
|
+ fileMap.put("url",fileNewUrl);
|
|
|
|
|
+ List fileList = new ArrayList();
|
|
|
|
|
+ fileList.add(fileMap);
|
|
|
|
|
+ formMap.put("attachmentField_ml9154mb",fileList);
|
|
|
|
|
+
|
|
|
|
|
+ String formDataJson = JSON.toJSONString(formMap);
|
|
|
|
|
+ System.out.println("mapJson:" + formDataJson);
|
|
|
|
|
+
|
|
|
|
|
+ Map searchMap = new HashMap<>();
|
|
|
|
|
+ searchMap.put("key", "textField_ml9154m5");
|
|
|
|
|
+ searchMap.put("value", fileName);
|
|
|
|
|
+ searchMap.put("type", "TEXT");
|
|
|
|
|
+ searchMap.put("operator", "eq");
|
|
|
|
|
+ searchMap.put("componentName", "TextField");
|
|
|
|
|
+ List searchList = new ArrayList();
|
|
|
|
|
+ searchList.add(searchMap);
|
|
|
|
|
+ String searchCondition = JSON.toJSONString(searchList);
|
|
|
|
|
+ System.out.println("查询条件searchCondition:" + searchCondition);
|
|
|
|
|
+ /*新增或更新到宜搭*/
|
|
|
|
|
+ log.info("开始新增或更新到宜搭「票夹」表单--->");
|
|
|
|
|
+ YiDaFormData.CreateOrUpdateFormData(
|
|
|
|
|
+ "FORM-036D3F7CB4CC44E7AE7846A789C3DA65EOJN",
|
|
|
|
|
+ searchCondition,
|
|
|
|
|
+ formDataJson,
|
|
|
|
|
+ accessTokenService.getAccessToken());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**钉钉应用*/
|
|
|
|
|
+ //APPKEY
|
|
|
|
|
+ private static String APPKEY = "dingzupxqpzcczaaddcw";
|
|
|
|
|
+ //APPSECRET
|
|
|
|
|
+ private static String APPSECRET = "EpND2Oj4adk2Od9ZwAszSYGC8WL_OWYPq1Uj7b5jR1DI6rCsWTdxzvqTHM4H3Dz6";
|
|
|
|
|
+ //AgenthId:
|
|
|
|
|
+ //corpId:
|
|
|
|
|
+
|
|
|
|
|
+ public static String DingtalkAccessToken = null;
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void test9() {
|
|
|
|
|
+
|
|
|
|
|
+ DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
|
|
|
|
|
+ OapiGettokenRequest request = new OapiGettokenRequest();
|
|
|
|
|
+ request.setAppkey(APPKEY);
|
|
|
|
|
+ request.setAppsecret(APPSECRET);
|
|
|
|
|
+ request.setHttpMethod("GET");
|
|
|
|
|
+ try {
|
|
|
|
|
+ OapiGettokenResponse response = client.execute(request);
|
|
|
|
|
+ DingtalkAccessToken = response.getAccessToken();
|
|
|
|
|
+ System.out.println("乐檬钉钉AccessToken:" + DingtalkAccessToken);
|
|
|
|
|
+ } catch (ApiException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+// /**
|
|
|
|
|
+// * <b>description</b> :
|
|
|
|
|
+// * <p>使用凭据初始化账号Client</p>
|
|
|
|
|
+// * @return Client
|
|
|
|
|
+// *
|
|
|
|
|
+// * @throws Exception
|
|
|
|
|
+// */
|
|
|
|
|
+// public static com.aliyun.ocr_api20210707.Client createClientOCR() throws Exception {
|
|
|
|
|
+// // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378657.html。
|
|
|
|
|
+// com.aliyun.credentials.Client credential = new com.aliyun.credentials.Client();
|
|
|
|
|
+// com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
|
|
|
|
+// .setCredential(credential);
|
|
|
|
|
+// // Endpoint 请参考 https://api.aliyun.com/product/ocr-api
|
|
|
|
|
+// config.endpoint = "ocr-api.cn-hangzhou.aliyuncs.com";
|
|
|
|
|
+// return new com.aliyun.ocr_api20210707.Client(config);
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// //OCR识别
|
|
|
|
|
+// @Test
|
|
|
|
|
+// public void test10() {
|
|
|
|
|
+// try {
|
|
|
|
|
+// com.aliyun.ocr_api20210707.Client client = createClientOCR();
|
|
|
|
|
+// com.aliyun.ocr_api20210707.models.RecognizeAllTextRequest recognizeAllTextRequest = new com.aliyun.ocr_api20210707.models.RecognizeAllTextRequest()
|
|
|
|
|
+// .setType("Advanced")
|
|
|
|
|
+// .setUrl("https://poc.cloudpure.cn/changguchuan/invoice/2026-02-05/26329216804000097816.pdf");
|
|
|
|
|
+// com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
|
|
|
|
+// com.aliyun.ocr_api20210707.models.RecognizeAllTextResponse resp = client.recognizeAllTextWithOptions(recognizeAllTextRequest, runtime);
|
|
|
|
|
+// System.out.println(new com.google.gson.Gson().toJson(resp));
|
|
|
|
|
+// } catch (TeaException error) {
|
|
|
|
|
+// // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
|
|
|
|
+// // 错误 message
|
|
|
|
|
+// System.out.println(error.getMessage());
|
|
|
|
|
+// // 诊断地址
|
|
|
|
|
+// System.out.println(error.getData().get("Recommend"));
|
|
|
|
|
+// } catch (Exception _error) {
|
|
|
|
|
+// TeaException error = new TeaException(_error.getMessage(), _error);
|
|
|
|
|
+// // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
|
|
|
|
+// // 错误 message
|
|
|
|
|
+// System.out.println(error.getMessage());
|
|
|
|
|
+// // 诊断地址
|
|
|
|
|
+// System.out.println(error.getData().get("Recommend"));
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 创建 OCR 客户端
|
|
|
|
|
+ * @param accessKeyId 阿里云 AccessKey ID
|
|
|
|
|
+ * @param accessKeySecret 阿里云 AccessKey Secret
|
|
|
|
|
+ * @return Client
|
|
|
|
|
+ * @throws Exception
|
|
|
|
|
+ */
|
|
|
|
|
+ public static Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
|
|
|
|
|
+ Config config = new Config()
|
|
|
|
|
+ // 必填,您的 AccessKey ID
|
|
|
|
|
+ .setAccessKeyId(accessKeyId)
|
|
|
|
|
+ // 必填,您的 AccessKey Secret
|
|
|
|
|
+ .setAccessKeySecret(accessKeySecret);
|
|
|
|
|
+ // Endpoint (地域节点),OCR 统一识别通常使用 cn-shanghai
|
|
|
|
|
+ config.endpoint = "ocr-api.cn-hangzhou.aliyuncs.com";
|
|
|
|
|
+ return new Client(config);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void test11() {
|
|
|
|
|
+ // 1. 替换为你的阿里云密钥
|
|
|
|
|
+ String accessKeyId = "LTAI5tRXcYFKYuBV3EriBAKm";
|
|
|
|
|
+ String accessKeySecret = "dWPdO22hTwkH4UoK734J53FLwwvBsY";
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 2. 初始化客户端
|
|
|
|
|
+ Client client = createClient(accessKeyId, accessKeySecret);
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 构建请求对象
|
|
|
|
|
+ RecognizeAllTextRequest request = new RecognizeAllTextRequest();
|
|
|
|
|
+
|
|
|
|
|
+ // 设置请求参数
|
|
|
|
|
+ // 方式一:传图片 URL (推荐,简单)
|
|
|
|
|
+ request.setUrl("https://poc.cloudpure.cn/changguchuan/invoice/2026-02-05/26329216804000097816.pdf");
|
|
|
|
|
+
|
|
|
|
|
+ // 方式二:传本地图片二进制流 (需要自行读取文件)
|
|
|
|
|
+ // byte[] imageBytes = Files.readAllBytes(Paths.get("path/to/your/image.jpg"));
|
|
|
|
|
+ // request.setBody(TeaUtil.toReadableByteChannel(imageBytes));
|
|
|
|
|
+
|
|
|
|
|
+ // 必填参数:指定图片类型
|
|
|
|
|
+ // Advanced = 通用文字识别高精版
|
|
|
|
|
+ request.setType("Advanced");
|
|
|
|
|
+
|
|
|
|
|
+ // 可选参数:是否返回坐标
|
|
|
|
|
+ // request.setOutputCoordinate("points");
|
|
|
|
|
+
|
|
|
|
|
+ // 4. 设置运行时选项(如超时)
|
|
|
|
|
+ RuntimeOptions runtime = new RuntimeOptions();
|
|
|
|
|
+ runtime.readTimeout = 10000; // 10秒读超时
|
|
|
|
|
+ runtime.connectTimeout = 5000; // 5秒连接超时
|
|
|
|
|
+
|
|
|
|
|
+ // 5. 发起调用
|
|
|
|
|
+ // RecognizeAllText 是 API 方法名
|
|
|
|
|
+ RecognizeAllTextResponse response = client.recognizeAllTextWithOptions(request, runtime);
|
|
|
|
|
+
|
|
|
|
|
+ // 6. 处理结果
|
|
|
|
|
+ if (response.getBody() != null && response.getBody().getData() != null) {
|
|
|
|
|
+ System.out.println("识别成功!");
|
|
|
|
|
+ System.out.println("图片宽度: " + response.getBody().getData().getWidth());
|
|
|
|
|
+ System.out.println("图片高度: " + response.getBody().getData().getHeight());
|
|
|
|
|
+ System.out.println("识别内容: " + response.getBody().getData().getContent());
|
|
|
|
|
+
|
|
|
|
|
+ // 详细结果在 SubImages 或 BlockInfo 中
|
|
|
|
|
+ // 具体结构请参考文档中的 JSON 结构
|
|
|
|
|
+ } else {
|
|
|
|
|
+ System.out.println("识别失败,无数据返回");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } catch (TeaException e) {
|
|
|
|
|
+ // 阿里云 SDK 异常
|
|
|
|
|
+ System.err.println("ErrorCode: " + e.getCode());
|
|
|
|
|
+ System.err.println("Message: " + e.getMessage());
|
|
|
|
|
+ System.err.println("Data: " + e.getData());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void test12() {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void test13(){
|
|
|
|
|
+ String accessToken = null;
|
|
|
|
|
+
|
|
|
|
|
+ String grant_type = "client_credentials";//固定值
|
|
|
|
|
+ String client_id = "tlHiqXxwX6jVFEKs";//应用id
|
|
|
|
|
+ String client_secret = "BI9O3IvEBJVYuKC55hEuxkwkpHTdheh8PUSipwBreHkEWq0xDc0rOUQ9pM9lktuE";//应用密钥
|
|
|
|
|
+ String bodyStr = "grant_type="+ grant_type +"&client_id="+ client_id +"&client_secret=" + client_secret;
|
|
|
|
|
+ try {
|
|
|
|
|
+ OkHttpClient client = new OkHttpClient().newBuilder()
|
|
|
|
|
+ .build();
|
|
|
|
|
+ MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
|
|
|
|
|
+ RequestBody body = RequestBody.create(mediaType, bodyStr);
|
|
|
|
|
+ Request request = new Request.Builder()
|
|
|
|
|
+ .url("https://alimail-cn.aliyuncs.com/oauth2/v2.0/token")
|
|
|
|
|
+ .method("POST", body)
|
|
|
|
|
+ .addHeader("Content-Type", "application/x-www-form-urlencoded")
|
|
|
|
|
+ .build();
|
|
|
|
|
+ Response response = client.newCall(request).execute();
|
|
|
|
|
+ String resStr = response.body().string();
|
|
|
|
|
+ JSONObject jsonObject = JSON.parseObject(resStr);
|
|
|
|
|
+ accessToken = jsonObject.getString("access_token");
|
|
|
|
|
+ System.out.println("阿里企业邮箱的access_token:" + accessToken);
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void test14(){
|
|
|
|
|
+
|
|
|
|
|
+ String email = "zhuxiaojian@cnlemon.net";
|
|
|
|
|
+
|
|
|
|
|
+ //查询表单实例数据
|
|
|
|
|
+ Map mapAll = new HashMap();
|
|
|
|
|
+ //邮箱地址
|
|
|
|
|
+ mapAll.put("textField_mob3qfjb", email);
|
|
|
|
|
+ String mapAllStr = JSON.toJSONString(mapAll);
|
|
|
|
|
+ System.out.println("封装查询的字段参数:" + mapAllStr);
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+
|
|
|
|
|
+ int size = 100;
|
|
|
|
|
+ int page = 1;
|
|
|
|
|
+ try {
|
|
|
|
|
+ com.aliyun.dingtalkyida_1_0.Client client = createClient3();
|
|
|
|
|
+ com.aliyun.dingtalkyida_1_0.models.SearchFormDatasHeaders searchFormDatasHeaders = new com.aliyun.dingtalkyida_1_0.models.SearchFormDatasHeaders();
|
|
|
|
|
+ searchFormDatasHeaders.xAcsDingtalkAccessToken = accessTokenService.getAccessToken();
|
|
|
|
|
+ com.aliyun.dingtalkyida_1_0.models.SearchFormDatasRequest searchFormDatasRequest = new com.aliyun.dingtalkyida_1_0.models.SearchFormDatasRequest()
|
|
|
|
|
+ .setSystemToken("3Z966P91XA1FTYVQ7UTVLDTGJ4613UJUR7ONLT7C")
|
|
|
|
|
+
|
|
|
|
|
+ .setSearchFieldJson(mapAllStr)
|
|
|
|
|
+
|
|
|
|
|
+ .setCurrentPage(page)
|
|
|
|
|
+ .setPageSize(size)
|
|
|
|
|
+ .setFormUuid("FORM-E489F03D805D4E169BA6A8755B4E72E6TN6N")
|
|
|
|
|
+ .setUserId("yida_pub_account")
|
|
|
|
|
+ .setAppType("APP_YPF7S88D9O139KRVM83J");
|
|
|
|
|
+
|
|
|
|
|
+ SearchFormDatasResponse searchFormDatasResponse = client.searchFormDatasWithOptions(searchFormDatasRequest, searchFormDatasHeaders, new RuntimeOptions());
|
|
|
|
|
+// System.out.println(JSON.toJSONString(searchFormDatasResponse.getBody()));
|
|
|
|
|
+ String s = JSON.toJSONString(searchFormDatasResponse.getBody());
|
|
|
|
|
+ jsonObject = JSON.parseObject(s);
|
|
|
|
|
+ System.out.println("宜搭数据高级条件查询到接口object对象:" + jsonObject);
|
|
|
|
|
+ JSONArray data = jsonObject.getJSONArray("data");
|
|
|
|
|
+ if (data.isEmpty()) {
|
|
|
|
|
+ System.out.println("根据邮箱地址查询【用户信息】返回数据为空!");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ JSONObject formData = data.getJSONObject(0).getJSONObject("formData");
|
|
|
|
|
+ //成员userId
|
|
|
|
|
+ String emailUserId = formData.getJSONArray("employeeField_mm1g5703_id").getString(0);
|
|
|
|
|
+ System.out.println("成员userId===>" + emailUserId);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (TeaException err) {
|
|
|
|
|
+ if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
|
|
|
|
+ // err 中含有 code 和 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 属性,可帮助开发定位问题
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void test15(){
|
|
|
|
|
+
|
|
|
|
|
+ String shiliID = "FINST-GOD667C13RN57V1XM8AC995FKPW42K8Q495PMNOA";
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject jsonObject = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ com.aliyun.dingtalkyida_2_0.Client client = createClient2();
|
|
|
|
|
+ com.aliyun.dingtalkyida_2_0.models.GetFormDataByIDHeaders getFormDataByIDHeaders = new com.aliyun.dingtalkyida_2_0.models.GetFormDataByIDHeaders();
|
|
|
|
|
+ getFormDataByIDHeaders.xAcsDingtalkAccessToken = accessTokenService.getAccessToken_YunpuPOC();
|
|
|
|
|
+ com.aliyun.dingtalkyida_2_0.models.GetFormDataByIDRequest getFormDataByIDRequest = new com.aliyun.dingtalkyida_2_0.models.GetFormDataByIDRequest()
|
|
|
|
|
+ .setSystemToken("R9666ED1IRN57Y9RGFEGQ742QXID2MH74S3PM6Y4")
|
|
|
|
|
+ .setUserId("yida_pub_account")
|
|
|
|
|
+ .setAppType("APP_IJXSY7YQ7O3U23759WV8");
|
|
|
|
|
+ GetFormDataByIDResponse formDataByIDWithOptions = client.getFormDataByIDWithOptions(shiliID, getFormDataByIDRequest, getFormDataByIDHeaders, new RuntimeOptions());
|
|
|
|
|
+ String s = JSON.toJSONString(formDataByIDWithOptions.getBody());
|
|
|
|
|
+ jsonObject = JSON.parseObject(s);
|
|
|
|
|
+// System.out.println("获取宜搭表单数据,表单object对象:" + jsonObject);
|
|
|
|
|
+ } catch (TeaException err) {
|
|
|
|
|
+ if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
|
|
|
|
+ // err 中含有 code 和 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("获取宜搭表单数据,表单object对象:" + jsonObject);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void test16(){
|
|
|
|
|
+
|
|
|
|
|
+ String userId = "011033176057927940";
|
|
|
|
|
+
|
|
|
|
|
+ String userRank = null;
|
|
|
|
|
+ String targetFieldCode = "419d7ae9-1d42-4b55-aae4-7248afb1b936";//钉钉花名册自定义字段职级id
|
|
|
|
|
+ try {
|
|
|
|
|
+ com.aliyun.dingtalkhrm_1_0.Client client = createClient4();
|
|
|
|
|
+ com.aliyun.dingtalkhrm_1_0.models.GetEmployeeRosterByFieldHeaders getEmployeeRosterByFieldHeaders = new com.aliyun.dingtalkhrm_1_0.models.GetEmployeeRosterByFieldHeaders();
|
|
|
|
|
+ getEmployeeRosterByFieldHeaders.xAcsDingtalkAccessToken = accessTokenService.getAccessToken();
|
|
|
|
|
+ com.aliyun.dingtalkhrm_1_0.models.GetEmployeeRosterByFieldRequest getEmployeeRosterByFieldRequest = new com.aliyun.dingtalkhrm_1_0.models.GetEmployeeRosterByFieldRequest()
|
|
|
|
|
+ .setUserIdList(java.util.Arrays.asList(
|
|
|
|
|
+ userId
|
|
|
|
|
+ ))
|
|
|
|
|
+ .setAppAgentId(4574746416L)
|
|
|
|
|
+ .setText2SelectConvert(true);
|
|
|
|
|
+ GetEmployeeRosterByFieldResponse employeeRosterByFieldWithOptions = client.getEmployeeRosterByFieldWithOptions(getEmployeeRosterByFieldRequest, getEmployeeRosterByFieldHeaders, new RuntimeOptions());
|
|
|
|
|
+ String jsonString = JSON.toJSONString(employeeRosterByFieldWithOptions.getBody());
|
|
|
|
|
+ JSONObject jsonObject = JSON.parseObject(jsonString);
|
|
|
|
|
+ System.out.println("获取钉钉花名册接口返回:" + jsonObject);
|
|
|
|
|
+ JSONArray jsonArray = jsonObject.getJSONArray("result");
|
|
|
|
|
+ JSONObject jsonObject1 = jsonArray.getJSONObject(0);
|
|
|
|
|
+ JSONArray jsonArray1 = jsonObject1.getJSONArray("fieldDataList");
|
|
|
|
|
+ userRank = jsonArray1.stream()
|
|
|
|
|
+ .map(JSONObject.class::cast)
|
|
|
|
|
+ .filter(field -> targetFieldCode.equals(field.getString("fieldCode")))
|
|
|
|
|
+ .flatMap(field -> field.getJSONArray("fieldValueList").stream())
|
|
|
|
|
+ .map(JSONObject.class::cast)
|
|
|
|
|
+ .map(item -> item.getString("label"))
|
|
|
|
|
+ .findFirst()
|
|
|
|
|
+ .orElse(null);
|
|
|
|
|
+ } catch (TeaException err) {
|
|
|
|
|
+ if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
|
|
|
|
+ // err 中含有 code 和 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("该人员钉钉花名册职级:" + userRank);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|