diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/config/KingdeeConfig.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/config/KingdeeConfig.java index 9ae3ddba..7eade754 100644 --- a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/config/KingdeeConfig.java +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/config/KingdeeConfig.java @@ -47,6 +47,11 @@ public class KingdeeConfig { */ public static String STK_MisDelivery = "STK_MisDelivery"; + /** + * 其他入库单formId + */ + public static String STK_MISCELLANEOUS = "STK_MISCELLANEOUS"; + /** * 京源项目 */ @@ -72,6 +77,11 @@ public class KingdeeConfig { */ public static JSONObject FBillTypeIDOtherOutStorage = new JSONObject(); + /** + * 单据类型-其他入库单 + */ + public static JSONObject FBillTypeIDOtherInStorage = new JSONObject(); + /** * 币别 */ @@ -122,6 +132,14 @@ public class KingdeeConfig { return FBillTypeIDOtherOutStorage; } + /** + * 单据类型-其他入库单 + */ + public static JSONObject getFBillTypeIDOtherInStorage() { + FBillTypeIDOtherInStorage.put("FNUMBER", "QTRKD01_SYS"); + return FBillTypeIDOtherInStorage; + } + /** * 币别 */ diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/controller/KingdeeErpSyncController.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/controller/KingdeeErpSyncController.java index 85ffbc5b..b44a6f60 100644 --- a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/controller/KingdeeErpSyncController.java +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/controller/KingdeeErpSyncController.java @@ -89,6 +89,21 @@ public class KingdeeErpSyncController { } } + + /** + * 其他入库单保存->提交->审核 + * @param params {"FMaterialId": "01150020","FDate": "2024-04-12 00:00:00","FUnitID": "zhi1","FStockId": "CK052","FAuxPropId": "304不锈钢滤帽","FQty": 4.0000,"FPrice": 20.3} + * @return { "msg": "{\"IsSuccess\":true,\"Errors\":[],\"SuccessEntitys\":[{\"Id\":\"100418\",\"Number\":\"QTRK000352\",\"DIndex\":0}]}", "code": 200} + */ + @PostMapping(("/saveOtherInStorage")) + public AjaxResult saveOtherInStorage(@RequestBody String params) { + try { + return AjaxResult.success(kingdeeErpService.saveOtherInStorage(params)); + } catch (Exception e) { + return AjaxResult.error(e.toString()); + } + } + /** * ERP通用保存接口 * diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/impl/KingdeeErpService.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/impl/KingdeeErpService.java index 8aa0d0f8..37a25b52 100644 --- a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/impl/KingdeeErpService.java +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/impl/KingdeeErpService.java @@ -449,13 +449,13 @@ public class KingdeeErpService { //其他出库单提交 String commitResult = this.genericCommitInterface(json); RepoRet commitRepoRet = gson.fromJson(commitResult, RepoRet.class); - if (!commitRepoRet.getResult().getResponseStatus().isIsSuccess()){ + if (!commitRepoRet.getResult().getResponseStatus().isIsSuccess()) { logger.error("saveOtherOutStorage|请求参数:" + json.toJSONString() + "|返回结果:" + commitRepoRet); } //其他出库单审核 String auditResult = this.genericAuditInterface(json); RepoRet auditRepoRet = gson.fromJson(auditResult, RepoRet.class); - if (!auditRepoRet.getResult().getResponseStatus().isIsSuccess()){ + if (!auditRepoRet.getResult().getResponseStatus().isIsSuccess()) { logger.error("saveOtherOutStorage|请求参数:" + json.toJSONString() + "|返回结果:" + commitRepoRet); } } @@ -465,4 +465,99 @@ public class KingdeeErpService { return e.getMessage(); } } + + /** + * 其他入库单保存->提交->审核 + * + * @param params + * @return + */ + public String saveOtherInStorage(String params) { + Gson gsonParams = new Gson(); + JSONObject objectParams = gsonParams.fromJson(params, JSONObject.class); + JSONObject model = new JSONObject(); + JSONObject FEntity = new JSONObject(); + String FDate = (String) objectParams.get("FDate");//日期 + String FMaterialId = (String) objectParams.get("FMaterialId");//物料编码 + String FAuxPropId = (String) objectParams.get("FAuxPropId");//物料辅助属性 + String FUnitID = (String) objectParams.get("FUnitID");//单位 + Double FQty = (Double) objectParams.get("FQty");//实发数量 + Double FPrice = (Double) objectParams.get("FPrice");//成本价 + String FStockId = (String) objectParams.get("FStockId");//仓库 + try { + //业务对象标识 + String formId = KingdeeConfig.STK_MISCELLANEOUS; + //调用接口 + JSONObject FMaterialIdObject = new JSONObject(); + FMaterialIdObject.put("FNumber", FMaterialId); + FEntity.put("FMaterialId", FMaterialIdObject); //物料编码(必填项) + JSONObject FUnitIDObject = new JSONObject(); + FUnitIDObject.put("FNumber", FUnitID); + FEntity.put("FUnitID", FUnitIDObject); //单位(必填项) + FEntity.put("FQty", FQty); //实发数量 + FEntity.put("FPrice", FPrice); //成本价 + FEntity.put("FBaseUnitId", FUnitIDObject); //基本单位(必填项) + JSONObject FStockIdObject = new JSONObject(); + FStockIdObject.put("FNumber", FStockId); + FEntity.put("FStockId", FStockIdObject); //发货仓库 + FEntity.put("FOWNERTYPEID", "BD_OwnerOrg"); //货主类型(必填项) + FEntity.put("FOWNERID", KingdeeConfig.getFApplicationOrgId()); //货主(必填项) + JSONObject FStockStatusIdObject = new JSONObject(); + FStockStatusIdObject.put("FNumber", "KCZT01_SYS"); + FEntity.put("FStockStatusId", FStockStatusIdObject); //库存状态(必填项) + FEntity.put("FKeeperTypeId", "BD_KeeperOrg"); //保管者类型(必填项) + FEntity.put("FKeeperId", KingdeeConfig.getFApplicationOrgId()); //保管者(必填项) + JSONObject FAuxPropIdObject = new JSONObject(); + FAuxPropIdObject.put("FAUXPROPID__FF100001", FAuxPropId); + FEntity.put("FAuxPropId", FAuxPropIdObject); //辅助属性 + + ArrayList entityList = new ArrayList<>(); + entityList.add(FEntity); + model.put("FEntity", entityList); + JSONObject data = new JSONObject(); + model.put("FID", KingdeeConfig.FID); + model.put("FBillTypeID", KingdeeConfig.getFBillTypeIDOtherInStorage()); //单据类型(必填项) + model.put("FStockOrgId", KingdeeConfig.getFApplicationOrgId()); //收料组织(必填项) + model.put("FStockDirect", "GENERAL"); //库存方向(必填项) + model.put("FDate", FDate); //日期(必填项) + model.put("FOwnerTypeIdHead", "BD_OwnerOrg"); //货主类型(必填项) + model.put("FOwnerIdHead", KingdeeConfig.getFApplicationOrgId()); //货主(必填项) + JSONObject FDeptIdObject = new JSONObject(); + FDeptIdObject.put("FNumber", "BM000001"); + model.put("FDeptId", FDeptIdObject); //部门 + 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("saveOtherInStorage接口调用成功|请求参数:" + saveParams + "|返回结果:" + resultJson); + RepoStatus responseStatus = repoRet.getResult().getResponseStatus(); + if (responseStatus.isIsSuccess()) { + JSONObject json = new JSONObject(); + json.put("formId", KingdeeConfig.STK_MISCELLANEOUS); + 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("saveOtherInStorage|请求参数:" + json.toJSONString() + "|返回结果:" + commitRepoRet); + } + //其他入库单审核 + String auditResult = this.genericAuditInterface(json); + RepoRet auditRepoRet = gson.fromJson(auditResult, RepoRet.class); + if (!auditRepoRet.getResult().getResponseStatus().isIsSuccess()){ + logger.error("saveOtherInStorage|请求参数:" + json.toJSONString() + "|返回结果:" + commitRepoRet); + } + } + return gson.toJson(responseStatus); + } catch (Exception e) { + logger.error("saveOtherInStorage|params:" + params + "|Exception:" + e); + return e.getMessage(); + } + } + + }