From 42c1a1b9b4c616078434152959355f2a2bb0b0f0 Mon Sep 17 00:00:00 2001 From: liejiu946 Date: Wed, 11 Jun 2025 11:00:05 +0800 Subject: [PATCH] =?UTF-8?q?opt:=201.=E5=87=BA=E5=BA=93=E5=88=86=E9=85=8D?= =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/MdPbStoragevehicleextMapper.java | 7 + .../mapper/MdPbStoragevehicleextMapper.xml | 52 +++ .../service/dto/MdPbStoragevehicleextDto.java | 6 + .../controller/OutBillController.java | 34 ++ .../service/IOutBillService.java | 37 ++ .../service/impl/OutBillServiceImpl.java | 384 +++++++++++++++++- .../src/views/wms/st/outbill/StructIvt.vue | 46 +-- .../src/views/wms/st/outbill/checkoutbill.js | 23 +- 8 files changed, 526 insertions(+), 63 deletions(-) diff --git a/wms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/basedata_manage/service/dao/mapper/MdPbStoragevehicleextMapper.java b/wms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/basedata_manage/service/dao/mapper/MdPbStoragevehicleextMapper.java index f66bffc..930b0a6 100644 --- a/wms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/basedata_manage/service/dao/mapper/MdPbStoragevehicleextMapper.java +++ b/wms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/basedata_manage/service/dao/mapper/MdPbStoragevehicleextMapper.java @@ -73,4 +73,11 @@ public interface MdPbStoragevehicleextMapper extends BaseMapper */ List getIosDtl(@Param("param") JSONObject whereJson); + + /** + * 查询可用库存 + * @param whereJson + * @return + */ + List queryAvailableInv(@Param("params") Map whereJson); } diff --git a/wms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/basedata_manage/service/dao/mapper/MdPbStoragevehicleextMapper.xml b/wms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/basedata_manage/service/dao/mapper/MdPbStoragevehicleextMapper.xml index 227036f..6a206ef 100644 --- a/wms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/basedata_manage/service/dao/mapper/MdPbStoragevehicleextMapper.xml +++ b/wms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/basedata_manage/service/dao/mapper/MdPbStoragevehicleextMapper.xml @@ -207,4 +207,56 @@ ORDER BY ext.insert_time Desc + + diff --git a/wms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/basedata_manage/service/dto/MdPbStoragevehicleextDto.java b/wms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/basedata_manage/service/dto/MdPbStoragevehicleextDto.java index 379a3fd..ded89d6 100644 --- a/wms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/basedata_manage/service/dto/MdPbStoragevehicleextDto.java +++ b/wms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/basedata_manage/service/dto/MdPbStoragevehicleextDto.java @@ -39,4 +39,10 @@ public class MdPbStoragevehicleextDto extends MdPbStoragevehicleext{ * 仓位名称 */ private String struct_name; + + /** + * 物料名称 + */ + private String material_name; + } diff --git a/wms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/warehouse_management/controller/OutBillController.java b/wms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/warehouse_management/controller/OutBillController.java index de62006..7ee5e41 100644 --- a/wms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/warehouse_management/controller/OutBillController.java +++ b/wms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/warehouse_management/controller/OutBillController.java @@ -85,4 +85,38 @@ public class OutBillController { iOutBillService.autoCancel(whereJson); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } + + @GetMapping("/getStructIvt") + @Log("查询可分配库存") + public ResponseEntity getStructIvt(@RequestParam Map whereJson) { + return new ResponseEntity<>(iOutBillService.queryAvailableInv(whereJson), HttpStatus.OK); + } + + @PostMapping("/manualDiv") + @Log("出库单手动分配") + public ResponseEntity manualDiv(@RequestBody JSONObject whereJson) { + iOutBillService.manualDiv(whereJson); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @PostMapping("/oneCancel") + @Log("出库单取消分配") + public ResponseEntity oneCancel (@RequestBody JSONObject whereJson) { + iOutBillService.oneCancel(whereJson); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @PostMapping("/allSetPoint") + @Log("一键设置") + public ResponseEntity allSetPoint(@RequestBody JSONObject whereJson) { + iOutBillService.allSetPoint(whereJson); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @PostMapping("/confirm") + @Log("出库单强制确认") + public ResponseEntity confirm(@RequestBody JSONObject whereJson) { + iOutBillService.confirm(whereJson); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } } diff --git a/wms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/warehouse_management/service/IOutBillService.java b/wms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/warehouse_management/service/IOutBillService.java index 95dd8e0..1a9c86f 100644 --- a/wms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/warehouse_management/service/IOutBillService.java +++ b/wms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/warehouse_management/service/IOutBillService.java @@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import org.nl.common.domain.query.PageQuery; +import org.nl.wms.basedata_manage.service.dto.MdPbStoragevehicleextDto; import org.nl.wms.warehouse_management.service.dao.IOStorInv; import org.nl.wms.warehouse_management.service.dto.IOStorInvDisDto; import org.nl.wms.warehouse_management.service.dto.IOStorInvDtlDto; @@ -94,4 +95,40 @@ public interface IOutBillService extends IService { * @param whereJson */ void autoCancel(JSONObject whereJson); + + /** + * 查询可用库存 + * @param whereJson + * @return + */ + List queryAvailableInv(Map whereJson); + + /** + * 出库单手动分配 + * + * @param whereJson / + */ + void manualDiv(JSONObject whereJson); + + /** + * 出库单取消分配 + * + * @param whereJson / + */ + void oneCancel(JSONObject whereJson); + + /** + * 设置全部站点 + * + * @param whereJson / + */ + void allSetPoint(JSONObject whereJson); + + /** + * 出库单强制确认(更新仓位以及库存信息) + * + * @param whereJson / + */ + void confirm(JSONObject whereJson); + } diff --git a/wms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/warehouse_management/service/impl/OutBillServiceImpl.java b/wms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/warehouse_management/service/impl/OutBillServiceImpl.java index e984a61..ec8472f 100644 --- a/wms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/warehouse_management/service/impl/OutBillServiceImpl.java +++ b/wms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/warehouse_management/service/impl/OutBillServiceImpl.java @@ -17,6 +17,7 @@ import org.nl.common.exception.BadRequestException; import org.nl.common.utils.CodeUtil; import org.nl.common.utils.SecurityUtils; import org.nl.config.IdUtil; +import org.nl.config.SpringContextHolder; import org.nl.wms.basedata_manage.enums.BaseDataEnum; import org.nl.wms.basedata_manage.service.IBsrealStorattrService; import org.nl.wms.basedata_manage.service.IMdPbStoragevehicleextService; @@ -25,12 +26,17 @@ import org.nl.wms.basedata_manage.service.dao.BsrealStorattr; import org.nl.wms.basedata_manage.service.dao.MdPbStoragevehicleext; import org.nl.wms.basedata_manage.service.dao.mapper.MdPbStoragevehicleextMapper; import org.nl.wms.basedata_manage.service.dto.MdPbStoragevehicleextDto; +import org.nl.wms.sch_manage.service.dao.SchBasePoint; +import org.nl.wms.sch_manage.service.dao.mapper.SchBasePointMapper; +import org.nl.wms.sch_manage.service.util.tasks.StInTask; import org.nl.wms.warehouse_management.enums.IOSConstant; import org.nl.wms.warehouse_management.enums.IOSEnum; import org.nl.wms.warehouse_management.service.IOutBillService; +import org.nl.wms.warehouse_management.service.dao.GroupPlate; import org.nl.wms.warehouse_management.service.dao.IOStorInv; import org.nl.wms.warehouse_management.service.dao.IOStorInvDis; import org.nl.wms.warehouse_management.service.dao.IOStorInvDtl; +import org.nl.wms.warehouse_management.service.dao.mapper.GroupPlateMapper; import org.nl.wms.warehouse_management.service.dao.mapper.IOStorInvDisMapper; import org.nl.wms.warehouse_management.service.dao.mapper.IOStorInvDtlMapper; import org.nl.wms.warehouse_management.service.dao.mapper.IOStorInvMapper; @@ -75,6 +81,12 @@ public class OutBillServiceImpl extends ServiceImpl i @Resource private IOStorInvDtlMapper ioStorInvDtlMapper; + @Resource + private GroupPlateMapper groupPlateMapper; + + @Resource + private SchBasePointMapper schBasePointMapper; + @Override public IPage pageQuery(Map whereJson, PageQuery page, String[] stor_id, String[] bill_status, String[] bill_type) { @@ -307,6 +319,7 @@ public class OutBillServiceImpl extends ServiceImpl i List outAllocationList = mdPbStoragevehicleextMapper.queryOutAllocation(pcsn,material_id); int seq_no = 1; + double allocation_canuse_qty = 0; for (MdPbStoragevehicleextDto outAllocation : outAllocationList) { //分配明细 IOStorInvDis ioStorInvDis = new IOStorInvDis(); @@ -329,10 +342,18 @@ public class OutBillServiceImpl extends ServiceImpl i ioStorInvDis.setWork_status(IOSEnum.INBILL_DIS_STATUS.code("生成")); // 未分配数量 - 该库位上的可用数量 < 0 目前做整出 +// double canuse_qty = outAllocation.getCanuse_qty().doubleValue(); +// if (unassign_qty-canuse_qty>=0){ +// ioStorInvDis.setPlan_qty(BigDecimal.valueOf(canuse_qty)); +// }else { +// ioStorInvDis.setPlan_qty(BigDecimal.valueOf(unassign_qty)); +// } +// unassign_qty = unassign_qty-canuse_qty; unassign_qty = unassign_qty-outAllocation.getCanuse_qty().doubleValue(); if (unassign_qty<0){ unassign_qty=0; } + allocation_canuse_qty = allocation_canuse_qty + outAllocation.getCanuse_qty().doubleValue(); ioStorInvDis.setPlan_qty(outAllocation.getCanuse_qty()); //锁定货位 @@ -368,7 +389,7 @@ public class OutBillServiceImpl extends ServiceImpl i //更新详情 dtl.setBill_status(IOSEnum.BILL_STATUS.code("分配完")); - double assign_qty = dtl.getUnassign_qty().doubleValue() + dtl.getAssign_qty().doubleValue(); + double assign_qty = allocation_canuse_qty + dtl.getAssign_qty().doubleValue(); dtl.setUnassign_qty(BigDecimal.valueOf(unassign_qty)); dtl.setAssign_qty(BigDecimal.valueOf(assign_qty)); ioStorInvDtlMapper.updateById(dtl); @@ -513,6 +534,7 @@ public class OutBillServiceImpl extends ServiceImpl i List outAllocationList = mdPbStoragevehicleextMapper.queryOutAllocation(pcsn,material_id); int seq_no = 1; + double allocation_canuse_qty = 0; for (MdPbStoragevehicleextDto outAllocation : outAllocationList) { //分配明细 IOStorInvDis ioStorInvDis = new IOStorInvDis(); @@ -535,10 +557,18 @@ public class OutBillServiceImpl extends ServiceImpl i ioStorInvDis.setWork_status(IOSEnum.INBILL_DIS_STATUS.code("生成")); // 未分配数量 - 该库位上的可用数量 < 0 目前做整出 +// double canuse_qty = outAllocation.getCanuse_qty().doubleValue(); +// if (unassign_qty-canuse_qty>=0){ +// ioStorInvDis.setPlan_qty(BigDecimal.valueOf(canuse_qty)); +// }else { +// ioStorInvDis.setPlan_qty(BigDecimal.valueOf(unassign_qty)); +// } +// unassign_qty = unassign_qty-canuse_qty; unassign_qty = unassign_qty-outAllocation.getCanuse_qty().doubleValue(); if (unassign_qty<0){ unassign_qty=0; } + allocation_canuse_qty = allocation_canuse_qty + outAllocation.getCanuse_qty().doubleValue(); ioStorInvDis.setPlan_qty(outAllocation.getCanuse_qty()); //锁定货位 @@ -574,7 +604,7 @@ public class OutBillServiceImpl extends ServiceImpl i //更新详情 dtl.setBill_status(IOSEnum.BILL_STATUS.code("分配完")); - double assign_qty = dtl.getUnassign_qty().doubleValue() + dtl.getAssign_qty().doubleValue(); + double assign_qty = allocation_canuse_qty + dtl.getAssign_qty().doubleValue(); dtl.setUnassign_qty(BigDecimal.valueOf(unassign_qty)); dtl.setAssign_qty(BigDecimal.valueOf(assign_qty)); ioStorInvDtlMapper.updateById(dtl); @@ -676,4 +706,354 @@ public class OutBillServiceImpl extends ServiceImpl i ioStorInvMapper.updateById(ios); } + @Override + public List queryAvailableInv(Map whereJson) { + return mdPbStoragevehicleextMapper.queryAvailableInv(whereJson); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void manualDiv(JSONObject whereJson) { + + String currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getCurrentNickName(); + String now = DateUtil.now(); + + JSONObject row = whereJson.getJSONObject("row"); + JSONArray rows = whereJson.getJSONArray("rows"); + + String iostorinv_id = row.getString("iostorinv_id"); + + //查询主表信息 + IOStorInv ioStorInv = ioStorInvMapper.selectById(iostorinv_id); + if (ObjectUtil.isEmpty(ioStorInv)) { + throw new BadRequestException("当前订单无可分配出库明细"); + } + + //查询生成和未分配完的明细 + JSONObject queryDtl = new JSONObject(); + queryDtl.put("bill_status", IOSEnum.BILL_STATUS.code("分配完")); + queryDtl.put("unassign_flag", BaseDataEnum.IS_YES_NOT.code("是")); + queryDtl.put("iostorinv_id", iostorinv_id); + queryDtl.put("iostorinvdtl_id", row.getString("iostorinvdtl_id")); + List dtls = ioStorInvMapper.getIODtl(queryDtl); + if (ObjectUtil.isEmpty(dtls)) { + throw new BadRequestException("当前订单无可分配出库明细"); + } + + for (IOStorInvDtlDto dtl:dtls){ + double unassign_qty = dtl.getUnassign_qty().doubleValue(); + //分配数量 + double allocation_canuse_qty = 0; + for (int i = 0; i < rows.size(); i++){ + JSONObject ivt = rows.getJSONObject(i); + double canuse_qty = ivt.getDoubleValue("canuse_qty"); + //分配明细 + IOStorInvDis ioStorInvDis = new IOStorInvDis(); + ioStorInvDis.setIostorinvdis_id(IdUtil.getStringId()); + ioStorInvDis.setIostorinv_id(dtl.getIostorinv_id()); + ioStorInvDis.setIostorinvdtl_id(dtl.getIostorinvdtl_id()); + ioStorInvDis.setSeq_no((i+1)+""); + ioStorInvDis.setSect_id(ivt.getString("sect_id")); + ioStorInvDis.setPcsn(ivt.getString("pcsn")); + ioStorInvDis.setMaterial_id(dtl.getMaterial_id()); + ioStorInvDis.setSect_name(ivt.getString("sect_name")); + ioStorInvDis.setSect_code(ivt.getString("sect_code")); + ioStorInvDis.setStruct_id(ivt.getString("struct_id")); + ioStorInvDis.setStruct_name(ivt.getString("struct_name")); + ioStorInvDis.setStruct_code(ivt.getString("struct_code")); + ioStorInvDis.setStoragevehicle_code(ivt.getString("storagevehicle_code")); + ioStorInvDis.setIs_issued(BaseDataEnum.IS_YES_NOT.code("否")); + ioStorInvDis.setQty_unit_id(dtl.getQty_unit_id()); + ioStorInvDis.setQty_unit_name(dtl.getQty_unit_name()); + ioStorInvDis.setWork_status(IOSEnum.INBILL_DIS_STATUS.code("生成")); + + // 未分配数量 - 该库位上的可用数量 < 0 目前做整出 +// double canuse_qty = outAllocation.getCanuse_qty().doubleValue(); +// if (unassign_qty-canuse_qty>=0){ +// ioStorInvDis.setPlan_qty(BigDecimal.valueOf(canuse_qty)); +// }else { +// ioStorInvDis.setPlan_qty(BigDecimal.valueOf(unassign_qty)); +// } +// unassign_qty = unassign_qty-canuse_qty; +// if (unassign_qty<0){ +// unassign_qty=0; +// } + if (unassign_qty <= 0){ + throw new BadRequestException("已全部分配完,未分配数量为0"); + } + unassign_qty = unassign_qty-canuse_qty; + if (unassign_qty<0){ + unassign_qty=0; + } + allocation_canuse_qty = allocation_canuse_qty + canuse_qty; + ioStorInvDis.setPlan_qty(BigDecimal.valueOf(canuse_qty)); + + //锁定货位 + JSONObject lock_map = new JSONObject(); + lock_map.put("struct_code", ivt.getString("struct_code")); + lock_map.put("inv_id", ioStorInv.getIostorinv_id()); + lock_map.put("inv_code", ioStorInv.getBill_code()); + lock_map.put("inv_type", ioStorInv.getBill_type()); + lock_map.put("lock_type", IOSEnum.LOCK_TYPE.code("出库锁")); + iStructattrService.updateStatusByCode("0",lock_map); + + //生成分配明细 + ioStorInvDisMapper.insert(ioStorInvDis); + + //更新库存 加冻结减可用 + List updateIvtList = new ArrayList<>(); + JSONObject jsonIvt = new JSONObject(); + jsonIvt.put("type", IOSConstant.UPDATE_IVT_TYPE_ADD_FROZEN); + jsonIvt.put("storagevehicle_code", ivt.getString("storagevehicle_code")); + jsonIvt.put("material_id", dtl.getMaterial_id()); + jsonIvt.put("pcsn", ivt.getString("pcsn")); + jsonIvt.put("qty_unit_id", dtl.getQty_unit_id()); + jsonIvt.put("qty_unit_name", dtl.getQty_unit_name()); + jsonIvt.put("change_qty", ioStorInvDis.getPlan_qty()); + updateIvtList.add(jsonIvt); + iMdPbStoragevehicleextService.updateIvt(updateIvtList); + } + + //更新详情 + dtl.setBill_status(unassign_qty==0 ? IOSEnum.BILL_STATUS.code("分配完"): IOSEnum.BILL_STATUS.code("分配中")); + double assign_qty = allocation_canuse_qty + dtl.getAssign_qty().doubleValue(); + dtl.setUnassign_qty(BigDecimal.valueOf(unassign_qty)); + dtl.setAssign_qty(BigDecimal.valueOf(assign_qty)); + ioStorInvDtlMapper.updateById(dtl); + } + + //更新主表 + //根据单据标识判断明细是否都已经分配完成 + int disCount = ioStorInvDtlMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDtl.class) + .eq(IOStorInvDtl::getIostorinv_id,iostorinv_id) + .lt(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("分配完")) + ); + + // 根据分配货位情况 更新主表单据状态 + IOStorInv ios = new IOStorInv(); + ios.setIostorinv_id(iostorinv_id); + ios.setUpdate_optid(currentUserId); + ios.setUpdate_optname(nickName); + ios.setUpdate_time(now); + ios.setBill_status(disCount>0 ? IOSEnum.BILL_STATUS.code("分配中") : IOSEnum.BILL_STATUS.code("分配完")); + ioStorInvMapper.updateById(ios); + } + + @Override + public void oneCancel(JSONObject whereJson) { + + String currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getCurrentNickName(); + String now = DateUtil.now(); + + String iostorinv_id = whereJson.getString("iostorinv_id"); + + List ioStorInvDisList = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<>(IOStorInvDis.class) + .le(IOStorInvDis::getWork_status,IOSEnum.INBILL_DIS_STATUS.code("生成")) + .eq(IOStorInvDis::getIs_issued,BaseDataEnum.IS_YES_NOT.code("否")) + .eq(IOStorInvDis::getIostorinv_id,iostorinv_id) + .eq(IOStorInvDis::getIostorinvdis_id,whereJson.getString("iostorinvdis_id")) + ); + if (ObjectUtil.isEmpty(ioStorInvDisList)){ + throw new BadRequestException("不存在可取消的出库分配明细"); + } + + for (IOStorInvDis ioStorInvDis:ioStorInvDisList){ + + //更新库存 减冻结加可用 + List updateIvtList = new ArrayList<>(); + JSONObject jsonIvt = new JSONObject(); + jsonIvt.put("type", IOSConstant.UPDATE_IVT_TYPE_SUB_FROZEN_ADD_CANUSE); + jsonIvt.put("storagevehicle_code", ioStorInvDis.getStoragevehicle_code()); + jsonIvt.put("material_id", ioStorInvDis.getMaterial_id()); + jsonIvt.put("pcsn", ioStorInvDis.getPcsn()); + jsonIvt.put("qty_unit_id", ioStorInvDis.getQty_unit_id()); + jsonIvt.put("qty_unit_name", ioStorInvDis.getQty_unit_name()); + jsonIvt.put("change_qty", ioStorInvDis.getPlan_qty()); + updateIvtList.add(jsonIvt); + iMdPbStoragevehicleextService.updateIvt(updateIvtList); + + //解锁库位 + JSONObject unlock_map = new JSONObject(); + unlock_map.put("struct_code", ioStorInvDis.getStruct_code()); + unlock_map.put("inv_type", null); + unlock_map.put("inv_id", null); + unlock_map.put("inv_code", null); + iStructattrService.updateStatusByCode("2",unlock_map); + + //更新出库明细单状态 + IOStorInvDtl ioStorInvDtl = ioStorInvDtlMapper.selectById(whereJson.getString("iostorinvdtl_id")); + + //取消分配计算 已分配 = 已分配 - 分配详情计划数量 + // 未分配 = 计划分配 - 已分配 + double assign_qty = ioStorInvDtl.getAssign_qty().doubleValue()-ioStorInvDis.getPlan_qty().doubleValue(); + double unassign_qty = ioStorInvDtl.getUnassign_qty().doubleValue() + (ioStorInvDtl.getPlan_qty().doubleValue()-assign_qty); + ioStorInvDtl.setAssign_qty(BigDecimal.valueOf(assign_qty)); + ioStorInvDtl.setUnassign_qty(BigDecimal.valueOf(unassign_qty)); + ioStorInvDtl.setBill_status(IOSEnum.BILL_STATUS.code("生成")); + ioStorInvDtlMapper.updateById(ioStorInvDtl); + + //删除出入库单分配表 + ioStorInvDisMapper.deleteById(ioStorInvDis.getIostorinvdis_id()); + + } + + //更新主表 + //根据单据标识判断明细是否都已经分配完成 + int disCount = ioStorInvDtlMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDtl.class) + .eq(IOStorInvDtl::getIostorinv_id,iostorinv_id) + .le(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("分配完")) + .gt(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("生成")) + ); + + // 根据分配货位情况 更新主表单据状态 + IOStorInv ios = new IOStorInv(); + ios.setIostorinv_id(iostorinv_id); + ios.setUpdate_optid(currentUserId); + ios.setUpdate_optname(nickName); + ios.setUpdate_time(now); + ios.setBill_status(disCount>0 ? IOSEnum.BILL_STATUS.code("分配中") : IOSEnum.BILL_STATUS.code("生成")); + ioStorInvMapper.updateById(ios); + } + + @Override + public void allSetPoint(JSONObject whereJson) { + //出库点 + String point_code = whereJson.getString("point_code"); + + if (StrUtil.isBlank(point_code)){ + throw new BadRequestException("未选择出库点"); + } + String iostorinv_id = whereJson.getString("iostorinv_id"); + + //查询主表信息 + IOStorInv ioStorInv = ioStorInvMapper.selectById(iostorinv_id); + if (ObjectUtil.isEmpty(ioStorInv)) { + throw new BadRequestException("未查到相关出库单"); + } + + List ioStorInvDisList = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<>(IOStorInvDis.class) + .eq(IOStorInvDis::getIostorinv_id,iostorinv_id) + .eq(IOStorInvDis::getIs_issued,BaseDataEnum.IS_YES_NOT.code("否")) + .and(wrapper -> wrapper.isNotNull(IOStorInvDis::getStruct_code).ne(IOStorInvDis::getStruct_code,"")) + ); + if (ObjectUtil.isEmpty(ioStorInvDisList)){ + throw new BadRequestException("当前没有可设置的分配明细"); + } + + for (IOStorInvDis ioStorInvDis:ioStorInvDisList){ + //创建任务 + JSONObject task_form = new JSONObject(); + task_form.put("task_type", "STInTask"); + task_form.put("TaskCode",CodeUtil.getNewCode("TASK_CODE")); + task_form.put("PickingLocation", point_code); + task_form.put("PlacedLocation", ioStorInvDis.getStruct_code()); + task_form.put("vehicle_code", ioStorInvDis.getStoragevehicle_code()); + + StInTask stInTask = SpringContextHolder.getBean("STInTask"); + + String task_id = stInTask.create(task_form); + + //分配明细表更新任务相关数据 + IOStorInvDis dis = new IOStorInvDis(); + dis.setIostorinvdis_id(ioStorInvDis.getIostorinvdis_id()); + dis.setWork_status(IOSEnum.INBILL_DIS_STATUS.code("执行中")); + dis.setTask_id(task_id); + dis.setIs_issued(BaseDataEnum.IS_YES_NOT.code("是")); + dis.setPoint_code(point_code); + ioStorInvDisMapper.updateById(dis); + } + } + + @Override + public void confirm(JSONObject whereJson) { + + String currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getCurrentNickName(); + String now = DateUtil.now(); + + String iostorinv_id = whereJson.getString("iostorinv_id"); + + //查询主表信息 + IOStorInv ioStorInv = ioStorInvMapper.selectById(iostorinv_id); + if (ObjectUtil.isEmpty(ioStorInv)) { + throw new BadRequestException("未查到相关出库单"); + } + + if (!IOSEnum.BILL_STATUS.code("分配完").equals(ioStorInv.getBill_status())){ + throw new BadRequestException("主表状态必须为分配完!"); + } + + //解锁原货位点位 + List storInvDisList = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<>(IOStorInvDis.class) + .eq(IOStorInvDis::getIostorinv_id,whereJson.get("iostorinv_id")) + ); + + for (IOStorInvDis ioStorInvDis: storInvDisList){ + if (StrUtil.isNotBlank(ioStorInvDis.getStruct_code())){ + //解绑仓位 + JSONObject finish_map = new JSONObject(); + finish_map.put("struct_code",ioStorInvDis.getStruct_code()); + finish_map.put("storagevehicle_code",null); + finish_map.put("inv_type", null); + finish_map.put("inv_id", null); + finish_map.put("inv_code", null); + iStructattrService.updateStatusByCode("1",finish_map); + + //库存绑定到出库点。 + schBasePointMapper.update(new SchBasePoint(),new LambdaUpdateWrapper<>(SchBasePoint.class) + .set(SchBasePoint::getVehicle_code,ioStorInvDis.getStoragevehicle_code()) + .set(SchBasePoint::getIos_id,ioStorInvDis.getIostorinvdis_id()) + .eq(SchBasePoint::getPoint_code,ioStorInvDis.getPoint_code()) + ); + + //修改库存 减冻结加可用 + List updateIvtList = new ArrayList<>(); + JSONObject jsonIvt = new JSONObject(); + jsonIvt.put("type", IOSConstant.UPDATE_IVT_TYPE_SUB_FROZEN_ADD_CANUSE); + jsonIvt.put("storagevehicle_code", ioStorInvDis.getStoragevehicle_code()); + jsonIvt.put("material_id", ioStorInvDis.getMaterial_id()); + jsonIvt.put("pcsn", ioStorInvDis.getPcsn()); + jsonIvt.put("qty_unit_id", ioStorInvDis.getQty_unit_id()); + jsonIvt.put("qty_unit_name", ioStorInvDis.getQty_unit_name()); + jsonIvt.put("change_qty", ioStorInvDis.getPlan_qty()); + updateIvtList.add(jsonIvt); + iMdPbStoragevehicleextService.updateIvt(updateIvtList); + } + + //更新详情数据 + ioStorInvDisMapper.update(ioStorInvDis,new LambdaUpdateWrapper<>(IOStorInvDis.class) + .set(IOStorInvDis::getWork_status,IOSEnum.INBILL_DIS_STATUS.code("完成")) + .set(IOStorInvDis::getReal_qty,ioStorInvDis.getPlan_qty()) + .eq(IOStorInvDis::getIostorinvdis_id,ioStorInvDis.getIostorinvdis_id()) + .ne(IOStorInvDis::getWork_status,IOSEnum.INBILL_DIS_STATUS.code("完成")) + ); + + ioStorInvDtlMapper.update(new IOStorInvDtl(),new LambdaUpdateWrapper<>(IOStorInvDtl.class) + .set(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("完成")) + .set(IOStorInvDtl::getReal_qty,ioStorInvDis.getPlan_qty()) + .eq(IOStorInvDtl::getIostorinvdtl_id,ioStorInvDis.getIostorinvdtl_id()) + .ne(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("完成")) + ); + + //更新组盘记录表 + groupPlateMapper.update(new GroupPlate(),new LambdaUpdateWrapper<>(GroupPlate.class) + .set(GroupPlate::getStatus,IOSEnum.GROUP_PLATE_STATUS.code("出库")) + .eq(GroupPlate::getPcsn,ioStorInvDis.getPcsn()) + .eq(GroupPlate::getMaterial_id,ioStorInvDis.getMaterial_id()) + .eq(GroupPlate::getStoragevehicle_code,ioStorInvDis.getStoragevehicle_code()) + ); + } + + //更新主表状态 + ioStorInvMapper.update(ioStorInv,new LambdaUpdateWrapper<>(IOStorInv.class) + .set(IOStorInv::getBill_status,IOSEnum.BILL_STATUS.code("完成")) + .set(IOStorInv::getConfirm_optid,currentUserId) + .set(IOStorInv::getConfirm_optname,nickName) + .set(IOStorInv::getConfirm_time,now) + .eq(IOStorInv::getIostorinv_id,whereJson.get("iostorinv_id")) + ); + } + } diff --git a/wms/nladmin-ui/src/views/wms/st/outbill/StructIvt.vue b/wms/nladmin-ui/src/views/wms/st/outbill/StructIvt.vue index 169e845..ad695d2 100644 --- a/wms/nladmin-ui/src/views/wms/st/outbill/StructIvt.vue +++ b/wms/nladmin-ui/src/views/wms/st/outbill/StructIvt.vue @@ -50,9 +50,9 @@ @change="sectQueryChange" /> - + - - - - + @@ -100,18 +90,10 @@ - + - - + - - - - - - -