|
@@ -67,10 +67,15 @@ public class ListenerMaterialApply implements TaskListener, ExecutionListener {
|
|
|
queryWrapper.eq("material_name",materialName);
|
|
|
queryWrapper.eq("unit",unit);
|
|
|
Material material = materialMapper.selectOne(queryWrapper);
|
|
|
- if(material!=null){
|
|
|
- material.setQuantity(material.getQuantity().subtract(amount));
|
|
|
- materialMapper.updateById(material);
|
|
|
+ if(material==null){
|
|
|
+ throw new Exception("物料名称为"+materialName+"规格型号为"+unit+"的物料不存在");
|
|
|
}
|
|
|
+ BigDecimal quantity = material.getQuantity();
|
|
|
+ if(quantity.compareTo(amount)==-1){
|
|
|
+ throw new Exception("物料名称为"+materialName+"规格型号为"+unit+"的库存数量小于申请数量!");
|
|
|
+ }
|
|
|
+ material.setQuantity(material.getQuantity().subtract(amount));
|
|
|
+ materialMapper.updateById(material);
|
|
|
}
|
|
|
}
|
|
|
} else if ("take".equals(eventName)) {
|