|
@@ -1,7 +1,11 @@
|
|
|
package com.huimv.admin.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.http.Header;
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
@@ -18,11 +22,11 @@ import com.huimv.admin.mapper.BreedVaccinationRecordMapper;
|
|
|
import com.huimv.admin.mapper.ProtSheepInfoMapper;
|
|
|
import com.huimv.admin.service.IProtSheepInfoService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import net.sf.json.JSONArray;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.text.DecimalFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -89,15 +93,10 @@ public class ProtSheepInfoServiceImpl extends ServiceImpl<ProtSheepInfoMapper, P
|
|
|
day4++;
|
|
|
}
|
|
|
}
|
|
|
- double a1 = (double) day1 / protSheepInfos.size() * 100;
|
|
|
- double a2 = (double) day2 / protSheepInfos.size() * 100;
|
|
|
- double a3 = (double) day3 / protSheepInfos.size() * 100;
|
|
|
- double a4 = (double) day4 / protSheepInfos.size() * 100;
|
|
|
- DecimalFormat def = new DecimalFormat("0.00");
|
|
|
- jsonObject.put("day1", def.format(a1));
|
|
|
- jsonObject.put("day2", def.format(a2));
|
|
|
- jsonObject.put("day3", def.format(a3));
|
|
|
- jsonObject.put("day4", def.format(a4));
|
|
|
+ jsonObject.put("day1", day1);
|
|
|
+ jsonObject.put("day2", day2);
|
|
|
+ jsonObject.put("day3", day3);
|
|
|
+ jsonObject.put("day4", day4);
|
|
|
} else {
|
|
|
jsonObject.put("day1", "0");
|
|
|
jsonObject.put("day2", "0");
|
|
@@ -108,8 +107,13 @@ public class ProtSheepInfoServiceImpl extends ServiceImpl<ProtSheepInfoMapper, P
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public Result stockDetail(Map<String, String> paramsMap) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public Result stockCount(Map<String, String> paramsMap) {
|
|
|
- String farmId = paramsMap.get("farm_id");
|
|
|
+ String farmId = paramsMap.get("farmId");
|
|
|
List<ProtSheepInfo> protSheepInfos = sheepInfoMapper.selectList(new QueryWrapper<ProtSheepInfo>().eq("farm_id", farmId));
|
|
|
Integer count = 0;
|
|
|
Integer femaleCount = 0;
|
|
@@ -120,18 +124,18 @@ public class ProtSheepInfoServiceImpl extends ServiceImpl<ProtSheepInfoMapper, P
|
|
|
if (protSheepInfos.size() != 0) {
|
|
|
for (ProtSheepInfo protSheepInfo : protSheepInfos) {
|
|
|
if (protSheepInfo.getIsLeave() == 1) {
|
|
|
- isLeaveCount++;
|
|
|
+ isLeaveCount = isLeaveCount + 1;
|
|
|
} else {
|
|
|
if (protSheepInfo.getSheepType() == 0) {
|
|
|
- goodsCount++;
|
|
|
+ goodsCount = goodsCount + 1;
|
|
|
} else if (protSheepInfo.getSheepType() == 1) {
|
|
|
if (protSheepInfo.getSex() == 0) {
|
|
|
- femaleCount++;
|
|
|
+ femaleCount = femaleCount + 1;
|
|
|
} else {
|
|
|
- maleCount++;
|
|
|
+ maleCount = maleCount + 1;
|
|
|
}
|
|
|
}
|
|
|
- count++;
|
|
|
+ count = count + 1;
|
|
|
}
|
|
|
}
|
|
|
jsonObject.put("count", count);
|
|
@@ -165,24 +169,33 @@ public class ProtSheepInfoServiceImpl extends ServiceImpl<ProtSheepInfoMapper, P
|
|
|
screenVo.setUnitName(sheepInfo.getUnitName());
|
|
|
screenVo.setSheepDay(sheepInfo.getSheepDay());
|
|
|
|
|
|
- HashMap<String, Object> paramMap = new HashMap<>();
|
|
|
- paramMap.put("farmId", farmId);
|
|
|
- paramMap.put("earmark", sheepId);
|
|
|
- paramMap.put("status", "");
|
|
|
- paramMap.put("pageNo", 1);
|
|
|
- paramMap.put("pageSize", 20);
|
|
|
- String result= HttpUtil.post("http://119.3.44.183:8016/manage2/eartagRegister/listUserEartagData", paramMap);
|
|
|
- cn.hutool.json.JSONObject jsonObject = new cn.hutool.json.JSONObject(result);
|
|
|
- net.sf.json.JSONObject data = (net.sf.json.JSONObject) jsonObject.get("data");
|
|
|
- JSONArray records = data.getJSONArray("records");
|
|
|
- JSONObject record = (JSONObject) records.get(0);
|
|
|
- screenVo.setAct(record.get("actRange").toString());
|
|
|
-
|
|
|
- Integer count=0;
|
|
|
+ JSONObject jsonObject2 = new JSONObject();
|
|
|
+ jsonObject2.put("farmId", "330110007");
|
|
|
+ jsonObject2.put("earmark", "1010003");
|
|
|
+ jsonObject2.put("pageNo", 1);
|
|
|
+ jsonObject2.put("pageSize", 20);
|
|
|
+ jsonObject2 .put("status", "");
|
|
|
+
|
|
|
+ String result = HttpRequest.post("https://eartag.alafarms.com/api/manage2/eartagRegister/listUserEartagData").header(Header.CONTENT_TYPE, "application/json")
|
|
|
+ .body(jsonObject2.toJSONString())
|
|
|
+ .timeout(30 * 1000).execute().body();
|
|
|
+ System.out.println(result);
|
|
|
+ JSONObject jsonObject = JSON.parseObject(result);
|
|
|
+ JSONObject data = (JSONObject) jsonObject.get("data");
|
|
|
+ com.alibaba.fastjson.JSONArray records = data.getJSONArray("records");
|
|
|
+ if (records.size() != 0) {
|
|
|
+ JSONObject record = (JSONObject) records.get(0);
|
|
|
+ screenVo.setAct(record.get("actRange").toString());
|
|
|
+ } else {
|
|
|
+ screenVo.setAct("0");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Integer count = 0;
|
|
|
if (sheepInfo.getIsBatch() == 0) {
|
|
|
- count = recordMapper.selectCount(new QueryWrapper<BreedVaccinationRecord>().eq("farm_id", farmId).eq("sheep_id", sheepInfo.getSheepId()));
|
|
|
+ count = recordMapper.selectCount(new QueryWrapper<BreedVaccinationRecord>().eq("farm_id", farmId).eq("sheep_id", sheepInfo.getSheepId()));
|
|
|
} else {
|
|
|
- count = recordMapper.selectCount(new QueryWrapper<BreedVaccinationRecord>().eq("farm_id", farmId).eq("batch_num", sheepInfo.getBatchNum()));
|
|
|
+ count = recordMapper.selectCount(new QueryWrapper<BreedVaccinationRecord>().eq("farm_id", farmId).eq("batch_num", sheepInfo.getBatchNum()));
|
|
|
}
|
|
|
if (count == 0) {
|
|
|
screenVo.setVaccinationResult("未接种");
|
|
@@ -205,23 +218,34 @@ public class ProtSheepInfoServiceImpl extends ServiceImpl<ProtSheepInfoMapper, P
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
if (sheepInfos.size() != 0) {
|
|
|
for (ProtSheepInfo sheepInfo : sheepInfos) {
|
|
|
- HashMap<String, Object> paramMap = new HashMap<>();
|
|
|
+ JSONObject paramMap = new JSONObject();
|
|
|
paramMap.put("farmId", farmId);
|
|
|
paramMap.put("earmark", sheepInfo.getSheepId());
|
|
|
paramMap.put("status", "");
|
|
|
paramMap.put("pageNo", 1);
|
|
|
paramMap.put("pageSize", 20);
|
|
|
- String result= HttpUtil.post("http://119.3.44.183:8016/manage2/eartagRegister/listUserEartagData", paramMap);
|
|
|
- cn.hutool.json.JSONObject jsonObject = new cn.hutool.json.JSONObject(result);
|
|
|
- net.sf.json.JSONObject data = (net.sf.json.JSONObject) jsonObject.get("data");
|
|
|
- JSONArray records = data.getJSONArray("records");
|
|
|
- JSONObject record = (JSONObject) records.get(0);
|
|
|
+ String result = HttpRequest.post("https://eartag.alafarms.com/api/manage2/eartagRegister/listUserEartagData").header(Header.CONTENT_TYPE, "application/json")
|
|
|
+ .body(paramMap.toJSONString())
|
|
|
+ .timeout(30 * 1000).execute().body();
|
|
|
+ JSONObject jsonObject = JSON.parseObject(result);
|
|
|
+ JSONObject data = (JSONObject) jsonObject.get("data");
|
|
|
+ com.alibaba.fastjson.JSONArray records = data.getJSONArray("records");
|
|
|
+
|
|
|
|
|
|
JSONObject object = new JSONObject();
|
|
|
+ object.put("sex", sheepInfo.getSex());
|
|
|
+ object.put("sheepVariety", sheepInfo.getSheepVariety());
|
|
|
+ object.put("unitName", sheepInfo.getUnitName());
|
|
|
object.put("sheepId", sheepInfo.getSheepId());
|
|
|
object.put("day", sheepInfo.getSheepDay());
|
|
|
- object.put("hum", record.get("earTemp1"));
|
|
|
- object.put("act", record.get("actRange"));
|
|
|
+ if (records.size() != 0) {
|
|
|
+ JSONObject record = (JSONObject) records.get(0);
|
|
|
+ object.put("hum", record.get("earTemp1"));
|
|
|
+ object.put("act", record.get("actRange"));
|
|
|
+ } else {
|
|
|
+ object.put("hum", 0);
|
|
|
+ object.put("act", 0);
|
|
|
+ }
|
|
|
jsonArray.add(object);
|
|
|
}
|
|
|
}
|
|
@@ -246,27 +270,33 @@ public class ProtSheepInfoServiceImpl extends ServiceImpl<ProtSheepInfoMapper, P
|
|
|
if (sheepInfos.size() != 0) {
|
|
|
for (ProtSheepInfo sheepInfo : sheepInfos) {
|
|
|
if (StringUtils.isNotBlank(sheepInfo.getSheepId())) {
|
|
|
- earmarkCount++;
|
|
|
- HashMap<String, Object> paramMap = new HashMap<>();
|
|
|
+
|
|
|
+ JSONObject paramMap = new JSONObject();
|
|
|
paramMap.put("farmId", farmId);
|
|
|
paramMap.put("earmark", sheepInfo.getSheepId());
|
|
|
paramMap.put("status", "");
|
|
|
paramMap.put("pageNo", 1);
|
|
|
paramMap.put("pageSize", 20);
|
|
|
- String result= HttpUtil.post("http://119.3.44.183:8016/manage2/eartagRegister/listUserEartagData", paramMap);
|
|
|
- cn.hutool.json.JSONObject jsonObject = new cn.hutool.json.JSONObject(result);
|
|
|
- net.sf.json.JSONObject data = (net.sf.json.JSONObject) jsonObject.get("data");
|
|
|
- JSONArray records = data.getJSONArray("records");
|
|
|
- JSONObject record = (JSONObject) records.get(0);
|
|
|
- if (Double.valueOf(record.get("earTemp1").toString()) > 37.5) {
|
|
|
- errorCount++;
|
|
|
+ String result = HttpRequest.post("https://eartag.alafarms.com/api/manage2/eartagRegister/listUserEartagData").header(Header.CONTENT_TYPE, "application/json")
|
|
|
+ .body(paramMap.toJSONString())
|
|
|
+ .timeout(30 * 1000).execute().body();
|
|
|
+
|
|
|
+ JSONObject jsonObject = JSON.parseObject(result);
|
|
|
+ JSONObject data = (JSONObject) jsonObject.get("data");
|
|
|
+ com.alibaba.fastjson.JSONArray records = data.getJSONArray("records");
|
|
|
+ if (records.size() != 0) {
|
|
|
+ JSONObject record = (JSONObject) records.get(0);
|
|
|
+ if (Double.valueOf(record.get("earTemp1").toString()) > 37.5) {
|
|
|
+ errorCount++;
|
|
|
+ }
|
|
|
+ earmarkCount++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("count", sheepInfos.size());
|
|
|
- jsonObject.put("buildCount",buildCount);
|
|
|
+ jsonObject.put("buildCount", buildCount);
|
|
|
jsonObject.put("earmarkCount", earmarkCount);
|
|
|
jsonObject.put("errorCount", errorCount);
|
|
|
return new Result(ResultCode.SUCCESS, jsonObject);
|
|
@@ -279,73 +309,101 @@ public class ProtSheepInfoServiceImpl extends ServiceImpl<ProtSheepInfoMapper, P
|
|
|
Integer errorCount = 0;
|
|
|
Integer earmarkCount = 0;
|
|
|
double temp = 0.00;
|
|
|
- double act = 0.00;
|
|
|
+ Integer act = 0;
|
|
|
JSONObject object = new JSONObject();
|
|
|
DecimalFormat def = new DecimalFormat("0.00");
|
|
|
List<ProtSheepInfo> sheepInfos = sheepInfoMapper.selectList(new QueryWrapper<ProtSheepInfo>().eq("farm_id", farmId).eq("is_leave", 0));
|
|
|
if (sheepInfos.size() != 0) {
|
|
|
for (ProtSheepInfo sheepInfo : sheepInfos) {
|
|
|
if (StringUtils.isNotBlank(sheepInfo.getSheepId())) {
|
|
|
- HashMap<String, Object> paramMap = new HashMap<>();
|
|
|
+ JSONObject paramMap = new JSONObject();
|
|
|
paramMap.put("farmId", farmId);
|
|
|
paramMap.put("earmark", sheepInfo.getSheepId());
|
|
|
paramMap.put("status", "");
|
|
|
paramMap.put("pageNo", 1);
|
|
|
paramMap.put("pageSize", 20);
|
|
|
- String result= HttpUtil.post("http://119.3.44.183:8016/manage2/eartagRegister/listUserEartagData", paramMap);
|
|
|
- cn.hutool.json.JSONObject jsonObject = new cn.hutool.json.JSONObject(result);
|
|
|
- net.sf.json.JSONObject data = (net.sf.json.JSONObject) jsonObject.get("data");
|
|
|
- JSONArray records = data.getJSONArray("records");
|
|
|
- JSONObject record = (JSONObject) records.get(0);
|
|
|
- if (Double.valueOf(record.get("earTemp1").toString()) > 37.5) {
|
|
|
- errorCount++;
|
|
|
+ String result = HttpRequest.post("https://eartag.alafarms.com/api/manage2/eartagRegister/listUserEartagData").header(Header.CONTENT_TYPE, "application/json")
|
|
|
+ .body(paramMap.toJSONString())
|
|
|
+ .timeout(30 * 1000).execute().body();
|
|
|
+ System.out.println(result);
|
|
|
+ JSONObject jsonObject = JSON.parseObject(result);
|
|
|
+ JSONObject data = (JSONObject) jsonObject.get("data");
|
|
|
+ com.alibaba.fastjson.JSONArray records = data.getJSONArray("records");
|
|
|
+ if (records.size() != 0) {
|
|
|
+ JSONObject record = (JSONObject) records.get(0);
|
|
|
+ if (Double.valueOf(record.get("earTemp1").toString()) > 37.5) {
|
|
|
+ errorCount++;
|
|
|
+ }
|
|
|
+ temp = temp + Double.valueOf(record.get("earTemp1").toString());
|
|
|
+ act = act + Integer.parseInt(record.get("actRange").toString());
|
|
|
+ earmarkCount++;
|
|
|
}
|
|
|
- temp = temp + Double.valueOf(record.get("earTemp1").toString());
|
|
|
- act = act + Integer.parseInt(record.get("actRange").toString());
|
|
|
- earmarkCount++;
|
|
|
}
|
|
|
}
|
|
|
- act = (double) act / earmarkCount;
|
|
|
- temp = temp / earmarkCount;
|
|
|
+ if (earmarkCount != 0) {
|
|
|
+ act = act / earmarkCount;
|
|
|
+ temp = temp / earmarkCount;
|
|
|
+ }
|
|
|
}
|
|
|
object.put("earmarkCount", earmarkCount);
|
|
|
object.put("temp", def.format(temp));
|
|
|
- object.put("act", def.format(act));
|
|
|
- object.put("errorCount", def.format(errorCount));
|
|
|
+ object.put("act",act);
|
|
|
+ object.put("errorCount", errorCount);
|
|
|
return new Result(ResultCode.SUCCESS, object);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Result listAct(Map<String, String> paramsMap) {
|
|
|
String farmId = paramsMap.get("farmId");
|
|
|
- HashMap<String, Object> paramMap = new HashMap<>();
|
|
|
- paramMap.put("farmId", farmId);
|
|
|
- String result= HttpUtil.post("http://119.3.44.183:8016/manage2/eartag-hour-act/listActAvg", paramMap);
|
|
|
- cn.hutool.json.JSONObject jsonObject = new cn.hutool.json.JSONObject(result);
|
|
|
- cn.hutool.json.JSONArray records = jsonObject.getJSONArray("data");
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
+ JSONObject jsonObject1 = new JSONObject();
|
|
|
+ jsonObject1.put("farmId", farmId);
|
|
|
+ map.put("Content-Type", "application/json;charset=utf-8");
|
|
|
+ String result = HttpRequest.post("https://eartag.alafarms.com/api/manage2/eartag-hour-act/listActAvg")
|
|
|
+ .headerMap(map, false).body(jsonObject1.toJSONString()).timeout(30 * 1000).execute().body();
|
|
|
+ JSONObject jsonObject = JSON.parseObject(result);
|
|
|
+ com.alibaba.fastjson.JSONArray records = jsonObject.getJSONArray("data");
|
|
|
return new Result(ResultCode.SUCCESS, records);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Result listTemp(Map<String, String> paramsMap) {
|
|
|
String farmId = paramsMap.get("farmId");
|
|
|
- HashMap<String, Object> paramMap = new HashMap<>();
|
|
|
+ JSONObject paramMap = new JSONObject();
|
|
|
paramMap.put("farmId", farmId);
|
|
|
- String result= HttpUtil.post("http://119.3.44.183:8016/api/pig/allHealthy", paramMap);
|
|
|
- cn.hutool.json.JSONObject jsonObject = new cn.hutool.json.JSONObject(result);
|
|
|
- cn.hutool.json.JSONArray records = jsonObject.getJSONArray("data");
|
|
|
+ String result = HttpRequest.post("https://eartag.alafarms.com/api/manage2/pig/allHealthy2").header(Header.CONTENT_TYPE, "application/json")
|
|
|
+ .body(paramMap.toJSONString())
|
|
|
+ .timeout(30 * 1000).execute().body();
|
|
|
+ JSONObject jsonObject = JSON.parseObject(result);
|
|
|
+ com.alibaba.fastjson.JSONArray records = jsonObject.getJSONArray("data");
|
|
|
return new Result(ResultCode.SUCCESS, records);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result listWarning(Map<String, String> paramsMap) {
|
|
|
+ public String listWarning(Map<String, String> paramsMap) {
|
|
|
String farmId = paramsMap.get("farmId");
|
|
|
- HashMap<String, Object> paramMap = new HashMap<>();
|
|
|
- paramMap.put("farmId", farmId);
|
|
|
- String result= HttpUtil.post("http://119.3.44.183:8016/manage2/pig/listWarning", paramMap);
|
|
|
- cn.hutool.json.JSONObject jsonObject = new cn.hutool.json.JSONObject(result);
|
|
|
- cn.hutool.json.JSONArray records = jsonObject.getJSONArray("data");
|
|
|
- return new Result(ResultCode.SUCCESS, records);
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
+ JSONObject jsonObject1 = new JSONObject();
|
|
|
+ jsonObject1.put("farmId", farmId);
|
|
|
+ map.put("Content-Type", "application/json;charset=utf-8");
|
|
|
+ String result = HttpRequest.post("https://eartag.alafarms.com/api/manage2/pig/listWarning")
|
|
|
+ .headerMap(map, false).body(jsonObject1.toJSONString()).timeout(30 * 1000).execute().body();
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String listWarning2(Map<String, String> paramsMap) {
|
|
|
+ String farmId = paramsMap.get("farmId");
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
+ JSONObject jsonObject1 = new JSONObject();
|
|
|
+ jsonObject1.put("farmId", farmId);
|
|
|
+ jsonObject1.put("pageNum", paramsMap.get("pageNum"));
|
|
|
+ jsonObject1.put("pageSize", paramsMap.get("pageSize"));
|
|
|
+ map.put("Content-Type", "application/json;charset=utf-8");
|
|
|
+ String result = HttpRequest.post("https://eartag.alafarms.com/api/manage2/pig/listWarning2")
|
|
|
+ .headerMap(map, false).body(jsonObject1.toJSONString()).timeout(30 * 1000).execute().body();
|
|
|
+ System.out.println(result);
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -355,65 +413,72 @@ public class ProtSheepInfoServiceImpl extends ServiceImpl<ProtSheepInfoMapper, P
|
|
|
QueryWrapper<ProtSheepInfo> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq("farm_id", farmId).eq("sheep_id", sheepId).eq("is_leave", 0);
|
|
|
ProtSheepInfo sheepInfo = sheepInfoMapper.selectOne(queryWrapper);
|
|
|
-
|
|
|
TreeSheepInfo treeSheepInfo = new TreeSheepInfo();
|
|
|
- treeSheepInfo.setDayNum(sheepInfo.getSheepDay());
|
|
|
- treeSheepInfo.setSex(sheepInfo.getSex());
|
|
|
- treeSheepInfo.setSheepId(sheepInfo.getSheepId());
|
|
|
- treeSheepInfo.setSheepVariety(sheepInfo.getSheepVariety());
|
|
|
- treeSheepInfo.setUnitName(sheepInfo.getUnitName());
|
|
|
- treeSheepInfo.setId(sheepInfo.getId());
|
|
|
- if (StringUtils.isNotBlank(sheepInfo.getSheepMother())) {
|
|
|
- ProtSheepInfo mother = sheepInfoMapper.selectOne(new QueryWrapper<ProtSheepInfo>().eq("sheep_id", sheepInfo.getSheepMother()));
|
|
|
- TreeSheepInfo treeSheepInfo1 = new TreeSheepInfo();
|
|
|
- treeSheepInfo1.setDayNum(mother.getSheepDay());
|
|
|
- treeSheepInfo1.setSex(mother.getSex());
|
|
|
- treeSheepInfo1.setSheepId(mother.getSheepId());
|
|
|
- treeSheepInfo1.setSheepVariety(mother.getSheepVariety());
|
|
|
- treeSheepInfo1.setUnitName(mother.getUnitName());
|
|
|
- treeSheepInfo1.setId(mother.getId());
|
|
|
- treeSheepInfo.setMotherSheep(treeSheepInfo1);
|
|
|
- if (StringUtils.isNotBlank(mother.getSheepMother())) {
|
|
|
- ProtSheepInfo grandma = sheepInfoMapper.selectOne(new QueryWrapper<ProtSheepInfo>().eq("sheep_id", mother.getSheepMother()));
|
|
|
- TreeSheepInfo treeSheepInfo2 = new TreeSheepInfo();
|
|
|
- treeSheepInfo2.setDayNum(grandma.getSheepDay());
|
|
|
- treeSheepInfo2.setSex(grandma.getSex());
|
|
|
- treeSheepInfo2.setSheepId(grandma.getSheepId());
|
|
|
- treeSheepInfo2.setSheepVariety(grandma.getSheepVariety());
|
|
|
- treeSheepInfo2.setUnitName(grandma.getUnitName());
|
|
|
- treeSheepInfo2.setId(grandma.getId());
|
|
|
- treeSheepInfo1.setMotherSheep(treeSheepInfo2);
|
|
|
+ if (ObjectUtil.isNotEmpty(sheepInfo)) {
|
|
|
+ treeSheepInfo.setDayNum(sheepInfo.getSheepDay());
|
|
|
+ treeSheepInfo.setSex(sheepInfo.getSex());
|
|
|
+ treeSheepInfo.setSheepId(sheepInfo.getSheepId());
|
|
|
+ treeSheepInfo.setSheepVariety(sheepInfo.getSheepVariety());
|
|
|
+ treeSheepInfo.setUnitName(sheepInfo.getUnitName());
|
|
|
+ treeSheepInfo.setId(sheepInfo.getId());
|
|
|
+ if (StringUtils.isNotBlank(sheepInfo.getSheepMother())) {
|
|
|
+ ProtSheepInfo mother = sheepInfoMapper.selectOne(new QueryWrapper<ProtSheepInfo>().eq("sheep_id", sheepInfo.getSheepMother()));
|
|
|
+ TreeSheepInfo treeSheepInfo1 = new TreeSheepInfo();
|
|
|
+ treeSheepInfo1.setDayNum(mother.getSheepDay());
|
|
|
+ treeSheepInfo1.setSex(mother.getSex());
|
|
|
+ treeSheepInfo1.setSheepId(mother.getSheepId());
|
|
|
+ treeSheepInfo1.setSheepVariety(mother.getSheepVariety());
|
|
|
+ treeSheepInfo1.setUnitName(mother.getUnitName());
|
|
|
+ treeSheepInfo1.setId(mother.getId());
|
|
|
+ treeSheepInfo.setMotherSheep(treeSheepInfo1);
|
|
|
+ if (StringUtils.isNotBlank(mother.getSheepMother())) {
|
|
|
+ ProtSheepInfo grandma = sheepInfoMapper.selectOne(new QueryWrapper<ProtSheepInfo>().eq("sheep_id", mother.getSheepMother()));
|
|
|
+ TreeSheepInfo treeSheepInfo2 = new TreeSheepInfo();
|
|
|
+ treeSheepInfo2.setDayNum(grandma.getSheepDay());
|
|
|
+ treeSheepInfo2.setSex(grandma.getSex());
|
|
|
+ treeSheepInfo2.setSheepId(grandma.getSheepId());
|
|
|
+ treeSheepInfo2.setSheepVariety(grandma.getSheepVariety());
|
|
|
+ treeSheepInfo2.setUnitName(grandma.getUnitName());
|
|
|
+ treeSheepInfo2.setId(grandma.getId());
|
|
|
+ treeSheepInfo1.setMotherSheep(treeSheepInfo2);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(sheepInfo.getSheepFather())) {
|
|
|
- ProtSheepInfo father = sheepInfoMapper.selectOne(new QueryWrapper<ProtSheepInfo>().eq("sheep_id", sheepInfo.getSheepFather()));
|
|
|
- TreeSheepInfo treeSheepInfo1 = new TreeSheepInfo();
|
|
|
- treeSheepInfo1.setDayNum(father.getSheepDay());
|
|
|
- treeSheepInfo1.setSex(father.getSex());
|
|
|
- treeSheepInfo1.setSheepId(father.getSheepId());
|
|
|
- treeSheepInfo1.setSheepVariety(father.getSheepVariety());
|
|
|
- treeSheepInfo1.setUnitName(father.getUnitName());
|
|
|
- treeSheepInfo1.setId(father.getId());
|
|
|
- treeSheepInfo.setMotherSheep(treeSheepInfo1);
|
|
|
- if (StringUtils.isNotBlank(father.getSheepFather())) {
|
|
|
- ProtSheepInfo grandfa = sheepInfoMapper.selectOne(new QueryWrapper<ProtSheepInfo>().eq("sheep_id", father.getSheepFather()));
|
|
|
- TreeSheepInfo treeSheepInfo2 = new TreeSheepInfo();
|
|
|
- treeSheepInfo2.setDayNum(grandfa.getSheepDay());
|
|
|
- treeSheepInfo2.setSex(grandfa.getSex());
|
|
|
- treeSheepInfo2.setSheepId(grandfa.getSheepId());
|
|
|
- treeSheepInfo2.setSheepVariety(grandfa.getSheepVariety());
|
|
|
- treeSheepInfo2.setUnitName(grandfa.getUnitName());
|
|
|
- treeSheepInfo2.setId(grandfa.getId());
|
|
|
- treeSheepInfo1.setMotherSheep(treeSheepInfo2);
|
|
|
+ if (StringUtils.isNotBlank(sheepInfo.getSheepFather())) {
|
|
|
+ ProtSheepInfo father = sheepInfoMapper.selectOne(new QueryWrapper<ProtSheepInfo>().eq("sheep_id", sheepInfo.getSheepFather()));
|
|
|
+ TreeSheepInfo treeSheepInfo1 = new TreeSheepInfo();
|
|
|
+ treeSheepInfo1.setDayNum(father.getSheepDay());
|
|
|
+ treeSheepInfo1.setSex(father.getSex());
|
|
|
+ treeSheepInfo1.setSheepId(father.getSheepId());
|
|
|
+ treeSheepInfo1.setSheepVariety(father.getSheepVariety());
|
|
|
+ treeSheepInfo1.setUnitName(father.getUnitName());
|
|
|
+ treeSheepInfo1.setId(father.getId());
|
|
|
+ treeSheepInfo.setFatherSheep(treeSheepInfo1);
|
|
|
+ if (StringUtils.isNotBlank(father.getSheepFather())) {
|
|
|
+ ProtSheepInfo grandfa = sheepInfoMapper.selectOne(new QueryWrapper<ProtSheepInfo>().eq("sheep_id", father.getSheepFather()));
|
|
|
+ TreeSheepInfo treeSheepInfo2 = new TreeSheepInfo();
|
|
|
+ treeSheepInfo2.setDayNum(grandfa.getSheepDay());
|
|
|
+ treeSheepInfo2.setSex(grandfa.getSex());
|
|
|
+ treeSheepInfo2.setSheepId(grandfa.getSheepId());
|
|
|
+ treeSheepInfo2.setSheepVariety(grandfa.getSheepVariety());
|
|
|
+ treeSheepInfo2.setUnitName(grandfa.getUnitName());
|
|
|
+ treeSheepInfo2.setId(grandfa.getId());
|
|
|
+ treeSheepInfo1.setFatherSheep(treeSheepInfo2);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return new Result(ResultCode.SUCCESS, treeSheepInfo);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void updateDayAge() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询结果 转换成树形结构
|
|
|
*
|
|
|
- * @param bizBaseAreas 原始数据
|
|
|
+ * @param
|
|
|
* @return 树
|
|
|
*/
|
|
|
// private List<TreeBasePigpen> parseBizBaseArea(List<BasePigpen> bizBaseAreas) {
|
|
@@ -445,4 +510,26 @@ public class ProtSheepInfoServiceImpl extends ServiceImpl<ProtSheepInfoMapper, P
|
|
|
// });
|
|
|
// return roots;
|
|
|
// }
|
|
|
+ public static void main(String[] args) {
|
|
|
+// HashMap<String, Object> paramMap = new HashMap<>();
|
|
|
+// paramMap.put("farmId", "330110007");
|
|
|
+// paramMap.put("earmark", "1010003");
|
|
|
+// paramMap.put("status", "");
|
|
|
+// paramMap.put("pageNo", 1);
|
|
|
+// paramMap.put("pageSize", 20);
|
|
|
+// String result = HttpUtil.post("https://eartag.alafarms.com/api/manage2/eartagRegister/listUserEartagData", paramMap);
|
|
|
+// System.out.println(result);
|
|
|
+
|
|
|
+ JSONObject jsonObject2 = new JSONObject();
|
|
|
+ jsonObject2.put("farmId", "330110007");
|
|
|
+ jsonObject2.put("earmark", "1010003");
|
|
|
+ jsonObject2.put("pageNo", 1);
|
|
|
+ jsonObject2.put("pageSize", 20);
|
|
|
+ jsonObject2.put("status", "");
|
|
|
+
|
|
|
+ String body = HttpRequest.post("https://eartag.alafarms.com/api/manage2/eartagRegister/listUserEartagData").header(Header.CONTENT_TYPE, "application/json")
|
|
|
+ .body(jsonObject2.toJSONString())
|
|
|
+ .timeout(30 * 1000).execute().body();
|
|
|
+ System.out.println(body);
|
|
|
+ }
|
|
|
}
|