diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/service/impl/StructivtServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/service/impl/StructivtServiceImpl.java index 8ef86805e..047d94e93 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/service/impl/StructivtServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/service/impl/StructivtServiceImpl.java @@ -48,6 +48,7 @@ public class StructivtServiceImpl implements StructivtService { String material = MapUtil.getStr(whereJson, "material"); String struct = MapUtil.getStr(whereJson, "struct"); String stor_id = MapUtil.getStr(whereJson, "stor_id"); + String sect_id = MapUtil.getStr(whereJson, "sect_id"); String pcsn = MapUtil.getStr(whereJson, "pcsn"); String sap_pcsn = MapUtil.getStr(whereJson, "sap_pcsn"); String package_box_sn = MapUtil.getStr(whereJson, "package_box_sn"); @@ -55,6 +56,7 @@ public class StructivtServiceImpl implements StructivtService { JSONObject map = new JSONObject(); map.put("flag", "1"); map.put("stor_id", stor_id); + map.put("sect_id", sect_id); if (StrUtil.isNotEmpty(material)) { map.put("material", "%" + material + "%"); } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/wql/QST_STRUCTIVT001.wql b/lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/wql/QST_STRUCTIVT001.wql index 2d601ad29..cc92bed3e 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/wql/QST_STRUCTIVT001.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/wql/QST_STRUCTIVT001.wql @@ -17,6 +17,7 @@ 输入.struct TYPEAS s_string 输入.material TYPEAS s_string 输入.stor_id TYPEAS s_string + 输入.sect_id TYPEAS s_string 输入.pcsn TYPEAS s_string 输入.sap_pcsn TYPEAS s_string 输入.sale_order_name TYPEAS s_string @@ -95,6 +96,10 @@ attr.stor_id = 输入.stor_id ENDOPTION + OPTION 输入.sect_id <> "" + attr.sect_id = 输入.sect_id + ENDOPTION + OPTION 输入.package_box_sn <> "" sub.package_box_sn like 输入.package_box_sn ENDOPTION diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/ext/mes/service/impl/MesToLmsServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/ext/mes/service/impl/MesToLmsServiceImpl.java index b5d26420b..30be23dac 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/ext/mes/service/impl/MesToLmsServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/ext/mes/service/impl/MesToLmsServiceImpl.java @@ -30,6 +30,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.HashMap; +import java.util.HashSet; @Service @RequiredArgsConstructor @@ -958,85 +959,121 @@ public class MesToLmsServiceImpl implements MesToLmsService { String SaleOrderItem = param.getString("SaleOrderItem"); String CustomerName = param.getString("CustomerName"); String DemandDate = param.getString("DemandDate"); - double total_qty = 0; - double detail_count = 0; - String changeinv_id = IdUtil.getSnowflake(1, 1).nextId() + ""; + if (ObjectUtil.isEmpty(rows) || rows.size() == 0) { throw new BadRequestException("item长度不能为0!"); } + + // 定义set集合储存仓库 + HashSet storSet = new HashSet<>(); + for (int i = 0; i < rows.size(); i++) { - JSONObject row = rows.getJSONObject(i); - String PackageBoxSN = row.getString("PackageBoxSN"); - String isRePrintPackageBoxLabel = row.getString("isRePrintPackageBoxLabel"); - String isUnPackBox = row.getString("isUnPackBox"); - String UpdatedDateOfProduction = row.getString("UpdatedDateOfProduction"); - //查询该木箱内子卷数量 - JSONArray container_rows = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("package_box_sn = '" + PackageBoxSN + "'").getResultJSONArray(0); - for (int j = 0; j < container_rows.size(); j++) { - JSONObject container_row = container_rows.getJSONObject(j); - JSONObject change_jo = new JSONObject(); - change_jo.put("changeinvdtl_id", IdUtil.getSnowflake(1, 1).nextId() + ""); - change_jo.put("changeinv_id", changeinv_id); - change_jo.put("seq_no", detail_count + 1); - JSONObject mater_jo = WQLObject.getWQLObject("md_me_materialbase").query("material_code = '" + container_row.getString("product_name") + "'").uniqueResult(0); - if (ObjectUtil.isEmpty(mater_jo)) - throw new BadRequestException("物料不存在:" + container_row.getString("product_name")); - change_jo.put("material_id", mater_jo.getString("material_id")); - change_jo.put("pcsn", container_row.getString("container_name")); - change_jo.put("package_box_sn", container_row.getString("package_box_sn")); - change_jo.put("mfg_order_name", SaleOrderItem); - change_jo.put("demand_date", DemandDate); - change_jo.put("customer_name", CustomerName); - //查询对应的客户 - JSONObject customer_jo = WQLObject.getWQLObject("md_cs_customerbase").query("cust_code = '" + CustomerName + "'").uniqueResult(0); - if (ObjectUtil.isEmpty(customer_jo)) throw new BadRequestException("客户不存在:" + CustomerName); - change_jo.put("customer_description", customer_jo.getString("cust_name")); - change_jo.put("isRePrintPackageBoxLabel", isRePrintPackageBoxLabel); - change_jo.put("isUnPackBox", isUnPackBox); - change_jo.put("UpdatedDateOfProduction", UpdatedDateOfProduction); - JSONObject unit = WQLObject.getWQLObject("md_pb_measureunit").query("measure_unit_id = '" + mater_jo.getString("base_unit_id") + "'").uniqueResult(0); - if (ObjectUtil.isEmpty(unit)) - throw new BadRequestException("计量单位不存在:" + mater_jo.getString("base_unit_id")); - change_jo.put("qty_unit_id", mater_jo.getString("base_unit_id")); - change_jo.put("qty_unit_name", unit.getString("unit_name")); - change_jo.put("qty", container_row.getString("net_weight")); - WQLObject.getWQLObject("ST_IVT_StructIvtChangeDtl").insert(change_jo); - total_qty += container_row.getDoubleValue("net_weight"); - detail_count += 1; + JSONObject json = rows.getJSONObject(i); + String PackageBoxSN = json.getString("PackageBoxSN"); + + // 查询此木箱在哪个仓库 + JSONObject jsonBox = WQLObject.getWQLObject("st_ivt_structattr") + .query("storagevehicle_code = '" + PackageBoxSN + "' and is_delete = '0' and is_used = '1' and lock_type = '1'").uniqueResult(0); + + if (ObjectUtil.isEmpty(jsonBox)) { + throw new BadRequestException("此木箱不在库内:"+PackageBoxSN); } + storSet.add(jsonBox.getString("stor_code")); } - String currentUserId = SecurityUtils.getCurrentUserId(); - String nickName = SecurityUtils.getCurrentNickName(); - String now = DateUtil.now(); - JSONObject mst_jo = new JSONObject(); - mst_jo.put("changeinv_id", changeinv_id); - mst_jo.put("bill_code", CodeUtil.getNewCode("CHANGE_CODE")); - mst_jo.put("buss_type", "2001"); - mst_jo.put("bill_type", "2001"); - mst_jo.put("biz_date", DateUtil.today()); - JSONObject stor = WQLObject.getWQLObject("st_ivt_bsrealstorattr").query("is_delete = '0' AND is_used = '1' AND is_productstore = '1'").uniqueResult(0); - if (ObjectUtil.isEmpty(stor)) throw new BadRequestException("仓库不存在!"); - mst_jo.put("stor_id", stor.getString("stor_id")); - mst_jo.put("stor_code", stor.getString("stor_code")); - mst_jo.put("stor_name", stor.getString("stor_name")); - mst_jo.put("total_qty", total_qty); - mst_jo.put("detail_count", detail_count); - mst_jo.put("bill_status", "10"); - mst_jo.put("create_mode", "03"); - mst_jo.put("input_optid", currentUserId + ""); - mst_jo.put("input_optname", nickName); - mst_jo.put("input_time", now); - mst_jo.put("update_optid", currentUserId + ""); - mst_jo.put("update_optname", nickName); - mst_jo.put("update_time", now); - mst_jo.put("is_delete", "0"); - mst_jo.put("is_upload", "0"); - Long deptId = SecurityUtils.getDeptId(); - mst_jo.put("sysdeptid", deptId + ""); - mst_jo.put("syscompanyid", deptId + ""); - WQLObject.getWQLObject("ST_IVT_StructIvtChange").insert(mst_jo); + // 根据仓库生成多个库存变更单据 + for (String stor_code : storSet) { + double total_qty = 0; + double detail_count = 0; + String changeinv_id = IdUtil.getSnowflake(1, 1).nextId() + ""; + JSONObject jsonStor = WQLObject.getWQLObject("st_ivt_bsrealstorattr").query("stor_code = '" + stor_code + "'").uniqueResult(0); + JSONArray rowsDtl = new JSONArray(); + + for (int i = 0; i < rows.size(); i++) { + JSONObject row = rows.getJSONObject(i); + String PackageBoxSN = row.getString("PackageBoxSN"); + + JSONObject jsonBox = WQLObject.getWQLObject("st_ivt_structattr") + .query("storagevehicle_code = '" + PackageBoxSN + "' and is_delete = '0' and is_used = '1' and lock_type = '1'").uniqueResult(0); + + if (StrUtil.equals(jsonBox.getString("stor_code"),stor_code)) { + rowsDtl.add(row); + } + } + + // 插入库存变更主表明细表 + for (int i = 0; i < rowsDtl.size(); i++) { + JSONObject row = rowsDtl.getJSONObject(i); + String PackageBoxSN = row.getString("PackageBoxSN"); + String isRePrintPackageBoxLabel = row.getString("isRePrintPackageBoxLabel"); + String isUnPackBox = row.getString("isUnPackBox"); + String UpdatedDateOfProduction = row.getString("UpdatedDateOfProduction"); + //查询该木箱内子卷数量 + JSONArray container_rows = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("package_box_sn = '" + PackageBoxSN + "'").getResultJSONArray(0); + for (int j = 0; j < container_rows.size(); j++) { + JSONObject container_row = container_rows.getJSONObject(j); + JSONObject change_jo = new JSONObject(); + change_jo.put("changeinvdtl_id", IdUtil.getSnowflake(1, 1).nextId() + ""); + change_jo.put("changeinv_id", changeinv_id); + change_jo.put("seq_no", detail_count + 1); + JSONObject mater_jo = WQLObject.getWQLObject("md_me_materialbase").query("material_code = '" + container_row.getString("product_name") + "'").uniqueResult(0); + if (ObjectUtil.isEmpty(mater_jo)) + throw new BadRequestException("物料不存在:" + container_row.getString("product_name")); + change_jo.put("material_id", mater_jo.getString("material_id")); + change_jo.put("pcsn", container_row.getString("container_name")); + change_jo.put("package_box_sn", container_row.getString("package_box_sn")); + change_jo.put("mfg_order_name", SaleOrderItem); + change_jo.put("demand_date", DemandDate); + change_jo.put("customer_name", CustomerName); + //查询对应的客户 + JSONObject customer_jo = WQLObject.getWQLObject("md_cs_customerbase").query("cust_code = '" + CustomerName + "'").uniqueResult(0); + if (ObjectUtil.isEmpty(customer_jo)) throw new BadRequestException("客户不存在:" + CustomerName); + change_jo.put("customer_description", customer_jo.getString("cust_name")); + change_jo.put("isRePrintPackageBoxLabel", isRePrintPackageBoxLabel); + change_jo.put("isUnPackBox", isUnPackBox); + change_jo.put("UpdatedDateOfProduction", UpdatedDateOfProduction); + JSONObject unit = WQLObject.getWQLObject("md_pb_measureunit").query("measure_unit_id = '" + mater_jo.getString("base_unit_id") + "'").uniqueResult(0); + if (ObjectUtil.isEmpty(unit)) + throw new BadRequestException("计量单位不存在:" + mater_jo.getString("base_unit_id")); + change_jo.put("qty_unit_id", mater_jo.getString("base_unit_id")); + change_jo.put("qty_unit_name", unit.getString("unit_name")); + change_jo.put("qty", container_row.getString("net_weight")); + WQLObject.getWQLObject("ST_IVT_StructIvtChangeDtl").insert(change_jo); + total_qty += container_row.getDoubleValue("net_weight"); + detail_count += 1; + } + } + String currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getCurrentNickName(); + String now = DateUtil.now(); + + JSONObject mst_jo = new JSONObject(); + mst_jo.put("changeinv_id", changeinv_id); + mst_jo.put("bill_code", CodeUtil.getNewCode("CHANGE_CODE")); + mst_jo.put("buss_type", "2001"); + mst_jo.put("bill_type", "2001"); + mst_jo.put("biz_date", DateUtil.today()); + mst_jo.put("stor_id", jsonStor.getString("stor_id")); + mst_jo.put("stor_code", jsonStor.getString("stor_code")); + mst_jo.put("stor_name", jsonStor.getString("stor_name")); + mst_jo.put("total_qty", total_qty); + mst_jo.put("detail_count", detail_count); + mst_jo.put("bill_status", "10"); + mst_jo.put("create_mode", "03"); + mst_jo.put("input_optid", currentUserId + ""); + mst_jo.put("input_optname", nickName); + mst_jo.put("input_time", now); + mst_jo.put("update_optid", currentUserId + ""); + mst_jo.put("update_optname", nickName); + mst_jo.put("update_time", now); + mst_jo.put("is_delete", "0"); + mst_jo.put("is_upload", "0"); + Long deptId = SecurityUtils.getDeptId(); + mst_jo.put("sysdeptid", deptId + ""); + mst_jo.put("syscompanyid", deptId + ""); + WQLObject.getWQLObject("ST_IVT_StructIvtChange").insert(mst_jo); + } result.put("RTYPE", "S"); result.put("RTMSG", "操作成功!"); result.put("RTOAL", 1); diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/ChangeServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/ChangeServiceImpl.java index e28c5bc91..6a25a610b 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/ChangeServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/ChangeServiceImpl.java @@ -1,6 +1,7 @@ package org.nl.wms.st.instor.service.impl; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; @@ -119,10 +120,11 @@ public class ChangeServiceImpl implements ChangeService { mst_jo.put("buss_type", "2002"); mst_jo.put("bill_type", "2002"); mst_jo.put("biz_date", DateUtil.today()); - JSONObject stor = WQLObject.getWQLObject("st_ivt_bsrealstorattr").query("is_delete = '0' AND is_used = '1' AND is_productstore = '1'").uniqueResult(0); - mst_jo.put("stor_id", stor.getString("stor_id")); - mst_jo.put("stor_code", stor.getString("stor_code")); - mst_jo.put("stor_name", stor.getString("stor_name")); + +// JSONObject stor = WQLObject.getWQLObject("st_ivt_bsrealstorattr").query("is_delete = '0' AND is_used = '1' AND is_productstore = '1'").uniqueResult(0); + mst_jo.put("stor_id", MapUtil.getStr(map, "stor_id")); + mst_jo.put("stor_code", MapUtil.getStr(map, "stor_code")); + mst_jo.put("stor_name", MapUtil.getStr(map, "stor_name")); mst_jo.put("bill_status", "10"); mst_jo.put("create_mode", "01"); mst_jo.put("input_optid", currentUserId + ""); diff --git a/lms/nladmin-ui/src/views/wms/basedata/st/ivt/index.vue b/lms/nladmin-ui/src/views/wms/basedata/st/ivt/index.vue index cdd2e7f7b..7fc199ecc 100644 --- a/lms/nladmin-ui/src/views/wms/basedata/st/ivt/index.vue +++ b/lms/nladmin-ui/src/views/wms/basedata/st/ivt/index.vue @@ -11,22 +11,16 @@ label-width="90px" label-suffix=":" > - - + - - + @change="sectQueryChange" + /> { - this.storlist = res + crudUserStor.getSect({ 'stor_id': '' }).then(res => { + this.sects = res.content }) }, methods: { @@ -191,6 +183,21 @@ export default { hand(value) { this.crud.toQuery() }, + sectQueryChange(val) { + if (val.length === 1) { + this.query.stor_id = val[0] + this.query.sect_id = '' + } + if (val.length === 0) { + this.query.sect_id = '' + this.query.stor_id = '' + } + if (val.length === 2) { + this.query.stor_id = val[0] + this.query.sect_id = val[1] + } + this.crud.toQuery() + }, downdtl() { if (this.currentRow !== null) { crud.downloadLoading = true diff --git a/lms/nladmin-ui/src/views/wms/st/inStor/change/index.vue b/lms/nladmin-ui/src/views/wms/st/inStor/change/index.vue index a6c11910c..bee44b788 100644 --- a/lms/nladmin-ui/src/views/wms/st/inStor/change/index.vue +++ b/lms/nladmin-ui/src/views/wms/st/inStor/change/index.vue @@ -169,9 +169,12 @@ - + + + +