盘点oms库存同步;

This commit is contained in:
王奎兴
2026-06-01 14:24:25 +08:00
parent 394f392c67
commit 1366f9c461
2 changed files with 172 additions and 0 deletions
@@ -222,6 +222,14 @@ public class ReservationMaterialInventoryImpl extends ServiceImpl<ReservationMat
// 库存冻结
kcdj(netWeight, grossWeight, volume, area, quantity, materialInventoryId);
break;
case "8":
// 盘盈
py(netWeight, grossWeight, volume, area, quantity, materialInventoryId);
break;
case "9":
// 盘亏
pk(netWeight, grossWeight, volume, area, quantity, materialInventoryId);
break;
default:
throw new ServiceException("错误的类型");
}
@@ -412,6 +420,42 @@ public class ReservationMaterialInventoryImpl extends ServiceImpl<ReservationMat
inventoryAdjustmentRecord.setInventoryBeforeQuantity(materialInventory.getInventoryQuantity());
inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventory.getInventoryQuantity());
// 调整前:库存数量(净重、毛重、体积、面积)
inventoryAdjustmentRecord.setNetWeight(materialInventory.getNetWeight());
inventoryAdjustmentRecord.setGrossWeight(materialInventory.getGrossWeight());
inventoryAdjustmentRecord.setVolume(materialInventory.getVolume());
inventoryAdjustmentRecord.setArea(materialInventory.getArea());
// 调整后:库存数量 - 复核时填写的数量
inventoryAdjustmentRecord.setAdjustedNetWeight(materialInventory.getNetWeight());
inventoryAdjustmentRecord.setAdjustedGrossWeight(materialInventory.getGrossWeight());
inventoryAdjustmentRecord.setAdjustedVolume(materialInventory.getVolume());
inventoryAdjustmentRecord.setAdjustedArea(materialInventory.getArea());
} else if ("盘盈入库".equals(adjustAction)) {
inventoryAdjustmentRecord.setAllocationBeforeQuantity(nz(materialInventory.getAllocationQuantity()));
inventoryAdjustmentRecord.setAllocationAfterQuantity(nz(materialInventory.getAllocationQuantity()).add(qty));
inventoryAdjustmentRecord.setFreezeBeforeQuantity(nz(materialInventory.getFreezeQuantity()));
inventoryAdjustmentRecord.setFreezeAfterQuantity(nz(materialInventory.getFreezeQuantity()));//调整后 冻结-出库
inventoryAdjustmentRecord.setInventoryBeforeQuantity(materialInventory.getInventoryQuantity());
inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventory.getInventoryQuantity().add(qty));
// 调整前:库存数量(净重、毛重、体积、面积)
inventoryAdjustmentRecord.setNetWeight(materialInventory.getNetWeight());
inventoryAdjustmentRecord.setGrossWeight(materialInventory.getGrossWeight());
inventoryAdjustmentRecord.setVolume(materialInventory.getVolume());
inventoryAdjustmentRecord.setArea(materialInventory.getArea());
// 调整后:库存数量 - 复核时填写的数量
inventoryAdjustmentRecord.setAdjustedNetWeight(materialInventory.getNetWeight());
inventoryAdjustmentRecord.setAdjustedGrossWeight(materialInventory.getGrossWeight());
inventoryAdjustmentRecord.setAdjustedVolume(materialInventory.getVolume());
inventoryAdjustmentRecord.setAdjustedArea(materialInventory.getArea());
} else if ("盘亏出库".equals(adjustAction)) {
inventoryAdjustmentRecord.setAllocationBeforeQuantity(nz(materialInventory.getAllocationQuantity()));
inventoryAdjustmentRecord.setAllocationAfterQuantity(nz(materialInventory.getAllocationQuantity()).subtract(qty));
inventoryAdjustmentRecord.setFreezeBeforeQuantity(nz(materialInventory.getFreezeQuantity()));
inventoryAdjustmentRecord.setFreezeAfterQuantity(nz(materialInventory.getFreezeQuantity()));//调整后 冻结-出库
inventoryAdjustmentRecord.setInventoryBeforeQuantity(materialInventory.getInventoryQuantity());
inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventory.getInventoryQuantity().subtract(qty));
// 调整前:库存数量(净重、毛重、体积、面积)
inventoryAdjustmentRecord.setNetWeight(materialInventory.getNetWeight());
inventoryAdjustmentRecord.setGrossWeight(materialInventory.getGrossWeight());
@@ -855,4 +899,102 @@ public class ReservationMaterialInventoryImpl extends ServiceImpl<ReservationMat
materialInventoryMapper.updateById(materialInventory);
}
}
private void py(BigDecimal netWeight, BigDecimal grossWeight, BigDecimal volume, BigDecimal area, BigDecimal quantity, Long materialInventoryId) {
ReservationMaterialInventory materialInventoryPO = materialInventoryMapper.selectById(materialInventoryId);
if (materialInventoryPO != null) {
//库存数量
BigDecimal oldInventoryQuantity = materialInventoryPO.getInventoryQuantity();
oldInventoryQuantity = oldInventoryQuantity != null ? oldInventoryQuantity : BigDecimal.ZERO;
//可用数量
BigDecimal oldAllocationQuantity = materialInventoryPO.getAllocationQuantity();
oldAllocationQuantity = oldAllocationQuantity != null ? oldAllocationQuantity : BigDecimal.ZERO;
//冻结数量(出库交接不变动冻结数量)
BigDecimal oldFreezeQuantity = materialInventoryPO.getFreezeQuantity();
oldFreezeQuantity = oldFreezeQuantity != null ? oldFreezeQuantity : BigDecimal.ZERO;
BigDecimal newInventoryQuantity = oldInventoryQuantity.add(quantity);
BigDecimal newAllocationQuantity = oldAllocationQuantity.add(quantity);
// BigDecimal newFreezeQuantity = oldFreezeQuantity.add(quantity);
BigDecimal oldArea = materialInventoryPO.getArea();
BigDecimal oldVolume = materialInventoryPO.getVolume();
BigDecimal oldGrossWeight = materialInventoryPO.getGrossWeight();
BigDecimal oldNetWeight = materialInventoryPO.getNetWeight();
// 初始化旧数据,避免空指针
oldArea = oldArea != null ? oldArea : BigDecimal.ZERO;
oldVolume = oldVolume != null ? oldVolume : BigDecimal.ZERO;
oldGrossWeight = oldGrossWeight != null ? oldGrossWeight : BigDecimal.ZERO;
oldNetWeight = oldNetWeight != null ? oldNetWeight : BigDecimal.ZERO;
BigDecimal newArea = oldArea.subtract(area);
BigDecimal newVolume = oldVolume.subtract(volume);
BigDecimal newGrossWeight = oldGrossWeight.subtract(grossWeight);
BigDecimal newNetWeight = oldNetWeight.subtract(netWeight);
materialInventoryPO.setInventoryQuantity(newInventoryQuantity);
materialInventoryPO.setAllocationQuantity(newAllocationQuantity);
// materialInventoryPO.setFreezeQuantity(newFreezeQuantity);
// materialInventoryPO.setArea(newArea);
// materialInventoryPO.setVolume(newVolume);
// materialInventoryPO.setGrossWeight(newGrossWeight);
// materialInventoryPO.setNetWeight(newNetWeight);
materialInventoryPO.setUpdateTime(new Date());
ReservationMaterialInventory materialInventory = new ReservationMaterialInventory();
com.mhd.common.core.utils.bean.BeanUtils.copyProperties(materialInventoryPO, materialInventory);
materialInventoryMapper.updateById(materialInventory);
}
}
private void pk(BigDecimal netWeight, BigDecimal grossWeight, BigDecimal volume, BigDecimal area, BigDecimal quantity, Long materialInventoryId) {
ReservationMaterialInventory materialInventoryPO = materialInventoryMapper.selectById(materialInventoryId);
if (materialInventoryPO != null) {
//库存数量
BigDecimal oldInventoryQuantity = materialInventoryPO.getInventoryQuantity();
oldInventoryQuantity = oldInventoryQuantity != null ? oldInventoryQuantity : BigDecimal.ZERO;
//可用数量
BigDecimal oldAllocationQuantity = materialInventoryPO.getAllocationQuantity();
oldAllocationQuantity = oldAllocationQuantity != null ? oldAllocationQuantity : BigDecimal.ZERO;
//冻结数量(出库交接不变动冻结数量)
BigDecimal oldFreezeQuantity = materialInventoryPO.getFreezeQuantity();
oldFreezeQuantity = oldFreezeQuantity != null ? oldFreezeQuantity : BigDecimal.ZERO;
//扣减后库存数量
BigDecimal newInventoryQuantity = oldInventoryQuantity.subtract(quantity);
//扣减后可用数量
BigDecimal newAllocationQuantity = oldAllocationQuantity.subtract(quantity);
// BigDecimal newFreezeQuantity = oldFreezeQuantity.subtract(quantity);
BigDecimal oldArea = materialInventoryPO.getArea();
BigDecimal oldVolume = materialInventoryPO.getVolume();
BigDecimal oldGrossWeight = materialInventoryPO.getGrossWeight();
BigDecimal oldNetWeight = materialInventoryPO.getNetWeight();
// 初始化旧数据,避免空指针
oldArea = oldArea != null ? oldArea : BigDecimal.ZERO;
oldVolume = oldVolume != null ? oldVolume : BigDecimal.ZERO;
oldGrossWeight = oldGrossWeight != null ? oldGrossWeight : BigDecimal.ZERO;
oldNetWeight = oldNetWeight != null ? oldNetWeight : BigDecimal.ZERO;
BigDecimal newArea = oldArea.subtract(area);
BigDecimal newVolume = oldVolume.subtract(volume);
BigDecimal newGrossWeight = oldGrossWeight.subtract(grossWeight);
BigDecimal newNetWeight = oldNetWeight.subtract(netWeight);
materialInventoryPO.setInventoryQuantity(newInventoryQuantity);
materialInventoryPO.setAllocationQuantity(newAllocationQuantity);
// materialInventoryPO.setFreezeQuantity(newFreezeQuantity);
// materialInventoryPO.setArea(newArea);
// materialInventoryPO.setVolume(newVolume);
// materialInventoryPO.setGrossWeight(newGrossWeight);
// materialInventoryPO.setNetWeight(newNetWeight);
materialInventoryPO.setUpdateTime(new Date());
ReservationMaterialInventory materialInventory = new ReservationMaterialInventory();
com.mhd.common.core.utils.bean.BeanUtils.copyProperties(materialInventoryPO, materialInventory);
materialInventoryMapper.updateById(materialInventory);
}
}
}
@@ -442,6 +442,36 @@ public class DifferentManageImpl extends ServiceImpl<DifferentManageMapper, Diff
inventoryAdjustmentRecord.setInventoryBeforeQuantity(investigetionManageDetailDO.getInventoryQuantity());
inventoryAdjustmentRecord.setInventoryAfterQuantity(investigetionManageDetailDO.getInvestigationQuantity());
inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord);
if (investigetionManageDetailDO.getInvestigationResult() == 1){
//同步oms
MaterialInventoryOmsParamDO materialInventoryOmsParamDO = new MaterialInventoryOmsParamDO();
materialInventoryOmsParamDO.setLotNumber(materialInventory1.getLotNumber());
materialInventoryOmsParamDO.setWarehouseId(materialInventory1.getWarehouseId());
materialInventoryOmsParamDO.setMaterialBaseInfoId(materialInventory1.getMaterialBaseInfoId());
materialInventoryOmsParamDO.setBatchNumber(materialInventory1.getBatchNumber());
materialInventoryOmsParamDO.setInOrderNumber(materialInventory1.getInOrderNumber());
materialInventoryOmsParamDO.setType("8");
materialInventoryOmsParamDO.setKctzType("盘盈入库");
materialInventoryOmsParamDO.setQuantity(investigetionManageDetailDO.getDifferentQuantity());
omsServiceFeign.omsEdit(materialInventoryOmsParamDO);
} else if (investigetionManageDetailDO.getInvestigationResult() == 2) {
//同步oms
MaterialInventoryOmsParamDO materialInventoryOmsParamDO = new MaterialInventoryOmsParamDO();
materialInventoryOmsParamDO.setLotNumber(materialInventory1.getLotNumber());
materialInventoryOmsParamDO.setWarehouseId(materialInventory1.getWarehouseId());
materialInventoryOmsParamDO.setMaterialBaseInfoId(materialInventory1.getMaterialBaseInfoId());
materialInventoryOmsParamDO.setBatchNumber(materialInventory1.getBatchNumber());
materialInventoryOmsParamDO.setInOrderNumber(materialInventory1.getInOrderNumber());
materialInventoryOmsParamDO.setType("9");
materialInventoryOmsParamDO.setKctzType("盘亏出库");
materialInventoryOmsParamDO.setQuantity(investigetionManageDetailDO.getDifferentQuantity());
omsServiceFeign.omsEdit(materialInventoryOmsParamDO);
}
}
@Override