|
@@ -3,7 +3,9 @@ package com.huimv.production.autoGetData.service.impl;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.huimv.production.autoGetData.entity.IndexParameter;
|
|
|
+import com.huimv.production.autoGetData.entity.ProductionGroup;
|
|
|
import com.huimv.production.autoGetData.repo.IndexParameterRepository;
|
|
|
+import com.huimv.production.autoGetData.repo.ProductionGroupRepo;
|
|
|
import com.huimv.production.autoGetData.service.IAutoGetErpData;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -39,13 +41,15 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
private RestTemplate template;
|
|
|
@Autowired
|
|
|
private IndexParameterRepository parameterRepository;
|
|
|
+ @Autowired
|
|
|
+ private ProductionGroupRepo productionGroupRepo;
|
|
|
|
|
|
//PSY
|
|
|
@Override
|
|
|
public void getPsy() {
|
|
|
String token = getToken();
|
|
|
- String servicePath = apiIp + apiPort + serviceName;
|
|
|
- System.out.println("servicePath>>"+servicePath);
|
|
|
+// String servicePath = apiIp + apiPort + serviceName;
|
|
|
+// System.out.println("servicePath>>"+servicePath);
|
|
|
JSONObject jsonObject = template.getForObject(apiIp + apiPort + serviceName + "/getPsy?startDate="+startDate+"&endDate="+endDate+"&accessToken="+token
|
|
|
,JSONObject.class );
|
|
|
String data = jsonObject.getString("data");
|
|
@@ -75,21 +79,29 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
}
|
|
|
|
|
|
String reestrus_rate ="0.00000";
|
|
|
+ String variety = "";
|
|
|
+ ProductionGroup productionGroup = new ProductionGroup();
|
|
|
+ int i =4;
|
|
|
List<Map<String,String>> list = (List<Map<String,String>> ) JSON.parse(data);
|
|
|
for (Map<String, String> stringStringMap : list) {
|
|
|
for (String s : stringStringMap.keySet()) {
|
|
|
String farm = stringStringMap.get(s);
|
|
|
if (farm != null && farm.contains("海盐")){
|
|
|
reestrus_rate = stringStringMap.get("reestrus_rate");
|
|
|
+ variety = stringStringMap.get("variety");
|
|
|
+ productionGroup.setProductionType("reEstrus");
|
|
|
+ productionGroup.setVariety(variety);
|
|
|
+ productionGroup.setId(i);
|
|
|
+ productionGroup.setFrequency(reestrus_rate);
|
|
|
+ productionGroupRepo.save(productionGroup);
|
|
|
+ i++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- IndexParameter indexParameter = parameterRepository.findById(9).get();
|
|
|
- indexParameter.setData(reestrus_rate);
|
|
|
- indexParameter.setUpdateTime(new Date());
|
|
|
+
|
|
|
|
|
|
System.out.println("返情率------->"+data);
|
|
|
- parameterRepository.save(indexParameter);
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
@@ -104,25 +116,30 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- String parturition_rate ="0.00000";
|
|
|
+ String parturitionRate ="0.00000";
|
|
|
+ String variety = "";
|
|
|
+ ProductionGroup productionGroup = new ProductionGroup();
|
|
|
+ int i =1;
|
|
|
List<Map<String,String>> list = (List<Map<String,String>> ) JSON.parse(data);
|
|
|
for (Map<String, String> stringStringMap : list) {
|
|
|
for (String s : stringStringMap.keySet()) {
|
|
|
String farm = stringStringMap.get(s);
|
|
|
if (farm != null && farm.contains("海盐")){
|
|
|
- parturition_rate = stringStringMap.get("parturition_rate");
|
|
|
+ parturitionRate = stringStringMap.get("parturition_rate");
|
|
|
+ variety = stringStringMap.get("variety");
|
|
|
+ productionGroup.setFrequency(parturitionRate);
|
|
|
+ productionGroup.setId(i);
|
|
|
+ productionGroup.setProductionType("parturition");
|
|
|
+ productionGroup.setVariety(variety);
|
|
|
+ productionGroupRepo.save(productionGroup);
|
|
|
+ i++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- IndexParameter indexParameter = parameterRepository.findById(12).get();
|
|
|
- indexParameter.setData(parturition_rate);
|
|
|
- indexParameter.setUpdateTime(new Date());
|
|
|
-
|
|
|
|
|
|
- System.out.println("分娩率------->"+data);
|
|
|
- parameterRepository.save(indexParameter);
|
|
|
}
|
|
|
|
|
|
+ //获取各种存栏
|
|
|
@Override
|
|
|
public List getStorage() {
|
|
|
String token = getToken();
|
|
@@ -151,7 +168,7 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
//获取均产仔数,仔猪存活率
|
|
|
@Override
|
|
|
public void getPigletInfo() {
|
|
|
- /* String token = getToken();
|
|
|
+ String token = getToken();
|
|
|
JSONObject jsonObject = template.getForObject(apiIp + apiPort + serviceName +"/getPigletInfo?startDate="+startDate+"&endDate="+endDate+"&accessToken="+token
|
|
|
,JSONObject.class );
|
|
|
String data = jsonObject.getString("data");
|
|
@@ -159,20 +176,40 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
return;
|
|
|
}
|
|
|
//TODO 未完成
|
|
|
- String parturition_rate ="0.00000";
|
|
|
+ System.out.println("均产仔数,仔猪存活率--->"+data);
|
|
|
+ String birth_number ="0";
|
|
|
+ String total ="0";
|
|
|
+ String dead_quantity ="0";
|
|
|
List<Map<String,String>> list = (List<Map<String,String>> ) JSON.parse(data);
|
|
|
for (Map<String, String> stringStringMap : list) {
|
|
|
for (String s : stringStringMap.keySet()) {
|
|
|
String farm = stringStringMap.get(s);
|
|
|
if (farm != null && farm.contains("海盐")){
|
|
|
- parturition_rate = stringStringMap.get("parturition_rate");
|
|
|
+ birth_number = stringStringMap.get("birth_number");
|
|
|
+ total = stringStringMap.get("total");
|
|
|
+ dead_quantity = stringStringMap.get("dead_quantity");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- IndexParameter indexParameter = parameterRepository.findById(12).get();
|
|
|
- indexParameter.setData(parturition_rate);
|
|
|
+
|
|
|
+ //分娩头数
|
|
|
+ IndexParameter indexParameter = parameterRepository.findById(19).get();
|
|
|
+ indexParameter.setData(birth_number);
|
|
|
indexParameter.setUpdateTime(new Date());
|
|
|
- parameterRepository.save(indexParameter);*/
|
|
|
+ parameterRepository.save(indexParameter);
|
|
|
+
|
|
|
+
|
|
|
+ //产仔总数
|
|
|
+ IndexParameter indexParameter2 = parameterRepository.findById(20).get();
|
|
|
+ indexParameter2.setData(total);
|
|
|
+ indexParameter2.setUpdateTime(new Date());
|
|
|
+ parameterRepository.save(indexParameter2);
|
|
|
+
|
|
|
+ //仔猪死淘数
|
|
|
+ IndexParameter indexParameter3 = parameterRepository.findById(21).get();
|
|
|
+ indexParameter3.setData(dead_quantity);
|
|
|
+ indexParameter3.setUpdateTime(new Date());
|
|
|
+ parameterRepository.save(indexParameter);
|
|
|
}
|
|
|
|
|
|
//配种数量
|
|
@@ -186,22 +223,29 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
return;
|
|
|
}
|
|
|
String mate_quantity ="0";
|
|
|
+ String variety = "";
|
|
|
+ ProductionGroup productionGroup = new ProductionGroup();
|
|
|
+ int i = 7;
|
|
|
List<Map<String,String>> list = (List<Map<String,String>> ) JSON.parse(data);
|
|
|
for (Map<String, String> stringStringMap : list) {
|
|
|
for (String s : stringStringMap.keySet()) {
|
|
|
String farm = stringStringMap.get(s);
|
|
|
if (farm != null && farm.contains("海盐")){
|
|
|
mate_quantity = stringStringMap.get("mate_quantity");
|
|
|
+ variety = stringStringMap.get("variety");
|
|
|
+ productionGroup.setId(i);
|
|
|
+ productionGroup.setFrequency(mate_quantity);
|
|
|
+ productionGroup.setVariety(variety);
|
|
|
+ productionGroup.setProductionType("mateQuantity");
|
|
|
+ productionGroupRepo.save(productionGroup);
|
|
|
+ i++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- IndexParameter indexParameter = parameterRepository.findById(10).get();
|
|
|
- indexParameter.setData(mate_quantity);
|
|
|
- indexParameter.setUpdateTime(new Date());
|
|
|
|
|
|
System.out.println("配种数------->"+data);
|
|
|
|
|
|
- parameterRepository.save(indexParameter);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//受胎率
|
|
@@ -224,14 +268,14 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- IndexParameter indexParameter = parameterRepository.findById(11).get();
|
|
|
+ IndexParameter indexParameter = parameterRepository.findById(18).get();
|
|
|
indexParameter.setData(conception_rate);
|
|
|
indexParameter.setUpdateTime(new Date());
|
|
|
|
|
|
System.out.println("受胎率------->"+data);
|
|
|
parameterRepository.save(indexParameter);
|
|
|
}
|
|
|
-
|
|
|
+ //总存栏,母猪存栏
|
|
|
@Override
|
|
|
public void getAllStorage() {
|
|
|
String token = getToken();
|
|
@@ -262,12 +306,42 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
IndexParameter indexParameter1 = parameterRepository.findById(3).get();
|
|
|
indexParameter1.setData(sow_quantity);
|
|
|
indexParameter1.setUpdateTime(new Date());
|
|
|
+ System.out.println("总存栏,母猪存栏------->"+data);
|
|
|
+
|
|
|
parameterRepository.save(indexParameter);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List findAll() {
|
|
|
+ List<ProductionGroup> delivery = productionGroupRepo.findAllByVariety("巴嘉");
|
|
|
+ List<ProductionGroup> reservice = productionGroupRepo.findAllByVariety("杜巴嘉");
|
|
|
+ List<ProductionGroup> breeding = productionGroupRepo.findAllByVariety("金华两头乌");
|
|
|
+ Map map1 = new HashMap();
|
|
|
+ Map map2 = new HashMap();
|
|
|
+ Map map3 = new HashMap();
|
|
|
+ map1.put("veriety","巴嘉");
|
|
|
+ map2.put("veriety","杜巴嘉");
|
|
|
+ map3.put("veriety","金华两头乌");
|
|
|
+ for (ProductionGroup productionGroup : delivery) {
|
|
|
+ map1.put(productionGroup.getProductionType(),productionGroup.getFrequency());
|
|
|
+ }
|
|
|
+ for (ProductionGroup productionGroup : reservice) {
|
|
|
+ map2.put(productionGroup.getProductionType(),productionGroup.getFrequency());
|
|
|
+ }
|
|
|
+ for (ProductionGroup productionGroup : breeding) {
|
|
|
+ map3.put(productionGroup.getProductionType(),productionGroup.getFrequency());
|
|
|
+ }
|
|
|
+
|
|
|
+ List list = new ArrayList();
|
|
|
+ list.add(map1);
|
|
|
+ list.add(map2);
|
|
|
+ list.add(map3);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private String getToken(){
|
|
|
- JSONObject token = template.getForObject("http://192.168.1.62:9100/token/getToken?userId=20210501×tamp=45546546454&random=1156&sign=7fa431325504e01e9fa87ed0e274c40c",
|
|
|
+ JSONObject token = template.getForObject("http://127.0.0.1:9100/token/getToken?userId=20210501×tamp=45546546454&random=1156&sign=7fa431325504e01e9fa87ed0e274c40c",
|
|
|
JSONObject.class);
|
|
|
return token.getString("accessToken");
|
|
|
|