|
|
@@ -3,24 +3,41 @@ package com.malk.zhiwei.service.impl;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.google.gson.Gson;
|
|
|
+import com.google.gson.JsonObject;
|
|
|
+import com.kingdee.bos.webapi.entity.IdentifyInfo;
|
|
|
+import com.kingdee.bos.webapi.entity.RepoRet;
|
|
|
+import com.kingdee.bos.webapi.sdk.K3CloudApi;
|
|
|
import com.malk.server.aliwork.YDConf;
|
|
|
import com.malk.server.aliwork.YDParam;
|
|
|
+import com.malk.server.common.McR;
|
|
|
+import com.malk.server.dingtalk.DDConf;
|
|
|
import com.malk.service.aliwork.YDClient;
|
|
|
-import com.malk.service.aliwork.YDService;
|
|
|
import com.malk.utils.PublicUtil;
|
|
|
import com.malk.utils.UtilMap;
|
|
|
+import com.malk.zhiwei.config.KDWebApiConf;
|
|
|
+import com.malk.zhiwei.entity.CustomerModel;
|
|
|
+import com.malk.zhiwei.entity.FNumber;
|
|
|
import com.malk.zhiwei.service.ZwService;
|
|
|
+import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import javax.rmi.CORBA.Util;
|
|
|
import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
public class ZwServiceImpl implements ZwService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private KDWebApiConf kdWebApiConf;
|
|
|
+ @Autowired
|
|
|
+ private YDConf ydConf;
|
|
|
+ @Autowired
|
|
|
+ private DDConf ddConf;
|
|
|
+
|
|
|
private static String ERP_URL="http://10.0.0.208:80";
|
|
|
private static String ERP_NAME="064";
|
|
|
private static String ERP_PASSWORD="";
|
|
|
@@ -190,4 +207,77 @@ public class ZwServiceImpl implements ZwService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @SneakyThrows
|
|
|
+ @Override
|
|
|
+ public McR savecustomer(String instanceId) throws JsonProcessingException {
|
|
|
+ log.info("客户宜搭实例id:{}",instanceId);
|
|
|
+ Map data = (Map) ydClient.queryData(YDParam.builder().formInstId(instanceId)
|
|
|
+ .appType(ydConf.getAppType()).systemToken(ydConf.getSystemToken())
|
|
|
+ .userId(ddConf.getOperator()).build(), YDConf.FORM_QUERY.retrieve_id).getFormData();
|
|
|
+
|
|
|
+ FNumber zd = new FNumber(data.get("selectField_mnft99ue").toString());//终端
|
|
|
+ FNumber syb = new FNumber(data.get("selectField_mnft99ud").toString());//事业部
|
|
|
+ FNumber hy = new FNumber(data.get("textField_mnfujcak").toString());//行业
|
|
|
+ FNumber sktj = new FNumber(data.get("textField_mnfujcaf").toString());//收款条件
|
|
|
+ FNumber xsbm = new FNumber(data.get("textField_mnfujcac").toString());//销售部门
|
|
|
+ FNumber xsy = new FNumber(data.get("textField_mnfujcad").toString());//销售员
|
|
|
+ String kh = data.get("textField_lqanqe6j").toString();// 客户
|
|
|
+ Object empObj = data.get("employeeField_mnft99uj");
|
|
|
+ String ywy = "";//业务员
|
|
|
+ if (empObj instanceof JSONArray) {
|
|
|
+ JSONArray empArray = (JSONArray) empObj;
|
|
|
+ if (!empArray.isEmpty()) {
|
|
|
+ ywy = empArray.getString(0);
|
|
|
+ }
|
|
|
+ } else if (empObj != null) {
|
|
|
+ ywy = empObj.toString();
|
|
|
+ }
|
|
|
+ String nsdjhc = data.get("textField_llujklkq").toString();//纳税登记号
|
|
|
+ CustomerModel customerModel = new CustomerModel(kh,sktj,hy,syb,zd,ywy,nsdjhc,xsbm,xsy);
|
|
|
+ return saveToAudit("BD_Customer", customerModel);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private McR saveToAudit(String formid, Object object) throws Exception {
|
|
|
+ JSONObject resultObj = new JSONObject();
|
|
|
+ K3CloudApi client = new K3CloudApi(initIden());
|
|
|
+ String result=client.save(formid,JSONObject.toJSONString(UtilMap.map("Model",object)));
|
|
|
+ resultObj.put("save",result);
|
|
|
+ Gson gson = new Gson();
|
|
|
+ RepoRet sRet = gson.fromJson(result, RepoRet.class);
|
|
|
+ if (sRet.isSuccessfully()) {
|
|
|
+ JsonObject jsonData = new JsonObject();
|
|
|
+ jsonData.addProperty("Ids", sRet.getResult().getId());
|
|
|
+ String result2=client.submit(formid, jsonData.toString());
|
|
|
+ resultObj.put("save",result2);
|
|
|
+ RepoRet sRet2 = gson.fromJson(result, RepoRet.class);
|
|
|
+ if (sRet2.isSuccessfully()) {
|
|
|
+ JsonObject jsonData3 = new JsonObject();
|
|
|
+ jsonData3.addProperty("Ids", sRet2.getResult().getId());
|
|
|
+ String result3 = client.audit(formid, jsonData3.toString());
|
|
|
+ RepoRet repoRet3 = gson.fromJson(result3, RepoRet.class);
|
|
|
+ if (repoRet3.getResult().getResponseStatus().isIsSuccess()) {
|
|
|
+ log.info("审批通过,新增完成");
|
|
|
+ return McR.success(resultObj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return McR.error("203",JSONObject.toJSONString(resultObj));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private IdentifyInfo initIden(){
|
|
|
+ //注意 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.setServerUrl(kdWebApiConf.getXKDApiServerUrl());
|
|
|
+
|
|
|
+ return iden;
|
|
|
+ }
|
|
|
}
|