Merge branch 'master' of https://gitee.com/hdka/FURNITURE-OA
This commit is contained in:
@@ -154,13 +154,13 @@ public class MatMaterialOutServiceImpl implements IMatMaterialOutService {
|
|||||||
private void reduceInventory(Long materialId, BigDecimal quantity) {
|
private void reduceInventory(Long materialId, BigDecimal quantity) {
|
||||||
MatMaterialVo material = matMaterialService.queryById(materialId);
|
MatMaterialVo material = matMaterialService.queryById(materialId);
|
||||||
if (material != null) {
|
if (material != null) {
|
||||||
|
// 验证要扣减的数量不能大于当前库存
|
||||||
|
if (quantity.compareTo(material.getCurrentStock()) > 0) {
|
||||||
|
throw new IllegalArgumentException("要扣减的数量不能大于当前库存数量,物料ID:" + materialId + ",当前库存:" + material.getCurrentStock() + ",请求扣减:" + quantity);
|
||||||
|
}
|
||||||
|
|
||||||
MatMaterialBo materialBo = new MatMaterialBo();
|
MatMaterialBo materialBo = new MatMaterialBo();
|
||||||
materialBo.setMaterialId(materialId);
|
materialBo.setMaterialId(materialId);
|
||||||
materialBo.setMaterialName(material.getMaterialName());
|
|
||||||
materialBo.setSpec(material.getSpec());
|
|
||||||
materialBo.setModel(material.getModel());
|
|
||||||
materialBo.setFactory(material.getFactory());
|
|
||||||
materialBo.setUnit(material.getUnit());
|
|
||||||
|
|
||||||
// 计算扣减后的库存数量
|
// 计算扣减后的库存数量
|
||||||
BigDecimal newStock = material.getCurrentStock().subtract(quantity);
|
BigDecimal newStock = material.getCurrentStock().subtract(quantity);
|
||||||
@@ -169,11 +169,11 @@ public class MatMaterialOutServiceImpl implements IMatMaterialOutService {
|
|||||||
}
|
}
|
||||||
materialBo.setCurrentStock(newStock);
|
materialBo.setCurrentStock(newStock);
|
||||||
|
|
||||||
materialBo.setRemark(material.getRemark());
|
|
||||||
matMaterialService.updateByBo(materialBo);
|
matMaterialService.updateByBo(materialBo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 恢复库存数量(增加库存)
|
* 恢复库存数量(增加库存)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -275,13 +275,14 @@ public class MatPurchaseInDetailServiceImpl implements IMatPurchaseInDetailServi
|
|||||||
private void revertInventory(Long materialId, BigDecimal quantity) {
|
private void revertInventory(Long materialId, BigDecimal quantity) {
|
||||||
MatMaterialVo material = matMaterialService.queryById(materialId);
|
MatMaterialVo material = matMaterialService.queryById(materialId);
|
||||||
if (material != null) {
|
if (material != null) {
|
||||||
|
// 验证要减少的数量不能大于当前库存
|
||||||
|
if (quantity.compareTo(material.getCurrentStock()) > 0) {
|
||||||
|
throw new IllegalArgumentException("要减少的数量不能大于当前库存数量,物料ID:" + materialId + ",当前库存:" + material.getCurrentStock() + ",请求减少:" + quantity);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MatMaterialBo materialBo = new MatMaterialBo();
|
MatMaterialBo materialBo = new MatMaterialBo();
|
||||||
materialBo.setMaterialId(materialId);
|
materialBo.setMaterialId(materialId);
|
||||||
materialBo.setMaterialName(material.getMaterialName());
|
|
||||||
materialBo.setSpec(material.getSpec());
|
|
||||||
materialBo.setModel(material.getModel());
|
|
||||||
materialBo.setFactory(material.getFactory());
|
|
||||||
materialBo.setUnit(material.getUnit());
|
|
||||||
|
|
||||||
// 计算还原后的库存数量(减去本次入库的数量)
|
// 计算还原后的库存数量(减去本次入库的数量)
|
||||||
BigDecimal newStock = material.getCurrentStock().subtract(quantity);
|
BigDecimal newStock = material.getCurrentStock().subtract(quantity);
|
||||||
@@ -290,7 +291,6 @@ public class MatPurchaseInDetailServiceImpl implements IMatPurchaseInDetailServi
|
|||||||
}
|
}
|
||||||
materialBo.setCurrentStock(newStock);
|
materialBo.setCurrentStock(newStock);
|
||||||
|
|
||||||
materialBo.setRemark(material.getRemark());
|
|
||||||
matMaterialService.updateByBo(materialBo);
|
matMaterialService.updateByBo(materialBo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user