feat: 保密出入库、保密上下架、保密拆合批

This commit is contained in:
faramita 2024-12-04 15:54:49 +08:00
parent 312a7a56ac
commit 7cd9d112cc
13 changed files with 127 additions and 89 deletions

View File

@ -20,6 +20,6 @@ public class ListWithStringAndBoolsDTO<T> {
private List<T> list; private List<T> list;
public boolean getSwitch(int i) { public boolean getSwitch(int i) {
return switchArray != null && switchArray.length > 0 && switchArray[i]; return switchArray != null && switchArray.length > i && switchArray[i];
} }
} }

View File

@ -34,4 +34,6 @@ public class ScanCodeDTO {
private String dnOrder; private String dnOrder;
private Integer dnOrderSeq; private Integer dnOrderSeq;
private String secrecyId;
} }

View File

@ -178,11 +178,14 @@ public class Inventory extends Model<Inventory> {
private String erpStorageLocation; private String erpStorageLocation;
/** /**
* 库存调整原因 * 库存保密ID
*/ */
@ApiModelProperty(value = "库存调整原因") @ApiModelProperty(value = "库存调整原因")
@Deprecated @Deprecated
private String adjustmentReason; private String adjustmentReason;
@ApiModelProperty(value = "库存保密ID")
private String secrecyId;
/** /**
* 是否采购到货批 * 是否采购到货批
*/ */

View File

@ -854,10 +854,10 @@ public class DocumentController {
@ApiOperation(value = "单据扫码", notes = "单据扫码") @ApiOperation(value = "单据扫码", notes = "单据扫码")
@GetMapping("/scanCode") @GetMapping("/scanCode")
@SysLog("单据扫码") @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 site = TenantContextHolder.getTenantId();
String user = SecurityUtils.getUserName(); 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 = "单据拣货保存") @ApiOperation(value = "单据拣货保存", notes = "单据拣货保存")

View File

@ -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.excel.annotation.ResponseExcel;
import com.foreverwin.mom.common.log.annotation.SysLog; import com.foreverwin.mom.common.log.annotation.SysLog;
import com.foreverwin.mom.common.security.util.SecurityUtils; 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.ListWithStringDTO;
import com.foreverwin.mom.wms.dto.StorageBinDto; import com.foreverwin.mom.wms.dto.StorageBinDto;
import com.foreverwin.mom.wms.entity.StorageBin; import com.foreverwin.mom.wms.entity.StorageBin;
@ -164,29 +165,29 @@ public class WmsStorageBinController {
@ApiOperation(value = "上下架扫码", notes = "上下架扫码") @ApiOperation(value = "上下架扫码", notes = "上下架扫码")
@GetMapping("/scanCode") @GetMapping("/scanCode")
@SysLog("上下架扫码") @SysLog("上下架扫码")
public R scanCode(String code) { public R scanCode(String code, boolean isSecrecy) {
String site = TenantContextHolder.getTenantId(); String site = TenantContextHolder.getTenantId();
String user = SecurityUtils.getUserName(); String user = SecurityUtils.getUserName();
return R.ok(storageBinService.scanCode(site, user, code)); return R.ok(storageBinService.scanCode(site, user, code, isSecrecy));
} }
@ApiOperation(value = "货格绑定", notes = "货格绑定") @ApiOperation(value = "货格绑定", notes = "货格绑定")
@SysLog("货格绑定") @SysLog("货格绑定")
@PostMapping("/bind") @PostMapping("/bind")
public R bind(@RequestBody ListWithStringDTO<String> dto) { public R bind(@RequestBody ListWithStringAndBoolsDTO<String> dto) {
String site = TenantContextHolder.getTenantId(); String site = TenantContextHolder.getTenantId();
String user = SecurityUtils.getUserName(); 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(); return R.ok();
} }
@ApiOperation(value = "货格解绑", notes = "货格解绑") @ApiOperation(value = "货格解绑", notes = "货格解绑")
@SysLog("货格解绑") @SysLog("货格解绑")
@PostMapping("/unBind") @PostMapping("/unBind")
public R unBind(@RequestBody List<String> inventoryIdList) { public R unBind(@RequestBody ListWithStringAndBoolsDTO<String> dto) {
String site = TenantContextHolder.getTenantId(); String site = TenantContextHolder.getTenantId();
String user = SecurityUtils.getUserName(); String user = SecurityUtils.getUserName();
storageBinService.unBind(site, user, inventoryIdList); storageBinService.unBind(site, user, dto.getList(), dto.getSwitch(0));
return R.ok(); return R.ok();
} }

View File

@ -1,5 +1,6 @@
package com.foreverwin.mom.wms.controller; package com.foreverwin.mom.wms.controller;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -370,7 +371,8 @@ public class ZWmsInventoryController {
int splitNum = Integer.parseInt(request.get("splitNum")); int splitNum = Integer.parseInt(request.get("splitNum"));
String qmsSpecialMarking = request.get("qmsSpecialMarking"); String qmsSpecialMarking = request.get("qmsSpecialMarking");
String printer = request.get("printer"); String printer = request.get("printer");
List<String> splitInventoryIdList = inventoryService.splitInventory(site, user, parentInventoryId, splitQty, splitNum, null, null, null, null, qmsSpecialMarking, printer); boolean isSecrecy = Boolean.parseBoolean(request.get("isSecrecy"));
List<String> splitInventoryIdList = inventoryService.splitInventory(site, user, parentInventoryId, splitQty, splitNum, null, null, null, null, qmsSpecialMarking, printer, isSecrecy);
splitInventoryIdList.add(parentInventoryId); splitInventoryIdList.add(parentInventoryId);
splitInventoryIdList.remove(splitInventoryIdList.size() - 1); splitInventoryIdList.remove(splitInventoryIdList.size() - 1);
return R.ok(splitInventoryIdList); return R.ok(splitInventoryIdList);
@ -389,7 +391,8 @@ public class ZWmsInventoryController {
String user = SecurityUtils.getUserName(); String user = SecurityUtils.getUserName();
List<String> inventoryIdList = (List<String>) request.get("inventoryIdList"); List<String> inventoryIdList = (List<String>) request.get("inventoryIdList");
String printer = request.get("printer").toString(); 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); return R.ok(mergeInventoryId);
//} //}
} }
@ -402,9 +405,9 @@ public class ZWmsInventoryController {
*/ */
@ApiOperation(value = "查询待拆合批条码", notes = "查询待拆合批条码") @ApiOperation(value = "查询待拆合批条码", notes = "查询待拆合批条码")
@GetMapping("/selectForSplit") @GetMapping("/selectForSplit")
public R selectForSplit(String inventoryId) { public R selectForSplit(String inventoryId, boolean isSecrecy) {
String site = TenantContextHolder.getTenantId(); String site = TenantContextHolder.getTenantId();
return R.ok(inventoryService.selectForSplit(site, inventoryId)); return R.ok(inventoryService.selectForSplit(site, inventoryId, isSecrecy));
} }
@ApiOperation(value = "查询待盘盈盘亏条码", notes = "查询待盘盈盘亏条码") @ApiOperation(value = "查询待盘盈盘亏条码", notes = "查询待盘盈盘亏条码")

View File

@ -310,7 +310,7 @@ public interface DocumentService extends IService<Document> {
List<DocumentDetailed> getSubmitDocumentDetail(String site, String user, String documentNo, String sourceWarehouse, String targetWarehouse); List<DocumentDetailed> getSubmitDocumentDetail(String site, String user, String documentNo, String sourceWarehouse, String targetWarehouse);
List<ScanCodeDTO> scanCode(String site, String user, String code, String documentNo, boolean fullSearch); List<ScanCodeDTO> scanCode(String site, String user, String code, String documentNo, boolean fullSearch, boolean isSecrecy);
/** /**
* 保存拣货 * 保存拣货

View File

@ -35,10 +35,10 @@ public interface WmsStorageBinService extends IService<StorageBin> {
String labelPrint(String site, List<StorageBin> printList, String printer); String labelPrint(String site, List<StorageBin> printList, String printer);
List<ScanCodeDTO> scanCode(String site, String user, String code); List<ScanCodeDTO> scanCode(String site, String user, String code, boolean isSecrecy);
void bind(String site, String user, String storageBin, List<String> inventoryIdList); void bind(String site, String user, String storageBin, List<String> inventoryIdList, boolean isSecrecy);
void unBind(String site, String user, List<String> inventoryIdList); void unBind(String site, String user, List<String> inventoryIdList, boolean isSecrecy);
} }

View File

@ -87,7 +87,7 @@ public interface ZWmsInventoryService extends IService<Inventory> {
*/ */
List<String> splitInventory(String site, String user, String parentInventory, BigDecimal splitQty, int splitNum, String documentNo, String documentType, String storageBinBo); List<String> splitInventory(String site, String user, String parentInventory, BigDecimal splitQty, int splitNum, String documentNo, String documentType, String storageBinBo);
List<String> splitInventory(String site, String user, String parentInventoryId, BigDecimal splitQty, int splitNum, String documentNo, String documentType, String storageBinBo, List<String> newInventoryIdList, String qmsSpecialMarking, String printerName); List<String> splitInventory(String site, String user, String parentInventoryId, BigDecimal splitQty, int splitNum, String documentNo, String documentType, String storageBinBo, List<String> newInventoryIdList, String qmsSpecialMarking, String printerName, boolean isSecrecy);
/** /**
* 合并库存 * 合并库存
@ -97,13 +97,13 @@ public interface ZWmsInventoryService extends IService<Inventory> {
* @param inventoryIList 库存ID集合 * @param inventoryIList 库存ID集合
* @return 新库存ID * @return 新库存ID
*/ */
String mergeInventory(String site, String user, List<String> inventoryIList,String printer); String mergeInventory(String site, String user, List<String> inventoryIList, String printer, boolean isSecrecy);
IPage fetchItemList(Page page, String item); IPage fetchItemList(Page page, String item);
IPage fetchItemGroesList(Page page, String searchText); 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); InventoryDto selectForStocktaking(String site, String inventoryId);
@ -132,4 +132,8 @@ public interface ZWmsInventoryService extends IService<Inventory> {
* Lot合批-产生新批号新增或修改库存表远程接口 * Lot合批-产生新批号新增或修改库存表远程接口
*/ */
void margeNewUpdateInventory(InventoryDto dto); void margeNewUpdateInventory(InventoryDto dto);
List<String> getTrueInvIdListBySecrecyIdList(String site, List<String> secrecyIdList);
String getTrueInventoryIdBySecrecyId(String site, String secrecyId);
} }

View File

@ -5982,7 +5982,7 @@ public class DocumentServiceImpl extends ServiceImpl<DocumentMapper, Document> i
documentNo, documentNo,
null, null,
storageBinBindInventory.getStorageBinBo(), storageBinBindInventory.getStorageBinBo(),
Collections.singletonList(parentInventoryId + "-1"), null, null Collections.singletonList(parentInventoryId + "-1"), null, null,false
).get(0); ).get(0);
inventoryService.update(Wrappers.lambdaUpdate(Inventory.class) inventoryService.update(Wrappers.lambdaUpdate(Inventory.class)
.eq(Inventory::getHandle, Inventory.genHandle(site, freezeInventoryId)) .eq(Inventory::getHandle, Inventory.genHandle(site, freezeInventoryId))
@ -6648,9 +6648,10 @@ public class DocumentServiceImpl extends ServiceImpl<DocumentMapper, Document> i
} }
@Override @Override
public List<ScanCodeDTO> scanCode(String site, String user, String code, String documentNo, boolean fullSearch) { public List<ScanCodeDTO> scanCode(String site, String user, String code, String documentNo, boolean fullSearch, boolean isSecrecy) {
pickingService.checkCodePicking(site, code); String trueCode = isSecrecy ? inventoryService.getTrueInventoryIdBySecrecyId(site, code) : code;
List<ScanCodeDTO> scanCodeDTOS = fullSearch ? inventoryService.selectTrayInvByCode(site, user, code) : inventoryService.selectInvByCode(site, user, code); pickingService.checkCodePicking(site, trueCode);
List<ScanCodeDTO> scanCodeDTOS = fullSearch ? inventoryService.selectTrayInvByCode(site, user, trueCode) : inventoryService.selectInvByCode(site, user, trueCode);
if (CollectionUtil.isEmpty(scanCodeDTOS)) { if (CollectionUtil.isEmpty(scanCodeDTOS)) {
throw BusinessException.build("条码无法识别"); throw BusinessException.build("条码无法识别");
} else if (StrUtil.isNotBlank(documentNo)) { } else if (StrUtil.isNotBlank(documentNo)) {
@ -6687,6 +6688,7 @@ public class DocumentServiceImpl extends ServiceImpl<DocumentMapper, Document> i
Map<String, Integer> seqMap = documentDetailedService.lambdaQuery().eq(DocumentDetailed::getDocumentBo, documentBo).select(DocumentDetailed::getItem, DocumentDetailed::getSeq).list().stream().collect(Collectors.toMap(DocumentDetailed::getItem, DocumentDetailed::getSeq, (s, s2) -> s)); Map<String, Integer> 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(); LocalDateTime now = LocalDateTime.now();
pickingService.lambdaUpdate().eq(Picking::getSite, site).eq(Picking::getDocumentNo, documentNo).remove(); pickingService.lambdaUpdate().eq(Picking::getSite, site).eq(Picking::getDocumentNo, documentNo).remove();
if (checkScanAll) { if (checkScanAll) {
checkPickingTrayAllScan(site, list); checkPickingTrayAllScan(site, list);
} }

View File

@ -234,32 +234,34 @@ public class WmsStorageBinServiceImpl extends ServiceImpl<ZWmsStorageBinMapper,
} }
@Override @Override
public void bind(String site, String user, String storageBin, List<String> inventoryIdList) { public void bind(String site, String user, String storageBin, List<String> inventoryIdList, boolean isSecrecy) {
String storageBinBo = StorageBin.genHandle(site, storageBin); String storageBinBo = StorageBin.genHandle(site, storageBin);
String erpStorageLocation = Optional.ofNullable(getStorageLocationByStorageBin(site, storageBin)).orElseThrow(() -> BusinessException.build("未找到货格对应的仓库")); String erpStorageLocation = Optional.ofNullable(getStorageLocationByStorageBin(site, storageBin)).orElseThrow(() -> BusinessException.build("未找到货格对应的仓库"));
List<String> inventoryBoList = inventoryIdList.stream().map(o -> Inventory.genHandle(site, o)).collect(Collectors.toList()); List<String> trueInventoryIdList = isSecrecy ? inventoryService.getTrueInvIdListBySecrecyIdList(site, inventoryIdList) : inventoryIdList;
List<String> inventoryBoList = trueInventoryIdList.stream().map(o -> Inventory.genHandle(site, o)).collect(Collectors.toList());
List<Inventory> inventoryList = inventoryService.listByIds(inventoryBoList); List<Inventory> inventoryList = inventoryService.listByIds(inventoryBoList);
inventoryList.stream().filter(o -> !erpStorageLocation.equals(o.getErpStorageLocation())).findFirst().ifPresent(inventory -> { 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()) { 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) + "]不存在"); throw BusinessException.build("库存[" + String.join(",", inventoryIdList) + "]不存在");
} }
inventoryService.lambdaUpdate().in(Inventory::getHandle, inventoryBoList) inventoryService.lambdaUpdate().in(Inventory::getHandle, inventoryBoList)
.set(Inventory::getWmsStorageBinBo, storageBinBo) .set(Inventory::getWmsStorageBinBo, storageBinBo)
.set(Inventory::getUpdateTime, LocalDateTime.now()) .set(Inventory::getUpdateTime, LocalDateTime.now())
.set(Inventory::getUpdater, user).update(); .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 @Override
public void unBind(String site, String user, List<String> inventoryIdList) { public void unBind(String site, String user, List<String> inventoryIdList, boolean isSecrecy) {
List<String> inventoryBoList = inventoryIdList.stream().map(o -> Inventory.genHandle(site, o)).collect(Collectors.toList()); List<String> trueInventoryIdList = isSecrecy ? inventoryService.getTrueInvIdListBySecrecyIdList(site, inventoryIdList) : inventoryIdList;
List<String> inventoryBoList = trueInventoryIdList.stream().map(o -> Inventory.genHandle(site, o)).collect(Collectors.toList());
List<Inventory> inventoryList = inventoryService.listByIds(inventoryBoList); List<Inventory> inventoryList = inventoryService.listByIds(inventoryBoList);
if (CollectionUtil.isEmpty(inventoryList) || inventoryList.size() != inventoryIdList.size()) { 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) + "]不存在"); throw BusinessException.build("库存[" + String.join(",", inventoryIdList) + "]不存在");
} }
inventoryService.lambdaUpdate().in(Inventory::getHandle, inventoryBoList) inventoryService.lambdaUpdate().in(Inventory::getHandle, inventoryBoList)
@ -270,12 +272,16 @@ public class WmsStorageBinServiceImpl extends ServiceImpl<ZWmsStorageBinMapper,
} }
@Override @Override
public List<ScanCodeDTO> scanCode(String site, String user, String code) { public List<ScanCodeDTO> scanCode(String site, String user, String code, boolean isSecrecy) {
pickingService.checkCodePicking(site, code); String trueCode = isSecrecy ? inventoryService.getTrueInventoryIdBySecrecyId(site, code) : code;
List<ScanCodeDTO> scanCodeDTOS = inventoryService.selectTrayInvByCode(site, user, code); pickingService.checkCodePicking(site, trueCode);
List<ScanCodeDTO> scanCodeDTOS = inventoryService.selectTrayInvByCode(site, user, trueCode);
if (CollectionUtil.isEmpty(scanCodeDTOS)) { if (CollectionUtil.isEmpty(scanCodeDTOS)) {
throw BusinessException.build("条码" + code + "无法识别"); throw BusinessException.build("条码" + code + "无法识别");
} else { } else {
/*if (isSecrecy) {
scanCodeDTOS.forEach(scanCodeDTO -> scanCodeDTO.setInventoryId(scanCodeDTO.getSecrecyId()));
}*/
return scanCodeDTOS; return scanCodeDTOS;
} }
} }

View File

@ -12,12 +12,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.foreverwin.iep.common.base.FrontPage; import com.foreverwin.iep.common.base.FrontPage;
import com.foreverwin.iep.common.constant.BaseConstants; 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.domain.GenerateNextNumberRequest;
import com.foreverwin.iep.prd.entity.Item; import com.foreverwin.iep.prd.entity.Item;
import com.foreverwin.iep.prd.feign.RemoteNextNumberService; 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.constant.SecurityConstants;
import com.foreverwin.mom.common.core.exception.BusinessException; import com.foreverwin.mom.common.core.exception.BusinessException;
import com.foreverwin.mom.common.data.tenant.TenantContextHolder; 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.ZWmsInventoryLogService;
import com.foreverwin.mom.wms.service.ZWmsInventoryService; import com.foreverwin.mom.wms.service.ZWmsInventoryService;
import com.foreverwin.mom.wms.util.StringUtil; import com.foreverwin.mom.wms.util.StringUtil;
import com.foreverwin.mom.wms.util.ThreadPoolUtil;
import com.foreverwin.nlv.print.feign.RemotePrintService; import com.foreverwin.nlv.print.feign.RemotePrintService;
import io.swagger.models.auth.In;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -382,14 +377,15 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
@Override @Override
public List<String> splitInventory(String site, String user, String parentInventoryId, BigDecimal splitQty, int splitNum, String documentNo, String documentType, String storageBinBo) { public List<String> 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 //@GlobalTransactional
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public List<String> splitInventory(String site, String user, String parentInventoryId, BigDecimal splitQty, int splitNum, String documentNo, String documentType, String storageBinBo, List<String> newInventoryIdList, String qmsSpecialMarking, String printerName) { public List<String> splitInventory(String site, String user, String parentInventoryId, BigDecimal splitQty, int splitNum, String documentNo, String documentType, String storageBinBo, List<String> newInventoryIdList, String qmsSpecialMarking, String printerName, boolean isSecrecy) {
Inventory parentInventory = getByCode(site, parentInventoryId); Inventory parentInventory = isSecrecy ? lambdaQuery().eq(Inventory::getSite, site).eq(Inventory::getSecrecyId, parentInventoryId)
.one() : getById(Inventory.genHandle(site, parentInventoryId));
if (parentInventory == null) { if (parentInventory == null) {
throw BusinessException.build("库存不存在"); throw BusinessException.build("库存不存在");
} else { } else {
@ -414,7 +410,10 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
} }
//创建库存 //创建库存
List<Inventory> newInventoryList = new ArrayList<>(); List<Inventory> newInventoryList = new ArrayList<>();
for (String inventoryId : newInventoryIdList) { List<InventoryLog> 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(); JSONObject paramMap = new JSONObject();
Inventory inventory = new Inventory(); Inventory inventory = new Inventory();
BeanUtils.copyProperties(parentInventory, inventory); BeanUtils.copyProperties(parentInventory, inventory);
@ -426,8 +425,18 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
inventory.setQmsSpecialMarking(qmsSpecialMarking); inventory.setQmsSpecialMarking(qmsSpecialMarking);
//inventory.setCreateTime(LocalDateTime.now()); //inventory.setCreateTime(LocalDateTime.now());
inventory.setParentInventoryBo(parentInventory.getHandle()); inventory.setParentInventoryBo(parentInventory.getHandle());
inventory.setSecrecyId(isSecrecy ? UUID.randomUUID().toString() : null);
//货格绑定
inventory.setWmsStorageBinBo(storageBinBo);
inventory.setUpdateTime(LocalDateTime.now());
inventory.setUpdater(user);
newInventoryList.add(inventory); newInventoryList.add(inventory);
//库存日志
newInventoryLogList.add(inventoryLogService.buildLog(user, inventoryId, documentNo, null, StrUtil.isBlank(documentType) ? Constant.CHANGE_TYPE_SPLIT : documentType,
null, null, storageBinBo, null, null, null, inventory));
/*if (isSecrecy) {
newInventoryIdList.set(i, inventory.getSecrecyId());
}*/
// 添加打印参数 // 添加打印参数
paramMap.put("ITEM", itemObj.getItem()); paramMap.put("ITEM", itemObj.getItem());
paramMap.put("DES", itemObj.getDescription()); paramMap.put("DES", itemObj.getDescription());
@ -440,31 +449,20 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
printData.add(paramMap); printData.add(paramMap);
} }
saveBatch(newInventoryList); saveBatch(newInventoryList);
//货格绑定/库存日志 inventoryLogService.saveBatch(newInventoryLogList);
storageBinBo = StrUtil.blankToDefault(storageBinBo, parentStorageBinBo);
for (String inventoryId : newInventoryIdList) {
lambdaUpdate().eq(Inventory::getHandle, Inventory.genHandle(site, inventoryId))
.set(StrUtil.isNotBlank(storageBinBo), Inventory::getWmsStorageBinBo, storageBinBo)
.set(Inventory::getUpdateTime, LocalDateTime.now())
.set(Inventory::getUpdater, user).update();
inventoryLogService.saveLog(user, inventoryId, documentNo, null, StrUtil.isBlank(documentType) ? Constant.CHANGE_TYPE_SPLIT : documentType,
null, null, storageBinBo);
}
//更新父库存 //更新父库存
BigDecimal subtract = parentInventory.getQtyOnHand().subtract(qty); BigDecimal subtract = parentInventory.getQtyOnHand().subtract(qty);
updateQty(user, parentInventoryId, subtract); updateQty(user, parentInventory.getInventoryId(), subtract);
//数量为0解绑父库存 //数量为0解绑父库存
boolean parentIsEmpty = BigDecimal.ZERO.compareTo(subtract) == 0; boolean parentIsEmpty = BigDecimal.ZERO.compareTo(subtract) == 0;
if (parentIsEmpty) { if (parentIsEmpty) {
lambdaUpdate().eq(Inventory::getHandle, Inventory.genHandle(site, parentInventoryId)) lambdaUpdate().eq(Inventory::getHandle, parentInventory.getHandle())
.set(Inventory::getWmsStorageBinBo, null) .set(Inventory::getWmsStorageBinBo, null)
.set(Inventory::getUpdateTime, LocalDateTime.now()) .set(Inventory::getUpdateTime, LocalDateTime.now())
.set(Inventory::getUpdater, user).update(); .set(Inventory::getUpdater, user).update();
} }
//父库存日志 //父库存日志
inventoryLogService.saveLog(user, parentInventoryId, documentNo, parentInventory.getStatus(), Constant.CHANGE_TYPE_SPLIT, inventoryLogService.saveLog(user, parentInventory.getInventoryId(), documentNo, parentInventory.getStatus(), Constant.CHANGE_TYPE_SPLIT,
parentStorageBinBo, parentInventory.getQtyOnHand(), parentIsEmpty ? null : parentStorageBinBo); parentStorageBinBo, parentInventory.getQtyOnHand(), parentIsEmpty ? null : parentStorageBinBo);
// 执行打印,单独开个线程去跑 // 执行打印,单独开个线程去跑
@ -521,12 +519,13 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
//@GlobalTransactional //@GlobalTransactional
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public String mergeInventory(String site, String user, List<String> inventoryIdList,String printer) { public String mergeInventory(String site, String user, List<String> inventoryIdList, String printer, boolean isSecrecy) {
List<String> inventoryBoList = inventoryIdList.stream().map(o -> Inventory.genHandle(site, o)).collect(Collectors.toList());
//查询并校验库存 //查询并校验库存
List<Inventory> inventoryList = listByIds(inventoryBoList); List<Inventory> 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()) { 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) + "]不存在"); throw BusinessException.build("库存[" + String.join(",", inventoryIdList) + "]不存在");
} else { } else {
//查询并校验货格 //查询并校验货格
@ -542,22 +541,25 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
//扣除父库存数量并解绑 //扣除父库存数量并解绑
BigDecimal qty = BigDecimal.ZERO; BigDecimal qty = BigDecimal.ZERO;
update(Wrappers.lambdaUpdate(Inventory.class).in(Inventory::getHandle, inventoryBoList) List<InventoryLog> inventoryLogs = new ArrayList<>();
.set(Inventory::getWmsStorageBinBo, null)
.set(Inventory::getQtyOnHand, BigDecimal.ZERO)
.set(Inventory::getUpdater, user)
.set(Inventory::getUpdateTime, LocalDateTime.now()));
for (Inventory inventory : inventoryList) { for (Inventory inventory : inventoryList) {
String inventoryId = inventory.getInventoryId(); String inventoryId = inventory.getInventoryId();
BigDecimal qtyOnHand = inventory.getQtyOnHand(); BigDecimal qtyOnHand = inventory.getQtyOnHand();
qty = qty.add(qtyOnHand); qty = qty.add(qtyOnHand);
inventoryLogService.saveLog(user, inventoryId, null, inventory.getStatus(), Constant.CHANGE_TYPE_MERGE, inventoryLogs.add(inventoryLogService.buildLog(user, inventoryId, null, inventory.getStatus(), Constant.CHANGE_TYPE_MERGE,
inventory.getWmsStorageBinBo(), qtyOnHand, null); 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(); String itemBo = inventoryList.get(0).getItemBo();
Item itemObj = itemService.getById(itemBo); Item itemObj = itemService.getById(itemBo);
if(itemObj==null){ if (itemObj == null) {
throw BusinessException.build("根据物料主键"+itemBo+"未找到对象"); throw BusinessException.build("根据物料主键" + itemBo + "未找到对象");
} }
//创建新库存并绑定 //创建新库存并绑定
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
@ -576,6 +578,7 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
inventory.setWmsStorageBinBo(inventoryList.get(0).getWmsStorageBinBo()); inventory.setWmsStorageBinBo(inventoryList.get(0).getWmsStorageBinBo());
inventory.setUpdateTime(null); inventory.setUpdateTime(null);
inventory.setUpdater(null); inventory.setUpdater(null);
inventory.setSecrecyId(isSecrecy ? UUID.randomUUID().toString() : null);
save(inventory); save(inventory);
inventoryLogService.saveLog(user, inventoryId, null, null, Constant.CHANGE_TYPE_MERGE, inventoryLogService.saveLog(user, inventoryId, null, null, Constant.CHANGE_TYPE_MERGE,
null, null, inventoryList.get(0).getWmsStorageBinBo()); null, null, inventoryList.get(0).getWmsStorageBinBo());
@ -608,7 +611,7 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
} }
}); });
} }
return inventoryId; return /*isSecrecy ? */inventoryId /*: inventory.getSecrecyId()*/;
} }
} }
@ -625,22 +628,17 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
} }
@Override @Override
public InventoryDto selectForSplit(String site, String inventoryId) { public InventoryDto selectForSplit(String site, String inventoryId, boolean isSecrecy) {
pickingService.checkCodePicking(site, inventoryId); String trueInventoryId = isSecrecy ? getTrueInventoryIdBySecrecyId(site, inventoryId) : inventoryId;
InventoryDto inventoryDto = Optional.ofNullable(baseMapper.selectWithStorageBin(Inventory.genHandle(site, inventoryId))).orElseThrow(() -> BusinessException.build(inventoryId+"库存不存在")); pickingService.checkCodePicking(site, trueInventoryId);
/*String itemType = Optional.ofNullable(inventoryDto).orElseThrow(() -> BusinessException.build("库存不存在或未绑定货格")).getItemType(); InventoryDto inventoryDto = Optional.ofNullable(baseMapper.selectWithStorageBin(Inventory.genHandle(site, trueInventoryId))).orElseThrow(() -> BusinessException.build(inventoryId + "库存不存在"));
if (StrUtil.isBlank(itemType) || !StrUtil.equalsAny(itemType, KeyWordConstant.ITEM_MATERIAL_TYPE_ROH, KeyWordConstant.ITEM_MATERIAL_TYPE_VERP)) {
throw BusinessException.build("非原材料/包材不允许拆合批");
} else*/
if (BigDecimal.ZERO.compareTo(inventoryDto.getQtyOnHand()) == 0) { if (BigDecimal.ZERO.compareTo(inventoryDto.getQtyOnHand()) == 0) {
throw BusinessException.build(inventoryId+"库存为0不允许拆合批"); throw BusinessException.build(inventoryId + "库存为0不允许拆合批");
} else { } else {
/*long count = inventoryGroupService.count(Wrappers.lambdaQuery(InventoryGroup.class).eq(InventoryGroup::getInventoryBo, Inventory.genHandle(site, inventoryId))); /*if (isSecrecy) {
if (count > 0) { inventoryDto.setInventoryId(inventoryDto.getSecrecyId());
throw BusinessException.build("分组库存不允许拆合批"); }*/
} else {*/
return inventoryDto; return inventoryDto;
//}
} }
} }
@ -1032,4 +1030,19 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
inventoryLogService.save(inventoryLog); inventoryLogService.save(inventoryLog);
} }
} }
@Override
public String getTrueInventoryIdBySecrecyId(String site, String secrecyId) {
return Optional.ofNullable(getObj(Wrappers.lambdaQuery(Inventory.class).eq(Inventory::getSite, site).eq(Inventory::getSecrecyId, secrecyId).select(Inventory::getInventoryId), Object::toString)).orElseThrow(() -> BusinessException.build("保密库存" + secrecyId + "不存在"));
}
@Override
public List<String> getTrueInvIdListBySecrecyIdList(String site, List<String> secrecyIdList) {
List<String> 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;
}
}
} }

View File

@ -51,6 +51,7 @@
<result property="itemType" column="ITEM_TYPE"/> <result property="itemType" column="ITEM_TYPE"/>
<result property="warranty" column="WARRANTY"/> <result property="warranty" column="WARRANTY"/>
<result property="item" column="ITEM"/> <result property="item" column="ITEM"/>
<result property="secrecyId" column="SECRECY_ID"/>
</resultMap> </resultMap>
<resultMap id="fullMap" extends="inventoryMap" type="com.foreverwin.mom.wms.dto.InventoryDto"> <resultMap id="fullMap" extends="inventoryMap" type="com.foreverwin.mom.wms.dto.InventoryDto">
<result property="item" column="ITEM"/> <result property="item" column="ITEM"/>
@ -259,7 +260,7 @@
SELECT WI.HANDLE,WI.`INVENTORY_ID`,WI.ORIGINAL_QTY,WI.ITEM_BO, WI.`QTY_ON_HAND` 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 , SUBSTRING_INDEX(SUBSTRING_INDEX(WI.ITEM_BO , ',', -2),',', 1) AS ITEM
, wi.WMS_STORAGE_BIN_BO , 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 FROM WMS_INVENTORY WI
WHERE WI.`HANDLE`= #{handle} WHERE WI.`HANDLE`= #{handle}
</select> </select>
@ -347,6 +348,7 @@
<result property="wmsStorageBinBo" column="WMS_STORAGE_BIN_BO"/> <result property="wmsStorageBinBo" column="WMS_STORAGE_BIN_BO"/>
<result property="dnOrder" column="DN_ORDER"/> <result property="dnOrder" column="DN_ORDER"/>
<result property="dnOrderSeq" column="DN_ORDER_SEQ"/> <result property="dnOrderSeq" column="DN_ORDER_SEQ"/>
<result property="secrecyId" column="SECRECY_ID"/>
</resultMap> </resultMap>
<select id="selectInvByCode" resultMap="scanCodeResultMap"> <select id="selectInvByCode" resultMap="scanCodeResultMap">
SELECT WI.INVENTORY_ID SELECT WI.INVENTORY_ID
@ -362,6 +364,7 @@
, WI.DN_ORDER , WI.DN_ORDER
, WI.DN_ORDER_SEQ , WI.DN_ORDER_SEQ
, SUBSTRING_INDEX(WI.WMS_STORAGE_BIN_BO, ',', -1) AS STORAGE_BIN , SUBSTRING_INDEX(WI.WMS_STORAGE_BIN_BO, ',', -1) AS STORAGE_BIN
, WI.SECRECY_ID
FROM WMS_INVENTORY WI FROM WMS_INVENTORY WI
LEFT JOIN WMS_CARRIER_MEMBER WCM ON WCM.CARRIER_OR_INVENTORY_BO = WI.HANDLE LEFT JOIN WMS_CARRIER_MEMBER WCM ON WCM.CARRIER_OR_INVENTORY_BO = WI.HANDLE
<where> <where>
@ -380,6 +383,7 @@
, WI.DN_ORDER , WI.DN_ORDER
, WI.DN_ORDER_SEQ , WI.DN_ORDER_SEQ
, SUBSTRING_INDEX(WI.WMS_STORAGE_BIN_BO, ',', -1) AS STORAGE_BIN , SUBSTRING_INDEX(WI.WMS_STORAGE_BIN_BO, ',', -1) AS STORAGE_BIN
, WI.SECRECY_ID
FROM WMS_INVENTORY WI FROM WMS_INVENTORY WI
LEFT JOIN WMS_CARRIER_MEMBER WCM ON WCM.CARRIER_OR_INVENTORY_BO = WI.HANDLE LEFT JOIN WMS_CARRIER_MEMBER WCM ON WCM.CARRIER_OR_INVENTORY_BO = WI.HANDLE
WHERE WI.HANDLE = #{inventoryBo} or WCM.`CARRIER_BO`= #{carrierBo} or WCM.`CARRIER_BO` = ( WHERE WI.HANDLE = #{inventoryBo} or WCM.`CARRIER_BO`= #{carrierBo} or WCM.`CARRIER_BO` = (