change - 采购申请单多物料上传ERP

master
yinq 4 months ago
parent ad39278bbc
commit 3b17b2879e

@ -127,7 +127,7 @@ public class KingdeeErpSyncController {
/** /**
* ->-> * ->->
* *
* @param params {"FMaterialId": "040200050162","FMaterialDesc": "UPVC直管","FReqQty": 20} * @param params {"FMaterialId": "040200050162","FMaterialDesc": "UPVC直管","FReqQty": 20}
* @return {"msg": "{"IsSuccess": true,"Errors": [],"SuccessEntitys": [{"Id": "154898","Number": "CGSQ010785","DIndex": 0}]}", "code": 200} * @return {"msg": "{"IsSuccess": true,"Errors": [],"SuccessEntitys": [{"Id": "154898","Number": "CGSQ010785","DIndex": 0}]}", "code": 200}

@ -1,6 +1,7 @@
package com.hw.jindie.service.impl; package com.hw.jindie.service.impl;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.alibaba.nacos.shaded.com.google.gson.Gson; import com.alibaba.nacos.shaded.com.google.gson.Gson;
import com.hw.common.core.utils.StringUtils; import com.hw.common.core.utils.StringUtils;
@ -12,6 +13,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
@ -33,39 +35,47 @@ public class KingdeeErpService {
/** /**
* ->-> * ->->
* *
* @param params * @param params
* @return * @return
*/ */
public String singleSavePurchaseRequisition(String params) { public String singleSavePurchaseRequisition(String params) {
Gson gsonParams = new Gson(); Gson gsonParams = new Gson();
JSONObject objectParams = gsonParams.fromJson(params, JSONObject.class); JSONArray jsonArray = gsonParams.fromJson(params, JSONArray.class);
JSONObject model = new JSONObject(); JSONObject model = new JSONObject();
JSONObject FEntity = new JSONObject(); ArrayList<JSONObject> entityList = new ArrayList<>();
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");//含税单价
try { try {
//业务对象标识 //业务对象标识
String formId = KingdeeConfig.PUR_Requisition; String formId = KingdeeConfig.PUR_Requisition;
//调用接口 //调用接口
FEntity.put("FRequireOrgId", KingdeeConfig.getFApplicationOrgId()); //需求组织(必填项) for (Object obj : jsonArray) {
JSONObject FMaterialIdObject = new JSONObject(); JSONObject FEntity = new JSONObject();
FMaterialIdObject.put("FNumber", FMaterialId); JSONObject objectParams = JSONObject.from(obj);
FEntity.put("FMaterialId", FMaterialIdObject); //物料编码(必填项) String FMaterialId = (String) objectParams.get("FMaterialId");//物料编码
FEntity.put("FPurchaseOrgId", KingdeeConfig.getFApplicationOrgId()); //采购组织(必填项) String FUnitId = (String) objectParams.get("FUnitId");//单位
JSONObject FUnitIdObject = new JSONObject(); String FPriceUnitId = (String) objectParams.get("FPriceUnitId");//计价单位
FUnitIdObject.put("FNumber", FUnitId); String FMaterialDesc = (String) objectParams.get("FMaterialDesc");//物料说明
FEntity.put("FUnitId", FUnitIdObject); //申请单位(必填项) BigDecimal BFReqQty = (BigDecimal) objectParams.get("FReqQty");//采购数量
JSONObject FPriceUnitIdObject = new JSONObject(); double FReqQty = BFReqQty.doubleValue();
FPriceUnitIdObject.put("FNumber", FPriceUnitId); BigDecimal FFTAXPRICE = (BigDecimal) objectParams.get("FTAXPRICE");//含税单价
FEntity.put("FPriceUnitId", FPriceUnitIdObject); //计价单位(必填项) double FTAXPRICE = FFTAXPRICE.doubleValue();
FEntity.put("FREQSTOCKUNITID", FUnitIdObject); //库存单位(必填项)
FEntity.put("FReqQty", FReqQty); //申请数量 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("FMaterialDesc", FMaterialDesc); //物料说明
// FEntity.put("FReceiveOrgId", KingdeeConfig.getFApplicationOrgId()); //收料组织 // FEntity.put("FReceiveOrgId", KingdeeConfig.getFApplicationOrgId()); //收料组织
@ -85,8 +95,7 @@ public class KingdeeErpService {
// FEntity.put("FIsVmiBusiness", false); //VMI业务 // FEntity.put("FIsVmiBusiness", false); //VMI业务
// FEntity.put("FDEMANDBILLENTRYSEQ", 0); // 需求单据行号 // FEntity.put("FDEMANDBILLENTRYSEQ", 0); // 需求单据行号
// FEntity.put("FDEMANDBILLENTRYID", 0); // 需求单据分录内码 // FEntity.put("FDEMANDBILLENTRYID", 0); // 需求单据分录内码
ArrayList<JSONObject> entityList = new ArrayList<>();
entityList.add(FEntity);
model.put("FEntity", entityList); model.put("FEntity", entityList);
JSONObject data = new JSONObject(); JSONObject data = new JSONObject();
model.put("FID", KingdeeConfig.FID); model.put("FID", KingdeeConfig.FID);

@ -1,5 +1,6 @@
package com.hw.mes.service.impl; package com.hw.mes.service.impl;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.hw.common.core.constant.SecurityConstants; import com.hw.common.core.constant.SecurityConstants;
import com.hw.common.core.domain.R; import com.hw.common.core.domain.R;
@ -61,6 +62,7 @@ public class MesImportImpl implements IMesImportService {
int failureNum = 0; int failureNum = 0;
StringBuilder successMsg = new StringBuilder(); StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder(); StringBuilder failureMsg = new StringBuilder();
JSONArray jsonArray = new JSONArray();
for (MesPurchaseRequisitionTemplate purchaseRequisitionTemplate : purchaseRequisitionTemplateList) { for (MesPurchaseRequisitionTemplate purchaseRequisitionTemplate : purchaseRequisitionTemplateList) {
try { try {
String materialName = purchaseRequisitionTemplate.getMaterialName(); String materialName = purchaseRequisitionTemplate.getMaterialName();
@ -92,11 +94,8 @@ public class MesImportImpl implements IMesImportService {
data.put("FPriceUnitId", priceUnitIdUnitInfo.getUnitCode()); data.put("FPriceUnitId", priceUnitIdUnitInfo.getUnitCode());
data.put("FReqQty", purchaseRequisitionTemplate.getAmount()); data.put("FReqQty", purchaseRequisitionTemplate.getAmount());
data.put("FTAXPRICE", purchaseRequisitionTemplate.getTaxUnitPrice()); data.put("FTAXPRICE", purchaseRequisitionTemplate.getTaxUnitPrice());
String params = data.toJSONString(); jsonArray.add(data);
R<AjaxResult> ajaxResult = remoteJindieService.singleSavePurchaseRequisition(params, SecurityConstants.INNER);
successNum++; successNum++;
successMsg.append("<br/>").append(materialName).append(" 导入成功");
log.info(purchaseRequisitionTemplate.toString(), ajaxResult);
} else if (successFlag > 1) { } else if (successFlag > 1) {
failureNum++; failureNum++;
failureMsg.append("<br/>").append(failureNum).append(" 查出多条物料记录 导入失败"); failureMsg.append("<br/>").append(failureNum).append(" 查出多条物料记录 导入失败");
@ -107,16 +106,23 @@ public class MesImportImpl implements IMesImportService {
} catch (Exception e) { } catch (Exception e) {
failureNum++; failureNum++;
String msg = "<br/>" + failureNum + " 导入失败:"; String msg = "<br/>" + failureNum + " 导入失败:";
failureMsg.append(msg + e.getMessage()); failureMsg.append(msg).append(e.getMessage());
log.error(msg, e); log.error(msg, e);
} }
} }
if (jsonArray.size() > 0){
String params = jsonArray.toJSONString();
R<AjaxResult> ajaxResult = remoteJindieService.singleSavePurchaseRequisition(params, SecurityConstants.INNER);
successMsg.append("<br/>").append("采购申请单全部信息导入成功");
log.info("++++++采购申请单导入++++++",purchaseRequisitionTemplateList, ajaxResult);
}
if (failureNum > 0) { if (failureNum > 0) {
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new ServiceException(failureMsg.toString()); throw new ServiceException(failureMsg.toString());
} else {
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
} }
return successMsg.toString(); return successMsg.toString();
} }

@ -43,7 +43,7 @@ public class IWmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServ
@Override @Override
public int synchronizeInventoryInformationToERP() { public int synchronizeInventoryInformationToERP() {
//仓库编码 //仓库编码
String FStockId = "CK002"; String FStockId = "CK050";
WmsRawInstock wmsRawInstock = new WmsRawInstock(); WmsRawInstock wmsRawInstock = new WmsRawInstock();
int result = 0; int result = 0;
List<WmsRawInstock> inStockList = wmsRawInstockMapper.selectWmsRawInstockERPNotSynchronized(wmsRawInstock); List<WmsRawInstock> inStockList = wmsRawInstockMapper.selectWmsRawInstockERPNotSynchronized(wmsRawInstock);

Loading…
Cancel
Save