This commit is contained in:
2022-11-17 14:39:06 +08:00
3 changed files with 63 additions and 22 deletions

View File

@@ -76,6 +76,9 @@ public class SapToLmsServiceImpl implements SapToLmsService {
jsonMst.put("bill_type", "1001"); jsonMst.put("bill_type", "1001");
jsonMst.put("source_id", json.getLongValue("VBELN")); jsonMst.put("source_id", json.getLongValue("VBELN"));
jsonMst.put("source_name", "交货单"); jsonMst.put("source_name", "交货单");
jsonMst.put("receiver", json.getString("CONSIGNEE")); // 收货人
jsonMst.put("receiptphone", json.getString("TEL_NUMBER")); // 联系电话
jsonMst.put("contractno", json.getString("BSTNK")); // 合同号
// 明细 // 明细
JSONObject jsonMater = materTab.query("material_code = '" + json.getString("MATNR") + "'").uniqueResult(0); JSONObject jsonMater = materTab.query("material_code = '" + json.getString("MATNR") + "'").uniqueResult(0);
@@ -87,6 +90,8 @@ public class SapToLmsServiceImpl implements SapToLmsService {
jsonDtl.put("qty_unit_name",jsonUnit.getString("unit_name")); jsonDtl.put("qty_unit_name",jsonUnit.getString("unit_name"));
jsonDtl.put("plan_qty",json.getDoubleValue("LFIMG")); jsonDtl.put("plan_qty",json.getDoubleValue("LFIMG"));
jsonDtl.put("source_bill_code",json.getString("VGBEL-VGPOS")); jsonDtl.put("source_bill_code",json.getString("VGBEL-VGPOS"));
jsonDtl.put("vbeln",json.getString("VBELN")); // 来源交货单
jsonDtl.put("posnr",json.getString("POSNR")); // 来源交货单行
tableData.add(jsonDtl); tableData.add(jsonDtl);
} }
} }

View File

@@ -1537,6 +1537,10 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_IOStorInv"); WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_IOStorInv");
// 物料表 // 物料表
WQLObject materTab = WQLObject.getWQLObject("md_me_materialbase"); WQLObject materTab = WQLObject.getWQLObject("md_me_materialbase");
// 库区表
WQLObject sectTab = WQLObject.getWQLObject("st_ivt_sectattr");
// 子卷包装关系表
WQLObject subTab = WQLObject.getWQLObject("pdm_bi_subpackagerelation");
String iostorinv_id = form.getString("iostorinv_id"); String iostorinv_id = form.getString("iostorinv_id");
Long currentUserId = SecurityUtils.getCurrentUserId(); Long currentUserId = SecurityUtils.getCurrentUserId();
@@ -1639,9 +1643,10 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
// 销售出库 // 销售出库
if (StrUtil.equals(bill_type, "1001")) { if (StrUtil.equals(bill_type, "1001")) {
// 1.回传sap // 1.回传sap
JSONArray paramSapMstArr = new JSONArray();
JSONObject paramSapMst = new JSONObject(); JSONObject paramSapMst = new JSONObject();
paramSapMst.put("ZACTION", "P"); paramSapMst.put("ZACTION", "P");
paramSapMst.put("VBELN", ""); // 交货
paramSapMst.put("BUDAT", jo_mst.getString("biz_date")); paramSapMst.put("BUDAT", jo_mst.getString("biz_date"));
paramSapMst.put("ZZYGYF", jo_mst.getString("estimated_freight")); paramSapMst.put("ZZYGYF", jo_mst.getString("estimated_freight"));
paramSapMst.put("ZZYFGY", jo_mst.getString("trans_code")); paramSapMst.put("ZZYFGY", jo_mst.getString("trans_code"));
@@ -1655,10 +1660,10 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
// 明细 // 明细
JSONObject jsonDtl = new JSONObject(); JSONObject jsonDtl = new JSONObject();
jsonDtl.put("VBELN", ""); // 交货 jsonDtl.put("VBELN", json.getString("vbeln")); // 交货
jsonDtl.put("POSNR", json.getString("seq_no")); paramSapMst.put("VBELN", json.getString("vbeln")); // 主表交货
jsonDtl.put("POSNR", json.getString("posnr")); // 项目
jsonDtl.put("MATNR", jsonMater.getString("material_code")); jsonDtl.put("MATNR", jsonMater.getString("material_code"));
jsonDtl.put("LGORT", ""); // 储存地点
// 分配明细 // 分配明细
JSONArray disArr = wo_dis.query("iostorinvdtl_id = '" + json.getString("iostorinvdtl_id") + "'").getResultJSONArray(0); JSONArray disArr = wo_dis.query("iostorinvdtl_id = '" + json.getString("iostorinvdtl_id") + "'").getResultJSONArray(0);
@@ -1666,12 +1671,20 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
JSONObject json2 = disArr.getJSONObject(j); JSONObject json2 = disArr.getJSONObject(j);
JSONObject jsonDis = new JSONObject(); JSONObject jsonDis = new JSONObject();
jsonDis.put("VBELN", ""); // 交货 JSONObject jsonSect = sectTab.query("sect_id = '" + json2.getString("sect_id") + "'").uniqueResult(0);
jsonDis.put("POSNR", json2.getString("seq_no")); if (ObjectUtil.isNotEmpty(jsonSect)) {
jsonDis.put("CHARG", json2.getString("pcsn")); jsonDtl.put("LGORT", jsonSect.getString("ext_id")); // 明細储存地点
jsonDis.put("LFIMG", json.getString("plan_qty")); }
JSONObject jsonSub = subTab.query("container_name = '" + json2.getString("pcsn") + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonSect)) {
jsonDis.put("CHARG", jsonSub.getString("sap_pcsn")); // sap批次
}
jsonDis.put("VBELN", json.getString("vbeln")); // 交货
jsonDis.put("POSNR", json.getString("posnr")); // 项目
jsonDis.put("LFIMG", json2.getString("real_qty"));
jsonDis.put("VRKME", json.getString("qty_unit_name")); jsonDis.put("VRKME", json.getString("qty_unit_name"));
jsonDis.put("PIKMG", json2.getString("plan_qty")); jsonDis.put("PIKMG", json2.getString("real_qty"));
jsonDis.put("VRKMP", json2.getString("qty_unit_name")); jsonDis.put("VRKMP", json2.getString("qty_unit_name"));
paramDisArr.add(jsonDis); paramDisArr.add(jsonDis);
} }
@@ -1679,9 +1692,13 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
paramDtlArr.add(jsonDtl); paramDtlArr.add(jsonDtl);
} }
paramSapMst.put("ITEM", paramDtlArr); paramSapMst.put("ITEM", paramDtlArr);
paramSapMstArr.add(paramSapMst);
JSONObject param = new JSONObject();
param.put("HEAD", paramSapMstArr);
// 调用接口回传 // 调用接口回传
new LmsToSapServiceImpl().returnDelivery(paramSapMst); new LmsToSapServiceImpl().returnDelivery(param);
// 2.回传mes // 2.回传mes
JSONObject paramMesMst = new JSONObject(); JSONObject paramMesMst = new JSONObject();

View File

@@ -75,6 +75,11 @@ public class InAndOutRetrunServiceImpl implements InAndOutReturnService {
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_IOStorInv"); WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_IOStorInv");
// 物料表 // 物料表
WQLObject materTab = WQLObject.getWQLObject("md_me_materialbase"); WQLObject materTab = WQLObject.getWQLObject("md_me_materialbase");
// 库区表
WQLObject sectTab = WQLObject.getWQLObject("st_ivt_sectattr");
// 子卷包装关系表
WQLObject subTab = WQLObject.getWQLObject("pdm_bi_subpackagerelation");
//根据出入单类型判断回传业务 //根据出入单类型判断回传业务
//1、生产入库回传MES手工入库回传SAP //1、生产入库回传MES手工入库回传SAP
//1、销售出库回传MES、SAP改切出库回传SAP //1、销售出库回传MES、SAP改切出库回传SAP
@@ -92,26 +97,27 @@ public class InAndOutRetrunServiceImpl implements InAndOutReturnService {
// 销售出库 // 销售出库
if (StrUtil.equals(bill_type, "1001")) { if (StrUtil.equals(bill_type, "1001")) {
// 1.回传sap // 1.回传sap
JSONArray paramSapMstArr = new JSONArray();
JSONObject paramSapMst = new JSONObject(); JSONObject paramSapMst = new JSONObject();
paramSapMst.put("ZACTION", "P"); paramSapMst.put("ZACTION", "P");
paramSapMst.put("VBELN", ""); // 交货
paramSapMst.put("BUDAT", jo_mst.getString("biz_date")); paramSapMst.put("BUDAT", jo_mst.getString("biz_date"));
paramSapMst.put("ZZYGYF", jo_mst.getString("estimated_freight")); paramSapMst.put("ZZYGYF", jo_mst.getString("estimated_freight"));
paramSapMst.put("ZZYFGY", jo_mst.getString("trans_code")); paramSapMst.put("ZZYFGY", jo_mst.getString("trans_code"));
JSONArray paramDtlArr = new JSONArray(); JSONArray paramDtlArr = new JSONArray();
JSONArray dtlArr = wo_dtl.query("iostorinv_id = '" + jo_mst.getString("iostorinv_id") + "'").getResultJSONArray(0); JSONArray dtlArr = wo_dtl.query("iostorinv_id = '" + jo_mst.getString("iostorinv_id") + "'").getResultJSONArray(0);
for (int m = 0; m < dtlArr.size(); m++) { for (int k = 0; k < dtlArr.size(); k++) {
JSONArray paramDisArr = new JSONArray(); JSONArray paramDisArr = new JSONArray();
JSONObject json = dtlArr.getJSONObject(m); JSONObject json = dtlArr.getJSONObject(k);
JSONObject jsonMater = materTab.query("material_id = '" + json.getString("material_id") + "'").uniqueResult(0); JSONObject jsonMater = materTab.query("material_id = '" + json.getString("material_id") + "'").uniqueResult(0);
// 明细 // 明细
JSONObject jsonDtl = new JSONObject(); JSONObject jsonDtl = new JSONObject();
jsonDtl.put("VBELN", ""); // 交货 jsonDtl.put("VBELN", json.getString("vbeln")); // 交货
jsonDtl.put("POSNR", json.getString("seq_no")); paramSapMst.put("VBELN", json.getString("vbeln")); // 主表交货
jsonDtl.put("POSNR", json.getString("posnr")); // 项目
jsonDtl.put("MATNR", jsonMater.getString("material_code")); jsonDtl.put("MATNR", jsonMater.getString("material_code"));
jsonDtl.put("LGORT", ""); // 储存地点
// 分配明细 // 分配明细
JSONArray disArr = wo_dis.query("iostorinvdtl_id = '" + json.getString("iostorinvdtl_id") + "'").getResultJSONArray(0); JSONArray disArr = wo_dis.query("iostorinvdtl_id = '" + json.getString("iostorinvdtl_id") + "'").getResultJSONArray(0);
@@ -119,12 +125,20 @@ public class InAndOutRetrunServiceImpl implements InAndOutReturnService {
JSONObject json2 = disArr.getJSONObject(j); JSONObject json2 = disArr.getJSONObject(j);
JSONObject jsonDis = new JSONObject(); JSONObject jsonDis = new JSONObject();
jsonDis.put("VBELN", ""); // 交货 JSONObject jsonSect = sectTab.query("sect_id = '" + json2.getString("sect_id") + "'").uniqueResult(0);
jsonDis.put("POSNR", json2.getString("seq_no")); if (ObjectUtil.isNotEmpty(jsonSect)) {
jsonDis.put("CHARG", json2.getString("pcsn")); jsonDtl.put("LGORT", jsonSect.getString("ext_id")); // 明細储存地点
jsonDis.put("LFIMG", json.getString("plan_qty")); }
JSONObject jsonSub = subTab.query("container_name = '" + json2.getString("pcsn") + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonSect)) {
jsonDis.put("CHARG", jsonSub.getString("sap_pcsn")); // sap批次
}
jsonDis.put("VBELN", json.getString("vbeln")); // 交货
jsonDis.put("POSNR", json.getString("posnr")); // 项目
jsonDis.put("LFIMG", json2.getString("real_qty"));
jsonDis.put("VRKME", json.getString("qty_unit_name")); jsonDis.put("VRKME", json.getString("qty_unit_name"));
jsonDis.put("PIKMG", json2.getString("plan_qty")); jsonDis.put("PIKMG", json2.getString("real_qty"));
jsonDis.put("VRKMP", json2.getString("qty_unit_name")); jsonDis.put("VRKMP", json2.getString("qty_unit_name"));
paramDisArr.add(jsonDis); paramDisArr.add(jsonDis);
} }
@@ -132,9 +146,14 @@ public class InAndOutRetrunServiceImpl implements InAndOutReturnService {
paramDtlArr.add(jsonDtl); paramDtlArr.add(jsonDtl);
} }
paramSapMst.put("ITEM", paramDtlArr); paramSapMst.put("ITEM", paramDtlArr);
paramSapMstArr.add(paramSapMst);
JSONObject param = new JSONObject();
param.put("HEAD", paramSapMstArr);
// System.out.println(param.toString());
// 调用接口回传 // 调用接口回传
new LmsToSapServiceImpl().returnDelivery(paramSapMst); new LmsToSapServiceImpl().returnDelivery(param);
// 2.回传mes // 2.回传mes
JSONObject paramMesMst = new JSONObject(); JSONObject paramMesMst = new JSONObject();