jinpengyong
2020-09-28 48bb075f91c5daf35cff0a16abe1136f132aafb4
src/main/java/com/moral/service/impl/RealWeatherServiceImpl.java
@@ -147,34 +147,55 @@
            map.put("data", nowMap);
        }
        List<Map<String,Object>> resultList=new ArrayList<>();
        List<Map<String, Object>> resultList = new ArrayList<>();
        for (Map<String, Object> map : hashSet) {
            Map<String,Object> resultMap=new HashMap<>();
            resultMap.put("cityCode",map.get("cityCode").toString());
            resultMap.put("time",now);
            Map<String, Object> resultMap = new HashMap<>();
            resultMap.put("cityCode", map.get("cityCode").toString());
            resultMap.put("time", now);
            Map<String, Object> jsonMap = (Map<String, Object>) map.get("data");
            //风速km/h->m/s
            Double windSpeed = Double.valueOf(jsonMap.get("windSpeed").toString());
            windSpeed = windSpeed * 1000 / 3600;
            jsonMap.put("windSpeed",df.format(windSpeed));
            jsonMap.put("windSpeed", df.format(windSpeed));
            jsonMap.remove("obsTime");
            jsonMap.remove("icon");
            String text = jsonMap.get("text").toString();
            if(text.equals("晴")){
                jsonMap.put("condition","100");
            }else if(text.equals("多云")){
                jsonMap.put("condition","80");
            }else if(text.equals("阴")){
                jsonMap.put("condition","60");
            }else if(text.equals("雷阵雨")||text.equals("阵雨")){
                jsonMap.put("condition","40");
            }else if(text.equals("小雨")){
                jsonMap.put("condition","20");
            }else if(text.equals("雨")){
                jsonMap.put("condition","0");
            String condition;
            if ("晴".equals(text)) {
                condition = "100";
            } else if ("雾".equals(text)) {
                condition = "90";
            } else if ("多云".equals(text)) {
                condition = "80";
            } else if ("霾".equals(text)) {
                condition = "70";
            } else if ("阴".equals(text) || "扬沙".equals(text) || "浮尘".equals(text) || "".equals(text)) {
                condition = "60";
            } else if ("阵雨".equals(text)) {
                condition = "45";
            } else if ("雷阵雨".equals(text)) {
                condition = "40";
            } else if ("雷阵雨转小雨".equals(text) || "阵雨转小雨".equals(text)) {
                condition = "30";
            } else if ("小雨".equals(text)) {
                condition = "20";
            } else if ("雨".equals(text)) {
                condition = "10";
            } else if ("雷阵雨转中雨".equals(text)) {
                condition = "5";
            } else if ("雷阵雨转大雨".equals(text)) {
                condition = "4";
            } else if ("中雨".equals(text) || "大雨".equals(text) || "暴雨".equals(text)
                    || "小雪".equals(text) || "中雪".equals(text) || "大雪".equals(text)
                    || "雨夹雪".equals(text) || "雨夹雪(伴有冰雹)".equals(text)||"暴雪".equals(text)
            ) {
                condition = "0";
            } else {
                condition = "50";
            }
            resultMap.put("json",JSONObject.toJSONString(jsonMap));
            jsonMap.put("condition",condition);
            resultMap.put("json", JSONObject.toJSONString(jsonMap));
            resultList.add(resultMap);
        }
        realWeatherMapper.deleteRealWeather(sdf1.format(now));