|
@@ -1756,6 +1756,236 @@ public class AutoGetErpDataImpl implements IAutoGetErpData {
|
|
|
|
|
|
}
|
|
|
|
|
|
+// @Override
|
|
|
+ public void getSalesMoney_old() throws ParseException, IOException {
|
|
|
+ //
|
|
|
+ Map timeoutMap = httpClientUtil.setTimeout(connectTimeout, requestTimeout, socketTimeout);
|
|
|
+ //
|
|
|
+ String token = getRemoteToken();
|
|
|
+ //
|
|
|
+ Map<String, String> paramsMap = new HashMap<String, String>();
|
|
|
+ paramsMap.put("accessToken", token);
|
|
|
+ String farmCode = "31025DA4-F9E1-46B8-BF38-5F2FA25E9C07";
|
|
|
+ paramsMap.put("farmCode", farmCode);
|
|
|
+
|
|
|
+// String url = apiIp + apiPort + serviceName + "/getSales";
|
|
|
+ String url = apiIp + apiPort + serviceName + "/getSalesTest";
|
|
|
+ log.info("销售数据接口访问地址=" + url);
|
|
|
+ log.info("业务请求参数=" + paramsMap.toString());
|
|
|
+ log.info("开始取数=" + new Date(System.currentTimeMillis()));
|
|
|
+ //
|
|
|
+ JSONObject outJo = httpClientUtil.doGet(url, paramsMap);
|
|
|
+// log.info("返回结果=" + outJo);
|
|
|
+ log.info("结束取数=" + new Date(System.currentTimeMillis()));
|
|
|
+ if (outJo.getBoolean("status")) {
|
|
|
+ JSONObject contentJo = outJo.getJSONObject("content");
|
|
|
+ if (contentJo.getBoolean("success")) {
|
|
|
+ JSONArray dataJa = contentJo.getJSONArray("data");
|
|
|
+ if (dataJa.size() == 0) {
|
|
|
+ log.info("未取到数据 。");
|
|
|
+ } else {
|
|
|
+ System.out.println("dataJa.size="+dataJa.size());
|
|
|
+ log.info("取回记录条数="+dataJa.size());
|
|
|
+ JSONArray saleJa = new JSONArray();
|
|
|
+ BigDecimal totalMoneyBg = new BigDecimal(0);
|
|
|
+ BigDecimal totalBg = new BigDecimal(0);
|
|
|
+ for(int a=0;a<dataJa.size();a++){
|
|
|
+ JSONObject dataJo = dataJa.getJSONObject(a);
|
|
|
+ System.out.println((a+1)+","+dataJo);
|
|
|
+// if(dataJo.getString("f16").trim().equalsIgnoreCase("海盐曙光") && dataJo.getString("f02").trim().indexOf(dateUtil.getThisMonthText()) !=-1){
|
|
|
+// if(dataJo.getString("f16").trim().equalsIgnoreCase("海盐曙光") && dataJo.getString("f02").trim().indexOf("2022-07-12") !=-1){
|
|
|
+// System.out.println((a+1)+" "+dataJo);
|
|
|
+ String saleMoney = "0";
|
|
|
+ if(dataJo.getString("f09") != null){
|
|
|
+ saleMoney = dataJo.getString("f09");
|
|
|
+ }
|
|
|
+ String total = "0";
|
|
|
+ if(dataJo.getString("f07") != null){
|
|
|
+ total = dataJo.getString("f07");
|
|
|
+ }
|
|
|
+ totalMoneyBg = totalMoneyBg.add(new BigDecimal(saleMoney));
|
|
|
+ totalBg = totalBg.add(new BigDecimal(total));
|
|
|
+ saleJa.add(dataJo);
|
|
|
+// }
|
|
|
+ }
|
|
|
+ log.info("符合条件的记录条数="+saleJa.size());
|
|
|
+ System.out.println("totalMoneyBg="+totalMoneyBg.toString());
|
|
|
+ System.out.println("totalBg="+totalBg.toString());
|
|
|
+
|
|
|
+// //删除旧数据
|
|
|
+// ProdSalesEntity delSalesEntity = new ProdSalesEntity();
|
|
|
+// delSalesEntity.setAddDate(dateUtil.getTodayDate());
|
|
|
+// Example<ProdSalesEntity> example = Example.of(delSalesEntity);
|
|
|
+// salesRepo.deleteAll(salesRepo.findAll(example));
|
|
|
+//
|
|
|
+// //获取牧场所有名称数据
|
|
|
+// List<ProdFarmNameEntity> farmNameEntityList = prodFarmNameRepo.findAll();
|
|
|
+// //获取牧场所有名称数据
|
|
|
+// for (int a = 0; a < dataJa.size(); a++) {
|
|
|
+// JSONObject dataJo = dataJa.getJSONObject(a);
|
|
|
+// System.out.println("dataJ>>" + dataJo);
|
|
|
+// ProdSalesEntity addSalesEntity = new ProdSalesEntity();
|
|
|
+// String farmName = dataJo.getString("farm_name");
|
|
|
+// addSalesEntity.setFarmName(farmName);
|
|
|
+// //
|
|
|
+// addSalesEntity.setFarmId(_getFarmIdByShortName(farmName, farmNameEntityList));
|
|
|
+// addSalesEntity.setTodayMoney(dataJo.getString("today_money"));
|
|
|
+// addSalesEntity.setTodayQuantity(dataJo.getString("today_quantity"));
|
|
|
+// addSalesEntity.setTodayWeight(dataJo.getString("today_weight"));
|
|
|
+// addSalesEntity.setWeekMoney(dataJo.getString("week_money"));
|
|
|
+// addSalesEntity.setWeekQuantity(dataJo.getString("week_quantity"));
|
|
|
+// addSalesEntity.setWeekWeight(dataJo.getString("week_weight"));
|
|
|
+// addSalesEntity.setMonthMoney(dataJo.getString("month_money"));
|
|
|
+// addSalesEntity.setMonthQuantity(dataJo.getString("month_quantity"));
|
|
|
+// addSalesEntity.setMonthWeight(dataJo.getString("month_weight"));
|
|
|
+// addSalesEntity.setAddDate(new Timestamp(new Date().getTime()));
|
|
|
+// salesRepo.save(addSalesEntity);
|
|
|
+// }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+// @Override
|
|
|
+ public void getSalesMoney_new1() throws ParseException, IOException {
|
|
|
+ //
|
|
|
+ Map timeoutMap = httpClientUtil.setTimeout(connectTimeout, requestTimeout, socketTimeout);
|
|
|
+ //
|
|
|
+ String token = getRemoteToken();
|
|
|
+
|
|
|
+ //查询所有记录
|
|
|
+ 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());
|
|
|
+
|
|
|
+ for (ProdFarmNameEntity farmNameEntity : farmNameEntityList) {
|
|
|
+ if (null != farmNameEntity.getErpFarmId()) {
|
|
|
+ System.out.println(""+farmNameEntity.getErpShortName());
|
|
|
+ //
|
|
|
+ paramsMap.put("farmID", farmNameEntity.getErpFarmId());
|
|
|
+ System.out.println("" + farmNameEntity.getErpFarmName() + " , " + farmNameEntity.getErpFarmId());
|
|
|
+ paramsMap.put("farmCode", farmNameEntity.getErpFarmId());
|
|
|
+ String url = apiIp + apiPort + serviceName + "/getSalesTest";
|
|
|
+ log.info("销售数据接口访问地址=" + url);
|
|
|
+ log.info("业务请求参数=" + paramsMap.toString());
|
|
|
+ log.info("开始取数=" + new Date(System.currentTimeMillis()));
|
|
|
+ //
|
|
|
+ JSONObject outJo = httpClientUtil.doGet(url, paramsMap);
|
|
|
+ log.info("返回结果>>" + outJo);
|
|
|
+ log.info("结束取数=" + new Date(System.currentTimeMillis()));
|
|
|
+ if (outJo.getBoolean("status")) {
|
|
|
+ JSONObject contentJo = outJo.getJSONObject("content");
|
|
|
+ if (contentJo.getBoolean("success")) {
|
|
|
+// String dataJa = contentJo.getString("data");
|
|
|
+ JSONArray dataJa = contentJo.getJSONArray("data");
|
|
|
+ System.out.println(">>" + dataJa);
|
|
|
+ if (dataJa.size() == 0) {
|
|
|
+ log.info("未取到数据 。");
|
|
|
+ } else {
|
|
|
+ JSONArray saleJa = new JSONArray();
|
|
|
+ BigDecimal totalBg = new BigDecimal(0);
|
|
|
+ BigDecimal totalMoneyBg = new BigDecimal(0);
|
|
|
+ for(int a=0;a<dataJa.size();a++){
|
|
|
+ JSONObject dataJo = dataJa.getJSONObject(a);
|
|
|
+ String saleMoney = "0";
|
|
|
+ if(dataJo.getString("f09") != null){
|
|
|
+ saleMoney = dataJo.getString("f09");
|
|
|
+ }
|
|
|
+ String total = "0";
|
|
|
+ if(dataJo.getString("f07") != null){
|
|
|
+ total = dataJo.getString("f07");
|
|
|
+ }
|
|
|
+ totalMoneyBg = totalMoneyBg.add(new BigDecimal(saleMoney));
|
|
|
+ totalBg = totalBg.add(new BigDecimal(total));
|
|
|
+ saleJa.add(dataJo);
|
|
|
+ }
|
|
|
+// }
|
|
|
+ System.out.println("totalMoneyBg="+totalMoneyBg.toString());
|
|
|
+ System.out.println("totalBg="+totalBg.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void getSalesMoney() throws ParseException, IOException {
|
|
|
+ //
|
|
|
+ Map timeoutMap = httpClientUtil.setTimeout(connectTimeout, requestTimeout, socketTimeout);
|
|
|
+ //
|
|
|
+ String token = getRemoteToken();
|
|
|
+ //查询所有记录
|
|
|
+ List<ProdFarmNameEntity> farmNameEntityList = prodFarmNameRepo.findAll();
|
|
|
+ Map<String, String> paramsMap = new HashMap<String, String>();
|
|
|
+ paramsMap.put("accessToken", token);
|
|
|
+ String todayText = dateUtil.getTodayDateText();
|
|
|
+ JSONArray saleJa = new JSONArray();
|
|
|
+ for (ProdFarmNameEntity farmNameEntity : farmNameEntityList) {
|
|
|
+ if (null != farmNameEntity.getErpFarmId()) {
|
|
|
+ System.out.println(""+farmNameEntity.getErpShortName());
|
|
|
+ //
|
|
|
+ paramsMap.put("farmID", farmNameEntity.getErpFarmId());
|
|
|
+ System.out.println("" + farmNameEntity.getErpFarmName() + " , " + farmNameEntity.getErpFarmId());
|
|
|
+ paramsMap.put("farmCode", farmNameEntity.getErpFarmId());
|
|
|
+ String url = apiIp + apiPort + serviceName + "/getSales2";
|
|
|
+ log.info("销售数据接口访问地址=" + url);
|
|
|
+ log.info("业务请求参数=" + paramsMap.toString());
|
|
|
+ log.info("开始取数=" + new Date(System.currentTimeMillis()));
|
|
|
+ //
|
|
|
+ JSONObject outJo = httpClientUtil.doGet(url, paramsMap);
|
|
|
+ log.info("返回结果>>" + outJo);
|
|
|
+ log.info("结束取数=" + new Date(System.currentTimeMillis()));
|
|
|
+ if (outJo.getBoolean("status")) {
|
|
|
+ JSONObject contentJo = outJo.getJSONObject("content");
|
|
|
+ if (contentJo.getBoolean("success")) {
|
|
|
+// String data = contentJo.getString("data");
|
|
|
+// JSONArray dataJa = contentJo.getJSONArray("data");
|
|
|
+ JSONObject dataJo = contentJo.getJSONObject("data");
|
|
|
+ if (dataJo.size() == 0) {
|
|
|
+ log.info("未取到数据 。");
|
|
|
+ } else {
|
|
|
+ String totalMoney = dataJo.getString("totalMoney");
|
|
|
+ String sum = dataJo.getString("sum");
|
|
|
+ System.out.println("farmId="+farmNameEntity.getFarmId());
|
|
|
+ System.out.println("todayText="+todayText);
|
|
|
+ System.out.println("totalMoney="+totalMoney);
|
|
|
+ System.out.println("sum="+sum);
|
|
|
+ dataJo.put("farmId",farmNameEntity.getFarmId());
|
|
|
+ dataJo.put("today",todayText);
|
|
|
+ saleJa.add(dataJo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+// ProdSalesEntity delSalesEntity = new ProdSalesEntity();
|
|
|
+// delSalesEntity.setAddDate(dateUtil.getTodayDate());
|
|
|
+// Example<ProdSalesEntity> example = Example.of(delSalesEntity);
|
|
|
+// salesRepo.deleteAll(salesRepo.findAll(example));
|
|
|
+
|
|
|
+ System.out.println("saleJa.size="+saleJa.size());
|
|
|
+ for(int a=0;a<saleJa.size();a++){
|
|
|
+ JSONObject saleJo = saleJa.getJSONObject(a);
|
|
|
+ System.out.println("saleJo="+saleJo);
|
|
|
+ ProdSalesEntity salesEntity = new ProdSalesEntity();
|
|
|
+ salesEntity.setAddDate(saleJo.getDate("today"));
|
|
|
+ salesEntity.setFarmId(saleJo.getInteger("farmId"));
|
|
|
+ Example<ProdSalesEntity> example = Example.of(salesEntity);
|
|
|
+ Optional<ProdSalesEntity> optional = salesRepo.findOne(example);
|
|
|
+ if(optional.isPresent()){
|
|
|
+ ProdSalesEntity prodSalesEntity = optional.get();
|
|
|
+ prodSalesEntity.setMonthQuantity(saleJo.getString("sum"));
|
|
|
+ prodSalesEntity.setMonthMoney(saleJo.getString("totalMoney"));
|
|
|
+ salesRepo.save(prodSalesEntity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void getManyFarmPsy() throws IOException, InterruptedException {
|
|
|
//
|