From b6736b9a9ddd4cce5ba7ddcf32a6b941df85964d Mon Sep 17 00:00:00 2001 From: liuxy Date: Tue, 30 Apr 2024 10:57:40 +0800 Subject: [PATCH] =?UTF-8?q?add=EF=BC=9A=E6=8B=A3=E9=80=89=E5=87=BA?= =?UTF-8?q?=E5=BA=93=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/StorPublicServiceImpl.java | 6 + .../service/impl/CheckOutBillServiceImpl.java | 268 ++++++++++++++++-- .../src/views/wms/st/outbill/AddDialog.vue | 35 ++- .../src/views/wms/st/outbill/DivDialog.vue | 7 + 4 files changed, 292 insertions(+), 24 deletions(-) diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/impl/StorPublicServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/impl/StorPublicServiceImpl.java index 05306e8fe..7269c4f0e 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/impl/StorPublicServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/impl/StorPublicServiceImpl.java @@ -484,6 +484,12 @@ public class StorPublicServiceImpl implements StorPublicService { map.put("storagevehicle_code", storagevehicle_code); } + if (ObjectUtil.isNotEmpty(from.getString("bill_type"))) { + if (from.getString("bill_type").equals("1011")){ + map.put("storagevehicle_code", storagevehicle_code); + } + } + wo_Struct.update(map, "struct_id = '" + jo.getString("struct_id") + "'"); wo_Point.update(map, "point_id = '" + jo.getString("point_id") + "'"); } else {//锁定 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 a3e6bf81a..18bef91d5 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 @@ -398,6 +398,11 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { @Override @Transactional(rollbackFor = Exception.class) public String insertDtl(JSONObject map) { + if(MapUtil.getStr(map,"bill_type").equals("1011")) { + String iostorinv_id = inserdtlPic(map); + return iostorinv_id ; + } + WQLObject ivtTab = WQLObject.getWQLObject("ST_IVT_StructIvt"); //明细另一种写法 JSONArray array = map.getJSONArray("tableData"); @@ -555,6 +560,116 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { return iostorinv_id; } + /** + * 拣选出库新增 + * @param map 、 + * @return 单据标识 + */ + private String inserdtlPic(JSONObject map) { + + WQLObject ivtTab = WQLObject.getWQLObject("ST_IVT_StructIvt"); + //明细另一种写法 + JSONArray rows = map.getJSONArray("tableData"); + + map.remove("tableData"); + String currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getCurrentNickName(); + String user = map.getString("user"); + if (ObjectUtil.isNotEmpty(user)) { + if ("mes".equals(user)) { + currentUserId = "2"; + nickName = "mes用户"; + } + if ("sap".equals(user)) { + currentUserId = "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"); + map.put("out_stor_id", map.getString("out_stor_id")); + if (ObjectUtil.isNotEmpty(user)) { + if (!"mes".equals(user) || "sap".equals(user)) { + 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); + // 校验计划数量不能为零 + double plan_qty = row.getDoubleValue("plan_qty"); + if (Double.compare(plan_qty, 0.0) == 0) { + throw new BadRequestException("数量不能为0"); + } + 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"); + String box_no = row.getString("box_no"); + //查询该箱子所在货位 + JSONObject struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("storagevehicle_code = '" + box_no + "'").uniqueResult(0); + if (ObjectUtil.isNotEmpty(pcsn)) { + if (ObjectUtil.isEmpty(struct_jo)) { + throw new BadRequestException("未查询到该批次所在货位!"); + } + String struct_code = struct_jo.getString("struct_code"); + JSONObject json = ivtTab.query("pcsn = '" + pcsn + "' AND struct_code = '" + struct_code + "'").uniqueResult(0); + if (ObjectUtil.isEmpty(json)) { + continue; + } + } + + } + map.put("total_qty", qty); + map.put("detail_count", num); + WQLObject.getWQLObject("ST_IVT_IOStorInv").insert(map); + + return iostorinv_id; + } + @Override @Transactional(rollbackFor = Exception.class) public String insertDtl2(JSONObject map) { @@ -1129,6 +1244,11 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { @Override @Transactional(rollbackFor = Exception.class) public void update(JSONObject whereJson) { + + if (whereJson.getString("bill_type").equals("1011")) { + updatePic(whereJson); + return; + } String currentUserId = SecurityUtils.getCurrentUserId(); String nickName = SecurityUtils.getCurrentNickName(); @@ -1254,6 +1374,82 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { } } + /** + * 分拣出库修改 + * @param whereJson、 + */ + private void updatePic(JSONObject whereJson) { + String currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getCurrentNickName(); + + String now = DateUtil.now(); + whereJson.put("update_optid", currentUserId + ""); + whereJson.put("update_optname", nickName); + whereJson.put("update_time", now); + + WQLObject wo = WQLObject.getWQLObject("ST_IVT_IOStorInv"); + WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl"); + WQLObject ivtTab = WQLObject.getWQLObject("ST_IVT_StructIvt"); + + wo.update(whereJson); + //先删除该单据下的所有明细 + String iostorinv_id = (String) whereJson.get("iostorinv_id"); + wo_dtl.delete("iostorinv_id = '" + iostorinv_id + "'"); + + JSONArray rows = whereJson.getJSONArray("tableData"); + + double qty = 0.0; // 主表重量 + int num = rows.size(); // 明细数 + for (int i = 0; i < rows.size(); i++) { + JSONObject row = rows.getJSONObject(i); + // 校验计划数量不能为零 + double plan_qty = row.getDoubleValue("plan_qty"); + if (Double.compare(plan_qty, 0) == 0) { + throw new BadRequestException("数量不能为0"); + } + + 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"); + String box_no = row.getString("box_no"); + //查询该箱子所在货位 + JSONObject struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("storagevehicle_code = '" + box_no + "'").uniqueResult(0); + if (ObjectUtil.isNotEmpty(pcsn)) { + if (ObjectUtil.isEmpty(struct_jo)) { + throw new BadRequestException("未查询到该批次所在货位!"); + } + String struct_code = struct_jo.getString("struct_code"); + JSONObject json = ivtTab.query("pcsn = '" + pcsn + "' AND struct_code = '" + struct_code + "'").uniqueResult(0); + if (ObjectUtil.isEmpty(json)) { + continue; + } + } + whereJson.put("total_qty", qty); + whereJson.put("detail_count", num); + wo.update(whereJson); + } + } + @Override @Transactional(rollbackFor = Exception.class) public void allDiv(JSONObject whereJson) { @@ -1425,7 +1621,13 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { throw new BadRequestException("库存不足"); } - double canuse_qty = jsonIvt.getDoubleValue("canuse_qty"); + double canuse_qty ; + if (StrUtil.equals(bill_type, "1011")) { + canuse_qty = dtl.getDoubleValue("plan_qty"); + } else { + canuse_qty = jsonIvt.getDoubleValue("canuse_qty"); + } + jsonIvt.put("change_qty", canuse_qty + ""); unassign_qty = 0; assign_qty = NumberUtil.add(assign_qty, canuse_qty); @@ -4402,23 +4604,6 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { storPublicService.IOStor(dis, "21"); } } - //解锁起点 - JSONObject from_start = new JSONObject(); - from_start.put("struct_id", dis.getString("struct_id")); - from_start.put("lock_type", "1"); - from_start.put("is_overdue", dis.getString("is_overdue")); - - if (jo_mst.getString("is_overdue").equals("1")) { - if (dis.getString("is_overdue").equals("1")) { - from_start.put("storagevehicle_code", dis.getString("box_no")); - } else { - from_start.put("storagevehicle_code", ""); - } - } else { - from_start.put("storagevehicle_code", ""); - } - - storPublicService.updateStructAndPoint(from_start); // 更新分配明细执行状态为 - 99 JSONObject jsonDis = wo_dis.query("iostorinvdis_id = '" + dis.getString("iostorinvdis_id") + "'").uniqueResult(0); @@ -4450,8 +4635,55 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { } else { jsonSub.put("status", "3"); } + + if (jo_mst.getString("bill_type").equals("1011")) { + // 更新子卷包装净重 + double net_weight = NumberUtil.sub(jsonSub.getDoubleValue("net_weight"), plan_qty); + jsonSub.put("net_weight",net_weight); + + if (net_weight <= 0) { + jsonSub.put("status","3"); + } else { + jsonSub.put("status","2"); + } + } + subTab.update(jsonSub); + // 解锁起点 + JSONObject from_start = new JSONObject(); + from_start.put("struct_id", dis.getString("struct_id")); + from_start.put("lock_type", "1"); + from_start.put("is_overdue", dis.getString("is_overdue")); + + if (jo_mst.getString("is_overdue").equals("1")) { + if (dis.getString("is_overdue").equals("1")) { + from_start.put("storagevehicle_code", dis.getString("box_no")); + } else { + from_start.put("storagevehicle_code", ""); + } + } else { + from_start.put("storagevehicle_code", ""); + } + + if (jo_mst.getString("bill_type").equals("1011")) { + // 判断此木箱下的所有子卷净重是否为0,如果为0则清空载具 + List packageList = subTab.query("package_box_sn = '" + jsonSub.getString("package_box_sn") + "'") + .getResultJSONArray(0).toJavaList(JSONObject.class); + + boolean is_zero = packageList.stream() + .allMatch(row -> row.getDoubleValue("net_weight") <= 0); + + if (is_zero) { + from_start.put("storagevehicle_code", ""); + } else { + from_start.put("bill_type","1011"); + from_start.put("storagevehicle_code", jsonSub.getString("package_box_sn")); + } + } + + storPublicService.updateStructAndPoint(from_start); + //插入包装关系出入库记录表 jsonSub.put("bill_code", jo_mst.getString("bill_code")); jsonSub.put("bill_id", jo_mst.getString("iostorinv_id")); diff --git a/lms/nladmin-ui/src/views/wms/st/outbill/AddDialog.vue b/lms/nladmin-ui/src/views/wms/st/outbill/AddDialog.vue index 42c74cb20..7f2c98f93 100644 --- a/lms/nladmin-ui/src/views/wms/st/outbill/AddDialog.vue +++ b/lms/nladmin-ui/src/views/wms/st/outbill/AddDialog.vue @@ -440,9 +440,8 @@ export default { const data = { 'data': rows } - checkoutbill.queryBox(data).then(res => { - res.forEach((item) => { - debugger + if(this.form.bill_type === '1011') { + rows.forEach((item) => { if (this.form.tableData.length !== 0) { this.flagnow = false for (let i = 0; i < this.form.tableData.length; i++) { @@ -451,18 +450,42 @@ export default { } } if (!this.flagnow) { - item.edit = true + item.edit = false this.form.tableData.splice(-1, 0, item) this.form.total_qty = parseFloat(this.form.total_qty) + parseFloat(item.plan_qty) } } else { - item.edit = true + item.edit = false this.form.tableData.splice(-1, 0, item) this.form.total_qty = parseFloat(this.form.total_qty) + parseFloat(item.plan_qty) } }) this.form.detail_count = this.form.tableData.length - }) + } else { + checkoutbill.queryBox(data).then(res => { + res.forEach((item) => { + debugger + if (this.form.tableData.length !== 0) { + this.flagnow = false + for (let i = 0; i < this.form.tableData.length; i++) { + if (this.form.tableData[i].box_no === item.box_no && this.form.tableData[i].pcsn === item.pcsn) { + this.flagnow = true + } + } + if (!this.flagnow) { + item.edit = true + this.form.tableData.splice(-1, 0, item) + this.form.total_qty = parseFloat(this.form.total_qty) + parseFloat(item.plan_qty) + } + } else { + item.edit = true + this.form.tableData.splice(-1, 0, item) + this.form.total_qty = parseFloat(this.form.total_qty) + parseFloat(item.plan_qty) + } + }) + this.form.detail_count = this.form.tableData.length + }) + } }, setMaterValue(row) { for (let i = 0; i < this.form.tableData.length; i++) { diff --git a/lms/nladmin-ui/src/views/wms/st/outbill/DivDialog.vue b/lms/nladmin-ui/src/views/wms/st/outbill/DivDialog.vue index 4c1801ede..8e88a2efb 100644 --- a/lms/nladmin-ui/src/views/wms/st/outbill/DivDialog.vue +++ b/lms/nladmin-ui/src/views/wms/st/outbill/DivDialog.vue @@ -61,6 +61,7 @@ --> +