Procházet zdrojové kódy

查询各种状态的猪

523096025 před 4 roky
rodič
revize
5e1cc922ea

+ 14 - 1
huimv-smart-management/src/main/java/com/huimv/management/controller/YearPigBaseController.java

@@ -183,6 +183,7 @@ public class YearPigBaseController {
         return R.ok().put("data",resultMap);
     }
 
+
     /**
      * 查谱系问题,请求头中需要有ID
      */
@@ -231,4 +232,16 @@ public class YearPigBaseController {
         return R.ok();
     }
 
-}
+     //查询认养,未认养,出栏,育肥
+     @RequestMapping("/statisticsAll")
+     public R statisticsAll(@RequestParam Map<String, Object> params){
+         String formFarmId = (String) params.get("formFarmId");
+         if (formFarmId == null || "".equals(formFarmId) ){
+             return R.error("请选择牧场");
+         }
+         HashMap<String,Integer> resultMap = yearPigBaseService.statisticsAll(params);
+         return R.ok().put("data",resultMap);
+     }
+
+
+ }

+ 2 - 0
huimv-smart-management/src/main/java/com/huimv/management/service/YearPigBaseService.java

@@ -57,5 +57,7 @@ public interface YearPigBaseService extends IService<YearPigBaseEntity> {
     Integer findByFosterStatus(int i, Integer formFarmId);
 
     void suchApp(String[] ids);
+
+    HashMap<String, Integer> statisticsAll(Map<String, Object> params);
 }
 

+ 37 - 0
huimv-smart-management/src/main/java/com/huimv/management/service/impl/YearPigBaseServiceImpl.java

@@ -420,4 +420,41 @@ public class YearPigBaseServiceImpl extends ServiceImpl<YearPigBaseDao, YearPigB
 
         return new PageUtils(page);
     }
+
+    @Override
+    public HashMap<String, Integer> statisticsAll(Map<String, Object> params) {
+        HashMap<String,Integer> resultMap = new HashMap<>();
+        String formFarmId = (String)params.get("formFarmId");
+        LambdaQueryWrapper<YearPigBaseEntity> wrapper = Wrappers.lambdaQuery();
+        wrapper.eq(StringUtils.isNotBlank(formFarmId),YearPigBaseEntity::getFarmId,Integer.parseInt(formFarmId));
+        //出栏
+        wrapper.eq(YearPigBaseEntity::getOutFenceStatus,1);
+        Integer outFence = pigBaseDao.selectCount(wrapper);
+        wrapper.clear();
+        resultMap.put("outFence",outFence);
+        //育肥
+        wrapper.eq(StringUtils.isNotBlank(formFarmId),YearPigBaseEntity::getFarmId,Integer.parseInt(formFarmId));
+        wrapper.eq(YearPigBaseEntity::getOutFenceStatus,0);
+        Integer fence = pigBaseDao.selectCount(wrapper);
+        wrapper.clear();
+        resultMap.put("fence",fence);
+        //认养
+        wrapper.eq(StringUtils.isNotBlank(formFarmId),YearPigBaseEntity::getFarmId,Integer.parseInt(formFarmId));
+        wrapper.eq(YearPigBaseEntity::getFosterStatus,1);
+        Integer foster = pigBaseDao.selectCount(wrapper);
+        wrapper.clear();
+        resultMap.put("foster",foster);
+
+
+        //未认养
+        wrapper.eq(StringUtils.isNotBlank(formFarmId),YearPigBaseEntity::getFarmId,Integer.parseInt(formFarmId));
+        wrapper.eq(YearPigBaseEntity::getFosterStatus,0);
+        Integer noFoster = pigBaseDao.selectCount(wrapper);
+        wrapper.clear();
+        resultMap.put("noFoster",noFoster);
+
+
+
+        return resultMap;
+    }
 }