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 f8df38c80..12adc2f6a 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 @@ -76,11 +76,19 @@ case when plan.paper_tube_or_FRP = '1' then plan.paper_tube_description when plan.paper_tube_or_FRP = '2' then plan.FRP_description end AS paper_name, sub.box_weight, CASE - WHEN DATEDIFF( NOW(), sub.date_of_production ) > '60' - AND DATEDIFF( NOW(), sub.date_of_production ) <= '90' THEN '2' - WHEN DATEDIFF( NOW(), sub.date_of_production ) <= '90' THEN '1' - WHEN DATEDIFF( NOW(), sub.date_of_production ) > '90' THEN '3' + WHEN SUBSTRING( sub.container_name, 1, 1 ) = 'B' THEN + CASE + WHEN DATEDIFF( NOW(), sub.date_of_production ) > '150' AND DATEDIFF( NOW(), sub.date_of_production ) <= '180' THEN '2' + WHEN DATEDIFF( NOW(), sub.date_of_production ) <= '180' THEN '1' + WHEN DATEDIFF( NOW(), sub.date_of_production ) > '180' THEN '3' + END + WHEN SUBSTRING( sub.container_name, 1, 1 ) <> 'B' THEN + CASE + WHEN DATEDIFF( NOW(), sub.date_of_production ) > '60' AND DATEDIFF( NOW(), sub.date_of_production ) <= '90' THEN '2' + WHEN DATEDIFF( NOW(), sub.date_of_production ) <= '90' THEN '1' + WHEN DATEDIFF( NOW(), sub.date_of_production ) > '90' THEN '3' + END END AS sub_type, DATEDIFF( NOW(), sub.date_of_production ) AS stock_age 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 a8e3f3d7e..b96fd7548 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 @@ -366,7 +366,7 @@ public class SapToLmsServiceImpl implements SapToLmsService { JSONObject json = item.getJSONObject(i); lfart = json.getString("LFART"); JSONObject jsonDtl = new JSONObject(); - if (StrUtil.equals(lfart, "ZLF")) { + if (StrUtil.equals(lfart, "ZLF") || StrUtil.equals(lfart, "ZJS")) { // 生成出库单 jsonMst.put("io_type", "1"); jsonMst.put("buss_type", "1001"); @@ -485,8 +485,7 @@ public class SapToLmsServiceImpl implements SapToLmsService { box_rows.add(map); } } - - + // 发货出库 if (StrUtil.equals(lfart, "ZLF")) { jsonMst.put("tableData", tableData); // 调用出库新增并分配 @@ -494,6 +493,17 @@ public class SapToLmsServiceImpl implements SapToLmsService { JSONObject jsonObject = new JSONObject(); jsonObject.put("iostorinv_id", iostorinv_id); } + // 分拣出库 + if (StrUtil.equals(lfart, "ZJS")) { + jsonMst.put("buss_type", "1011"); + jsonMst.put("bill_type", "1011"); + jsonMst.put("tableData", tableData); + // 调用出库新增并分配 + String iostorinv_id = checkOutBillService.insertDtl2(jsonMst); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("iostorinv_id", iostorinv_id); + } + // 退货入库 if (StrUtil.equals(lfart, "ZLR")) { jsonMst.put("tableData", box_rows); //创建退货入库单 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 445fb3432..3978620d5 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 @@ -319,4 +319,13 @@ public interface CheckOutBillService { * @param request、 */ void importExcel(MultipartFile file, HttpServletRequest request); + + /** + * 更新分拣出库重量 + * @param whereJson { + * dtl: 明细数据 + * tabledis: 分配明细集合 + * } + */ + void saveUpdate(JSONObject whereJson); } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/rest/CheckOutBillController.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/rest/CheckOutBillController.java index f761acbd9..9e99a9de2 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/rest/CheckOutBillController.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/rest/CheckOutBillController.java @@ -320,4 +320,11 @@ public class CheckOutBillController { checkOutBillService.importExcel(file, request); return new ResponseEntity<>(HttpStatus.OK); } + + @PostMapping("/saveUpdate") + @Log("更新分拣出库重量") + public ResponseEntity saveUpdate(@RequestBody JSONObject whereJson) { + checkOutBillService.saveUpdate(whereJson); + return new ResponseEntity<>(HttpStatus.OK); + } } 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 ba71db257..d0a2d955c 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 @@ -1241,6 +1241,72 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { } } + @Override + @Transactional(rollbackFor = Exception.class) + public void saveUpdate(JSONObject whereJson) { + // 分配明细表 + WQLObject disTab = WQLObject.getWQLObject("st_ivt_iostorinvdis"); + // 明细表 + WQLObject dtlTab = WQLObject.getWQLObject("st_ivt_iostorinvdtl"); + // 库存表 + WQLObject ivtTab = WQLObject.getWQLObject("st_ivt_structivt"); + + JSONObject jsonDtl = whereJson.getJSONObject("dtl"); + List disArr = whereJson.getJSONArray("tabledis").toJavaList(JSONObject.class); + + for (int i = 0; i < disArr.size(); i++) { + JSONObject json = disArr.get(i); + + // 输入数量不能为零 + if (json.getDoubleValue("plan_qty") == 0) { + throw new BadRequestException("输入数量不能为0!"); + } + + // 更新冻结库存 + JSONObject jsonIvt = ivtTab.query("pcsn = '" + json.getString("pcsn") + "'").uniqueResult(0); + if (ObjectUtil.isEmpty(jsonIvt)) { + throw new BadRequestException("库存不存在!"+json.getString("pcsn")); + } + + jsonIvt.put("frozen_qty", json.getDoubleValue("plan_qty")); + // 冻结库存不能超过库存数量 + if (jsonIvt.getDoubleValue("frozen_qty") > jsonIvt.getDoubleValue("ivt_qty")) { + throw new BadRequestException("输入数量不能大于库存数量! 当前库存数为:"+jsonIvt.getString("ivt_qty")); + } + + // 更新库存数 + double canuse_qty = NumberUtil.sub(jsonIvt.getDoubleValue("ivt_qty"), jsonIvt.getDoubleValue("frozen_qty")); + jsonIvt.put("canuse_qty",canuse_qty); + + ivtTab.update(jsonIvt); + + // 更新分配明细 + json.put("real_qty", json.getDoubleValue("plan_qty")); + disTab.update(json); + } + + // 更新明细 + double assign_qty = disArr.stream() + .map(row -> row.getDoubleValue("plan_qty")) + .reduce(Double::sum).orElse(0.00); + // 已分配重量 + jsonDtl.put("assign_qty", assign_qty); + + // 未分配重量/明细状态 + double unassign_qty = NumberUtil.sub(jsonDtl.getDoubleValue("plan_qty"), assign_qty); + if (unassign_qty <= 0) { + jsonDtl.put("unassign_qty", 0); + jsonDtl.put("bill_status", "40"); + } else { + jsonDtl.put("unassign_qty", unassign_qty); + jsonDtl.put("bill_status", "30"); + } + dtlTab.update(jsonDtl); + + // 更新主表状态 + updateMststatus(jsonDtl.getString("iostorinv_id")); + } + @Override @Transactional(rollbackFor = Exception.class) public void update(JSONObject whereJson) { @@ -2472,8 +2538,15 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { String iostorinv_id = whereJson.getString("iostorinv_id"); //查询主表信息 JSONObject jo_mst = wo_mst.query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0); - // 查询此分配明细下的所有相同箱号的分配明细 - JSONArray diss = wo_dis.query("box_no = '" + whereJson.getString("storagevehicle_code") + "' and iostorinv_id = '" + iostorinv_id + "'").getResultJSONArray(0); + // 查询此分配明细下的所有相同箱号的分配明细-- 如果为分拣出库则只需要更新当前子卷库存 + JSONArray diss; + if (jo_mst.getString("bill_type").equals("1011")) { + diss = wo_dis.query("pcsn = '" + whereJson.getString("pcsn") + "' and iostorinv_id = '" + iostorinv_id + "'").getResultJSONArray(0); + + } else { + diss = wo_dis.query("box_no = '" + whereJson.getString("storagevehicle_code") + "' and iostorinv_id = '" + iostorinv_id + "'").getResultJSONArray(0); + + } for (int i = 0; i < diss.size(); i++) { JSONObject dis = diss.getJSONObject(i); @@ -2544,18 +2617,28 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { map.put("is_delete", "1"); wo_Task.update(map, "task_id='" + dis.getString("task_id") + "'"); } - //解锁起点仓位点位 - JSONObject from_start = new JSONObject(); - from_start.put("struct_id", dis.getString("struct_id")); - from_start.put("lock_type", "1"); - storPublicService.updateStructAndPoint2(from_start); - //解锁终点仓位点位 - if (StrUtil.isNotEmpty(dis.getString("point_code"))) { - JSONObject from_end = new JSONObject(); - from_end.put("point_code", dis.getString("point_code")); - from_end.put("lock_type", "1"); - storPublicService.updateStructAndPoint2(from_end); + //解锁起点仓位点位: 判断此仓位是否还有库存 + List ivtList = WQLObject.getWQLObject("st_ivt_structivt") + .query("struct_id = '" + dis.getString("struct_id") + "'") + .getResultJSONArray(0).toJavaList(JSONObject.class); + + boolean is_zero = ivtList.stream() + .allMatch(row -> row.getDoubleValue("frozen_qty") == 0); + + if (is_zero) { + JSONObject from_start = new JSONObject(); + from_start.put("struct_id", dis.getString("struct_id")); + from_start.put("lock_type", "1"); + storPublicService.updateStructAndPoint2(from_start); + //解锁终点仓位点位 + if (StrUtil.isNotEmpty(dis.getString("point_code"))) { + JSONObject from_end = new JSONObject(); + from_end.put("point_code", dis.getString("point_code")); + from_end.put("lock_type", "1"); + storPublicService.updateStructAndPoint2(from_end); + } } + } else {//仓位载具扔有冻结数,需改任务类型为拣选出库 //任务号不为空 /* if (ObjectUtil.isNotEmpty(dis.getString("task_id"))) { diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/returns/service/impl/InAndOutRetrunServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/returns/service/impl/InAndOutRetrunServiceImpl.java index 00422dfce..9dd91345b 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/returns/service/impl/InAndOutRetrunServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/returns/service/impl/InAndOutRetrunServiceImpl.java @@ -660,7 +660,7 @@ public class InAndOutRetrunServiceImpl implements InAndOutReturnService { } // 销售出库 - if (StrUtil.equals(bill_type, "1001")) { + if (StrUtil.equals(bill_type, "1001") || StrUtil.equals(bill_type, "1011")) { // 1.回传sap JSONArray paramSapMstArr = new JSONArray(); @@ -1284,7 +1284,7 @@ public class InAndOutRetrunServiceImpl implements InAndOutReturnService { } // 销售出库 - if (StrUtil.equals(bill_type, "1001")) { + if (StrUtil.equals(bill_type, "1001") || StrUtil.equals(bill_type, "1011") ) { // 1.回传sap JSONArray paramSapMstArr = new JSONArray(); 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 8e88a2efb..254b9c61d 100644 --- a/lms/nladmin-ui/src/views/wms/st/outbill/DivDialog.vue +++ b/lms/nladmin-ui/src/views/wms/st/outbill/DivDialog.vue @@ -87,7 +87,6 @@ 一键设置 + + 保存修改 + @@ -273,11 +285,16 @@ - + - + + + @@ -655,6 +672,25 @@ export default { this.loadingSetAllPoint = false }) }, + saveUpdate() { + if (this.tabledis.length === 0) { + this.crud.notify('分配明细为空!', CRUD.NOTIFICATION_TYPE.INFO) + return + } + this.loadingSetAllPoint = true + const data = { + 'dtl': this.currentRow, + 'tabledis': this.tabledis + } + checkoutbill.saveUpdate(data).then(res => { + this.queryTableDtl() + this.queryTableDdis(this.currentRow.iostorinvdtl_id) + this.crud.notify('保存成功!', CRUD.NOTIFICATION_TYPE.INFO) + this.loadingSetAllPoint = false + }).catch(() => { + this.loadingSetAllPoint = false + }) + }, allSetPointAllDtl() { if (this.form2.point_code === '') { this.crud.notify('请先选择站点!', CRUD.NOTIFICATION_TYPE.INFO) diff --git a/lms/nladmin-ui/src/views/wms/st/outbill/checkoutbill.js b/lms/nladmin-ui/src/views/wms/st/outbill/checkoutbill.js index 2aa093377..bc41b9bd2 100644 --- a/lms/nladmin-ui/src/views/wms/st/outbill/checkoutbill.js +++ b/lms/nladmin-ui/src/views/wms/st/outbill/checkoutbill.js @@ -255,4 +255,11 @@ export function excelImport(data) { data }) } -export default { add, edit, del, allDiv, allCancel, getOutBillDtl, getOutBillDis, getOutBillDis2, setPoint, oneSetPoint, getOutBillTask, getStructIvt, manualDiv, confirm, issueTask, finishTask, cancleTaskfinish, getInvTypes, paramByCodeType, schAreaType, backConfirm, getOutBillDisDtl, getType, allDivOne, moneySubmit, getDisNum, queryBox, getOutBillTask2, oneCancel, cancelTask, allSetPoint, oneSetPoint2, outReturn, updataIsOverdue, excelImport } +export function saveUpdate(data) { + return request({ + url: '/api/checkoutbill/saveUpdate', + method: 'post', + data + }) +} +export default { add, edit, del, allDiv, allCancel, getOutBillDtl, getOutBillDis, getOutBillDis2, setPoint, oneSetPoint, getOutBillTask, getStructIvt, manualDiv, confirm, issueTask, finishTask, cancleTaskfinish, getInvTypes, paramByCodeType, schAreaType, backConfirm, getOutBillDisDtl, getType, allDivOne, moneySubmit, getDisNum, queryBox, getOutBillTask2, oneCancel, cancelTask, allSetPoint, oneSetPoint2, outReturn, updataIsOverdue, excelImport, saveUpdate }