|
|
@@ -1,15 +1,20 @@
|
|
|
package org.springblade.finance.tool;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.aliyun.tea.TeaConverter;
|
|
|
import com.aliyun.tea.TeaPair;
|
|
|
-import com.jdy.v7sdk.business.models.MaterialListRequest;
|
|
|
import com.jdy.v7sdk.models.AccountGroupRequest;
|
|
|
+import com.github.kevinsawicki.http.HttpRequest;
|
|
|
+import lombok.Data;
|
|
|
+import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.springblade.finance.TokenRequestQuery;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
public class JdyTool
|
|
|
{
|
|
|
|
|
|
- public void test() throws Exception {
|
|
|
+ public static void test() throws Exception {
|
|
|
com.jdy.v7sdk.auth auth = new com.jdy.v7sdk.auth();
|
|
|
//登录参数
|
|
|
TokenRequestQuery tokenRequestQuery = TokenRequestQuery.build(TeaConverter.buildMap(
|
|
|
@@ -26,21 +31,119 @@ public class JdyTool
|
|
|
java.util.Map<String, Object> accountService = com.aliyun.teautil.Common.assertAsMap(accountGroups.get(0));
|
|
|
java.util.List<Object> groups = com.aliyun.teautil.Common.assertAsArray(accountService.get("accountGroups"));
|
|
|
java.util.Map<String, String> group = com.aliyun.teautil.Common.stringifyMapValue(com.aliyun.teautil.Common.assertAsMap(groups.get(1)));
|
|
|
- String accountId = group.get("accountId");
|
|
|
- String groupName = group.get("groupName");
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2022-1-5 已咨询官方人员, 目前是1.0演示版,1.0中财务没有凭证相关,2.0版本含有,目前代码还在完善,稍后还在更新
|
|
|
+ * 因为2.0 还没发布, 所以上面获取账套信息用官方java-SDK完成, 下面获取凭证无法通过sdk,改用api方式
|
|
|
+ * */
|
|
|
+ //用官方测试账号 测试数据, 账套名称: 金蝶开发者测试账套
|
|
|
+ String accountId = "1584244570835057173";//group.get("accountId");
|
|
|
+ String groupName = "ns-v7g6";//group.get("groupName");
|
|
|
String accessToken = accessTokenObject.accessToken;
|
|
|
- com.jdy.v7sdk.kernel kernel = new com.jdy.v7sdk.kernel(accessToken, accountId, groupName);
|
|
|
|
|
|
- com.jdy.v7sdk.business.basedata bd = new com.jdy.v7sdk.business.basedata(kernel);
|
|
|
- com.jdy.v7sdk.business.fi fd=new com.jdy.v7sdk.business.fi(kernel);
|
|
|
- com.jdy.v7sdk.business.scm sc=new com.jdy.v7sdk.business.scm(kernel);
|
|
|
+ //金蝶云-星辰 官网API地址: https://open.jdy.com/#/files/api/detail?index=2&categrayId=1f51c576013945e2af68ef15d4245a48&id=525e704824d24b178ab466530456c037
|
|
|
+ String url="http://api.kingdee.com/jdy/gl/voucher_list?access_token="+accessToken;
|
|
|
+ //用官方测试账号, 请求业务列表接口 试试
|
|
|
+ String s = testGetVoucherList(url, accountId, groupName);
|
|
|
+ //用官方测试账号, 请求业务列表保存接口 试试
|
|
|
+ String s1 = testSaveVoucher(url, accountId, groupName);
|
|
|
+
|
|
|
|
|
|
+ /* com.jdy.v7sdk.kernel kernel = new com.jdy.v7sdk.kernel(accessToken, accountId, groupName);
|
|
|
//获取商品列表示例
|
|
|
+ com.jdy.v7sdk.business.basedata bd = new com.jdy.v7sdk.business.basedata(kernel);
|
|
|
+
|
|
|
+ com.jdy.v7sdk.business.fi fi=new com.jdy.v7sdk.business.fi(kernel);
|
|
|
+ //获取财务-凭证列表
|
|
|
+
|
|
|
+
|
|
|
MaterialListRequest materialListRequest = MaterialListRequest.build(TeaConverter.buildMap(
|
|
|
));
|
|
|
java.util.Map<String, ?> response = bd.getMaterialList(materialListRequest);
|
|
|
|
|
|
- System.out.println("请求商品列表成功 response = " + response);
|
|
|
+ System.out.println("请求商品列表成功 response = " + response);*/
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //测试-调用金蝶云官方测试数据的凭证列表
|
|
|
+ public static String testGetVoucherList (String url,String accountId,String groupName)
|
|
|
+ {
|
|
|
+ HttpRequest httpRequest = new HttpRequest(url,"POST");
|
|
|
+ httpRequest.header("accountId",accountId);
|
|
|
+ httpRequest.header("groupName",groupName);
|
|
|
+ httpRequest.header("Content-Type","application/json");
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
+ data.put("page",1);
|
|
|
+ data.put("pagesize",50);
|
|
|
+ JSONObject map = new JSONObject();
|
|
|
+ map.put("requestData",data);
|
|
|
+ httpRequest.send(map.toJSONString());
|
|
|
+ System.out.println("请求body===="+httpRequest.body().toString());
|
|
|
+ JSONObject result = JSONObject.parseObject(httpRequest.body());
|
|
|
+ return result.toJSONString();
|
|
|
+ }
|
|
|
+
|
|
|
+ //测试-调用金蝶云官方账号的保存
|
|
|
+ public static String testSaveVoucher (String url,String accountId,String groupName)
|
|
|
+ {
|
|
|
+ HttpRequest httpRequest = new HttpRequest(url,"POST");
|
|
|
+ httpRequest.header("accountId",accountId);
|
|
|
+ httpRequest.header("groupName",groupName);
|
|
|
+ httpRequest.header("Content-Type","application/json");
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
+ data.put("page",1);
|
|
|
+ data.put("pagesize",50);
|
|
|
+ JSONObject map = new JSONObject();
|
|
|
+ map.put("requestData",data);
|
|
|
+ httpRequest.send(map.toJSONString());
|
|
|
+ System.out.println("请求body===="+httpRequest.body().toString());
|
|
|
+ JSONObject result = JSONObject.parseObject(httpRequest.body());
|
|
|
+ return result.toJSONString();
|
|
|
+ }
|
|
|
+
|
|
|
+ //凭证列表对象
|
|
|
+ @Data
|
|
|
+ public class items
|
|
|
+ {
|
|
|
+ //凭证日期 YYYY-MM-DD形式
|
|
|
+ private String date;
|
|
|
+ //分录列表
|
|
|
+ private List<entries> entries;
|
|
|
+ }
|
|
|
+
|
|
|
+ //分录列表
|
|
|
+ @Data
|
|
|
+ public class entries
|
|
|
+ {
|
|
|
+ //借贷方向 (1:借 ,-1:贷)
|
|
|
+ private String dc;
|
|
|
+ //摘要: 类似于备注
|
|
|
+ private String explanation;
|
|
|
+ //借方金额(本位币)
|
|
|
+ private String debitamount;
|
|
|
+ //贷方金额(本位币)
|
|
|
+ private String creditamount;
|
|
|
+ //科目id(必填)
|
|
|
+ private String account_id;
|
|
|
+ //科目编码
|
|
|
+ private String account_number;
|
|
|
+ //辅助核算列表
|
|
|
+ private List<assist> assist;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Data
|
|
|
+ private class assist
|
|
|
+ {
|
|
|
+ private String type;
|
|
|
+
|
|
|
+ private String bd_auxinfo_type_id;
|
|
|
+
|
|
|
+ private String id;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|