|
@@ -1,11 +1,22 @@
|
|
|
package com.huimv.eartag.controller;
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.huimv.common.utils.Result;
|
|
|
+import com.huimv.common.utils.ResultCode;
|
|
|
+import com.huimv.eartag.entity.BaseFarmInfo;
|
|
|
+import com.huimv.eartag.entity.EartagData;
|
|
|
+import com.huimv.eartag.entity.EartagRegisterEntity;
|
|
|
+import com.huimv.eartag.entity.vo.PigCountInfo;
|
|
|
+import com.huimv.eartag.mapper.BaseFarmInfoMapper;
|
|
|
+import com.huimv.eartag.mapper.EartagRegisterMapper;
|
|
|
import com.huimv.eartag.service.IEartagDataService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
@@ -22,6 +33,104 @@ public class EartagDataController {
|
|
|
@Autowired
|
|
|
private IEartagDataService eartagDataService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private BaseFarmInfoMapper baseFarmInfoMapper ;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private EartagRegisterMapper eartagRegisterMapper ;
|
|
|
+
|
|
|
+
|
|
|
+ //展示不同公司的猪的数量
|
|
|
+
|
|
|
+ @PostMapping("/getPigCount")
|
|
|
+ public Result getPigCount(@RequestBody Map<String,Object> params ){
|
|
|
+ //传了就是牧场。不传就是管理员
|
|
|
+
|
|
|
+ //searchType=1 养殖 2.检疫 3.屠宰
|
|
|
+ Integer searchType = (Integer)params.get("searchType");
|
|
|
+
|
|
|
+ List<PigCountInfo> pigCount = new ArrayList<>();
|
|
|
+
|
|
|
+ //管理员
|
|
|
+ List<BaseFarmInfo> baseFarmInfos = baseFarmInfoMapper.selectList(null);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ for (BaseFarmInfo baseFarmInfo : baseFarmInfos) {
|
|
|
+ //屠宰的
|
|
|
+ if(baseFarmInfo.getType()==1) {
|
|
|
+ QueryWrapper<EartagRegisterEntity> queryWrapper = new QueryWrapper<>();
|
|
|
+ //第一次上传是谁的基站就是谁的耳标
|
|
|
+ queryWrapper.eq("butcher_id", baseFarmInfo.getId());
|
|
|
+ List<EartagRegisterEntity> eartagRegisterEntities = eartagRegisterMapper.selectList(queryWrapper);
|
|
|
+
|
|
|
+ PigCountInfo pigCountInfo = new PigCountInfo();
|
|
|
+ pigCountInfo.setCount(eartagRegisterEntities.size());
|
|
|
+ pigCountInfo.setFarmId(baseFarmInfo.getId());
|
|
|
+ pigCountInfo.setFarmName(baseFarmInfo.getFarmName());
|
|
|
+ pigCountInfo.setType(baseFarmInfo.getType());
|
|
|
+ pigCount.add(pigCountInfo);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //养殖
|
|
|
+ if(baseFarmInfo.getType()==2) {
|
|
|
+ QueryWrapper<EartagRegisterEntity> queryWrapper = new QueryWrapper<>();
|
|
|
+ //第一次上传是谁的基站就是谁的耳标
|
|
|
+ queryWrapper.eq("farm_code", baseFarmInfo.getId());
|
|
|
+ List<EartagRegisterEntity> eartagRegisterEntities = eartagRegisterMapper.selectList(queryWrapper);
|
|
|
+ PigCountInfo pigCountInfo = new PigCountInfo();
|
|
|
+ pigCountInfo.setCount(eartagRegisterEntities.size());
|
|
|
+ pigCountInfo.setFarmId(baseFarmInfo.getId());
|
|
|
+ pigCountInfo.setFarmName(baseFarmInfo.getFarmName());
|
|
|
+ pigCountInfo.setType(baseFarmInfo.getType());
|
|
|
+ pigCount.add(pigCountInfo);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //检疫
|
|
|
+ if(baseFarmInfo.getType()==3) {
|
|
|
+ QueryWrapper<EartagRegisterEntity> queryWrapper = new QueryWrapper<>();
|
|
|
+ //第一次上传是谁的基站就是谁的耳标
|
|
|
+ queryWrapper.eq("inspec_id", baseFarmInfo.getId());
|
|
|
+ List<EartagRegisterEntity> eartagRegisterEntities = eartagRegisterMapper.selectList(queryWrapper);
|
|
|
+ PigCountInfo pigCountInfo = new PigCountInfo();
|
|
|
+ pigCountInfo.setCount(eartagRegisterEntities.size());
|
|
|
+ pigCountInfo.setFarmId(baseFarmInfo.getId());
|
|
|
+ pigCountInfo.setFarmName(baseFarmInfo.getFarmName());
|
|
|
+ pigCountInfo.setType(baseFarmInfo.getType());
|
|
|
+ pigCount.add(pigCountInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ List<PigCountInfo> resultInfo = new ArrayList<>();
|
|
|
+
|
|
|
+ for (PigCountInfo pigCountInfo : pigCount) {
|
|
|
+ if(pigCountInfo.getType()==searchType){
|
|
|
+ resultInfo.add(pigCountInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return new Result(ResultCode.SUCCESS, resultInfo);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
@PostMapping("/getTemp")
|
|
|
public Result getTemp(@RequestBody Map<String,String> map){
|
|
|
return eartagDataService.getTemp(map);
|
|
@@ -36,4 +145,5 @@ public class EartagDataController {
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
}
|