opt:优化倒扣逻辑:不校验WMS线边库库存,如果没有库存时则强制扣减WMS最大库存

This commit is contained in:
zhangzq
2026-09-29 10:46:52 +08:00
parent e00f379b95
commit 7eeeacf864
3 changed files with 65 additions and 8 deletions

View File

@@ -21,6 +21,9 @@ public abstract class InventoryChangeType<T extends InventoryParam> {
//减冻结数
public static final InventoryChangeType<OutFinishParam> OUT_FINS =
new InventoryChangeType<OutFinishParam>(OutFinishParam.class) {};
//强制减冻结数
public static final InventoryChangeType<OutFinishParamForce> OUT_FINS_FORCE =
new InventoryChangeType<OutFinishParamForce>(OutFinishParamForce.class) {};
//入库相关不用处理,基于组盘
public static final InventoryChangeType<InDisParam> IN_DIS =
new InventoryChangeType<InDisParam>(InDisParam.class) {};

View File

@@ -54,7 +54,7 @@ public class StInventoryServiceImpl implements IStInventoryService {
public <T extends InventoryParam> void changeInventory(InventoryChangeType<T> typeEnum, List<T> params) {
final String type = typeEnum.getType();
params.forEach(a->a.validation());
//AddInvParam,SubInvParam,OutDisParam,OutFinishParam,InDisParam,InFinishParam
//AddInvParam,SubInvParam,OutDisParam,OutFinishParam,InDisParam,InFinishParam,OutFinishParamForce
switch (type){
case "AddInvParam":
final List<AddInvParam> addInvParams = (List<AddInvParam>) params;
@@ -207,6 +207,62 @@ public class StInventoryServiceImpl implements IStInventoryService {
}
stIvtStructivtflowService.saveBatch(recordsOutFinish);
break;
case "OutFinishParamForce":
final List<OutFinishParamForce> outFinishParamForces = (List<OutFinishParamForce>) params;
List<StIvtStructivtflow> recordsOutFinishForce = new ArrayList<>();
for (OutFinishParamForce outFinishParam : outFinishParamForces) {
final LambdaQueryWrapper<GroupPlate> queryWrapper = new QueryWrapper<GroupPlate>().lambda()
.eq(GroupPlate::getStoragevehicle_code, outFinishParam.getStoragevehicleCode())
.eq(GroupPlate::getMaterial_code, outFinishParam.getMaterialCode())
.eq(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("入库"));
if (!StringUtils.isEmpty(outFinishParam.getPcsn())){
queryWrapper.eq(GroupPlate::getPcsn, outFinishParam.getPcsn());
}
GroupPlate groupPlate = iMdPbGroupplateService.getOne(queryWrapper);
BigDecimal forceQty = BigDecimal.ZERO;
BigDecimal qty = BigDecimal.ZERO;
if (groupPlate == null){
log.error("当前无组盘入库记录"+outFinishParam.getStoragevehicleCode()+"_"+ outFinishParam.getMaterialCode());
}else {
final BigDecimal force_qty = groupPlate.getFrozen_qty().subtract(outFinishParam.getChangeQty());
qty = groupPlate.getQty();
if (groupPlate.getQty().subtract(outFinishParam.getChangeQty()).intValue() <= 0){
iMdPbGroupplateService.removeById(groupPlate.getGroup_id());
}else {
forceQty = force_qty;
if (force_qty.intValue()< 0 ){
log.error("冻结数量为负"+groupPlate.getStoragevehicle_code()+"_"+ groupPlate.getMaterial_code());
}
if (groupPlate.getQty().subtract(outFinishParam.getChangeQty()).intValue() > 0 ){
groupPlate.setFrozen_qty(BigDecimal.ZERO.max(forceQty));
groupPlate.setQty(groupPlate.getQty().subtract(outFinishParam.getChangeQty()));
groupPlate.setUpdate_id(SecurityUtils.getCurrentUserId());
groupPlate.setUpdate_name(SecurityUtils.getCurrentNickName());
groupPlate.setUpdate_time(DateUtil.now());
iMdPbGroupplateService.updateById(groupPlate);
}else {
iMdPbGroupplateService.removeById(groupPlate.getGroup_id());
}
}
}
StIvtStructivtflow stIvtStructivtflow = new StIvtStructivtflow();
stIvtStructivtflow.setId(IdUtil.getStringId());
stIvtStructivtflow.setUpdate_time(DateUtil.now());
stIvtStructivtflow.setChange_qty(BigDecimal.ZERO);
stIvtStructivtflow.setQty(qty);
stIvtStructivtflow.setChange_qty(outFinishParam.getChangeQty());
stIvtStructivtflow.setFrozen_qty(forceQty);
stIvtStructivtflow.setVehicle_code(outFinishParam.getStoragevehicleCode());
stIvtStructivtflow.setStor_code(outFinishParam.getStorCode());
stIvtStructivtflow.setSect_code(outFinishParam.getSectCode());
stIvtStructivtflow.setStruct_code(outFinishParam.getStructCode());
stIvtStructivtflow.setPcsn(outFinishParam.getPcsn());
stIvtStructivtflow.setGrowth(false);
stIvtStructivtflow.setMaterial_id(outFinishParam.getMaterialCode());
recordsOutFinishForce.add(stIvtStructivtflow);
}
stIvtStructivtflowService.saveBatch(recordsOutFinishForce);
break;
case "OutDisReverseParam":
final List<OutDisReverseParam> outFinishReverseParams = (List<OutDisReverseParam>) params;
for (OutDisReverseParam param : outFinishReverseParams) {

View File

@@ -38,6 +38,7 @@ import org.nl.wms.warehouse_manage.inAndOut.service.dao.mapper.IOStorInvMapper;
import org.nl.wms.warehouse_manage.inventory.IStInventoryService;
import org.nl.wms.warehouse_manage.inventory.core.enums.InventoryChangeType;
import org.nl.wms.warehouse_manage.inventory.core.param.impl.OutFinishParam;
import org.nl.wms.warehouse_manage.inventory.core.param.impl.OutFinishParamForce;
import org.nl.wms.warehouse_manage.service.IMdPbGroupplateService;
import org.nl.wms.warehouse_manage.service.dao.GroupPlate;
import org.nl.wms.warehouse_manage.service.dao.mapper.MdPbGroupplateMapper;
@@ -400,7 +401,7 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
final String now = DateUtil.now();
final List<IOStorInvDtl> ioStorInvDtls = new ArrayList<>();
final List<IOStorInvDis> iOStorInvDiss = new ArrayList<>();
List<OutFinishParam> outFinsParams = new ArrayList<>();
List<OutFinishParamForce> outFinsParams = new ArrayList<>();
for (ReceiveOutReturnDetail detail : details) {
//已经生成单子但是回传EAS报错了
@@ -412,10 +413,7 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
final BigDecimal qty = detail.getQty();
final BigDecimal actualQty = groupInventoryMap.get(materialCode) == null?BigDecimal.ZERO:groupInventoryMap.get(materialCode);
final BigDecimal easQty = stockMap.get(materialCode) == null?BigDecimal.ZERO:stockMap.get(materialCode);
if (qty.compareTo(actualQty) > 0) {
failDetailWMS.add(detail);
continue;
}
if (qty.compareTo(easQty)>0) {
failDetailEAS.add(detail);
continue;
@@ -458,7 +456,7 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
ioStorInvDtls.add(ioStorInvDtl);
iOStorInvDiss.add(ioStorInvDis);
//更新组盘记录表
outFinsParams.add(OutFinishParam.builder()
outFinsParams.add(OutFinishParamForce.builder()
.storagevehicleCode("VTP0008")
.changeQty(qty)
.sectCode(sectattr.getSect_code())
@@ -491,7 +489,7 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
ioStorInvMapper.insert(ioStorInv);
ioStorInvDtlMapper.batchInsert(ioStorInvDtls);
ioStorInvDisMapper.batchSave(iOStorInvDiss);
iStInventoryService.changeInventory(InventoryChangeType.OUT_FINS, outFinsParams);
iStInventoryService.changeInventory(InventoryChangeType.OUT_FINS_FORCE, outFinsParams);
mst.setRequestId(mst.getRequestId()!=null?(mst.getRequestId()+ "," + ioStorInv.getBill_code()):ioStorInv.getBill_code());
}
if (!CollectionUtils.isEmpty(failDetailWMS)){