|
@@ -6,14 +6,11 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
//import com.huimv.common.date.DateUtil;
|
|
|
-import com.huimv.production.autoGetData.entity.IndexParameter;
|
|
|
-import com.huimv.production.autoGetData.entity.ProdWarningMsgEntity;
|
|
|
-import com.huimv.production.autoGetData.entity.ProductionGroup;
|
|
|
-import com.huimv.production.autoGetData.repo.IndexParameterRepository;
|
|
|
-import com.huimv.production.autoGetData.repo.ProdWarningMsgRepo;
|
|
|
-import com.huimv.production.autoGetData.repo.ProductionGroupRepo;
|
|
|
+import com.huimv.production.autoGetData.entity.*;
|
|
|
+import com.huimv.production.autoGetData.repo.*;
|
|
|
import com.huimv.production.autoGetData.service.IAutoGetErpData;
|
|
|
import com.huimv.production.autoGetData.utils.HttpTemplete;
|
|
|
+import com.huimv.production.autoGetData.utils.MathUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -23,6 +20,7 @@ import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.sql.Timestamp;
|
|
|
+import java.text.NumberFormat;
|
|
|
import java.text.ParseException;
|
|
|
import java.util.*;
|
|
|
|
|
@@ -61,6 +59,12 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
private com.huimv.production.autoGetData.utils.DateUtil dateUtil;
|
|
|
@Autowired
|
|
|
private ProdWarningMsgRepo warningMsgRepo;
|
|
|
+ @Autowired
|
|
|
+ private ProdFarmNameRepo prodFarmNameRepo;
|
|
|
+ @Autowired
|
|
|
+ private ProdStockRepo prodStockRepo;
|
|
|
+ @Autowired
|
|
|
+ private MathUtil mathUtil;
|
|
|
|
|
|
//PSY
|
|
|
@Override
|
|
@@ -68,69 +72,68 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
String token = getToken();
|
|
|
// String servicePath = apiIp + apiPort + serviceName;
|
|
|
// System.out.println("servicePath>>"+servicePath);
|
|
|
- String startDate ;
|
|
|
+ String startDate;
|
|
|
String endDate;
|
|
|
DateTime date = DateUtil.date();
|
|
|
- endDate = (date+"").substring(0,10);
|
|
|
- startDate = (DateUtil.beginOfMonth(date)+"").substring(0,10);
|
|
|
+ endDate = (date + "").substring(0, 10);
|
|
|
+ startDate = (DateUtil.beginOfMonth(date) + "").substring(0, 10);
|
|
|
|
|
|
- JSONObject jsonObject = template.getForObject(apiIp + apiPort + serviceName + "/getPsy?startDate="+startDate+"&endDate="+endDate+"&accessToken="+token
|
|
|
- ,JSONObject.class );
|
|
|
+ JSONObject jsonObject = template.getForObject(apiIp + apiPort + serviceName + "/getPsy?startDate=" + startDate + "&endDate=" + endDate + "&accessToken=" + token
|
|
|
+ , JSONObject.class);
|
|
|
String data = jsonObject.getString("data");
|
|
|
- if (data == null){
|
|
|
+ if (data == null) {
|
|
|
return;
|
|
|
}
|
|
|
IndexParameter indexParameter = parameterRepository.findById(7).get();
|
|
|
indexParameter.setUpdateTime(new Date());
|
|
|
indexParameter.setData(data);
|
|
|
- System.out.println("PSY------->"+data);
|
|
|
+ System.out.println("PSY------->" + data);
|
|
|
|
|
|
parameterRepository.save(indexParameter);
|
|
|
|
|
|
|
|
|
-
|
|
|
- System.out.println("startDate:"+startDate);
|
|
|
- System.out.println("endDate:"+endDate);
|
|
|
+ System.out.println("startDate:" + startDate);
|
|
|
+ System.out.println("endDate:" + endDate);
|
|
|
}
|
|
|
|
|
|
//返情率
|
|
|
@Override
|
|
|
public void getReEstrusRate() {
|
|
|
- String startDate ;
|
|
|
+ String startDate;
|
|
|
String endDate;
|
|
|
DateTime date = DateUtil.date();
|
|
|
- endDate = (date+"").substring(0,10);
|
|
|
- startDate = (DateUtil.beginOfMonth(date)+"").substring(0,10);
|
|
|
+ endDate = (date + "").substring(0, 10);
|
|
|
+ startDate = (DateUtil.beginOfMonth(date) + "").substring(0, 10);
|
|
|
|
|
|
String token = getToken();
|
|
|
- JSONObject jsonObject = template.getForObject(apiIp + apiPort + serviceName + "/getReEstrusRate?startDate="+startDate+"&endDate="+endDate+"&accessToken="+token
|
|
|
- ,JSONObject.class );
|
|
|
+ JSONObject jsonObject = template.getForObject(apiIp + apiPort + serviceName + "/getReEstrusRate?startDate=" + startDate + "&endDate=" + endDate + "&accessToken=" + token
|
|
|
+ , JSONObject.class);
|
|
|
String data = jsonObject.getString("data");
|
|
|
- if (data == null){
|
|
|
+ if (data == null) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- String reestrus_rate ="0.00000";
|
|
|
+ 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);
|
|
|
+ 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++;
|
|
|
+ // 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++;
|
|
|
// }
|
|
|
// }
|
|
|
}
|
|
|
- System.out.println("返情率------->"+data);
|
|
|
+ System.out.println("返情率------->" + data);
|
|
|
|
|
|
|
|
|
}
|
|
@@ -138,42 +141,42 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
//获取分娩率
|
|
|
@Override
|
|
|
public void getParturitionRate() {
|
|
|
- String startDate ;
|
|
|
+ String startDate;
|
|
|
String endDate;
|
|
|
DateTime date = DateUtil.date();
|
|
|
- endDate = (date+"").substring(0,10);
|
|
|
- startDate = (DateUtil.beginOfMonth(date)+"").substring(0,10);
|
|
|
+ endDate = (date + "").substring(0, 10);
|
|
|
+ startDate = (DateUtil.beginOfMonth(date) + "").substring(0, 10);
|
|
|
|
|
|
String token = getToken();
|
|
|
- JSONObject jsonObject = template.getForObject(apiIp + apiPort + serviceName +"/getParturitionRate?startDate="+startDate+"&endDate="+endDate+"&accessToken="+token
|
|
|
- ,JSONObject.class );
|
|
|
+ JSONObject jsonObject = template.getForObject(apiIp + apiPort + serviceName + "/getParturitionRate?startDate=" + startDate + "&endDate=" + endDate + "&accessToken=" + token
|
|
|
+ , JSONObject.class);
|
|
|
String data = jsonObject.getString("data");
|
|
|
- if (data == null){
|
|
|
+ if (data == null) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- String parturitionRate ="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);
|
|
|
+ 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("秀洲")){
|
|
|
- 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++;
|
|
|
+ // if (farm != null && farm.contains("秀洲")){
|
|
|
+ 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++;
|
|
|
// }
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
- System.out.println("分娩率--->"+data);
|
|
|
+ System.out.println("分娩率--->" + data);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -183,58 +186,59 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
|
|
|
|
|
|
String token = getToken();
|
|
|
- JSONObject jsonObject = template.getForObject(apiIp + apiPort + serviceName +"/getStorage?accessToken="+token
|
|
|
- ,JSONObject.class );
|
|
|
+ JSONObject jsonObject = template.getForObject(apiIp + apiPort + serviceName + "/getStorage?accessToken=" + token
|
|
|
+ , JSONObject.class);
|
|
|
String data = jsonObject.getString("data");
|
|
|
- if (data == null){
|
|
|
+ if (data == null) {
|
|
|
return null;
|
|
|
}
|
|
|
- List<Map<String,String>> list = (List<Map<String,String>> ) JSON.parse(data);JSON.parse(data);
|
|
|
+ List<Map<String, String>> list = (List<Map<String, String>>) JSON.parse(data);
|
|
|
+ JSON.parse(data);
|
|
|
List list1 = new ArrayList();
|
|
|
for (Map<String, String> stringStringMap : list) {
|
|
|
for (String s : stringStringMap.keySet()) {
|
|
|
String farm = stringStringMap.get(s);
|
|
|
// if (farm != null && farm.contains("秀洲")){
|
|
|
- Map map = new HashMap();
|
|
|
- map.put("name",stringStringMap.get("name"));
|
|
|
- map.put("quantity",stringStringMap.get("quantity"));
|
|
|
- list1.add(map);
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put("name", stringStringMap.get("name"));
|
|
|
+ map.put("quantity", stringStringMap.get("quantity"));
|
|
|
+ list1.add(map);
|
|
|
// }
|
|
|
}
|
|
|
}
|
|
|
- System.out.println("各种存栏--->"+data);
|
|
|
+ System.out.println("各种存栏--->" + data);
|
|
|
return list1;
|
|
|
}
|
|
|
|
|
|
//获取均产仔数,仔猪存活率
|
|
|
@Override
|
|
|
public void getPigletInfo() {
|
|
|
- String startDate ;
|
|
|
+ String startDate;
|
|
|
String endDate;
|
|
|
DateTime date = DateUtil.date();
|
|
|
- endDate = (date+"").substring(0,10);
|
|
|
- startDate = (DateUtil.beginOfMonth(date)+"").substring(0,10);
|
|
|
+ endDate = (date + "").substring(0, 10);
|
|
|
+ startDate = (DateUtil.beginOfMonth(date) + "").substring(0, 10);
|
|
|
|
|
|
String token = getToken();
|
|
|
- JSONObject jsonObject = template.getForObject(apiIp + apiPort + serviceName +"/getPigletInfo?startDate="+startDate+"&endDate="+endDate+"&accessToken="+token
|
|
|
- ,JSONObject.class );
|
|
|
+ JSONObject jsonObject = template.getForObject(apiIp + apiPort + serviceName + "/getPigletInfo?startDate=" + startDate + "&endDate=" + endDate + "&accessToken=" + token
|
|
|
+ , JSONObject.class);
|
|
|
String data = jsonObject.getString("data");
|
|
|
- if (data == null){
|
|
|
+ if (data == null) {
|
|
|
return;
|
|
|
}
|
|
|
//TODO 未完成
|
|
|
- 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);
|
|
|
+ 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("秀洲")){
|
|
|
- birth_number = stringStringMap.get("birth_number");
|
|
|
- total = stringStringMap.get("total");
|
|
|
- dead_quantity = stringStringMap.get("dead_quantity");
|
|
|
+ birth_number = stringStringMap.get("birth_number");
|
|
|
+ total = stringStringMap.get("total");
|
|
|
+ dead_quantity = stringStringMap.get("dead_quantity");
|
|
|
// }
|
|
|
}
|
|
|
}
|
|
@@ -263,41 +267,41 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
//配种数量
|
|
|
@Override
|
|
|
public void getMateQuantity() {
|
|
|
- String startDate ;
|
|
|
+ String startDate;
|
|
|
String endDate;
|
|
|
DateTime date = DateUtil.date();
|
|
|
- endDate = (date+"").substring(0,10);
|
|
|
- startDate = (DateUtil.beginOfMonth(date)+"").substring(0,10);
|
|
|
+ endDate = (date + "").substring(0, 10);
|
|
|
+ startDate = (DateUtil.beginOfMonth(date) + "").substring(0, 10);
|
|
|
|
|
|
String token = getToken();
|
|
|
- JSONObject jsonObject = template.getForObject(apiIp + apiPort + serviceName +"/getMateQuantity?startDate="+startDate+"&endDate="+endDate+"&accessToken="+token
|
|
|
- ,JSONObject.class );
|
|
|
+ JSONObject jsonObject = template.getForObject(apiIp + apiPort + serviceName + "/getMateQuantity?startDate=" + startDate + "&endDate=" + endDate + "&accessToken=" + token
|
|
|
+ , JSONObject.class);
|
|
|
String data = jsonObject.getString("data");
|
|
|
- if (data == null){
|
|
|
+ if (data == null) {
|
|
|
return;
|
|
|
}
|
|
|
- String mate_quantity ="0";
|
|
|
+ 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);
|
|
|
+ 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++;
|
|
|
+ // 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++;
|
|
|
// }
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
- System.out.println("配种数------->"+data);
|
|
|
+ System.out.println("配种数------->" + data);
|
|
|
|
|
|
|
|
|
}
|
|
@@ -305,26 +309,26 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
//受胎率
|
|
|
@Override
|
|
|
public void getConceptionRate() {
|
|
|
- String startDate ;
|
|
|
+ String startDate;
|
|
|
String endDate;
|
|
|
DateTime date = DateUtil.date();
|
|
|
- endDate = (date+"").substring(0,10);
|
|
|
- startDate = (DateUtil.beginOfMonth(date)+"").substring(0,10);
|
|
|
+ endDate = (date + "").substring(0, 10);
|
|
|
+ startDate = (DateUtil.beginOfMonth(date) + "").substring(0, 10);
|
|
|
|
|
|
String token = getToken();
|
|
|
- JSONObject jsonObject = template.getForObject(apiIp + apiPort + serviceName +"/getConceptionRate?startDate="+startDate+"&endDate="+endDate+"&accessToken="+token
|
|
|
- ,JSONObject.class );
|
|
|
+ JSONObject jsonObject = template.getForObject(apiIp + apiPort + serviceName + "/getConceptionRate?startDate=" + startDate + "&endDate=" + endDate + "&accessToken=" + token
|
|
|
+ , JSONObject.class);
|
|
|
String data = jsonObject.getString("data");
|
|
|
- if (data == null){
|
|
|
+ if (data == null) {
|
|
|
return;
|
|
|
}
|
|
|
- String conception_rate ="0";
|
|
|
- List<Map<String,String>> list = (List<Map<String,String>> ) JSON.parse(data);
|
|
|
+ String conception_rate = "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("秀洲")){
|
|
|
- conception_rate = stringStringMap.get("conception_rate");
|
|
|
+ // if (farm != null && farm.contains("秀洲")){
|
|
|
+ conception_rate = stringStringMap.get("conception_rate");
|
|
|
// }
|
|
|
// }
|
|
|
}
|
|
@@ -332,35 +336,36 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
indexParameter.setData(conception_rate);
|
|
|
indexParameter.setUpdateTime(new Date());
|
|
|
|
|
|
- System.out.println("受胎率------->"+data);
|
|
|
+ System.out.println("受胎率------->" + data);
|
|
|
parameterRepository.save(indexParameter);
|
|
|
}
|
|
|
+
|
|
|
//总存栏,母猪存栏
|
|
|
@Override
|
|
|
public void getAllStorage() {
|
|
|
- String startDate ;
|
|
|
+ String startDate;
|
|
|
String endDate;
|
|
|
DateTime date = DateUtil.date();
|
|
|
- endDate = (date+"").substring(0,10);
|
|
|
- startDate = (DateUtil.beginOfMonth(date)+"").substring(0,10);
|
|
|
+ endDate = (date + "").substring(0, 10);
|
|
|
+ startDate = (DateUtil.beginOfMonth(date) + "").substring(0, 10);
|
|
|
|
|
|
String token = getToken();
|
|
|
- JSONObject jsonObject = template.getForObject(apiIp + apiPort + serviceName +"/getAllStorage?startDate="+startDate+"&endDate="+endDate+"&accessToken="+token
|
|
|
- ,JSONObject.class );
|
|
|
+ JSONObject jsonObject = template.getForObject(apiIp + apiPort + serviceName + "/getAllStorage?startDate=" + startDate + "&endDate=" + endDate + "&accessToken=" + token
|
|
|
+ , JSONObject.class);
|
|
|
String data = jsonObject.getString("data");
|
|
|
- if (data == null){
|
|
|
+ if (data == null) {
|
|
|
return;
|
|
|
}
|
|
|
- List<Map<String,String>> list = (List<Map<String,String>> ) JSON.parse(data);
|
|
|
- String total ="0";
|
|
|
- String sow_quantity="0";
|
|
|
+ List<Map<String, String>> list = (List<Map<String, String>>) JSON.parse(data);
|
|
|
+ String total = "0";
|
|
|
+ String sow_quantity = "0";
|
|
|
|
|
|
for (Map<String, String> stringStringMap : list) {
|
|
|
for (String s : stringStringMap.keySet()) {
|
|
|
String farm = stringStringMap.get(s);
|
|
|
// if (farm != null && farm.contains("秀洲")){
|
|
|
- total = stringStringMap.get("total");
|
|
|
- sow_quantity = stringStringMap.get("sow_quantity");
|
|
|
+ total = stringStringMap.get("total");
|
|
|
+ sow_quantity = stringStringMap.get("sow_quantity");
|
|
|
// }
|
|
|
}
|
|
|
}
|
|
@@ -372,7 +377,7 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
IndexParameter indexParameter1 = parameterRepository.findById(3).get();
|
|
|
indexParameter1.setData(sow_quantity);
|
|
|
indexParameter1.setUpdateTime(new Date());
|
|
|
- System.out.println("总存栏,母猪存栏------->"+data);
|
|
|
+ System.out.println("总存栏,母猪存栏------->" + data);
|
|
|
|
|
|
parameterRepository.save(indexParameter);
|
|
|
}
|
|
@@ -385,17 +390,17 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
Map map1 = new HashMap();
|
|
|
Map map2 = new HashMap();
|
|
|
Map map3 = new HashMap();
|
|
|
- map1.put("veriety","巴嘉");
|
|
|
- map2.put("veriety","杜巴嘉");
|
|
|
- map3.put("veriety","金华两头乌");
|
|
|
+ map1.put("veriety", "巴嘉");
|
|
|
+ map2.put("veriety", "杜巴嘉");
|
|
|
+ map3.put("veriety", "金华两头乌");
|
|
|
for (ProductionGroup productionGroup : delivery) {
|
|
|
- map1.put(productionGroup.getProductionType(),productionGroup.getFrequency());
|
|
|
+ map1.put(productionGroup.getProductionType(), productionGroup.getFrequency());
|
|
|
}
|
|
|
for (ProductionGroup productionGroup : reservice) {
|
|
|
- map2.put(productionGroup.getProductionType(),productionGroup.getFrequency());
|
|
|
+ map2.put(productionGroup.getProductionType(), productionGroup.getFrequency());
|
|
|
}
|
|
|
for (ProductionGroup productionGroup : breeding) {
|
|
|
- map3.put(productionGroup.getProductionType(),productionGroup.getFrequency());
|
|
|
+ map3.put(productionGroup.getProductionType(), productionGroup.getFrequency());
|
|
|
}
|
|
|
|
|
|
List list = new ArrayList();
|
|
@@ -407,11 +412,11 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
|
|
|
@Override
|
|
|
public void getManyFarmProduce() throws IOException {
|
|
|
- String startDate ;
|
|
|
+ String startDate;
|
|
|
String endDate;
|
|
|
DateTime date = DateUtil.date();
|
|
|
- endDate = (date+"").substring(0,10);
|
|
|
- startDate = (DateUtil.beginOfMonth(date)+"").substring(0,10);
|
|
|
+ endDate = (date + "").substring(0, 10);
|
|
|
+ startDate = (DateUtil.beginOfMonth(date) + "").substring(0, 10);
|
|
|
//
|
|
|
String token = getRemoteToken();
|
|
|
// JSONObject jsonObject = template.getForObject(apiIp + apiPort + serviceName +"/getManyFarmProduce?startDate="+startDate+"&endDate="+endDate+"&accessToken="+token
|
|
@@ -429,34 +434,34 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
timeoutMap.put("connectTimeout", 120000);
|
|
|
timeoutMap.put("requestTimeout", 120000);
|
|
|
timeoutMap.put("socketTimeout", 120000);
|
|
|
- String url = apiIp + apiPort + serviceName +"/getManyFarmProduce";
|
|
|
- log.info("多个牧场生产数据访问地址="+url);
|
|
|
- log.info("业务请求参数="+paramsMap.toString());
|
|
|
- log.info("超时参数="+timeoutMap.toString());
|
|
|
- log.info("开始取数="+new Date(System.currentTimeMillis()));
|
|
|
+ String url = apiIp + apiPort + serviceName + "/getManyFarmProduce";
|
|
|
+ log.info("多个牧场生产数据访问地址=" + url);
|
|
|
+ log.info("业务请求参数=" + paramsMap.toString());
|
|
|
+ log.info("超时参数=" + timeoutMap.toString());
|
|
|
+ log.info("开始取数=" + new Date(System.currentTimeMillis()));
|
|
|
//
|
|
|
- JSONObject outJo = httpClientUtil.doGet(url,paramsMap,timeoutMap);
|
|
|
- log.info("返回结果="+outJo);
|
|
|
- log.info("完成取数="+new Date(System.currentTimeMillis()));
|
|
|
- if(outJo.getBoolean("status")){
|
|
|
+ JSONObject outJo = httpClientUtil.doGet(url, paramsMap, timeoutMap);
|
|
|
+ log.info("返回结果=" + outJo);
|
|
|
+ log.info("完成取数=" + new Date(System.currentTimeMillis()));
|
|
|
+ if (outJo.getBoolean("status")) {
|
|
|
JSONObject contentJo = outJo.getJSONObject("content");
|
|
|
- if(contentJo.getBoolean("success")){
|
|
|
+ if (contentJo.getBoolean("success")) {
|
|
|
JSONArray dataJa = contentJo.getJSONArray("data");
|
|
|
// 添加入库
|
|
|
- for(int a=0;a<dataJa.size();a++){
|
|
|
+ for (int a = 0; a < dataJa.size(); a++) {
|
|
|
JSONObject dataJo = dataJa.getJSONObject(a);
|
|
|
- System.out.println((a+1)+" "+dataJo);
|
|
|
+ System.out.println((a + 1) + " " + dataJo);
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
System.out.println("取数失败");
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
System.out.println("取数失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
- private String getToken(){
|
|
|
+ private String getToken() {
|
|
|
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");
|
|
@@ -477,18 +482,20 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
timeoutMap.put("connectTimeout", 5000);
|
|
|
timeoutMap.put("requestTimeout", 5000);
|
|
|
timeoutMap.put("socketTimeout", 5000);
|
|
|
- String url = apiIp + apiPort +"/token/getToken";
|
|
|
+ String url = apiIp + apiPort + "/token/getToken";
|
|
|
//
|
|
|
- JSONObject outJo = httpClientUtil.doGet(url,paramsMap,timeoutMap);
|
|
|
- if(outJo.getBoolean("status")){
|
|
|
+ JSONObject outJo = httpClientUtil.doGet(url, paramsMap, timeoutMap);
|
|
|
+ if (outJo.getBoolean("status")) {
|
|
|
return outJo.getJSONObject("content").getString("accessToken");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return outJo.getString("content");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void getManyFarmStock() throws IOException {
|
|
|
+ String year = dateUtil.getThisYear();
|
|
|
+ String month = dateUtil.getThisMonth();
|
|
|
//
|
|
|
String token = getRemoteToken();
|
|
|
Map<String, String> paramsMap = new HashMap<String, String>();
|
|
@@ -497,32 +504,175 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
timeoutMap.put("connectTimeout", 120000);
|
|
|
timeoutMap.put("requestTimeout", 120000);
|
|
|
timeoutMap.put("socketTimeout", 120000);
|
|
|
- String url = apiIp + apiPort + serviceName +"/getManyFarmStock";
|
|
|
- log.info("获取多个牧场的存栏数据请求地址="+url);
|
|
|
- log.info("业务请求参数="+paramsMap.toString());
|
|
|
- log.info("超时参数="+timeoutMap.toString());
|
|
|
- log.info("开始取数="+new Date(System.currentTimeMillis()));
|
|
|
+ String url = apiIp + apiPort + serviceName + "/getManyFarmStock";
|
|
|
+ log.info("获取多个牧场的存栏数据请求地址=" + url);
|
|
|
+ log.info("业务请求参数=" + paramsMap.toString());
|
|
|
+ log.info("超时参数=" + timeoutMap.toString());
|
|
|
+ log.info("开始取数=" + new Date(System.currentTimeMillis()));
|
|
|
//
|
|
|
- JSONObject outJo = httpClientUtil.doGet(url,paramsMap,timeoutMap);
|
|
|
- log.info("返回结果="+outJo);
|
|
|
- log.info("结束取数="+new Date(System.currentTimeMillis()));
|
|
|
- if(outJo.getBoolean("status")){
|
|
|
+ JSONObject outJo = httpClientUtil.doGet(url, paramsMap, timeoutMap);
|
|
|
+ log.info("返回结果=" + outJo);
|
|
|
+ log.info("结束取数=" + new Date(System.currentTimeMillis()));
|
|
|
+ if (outJo.getBoolean("status")) {
|
|
|
JSONObject contentJo = outJo.getJSONObject("content");
|
|
|
- if(contentJo.getBoolean("success")){
|
|
|
+ if (contentJo.getBoolean("success")) {
|
|
|
JSONArray dataJa = contentJo.getJSONArray("data");
|
|
|
- // 添加入库
|
|
|
- for(int a=0;a<dataJa.size();a++){
|
|
|
- JSONObject dataJo = dataJa.getJSONObject(a);
|
|
|
- System.out.println((a+1)+" "+dataJo);
|
|
|
+ if (dataJa.size() > 0) {
|
|
|
+ //获取牧场所有名称数据
|
|
|
+ List<ProdFarmNameEntity> farmNameEntityList = prodFarmNameRepo.findAll();
|
|
|
+// for(ProdFarmNameEntity farmNameEntity:farmNameEntityList){
|
|
|
+// System.out.println(""+farmNameEntity.toString());
|
|
|
+// }
|
|
|
+ //删除旧数据
|
|
|
+ ProdStockEntity prodStockEntity = new ProdStockEntity();
|
|
|
+ prodStockEntity.setYear(Integer.parseInt(year));
|
|
|
+ prodStockEntity.setMonth(Integer.parseInt(month));
|
|
|
+ Example<ProdStockEntity> example = Example.of(prodStockEntity);
|
|
|
+ prodStockRepo.deleteAll(prodStockRepo.findAll(example));
|
|
|
+// prodStockRepo.deleteByYearAndMonth(Integer.parseInt(year),Integer.parseInt(month));
|
|
|
+
|
|
|
+ // 添加入库
|
|
|
+ for (int a = 0; a < dataJa.size(); a++) {
|
|
|
+ JSONObject dataJo = dataJa.getJSONObject(a);
|
|
|
+ System.out.println((a + 1) + " " + dataJo);
|
|
|
+ int farmId = _getFarmId2(dataJo.getString("mcmc"), farmNameEntityList);
|
|
|
+ int mz = dataJo.getInteger("mz");
|
|
|
+ int gz = dataJo.getInteger("gz");
|
|
|
+ int zz = dataJo.getInteger("zz");
|
|
|
+ int by = dataJo.getInteger("by");
|
|
|
+ int yf = dataJo.getInteger("yf");
|
|
|
+ int total = mz + gz + zz + by + yf;
|
|
|
+ System.out.println("farmId=" + farmId + ",total=" + total);
|
|
|
+ //母猪存栏
|
|
|
+ ProdStockEntity stockEntity1 = new ProdStockEntity();
|
|
|
+ stockEntity1.setFarmId(farmId);
|
|
|
+ stockEntity1.setStockType("sow_stock");
|
|
|
+ stockEntity1.setStockName("母猪存栏");
|
|
|
+ stockEntity1.setStockQuantity(dataJo.getString("mz"));
|
|
|
+ stockEntity1.setRate(Float.parseFloat(mathUtil.countRate(mz,total,1)));
|
|
|
+ stockEntity1.setMonth(Integer.valueOf(month));
|
|
|
+ stockEntity1.setYear(Integer.parseInt(year));
|
|
|
+ prodStockRepo.saveAndFlush(stockEntity1);
|
|
|
+ //公猪存栏
|
|
|
+ ProdStockEntity stockEntity2 = new ProdStockEntity();
|
|
|
+ stockEntity2.setFarmId(farmId);
|
|
|
+ stockEntity2.setStockType("boar_stock");
|
|
|
+ stockEntity2.setStockName("公猪存栏");
|
|
|
+ stockEntity2.setStockQuantity(dataJo.getString("gz"));
|
|
|
+ stockEntity2.setRate(Float.parseFloat(mathUtil.countRate(gz,total,1)));
|
|
|
+ stockEntity2.setMonth(Integer.valueOf(month));
|
|
|
+ stockEntity2.setYear(Integer.parseInt(year));
|
|
|
+ prodStockRepo.saveAndFlush(stockEntity2);
|
|
|
+ //哺乳猪存栏/仔猪存栏
|
|
|
+ ProdStockEntity stockEntity3 = new ProdStockEntity();
|
|
|
+ stockEntity3.setFarmId(farmId);
|
|
|
+ stockEntity3.setStockType("grice_stock");
|
|
|
+ stockEntity3.setStockName("哺乳猪存栏");
|
|
|
+ stockEntity3.setStockQuantity(dataJo.getString("zz"));
|
|
|
+ stockEntity3.setRate(Float.parseFloat(mathUtil.countRate(zz,total,1)));
|
|
|
+ stockEntity3.setMonth(Integer.valueOf(month));
|
|
|
+ stockEntity3.setYear(Integer.parseInt(year));
|
|
|
+ prodStockRepo.saveAndFlush(stockEntity3);
|
|
|
+ //保育猪存栏
|
|
|
+ ProdStockEntity stockEntity4 = new ProdStockEntity();
|
|
|
+ stockEntity4.setFarmId(farmId);
|
|
|
+ stockEntity4.setStockType("piglet_stock");
|
|
|
+ stockEntity4.setStockName("保育猪存栏");
|
|
|
+ stockEntity4.setStockQuantity(dataJo.getString("by"));
|
|
|
+ stockEntity4.setRate(Float.parseFloat(mathUtil.countRate(by,total,1)));
|
|
|
+ stockEntity4.setMonth(Integer.valueOf(month));
|
|
|
+ stockEntity4.setYear(Integer.parseInt(year));
|
|
|
+ prodStockRepo.saveAndFlush(stockEntity4);
|
|
|
+ //育肥猪存栏
|
|
|
+ ProdStockEntity stockEntity5 = new ProdStockEntity();
|
|
|
+ stockEntity5.setFarmId(farmId);
|
|
|
+ stockEntity5.setStockType("fatpig_stock");
|
|
|
+ stockEntity5.setStockName("育肥猪存栏");
|
|
|
+ stockEntity5.setStockQuantity(dataJo.getString("yf"));
|
|
|
+ stockEntity5.setRate(Float.parseFloat(mathUtil.countRate(yf,total,1)));
|
|
|
+ stockEntity5.setMonth(Integer.valueOf(month));
|
|
|
+ stockEntity5.setYear(Integer.parseInt(year));
|
|
|
+ prodStockRepo.saveAndFlush(stockEntity5);
|
|
|
+ //总存栏
|
|
|
+ ProdStockEntity stockEntity6 = new ProdStockEntity();
|
|
|
+ stockEntity6.setFarmId(farmId);
|
|
|
+ stockEntity6.setStockType("total_stock");
|
|
|
+ stockEntity6.setStockName("总存栏");
|
|
|
+ stockEntity6.setStockQuantity(String.valueOf(total));
|
|
|
+ stockEntity6.setMonth(Integer.valueOf(month));
|
|
|
+ stockEntity6.setYear(Integer.parseInt(year));
|
|
|
+ prodStockRepo.saveAndFlush(stockEntity6);
|
|
|
+
|
|
|
+ //妊娠
|
|
|
+ ProdStockEntity stockEntity7 = new ProdStockEntity();
|
|
|
+ stockEntity7.setFarmId(farmId);
|
|
|
+ stockEntity7.setStockType("sow_stock_1");
|
|
|
+ stockEntity7.setStockName("妊娠");
|
|
|
+ stockEntity7.setStockQuantity(String.valueOf(dataJo.getInteger("rs")));
|
|
|
+ stockEntity7.setMonth(Integer.valueOf(month));
|
|
|
+ stockEntity7.setYear(Integer.parseInt(year));
|
|
|
+ prodStockRepo.saveAndFlush(stockEntity7);
|
|
|
+ //哺乳
|
|
|
+ ProdStockEntity stockEntity8 = new ProdStockEntity();
|
|
|
+ stockEntity8.setFarmId(farmId);
|
|
|
+ stockEntity8.setStockType("sow_stock_2");
|
|
|
+ stockEntity8.setStockName("哺乳");
|
|
|
+ stockEntity8.setStockQuantity(String.valueOf(dataJo.getInteger("br")));
|
|
|
+ stockEntity8.setMonth(Integer.valueOf(month));
|
|
|
+ stockEntity8.setYear(Integer.parseInt(year));
|
|
|
+ prodStockRepo.saveAndFlush(stockEntity8);
|
|
|
+ //空怀
|
|
|
+ ProdStockEntity stockEntity9 = new ProdStockEntity();
|
|
|
+ stockEntity9.setFarmId(farmId);
|
|
|
+ stockEntity9.setStockType("sow_stock_3");
|
|
|
+ stockEntity9.setStockName("空怀");
|
|
|
+ stockEntity9.setStockQuantity(String.valueOf(dataJo.getInteger("kh")));
|
|
|
+ stockEntity9.setMonth(Integer.valueOf(month));
|
|
|
+ stockEntity9.setYear(Integer.parseInt(year));
|
|
|
+ prodStockRepo.saveAndFlush(stockEntity9);
|
|
|
+ //返情
|
|
|
+
|
|
|
+ //后备
|
|
|
+ ProdStockEntity stockEntity10 = new ProdStockEntity();
|
|
|
+ stockEntity10.setFarmId(farmId);
|
|
|
+ stockEntity10.setStockType("sow_stock_5");
|
|
|
+ stockEntity10.setStockName("后备");
|
|
|
+ stockEntity10.setStockQuantity(String.valueOf(dataJo.getInteger("hb")));
|
|
|
+ stockEntity10.setMonth(Integer.valueOf(month));
|
|
|
+ stockEntity10.setYear(Integer.parseInt(year));
|
|
|
+ prodStockRepo.saveAndFlush(stockEntity10);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
log.info("取数失败");
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
log.info("取数失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ //读取ERP数据中对应的名称
|
|
|
+ private int _getFarmId2(String pigfarm, List<ProdFarmNameEntity> farmNameEntityList) {
|
|
|
+ System.out.println("pigfarm=" + pigfarm);
|
|
|
+ //
|
|
|
+ int farmId = 0;
|
|
|
+ boolean isExist = false;
|
|
|
+ for (ProdFarmNameEntity prodFarmNameEntity : farmNameEntityList) {
|
|
|
+ if (prodFarmNameEntity.getErpShortName() != null && prodFarmNameEntity.getErpShortName().equalsIgnoreCase(pigfarm)) {
|
|
|
+ farmId = prodFarmNameEntity.getFarmId();
|
|
|
+ isExist = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isExist) {
|
|
|
+ log.info("牧场简称‘" + pigfarm + "’在prod_farm_name表中不存在对应的数据.");
|
|
|
+ }
|
|
|
+ return farmId;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void getCostWithManyFarm() throws IOException {
|
|
|
//
|
|
@@ -537,44 +687,43 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
timeoutMap.put("connectTimeout", 120000);
|
|
|
timeoutMap.put("requestTimeout", 120000);
|
|
|
timeoutMap.put("socketTimeout", 120000);
|
|
|
- String url = apiIp + apiPort + serviceName +"/getCostWithManyFarm";
|
|
|
- log.info("获取多个牧场的成本数据访问地址="+url);
|
|
|
- log.info("业务请求参数="+paramsMap.toString());
|
|
|
- log.info("超时参数="+timeoutMap.toString());
|
|
|
- log.info("开始取数="+new Date(System.currentTimeMillis()));
|
|
|
+ String url = apiIp + apiPort + serviceName + "/getCostWithManyFarm";
|
|
|
+ log.info("获取多个牧场的成本数据访问地址=" + url);
|
|
|
+ log.info("业务请求参数=" + paramsMap.toString());
|
|
|
+ log.info("超时参数=" + timeoutMap.toString());
|
|
|
+ log.info("开始取数=" + new Date(System.currentTimeMillis()));
|
|
|
//
|
|
|
- JSONObject outJo = httpClientUtil.doGet(url,paramsMap,timeoutMap);
|
|
|
- log.info("返回结果="+outJo);
|
|
|
- log.info("结束取数="+new Date(System.currentTimeMillis()));
|
|
|
- if(outJo.getBoolean("status")){
|
|
|
+ JSONObject outJo = httpClientUtil.doGet(url, paramsMap, timeoutMap);
|
|
|
+ log.info("返回结果=" + outJo);
|
|
|
+ log.info("结束取数=" + new Date(System.currentTimeMillis()));
|
|
|
+ if (outJo.getBoolean("status")) {
|
|
|
JSONObject contentJo = outJo.getJSONObject("content");
|
|
|
- if(contentJo.getBoolean("success")){
|
|
|
+ if (contentJo.getBoolean("success")) {
|
|
|
JSONArray dataJa = contentJo.getJSONArray("data");
|
|
|
- if(dataJa.size()==0){
|
|
|
+ if (dataJa.size() == 0) {
|
|
|
log.info("未取到数据 。");
|
|
|
}
|
|
|
// 添加入库
|
|
|
- for(int a=0;a<dataJa.size();a++){
|
|
|
+ for (int a = 0; a < dataJa.size(); a++) {
|
|
|
JSONObject dataJo = dataJa.getJSONObject(a);
|
|
|
- System.out.println((a+1)+" "+dataJo);
|
|
|
+ System.out.println((a + 1) + " " + dataJo);
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
System.out.println("取数失败");
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
System.out.println("取数失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @Method : getWarningMessage
|
|
|
- * @Description :
|
|
|
- * @Params : []
|
|
|
- * @Return : void
|
|
|
- *
|
|
|
- * @Author : ZhuoNing
|
|
|
- * @Date : 2021/11/19
|
|
|
- * @Time : 15:48
|
|
|
+ * @Method : getWarningMessage
|
|
|
+ * @Description :
|
|
|
+ * @Params : []
|
|
|
+ * @Return : void
|
|
|
+ * @Author : ZhuoNing
|
|
|
+ * @Date : 2021/11/19
|
|
|
+ * @Time : 15:48
|
|
|
*/
|
|
|
@Override
|
|
|
public void getWarningMessage() throws IOException, ParseException {
|
|
@@ -588,20 +737,20 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
timeoutMap.put("connectTimeout", 120000);
|
|
|
timeoutMap.put("requestTimeout", 120000);
|
|
|
timeoutMap.put("socketTimeout", 120000);
|
|
|
- String url = apiIp + apiPort + serviceName +"/getWarningMessage";
|
|
|
- log.info("获取预警数据访问地址="+url);
|
|
|
- log.info("业务请求参数="+paramsMap.toString());
|
|
|
- log.info("超时参数="+timeoutMap.toString());
|
|
|
- log.info("开始取数="+new Date(System.currentTimeMillis()));
|
|
|
+ String url = apiIp + apiPort + serviceName + "/getWarningMessage";
|
|
|
+ log.info("获取预警数据访问地址=" + url);
|
|
|
+ log.info("业务请求参数=" + paramsMap.toString());
|
|
|
+ log.info("超时参数=" + timeoutMap.toString());
|
|
|
+ log.info("开始取数=" + new Date(System.currentTimeMillis()));
|
|
|
//
|
|
|
- JSONObject outJo = httpClientUtil.doGet(url,paramsMap,timeoutMap);
|
|
|
- log.info("返回结果="+outJo);
|
|
|
- log.info("结束取数="+new Date(System.currentTimeMillis()));
|
|
|
- if(outJo.getBoolean("status")){
|
|
|
+ JSONObject outJo = httpClientUtil.doGet(url, paramsMap, timeoutMap);
|
|
|
+// log.info("返回结果="+outJo);
|
|
|
+ log.info("结束取数=" + new Date(System.currentTimeMillis()));
|
|
|
+ if (outJo.getBoolean("status")) {
|
|
|
JSONObject contentJo = outJo.getJSONObject("content");
|
|
|
- if(contentJo.getBoolean("success")){
|
|
|
+ if (contentJo.getBoolean("success")) {
|
|
|
JSONArray dataJa = contentJo.getJSONArray("data");
|
|
|
- if(dataJa.size()==0){
|
|
|
+ if (dataJa.size() == 0) {
|
|
|
log.info("未取到数据 。");
|
|
|
}
|
|
|
//删除当天旧数据
|
|
@@ -609,39 +758,62 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
delWarningMsgEntity.setAddTime(dateUtil.getTodayDate());
|
|
|
Example<ProdWarningMsgEntity> example = Example.of(delWarningMsgEntity);
|
|
|
warningMsgRepo.deleteAll(warningMsgRepo.findAll(example));
|
|
|
-
|
|
|
+ //获取牧场所有名称数据
|
|
|
+ List<ProdFarmNameEntity> farmNameEntityList = prodFarmNameRepo.findAll();
|
|
|
+ for (ProdFarmNameEntity farmNameEntity : farmNameEntityList) {
|
|
|
+ System.out.println("" + farmNameEntity.toString());
|
|
|
+ }
|
|
|
// 添加入库
|
|
|
- for(int a=0;a<dataJa.size();a++){
|
|
|
+ for (int a = 0; a < dataJa.size(); a++) {
|
|
|
JSONObject dataJo = dataJa.getJSONObject(a);
|
|
|
String content = dataJo.getString("xxnr").trim();
|
|
|
String[] contentArray = content.split("-");
|
|
|
String pigfarm = "";
|
|
|
String message = "";
|
|
|
- if(contentArray.length>=2){
|
|
|
+ if (contentArray.length >= 2) {
|
|
|
pigfarm = contentArray[0];
|
|
|
- message = content.replace(pigfarm+"-","").trim();
|
|
|
- }else{
|
|
|
- pigfarm = content.substring(0,3);
|
|
|
- message= content.substring(3,content.length());;
|
|
|
+ message = content.replace(pigfarm + "-", "").trim();
|
|
|
+ } else {
|
|
|
+ pigfarm = content.substring(0, 3);
|
|
|
+ message = content.substring(3, content.length());
|
|
|
}
|
|
|
// System.out.println((a+1)+" "+dateUtil.formatDateTime(dataJo.getString("tsrq"))+","+pigfarm+","+message+" length="+contentArray.length);
|
|
|
ProdWarningMsgEntity newWarningMsgEntity = new ProdWarningMsgEntity();
|
|
|
newWarningMsgEntity.setTipTime(dateUtil.formatDateTime(dataJo.getString("tsrq")));
|
|
|
newWarningMsgEntity.setFarmName(pigfarm);
|
|
|
newWarningMsgEntity.setWarningContent(message);
|
|
|
- newWarningMsgEntity.setFarmId(0);
|
|
|
+ newWarningMsgEntity.setFarmId(_getFarmId(pigfarm, farmNameEntityList));
|
|
|
newWarningMsgEntity.setAddTime(new Timestamp(new Date().getTime()));
|
|
|
newWarningMsgEntity.setHandleState(0);
|
|
|
ProdWarningMsgEntity outWarningMsgEntity = warningMsgRepo.saveAndFlush(newWarningMsgEntity);
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
System.out.println("取数失败");
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
System.out.println("取数失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //读取ERP数据中对应的名称
|
|
|
+ private int _getFarmId(String pigfarm, List<ProdFarmNameEntity> farmNameEntityList) {
|
|
|
+ System.out.println("pigfarm=" + pigfarm);
|
|
|
+ //
|
|
|
+ int farmId = 0;
|
|
|
+ boolean isExist = false;
|
|
|
+ for (ProdFarmNameEntity prodFarmNameEntity : farmNameEntityList) {
|
|
|
+ if (prodFarmNameEntity.getErpShortName() != null && prodFarmNameEntity.getErpShortName().indexOf(pigfarm) != -1) {
|
|
|
+ farmId = prodFarmNameEntity.getFarmId();
|
|
|
+ isExist = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isExist) {
|
|
|
+ log.info("牧场简称‘" + pigfarm + "’在prod_farm_name表中不存在对应的数据.");
|
|
|
+ }
|
|
|
+ return farmId;
|
|
|
+ }
|
|
|
+
|
|
|
/* public static void main(String[] args) {
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
|