|
|
@@ -1,8 +1,11 @@
|
|
|
package org.springblade.finance.tool;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.aliyun.tea.NameInMap;
|
|
|
import com.aliyun.tea.TeaConverter;
|
|
|
import com.aliyun.tea.TeaPair;
|
|
|
+import com.jdy.v7sdk.business.models.SaveResponse;
|
|
|
+import com.jdy.v7sdk.business.models.errorInfo;
|
|
|
import com.jdy.v7sdk.models.AccountGroupRequest;
|
|
|
import com.github.kevinsawicki.http.HttpRequest;
|
|
|
import lombok.Data;
|
|
|
@@ -10,8 +13,12 @@ import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.springblade.finance.TokenRequestQuery;
|
|
|
import org.springblade.finance.vojo.JDYitems;
|
|
|
|
|
|
+import java.io.Serializable;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
-
|
|
|
+/**
|
|
|
+ * 金蝶测试demo, 如果需要正式的,则需要替换
|
|
|
+ * */
|
|
|
public class JdyTool
|
|
|
{
|
|
|
|
|
|
@@ -42,7 +49,7 @@ public class JdyTool
|
|
|
String groupName = "ns-v7g6";//group.get("groupName");
|
|
|
String accessToken = accessTokenObject.accessToken;
|
|
|
|
|
|
- //金蝶云-星辰 官网API地址: https://open.jdy.com/#/files/api/detail?index=2&categrayId=1f51c576013945e2af68ef15d4245a48&id=525e704824d24b178ab466530456c037
|
|
|
+ //金蝶云-星辰 官网API地址: https://open.jdy.com/#/files/api/detail?index=2&categrayId=1f51c576013945e2af68ef15d4245a48&id=525e704824d24b178ab466530456c037
|
|
|
|
|
|
//用官方测试账号, 请求业务列表接口 试试
|
|
|
//String listUrl="http://api.kingdee.com/jdy/gl/voucher_list?access_token="+accessToken;
|
|
|
@@ -73,7 +80,7 @@ public class JdyTool
|
|
|
}
|
|
|
|
|
|
//测试-调用金蝶云官方账号的保存
|
|
|
- public static String testSaveVoucher (String url, String accountId, String groupName, List<JDYitems> jdYitems)
|
|
|
+ public static String testSaveVoucher (String url, String accountId, String groupName, List<JDYitems> jdYitems) throws Exception
|
|
|
{
|
|
|
HttpRequest httpRequest = new HttpRequest(url,"POST");
|
|
|
httpRequest.header("accountId",accountId);
|
|
|
@@ -83,15 +90,42 @@ public class JdyTool
|
|
|
JSONObject data=new JSONObject();
|
|
|
data.put("items",jdYitems);
|
|
|
httpRequest.send(data.toJSONString());
|
|
|
- System.out.println("请求结果===="+httpRequest.body().toString());
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(httpRequest.body());
|
|
|
+
|
|
|
+
|
|
|
+ String body = httpRequest.body().toString();
|
|
|
+ //获取返回对象
|
|
|
+ JDYSaveResponse saveResponse = JSONObject.parseObject(body, JDYSaveResponse.class);
|
|
|
+ //获取主表id
|
|
|
+ List<String> successPkIds = saveResponse.getData().get(0).getSuccessPkIds();
|
|
|
/*System.out.println("请求body===="+httpRequest.body().toString());
|
|
|
JSONObject result = JSONObject.parseObject(httpRequest.body());
|
|
|
return result.toJSONString();*/
|
|
|
- return null;
|
|
|
+ return successPkIds.toString().replace("[","").replace("]","");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Data
|
|
|
+ public static class JDYSaveResponse implements Serializable
|
|
|
+ {
|
|
|
+ private Boolean success;
|
|
|
+ private Boolean reachPlugin;
|
|
|
+ private List<SaveResponseData> data;
|
|
|
+ private String errorCode;
|
|
|
}
|
|
|
|
|
|
+ @Data
|
|
|
+ public static class SaveResponseData implements Serializable
|
|
|
+ {
|
|
|
+
|
|
|
+ public List<String> successPkIds;
|
|
|
+
|
|
|
+ public Boolean success;
|
|
|
|
|
|
+ public List<com.jdy.v7sdk.business.models.errorInfo> errorInfo;
|
|
|
+
|
|
|
+ public String message;
|
|
|
+
|
|
|
+ public String errorLevel;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|