|
@@ -993,20 +993,25 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
return farmId;
|
|
|
}
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ProdCostStatisticsRepo costStatisticsRepo;
|
|
|
+
|
|
|
@Override
|
|
|
- public void getCostWithManyFarm() throws IOException {
|
|
|
+ public void getCostWithManyFarm() throws IOException, ParseException {
|
|
|
//
|
|
|
String token = getRemoteToken();
|
|
|
//
|
|
|
Map<String, String> paramsMap = new HashMap<String, String>();
|
|
|
paramsMap.put("accessToken", token);
|
|
|
- paramsMap.put("year", dateUtil.getThisYear());
|
|
|
- paramsMap.put("month", dateUtil.getThisMonth());
|
|
|
+// paramsMap.put("year", dateUtil.getThisYear());
|
|
|
+// paramsMap.put("month", dateUtil.getThisMonth());
|
|
|
+ paramsMap.put("year", "2021");
|
|
|
+ paramsMap.put("month", "8");
|
|
|
//
|
|
|
Map<String, Integer> timeoutMap = new HashMap<String, Integer>();
|
|
|
- timeoutMap.put("connectTimeout", 120000);
|
|
|
- timeoutMap.put("requestTimeout", 120000);
|
|
|
- timeoutMap.put("socketTimeout", 120000);
|
|
|
+ timeoutMap.put("connectTimeout", Integer.parseInt(connectTimeout));
|
|
|
+ timeoutMap.put("requestTimeout", Integer.parseInt(requestTimeout));
|
|
|
+ timeoutMap.put("socketTimeout", Integer.parseInt(socketTimeout));
|
|
|
String url = apiIp + apiPort + serviceName + "/getCostWithManyFarm";
|
|
|
log.info("获取多个牧场的成本数据访问地址=" + url);
|
|
|
log.info("业务请求参数=" + paramsMap.toString());
|
|
@@ -1022,11 +1027,33 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
JSONArray dataJa = contentJo.getJSONArray("data");
|
|
|
if (dataJa.size() == 0) {
|
|
|
log.info("未取到数据 。");
|
|
|
- }
|
|
|
- // 添加入库
|
|
|
- for (int a = 0; a < dataJa.size(); a++) {
|
|
|
- JSONObject dataJo = dataJa.getJSONObject(a);
|
|
|
- System.out.println((a + 1) + " " + dataJo);
|
|
|
+ }else {
|
|
|
+ //删除当天旧数据
|
|
|
+ ProdCostStatisticsEntity delCostStatisticsEntity = new ProdCostStatisticsEntity();
|
|
|
+ delCostStatisticsEntity.setAddDate(dateUtil.getTodayDate());
|
|
|
+ Example<ProdCostStatisticsEntity> example = Example.of(delCostStatisticsEntity);
|
|
|
+ costStatisticsRepo.deleteAll(costStatisticsRepo.findAll(example));
|
|
|
+
|
|
|
+ //获取牧场所有名称数据
|
|
|
+ List<ProdFarmNameEntity> farmNameEntityList = prodFarmNameRepo.findAll();
|
|
|
+ // 添加入库
|
|
|
+ for (int a = 0; a < dataJa.size(); a++) {
|
|
|
+ JSONObject dataJo = dataJa.getJSONObject(a);
|
|
|
+// System.out.println((a + 1) + " " + dataJo);
|
|
|
+ ProdCostStatisticsEntity costStatisticsEntity = new ProdCostStatisticsEntity();
|
|
|
+ costStatisticsEntity.setFarmName(dataJo.getString("mcmc"));
|
|
|
+ //牧场名称
|
|
|
+ costStatisticsEntity.setFarmId(_getFarmIdByShortName(dataJo.getString("mcmc"), farmNameEntityList));
|
|
|
+ costStatisticsEntity.setBaseGroup(dataJo.getString("jczq"));
|
|
|
+ costStatisticsEntity.setPigletGroup(dataJo.getString("byzq"));
|
|
|
+ costStatisticsEntity.setFattenPig(dataJo.getString("yf"));
|
|
|
+ costStatisticsEntity.setReplaceGilt(dataJo.getString("hb"));
|
|
|
+ costStatisticsEntity.setCommonCost(dataJo.getString("gtfy"));
|
|
|
+ costStatisticsEntity.setTotal(dataJo.getString("hj"));
|
|
|
+ costStatisticsEntity.setProjectName(dataJo.getString("xmmc"));
|
|
|
+ costStatisticsEntity.setAddDate(new java.util.Date());
|
|
|
+ costStatisticsRepo.save(costStatisticsEntity);
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
System.out.println("取数失败");
|
|
@@ -1080,9 +1107,9 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
warningMsgRepo.deleteAll(warningMsgRepo.findAll(example));
|
|
|
//获取牧场所有名称数据
|
|
|
List<ProdFarmNameEntity> farmNameEntityList = prodFarmNameRepo.findAll();
|
|
|
- for (ProdFarmNameEntity farmNameEntity : farmNameEntityList) {
|
|
|
- System.out.println("" + farmNameEntity.toString());
|
|
|
- }
|
|
|
+// for (ProdFarmNameEntity farmNameEntity : farmNameEntityList) {
|
|
|
+// System.out.println("" + farmNameEntity.toString());
|
|
|
+// }
|
|
|
// 添加入库
|
|
|
for (int a = 0; a < dataJa.size(); a++) {
|
|
|
JSONObject dataJo = dataJa.getJSONObject(a);
|