|
@@ -13,6 +13,7 @@ import com.huimv.production.autoGetData.service.IAutoGetErpData;
|
|
import com.huimv.production.autoGetData.utils.HttpTemplete;
|
|
import com.huimv.production.autoGetData.utils.HttpTemplete;
|
|
import com.huimv.production.autoGetData.utils.MathUtil;
|
|
import com.huimv.production.autoGetData.utils.MathUtil;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.tomcat.jni.Time;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.data.domain.Example;
|
|
import org.springframework.data.domain.Example;
|
|
@@ -26,6 +27,7 @@ import java.text.ParseException;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
import static org.apache.tomcat.jni.Time.now;
|
|
import static org.apache.tomcat.jni.Time.now;
|
|
|
|
+import static org.apache.tomcat.jni.Time.sleep;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Project : huimv.shiwan
|
|
* @Project : huimv.shiwan
|
|
@@ -875,13 +877,23 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
int by = dataJo.getInteger("by");
|
|
int by = dataJo.getInteger("by");
|
|
int yf = dataJo.getInteger("yf");
|
|
int yf = dataJo.getInteger("yf");
|
|
int total = mz + gz + zz + by + yf;
|
|
int total = mz + gz + zz + by + yf;
|
|
|
|
+ System.out.println("mz="+mz);
|
|
|
|
+ System.out.println("gz="+gz);
|
|
|
|
+ System.out.println("zz="+zz);
|
|
|
|
+ System.out.println("by="+by);
|
|
|
|
+ System.out.println("yf="+yf);
|
|
|
|
+ System.out.println("total="+total);
|
|
//母猪存栏
|
|
//母猪存栏
|
|
ProdStockEntity stockEntity1 = new ProdStockEntity();
|
|
ProdStockEntity stockEntity1 = new ProdStockEntity();
|
|
stockEntity1.setFarmId(farmId);
|
|
stockEntity1.setFarmId(farmId);
|
|
stockEntity1.setStockType("sow_stock");
|
|
stockEntity1.setStockType("sow_stock");
|
|
stockEntity1.setStockName("母猪存栏");
|
|
stockEntity1.setStockName("母猪存栏");
|
|
stockEntity1.setStockQuantity(dataJo.getString("mz"));
|
|
stockEntity1.setStockQuantity(dataJo.getString("mz"));
|
|
- stockEntity1.setRate(Float.parseFloat(mathUtil.countRate(mz, total, 1)));
|
|
|
|
|
|
+ if(total == 0){
|
|
|
|
+ stockEntity1.setRate(Float.parseFloat("0"));
|
|
|
|
+ }else{
|
|
|
|
+ stockEntity1.setRate(Float.parseFloat(mathUtil.countRate(mz, total, 1)));
|
|
|
|
+ }
|
|
stockEntity1.setMonth(Integer.valueOf(month));
|
|
stockEntity1.setMonth(Integer.valueOf(month));
|
|
stockEntity1.setYear(Integer.parseInt(year));
|
|
stockEntity1.setYear(Integer.parseInt(year));
|
|
prodStockRepo.saveAndFlush(stockEntity1);
|
|
prodStockRepo.saveAndFlush(stockEntity1);
|
|
@@ -891,7 +903,11 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
stockEntity2.setStockType("boar_stock");
|
|
stockEntity2.setStockType("boar_stock");
|
|
stockEntity2.setStockName("公猪存栏");
|
|
stockEntity2.setStockName("公猪存栏");
|
|
stockEntity2.setStockQuantity(dataJo.getString("gz"));
|
|
stockEntity2.setStockQuantity(dataJo.getString("gz"));
|
|
- stockEntity2.setRate(Float.parseFloat(mathUtil.countRate(gz, total, 1)));
|
|
|
|
|
|
+ if(total == 0){
|
|
|
|
+ stockEntity2.setRate(Float.parseFloat("0"));
|
|
|
|
+ }else{
|
|
|
|
+ stockEntity2.setRate(Float.parseFloat(mathUtil.countRate(gz, total, 1)));
|
|
|
|
+ }
|
|
stockEntity2.setMonth(Integer.valueOf(month));
|
|
stockEntity2.setMonth(Integer.valueOf(month));
|
|
stockEntity2.setYear(Integer.parseInt(year));
|
|
stockEntity2.setYear(Integer.parseInt(year));
|
|
prodStockRepo.saveAndFlush(stockEntity2);
|
|
prodStockRepo.saveAndFlush(stockEntity2);
|
|
@@ -901,7 +917,11 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
stockEntity3.setStockType("grice_stock");
|
|
stockEntity3.setStockType("grice_stock");
|
|
stockEntity3.setStockName("哺乳猪存栏");
|
|
stockEntity3.setStockName("哺乳猪存栏");
|
|
stockEntity3.setStockQuantity(dataJo.getString("zz"));
|
|
stockEntity3.setStockQuantity(dataJo.getString("zz"));
|
|
- stockEntity3.setRate(Float.parseFloat(mathUtil.countRate(zz, total, 1)));
|
|
|
|
|
|
+ if(total == 0){
|
|
|
|
+ stockEntity3.setRate(Float.parseFloat("0"));
|
|
|
|
+ }else{
|
|
|
|
+ stockEntity3.setRate(Float.parseFloat(mathUtil.countRate(zz, total, 1)));
|
|
|
|
+ }
|
|
stockEntity3.setMonth(Integer.valueOf(month));
|
|
stockEntity3.setMonth(Integer.valueOf(month));
|
|
stockEntity3.setYear(Integer.parseInt(year));
|
|
stockEntity3.setYear(Integer.parseInt(year));
|
|
prodStockRepo.saveAndFlush(stockEntity3);
|
|
prodStockRepo.saveAndFlush(stockEntity3);
|
|
@@ -911,7 +931,11 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
stockEntity4.setStockType("piglet_stock");
|
|
stockEntity4.setStockType("piglet_stock");
|
|
stockEntity4.setStockName("保育猪存栏");
|
|
stockEntity4.setStockName("保育猪存栏");
|
|
stockEntity4.setStockQuantity(dataJo.getString("by"));
|
|
stockEntity4.setStockQuantity(dataJo.getString("by"));
|
|
- stockEntity4.setRate(Float.parseFloat(mathUtil.countRate(by, total, 1)));
|
|
|
|
|
|
+ if(total == 0){
|
|
|
|
+ stockEntity4.setRate(Float.parseFloat("0"));
|
|
|
|
+ }else{
|
|
|
|
+ stockEntity4.setRate(Float.parseFloat(mathUtil.countRate(by, total, 1)));
|
|
|
|
+ }
|
|
stockEntity4.setMonth(Integer.valueOf(month));
|
|
stockEntity4.setMonth(Integer.valueOf(month));
|
|
stockEntity4.setYear(Integer.parseInt(year));
|
|
stockEntity4.setYear(Integer.parseInt(year));
|
|
prodStockRepo.saveAndFlush(stockEntity4);
|
|
prodStockRepo.saveAndFlush(stockEntity4);
|
|
@@ -921,7 +945,11 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
stockEntity5.setStockType("fatpig_stock");
|
|
stockEntity5.setStockType("fatpig_stock");
|
|
stockEntity5.setStockName("育肥猪存栏");
|
|
stockEntity5.setStockName("育肥猪存栏");
|
|
stockEntity5.setStockQuantity(dataJo.getString("yf"));
|
|
stockEntity5.setStockQuantity(dataJo.getString("yf"));
|
|
- stockEntity5.setRate(Float.parseFloat(mathUtil.countRate(yf, total, 1)));
|
|
|
|
|
|
+ if(total == 0){
|
|
|
|
+ stockEntity5.setRate(Float.parseFloat("0"));
|
|
|
|
+ }else{
|
|
|
|
+ stockEntity5.setRate(Float.parseFloat(mathUtil.countRate(yf, total, 1)));
|
|
|
|
+ }
|
|
stockEntity5.setMonth(Integer.valueOf(month));
|
|
stockEntity5.setMonth(Integer.valueOf(month));
|
|
stockEntity5.setYear(Integer.parseInt(year));
|
|
stockEntity5.setYear(Integer.parseInt(year));
|
|
prodStockRepo.saveAndFlush(stockEntity5);
|
|
prodStockRepo.saveAndFlush(stockEntity5);
|
|
@@ -1403,7 +1431,108 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void getManyFarmPsy() throws IOException {
|
|
|
|
|
|
+ public void testGetManyFarmPsy() throws IOException {
|
|
|
|
+ //
|
|
|
|
+ Map timeoutMap = httpClientUtil.setTimeout(connectTimeout, requestTimeout, socketTimeout);
|
|
|
|
+ //
|
|
|
|
+ String token = getRemoteToken();
|
|
|
|
+ Map<String, String> paramsMap = new HashMap<String, String>();
|
|
|
|
+ paramsMap.put("accessToken", token);
|
|
|
|
+ paramsMap.put("startDate", dateUtil.getStartDateInThisMonth());
|
|
|
|
+ paramsMap.put("endDate", dateUtil.getEndDateInThisMonth());
|
|
|
|
+
|
|
|
|
+ //嘉兴秀洲青莲农业科技有限公司
|
|
|
|
+ System.out.println("嘉兴秀洲青莲农业科技有限公司");
|
|
|
|
+ paramsMap.put("farmID", "8466682B-0B55-4139-A5BE-AC3BB1DA9A45");
|
|
|
|
+ System.out.println(">>"+paramsMap);
|
|
|
|
+ System.out.println("返回结果>>" + httpClientUtil.doGet(apiIp + apiPort + serviceName + "/getPsy", paramsMap));
|
|
|
|
+// 空
|
|
|
|
+
|
|
|
|
+ //海盐曙光
|
|
|
|
+ System.out.println("海盐曙光");
|
|
|
|
+ paramsMap.put("farmID", "31025DA4-F9E1-46B8-BF38-5F2FA25E9C07");
|
|
|
|
+ System.out.println(">>"+paramsMap);
|
|
|
|
+ System.out.println("返回结果>>" + httpClientUtil.doGet(apiIp + apiPort + serviceName + "/getPsy", paramsMap));
|
|
|
|
+ //{"content":"{\"success\":true,\"code\":10000,\"message\":\"操作成功!\",\"data\":\"26.10\"}","status":true}
|
|
|
|
+
|
|
|
|
+ //嘉兴青莲王江泾农业发展有限公司
|
|
|
|
+ System.out.println("嘉兴青莲王江泾农业发展有限公司");
|
|
|
|
+ paramsMap.put("farmID", "F7F05931-84E8-4983-89FE-5F967C35BF51");
|
|
|
|
+ System.out.println(">>"+paramsMap);
|
|
|
|
+ System.out.println("返回结果>>" + httpClientUtil.doGet(apiIp + apiPort + serviceName + "/getPsy", paramsMap));
|
|
|
|
+ //空
|
|
|
|
+ //{"content":"{\"success\":true,\"code\":10000,\"message\":\"操作成功!\",\"data\":\"\"}","status":true}
|
|
|
|
+
|
|
|
|
+ //嘉兴青莲黑猪原种场
|
|
|
|
+ System.out.println("嘉兴青莲黑猪原种场");
|
|
|
|
+ paramsMap.put("farmID", "1F0F0044-715F-4854-9F57-82ED69EB21C9");
|
|
|
|
+ System.out.println(">>"+paramsMap);
|
|
|
|
+ System.out.println("返回结果>>" + httpClientUtil.doGet(apiIp + apiPort + serviceName + "/getPsy", paramsMap));
|
|
|
|
+// 空
|
|
|
|
+ //{"content":"{\"success\":true,\"code\":10000,\"message\":\"操作成功!\",\"data\":\"\"}","status":true}
|
|
|
|
+
|
|
|
|
+ //武义本生二农业开发有限公司
|
|
|
|
+ System.out.println("武义本生二农业开发有限公司");
|
|
|
|
+ paramsMap.put("farmID", "49C5ECC5-3B66-4851-84B8-C2E5179ACAC5");
|
|
|
|
+ System.out.println(">>"+paramsMap);
|
|
|
|
+ System.out.println("返回结果>>" + httpClientUtil.doGet(apiIp + apiPort + serviceName + "/getPsy", paramsMap));
|
|
|
|
+ //空
|
|
|
|
+ //{"content":"{\"success\":true,\"code\":10000,\"message\":\"操作成功!\",\"data\":\"\"}","status":true}
|
|
|
|
+
|
|
|
|
+// //兰溪市益品生态农牧发展有限公司
|
|
|
|
+ System.out.println("兰溪市益品生态农牧发展有限公司");
|
|
|
|
+ paramsMap.put("farmID", "583659FD-FEAE-4684-B21B-7A1BB20210AB");
|
|
|
|
+ System.out.println(">>"+paramsMap);
|
|
|
|
+ System.out.println("返回结果>>" + httpClientUtil.doGet(apiIp + apiPort + serviceName + "/getPsy", paramsMap));
|
|
|
|
+ //空
|
|
|
|
+ //{"content":"{\"success\":true,\"code\":10000,\"message\":\"操作成功!\",\"data\":\"\"}","status":true}
|
|
|
|
+
|
|
|
|
+ //武义本生农业开发有限公司
|
|
|
|
+ System.out.println("武义本生农业开发有限公司");
|
|
|
|
+ paramsMap.put("farmID", "5D8527E1-10B7-49D0-B89A-2A9D88010D31");
|
|
|
|
+ System.out.println(">>"+paramsMap);
|
|
|
|
+ System.out.println("返回结果>>" + httpClientUtil.doGet(apiIp + apiPort + serviceName + "/getPsy", paramsMap));
|
|
|
|
+ //空
|
|
|
|
+ //{"content":"{\"success\":true,\"code\":10000,\"message\":\"操作成功!\",\"data\":\"\"}","status":true}
|
|
|
|
+
|
|
|
|
+ //浙江盼达农业科技有限公司
|
|
|
|
+ System.out.println("浙江盼达农业科技有限公司");
|
|
|
|
+ paramsMap.put("farmID", "C6AD1371-64C5-4CC1-B236-FCCD2E83BF08");
|
|
|
|
+ System.out.println(">>"+paramsMap);
|
|
|
|
+ System.out.println("返回结果>>" + httpClientUtil.doGet(apiIp + apiPort + serviceName + "/getPsy", paramsMap));
|
|
|
|
+ //空
|
|
|
|
+ //{"content":"{\"success\":true,\"code\":10000,\"message\":\"操作成功!\",\"data\":\"\"}","status":true}
|
|
|
|
+
|
|
|
|
+ //浙江茶香牧业有限公司
|
|
|
|
+ System.out.println("浙江茶香牧业有限公司");
|
|
|
|
+ paramsMap.put("farmID", "CE8B6155-FCE2-453F-A4E6-EBBB012298F0");
|
|
|
|
+ System.out.println(">>"+paramsMap);
|
|
|
|
+ System.out.println("返回结果>>" + httpClientUtil.doGet(apiIp + apiPort + serviceName + "/getPsy", paramsMap));
|
|
|
|
+ //空
|
|
|
|
+ //{"content":"{\"success\":true,\"code\":10000,\"message\":\"操作成功!\",\"data\":\"\"}","status":true}
|
|
|
|
+
|
|
|
|
+ //海盐海兴
|
|
|
|
+ System.out.println("海盐海兴");
|
|
|
|
+ paramsMap.put("farmID", "FE9D5092-0113-48AE-884B-51205B474391");
|
|
|
|
+ System.out.println(">>"+paramsMap);
|
|
|
|
+ System.out.println("返回结果>>" + httpClientUtil.doGet(apiIp + apiPort + serviceName + "/getPsy", paramsMap));
|
|
|
|
+ //空
|
|
|
|
+ //{"content":"{\"success\":true,\"code\":10000,\"message\":\"操作成功!\",\"data\":\"\"}","status":true}
|
|
|
|
+
|
|
|
|
+ //昆山青莲梅山生猪养殖有限公司
|
|
|
|
+ System.out.println("昆山青莲梅山生猪养殖有限公司");
|
|
|
|
+ paramsMap.put("farmID", "48577FA9-3B7F-4974-BA1F-73026C885F62");
|
|
|
|
+ System.out.println(">>"+paramsMap);
|
|
|
|
+ System.out.println("返回结果>>" + httpClientUtil.doGet(apiIp + apiPort + serviceName + "/getPsy", paramsMap));
|
|
|
|
+ //空
|
|
|
|
+ //{"content":"{\"success\":true,\"code\":10000,\"message\":\"操作成功!\",\"data\":\"\"}","status":true}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void getManyFarmPsy() throws IOException, InterruptedException {
|
|
//
|
|
//
|
|
Map timeoutMap = httpClientUtil.setTimeout(connectTimeout, requestTimeout, socketTimeout);
|
|
Map timeoutMap = httpClientUtil.setTimeout(connectTimeout, requestTimeout, socketTimeout);
|
|
//
|
|
//
|
|
@@ -1413,15 +1542,21 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
|
|
|
//查询所有记录
|
|
//查询所有记录
|
|
List<ProdFarmNameEntity> farmNameEntityList = prodFarmNameRepo.findAll();
|
|
List<ProdFarmNameEntity> farmNameEntityList = prodFarmNameRepo.findAll();
|
|
|
|
+
|
|
|
|
+ Map<String, String> paramsMap = new HashMap<String, String>();
|
|
|
|
+ paramsMap.put("accessToken", token);
|
|
|
|
+
|
|
|
|
+ paramsMap.put("startDate", dateUtil.getStartDateInThisMonth());
|
|
|
|
+ paramsMap.put("endDate", dateUtil.getEndDateInThisMonth());
|
|
|
|
+
|
|
|
|
+
|
|
JSONArray psyJa = new JSONArray();
|
|
JSONArray psyJa = new JSONArray();
|
|
for(ProdFarmNameEntity farmNameEntity:farmNameEntityList){
|
|
for(ProdFarmNameEntity farmNameEntity:farmNameEntityList){
|
|
if(null != farmNameEntity.getErpFarmId()){
|
|
if(null != farmNameEntity.getErpFarmId()){
|
|
|
|
+// Thread.sleep(5000);
|
|
//
|
|
//
|
|
- Map<String, String> paramsMap = new HashMap<String, String>();
|
|
|
|
- paramsMap.put("accessToken", token);
|
|
|
|
paramsMap.put("farmID", farmNameEntity.getErpFarmId());
|
|
paramsMap.put("farmID", farmNameEntity.getErpFarmId());
|
|
- paramsMap.put("startDate", dateUtil.getStartDateInThisMonth());
|
|
|
|
- paramsMap.put("endDate", dateUtil.getEndDateInThisMonth());
|
|
|
|
|
|
+ System.out.println(""+farmNameEntity.getErpFarmName()+" , "+farmNameEntity.getErpFarmId());
|
|
|
|
|
|
String url = apiIp + apiPort + serviceName + "/getPsy";
|
|
String url = apiIp + apiPort + serviceName + "/getPsy";
|
|
log.info("销售数据接口访问地址=" + url);
|
|
log.info("销售数据接口访问地址=" + url);
|
|
@@ -1435,6 +1570,7 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
JSONObject contentJo = outJo.getJSONObject("content");
|
|
JSONObject contentJo = outJo.getJSONObject("content");
|
|
if (contentJo.getBoolean("success")) {
|
|
if (contentJo.getBoolean("success")) {
|
|
String psyData = contentJo.getString("data");
|
|
String psyData = contentJo.getString("data");
|
|
|
|
+ System.out.println(">>"+psyData);
|
|
if (null == psyData || psyData.trim().length()==0) {
|
|
if (null == psyData || psyData.trim().length()==0) {
|
|
log.info("未取到数据 。");
|
|
log.info("未取到数据 。");
|
|
} else {
|
|
} else {
|
|
@@ -1455,6 +1591,7 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
}
|
|
}
|
|
//关闭http连接资源
|
|
//关闭http连接资源
|
|
// httpClientUtil.closeHttpConn();
|
|
// httpClientUtil.closeHttpConn();
|
|
|
|
+ System.out.println("psyJa.size="+psyJa.size());
|
|
if(psyJa.size()>0){
|
|
if(psyJa.size()>0){
|
|
//
|
|
//
|
|
ProdProduceEntity delEntity = new ProdProduceEntity();
|
|
ProdProduceEntity delEntity = new ProdProduceEntity();
|
|
@@ -1553,7 +1690,8 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
addEntity1.setFarmId(newJo.getInteger("farm_id"));
|
|
addEntity1.setFarmId(newJo.getInteger("farm_id"));
|
|
addEntity1.setStockType("breed_rate");
|
|
addEntity1.setStockType("breed_rate");
|
|
addEntity1.setStockName("配种分娩率");
|
|
addEntity1.setStockName("配种分娩率");
|
|
- addEntity1.setStockQuantity(mathUtil.countRate(Float.parseFloat(newJo.getString("stock_quantity")),1));
|
|
|
|
|
|
+// addEntity1.setStockQuantity(mathUtil.countRate(Float.parseFloat(newJo.getString("stock_quantity")),1));
|
|
|
|
+ addEntity1.setStockQuantity(newJo.getString("stock_quantity"));
|
|
addEntity1.setMonth(Integer.valueOf(month));
|
|
addEntity1.setMonth(Integer.valueOf(month));
|
|
addEntity1.setYear(Integer.parseInt(year));
|
|
addEntity1.setYear(Integer.parseInt(year));
|
|
produceRepo.saveAndFlush(addEntity1);
|
|
produceRepo.saveAndFlush(addEntity1);
|