|
@@ -0,0 +1,65 @@
|
|
|
+package com.malk.jianhui.service.impl;
|
|
|
+
|
|
|
+import com.google.gson.Gson;
|
|
|
+import com.kingdee.bos.webapi.entity.IdentifyInfo;
|
|
|
+import com.kingdee.bos.webapi.entity.RepoRet;
|
|
|
+import com.kingdee.bos.webapi.entity.SaveParam;
|
|
|
+import com.kingdee.bos.webapi.entity.SaveResult;
|
|
|
+import com.malk.jianhui.common.SeqHelper;
|
|
|
+import com.malk.jianhui.config.KDWebApiConf;
|
|
|
+import com.malk.jianhui.entity.Customer;
|
|
|
+import com.malk.jianhui.service.JianhuiService;
|
|
|
+import com.malk.server.common.McR;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import com.kingdee.bos.webapi.sdk.K3CloudApi;
|
|
|
+import static org.junit.Assert.fail;
|
|
|
+
|
|
|
+import java.io.*;
|
|
|
+import java.util.Properties;
|
|
|
+import java.util.UUID;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class JianhuiServiceImpl implements JianhuiService {
|
|
|
+ @Autowired
|
|
|
+ private KDWebApiConf kdWebApiConf;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ //保存采购订单
|
|
|
+ public McR savePurchaseOrder() {
|
|
|
+ //注意 1:此处不再使用参数形式传入用户名及密码等敏感信息,改为在登录配置文件中设置。
|
|
|
+ //注意 2:必须先配置第三方系统登录授权信息后,再进行业务操作,详情参考各语言版本SDK介绍中的登录配置文件说明。
|
|
|
+ //读取配置,初始化SDK
|
|
|
+ IdentifyInfo iden = new IdentifyInfo();
|
|
|
+ iden.setUserName(kdWebApiConf.getXKDApiUserName());
|
|
|
+ iden.setAppId(kdWebApiConf.getXKDApiAppID());
|
|
|
+ iden.setdCID(kdWebApiConf.getXKDApiAcctID());
|
|
|
+ iden.setAppSecret(kdWebApiConf.getXKDApiAppSec());
|
|
|
+ iden.setlCID(2052);
|
|
|
+ iden.setServerUrl(kdWebApiConf.getXKDApiServerUrl());
|
|
|
+
|
|
|
+ K3CloudApi client = new K3CloudApi(iden);
|
|
|
+ //请求参数,要求为json字符串
|
|
|
+ String jsonData = "{\"CreateOrgId\":0,\"Number\":\"\",\"Id\":\"\",\"IsSortBySeq\":\"false\"}";
|
|
|
+ try{
|
|
|
+ //业务对象标识
|
|
|
+ String formId = "PUR_PurchaseOrder";
|
|
|
+ //调用接口
|
|
|
+ String resultJson = client.view(formId,jsonData);
|
|
|
+
|
|
|
+ //用于记录结果
|
|
|
+ Gson gson = new Gson();
|
|
|
+ //对返回结果进行解析和校验
|
|
|
+ RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class);
|
|
|
+ if (repoRet.getResult().getResponseStatus().isIsSuccess()) {
|
|
|
+ System.out.printf("接口返回结果: %s%n", gson.toJson(repoRet.getResult()));
|
|
|
+ } else {
|
|
|
+ fail("接口返回结果: " + gson.toJson(repoRet.getResult().getResponseStatus()));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ fail(e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return McR.success();
|
|
|
+ }
|
|
|
+}
|