修改
This commit is contained in:
@@ -39,13 +39,13 @@ public class SapToLmsServiceImpl implements SapToLmsService {
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
JSONObject row = rows.getJSONObject(i);
|
||||
String MATNR = row.getString("MATNR");
|
||||
if (StrUtil.isEmpty(MATNR)){
|
||||
if (StrUtil.isEmpty(MATNR)) {
|
||||
throw new BadRequestException("物料编码不能为空!");
|
||||
}
|
||||
JSONObject mater_jo = WQLObject.getWQLObject("md_me_materialbaseext").query("MATNR ='"+MATNR+"'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(mater_jo)){
|
||||
JSONObject mater_jo = WQLObject.getWQLObject("md_me_materialbaseext").query("MATNR ='" + MATNR + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(mater_jo)) {
|
||||
WQLObject.getWQLObject("md_me_materialbaseext").insert(row);
|
||||
}else {
|
||||
} else {
|
||||
WQLObject.getWQLObject("md_me_materialbaseext").update(row);
|
||||
}
|
||||
}
|
||||
@@ -69,158 +69,177 @@ public class SapToLmsServiceImpl implements SapToLmsService {
|
||||
JSONObject result = new JSONObject();
|
||||
|
||||
try {
|
||||
JSONArray item = jo.getJSONArray("ITEM");
|
||||
JSONArray items = jo.getJSONArray("ITEM");
|
||||
|
||||
JSONObject jsonMst = new JSONObject();
|
||||
|
||||
//获取SAP的存储地点
|
||||
String LGORT = item.getJSONObject(0).getString("LGORT");
|
||||
JSONObject stor_jo = WQLObject.getWQLObject("ST_IVT_BSRealStorAttr").query("ext_id = '"+LGORT+"'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(stor_jo)){
|
||||
result.put("RTYPE", "E");
|
||||
result.put("RTMSG", "操作失败!" + "未查询到外部标识为:"+LGORT+"对应的仓库!");
|
||||
result.put("RTOAL", 1);
|
||||
result.put("RTDAT", null);
|
||||
return result;
|
||||
HashMap<String, JSONArray> mst_rows = new HashMap<>();
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
JSONObject dtl = items.getJSONObject(i);
|
||||
String vbeln = dtl.getString(" ");
|
||||
if (mst_rows.containsKey(vbeln)) {
|
||||
JSONArray objects = mst_rows.get(vbeln);
|
||||
objects.add(dtl);
|
||||
mst_rows.put(vbeln, objects);
|
||||
} else {
|
||||
JSONArray objects = new JSONArray();
|
||||
objects.add(dtl);
|
||||
mst_rows.put(vbeln, objects);
|
||||
}
|
||||
}
|
||||
jsonMst.put("stor_id", stor_jo.getString("stor_id"));
|
||||
jsonMst.put("stor_code", stor_jo.getString("stor_code"));
|
||||
jsonMst.put("stor_name", stor_jo.getString("stor_name"));
|
||||
jsonMst.put("detail_count", item.size());
|
||||
jsonMst.put("bill_status", "10");
|
||||
jsonMst.put("create_mode", "03");
|
||||
jsonMst.put("biz_date", DateUtil.now());
|
||||
jsonMst.put("user", "sap");
|
||||
|
||||
JSONArray tableData = new JSONArray();
|
||||
ArrayList<HashMap> box_rows = new ArrayList<>();
|
||||
for (String s : mst_rows.keySet()) {
|
||||
JSONArray item = mst_rows.get(s);
|
||||
JSONObject jsonMst = new JSONObject();
|
||||
|
||||
//获取SAP的存储地点
|
||||
String LGORT = item.getJSONObject(0).getString("LGORT");
|
||||
JSONObject stor_jo = WQLObject.getWQLObject("ST_IVT_BSRealStorAttr").query("ext_id = '" + LGORT + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(stor_jo)) {
|
||||
result.put("RTYPE", "E");
|
||||
result.put("RTMSG", "操作失败!" + "未查询到外部标识为:" + LGORT + "对应的仓库!");
|
||||
result.put("RTOAL", 1);
|
||||
result.put("RTDAT", null);
|
||||
return result;
|
||||
}
|
||||
jsonMst.put("stor_id", stor_jo.getString("stor_id"));
|
||||
jsonMst.put("stor_code", stor_jo.getString("stor_code"));
|
||||
jsonMst.put("stor_name", stor_jo.getString("stor_name"));
|
||||
jsonMst.put("detail_count", item.size());
|
||||
jsonMst.put("bill_status", "10");
|
||||
jsonMst.put("create_mode", "03");
|
||||
jsonMst.put("biz_date", DateUtil.now());
|
||||
jsonMst.put("user", "sap");
|
||||
|
||||
JSONArray tableData = new JSONArray();
|
||||
ArrayList<HashMap> box_rows = new ArrayList<>();
|
||||
|
||||
String lfart = "";
|
||||
for (int i = 0; i < item.size(); i++) {
|
||||
JSONObject json = item.getJSONObject(i);
|
||||
lfart = json.getString("LFART");
|
||||
JSONObject jsonDtl = new JSONObject();
|
||||
if (StrUtil.equals(lfart, "ZLF")) {
|
||||
// 生成出库单
|
||||
jsonMst.put("io_type", "1");
|
||||
jsonMst.put("buss_type", "1001");
|
||||
jsonMst.put("bill_type", "1001");
|
||||
jsonMst.put("source_id", json.getLongValue("VBELN"));
|
||||
jsonMst.put("source_name", "交货单");
|
||||
jsonMst.put("receiver", json.getString("CONSIGNEE")); // 收货人
|
||||
jsonMst.put("receiptphone", json.getString("TEL_NUMBER")); // 联系电话
|
||||
jsonMst.put("contractno", json.getString("BSTNK")); // 合同号
|
||||
jsonMst.put("cust_code", json.getString("KUNNR")); // 客户
|
||||
/*jsonMst.put("remark",json.getString("LGORT"));//库位*/
|
||||
|
||||
// 明细
|
||||
JSONObject jsonMater = materTab.query("material_code = '" + json.getString("MATNR") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(jsonMater))
|
||||
throw new BadRequestException("此物料不存在" + json.getString("MATNR"));
|
||||
JSONObject jsonUnit = unitTab.query("measure_unit_id = '" + jsonMater.getString("base_unit_id") + "'").uniqueResult(0);
|
||||
|
||||
jsonDtl.put("material_id", jsonMater.getString("material_id"));
|
||||
jsonDtl.put("qty_unit_id", jsonMater.getLongValue("base_unit_id"));
|
||||
jsonDtl.put("qty_unit_name", jsonUnit.getString("unit_name"));
|
||||
jsonDtl.put("plan_qty", json.getDoubleValue("LFIMG"));
|
||||
jsonDtl.put("source_bill_code", json.getString("VGBEL-VGPOS"));
|
||||
jsonDtl.put("vbeln", json.getString("VBELN")); // 来源交货单
|
||||
jsonDtl.put("posnr", json.getString("POSNR")); // 来源交货单行
|
||||
tableData.add(jsonDtl);
|
||||
}
|
||||
if (StrUtil.equals(lfart, "ZLR")) {
|
||||
/*jsonMst.put("remark",json.getString("LGORT"));//库位*/
|
||||
HashMap map = new HashMap();
|
||||
//更新包装关系
|
||||
String sap_pcsn = json.getString("CHARG");
|
||||
if (StrUtil.isEmpty(sap_pcsn)) {
|
||||
throw new BadRequestException("批次不能为空!");
|
||||
}
|
||||
String package_box_sn = json.getString("ZZJXH");
|
||||
if (StrUtil.isEmpty(package_box_sn)) {
|
||||
throw new BadRequestException("箱号不能为空!");
|
||||
}
|
||||
String sale_order_name = json.getString("VGBEL-VGPOS");
|
||||
if (StrUtil.isEmpty(sale_order_name)) {
|
||||
throw new BadRequestException("销售订单及行号不能为空!");
|
||||
}
|
||||
String length = json.getString("ZZJCD");
|
||||
if (StrUtil.isEmpty(length)) {
|
||||
throw new BadRequestException("子卷长度不能为空!");
|
||||
}
|
||||
String width = json.getString("HL02");
|
||||
if (StrUtil.isEmpty(width)) {
|
||||
throw new BadRequestException("子卷幅宽不能为空!");
|
||||
}
|
||||
// 明细
|
||||
JSONObject jsonMater = materTab.query("material_code = '" + json.getString("MATNR") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(jsonMater)) {
|
||||
throw new BadRequestException("此物料不存在" + json.getString("MATNR"));
|
||||
}
|
||||
|
||||
JSONObject sub_jo = WQLObject.getWQLObject("PDM_BI_SubPackageRelation").query("sap_pcsn = '" + sap_pcsn + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(sub_jo)) {
|
||||
//为空新增一条
|
||||
sub_jo = new JSONObject();
|
||||
sub_jo.put("workorder_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||
sub_jo.put("package_box_sn", package_box_sn);
|
||||
sub_jo.put("quanlity_in_box", 1);
|
||||
sub_jo.put("sale_order_name", sale_order_name);
|
||||
sub_jo.put("customer_name", json.getString("KUNNR"));
|
||||
sub_jo.put("customer_description", json.getString("NAMEM"));
|
||||
sub_jo.put("product_name", json.getString("MATNR"));
|
||||
sub_jo.put("product_description", jsonMater.getString("material_name"));
|
||||
sub_jo.put("container_name", sap_pcsn);
|
||||
sub_jo.put("width", width);
|
||||
sub_jo.put("net_weight", json.getString("LFIMG"));
|
||||
sub_jo.put("length", length);
|
||||
sub_jo.put("is_un_plan_production", 0);
|
||||
sub_jo.put("create_id", 0);
|
||||
sub_jo.put("create_name", 0);
|
||||
sub_jo.put("create_time", 0);
|
||||
sub_jo.put("status", "0");
|
||||
sub_jo.put("sap_pcsn", sap_pcsn);
|
||||
sub_jo.put("vbeln", json.getString("VBELN"));
|
||||
sub_jo.put("posnr", json.getString("POSNR"));
|
||||
WQLObject.getWQLObject("PDM_BI_SubPackageRelation").insert(sub_jo);
|
||||
} else {
|
||||
//不为空修改子卷包装关系
|
||||
sub_jo.put("vbeln", json.getString("VBELN"));
|
||||
sub_jo.put("posnr", json.getString("POSNR"));
|
||||
sub_jo.put("package_box_sn", package_box_sn);
|
||||
sub_jo.put("width", width);
|
||||
sub_jo.put("length", length);
|
||||
sub_jo.put("status", "0");
|
||||
WQLObject.getWQLObject("PDM_BI_SubPackageRelation").update(sub_jo);
|
||||
}
|
||||
|
||||
map.put("container_name", sub_jo.getString("container_name"));
|
||||
map.put("net_weight", sub_jo.getString("net_weight"));
|
||||
map.put("package_box_sn", sub_jo.getString("package_box_sn"));
|
||||
map.put("product_name", sub_jo.getString("product_name"));
|
||||
map.put("vbeln", json.getString("VBELN"));
|
||||
map.put("posnr", json.getString("POSNR"));
|
||||
box_rows.add(map);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String lfart = "";
|
||||
for (int i = 0; i < item.size(); i++) {
|
||||
JSONObject json = item.getJSONObject(i);
|
||||
lfart = json.getString("LFART");
|
||||
JSONObject jsonDtl = new JSONObject();
|
||||
if (StrUtil.equals(lfart, "ZLF")) {
|
||||
// 生成出库单
|
||||
jsonMst.put("io_type", "1");
|
||||
jsonMst.put("buss_type", "1001");
|
||||
jsonMst.put("bill_type", "1001");
|
||||
jsonMst.put("source_id", json.getLongValue("VBELN"));
|
||||
jsonMst.put("source_name", "交货单");
|
||||
jsonMst.put("receiver", json.getString("CONSIGNEE")); // 收货人
|
||||
jsonMst.put("receiptphone", json.getString("TEL_NUMBER")); // 联系电话
|
||||
jsonMst.put("contractno", json.getString("BSTNK")); // 合同号
|
||||
jsonMst.put("cust_code", json.getString("KUNNR")); // 客户
|
||||
/*jsonMst.put("remark",json.getString("LGORT"));//库位*/
|
||||
|
||||
// 明细
|
||||
JSONObject jsonMater = materTab.query("material_code = '" + json.getString("MATNR") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(jsonMater))
|
||||
throw new BadRequestException("此物料不存在" + json.getString("MATNR"));
|
||||
JSONObject jsonUnit = unitTab.query("measure_unit_id = '" + jsonMater.getString("base_unit_id") + "'").uniqueResult(0);
|
||||
|
||||
jsonDtl.put("material_id", jsonMater.getString("material_id"));
|
||||
jsonDtl.put("qty_unit_id", jsonMater.getLongValue("base_unit_id"));
|
||||
jsonDtl.put("qty_unit_name", jsonUnit.getString("unit_name"));
|
||||
jsonDtl.put("plan_qty", json.getDoubleValue("LFIMG"));
|
||||
jsonDtl.put("source_bill_code", json.getString("VGBEL-VGPOS"));
|
||||
jsonDtl.put("vbeln", json.getString("VBELN")); // 来源交货单
|
||||
jsonDtl.put("posnr", json.getString("POSNR")); // 来源交货单行
|
||||
tableData.add(jsonDtl);
|
||||
jsonMst.put("tableData", tableData);
|
||||
// 调用出库新增并分配
|
||||
String iostorinv_id = checkOutBillService.insertDtl2(jsonMst);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("iostorinv_id", iostorinv_id);
|
||||
//checkOutBillService.allDiv(jsonObject);
|
||||
}
|
||||
if (StrUtil.equals(lfart, "ZLR")) {
|
||||
/*jsonMst.put("remark",json.getString("LGORT"));//库位*/
|
||||
HashMap map = new HashMap();
|
||||
//更新包装关系
|
||||
String sap_pcsn = json.getString("CHARG");
|
||||
if (StrUtil.isEmpty(sap_pcsn)) {
|
||||
throw new BadRequestException("批次不能为空!");
|
||||
}
|
||||
String package_box_sn = json.getString("ZZJXH");
|
||||
if (StrUtil.isEmpty(package_box_sn)) {
|
||||
throw new BadRequestException("箱号不能为空!");
|
||||
}
|
||||
String sale_order_name = json.getString("VGBEL-VGPOS");
|
||||
if (StrUtil.isEmpty(sale_order_name)) {
|
||||
throw new BadRequestException("销售订单及行号不能为空!");
|
||||
}
|
||||
String length = json.getString("ZZJCD");
|
||||
if (StrUtil.isEmpty(length)) {
|
||||
throw new BadRequestException("子卷长度不能为空!");
|
||||
}
|
||||
String width = json.getString("HL02");
|
||||
if (StrUtil.isEmpty(width)) {
|
||||
throw new BadRequestException("子卷幅宽不能为空!");
|
||||
}
|
||||
// 明细
|
||||
JSONObject jsonMater = materTab.query("material_code = '" + json.getString("MATNR") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(jsonMater)) {
|
||||
throw new BadRequestException("此物料不存在" + json.getString("MATNR"));
|
||||
}
|
||||
|
||||
JSONObject sub_jo = WQLObject.getWQLObject("PDM_BI_SubPackageRelation").query("sap_pcsn = '" + sap_pcsn + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(sub_jo)) {
|
||||
//为空新增一条
|
||||
sub_jo = new JSONObject();
|
||||
sub_jo.put("workorder_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||
sub_jo.put("package_box_sn", package_box_sn);
|
||||
sub_jo.put("quanlity_in_box", 1);
|
||||
sub_jo.put("sale_order_name", sale_order_name);
|
||||
sub_jo.put("customer_name", json.getString("KUNNR"));
|
||||
sub_jo.put("customer_description", json.getString("NAMEM"));
|
||||
sub_jo.put("product_name", json.getString("MATNR"));
|
||||
sub_jo.put("product_description", jsonMater.getString("material_name"));
|
||||
sub_jo.put("container_name", sap_pcsn);
|
||||
sub_jo.put("width", width);
|
||||
sub_jo.put("net_weight", json.getString("LFIMG"));
|
||||
sub_jo.put("length", length);
|
||||
sub_jo.put("is_un_plan_production", 0);
|
||||
sub_jo.put("create_id", 0);
|
||||
sub_jo.put("create_name", 0);
|
||||
sub_jo.put("create_time", 0);
|
||||
sub_jo.put("status", "0");
|
||||
sub_jo.put("sap_pcsn", sap_pcsn);
|
||||
sub_jo.put("vbeln", json.getString("VBELN"));
|
||||
sub_jo.put("posnr", json.getString("POSNR"));
|
||||
WQLObject.getWQLObject("PDM_BI_SubPackageRelation").insert(sub_jo);
|
||||
} else {
|
||||
//不为空修改子卷包装关系
|
||||
sub_jo.put("vbeln", json.getString("VBELN"));
|
||||
sub_jo.put("posnr", json.getString("POSNR"));
|
||||
sub_jo.put("package_box_sn", package_box_sn);
|
||||
sub_jo.put("width", width);
|
||||
sub_jo.put("length", length);
|
||||
sub_jo.put("status", "0");
|
||||
WQLObject.getWQLObject("PDM_BI_SubPackageRelation").update(sub_jo);
|
||||
}
|
||||
|
||||
map.put("container_name", sub_jo.getString("container_name"));
|
||||
map.put("net_weight", sub_jo.getString("net_weight"));
|
||||
map.put("package_box_sn", sub_jo.getString("package_box_sn"));
|
||||
map.put("product_name", sub_jo.getString("product_name"));
|
||||
map.put("vbeln", json.getString("VBELN"));
|
||||
map.put("posnr", json.getString("POSNR"));
|
||||
box_rows.add(map);
|
||||
jsonMst.put("tableData", box_rows);
|
||||
//创建退货入库单
|
||||
jsonMst.put("bill_type", "0002");
|
||||
jsonMst.put("biz_date", DateUtil.now());
|
||||
jsonMst.put("bill_status", "30");
|
||||
rawAssistIStorService.insertDtl(jsonMst);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (StrUtil.equals(lfart, "ZLF")) {
|
||||
jsonMst.put("tableData", tableData);
|
||||
// 调用出库新增并分配
|
||||
String iostorinv_id = checkOutBillService.insertDtl2(jsonMst);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("iostorinv_id", iostorinv_id);
|
||||
//checkOutBillService.allDiv(jsonObject);
|
||||
}
|
||||
if (StrUtil.equals(lfart, "ZLR")) {
|
||||
jsonMst.put("tableData", box_rows);
|
||||
//创建退货入库单
|
||||
jsonMst.put("bill_type", "0002");
|
||||
jsonMst.put("biz_date", DateUtil.now());
|
||||
jsonMst.put("bill_status", "30");
|
||||
rawAssistIStorService.insertDtl(jsonMst);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result.put("RTYPE", "E");
|
||||
result.put("RTMSG", "操作失败!" + e.getMessage());
|
||||
|
||||
@@ -158,7 +158,7 @@ public class ChangeServiceImpl implements ChangeService {
|
||||
HashMap<String, HashMap> set = new HashMap<>();
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
HashMap row = rows.get(i);
|
||||
String package_box_sn = (String) row.get("package_box_sn");
|
||||
String package_box_sn = (String) row.get("storagevehicle_code");
|
||||
if (set.containsKey(package_box_sn)) {
|
||||
continue;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user