|
@@ -0,0 +1,434 @@
|
|
|
|
|
+package com.muzhi.ruilaipu.service.impl;
|
|
|
|
|
+
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponse;
|
|
|
|
|
+import com.aliyun.dingtalkyida_1_0.models.GetOpenUrlResponse;
|
|
|
|
|
+import com.aliyun.dingtalkyida_2_0.models.GetInstanceByIdResponse;
|
|
|
|
|
+import com.aliyun.tea.TeaException;
|
|
|
|
|
+import com.aliyun.teautil.models.RuntimeOptions;
|
|
|
|
|
+import com.muzhi.ruilaipu.service.AccessTokenService;
|
|
|
|
|
+import com.muzhi.ruilaipu.service.MeikebaoxiaoService;
|
|
|
|
|
+import com.muzhi.ruilaipu.common.R;
|
|
|
|
|
+import com.muzhi.ruilaipu.dingtalk.dingtalkWebhook;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import okhttp3.*;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
+
|
|
|
|
|
+import java.io.IOException;
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * @Author ZhangKan
|
|
|
|
|
+ * @Data 15:39
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+@Service
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+public class MeikebaoxiaoServiceImpl implements MeikebaoxiaoService {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private AccessTokenService accessTokenService;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ *每刻钉钉云服务器环境地址(钉版)
|
|
|
|
|
+ *正式环境:https://dt.maycur.com
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 每刻阿里云服务器环境地址(阿里云)
|
|
|
|
|
+ * 正式环境:https://ng.maycur.com
|
|
|
|
|
+ * */
|
|
|
|
|
+ private static String HTTP_HOST = "https://ng.maycur.com";
|
|
|
|
|
+
|
|
|
|
|
+ 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);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //每刻报销和钉钉userId互查
|
|
|
|
|
+ public String getMeikeUserId(String userid){
|
|
|
|
|
+
|
|
|
|
|
+ /**调用每刻报销接口授权码*/
|
|
|
|
|
+ JSONObject accessTokenMeike = accessTokenService.getAccessToken_meike();
|
|
|
|
|
+ String tokenId = null;
|
|
|
|
|
+ String entCode = null;
|
|
|
|
|
+ if (accessTokenMeike != null && !accessTokenMeike.isEmpty()) {
|
|
|
|
|
+ tokenId = accessTokenMeike.getString("tokenId");
|
|
|
|
|
+ entCode = accessTokenMeike.getString("entCode");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Map mapAll = new HashMap();
|
|
|
|
|
+ mapAll.put("ids", Arrays.asList(userid));//【是】合同责任人工号列表
|
|
|
|
|
+
|
|
|
|
|
+ String mapJsonString = JSON.toJSONString(mapAll);
|
|
|
|
|
+ System.out.println("封装每刻报销【合同台账】创建接口的参数:" + mapJsonString);
|
|
|
|
|
+
|
|
|
|
|
+ /**调用【每刻报销和钉钉userId互查】接口*/
|
|
|
|
|
+ OkHttpClient client = new OkHttpClient().newBuilder()
|
|
|
|
|
+ .build();
|
|
|
|
|
+ MediaType mediaType = MediaType.parse("application/json");
|
|
|
|
|
+ RequestBody body = RequestBody.create(mediaType, mapJsonString);
|
|
|
|
|
+ Request request = new Request.Builder()
|
|
|
|
|
+ .url(HTTP_HOST + "/api/openapi/employee/search/user/ids?idType=userId")
|
|
|
|
|
+ .method("POST", body)
|
|
|
|
|
+ .addHeader("Content-Type", "application/json")
|
|
|
|
|
+ .addHeader("entCode", entCode)
|
|
|
|
|
+ .addHeader("tokenId", tokenId)
|
|
|
|
|
+ .build();
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject jsonObjectMK = null;
|
|
|
|
|
+ String code = null;
|
|
|
|
|
+ String message = null;
|
|
|
|
|
+ String success = null;
|
|
|
|
|
+ JSONArray dataMK = null;
|
|
|
|
|
+ String employeeId = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ Response response = client.newCall(request).execute();
|
|
|
|
|
+ String bodyStr = response.body().string();
|
|
|
|
|
+ jsonObjectMK = JSON.parseObject(bodyStr);
|
|
|
|
|
+ System.out.println("返回体body{}:" + jsonObjectMK);
|
|
|
|
|
+
|
|
|
|
|
+ if (!jsonObjectMK.isEmpty() && jsonObjectMK != null) {
|
|
|
|
|
+ code = jsonObjectMK.getString("code");
|
|
|
|
|
+ message = jsonObjectMK.getString("message");
|
|
|
|
|
+ success = jsonObjectMK.getString("success");
|
|
|
|
|
+
|
|
|
|
|
+ dataMK = jsonObjectMK.getJSONArray("data");
|
|
|
|
|
+ System.out.println("dataMK[]:" + dataMK);
|
|
|
|
|
+ if (dataMK.size() > 0 && dataMK != null && !dataMK.isEmpty()){
|
|
|
|
|
+ employeeId = dataMK.getJSONObject(0).getString("employeeId");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ System.out.println("【每刻报销和钉钉userId互查】接口返回的状态码(code):" + code);
|
|
|
|
|
+ System.out.println("【每刻报销和钉钉userId互查】接口返回的结果信息(message):" + message);
|
|
|
|
|
+ System.out.println("【每刻报销和钉钉userId互查】接口返回的成功与否(success):" + success);
|
|
|
|
|
+
|
|
|
|
|
+ System.out.println("当前人员的钉钉userId查询到的【每刻报销系统工号】:" + employeeId);
|
|
|
|
|
+
|
|
|
|
|
+ return employeeId;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //每刻报销根据工号查询部门信息
|
|
|
|
|
+ public String getMeikeDeptId(String employeeId){
|
|
|
|
|
+
|
|
|
|
|
+ /**调用每刻报销接口授权码*/
|
|
|
|
|
+ JSONObject accessTokenMeike = accessTokenService.getAccessToken_meike();
|
|
|
|
|
+ String tokenId = null;
|
|
|
|
|
+ String entCode = null;
|
|
|
|
|
+ if (accessTokenMeike != null && !accessTokenMeike.isEmpty()) {
|
|
|
|
|
+ tokenId = accessTokenMeike.getString("tokenId");
|
|
|
|
|
+ entCode = accessTokenMeike.getString("entCode");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List listAll = new ArrayList();
|
|
|
|
|
+ Map mapAll = new HashMap();
|
|
|
|
|
+ mapAll.put("employeeId", employeeId);//【是】合同责任人工号列表
|
|
|
|
|
+ listAll.add(mapAll);
|
|
|
|
|
+
|
|
|
|
|
+ String listJsonString = JSON.toJSONString(listAll);
|
|
|
|
|
+ System.out.println("封装每刻报销【合同台账】创建接口的参数:" + listJsonString);
|
|
|
|
|
+
|
|
|
|
|
+ /**调用【每刻报销和钉钉userId互查】接口*/
|
|
|
|
|
+ OkHttpClient client = new OkHttpClient().newBuilder()
|
|
|
|
|
+ .build();
|
|
|
|
|
+ MediaType mediaType = MediaType.parse("application/json");
|
|
|
|
|
+ RequestBody body = RequestBody.create(mediaType, listJsonString);
|
|
|
|
|
+ Request request = new Request.Builder()
|
|
|
|
|
+ .url(HTTP_HOST + "/api/openapi/employee/dept")
|
|
|
|
|
+ .method("POST", body)
|
|
|
|
|
+ .addHeader("Content-Type", "application/json")
|
|
|
|
|
+ .addHeader("entCode", entCode)
|
|
|
|
|
+ .addHeader("tokenId", tokenId)
|
|
|
|
|
+ .build();
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject jsonObjectMK = null;
|
|
|
|
|
+ String code = null;
|
|
|
|
|
+ String message = null;
|
|
|
|
|
+ String success = null;
|
|
|
|
|
+ JSONArray dataMK = null;
|
|
|
|
|
+ String businessCode = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ Response response = client.newCall(request).execute();
|
|
|
|
|
+ String bodyStr = response.body().string();
|
|
|
|
|
+ jsonObjectMK = JSON.parseObject(bodyStr);
|
|
|
|
|
+ System.out.println("返回体body{}:" + jsonObjectMK);
|
|
|
|
|
+
|
|
|
|
|
+ if (!jsonObjectMK.isEmpty() && jsonObjectMK != null) {
|
|
|
|
|
+ code = jsonObjectMK.getString("code");
|
|
|
|
|
+ message = jsonObjectMK.getString("message");
|
|
|
|
|
+ success = jsonObjectMK.getString("success");
|
|
|
|
|
+
|
|
|
|
|
+ dataMK = jsonObjectMK.getJSONArray("data");
|
|
|
|
|
+ System.out.println("dataMK[]:" + dataMK);
|
|
|
|
|
+ if (dataMK.size() > 0 && dataMK != null && !dataMK.isEmpty()){
|
|
|
|
|
+ businessCode = dataMK.getJSONObject(0).getString("businessCode");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ System.out.println("【每刻报销根据工号查询部门信息】接口返回的状态码(code):" + code);
|
|
|
|
|
+ System.out.println("【每刻报销根据工号查询部门信息】接口返回的结果信息(message):" + message);
|
|
|
|
|
+ System.out.println("【每刻报销根据工号查询部门信息】接口返回的成功与否(success):" + success);
|
|
|
|
|
+
|
|
|
|
|
+ System.out.println("每刻报销根据工号查询部门id:" + businessCode);
|
|
|
|
|
+
|
|
|
|
|
+ return businessCode;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //获取宜搭流程实例id详情
|
|
|
|
|
+ public JSONArray getYidaSlid(String slid) {
|
|
|
|
|
+ JSONObject jsonObject = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ com.aliyun.dingtalkyida_2_0.Client client = createClient2();
|
|
|
|
|
+ com.aliyun.dingtalkyida_2_0.models.GetInstanceByIdHeaders getInstanceByIdHeaders = new com.aliyun.dingtalkyida_2_0.models.GetInstanceByIdHeaders();
|
|
|
|
|
+ getInstanceByIdHeaders.xAcsDingtalkAccessToken = accessTokenService.getAccessToken();
|
|
|
|
|
+ com.aliyun.dingtalkyida_2_0.models.GetInstanceByIdRequest getInstanceByIdRequest = new com.aliyun.dingtalkyida_2_0.models.GetInstanceByIdRequest()
|
|
|
|
|
+ .setSystemToken(System.getenv("YIDA_SYSTEM_TOKEN"))
|
|
|
|
|
+ .setUserId("yida_pub_account")
|
|
|
|
|
+ .setAppType("APP_A1U3R89IHBD21BJZVX06");
|
|
|
|
|
+
|
|
|
|
|
+ GetInstanceByIdResponse instanceByIdWithOptions = client.getInstanceByIdWithOptions(slid, getInstanceByIdRequest, getInstanceByIdHeaders, new RuntimeOptions());
|
|
|
|
|
+ String s = JSON.toJSONString(instanceByIdWithOptions.getBody());
|
|
|
|
|
+ jsonObject = JSON.parseObject(s);
|
|
|
|
|
+ System.out.println("获取审批流程中盖章合同附件:" + 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 jsonObject1 = jsonObject.getJSONObject("data");
|
|
|
|
|
+ JSONArray jsonArray = jsonObject1.getJSONArray("attachmentField_mdsafagg");
|
|
|
|
|
+ System.out.println("合同盖章附件jsonArray[]:" + jsonArray);
|
|
|
|
|
+ return jsonArray;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //获取宜搭附件免登地址
|
|
|
|
|
+ public String getYidafile(String url) {
|
|
|
|
|
+
|
|
|
|
|
+ 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(System.getenv("YIDA_SYSTEM_TOKEN"))
|
|
|
|
|
+ .setFileUrl(url)//宜搭附件url
|
|
|
|
|
+ .setUserId("yida_pub_account")
|
|
|
|
|
+ .setTimeout(86400000L);//最大值: 86400000 , 即24小时。不填则默认60000,即1分钟。填0或者负数无效。
|
|
|
|
|
+
|
|
|
|
|
+ GetOpenUrlResponse appA1U3R89IHBD21BJZVX06 = client.getOpenUrlWithOptions("APP_A1U3R89IHBD21BJZVX06", 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);
|
|
|
|
|
+ return fileUrl;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //【启用】宜搭推送同步每刻报销付款单
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public R syncMeikebaoxiaoFK(String formInstanceId, String contract_id, String creator_userId, String contract_name,
|
|
|
|
|
+ String contract_amount, long contract_startDate, long contract_endDate, String contract_file_link_array,
|
|
|
|
|
+ String or_not_to_pay, String contract_type, String current_unit_id, String current_unit_name, String contract_currency){
|
|
|
|
|
+ log.info("接收传参「宜搭实例id」:" + formInstanceId);
|
|
|
|
|
+ log.info("接收传参「合同id」:" + contract_id);
|
|
|
|
|
+ log.info("接收传参「创建人userId」:" + creator_userId);
|
|
|
|
|
+ log.info("接收传参「合同名称」:" + contract_name);
|
|
|
|
|
+ log.info("接收传参「合同金额」:" + contract_amount);
|
|
|
|
|
+ log.info("接收传参「合同开始日期」:" + contract_startDate);
|
|
|
|
|
+ log.info("接收传参「合同结束日期」:" + contract_endDate);
|
|
|
|
|
+ log.info("接收传参「合同附件列表」:" + contract_file_link_array);
|
|
|
|
|
+
|
|
|
|
|
+ log.info("接收传参「是否付款」:" + or_not_to_pay);
|
|
|
|
|
+ log.info("接收传参「合同类型(采购合同审批、采购订单合同审批)」:" + contract_type);
|
|
|
|
|
+ log.info("接收传参「往来单位编号」:" + current_unit_id);
|
|
|
|
|
+ log.info("接收传参「往来单位名称」:" + current_unit_name);
|
|
|
|
|
+ log.info("接收传参「合同币种」:" + contract_currency);
|
|
|
|
|
+
|
|
|
|
|
+ log.info("开始封装参数......");
|
|
|
|
|
+
|
|
|
|
|
+ if (or_not_to_pay.equals("是")) {
|
|
|
|
|
+ log.info("是否属于付款合同=是,开始同步合同数据到每刻报销!");
|
|
|
|
|
+
|
|
|
|
|
+ /**获取每刻报销用户id*/
|
|
|
|
|
+ String meikeUserId = getMeikeUserId(creator_userId);
|
|
|
|
|
+ String meikeDeptId = null;
|
|
|
|
|
+ if (meikeUserId == null){
|
|
|
|
|
+ return R.error().message("通过当前归属人id没有查询到每刻报销对应的工号,同步中断!");
|
|
|
|
|
+ }else {
|
|
|
|
|
+ /**根据每刻工号获取每刻部门id*/
|
|
|
|
|
+ meikeDeptId = getMeikeDeptId(meikeUserId);
|
|
|
|
|
+ if (meikeDeptId == null){
|
|
|
|
|
+ return R.error().message("通过当前归属人id没有查询到每刻报销对应的部门,同步中断!");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //金额货币编码(金额货币编码,目前仅支持人民币:CNY)
|
|
|
|
|
+ String currencyCode = contract_currency;
|
|
|
|
|
+ System.out.println("金额货币编码(金额货币编码,目前仅支持人民币:CNY):" + currencyCode);
|
|
|
|
|
+
|
|
|
|
|
+ /**获取宜搭审批实例详情*/
|
|
|
|
|
+ List listHTFJ = new ArrayList();
|
|
|
|
|
+ JSONArray yidaFileArray = getYidaSlid(formInstanceId);
|
|
|
|
|
+ if (yidaFileArray.size() > 0){
|
|
|
|
|
+ for (int i = 0; i < yidaFileArray.size(); i++) {
|
|
|
|
|
+ String url = yidaFileArray.getJSONObject(i).getString("url");
|
|
|
|
|
+ String yidafile = getYidafile(url);
|
|
|
|
|
+ System.out.println("获取第【" + i+1 + "】条宜搭免登附件地址:" + yidafile);
|
|
|
|
|
+
|
|
|
|
|
+ String name = yidaFileArray.getJSONObject(i).getString("name");
|
|
|
|
|
+ //截取.这个字符后面的所有字符
|
|
|
|
|
+ String[] split = name.split("\\.");
|
|
|
|
|
+ String type = split[1];
|
|
|
|
|
+ System.out.println("文件类型:" + type);
|
|
|
|
|
+
|
|
|
|
|
+ Map mapFujian = new HashMap();
|
|
|
|
|
+ mapFujian.put("url", yidafile);
|
|
|
|
|
+ mapFujian.put("fileName", name);
|
|
|
|
|
+ mapFujian.put("fileType", type);
|
|
|
|
|
+ listHTFJ.add(mapFujian);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //封装所有的合同附件列表
|
|
|
|
|
+ Map mapHTFJ = new HashMap();
|
|
|
|
|
+ mapHTFJ.put("CF38", listHTFJ);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**调用每刻报销接口授权码*/
|
|
|
|
|
+ JSONObject accessTokenMeike = accessTokenService.getAccessToken_meike();
|
|
|
|
|
+ String tokenId = null;
|
|
|
|
|
+ String entCode = null;
|
|
|
|
|
+ if (accessTokenMeike != null && !accessTokenMeike.isEmpty()) {
|
|
|
|
|
+ tokenId = accessTokenMeike.getString("tokenId");
|
|
|
|
|
+ entCode = accessTokenMeike.getString("entCode");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return R.error().message("每刻报销接口授权码获取失败");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //封装查询参数
|
|
|
|
|
+ Map map1 = new HashMap();
|
|
|
|
|
+ map1.put("amount", contract_amount);//付款金额
|
|
|
|
|
+ map1.put("currency", currencyCode);//合同币种
|
|
|
|
|
+ Map map2 = new HashMap();
|
|
|
|
|
+ map2.put("startDate", contract_startDate);//合同开始日期
|
|
|
|
|
+ map2.put("endDate", contract_endDate);//合同结束日期
|
|
|
|
|
+
|
|
|
|
|
+ Map mapAll = new HashMap();
|
|
|
|
|
+ mapAll.put("formCode", contract_id);//【否】合同的单据Code,有值时会使用该值作为单据号
|
|
|
|
|
+ mapAll.put("formSubTypeBizCode", "FT169939391584677905");//【是】系统字段,合同的单据类型业务编码,固定指向每刻报销的表单code
|
|
|
|
|
+ mapAll.put("requestUserEmployeeId", meikeUserId);//【是】系统字段,合同的提单人工号(单据所属人)
|
|
|
|
|
+ mapAll.put("responsibleUserEmployeeIds", Arrays.asList(meikeUserId));//【是】合同责任人工号列表
|
|
|
|
|
+ mapAll.put("responsibleDepartmentBizCode", meikeDeptId);//【是】责任部门编码
|
|
|
|
|
+ mapAll.put("contractName", contract_name);//【是】合同名称
|
|
|
|
|
+ mapAll.put("contractNum", contract_id);//【是】合同编码
|
|
|
|
|
+ mapAll.put("contractAmount", map1);//【是】合同金额
|
|
|
|
|
+ /**【说明】往来单位编号不做同步*/
|
|
|
|
|
+// mapAll.put("tradingPartnerBizCode", current_unit_id);//往来单位编号
|
|
|
|
|
+ mapAll.put("formAssociatedList", null);//【否】关联单据组件
|
|
|
|
|
+ mapAll.put("contractDateDto", map2);//合同日期
|
|
|
|
|
+ mapAll.put("customObject", mapHTFJ);//合同附件列表
|
|
|
|
|
+
|
|
|
|
|
+ String mapJsonString = JSON.toJSONString(mapAll);
|
|
|
|
|
+ System.out.println("封装每刻报销【合同台账】创建接口的参数:" + mapJsonString);
|
|
|
|
|
+
|
|
|
|
|
+ /**调用每刻报销合同台账导入接口*/
|
|
|
|
|
+ OkHttpClient client = new OkHttpClient().newBuilder()
|
|
|
|
|
+ .build();
|
|
|
|
|
+ MediaType mediaType = MediaType.parse("application/json");
|
|
|
|
|
+ RequestBody body = RequestBody.create(mediaType, mapJsonString);
|
|
|
|
|
+ Request request = new Request.Builder()
|
|
|
|
|
+ .url(HTTP_HOST + "/api/openapi/receive/contract")
|
|
|
|
|
+ .method("POST", body)
|
|
|
|
|
+ .addHeader("Content-Type", "application/json")
|
|
|
|
|
+ .addHeader("entCode", entCode)
|
|
|
|
|
+ .addHeader("tokenId", tokenId)
|
|
|
|
|
+ .build();
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject jsonObjectMK = null;
|
|
|
|
|
+ String code = null;
|
|
|
|
|
+ String message = null;
|
|
|
|
|
+ String success = null;
|
|
|
|
|
+ JSONArray dataMK = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ Response response = client.newCall(request).execute();
|
|
|
|
|
+ String bodyStr = response.body().string();
|
|
|
|
|
+ jsonObjectMK = JSON.parseObject(bodyStr);
|
|
|
|
|
+ System.out.println("返回体body{}:" + jsonObjectMK);
|
|
|
|
|
+
|
|
|
|
|
+ if (!jsonObjectMK.isEmpty() && jsonObjectMK != null) {
|
|
|
|
|
+ code = jsonObjectMK.getString("code");
|
|
|
|
|
+ message = jsonObjectMK.getString("message");
|
|
|
|
|
+ success = jsonObjectMK.getString("success");
|
|
|
|
|
+
|
|
|
|
|
+ //推送接口返回的字段内容,该业务中不需要启用
|
|
|
|
|
+// dataMK = jsonObjectMK.getJSONArray("data");
|
|
|
|
|
+// System.out.println("dataMK[]:" + dataMK);
|
|
|
|
|
+// if (dataMK.size() > 0 && dataMK != null && !dataMK.isEmpty()){
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ System.out.println("推送每刻报销【合同台账】接口返回的状态码(code):" + code);
|
|
|
|
|
+ System.out.println("推送每刻报销【合同台账】接口返回的结果信息(message):" + message);
|
|
|
|
|
+ System.out.println("推送每刻报销【合同台账】接口返回的成功与否(success):" + success);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (success.equals("true")) {
|
|
|
|
|
+ log.info("宜搭合同推送同步每刻报销「合同台账」-->成功" + "【data】" + jsonObjectMK);
|
|
|
|
|
+ return R.ok().message("宜搭合同推送同步每刻报销「合同台账」-->成功").data("data", jsonObjectMK);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.info("宜搭合同推送同步每刻报销「合同台账」-->失败" + "【data】" + jsonObjectMK);
|
|
|
|
|
+ return R.error().message("智能合同推送同步每刻报销「合同台账」-->失败").data("data", jsonObjectMK);
|
|
|
|
|
+ }
|
|
|
|
|
+ }else {
|
|
|
|
|
+ log.info("宜搭合同推送同步每刻报销「合同台账」-->是否付款属于【" + or_not_to_pay + "】不符合推送条件!");
|
|
|
|
|
+ return R.error().message("宜搭合同推送同步每刻报销「合同台账」-->是否付款属于【" + or_not_to_pay + "】不符合推送条件!");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|