diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/ext/sap/service/impl/SapToLmsServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/ext/sap/service/impl/SapToLmsServiceImpl.java index 5527a4c1f..f7eb7e434 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/ext/sap/service/impl/SapToLmsServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/ext/sap/service/impl/SapToLmsServiceImpl.java @@ -195,7 +195,7 @@ public class SapToLmsServiceImpl implements SapToLmsService { if (StrUtil.equals(lfart, "ZLF")) { jsonMst.put("tableData", tableData); // 调用出库新增并分配 - String iostorinv_id = checkOutBillService.insertDtl(jsonMst); + String iostorinv_id = checkOutBillService.insertDtl2(jsonMst); JSONObject jsonObject = new JSONObject(); jsonObject.put("iostorinv_id", iostorinv_id); //checkOutBillService.allDiv(jsonObject); diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/CheckOutBillService.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/CheckOutBillService.java index 9bb000752..3d1312b6d 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/CheckOutBillService.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/CheckOutBillService.java @@ -48,6 +48,12 @@ public interface CheckOutBillService { * / */ String insertDtl (JSONObject whereJson); + /** + * 发货出库用 + * @param whereJson + * / + */ + String insertDtl2 (JSONObject whereJson); /** * 新增出库单 * @param whereJson diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/service/impl/CheckOutBillServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/service/impl/CheckOutBillServiceImpl.java index 19e194a65..6ba394109 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/service/impl/CheckOutBillServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/service/impl/CheckOutBillServiceImpl.java @@ -332,6 +332,129 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { return iostorinv_id; } + @Override + @Transactional(rollbackFor = Exception.class) + public String insertDtl2(JSONObject map) { + WQLObject ivtTab = WQLObject.getWQLObject("ST_IVT_StructIvt"); + //明细另一种写法 + //JSONArray jsonArr = JSONArray.fromObject(whereJson.get("tableData")); + JSONArray rows = map.getJSONArray("tableData"); + + map.remove("tableData"); + Long currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getCurrentNickName(); + String user = map.getString("user"); + if (ObjectUtil.isNotEmpty(user)) { + if (user.equals("mes")) { + currentUserId = Long.parseLong(2 + ""); + nickName = "mes用户"; + } + if (user.equals("sap")) { + currentUserId = Long.parseLong(3 + ""); + nickName = "sap用户"; + } + } + String now = DateUtil.now(); + String iostorinv_id = IdUtil.getSnowflake(1, 1).nextId() + ""; + String bill_code = CodeUtil.getNewCode("IO_CODE"); + + JSONObject jsonStor = WQLObject.getWQLObject("st_ivt_bsrealstorattr").query("stor_id ='" + MapUtil.getStr(map, "stor_id") + "'").uniqueResult(0); + map.put("iostorinv_id", iostorinv_id); + map.put("bill_code", bill_code); + map.put("biz_date", map.getString("biz_date").substring(0, 10)); + String bill_type = (String) map.get("bill_type"); + map.put("buss_type", bill_type.substring(0, 4)); + map.put("io_type", "1"); + map.put("detail_count", rows.size() + ""); + map.put("create_mode", "01"); + map.put("stor_code", jsonStor.getString("stor_code")); + map.put("stor_name", jsonStor.getString("stor_name")); + map.put("input_optid", currentUserId + ""); + map.put("input_optname", nickName); + map.put("input_time", now); + map.put("update_optid", currentUserId + ""); + map.put("update_optname", nickName); + map.put("update_time", now); + map.put("is_delete", "0"); + map.put("is_upload", "0"); + if (ObjectUtil.isNotEmpty(user)) { + if (!user.equals("mes") || user.equals("sap")) { + Long deptId = SecurityUtils.getDeptId(); + map.put("sysdeptid", deptId); + map.put("syscompanyid", deptId); + } + } + double qty = 0.0; // 主表重量 + int num = rows.size(); // 明细数 + for (int i = 0; i < rows.size(); i++) { + JSONObject row = rows.getJSONObject(i); + JSONObject jsonDtl = new JSONObject(); + jsonDtl.put("iostorinvdtl_id", IdUtil.getSnowflake(1, 1).nextId() + ""); + jsonDtl.put("iostorinv_id", iostorinv_id); + jsonDtl.put("seq_no", (i + 1) + ""); + jsonDtl.put("material_id", row.getString("material_id")); + jsonDtl.put("pcsn", row.getString("pcsn")); + jsonDtl.put("box_no", row.getString("box_no")); + jsonDtl.put("quality_scode", "01"); + jsonDtl.put("bill_status", "10"); + jsonDtl.put("qty_unit_id", row.get("qty_unit_id")); + jsonDtl.put("qty_unit_name", row.getString("qty_unit_name")); + jsonDtl.put("plan_qty", row.get("plan_qty")); + jsonDtl.put("remark", row.getString("remark")); + jsonDtl.put("source_bill_code", row.getString("source_bill_code")); + jsonDtl.put("assign_qty", "0"); + jsonDtl.put("unassign_qty", row.get("plan_qty")); + jsonDtl.put("vbeln", row.getString("vbeln")); + jsonDtl.put("posnr", row.getString("posnr")); + WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").insert(jsonDtl); + qty += jsonDtl.getDoubleValue("plan_qty"); + + // 判断此明细子卷是否存在,存在则将此木箱下的子卷全部生成明细 + String pcsn = row.getString("pcsn"); + if (ObjectUtil.isNotEmpty(pcsn)) { + JSONObject json = ivtTab.query("pcsn = '" + pcsn + "'").uniqueResult(0); + if (ObjectUtil.isEmpty(json)) continue; + + JSONObject jsonMap = new JSONObject(); + jsonMap.put("flag", "1"); + jsonMap.put("pcsn", pcsn); + jsonMap.put("struct_id", json.getString("struct_id")); + + JSONArray ivtArr = WQL.getWO("ST_OUTIVT02").addParamMap(jsonMap).process().getResultJSONArray(0); + for (int j = 0; j < ivtArr.size(); j++) { + JSONObject jsonIvt = ivtArr.getJSONObject(j); + JSONObject jsonDtl2 = new JSONObject(); + + jsonDtl2.put("iostorinvdtl_id", IdUtil.getSnowflake(1, 1).nextId() + ""); + jsonDtl2.put("iostorinv_id", iostorinv_id); + jsonDtl2.put("seq_no", i + 2 + j); + jsonDtl2.put("material_id", jsonIvt.getString("material_id")); + jsonDtl2.put("pcsn", jsonIvt.getString("pcsn")); + jsonDtl2.put("box_no", jsonIvt.getString("box_no")); + jsonDtl2.put("quality_scode", "01"); + jsonDtl2.put("bill_status", "10"); + jsonDtl2.put("qty_unit_id", jsonIvt.get("qty_unit_id")); + jsonDtl2.put("qty_unit_name", jsonIvt.getString("qty_unit_name")); + jsonDtl2.put("plan_qty", jsonIvt.get("canuse_qty")); + jsonDtl2.put("remark", ""); + jsonDtl2.put("assign_qty", "0"); + jsonDtl2.put("unassign_qty", jsonIvt.get("canuse_qty")); + jsonDtl2.put("source_billdtl_id", jsonDtl.getString("iostorinvdtl_id")); + WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").insert(jsonDtl2); + + qty += jsonDtl2.getDoubleValue("plan_qty"); + } + num += ivtArr.size(); + } + + } + map.put("total_qty", qty); + map.put("detail_count", num); + WQLObject.getWQLObject("ST_IVT_IOStorInv").insert(map); + + return iostorinv_id; + } + @Override public JSONArray getOutBillDtl(Map whereJson) { whereJson.put("flag", "2");