فهرست منبع

物料申请监听 库存数量减少

xieyn 1 سال پیش
والد
کامیت
7dad233478

+ 8 - 3
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/activiti/listener/ListenerMaterialApply.java

@@ -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)) {