From 7cd9d112cc6e2bfbf6749f948fc6b01998184977 Mon Sep 17 00:00:00 2001 From: faramita <1246063744@qq.com> Date: Wed, 4 Dec 2024 15:54:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=9D=E5=AF=86=E5=87=BA=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E3=80=81=E4=BF=9D=E5=AF=86=E4=B8=8A=E4=B8=8B=E6=9E=B6?= =?UTF-8?q?=E3=80=81=E4=BF=9D=E5=AF=86=E6=8B=86=E5=90=88=E6=89=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wms/dto/ListWithStringAndBoolsDTO.java | 2 +- .../foreverwin/mom/wms/dto/ScanCodeDTO.java | 2 + .../foreverwin/mom/wms/entity/Inventory.java | 5 +- .../wms/controller/DocumentController.java | 4 +- .../controller/WmsStorageBinController.java | 13 +- .../controller/ZWmsInventoryController.java | 11 +- .../mom/wms/service/DocumentService.java | 2 +- .../mom/wms/service/WmsStorageBinService.java | 6 +- .../mom/wms/service/ZWmsInventoryService.java | 10 +- .../wms/service/impl/DocumentServiceImpl.java | 10 +- .../impl/WmsStorageBinServiceImpl.java | 28 +++-- .../impl/ZWmsInventoryServiceImpl.java | 117 ++++++++++-------- .../resources/mapper/ZWmsInventoryMapper.xml | 6 +- 13 files changed, 127 insertions(+), 89 deletions(-) diff --git a/mom-wms-api/src/main/java/com/foreverwin/mom/wms/dto/ListWithStringAndBoolsDTO.java b/mom-wms-api/src/main/java/com/foreverwin/mom/wms/dto/ListWithStringAndBoolsDTO.java index 4d5b033..4a324e1 100644 --- a/mom-wms-api/src/main/java/com/foreverwin/mom/wms/dto/ListWithStringAndBoolsDTO.java +++ b/mom-wms-api/src/main/java/com/foreverwin/mom/wms/dto/ListWithStringAndBoolsDTO.java @@ -20,6 +20,6 @@ public class ListWithStringAndBoolsDTO { private List list; public boolean getSwitch(int i) { - return switchArray != null && switchArray.length > 0 && switchArray[i]; + return switchArray != null && switchArray.length > i && switchArray[i]; } } diff --git a/mom-wms-api/src/main/java/com/foreverwin/mom/wms/dto/ScanCodeDTO.java b/mom-wms-api/src/main/java/com/foreverwin/mom/wms/dto/ScanCodeDTO.java index 8f47759..94e65bb 100644 --- a/mom-wms-api/src/main/java/com/foreverwin/mom/wms/dto/ScanCodeDTO.java +++ b/mom-wms-api/src/main/java/com/foreverwin/mom/wms/dto/ScanCodeDTO.java @@ -34,4 +34,6 @@ public class ScanCodeDTO { private String dnOrder; private Integer dnOrderSeq; + + private String secrecyId; } diff --git a/mom-wms-api/src/main/java/com/foreverwin/mom/wms/entity/Inventory.java b/mom-wms-api/src/main/java/com/foreverwin/mom/wms/entity/Inventory.java index 50f482c..ae1829b 100644 --- a/mom-wms-api/src/main/java/com/foreverwin/mom/wms/entity/Inventory.java +++ b/mom-wms-api/src/main/java/com/foreverwin/mom/wms/entity/Inventory.java @@ -178,11 +178,14 @@ public class Inventory extends Model { private String erpStorageLocation; /** - * 库存调整原因 + * 库存保密ID */ @ApiModelProperty(value = "库存调整原因") @Deprecated private String adjustmentReason; + + @ApiModelProperty(value = "库存保密ID") + private String secrecyId; /** * 是否采购到货批 */ diff --git a/mom-wms-core/src/main/java/com/foreverwin/mom/wms/controller/DocumentController.java b/mom-wms-core/src/main/java/com/foreverwin/mom/wms/controller/DocumentController.java index 6ad3082..1294b79 100644 --- a/mom-wms-core/src/main/java/com/foreverwin/mom/wms/controller/DocumentController.java +++ b/mom-wms-core/src/main/java/com/foreverwin/mom/wms/controller/DocumentController.java @@ -854,10 +854,10 @@ public class DocumentController { @ApiOperation(value = "单据扫码", notes = "单据扫码") @GetMapping("/scanCode") @SysLog("单据扫码") - public R scanCode(String code, String documentNo, boolean searchFull) { + public R scanCode(String code, String documentNo, boolean searchFull, boolean isSecrecy) { String site = TenantContextHolder.getTenantId(); String user = SecurityUtils.getUserName(); - return R.ok(documentService.scanCode(site, user, code, documentNo, searchFull)); + return R.ok(documentService.scanCode(site, user, code, documentNo, searchFull, isSecrecy)); } @ApiOperation(value = "单据拣货保存", notes = "单据拣货保存") diff --git a/mom-wms-core/src/main/java/com/foreverwin/mom/wms/controller/WmsStorageBinController.java b/mom-wms-core/src/main/java/com/foreverwin/mom/wms/controller/WmsStorageBinController.java index 25fdba3..1bc15fa 100644 --- a/mom-wms-core/src/main/java/com/foreverwin/mom/wms/controller/WmsStorageBinController.java +++ b/mom-wms-core/src/main/java/com/foreverwin/mom/wms/controller/WmsStorageBinController.java @@ -9,6 +9,7 @@ import com.foreverwin.mom.common.data.tenant.TenantContextHolder; import com.foreverwin.mom.common.excel.annotation.ResponseExcel; import com.foreverwin.mom.common.log.annotation.SysLog; import com.foreverwin.mom.common.security.util.SecurityUtils; +import com.foreverwin.mom.wms.dto.ListWithStringAndBoolsDTO; import com.foreverwin.mom.wms.dto.ListWithStringDTO; import com.foreverwin.mom.wms.dto.StorageBinDto; import com.foreverwin.mom.wms.entity.StorageBin; @@ -164,29 +165,29 @@ public class WmsStorageBinController { @ApiOperation(value = "上下架扫码", notes = "上下架扫码") @GetMapping("/scanCode") @SysLog("上下架扫码") - public R scanCode(String code) { + public R scanCode(String code, boolean isSecrecy) { String site = TenantContextHolder.getTenantId(); String user = SecurityUtils.getUserName(); - return R.ok(storageBinService.scanCode(site, user, code)); + return R.ok(storageBinService.scanCode(site, user, code, isSecrecy)); } @ApiOperation(value = "货格绑定", notes = "货格绑定") @SysLog("货格绑定") @PostMapping("/bind") - public R bind(@RequestBody ListWithStringDTO dto) { + public R bind(@RequestBody ListWithStringAndBoolsDTO dto) { String site = TenantContextHolder.getTenantId(); String user = SecurityUtils.getUserName(); - storageBinService.bind(site, user, dto.getStr(), dto.getList()); + storageBinService.bind(site, user, dto.getStr(), dto.getList(), dto.getSwitch(0)); return R.ok(); } @ApiOperation(value = "货格解绑", notes = "货格解绑") @SysLog("货格解绑") @PostMapping("/unBind") - public R unBind(@RequestBody List inventoryIdList) { + public R unBind(@RequestBody ListWithStringAndBoolsDTO dto) { String site = TenantContextHolder.getTenantId(); String user = SecurityUtils.getUserName(); - storageBinService.unBind(site, user, inventoryIdList); + storageBinService.unBind(site, user, dto.getList(), dto.getSwitch(0)); return R.ok(); } diff --git a/mom-wms-core/src/main/java/com/foreverwin/mom/wms/controller/ZWmsInventoryController.java b/mom-wms-core/src/main/java/com/foreverwin/mom/wms/controller/ZWmsInventoryController.java index 59e97f8..445c679 100644 --- a/mom-wms-core/src/main/java/com/foreverwin/mom/wms/controller/ZWmsInventoryController.java +++ b/mom-wms-core/src/main/java/com/foreverwin/mom/wms/controller/ZWmsInventoryController.java @@ -1,5 +1,6 @@ package com.foreverwin.mom.wms.controller; +import cn.hutool.core.util.StrUtil; import com.alibaba.excel.EasyExcel; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -370,7 +371,8 @@ public class ZWmsInventoryController { int splitNum = Integer.parseInt(request.get("splitNum")); String qmsSpecialMarking = request.get("qmsSpecialMarking"); String printer = request.get("printer"); - List splitInventoryIdList = inventoryService.splitInventory(site, user, parentInventoryId, splitQty, splitNum, null, null, null, null, qmsSpecialMarking, printer); + boolean isSecrecy = Boolean.parseBoolean(request.get("isSecrecy")); + List splitInventoryIdList = inventoryService.splitInventory(site, user, parentInventoryId, splitQty, splitNum, null, null, null, null, qmsSpecialMarking, printer, isSecrecy); splitInventoryIdList.add(parentInventoryId); splitInventoryIdList.remove(splitInventoryIdList.size() - 1); return R.ok(splitInventoryIdList); @@ -389,7 +391,8 @@ public class ZWmsInventoryController { String user = SecurityUtils.getUserName(); List inventoryIdList = (List) request.get("inventoryIdList"); String printer = request.get("printer").toString(); - String mergeInventoryId = inventoryService.mergeInventory(site, user, inventoryIdList,printer); + boolean isSecrecy = request.get("isSecrecy") != null && Boolean.parseBoolean(request.get("isSecrecy").toString()); + String mergeInventoryId = inventoryService.mergeInventory(site, user, inventoryIdList,printer,isSecrecy); return R.ok(mergeInventoryId); //} } @@ -402,9 +405,9 @@ public class ZWmsInventoryController { */ @ApiOperation(value = "查询待拆合批条码", notes = "查询待拆合批条码") @GetMapping("/selectForSplit") - public R selectForSplit(String inventoryId) { + public R selectForSplit(String inventoryId, boolean isSecrecy) { String site = TenantContextHolder.getTenantId(); - return R.ok(inventoryService.selectForSplit(site, inventoryId)); + return R.ok(inventoryService.selectForSplit(site, inventoryId, isSecrecy)); } @ApiOperation(value = "查询待盘盈盘亏条码", notes = "查询待盘盈盘亏条码") diff --git a/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/DocumentService.java b/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/DocumentService.java index ecd386f..6e25239 100644 --- a/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/DocumentService.java +++ b/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/DocumentService.java @@ -310,7 +310,7 @@ public interface DocumentService extends IService { List getSubmitDocumentDetail(String site, String user, String documentNo, String sourceWarehouse, String targetWarehouse); - List scanCode(String site, String user, String code, String documentNo, boolean fullSearch); + List scanCode(String site, String user, String code, String documentNo, boolean fullSearch, boolean isSecrecy); /** * 保存拣货 diff --git a/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/WmsStorageBinService.java b/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/WmsStorageBinService.java index a501a37..f0ec8f1 100644 --- a/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/WmsStorageBinService.java +++ b/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/WmsStorageBinService.java @@ -35,10 +35,10 @@ public interface WmsStorageBinService extends IService { String labelPrint(String site, List printList, String printer); - List scanCode(String site, String user, String code); + List scanCode(String site, String user, String code, boolean isSecrecy); - void bind(String site, String user, String storageBin, List inventoryIdList); + void bind(String site, String user, String storageBin, List inventoryIdList, boolean isSecrecy); - void unBind(String site, String user, List inventoryIdList); + void unBind(String site, String user, List inventoryIdList, boolean isSecrecy); } diff --git a/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/ZWmsInventoryService.java b/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/ZWmsInventoryService.java index 11fcb6b..5cf19ab 100644 --- a/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/ZWmsInventoryService.java +++ b/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/ZWmsInventoryService.java @@ -87,7 +87,7 @@ public interface ZWmsInventoryService extends IService { */ List splitInventory(String site, String user, String parentInventory, BigDecimal splitQty, int splitNum, String documentNo, String documentType, String storageBinBo); - List splitInventory(String site, String user, String parentInventoryId, BigDecimal splitQty, int splitNum, String documentNo, String documentType, String storageBinBo, List newInventoryIdList, String qmsSpecialMarking, String printerName); + List splitInventory(String site, String user, String parentInventoryId, BigDecimal splitQty, int splitNum, String documentNo, String documentType, String storageBinBo, List newInventoryIdList, String qmsSpecialMarking, String printerName, boolean isSecrecy); /** * 合并库存 @@ -97,13 +97,13 @@ public interface ZWmsInventoryService extends IService { * @param inventoryIList 库存ID集合 * @return 新库存ID */ - String mergeInventory(String site, String user, List inventoryIList,String printer); + String mergeInventory(String site, String user, List inventoryIList, String printer, boolean isSecrecy); IPage fetchItemList(Page page, String item); IPage fetchItemGroesList(Page page, String searchText); - InventoryDto selectForSplit(String site, String inventoryId); + InventoryDto selectForSplit(String site, String inventoryId, boolean isSecrecy); InventoryDto selectForStocktaking(String site, String inventoryId); @@ -132,4 +132,8 @@ public interface ZWmsInventoryService extends IService { * Lot合批-产生新批号新增或修改库存表远程接口 */ void margeNewUpdateInventory(InventoryDto dto); + + List getTrueInvIdListBySecrecyIdList(String site, List secrecyIdList); + + String getTrueInventoryIdBySecrecyId(String site, String secrecyId); } diff --git a/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/impl/DocumentServiceImpl.java b/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/impl/DocumentServiceImpl.java index 2bdbec9..85b65d2 100644 --- a/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/impl/DocumentServiceImpl.java +++ b/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/impl/DocumentServiceImpl.java @@ -5982,7 +5982,7 @@ public class DocumentServiceImpl extends ServiceImpl i documentNo, null, storageBinBindInventory.getStorageBinBo(), - Collections.singletonList(parentInventoryId + "-1"), null, null + Collections.singletonList(parentInventoryId + "-1"), null, null,false ).get(0); inventoryService.update(Wrappers.lambdaUpdate(Inventory.class) .eq(Inventory::getHandle, Inventory.genHandle(site, freezeInventoryId)) @@ -6648,9 +6648,10 @@ public class DocumentServiceImpl extends ServiceImpl i } @Override - public List scanCode(String site, String user, String code, String documentNo, boolean fullSearch) { - pickingService.checkCodePicking(site, code); - List scanCodeDTOS = fullSearch ? inventoryService.selectTrayInvByCode(site, user, code) : inventoryService.selectInvByCode(site, user, code); + public List scanCode(String site, String user, String code, String documentNo, boolean fullSearch, boolean isSecrecy) { + String trueCode = isSecrecy ? inventoryService.getTrueInventoryIdBySecrecyId(site, code) : code; + pickingService.checkCodePicking(site, trueCode); + List scanCodeDTOS = fullSearch ? inventoryService.selectTrayInvByCode(site, user, trueCode) : inventoryService.selectInvByCode(site, user, trueCode); if (CollectionUtil.isEmpty(scanCodeDTOS)) { throw BusinessException.build("条码无法识别"); } else if (StrUtil.isNotBlank(documentNo)) { @@ -6687,6 +6688,7 @@ public class DocumentServiceImpl extends ServiceImpl i Map seqMap = documentDetailedService.lambdaQuery().eq(DocumentDetailed::getDocumentBo, documentBo).select(DocumentDetailed::getItem, DocumentDetailed::getSeq).list().stream().collect(Collectors.toMap(DocumentDetailed::getItem, DocumentDetailed::getSeq, (s, s2) -> s)); LocalDateTime now = LocalDateTime.now(); pickingService.lambdaUpdate().eq(Picking::getSite, site).eq(Picking::getDocumentNo, documentNo).remove(); + if (checkScanAll) { checkPickingTrayAllScan(site, list); } diff --git a/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/impl/WmsStorageBinServiceImpl.java b/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/impl/WmsStorageBinServiceImpl.java index 2956e50..a97dd3c 100644 --- a/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/impl/WmsStorageBinServiceImpl.java +++ b/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/impl/WmsStorageBinServiceImpl.java @@ -234,32 +234,34 @@ public class WmsStorageBinServiceImpl extends ServiceImpl inventoryIdList) { + public void bind(String site, String user, String storageBin, List inventoryIdList, boolean isSecrecy) { String storageBinBo = StorageBin.genHandle(site, storageBin); String erpStorageLocation = Optional.ofNullable(getStorageLocationByStorageBin(site, storageBin)).orElseThrow(() -> BusinessException.build("未找到货格对应的仓库")); - List inventoryBoList = inventoryIdList.stream().map(o -> Inventory.genHandle(site, o)).collect(Collectors.toList()); + List trueInventoryIdList = isSecrecy ? inventoryService.getTrueInvIdListBySecrecyIdList(site, inventoryIdList) : inventoryIdList; + List inventoryBoList = trueInventoryIdList.stream().map(o -> Inventory.genHandle(site, o)).collect(Collectors.toList()); List inventoryList = inventoryService.listByIds(inventoryBoList); inventoryList.stream().filter(o -> !erpStorageLocation.equals(o.getErpStorageLocation())).findFirst().ifPresent(inventory -> { - throw BusinessException.build("条码" + inventory.getInventoryId() + "库存地点与货格不匹配"); + throw BusinessException.build("条码" + (isSecrecy ? inventory.getSecrecyId() : inventory.getInventoryId()) + "库存地点与货格不匹配"); }); if (CollectionUtil.isEmpty(inventoryList) || inventoryList.size() != inventoryIdList.size()) { - inventoryIdList.removeAll(inventoryList.stream().map(Inventory::getInventoryId).collect(Collectors.toList())); + inventoryIdList.removeAll(inventoryList.stream().map(o -> isSecrecy ? o.getSecrecyId() : o.getInventoryId()).collect(Collectors.toList())); throw BusinessException.build("库存[" + String.join(",", inventoryIdList) + "]不存在"); } inventoryService.lambdaUpdate().in(Inventory::getHandle, inventoryBoList) .set(Inventory::getWmsStorageBinBo, storageBinBo) .set(Inventory::getUpdateTime, LocalDateTime.now()) .set(Inventory::getUpdater, user).update(); - inventoryLogService.saveBatch(inventoryList.stream().map(inventory -> inventoryLogService.buildLog(user, inventory.getInventoryId(), null, null, Constant.CHANGE_TYPE_UP_SHELF, inventory.getWmsStorageBinBo(), inventory.getQtyOnHand(), storageBinBo, null, null, null,null)).collect(Collectors.toList())); + inventoryLogService.saveBatch(inventoryList.stream().map(inventory -> inventoryLogService.buildLog(user, inventory.getInventoryId(), null, null, Constant.CHANGE_TYPE_UP_SHELF, inventory.getWmsStorageBinBo(), inventory.getQtyOnHand(), storageBinBo, null, null, null, null)).collect(Collectors.toList())); } @Override - public void unBind(String site, String user, List inventoryIdList) { - List inventoryBoList = inventoryIdList.stream().map(o -> Inventory.genHandle(site, o)).collect(Collectors.toList()); + public void unBind(String site, String user, List inventoryIdList, boolean isSecrecy) { + List trueInventoryIdList = isSecrecy ? inventoryService.getTrueInvIdListBySecrecyIdList(site, inventoryIdList) : inventoryIdList; + List inventoryBoList = trueInventoryIdList.stream().map(o -> Inventory.genHandle(site, o)).collect(Collectors.toList()); List inventoryList = inventoryService.listByIds(inventoryBoList); if (CollectionUtil.isEmpty(inventoryList) || inventoryList.size() != inventoryIdList.size()) { - inventoryIdList.removeAll(inventoryList.stream().map(Inventory::getInventoryId).collect(Collectors.toList())); + inventoryIdList.removeAll(inventoryList.stream().map(o -> isSecrecy ? o.getSecrecyId() : o.getInventoryId()).collect(Collectors.toList())); throw BusinessException.build("库存[" + String.join(",", inventoryIdList) + "]不存在"); } inventoryService.lambdaUpdate().in(Inventory::getHandle, inventoryBoList) @@ -270,12 +272,16 @@ public class WmsStorageBinServiceImpl extends ServiceImpl scanCode(String site, String user, String code) { - pickingService.checkCodePicking(site, code); - List scanCodeDTOS = inventoryService.selectTrayInvByCode(site, user, code); + public List scanCode(String site, String user, String code, boolean isSecrecy) { + String trueCode = isSecrecy ? inventoryService.getTrueInventoryIdBySecrecyId(site, code) : code; + pickingService.checkCodePicking(site, trueCode); + List scanCodeDTOS = inventoryService.selectTrayInvByCode(site, user, trueCode); if (CollectionUtil.isEmpty(scanCodeDTOS)) { throw BusinessException.build("条码" + code + "无法识别"); } else { + /*if (isSecrecy) { + scanCodeDTOS.forEach(scanCodeDTO -> scanCodeDTO.setInventoryId(scanCodeDTO.getSecrecyId())); + }*/ return scanCodeDTOS; } } diff --git a/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/impl/ZWmsInventoryServiceImpl.java b/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/impl/ZWmsInventoryServiceImpl.java index a6f322c..8fe5f87 100644 --- a/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/impl/ZWmsInventoryServiceImpl.java +++ b/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/impl/ZWmsInventoryServiceImpl.java @@ -12,12 +12,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.foreverwin.iep.common.base.FrontPage; import com.foreverwin.iep.common.constant.BaseConstants; -import com.foreverwin.iep.common.utils.HandleBoProcessor; import com.foreverwin.iep.prd.domain.GenerateNextNumberRequest; import com.foreverwin.iep.prd.entity.Item; import com.foreverwin.iep.prd.feign.RemoteNextNumberService; -import com.foreverwin.iep.wip.entity.LotBasis; -import com.foreverwin.iep.wip.entity.LotState; import com.foreverwin.mom.common.core.constant.SecurityConstants; import com.foreverwin.mom.common.core.exception.BusinessException; import com.foreverwin.mom.common.data.tenant.TenantContextHolder; @@ -35,9 +32,7 @@ import com.foreverwin.mom.wms.service.WmsItemService; import com.foreverwin.mom.wms.service.ZWmsInventoryLogService; import com.foreverwin.mom.wms.service.ZWmsInventoryService; import com.foreverwin.mom.wms.util.StringUtil; -import com.foreverwin.mom.wms.util.ThreadPoolUtil; import com.foreverwin.nlv.print.feign.RemotePrintService; -import io.swagger.models.auth.In; import lombok.RequiredArgsConstructor; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -382,14 +377,15 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl splitInventory(String site, String user, String parentInventoryId, BigDecimal splitQty, int splitNum, String documentNo, String documentType, String storageBinBo) { - return splitInventory(site, user, parentInventoryId, splitQty, splitNum, documentNo, documentType, storageBinBo, null, null, null); + return splitInventory(site, user, parentInventoryId, splitQty, splitNum, documentNo, documentType, storageBinBo, null, null, null, false); } //@GlobalTransactional @Override @Transactional(rollbackFor = Exception.class) - public List splitInventory(String site, String user, String parentInventoryId, BigDecimal splitQty, int splitNum, String documentNo, String documentType, String storageBinBo, List newInventoryIdList, String qmsSpecialMarking, String printerName) { - Inventory parentInventory = getByCode(site, parentInventoryId); + public List splitInventory(String site, String user, String parentInventoryId, BigDecimal splitQty, int splitNum, String documentNo, String documentType, String storageBinBo, List newInventoryIdList, String qmsSpecialMarking, String printerName, boolean isSecrecy) { + Inventory parentInventory = isSecrecy ? lambdaQuery().eq(Inventory::getSite, site).eq(Inventory::getSecrecyId, parentInventoryId) + .one() : getById(Inventory.genHandle(site, parentInventoryId)); if (parentInventory == null) { throw BusinessException.build("库存不存在"); } else { @@ -414,7 +410,10 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl newInventoryList = new ArrayList<>(); - for (String inventoryId : newInventoryIdList) { + List newInventoryLogList = new ArrayList<>(); + storageBinBo = StrUtil.blankToDefault(storageBinBo, parentStorageBinBo); + for (int i = 0; i < newInventoryIdList.size(); i++) { + String inventoryId = newInventoryIdList.get(i); JSONObject paramMap = new JSONObject(); Inventory inventory = new Inventory(); BeanUtils.copyProperties(parentInventory, inventory); @@ -426,8 +425,18 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl inventoryIdList,String printer) { - List inventoryBoList = inventoryIdList.stream().map(o -> Inventory.genHandle(site, o)).collect(Collectors.toList()); + public String mergeInventory(String site, String user, List inventoryIdList, String printer, boolean isSecrecy) { //查询并校验库存 - List inventoryList = listByIds(inventoryBoList); + List inventoryList = lambdaQuery().eq(Inventory::getSite, site) + .in(isSecrecy, Inventory::getSecrecyId, inventoryIdList) + .in(!isSecrecy, Inventory::getInventoryId, inventoryIdList).list(); if (CollectionUtil.isEmpty(inventoryList) || inventoryList.size() != inventoryIdList.size()) { - inventoryIdList.removeAll(inventoryList.stream().map(Inventory::getInventoryId).collect(Collectors.toList())); + inventoryIdList.removeAll(inventoryList.stream().map(o -> isSecrecy ? o.getSecrecyId() : o.getInventoryId()).collect(Collectors.toList())); throw BusinessException.build("库存[" + String.join(",", inventoryIdList) + "]不存在"); } else { //查询并校验货格 @@ -542,22 +541,25 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl inventoryLogs = new ArrayList<>(); for (Inventory inventory : inventoryList) { String inventoryId = inventory.getInventoryId(); BigDecimal qtyOnHand = inventory.getQtyOnHand(); qty = qty.add(qtyOnHand); - inventoryLogService.saveLog(user, inventoryId, null, inventory.getStatus(), Constant.CHANGE_TYPE_MERGE, - inventory.getWmsStorageBinBo(), qtyOnHand, null); + inventoryLogs.add(inventoryLogService.buildLog(user, inventoryId, null, inventory.getStatus(), Constant.CHANGE_TYPE_MERGE, + inventory.getWmsStorageBinBo(), qtyOnHand, null, null, null, null, inventory)); } + update(Wrappers.lambdaUpdate(Inventory.class).in(Inventory::getHandle, inventoryList.stream().map(Inventory::getHandle).collect(Collectors.toList())) + .set(Inventory::getWmsStorageBinBo, null) + .set(Inventory::getQtyOnHand, BigDecimal.ZERO) + .set(Inventory::getUpdater, user) + .set(Inventory::getUpdateTime, LocalDateTime.now())); + inventoryLogService.saveBatch(inventoryLogs); + String itemBo = inventoryList.get(0).getItemBo(); Item itemObj = itemService.getById(itemBo); - if(itemObj==null){ - throw BusinessException.build("根据物料主键"+itemBo+"未找到对象"); + if (itemObj == null) { + throw BusinessException.build("根据物料主键" + itemBo + "未找到对象"); } //创建新库存并绑定 Map map = new HashMap<>(); @@ -576,6 +578,7 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl BusinessException.build(inventoryId+"库存不存在")); - /*String itemType = Optional.ofNullable(inventoryDto).orElseThrow(() -> BusinessException.build("库存不存在或未绑定货格")).getItemType(); - if (StrUtil.isBlank(itemType) || !StrUtil.equalsAny(itemType, KeyWordConstant.ITEM_MATERIAL_TYPE_ROH, KeyWordConstant.ITEM_MATERIAL_TYPE_VERP)) { - throw BusinessException.build("非原材料/包材不允许拆合批"); - } else*/ + public InventoryDto selectForSplit(String site, String inventoryId, boolean isSecrecy) { + String trueInventoryId = isSecrecy ? getTrueInventoryIdBySecrecyId(site, inventoryId) : inventoryId; + pickingService.checkCodePicking(site, trueInventoryId); + InventoryDto inventoryDto = Optional.ofNullable(baseMapper.selectWithStorageBin(Inventory.genHandle(site, trueInventoryId))).orElseThrow(() -> BusinessException.build(inventoryId + "库存不存在")); if (BigDecimal.ZERO.compareTo(inventoryDto.getQtyOnHand()) == 0) { - throw BusinessException.build(inventoryId+"库存为0不允许拆合批"); + throw BusinessException.build(inventoryId + "库存为0不允许拆合批"); } else { - /*long count = inventoryGroupService.count(Wrappers.lambdaQuery(InventoryGroup.class).eq(InventoryGroup::getInventoryBo, Inventory.genHandle(site, inventoryId))); - if (count > 0) { - throw BusinessException.build("分组库存不允许拆合批"); - } else {*/ + /*if (isSecrecy) { + inventoryDto.setInventoryId(inventoryDto.getSecrecyId()); + }*/ return inventoryDto; - //} } } @@ -1032,4 +1030,19 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl BusinessException.build("保密库存" + secrecyId + "不存在")); + } + + @Override + public List getTrueInvIdListBySecrecyIdList(String site, List secrecyIdList) { + List invIdList = listObjs(Wrappers.lambdaQuery(Inventory.class).eq(Inventory::getSite, site).in(Inventory::getSecrecyId, secrecyIdList).select(Inventory::getInventoryId), Object::toString); + if (CollectionUtil.isEmpty(invIdList)) { + throw BusinessException.build("保密库存[" + String.join(",", secrecyIdList) + "]不存在"); + } else { + return invIdList; + } + } } diff --git a/mom-wms-db/src/main/resources/mapper/ZWmsInventoryMapper.xml b/mom-wms-db/src/main/resources/mapper/ZWmsInventoryMapper.xml index 770d0fb..f9301de 100644 --- a/mom-wms-db/src/main/resources/mapper/ZWmsInventoryMapper.xml +++ b/mom-wms-db/src/main/resources/mapper/ZWmsInventoryMapper.xml @@ -51,6 +51,7 @@ + @@ -259,7 +260,7 @@ SELECT WI.HANDLE,WI.`INVENTORY_ID`,WI.ORIGINAL_QTY,WI.ITEM_BO, WI.`QTY_ON_HAND` , SUBSTRING_INDEX(SUBSTRING_INDEX(WI.ITEM_BO , ',', -2),',', 1) AS ITEM , wi.WMS_STORAGE_BIN_BO - , WI.`STATUS`, WI.BATCH_NO, WI.ERP_STORAGE_LOCATION + , WI.`STATUS`, WI.BATCH_NO, WI.ERP_STORAGE_LOCATION, WI.SECRECY_ID FROM WMS_INVENTORY WI WHERE WI.`HANDLE`= #{handle} @@ -347,6 +348,7 @@ +