From 8b0501f73b6d92b611c7df74535566f65faa7d7b Mon Sep 17 00:00:00 2001 From: jinpengyong <jpy123456> Date: Thu, 17 Sep 2020 13:51:15 +0800 Subject: [PATCH] update --- src/main/java/com/moral/service/impl/WeatherServiceImpl.java | 27 +++++++++++++++++++++++---- 1 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/moral/service/impl/WeatherServiceImpl.java b/src/main/java/com/moral/service/impl/WeatherServiceImpl.java index 4010f85..82f4b1a 100644 --- a/src/main/java/com/moral/service/impl/WeatherServiceImpl.java +++ b/src/main/java/com/moral/service/impl/WeatherServiceImpl.java @@ -387,7 +387,18 @@ } parameters.put("cityCode", code); parameters.put("name", name); - String time = parameters.get("time").toString(); + String string = parameters.get("time").toString(); + String year = string.substring(0, 4); + String[] split = string.substring(5).split("-"); + String month = split[0]; + String day = split[1]; + if (split[0].length() < 2) { + month = 0 + split[0]; + } + if (split[1].length() < 2) { + day = 0 + split[1]; + } + String time = year + "-" + month + "-" + day; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date now = new Date(); @@ -733,9 +744,17 @@ map.put("COC", map.get("CO").toString()); map.remove("CO"); } - if ((!map.containsKey("PM25C")) && map.containsKey("PM2_5")) { - map.put("PM25C", map.get("PM2_5").toString().replace("\\.", "")); - map.remove("PM2_5"); + if ((!map.containsKey("PM25C")) && (map.containsKey("PM2_5")||map.containsKey("PM25"))) { + if (map.get("PM2_5") != null) { + map.put("PM25C", map.get("PM2_5").toString().replace("\\.", "")); + map.remove("PM2_5"); + break; + } + if(map.get("PM25") != null){ + map.put("PM25C", map.get("PM25").toString().replace("\\.", "")); + map.remove("PM25"); + break; + } } if ((!map.containsKey("PM10C")) && map.containsKey("PM10")) { map.put("PM10C", map.get("PM10").toString().replace("\\.", "")); -- Gitblit v1.8.0