diff --git a/src/main/java/org/springnewfiber/dataadapter/ziguang/yl/action/YlAction.java b/src/main/java/org/springnewfiber/dataadapter/ziguang/yl/action/YlAction.java index 30b7611..0f0473c 100644 --- a/src/main/java/org/springnewfiber/dataadapter/ziguang/yl/action/YlAction.java +++ b/src/main/java/org/springnewfiber/dataadapter/ziguang/yl/action/YlAction.java @@ -67,7 +67,7 @@ log.info("雨量基础信息list:{}", response.body()); List list = JSONObject.parseArray(response.body(), YlDto.class); list.forEach(i -> { - realTimeData(i.getSTCD()); + realTimeData(i); }); } @@ -76,39 +76,40 @@ * * @param stcd */ - public void realTimeData(String stcd) { + public void realTimeData(YlDto realYl) { try { - Map listByPramMap = ImmutableMap.of("searchFilters", ImmutableMap.of("stcd", stcd, "datatime", DateUtil.today())); + Map listByPramMap = ImmutableMap.of("searchFilters", ImmutableMap.of("stcd", realYl.getSTCD(), "datatime", DateUtil.today())); HttpRequest request = loginAction.getPostAuthRequest(ziGuangConfig.getYl().getRealUrl()); request.body(JSONObject.toJSONString(listByPramMap)); HttpResponse response = request.execute(); - log.info("单个雨量实时数据:stcd:{},数据:{}", stcd, response.body()); + log.info("单个雨量实时数据:stcd:{},数据:{}", realYl.getSTCD(), response.body()); List list = JSONObject.parseArray(response.body(), YlDto.class); if (CollectionUtil.isNotEmpty(list)) { - Boolean flag = bladeRedis.exists("yl:" + stcd); + Boolean flag = bladeRedis.exists("yl:" + realYl.getSTCD()); List newList = CollectionUtil.reverseNew(list); newList.forEach(i -> { YlDto dto = new YlDto(); - if ((flag && (dto = bladeRedis.get("yl:" + stcd)) != null && dto.getTM().before(i.getTM())) || !flag) { + if ((flag && (dto = bladeRedis.get("yl:" + realYl.getSTCD())) != null && dto.getTM().before(i.getTM())) || !flag) { log.info("雨量redis的数据:{},请求到的最新数据:{}", JSONObject.toJSONString(dto), JSONObject.toJSONString(i.getTM())); // getData(stcd, i.getTM(), i); Future future = rainfallAccumulationUtil.submit(i, i.getSTCD()); //自己累计雨量 nb-plus i.setCountPt(dto.getCountPt().add(new BigDecimal(i.getDRP()))); + i.setDAYDRP(realYl.getDAYDRP()); try { future.get(60, TimeUnit.SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - log.error("累计错误:stcd:{},Cause:{}", stcd, e.getCause()); + log.error("累计错误:stcd:{},Cause:{}", realYl.getSTCD(), e.getCause()); } rabbitTemplate.convertAndSend(JSONObject.toJSONString(YlDto.convert(i))); - bladeRedis.set("yl:" + stcd, i); - log.info("发送雨量的数据:{},数据:{}", stcd, JSONObject.toJSONString(YlDto.convert(i))); + bladeRedis.set("yl:" + realYl.getSTCD(), i); + log.info("发送雨量的数据:{},数据:{}", realYl.getSTCD(), JSONObject.toJSONString(YlDto.convert(i))); return; } }); } } catch (Exception e) { - log.error("雨量数据出错:stcd:{},Cause:{}", stcd, e.getCause()); + log.error("雨量数据出错:stcd:{},Cause:{}", realYl.getSTCD(), e.getCause()); } } diff --git a/src/main/java/org/springnewfiber/dataadapter/ziguang/yl/action/YlAction.java b/src/main/java/org/springnewfiber/dataadapter/ziguang/yl/action/YlAction.java index 30b7611..0f0473c 100644 --- a/src/main/java/org/springnewfiber/dataadapter/ziguang/yl/action/YlAction.java +++ b/src/main/java/org/springnewfiber/dataadapter/ziguang/yl/action/YlAction.java @@ -67,7 +67,7 @@ log.info("雨量基础信息list:{}", response.body()); List list = JSONObject.parseArray(response.body(), YlDto.class); list.forEach(i -> { - realTimeData(i.getSTCD()); + realTimeData(i); }); } @@ -76,39 +76,40 @@ * * @param stcd */ - public void realTimeData(String stcd) { + public void realTimeData(YlDto realYl) { try { - Map listByPramMap = ImmutableMap.of("searchFilters", ImmutableMap.of("stcd", stcd, "datatime", DateUtil.today())); + Map listByPramMap = ImmutableMap.of("searchFilters", ImmutableMap.of("stcd", realYl.getSTCD(), "datatime", DateUtil.today())); HttpRequest request = loginAction.getPostAuthRequest(ziGuangConfig.getYl().getRealUrl()); request.body(JSONObject.toJSONString(listByPramMap)); HttpResponse response = request.execute(); - log.info("单个雨量实时数据:stcd:{},数据:{}", stcd, response.body()); + log.info("单个雨量实时数据:stcd:{},数据:{}", realYl.getSTCD(), response.body()); List list = JSONObject.parseArray(response.body(), YlDto.class); if (CollectionUtil.isNotEmpty(list)) { - Boolean flag = bladeRedis.exists("yl:" + stcd); + Boolean flag = bladeRedis.exists("yl:" + realYl.getSTCD()); List newList = CollectionUtil.reverseNew(list); newList.forEach(i -> { YlDto dto = new YlDto(); - if ((flag && (dto = bladeRedis.get("yl:" + stcd)) != null && dto.getTM().before(i.getTM())) || !flag) { + if ((flag && (dto = bladeRedis.get("yl:" + realYl.getSTCD())) != null && dto.getTM().before(i.getTM())) || !flag) { log.info("雨量redis的数据:{},请求到的最新数据:{}", JSONObject.toJSONString(dto), JSONObject.toJSONString(i.getTM())); // getData(stcd, i.getTM(), i); Future future = rainfallAccumulationUtil.submit(i, i.getSTCD()); //自己累计雨量 nb-plus i.setCountPt(dto.getCountPt().add(new BigDecimal(i.getDRP()))); + i.setDAYDRP(realYl.getDAYDRP()); try { future.get(60, TimeUnit.SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - log.error("累计错误:stcd:{},Cause:{}", stcd, e.getCause()); + log.error("累计错误:stcd:{},Cause:{}", realYl.getSTCD(), e.getCause()); } rabbitTemplate.convertAndSend(JSONObject.toJSONString(YlDto.convert(i))); - bladeRedis.set("yl:" + stcd, i); - log.info("发送雨量的数据:{},数据:{}", stcd, JSONObject.toJSONString(YlDto.convert(i))); + bladeRedis.set("yl:" + realYl.getSTCD(), i); + log.info("发送雨量的数据:{},数据:{}", realYl.getSTCD(), JSONObject.toJSONString(YlDto.convert(i))); return; } }); } } catch (Exception e) { - log.error("雨量数据出错:stcd:{},Cause:{}", stcd, e.getCause()); + log.error("雨量数据出错:stcd:{},Cause:{}", realYl.getSTCD(), e.getCause()); } } diff --git a/src/main/java/org/springnewfiber/dataadapter/ziguang/yl/dto/YlDto.java b/src/main/java/org/springnewfiber/dataadapter/ziguang/yl/dto/YlDto.java index 901ede4..8f5cb7c 100644 --- a/src/main/java/org/springnewfiber/dataadapter/ziguang/yl/dto/YlDto.java +++ b/src/main/java/org/springnewfiber/dataadapter/ziguang/yl/dto/YlDto.java @@ -27,6 +27,7 @@ private Float MAXDRP; // 行政区划 private Float DSNM; + private Float DAYDRP; // 最新监测时间啊 YYYY-MM-DD HH:mm:ss private Date TM; // 纬度 @@ -48,6 +49,7 @@ public static String six = "p6"; public static String twelve = "p12"; public static String day = "p24"; + public static String pd = "pd"; public static String pt = "pt"; public static PtReceiveBaseModel convert(YlDto dto) { @@ -103,6 +105,13 @@ p1.setSn(YlDto.pt); dataMap.put(YlDto.pt, p1); } + if (dto.getDAYDRP() != null) { + MqNodeData p1 = new MqNodeData(); + p1.setKey(YlDto.pd); + p1.setValue(dto.getDAYDRP()); + p1.setSn(YlDto.pd); + dataMap.put(YlDto.pd, p1); + } dataMap.put("drp", data); model.setDataMap(dataMap); return model; diff --git a/src/main/java/org/springnewfiber/dataadapter/ziguang/yl/action/YlAction.java b/src/main/java/org/springnewfiber/dataadapter/ziguang/yl/action/YlAction.java index 30b7611..0f0473c 100644 --- a/src/main/java/org/springnewfiber/dataadapter/ziguang/yl/action/YlAction.java +++ b/src/main/java/org/springnewfiber/dataadapter/ziguang/yl/action/YlAction.java @@ -67,7 +67,7 @@ log.info("雨量基础信息list:{}", response.body()); List list = JSONObject.parseArray(response.body(), YlDto.class); list.forEach(i -> { - realTimeData(i.getSTCD()); + realTimeData(i); }); } @@ -76,39 +76,40 @@ * * @param stcd */ - public void realTimeData(String stcd) { + public void realTimeData(YlDto realYl) { try { - Map listByPramMap = ImmutableMap.of("searchFilters", ImmutableMap.of("stcd", stcd, "datatime", DateUtil.today())); + Map listByPramMap = ImmutableMap.of("searchFilters", ImmutableMap.of("stcd", realYl.getSTCD(), "datatime", DateUtil.today())); HttpRequest request = loginAction.getPostAuthRequest(ziGuangConfig.getYl().getRealUrl()); request.body(JSONObject.toJSONString(listByPramMap)); HttpResponse response = request.execute(); - log.info("单个雨量实时数据:stcd:{},数据:{}", stcd, response.body()); + log.info("单个雨量实时数据:stcd:{},数据:{}", realYl.getSTCD(), response.body()); List list = JSONObject.parseArray(response.body(), YlDto.class); if (CollectionUtil.isNotEmpty(list)) { - Boolean flag = bladeRedis.exists("yl:" + stcd); + Boolean flag = bladeRedis.exists("yl:" + realYl.getSTCD()); List newList = CollectionUtil.reverseNew(list); newList.forEach(i -> { YlDto dto = new YlDto(); - if ((flag && (dto = bladeRedis.get("yl:" + stcd)) != null && dto.getTM().before(i.getTM())) || !flag) { + if ((flag && (dto = bladeRedis.get("yl:" + realYl.getSTCD())) != null && dto.getTM().before(i.getTM())) || !flag) { log.info("雨量redis的数据:{},请求到的最新数据:{}", JSONObject.toJSONString(dto), JSONObject.toJSONString(i.getTM())); // getData(stcd, i.getTM(), i); Future future = rainfallAccumulationUtil.submit(i, i.getSTCD()); //自己累计雨量 nb-plus i.setCountPt(dto.getCountPt().add(new BigDecimal(i.getDRP()))); + i.setDAYDRP(realYl.getDAYDRP()); try { future.get(60, TimeUnit.SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - log.error("累计错误:stcd:{},Cause:{}", stcd, e.getCause()); + log.error("累计错误:stcd:{},Cause:{}", realYl.getSTCD(), e.getCause()); } rabbitTemplate.convertAndSend(JSONObject.toJSONString(YlDto.convert(i))); - bladeRedis.set("yl:" + stcd, i); - log.info("发送雨量的数据:{},数据:{}", stcd, JSONObject.toJSONString(YlDto.convert(i))); + bladeRedis.set("yl:" + realYl.getSTCD(), i); + log.info("发送雨量的数据:{},数据:{}", realYl.getSTCD(), JSONObject.toJSONString(YlDto.convert(i))); return; } }); } } catch (Exception e) { - log.error("雨量数据出错:stcd:{},Cause:{}", stcd, e.getCause()); + log.error("雨量数据出错:stcd:{},Cause:{}", realYl.getSTCD(), e.getCause()); } } diff --git a/src/main/java/org/springnewfiber/dataadapter/ziguang/yl/dto/YlDto.java b/src/main/java/org/springnewfiber/dataadapter/ziguang/yl/dto/YlDto.java index 901ede4..8f5cb7c 100644 --- a/src/main/java/org/springnewfiber/dataadapter/ziguang/yl/dto/YlDto.java +++ b/src/main/java/org/springnewfiber/dataadapter/ziguang/yl/dto/YlDto.java @@ -27,6 +27,7 @@ private Float MAXDRP; // 行政区划 private Float DSNM; + private Float DAYDRP; // 最新监测时间啊 YYYY-MM-DD HH:mm:ss private Date TM; // 纬度 @@ -48,6 +49,7 @@ public static String six = "p6"; public static String twelve = "p12"; public static String day = "p24"; + public static String pd = "pd"; public static String pt = "pt"; public static PtReceiveBaseModel convert(YlDto dto) { @@ -103,6 +105,13 @@ p1.setSn(YlDto.pt); dataMap.put(YlDto.pt, p1); } + if (dto.getDAYDRP() != null) { + MqNodeData p1 = new MqNodeData(); + p1.setKey(YlDto.pd); + p1.setValue(dto.getDAYDRP()); + p1.setSn(YlDto.pd); + dataMap.put(YlDto.pd, p1); + } dataMap.put("drp", data); model.setDataMap(dataMap); return model; diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 7b0b579..f945cbe 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -75,10 +75,10 @@ # realurl: http://58.49.51.33:8081/iwp/dynamic/hd/rvnm_order/list realurl: http://58.49.51.33:8081/iwp/dynamic/hd/wh_daylive/list login: -# username: data-service1 -# password: data-service11 - username: data-service2 - password: data-service212345678 + username: data-service1 + password: data-service11 +# username: data-service2 +# password: data-service212345678 loginurl: http://58.49.51.33:8081/jkfc/user/login #rabbitmq: # exchange: amq.topic