소스 검색

解决空指针bug问题

oyq28 2 년 전
부모
커밋
48c3a7b131
1개의 변경된 파일10개의 추가작업 그리고 9개의 파일을 삭제
  1. 10 9
      imcs-bt-be/imcs-authority-server/src/main/java/com/github/zuihou/api/OpsAppApi.java

+ 10 - 9
imcs-bt-be/imcs-authority-server/src/main/java/com/github/zuihou/api/OpsAppApi.java

@@ -315,16 +315,17 @@ public class OpsAppApi {
 
         //        根据设备id查询商品
         List<EquGoodsDto> equGoods = productionTenantResourceService.getEquGoods(equRecord.getEquId());
-//        根据设备查询料筒信息
-        QueryWrap<EquBarrel> barrelQueryWrap = new QueryWrap<>();
-        barrelQueryWrap.eq("equ_id", equRecord.getEquId());
-        List<EquBarrel> barrelList = equBarrelService.list(barrelQueryWrap);
+        QueryWrap<EquBarrel> equBarrelQueryWrap = new QueryWrap<>();
+        equBarrelQueryWrap.eq("equ_id", equRecord.getEquId());
+
+        Page<EquBarrel> page = new Page<>(1L, 20);
+        IPage<EquBarrel> equBarrelIPage = equBarrelService.pageList(page, equBarrelQueryWrap);
+        List<EquBarrel> barrelList = equBarrelIPage.getRecords();
         List<Long> mtList = new ArrayList<>();
-        if (null != barrelList) {
+        if (null != barrelList && barrelList.size()>0) {
             mtList = barrelList.stream().map(EquBarrel::getMtrId).collect(toList());
         }
 
-
 //        遍历商品,查询配方列表
         if (equGoods != null && equGoods.size() > 0) {
             List<Long> finalMtList = mtList;
@@ -350,13 +351,13 @@ public class OpsAppApi {
                                 barrelList.forEach(equBarrel -> {
                                     if (formula.getFormulaMtId().equals(equBarrel.getMtrId())) {
                                         System.out.println("小程序换料接口-->配方中的原料" + formula.getFormulaMtId() + "和料筒中的原料" + equBarrel.getMtrId() + "相同");
-                                        UpdateWrapper<EquAndGoods> equGoodsDtoUpdateWrapper = new UpdateWrapper<>();
+                                        LambdaUpdateWrapper<EquAndGoods> equGoodsDtoUpdateWrapper = new LambdaUpdateWrapper<EquAndGoods>();
 
                                         if (equBarrel.getMtrResidue().compareTo(equBarrel.getResidueWarn()) == 1) {
-                                            equGoodsDtoUpdateWrapper.set("is_starving", "1").eq("goods_id", equGoodsDto.getGoodsId()).eq("equ_id", equRecord.getEquId());
+                                            equGoodsDtoUpdateWrapper.set(EquAndGoods::getIsStarving, "1").eq(EquAndGoods::getGoodsId, equGoodsDto.getGoodsId()).eq(EquAndGoods::getEquId, equRecord.getEquId());
                                             equGoodsDto.setIsStarving("1");
                                         } else {
-                                            equGoodsDtoUpdateWrapper.set("is_starving", "0");
+                                            equGoodsDtoUpdateWrapper.set(EquAndGoods::getIsStarving, "0");
                                             equGoodsDto.setIsStarving("0");
                                         }
                                         equAndGoodsService.update(equGoodsDtoUpdateWrapper);