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 a11c012..853215d 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 @@ -127,7 +127,7 @@ public class KingdeeErpSyncController { /** - * 单一采购申请单保存->提交->审核 + * 采购申请单多物料->提交->审核 * * @param params {"FMaterialId": "040200050162","FMaterialDesc": "UPVC直管","FReqQty": 20} * @return {"msg": "{"IsSuccess": true,"Errors": [],"SuccessEntitys": [{"Id": "154898","Number": "CGSQ010785","DIndex": 0}]}", "code": 200} 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 a981b14..240b9b0 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 @@ -1,6 +1,7 @@ package com.hw.jindie.service.impl; +import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.alibaba.nacos.shaded.com.google.gson.Gson; import com.hw.common.core.utils.StringUtils; @@ -12,6 +13,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.util.ArrayList; @@ -33,39 +35,47 @@ public class KingdeeErpService { /** - * 单一采购申请单保存->提交->审核 + * 采购申请单多物料保存->提交->审核 * * @param params * @return */ public String singleSavePurchaseRequisition(String params) { Gson gsonParams = new Gson(); - JSONObject objectParams = gsonParams.fromJson(params, JSONObject.class); + JSONArray jsonArray = gsonParams.fromJson(params, JSONArray.class); JSONObject model = new JSONObject(); - JSONObject FEntity = new JSONObject(); - String FMaterialId = (String) objectParams.get("FMaterialId");//物料编码 - String FUnitId = (String) objectParams.get("FUnitId");//单位 - String FPriceUnitId = (String) objectParams.get("FPriceUnitId");//计价单位 - String FMaterialDesc = (String) objectParams.get("FMaterialDesc");//物料说明 - Double FReqQty = (Double) objectParams.get("FReqQty");//采购数量 - Double FTAXPRICE = (Double) objectParams.get("FTAXPRICE");//含税单价 + ArrayList entityList = new ArrayList<>(); try { //业务对象标识 String formId = KingdeeConfig.PUR_Requisition; //调用接口 - FEntity.put("FRequireOrgId", KingdeeConfig.getFApplicationOrgId()); //需求组织(必填项) - JSONObject FMaterialIdObject = new JSONObject(); - FMaterialIdObject.put("FNumber", FMaterialId); - FEntity.put("FMaterialId", FMaterialIdObject); //物料编码(必填项) - FEntity.put("FPurchaseOrgId", KingdeeConfig.getFApplicationOrgId()); //采购组织(必填项) - JSONObject FUnitIdObject = new JSONObject(); - FUnitIdObject.put("FNumber", FUnitId); - FEntity.put("FUnitId", FUnitIdObject); //申请单位(必填项) - JSONObject FPriceUnitIdObject = new JSONObject(); - FPriceUnitIdObject.put("FNumber", FPriceUnitId); - FEntity.put("FPriceUnitId", FPriceUnitIdObject); //计价单位(必填项) - FEntity.put("FREQSTOCKUNITID", FUnitIdObject); //库存单位(必填项) - FEntity.put("FReqQty", FReqQty); //申请数量 + for (Object obj : jsonArray) { + JSONObject FEntity = new JSONObject(); + JSONObject objectParams = JSONObject.from(obj); + String FMaterialId = (String) objectParams.get("FMaterialId");//物料编码 + String FUnitId = (String) objectParams.get("FUnitId");//单位 + String FPriceUnitId = (String) objectParams.get("FPriceUnitId");//计价单位 + String FMaterialDesc = (String) objectParams.get("FMaterialDesc");//物料说明 + BigDecimal BFReqQty = (BigDecimal) objectParams.get("FReqQty");//采购数量 + double FReqQty = BFReqQty.doubleValue(); + BigDecimal FFTAXPRICE = (BigDecimal) objectParams.get("FTAXPRICE");//含税单价 + double FTAXPRICE = FFTAXPRICE.doubleValue(); + + FEntity.put("FRequireOrgId", KingdeeConfig.getFApplicationOrgId()); //需求组织(必填项) + JSONObject FMaterialIdObject = new JSONObject(); + FMaterialIdObject.put("FNumber", FMaterialId); + FEntity.put("FMaterialId", FMaterialIdObject); //物料编码(必填项) + FEntity.put("FPurchaseOrgId", KingdeeConfig.getFApplicationOrgId()); //采购组织(必填项) + JSONObject FUnitIdObject = new JSONObject(); + FUnitIdObject.put("FNumber", FUnitId); + FEntity.put("FUnitId", FUnitIdObject); //申请单位(必填项) + JSONObject FPriceUnitIdObject = new JSONObject(); + FPriceUnitIdObject.put("FNumber", FPriceUnitId); + FEntity.put("FPriceUnitId", FPriceUnitIdObject); //计价单位(必填项) + FEntity.put("FREQSTOCKUNITID", FUnitIdObject); //库存单位(必填项) + FEntity.put("FReqQty", FReqQty); //申请数量 + entityList.add(FEntity); + } // FEntity.put("FMaterialDesc", FMaterialDesc); //物料说明 // FEntity.put("FReceiveOrgId", KingdeeConfig.getFApplicationOrgId()); //收料组织 @@ -85,8 +95,7 @@ public class KingdeeErpService { // FEntity.put("FIsVmiBusiness", false); //VMI业务 // FEntity.put("FDEMANDBILLENTRYSEQ", 0); // 需求单据行号 // FEntity.put("FDEMANDBILLENTRYID", 0); // 需求单据分录内码 - ArrayList entityList = new ArrayList<>(); - entityList.add(FEntity); + model.put("FEntity", entityList); JSONObject data = new JSONObject(); model.put("FID", KingdeeConfig.FID); diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesImportImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesImportImpl.java index 682390a..d21b619 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesImportImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesImportImpl.java @@ -1,5 +1,6 @@ package com.hw.mes.service.impl; +import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.hw.common.core.constant.SecurityConstants; import com.hw.common.core.domain.R; @@ -61,6 +62,7 @@ public class MesImportImpl implements IMesImportService { int failureNum = 0; StringBuilder successMsg = new StringBuilder(); StringBuilder failureMsg = new StringBuilder(); + JSONArray jsonArray = new JSONArray(); for (MesPurchaseRequisitionTemplate purchaseRequisitionTemplate : purchaseRequisitionTemplateList) { try { String materialName = purchaseRequisitionTemplate.getMaterialName(); @@ -92,11 +94,8 @@ public class MesImportImpl implements IMesImportService { data.put("FPriceUnitId", priceUnitIdUnitInfo.getUnitCode()); data.put("FReqQty", purchaseRequisitionTemplate.getAmount()); data.put("FTAXPRICE", purchaseRequisitionTemplate.getTaxUnitPrice()); - String params = data.toJSONString(); - R ajaxResult = remoteJindieService.singleSavePurchaseRequisition(params, SecurityConstants.INNER); + jsonArray.add(data); successNum++; - successMsg.append("
").append(materialName).append(" 导入成功"); - log.info(purchaseRequisitionTemplate.toString(), ajaxResult); } else if (successFlag > 1) { failureNum++; failureMsg.append("
").append(failureNum).append(" 查出多条物料记录 导入失败"); @@ -107,16 +106,23 @@ public class MesImportImpl implements IMesImportService { } catch (Exception e) { failureNum++; String msg = "
" + failureNum + " 导入失败:"; - failureMsg.append(msg + e.getMessage()); + failureMsg.append(msg).append(e.getMessage()); log.error(msg, e); } } + + if (jsonArray.size() > 0){ + String params = jsonArray.toJSONString(); + R ajaxResult = remoteJindieService.singleSavePurchaseRequisition(params, SecurityConstants.INNER); + successMsg.append("
").append("采购申请单全部信息导入成功"); + log.info("++++++采购申请单导入++++++",purchaseRequisitionTemplateList, ajaxResult); + } + if (failureNum > 0) { failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); throw new ServiceException(failureMsg.toString()); - } else { - successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); } + return successMsg.toString(); } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/IWmsErpScheduledTaskServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/IWmsErpScheduledTaskServiceImpl.java index 471eac1..4c95807 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/IWmsErpScheduledTaskServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/IWmsErpScheduledTaskServiceImpl.java @@ -43,7 +43,7 @@ public class IWmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServ @Override public int synchronizeInventoryInformationToERP() { //仓库编码 - String FStockId = "CK002"; + String FStockId = "CK050"; WmsRawInstock wmsRawInstock = new WmsRawInstock(); int result = 0; List inStockList = wmsRawInstockMapper.selectWmsRawInstockERPNotSynchronized(wmsRawInstock);