|
|
|
@ -3,6 +3,7 @@ package com.hw.jindie.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
|
|
|
|
import com.hw.common.core.utils.StringUtils;
|
|
|
|
|
import com.hw.jindie.config.KingdeeConfig;
|
|
|
|
|
import com.kingdee.bos.webapi.entity.RepoRet;
|
|
|
|
|
import com.kingdee.bos.webapi.entity.RepoStatus;
|
|
|
|
@ -43,6 +44,7 @@ public class KingdeeErpService {
|
|
|
|
|
JSONObject model = new JSONObject();
|
|
|
|
|
JSONObject FEntity = new JSONObject();
|
|
|
|
|
String FMaterialId = (String) objectParams.get("FMaterialId");//物料编码
|
|
|
|
|
String FUnitId = (String) objectParams.get("FUnitId");//单位
|
|
|
|
|
// String FMaterialDesc = (String) objectParams.get("FMaterialDesc");//物料说明
|
|
|
|
|
Double FReqQty = (Double) objectParams.get("FReqQty");//采购数量
|
|
|
|
|
try {
|
|
|
|
@ -54,12 +56,13 @@ public class KingdeeErpService {
|
|
|
|
|
FMaterialIdObject.put("FNumber", FMaterialId);
|
|
|
|
|
FEntity.put("FMaterialId", FMaterialIdObject); //物料编码(必填项)
|
|
|
|
|
FEntity.put("FPurchaseOrgId", KingdeeConfig.getFApplicationOrgId()); //采购组织(必填项)
|
|
|
|
|
JSONObject FUnitId = new JSONObject();
|
|
|
|
|
FUnitId.put("FNumber", "m");
|
|
|
|
|
FEntity.put("FUnitId", FUnitId); //申请单位(必填项)
|
|
|
|
|
FEntity.put("FPriceUnitId", FUnitId); //计价单位(必填项)
|
|
|
|
|
FEntity.put("FREQSTOCKUNITID", FUnitId); //库存单位(必填项)
|
|
|
|
|
JSONObject FUnitIdObject = new JSONObject();
|
|
|
|
|
FUnitIdObject.put("FNumber", FUnitId);
|
|
|
|
|
FEntity.put("FUnitId", FUnitIdObject); //申请单位(必填项)
|
|
|
|
|
FEntity.put("FPriceUnitId", FUnitIdObject); //计价单位(必填项)
|
|
|
|
|
FEntity.put("FREQSTOCKUNITID", FUnitIdObject); //库存单位(必填项)
|
|
|
|
|
FEntity.put("FReqQty", FReqQty); //申请数量
|
|
|
|
|
|
|
|
|
|
// FEntity.put("FMaterialDesc", FMaterialDesc); //物料说明
|
|
|
|
|
// FEntity.put("FReceiveOrgId", KingdeeConfig.getFApplicationOrgId()); //收料组织
|
|
|
|
|
// FEntity.put("FApproveQty", FReqQty); //批准数量
|
|
|
|
@ -81,7 +84,15 @@ public class KingdeeErpService {
|
|
|
|
|
ArrayList<JSONObject> entityList = new ArrayList<>();
|
|
|
|
|
entityList.add(FEntity);
|
|
|
|
|
model.put("FEntity", entityList);
|
|
|
|
|
String saveParams = this.saveGenericAssemblyEntity(model);
|
|
|
|
|
JSONObject data = new JSONObject();
|
|
|
|
|
model.put("FID", KingdeeConfig.FID);
|
|
|
|
|
model.put("F_TOND_Base", KingdeeConfig.getF_TOND_Base()); //京源项目(必填项)
|
|
|
|
|
model.put("FBillTypeID", KingdeeConfig.getFBillTypeIDPurchase()); //单据类型(必填项)
|
|
|
|
|
model.put("FApplicationDate", KingdeeConfig.FApplicationDate); //申请日期(必填项)
|
|
|
|
|
model.put("FRequestType", KingdeeConfig.FRequestType); //申请类型(必填项)
|
|
|
|
|
model.put("FApplicationOrgId", KingdeeConfig.getFApplicationOrgId()); //申请组织(必填项)
|
|
|
|
|
data.put("Model", model);
|
|
|
|
|
String saveParams = data.toJSONString();
|
|
|
|
|
String resultJson = client.save(formId, saveParams);
|
|
|
|
|
// String resultJson = "{\"Result\":{\"ResponseStatus\":{\"IsSuccess\":true,\"Errors\":[],\"SuccessEntitys\":[{\"Id\":154903,\"Number\":\"CGSQ010788\",\"DIndex\":0}],\"SuccessMessages\":[],\"MsgCode\":0},\"Id\":154903,\"Number\":\"CGSQ010788\",\"NeedReturnData\":[{}]}}";
|
|
|
|
|
|
|
|
|
@ -96,9 +107,17 @@ public class KingdeeErpService {
|
|
|
|
|
json.put("formId", KingdeeConfig.PUR_Requisition);
|
|
|
|
|
json.put("Ids", repoRet.getResult().getId());
|
|
|
|
|
//采购申请单提交
|
|
|
|
|
// String commitResult = this.genericCommitInterface(json);
|
|
|
|
|
String commitResult = this.genericCommitInterface(json);
|
|
|
|
|
RepoRet commitRepoRet = gson.fromJson(commitResult, RepoRet.class);
|
|
|
|
|
if (!commitRepoRet.getResult().getResponseStatus().isIsSuccess()) {
|
|
|
|
|
logger.error("singleSavePurchaseRequisitionCommitException|请求参数:" + json.toJSONString() + "|返回结果:" + commitRepoRet);
|
|
|
|
|
}
|
|
|
|
|
//采购申请单审核
|
|
|
|
|
// String auditResult = this.genericAuditInterface(json);
|
|
|
|
|
String auditResult = this.genericAuditInterface(json);
|
|
|
|
|
RepoRet auditRepoRet = gson.fromJson(auditResult, RepoRet.class);
|
|
|
|
|
if (!auditRepoRet.getResult().getResponseStatus().isIsSuccess()) {
|
|
|
|
|
logger.error("singleSavePurchaseRequisitionAuditException|请求参数:" + json.toJSONString() + "|返回结果:" + commitRepoRet);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return gson.toJson(responseStatus);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
@ -107,55 +126,6 @@ public class KingdeeErpService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 保存通用组装实体
|
|
|
|
|
*
|
|
|
|
|
* @param model 模型
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public String saveGenericAssemblyEntity(JSONObject model) {
|
|
|
|
|
// 组装数据json
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
result.put("NeedUpDateFields", new ArrayList<>());
|
|
|
|
|
result.put("NeedReturnFields", new ArrayList<>());
|
|
|
|
|
result.put("IsDeleteEntry", "true");
|
|
|
|
|
result.put("SubSystemId", "");
|
|
|
|
|
result.put("IsVerifyBaseDataField", "false");
|
|
|
|
|
result.put("IsEntryBatchFill", "true");
|
|
|
|
|
result.put("ValidateFlag", "true");
|
|
|
|
|
result.put("NumberSearch", "true");
|
|
|
|
|
result.put("IsAutoAdjustField", "false");
|
|
|
|
|
result.put("InterationFlags", "");
|
|
|
|
|
result.put("IgnoreInterationFlag", "");
|
|
|
|
|
result.put("IsControlPrecision", "false");
|
|
|
|
|
result.put("ValidateRepeatJson", "false");
|
|
|
|
|
|
|
|
|
|
model.put("FID", KingdeeConfig.FID);
|
|
|
|
|
model.put("FBillTypeID", KingdeeConfig.getFBillTypeIDPurchase()); //单据类型(必填项)
|
|
|
|
|
model.put("FApplicationDate", KingdeeConfig.FApplicationDate); //申请日期(必填项)
|
|
|
|
|
model.put("FRequestType", KingdeeConfig.FRequestType); //申请类型(必填项)
|
|
|
|
|
model.put("FApplicationOrgId", KingdeeConfig.getFApplicationOrgId()); //申请组织(必填项)
|
|
|
|
|
model.put("F_TOND_Base", KingdeeConfig.getF_TOND_Base()); //京源项目(必填项)
|
|
|
|
|
// model.put("FCurrencyId", KingdeeConfig.getFCurrencyId());
|
|
|
|
|
// model.put("FExchangeTypeId", KingdeeConfig.getFExchangeTypeId());
|
|
|
|
|
// model.put("FISPRICEEXCLUDETAX", true); //价外税
|
|
|
|
|
// model.put("FIsConvert", false); //是否是单据转换
|
|
|
|
|
// model.put("FACCTYPE", "Q"); //验收方式
|
|
|
|
|
// JSONObject FMobBillHead = new JSONObject();
|
|
|
|
|
// FMobBillHead.put("FIsMobBill", false);
|
|
|
|
|
// FMobBillHead.put("FMobIsPending", false);
|
|
|
|
|
// model.put("FMobBillHead", FMobBillHead); //移动单据
|
|
|
|
|
|
|
|
|
|
result.put("Model", model);
|
|
|
|
|
try {
|
|
|
|
|
return result.toJSONString();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ERP通用提交接口
|
|
|
|
|
*
|
|
|
|
@ -176,10 +146,8 @@ public class KingdeeErpService {
|
|
|
|
|
// requestParams.put("UseBatControlTimes", "false");
|
|
|
|
|
// requestParams.put("UseOrgId", 0);
|
|
|
|
|
//调用接口
|
|
|
|
|
String s = requestParams.toJSONString();
|
|
|
|
|
System.out.println(s);
|
|
|
|
|
String submit = client.submit(formId, requestParams.toJSONString());
|
|
|
|
|
logger.error("genericCommitInterface|formId:" + formId + "|请求参数:" + requestParams.toJSONString() + "|返回结果:" + submit);
|
|
|
|
|
logger.info("genericCommitInterface|formId:" + formId + "|请求参数:" + requestParams.toJSONString() + "|返回结果:" + submit);
|
|
|
|
|
return submit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -196,10 +164,116 @@ public class KingdeeErpService {
|
|
|
|
|
requestParams.put("Ids", params.get("Ids"));//单据内码集合
|
|
|
|
|
//调用接口
|
|
|
|
|
String audit = client.audit(formId, requestParams.toJSONString());
|
|
|
|
|
logger.error("genericAuditInterface|formId:" + formId + "|请求参数:" + requestParams.toJSONString() + "|返回结果:" + audit);
|
|
|
|
|
logger.info("genericAuditInterface|formId:" + formId + "|请求参数:" + requestParams.toJSONString() + "|返回结果:" + audit);
|
|
|
|
|
return audit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 单一采购入库
|
|
|
|
|
* 保存->提交->审核
|
|
|
|
|
*
|
|
|
|
|
* @param params
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public String savePurchaseStorage(String params) {
|
|
|
|
|
Gson gsonParams = new Gson();
|
|
|
|
|
JSONObject objectParams = gsonParams.fromJson(params, JSONObject.class);
|
|
|
|
|
JSONObject model = new JSONObject();
|
|
|
|
|
JSONObject FEntity = new JSONObject();
|
|
|
|
|
String FMaterialId = (String) objectParams.get("FMaterialId");//物料编码
|
|
|
|
|
String FAuxPropId = (String) objectParams.get("FAuxPropId");//物料辅助属性
|
|
|
|
|
String FSrcBillNo = (String) objectParams.get("FSrcBillNo");//源单编号
|
|
|
|
|
String FUnitID = (String) objectParams.get("FUnitID");//单位
|
|
|
|
|
String FDate = (String) objectParams.get("FDate");//物料编码
|
|
|
|
|
Double FRealQty = (Double) objectParams.get("FRealQty");//实收数量
|
|
|
|
|
String FStockId = (String) objectParams.get("FStockId");//仓库
|
|
|
|
|
String F_TOND_Base = "JY(NT)-SA-XS-2020-0039";//京源项目
|
|
|
|
|
try {
|
|
|
|
|
//业务对象标识
|
|
|
|
|
String formId = KingdeeConfig.STK_InStock;
|
|
|
|
|
//调用接口
|
|
|
|
|
FEntity.put("FOWNERID", KingdeeConfig.getFApplicationOrgId()); //货主(必填项)
|
|
|
|
|
JSONObject FPriceUnitIDObject = new JSONObject();
|
|
|
|
|
FPriceUnitIDObject.put("FNumber", FUnitID);
|
|
|
|
|
FEntity.put("FUnitID", FPriceUnitIDObject); //库存单位(必填项)
|
|
|
|
|
FEntity.put("FOWNERTYPEID", "BD_OwnerOrg"); //货主类型(必填项)
|
|
|
|
|
FEntity.put("FRemainInStockUnitId", FPriceUnitIDObject); //采购单位(必填项)
|
|
|
|
|
JSONObject FMaterialIdObject = new JSONObject();
|
|
|
|
|
FMaterialIdObject.put("FNumber", FMaterialId);
|
|
|
|
|
FEntity.put("FMaterialId", FMaterialIdObject); //物料编码(必填项)
|
|
|
|
|
FEntity.put("FPriceUnitID", FPriceUnitIDObject); //计价单位(必填项)
|
|
|
|
|
FEntity.put("FRealQty", FRealQty); //实收数量
|
|
|
|
|
JSONObject FStockIdObject = new JSONObject();
|
|
|
|
|
FStockIdObject.put("FNumber", FStockId);
|
|
|
|
|
FEntity.put("FStockId", FStockIdObject); //仓库
|
|
|
|
|
JSONObject FAuxPropIdObject = new JSONObject();
|
|
|
|
|
FAuxPropIdObject.put("FAUXPROPID__FF100001", FAuxPropId);
|
|
|
|
|
FEntity.put("FAuxPropId", FAuxPropIdObject); //辅助属性
|
|
|
|
|
FEntity.put("FSrcBillNo", FSrcBillNo); //源单编号
|
|
|
|
|
|
|
|
|
|
/* ArrayList<JSONObject> linkList = new ArrayList<>();
|
|
|
|
|
JSONObject linkObject = new JSONObject();
|
|
|
|
|
linkObject.put("FInStockEntry_Link_FRuleId", "PUR_PurchaseOrder-STK_InStock"); //上游单据和下游单据之间的转换规则
|
|
|
|
|
linkObject.put("FInStockEntry_Link_FSTableName", "t_PUR_POOrderEntry"); //源单(上游单据:对应的数据库表名称)
|
|
|
|
|
linkObject.put("FInStockEntry_Link_FSBillId", "108022"); //源单单据内码(上游单据:单据内码)
|
|
|
|
|
linkObject.put("FInStockEntry_Link_FSId", "165252"); //源单单据行内码(上游单据:单据行内码)
|
|
|
|
|
linkList.add(linkObject);
|
|
|
|
|
FEntity.put("FInStockEntry_Link", linkList);*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ArrayList<JSONObject> entityList = new ArrayList<>();
|
|
|
|
|
entityList.add(FEntity);
|
|
|
|
|
model.put("FInStockEntry", entityList);
|
|
|
|
|
model.put("FID", KingdeeConfig.FID);
|
|
|
|
|
JSONObject data = new JSONObject();
|
|
|
|
|
model.put("FID", KingdeeConfig.FID);
|
|
|
|
|
// model.put("FBusinessType", ""); //业务类型(必填项)
|
|
|
|
|
// model.put("FOwnerTypeIdHead", ""); //货主类型(必填项)
|
|
|
|
|
model.put("FBillTypeID", KingdeeConfig.getFBillTypeIDStorage()); //单据类型(必填项)
|
|
|
|
|
model.put("FStockOrgId", KingdeeConfig.getFApplicationOrgId()); //收料组织(必填项)
|
|
|
|
|
model.put("FOwnerIdHead", KingdeeConfig.getFApplicationOrgId()); //货主(必填项)
|
|
|
|
|
model.put("FPurchaseOrgId", KingdeeConfig.getFApplicationOrgId()); //采购组织(必填项)
|
|
|
|
|
model.put("FDate", FDate); //入库日期(必填项)
|
|
|
|
|
JSONObject F_TOND_BaseObject = new JSONObject();
|
|
|
|
|
F_TOND_BaseObject.put("FNUMBER", F_TOND_Base);
|
|
|
|
|
model.put("F_TOND_Base", F_TOND_BaseObject); //京源项目(必填项)
|
|
|
|
|
JSONObject FSupplierId = new JSONObject();
|
|
|
|
|
FSupplierId.put("FNumber", "VEN04969");
|
|
|
|
|
model.put("FSupplierId", FSupplierId); //供应商(必填项)
|
|
|
|
|
data.put("Model", model);
|
|
|
|
|
String saveParams = data.toJSONString();
|
|
|
|
|
String resultJson = client.save(formId, saveParams);
|
|
|
|
|
|
|
|
|
|
//用于记录结果
|
|
|
|
|
Gson gson = new Gson();
|
|
|
|
|
//对返回结果进行解析和校验
|
|
|
|
|
RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class);
|
|
|
|
|
logger.info("savePurchaseStorage接口调用成功|请求参数:" + saveParams + "|返回结果:" + resultJson);
|
|
|
|
|
RepoStatus responseStatus = repoRet.getResult().getResponseStatus();
|
|
|
|
|
if (responseStatus.isIsSuccess()) {
|
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
|
json.put("formId", KingdeeConfig.STK_InStock);
|
|
|
|
|
json.put("Ids", repoRet.getResult().getId());
|
|
|
|
|
//采购入库单提交
|
|
|
|
|
String commitResult = this.genericCommitInterface(json);
|
|
|
|
|
RepoRet commitRepoRet = gson.fromJson(commitResult, RepoRet.class);
|
|
|
|
|
if (!commitRepoRet.getResult().getResponseStatus().isIsSuccess()){
|
|
|
|
|
logger.error("savePurchaseStorage|请求参数:" + json.toJSONString() + "|返回结果:" + commitRepoRet);
|
|
|
|
|
}
|
|
|
|
|
//采购入库单审核
|
|
|
|
|
String auditResult = this.genericAuditInterface(json);
|
|
|
|
|
RepoRet auditRepoRet = gson.fromJson(auditResult, RepoRet.class);
|
|
|
|
|
if (!auditRepoRet.getResult().getResponseStatus().isIsSuccess()){
|
|
|
|
|
logger.error("savePurchaseStorage|请求参数:" + json.toJSONString() + "|返回结果:" + commitRepoRet);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return gson.toJson(responseStatus);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("savePurchaseStorage|params:" + params + "|Exception:" + e);
|
|
|
|
|
return e.getMessage();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ERP通用查看接口
|
|
|
|
|
*
|
|
|
|
@ -217,6 +291,54 @@ public class KingdeeErpService {
|
|
|
|
|
return audit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 保存通用组装实体
|
|
|
|
|
*
|
|
|
|
|
* @param model 模型
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public String saveGenericAssemblyEntity(JSONObject model) {
|
|
|
|
|
// 组装数据json
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
// result.put("NeedUpDateFields", new ArrayList<>());
|
|
|
|
|
// result.put("NeedReturnFields", new ArrayList<>());
|
|
|
|
|
// result.put("IsDeleteEntry", "true");
|
|
|
|
|
// result.put("SubSystemId", "");
|
|
|
|
|
// result.put("IsVerifyBaseDataField", "false");
|
|
|
|
|
// result.put("IsEntryBatchFill", "true");
|
|
|
|
|
// result.put("ValidateFlag", "true");
|
|
|
|
|
// result.put("NumberSearch", "true");
|
|
|
|
|
// result.put("IsAutoAdjustField", "false");
|
|
|
|
|
// result.put("InterationFlags", "");
|
|
|
|
|
// result.put("IgnoreInterationFlag", "");
|
|
|
|
|
// result.put("IsControlPrecision", "false");
|
|
|
|
|
// result.put("ValidateRepeatJson", "false");
|
|
|
|
|
|
|
|
|
|
// model.put("FID", KingdeeConfig.FID);
|
|
|
|
|
// model.put("FBillTypeID", KingdeeConfig.getFBillTypeIDPurchase()); //单据类型(必填项)
|
|
|
|
|
// model.put("FApplicationDate", KingdeeConfig.FApplicationDate); //申请日期(必填项)
|
|
|
|
|
// model.put("FRequestType", KingdeeConfig.FRequestType); //申请类型(必填项)
|
|
|
|
|
// model.put("FApplicationOrgId", KingdeeConfig.getFApplicationOrgId()); //申请组织(必填项)
|
|
|
|
|
// model.put("F_TOND_Base", KingdeeConfig.getF_TOND_Base()); //京源项目(必填项)
|
|
|
|
|
|
|
|
|
|
// model.put("FCurrencyId", KingdeeConfig.getFCurrencyId());
|
|
|
|
|
// model.put("FExchangeTypeId", KingdeeConfig.getFExchangeTypeId());
|
|
|
|
|
// model.put("FISPRICEEXCLUDETAX", true); //价外税
|
|
|
|
|
// model.put("FIsConvert", false); //是否是单据转换
|
|
|
|
|
// model.put("FACCTYPE", "Q"); //验收方式
|
|
|
|
|
// JSONObject FMobBillHead = new JSONObject();
|
|
|
|
|
// FMobBillHead.put("FIsMobBill", false);
|
|
|
|
|
// FMobBillHead.put("FMobIsPending", false);
|
|
|
|
|
// model.put("FMobBillHead", FMobBillHead); //移动单据
|
|
|
|
|
result.put("Model", model);
|
|
|
|
|
try {
|
|
|
|
|
return result.toJSONString();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 测试组装实体
|
|
|
|
|
*
|
|
|
|
@ -229,4 +351,22 @@ public class KingdeeErpService {
|
|
|
|
|
System.out.println(result);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ERP通用保存接口
|
|
|
|
|
*
|
|
|
|
|
* @param params
|
|
|
|
|
* @param formId
|
|
|
|
|
* @return
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public String genericSaveInterface(JSONObject params, String formId) throws Exception {
|
|
|
|
|
if (StringUtils.isEmpty(formId)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
//调用接口
|
|
|
|
|
String save = client.save(formId, params.toJSONString());
|
|
|
|
|
System.out.println(("genericSaveInterface|formId:" + formId + "|请求参数:" + params.toJSONString() + "|返回结果:" + save));
|
|
|
|
|
return save;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|