소스 검색

入库仓库报错

hfxc226 1 년 전
부모
커밋
5dbd4c7fa4
1개의 변경된 파일9개의 추가작업 그리고 3개의 파일을 삭제
  1. 9 3
      platform-service/src/main/java/com/platform/service/store/impl/InStoreFormServiceImpl.java

+ 9 - 3
platform-service/src/main/java/com/platform/service/store/impl/InStoreFormServiceImpl.java

@@ -411,9 +411,15 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
         SpareStore spareStore = new SpareStore();
         spareStore.setSpareId(model.getSpareId());
         spareStore = spareStoreMapper.selectOne(spareStore);
+        if(spareStore==null){
+            throw new BusinessException("该备件暂未选择库位,请前往备件基础信息修改!");
+        }
+
+        BigDecimal num = spareStore.getNum()==null?new BigDecimal(0):spareStore.getNum();
+        BigDecimal maxStock = sparePartInfo.getMaxStock()==null?new BigDecimal(0):sparePartInfo.getMaxStock();
 
-        if (spareStore.getNum().intValue()+model.getInNum()>sparePartInfo.getMaxStock().intValue()){
-            throw new BusinessException("该备件的最大库存量为"+sparePartInfo.getMaxStock()+"目前已超出,请修改入库数量!");
+        if (num.intValue()+model.getInNum()>maxStock.intValue()){
+            throw new BusinessException("该备件的最大库存量为"+maxStock+"目前已超出,请修改入库数量!");
         }
         UserInfo userInfo = SecurityUtils.getUserInfo();
         Weekend<InStoreForm> weekend = new Weekend<>(InStoreForm.class);
@@ -425,7 +431,7 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
         model.setStatus(InStoreStatusEnum.EXECUTING.getValue());
         InStoreForm inStoreForm = super.saveModelByDTO(model);
         //修改库存
-        spareStore.setNum(new BigDecimal(spareStore.getNum().intValue()+model.getInNum()));
+        spareStore.setNum(new BigDecimal(num.intValue()+model.getInNum()));
         spareStoreMapper.updateByPrimaryKeySelective(spareStore);
     }