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;
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 Integer dnOrderSeq;
private String secrecyId;
}

View File

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

View File

@ -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 = "单据拣货保存")

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.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<String> dto) {
public R bind(@RequestBody ListWithStringAndBoolsDTO<String> 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<String> inventoryIdList) {
public R unBind(@RequestBody ListWithStringAndBoolsDTO<String> 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();
}

View File

@ -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<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.remove(splitInventoryIdList.size() - 1);
return R.ok(splitInventoryIdList);
@ -389,7 +391,8 @@ public class ZWmsInventoryController {
String user = SecurityUtils.getUserName();
List<String> inventoryIdList = (List<String>) 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 = "查询待盘盈盘亏条码")

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<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);
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 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集合
* @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 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<Inventory> {
* Lot合批-产生新批号新增或修改库存表远程接口
*/
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,
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<DocumentMapper, Document> i
}
@Override
public List<ScanCodeDTO> scanCode(String site, String user, String code, String documentNo, boolean fullSearch) {
pickingService.checkCodePicking(site, code);
List<ScanCodeDTO> scanCodeDTOS = fullSearch ? inventoryService.selectTrayInvByCode(site, user, code) : inventoryService.selectInvByCode(site, user, code);
public List<ScanCodeDTO> 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<ScanCodeDTO> 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<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));
LocalDateTime now = LocalDateTime.now();
pickingService.lambdaUpdate().eq(Picking::getSite, site).eq(Picking::getDocumentNo, documentNo).remove();
if (checkScanAll) {
checkPickingTrayAllScan(site, list);
}

View File

@ -234,16 +234,17 @@ public class WmsStorageBinServiceImpl extends ServiceImpl<ZWmsStorageBinMapper,
}
@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 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);
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)
@ -255,11 +256,12 @@ public class WmsStorageBinServiceImpl extends ServiceImpl<ZWmsStorageBinMapper,
}
@Override
public void unBind(String site, String user, List<String> inventoryIdList) {
List<String> inventoryBoList = inventoryIdList.stream().map(o -> Inventory.genHandle(site, o)).collect(Collectors.toList());
public void unBind(String site, String user, List<String> inventoryIdList, boolean isSecrecy) {
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);
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<ZWmsStorageBinMapper,
}
@Override
public List<ScanCodeDTO> scanCode(String site, String user, String code) {
pickingService.checkCodePicking(site, code);
List<ScanCodeDTO> scanCodeDTOS = inventoryService.selectTrayInvByCode(site, user, code);
public List<ScanCodeDTO> scanCode(String site, String user, String code, boolean isSecrecy) {
String trueCode = isSecrecy ? inventoryService.getTrueInventoryIdBySecrecyId(site, code) : code;
pickingService.checkCodePicking(site, trueCode);
List<ScanCodeDTO> 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;
}
}

View File

@ -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<ZWmsInventoryMapper, I
@Override
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
@Override
@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) {
Inventory parentInventory = getByCode(site, parentInventoryId);
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 = 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<ZWmsInventoryMapper, I
}
//创建库存
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();
Inventory inventory = new Inventory();
BeanUtils.copyProperties(parentInventory, inventory);
@ -426,8 +425,18 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
inventory.setQmsSpecialMarking(qmsSpecialMarking);
//inventory.setCreateTime(LocalDateTime.now());
inventory.setParentInventoryBo(parentInventory.getHandle());
inventory.setSecrecyId(isSecrecy ? UUID.randomUUID().toString() : null);
//货格绑定
inventory.setWmsStorageBinBo(storageBinBo);
inventory.setUpdateTime(LocalDateTime.now());
inventory.setUpdater(user);
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("DES", itemObj.getDescription());
@ -440,31 +449,20 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
printData.add(paramMap);
}
saveBatch(newInventoryList);
//货格绑定/库存日志
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);
}
inventoryLogService.saveBatch(newInventoryLogList);
//更新父库存
BigDecimal subtract = parentInventory.getQtyOnHand().subtract(qty);
updateQty(user, parentInventoryId, subtract);
updateQty(user, parentInventory.getInventoryId(), subtract);
//数量为0解绑父库存
boolean parentIsEmpty = BigDecimal.ZERO.compareTo(subtract) == 0;
if (parentIsEmpty) {
lambdaUpdate().eq(Inventory::getHandle, Inventory.genHandle(site, parentInventoryId))
lambdaUpdate().eq(Inventory::getHandle, parentInventory.getHandle())
.set(Inventory::getWmsStorageBinBo, null)
.set(Inventory::getUpdateTime, LocalDateTime.now())
.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);
// 执行打印,单独开个线程去跑
@ -521,12 +519,13 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
//@GlobalTransactional
@Override
@Transactional(rollbackFor = Exception.class)
public String mergeInventory(String site, String user, List<String> inventoryIdList,String printer) {
List<String> inventoryBoList = inventoryIdList.stream().map(o -> Inventory.genHandle(site, o)).collect(Collectors.toList());
public String mergeInventory(String site, String user, List<String> inventoryIdList, String printer, boolean isSecrecy) {
//查询并校验库存
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()) {
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,18 +541,21 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
//扣除父库存数量并解绑
BigDecimal qty = BigDecimal.ZERO;
update(Wrappers.lambdaUpdate(Inventory.class).in(Inventory::getHandle, inventoryBoList)
.set(Inventory::getWmsStorageBinBo, null)
.set(Inventory::getQtyOnHand, BigDecimal.ZERO)
.set(Inventory::getUpdater, user)
.set(Inventory::getUpdateTime, LocalDateTime.now()));
List<InventoryLog> 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) {
@ -576,6 +578,7 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
inventory.setWmsStorageBinBo(inventoryList.get(0).getWmsStorageBinBo());
inventory.setUpdateTime(null);
inventory.setUpdater(null);
inventory.setSecrecyId(isSecrecy ? UUID.randomUUID().toString() : null);
save(inventory);
inventoryLogService.saveLog(user, inventoryId, null, null, Constant.CHANGE_TYPE_MERGE,
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
public InventoryDto selectForSplit(String site, String inventoryId) {
pickingService.checkCodePicking(site, inventoryId);
InventoryDto inventoryDto = Optional.ofNullable(baseMapper.selectWithStorageBin(Inventory.genHandle(site, inventoryId))).orElseThrow(() -> 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不允许拆合批");
} 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<ZWmsInventoryMapper, I
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="warranty" column="WARRANTY"/>
<result property="item" column="ITEM"/>
<result property="secrecyId" column="SECRECY_ID"/>
</resultMap>
<resultMap id="fullMap" extends="inventoryMap" type="com.foreverwin.mom.wms.dto.InventoryDto">
<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`
, 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}
</select>
@ -347,6 +348,7 @@
<result property="wmsStorageBinBo" column="WMS_STORAGE_BIN_BO"/>
<result property="dnOrder" column="DN_ORDER"/>
<result property="dnOrderSeq" column="DN_ORDER_SEQ"/>
<result property="secrecyId" column="SECRECY_ID"/>
</resultMap>
<select id="selectInvByCode" resultMap="scanCodeResultMap">
SELECT WI.INVENTORY_ID
@ -362,6 +364,7 @@
, WI.DN_ORDER
, WI.DN_ORDER_SEQ
, SUBSTRING_INDEX(WI.WMS_STORAGE_BIN_BO, ',', -1) AS STORAGE_BIN
, WI.SECRECY_ID
FROM WMS_INVENTORY WI
LEFT JOIN WMS_CARRIER_MEMBER WCM ON WCM.CARRIER_OR_INVENTORY_BO = WI.HANDLE
<where>
@ -380,6 +383,7 @@
, WI.DN_ORDER
, WI.DN_ORDER_SEQ
, SUBSTRING_INDEX(WI.WMS_STORAGE_BIN_BO, ',', -1) AS STORAGE_BIN
, WI.SECRECY_ID
FROM WMS_INVENTORY WI
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` = (