浏览代码

备件出库判断库存

lyhzzz 2 年之前
父节点
当前提交
5235626fc7

+ 1 - 0
src/main/java/com/fdkankan/sale/common/ResultCode.java

@@ -37,6 +37,7 @@ public enum ResultCode  {
     PRICE_TYPE_NOT(60015, "报价类型为空"),
     PART_ID_EMPTY(60016, "备件id为空"),
     LABOR_ID_EMPTY(60017, "人工id为空"),
+    PART_STOCK_ERROR(60018, "备件库存不足"),
 
 
 

+ 7 - 0
src/main/java/com/fdkankan/sale/service/impl/PartServiceImpl.java

@@ -82,6 +82,13 @@ public class PartServiceImpl extends ServiceImpl<IPartMapper, Part> implements I
 
     @Override
     public void outStock(Integer partId, Integer count,Long userId,String repairId) {
+        Part part = this.getById(partId);
+        if(part == null){
+            throw new BusinessException(ResultCode.PART_NOT_EXITS);
+        }
+        if(part.getPartStock() - count == 0){
+            throw new BusinessException(ResultCode.PART_STOCK_ERROR.code(),part.getPartName()+"_"+ResultCode.PART_STOCK_ERROR.message());
+        }
         LambdaUpdateWrapper<Part> wrapper = new LambdaUpdateWrapper<>();
         wrapper.eq(Part::getPartId,partId);
         wrapper.setSql("part_stock = part_stock -" + count);

+ 3 - 0
src/main/java/com/fdkankan/sale/service/impl/RepairPersonnelService.java

@@ -183,6 +183,9 @@ public class RepairPersonnelService {
         if(repair == null){
             throw new BusinessException(ResultCode.REPAIR_NOT_EXITS);
         }
+        if(repair.getStatus() !=7){ //回收完成
+            throw new BusinessException(ResultCode.REPAIR_STATUS_NOT_EXITS);
+        }
         repairRegisterService.repairOver(repair.getRepairId(),param.getRemark());
         repairLogService.saveBySysUser(userId,repair.getRepairId(),8,"维修完成");