package com.moral.service.impl; import java.text.DecimalFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import javax.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; import com.alibaba.fastjson.JSONObject; import com.moral.mapper.AQIMapper; import com.moral.mapper.DeviceMapper; import com.moral.mapper.WeatherMapper; import com.moral.mapper.HistoryHourlyMapper; import com.moral.mapper.MonitorPointMapper; import com.moral.service.WeatherService; @Service public class WeatherServiceImpl implements WeatherService { @Resource private WeatherMapper weatherMapper; @Resource private MonitorPointMapper monitorPointMapper; @Resource private AQIMapper aqiMapper; @Resource private DeviceMapper deviceMapper; @Resource private HistoryHourlyMapper historyHourlyMapper; //O3,PM2.5,PM10预测数据插入forecast_weather表 @Override public int insertForecastWeatherNew() throws ParseException { Calendar c = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String today = sdf.format(c.getTime()); DecimalFormat df = new DecimalFormat("0.0"); c.add(Calendar.DAY_OF_MONTH, 1); String nextDay = sdf.format(c.getTime()); c.setTime(c.getTime()); c.add(Calendar.DAY_OF_MONTH, 1); String nextNextDay = sdf.format(c.getTime()) + " 00"; RestTemplate restTemplate = new RestTemplate(); List> cityList = weatherMapper.getCityWeatherConfig(); cityList.clear(); Map cz = new HashMap<>(); cz.put("cityCode", 130900); cz.put("cityId", 101090701); cityList.add(cz); Map ks = new HashMap<>(); ks.put("cityCode", 320583); ks.put("cityId", 101190404); cityList.add(ks); Map hq = new HashMap<>(); hq.put("cityCode", 320505); hq.put("cityId", 101190406); cityList.add(hq); int state = 200; for (Map map : cityList) { String cityCode = map.get("cityCode").toString(); String id = map.get("cityId").toString(); Map dataMap = restTemplate.getForObject("https://api.heweather.net/v7/weather/72h?key=da05c6c4852d4f7aa3364a9236ee9e26&gzip=n&location={1}", Map.class, id); if (!dataMap.get("code").equals("200")) { return 500; } String json = JSONObject.toJSONString(dataMap); dataMap = (Map) JSONObject.parse(json); List> nextDayList = new ArrayList<>(); String string = dataMap.get("hourly").toString(); List> hourlyList = (List>) JSONObject.parse(string); for (Map hourlyMap : hourlyList) { //逐小时预报时间 String fxTime = hourlyMap.remove("fxTime").toString().split("\\+")[0].replace("T", " ") + ":00"; //icon为不需要字段 hourlyMap.remove("icon"); hourlyMap.put("time", fxTime); //天气 String text = hourlyMap.get("text").toString(); //风速km/h->m/s double windSpeed = Double.parseDouble(hourlyMap.get("windSpeed").toString()); windSpeed = windSpeed * 1000 / 3600; hourlyMap.put("windSpeed", df.format(windSpeed)); hourlyMap.put("windScale", String.valueOf(getWindScale(windSpeed))); hourlyMap.put("condition", getWeatherCondition(text)); String hour = fxTime.split(" ")[0]; String hour1 = fxTime.split(":")[0]; if (hour.equals(nextDay)) { nextDayList.add(hourlyMap); } if (hour1.equals(nextNextDay)) { nextDayList.add(hourlyMap); } } nextDayList.remove(0); map.put("data", nextDayList); //计算 c.setTime(sdf.parse(today)); c.add(Calendar.YEAR, -3); Date start = c.getTime(); Date end = sdf.parse(today); int timeUnits1 = c.get(Calendar.YEAR); int timeUnits2 = timeUnits1 + 1; int timeUnits3 = timeUnits1 + 2; int timeUnits4 = timeUnits1 + 3; //当天前15天 70%,当天前45天15%,其他 15% c.setTime(end); c.add(Calendar.DAY_OF_MONTH, -15); //前15天分割时间 Date slicedTime1 = c.getTime(); //前45天分割时间 c.add(Calendar.DAY_OF_MONTH, -30); Date slicedTime2 = c.getTime(); //每个城市结果存放list List> resultList = new ArrayList<>(); for (Map nextDayMap : nextDayList) { //O3预测 Map hashMap = new HashMap<>(); List hours = new ArrayList<>(); hashMap.put("cityCode", cityCode); hashMap.put("start", start); hashMap.put("end", end); hashMap.put("typeFormat", "%Y-%m-%d %H:%i:%s"); int condition = Integer.parseInt(nextDayMap.get("condition").toString()); int temp = Integer.parseInt(nextDayMap.get("temp").toString()); int pressure = Integer.parseInt(nextDayMap.get("pressure").toString()); //明日此小时风向 String windDir = nextDayMap.get("windDir").toString(); //风级 int windScale = Integer.parseInt(nextDayMap.get("windScale").toString()); String time = nextDayMap.remove("time").toString(); //当前小时 hours.add(time.substring(11, 13)); c.setTime(sdf1.parse(time)); //前1小时 c.add(Calendar.HOUR_OF_DAY, -1); hours.add(sdf1.format(c.getTime()).substring(11, 13)); //前2小时 c.add(Calendar.HOUR_OF_DAY, -1); String sHour = sdf1.format(c.getTime()).substring(11, 13); //后1小时 c.add(Calendar.HOUR_OF_DAY, 3); hours.add(sdf1.format(c.getTime()).substring(11, 13)); //后2小时 c.add(Calendar.HOUR_OF_DAY, 1); String eHour = sdf1.format(c.getTime()).substring(11, 13); hashMap.put("hours", hours); hashMap.put("score", 50); if (condition > 50) { hashMap.put("condition", 0); } else { hashMap.put("condition", 1); } List years = new ArrayList<>(); Collections.addAll(years, timeUnits1, timeUnits2, timeUnits3, timeUnits4); //根据天气筛选 List> O3Samples = getSample(hashMap, years); if (O3Samples.size() > 100) { O3Samples = O3Samples.parallelStream() .filter(sample -> Integer.parseInt(sample.get("temp").toString()) >= temp - 1 && Integer.parseInt(sample.get("temp").toString()) <= temp + 1) .collect(Collectors.toList()); if (O3Samples.size() > 100) { O3Samples = O3Samples.parallelStream() .filter(sample -> Integer.parseInt(sample.get("pressure").toString()) >= pressure - 5 && Integer.parseInt(sample.get("pressure").toString()) <= pressure + 5) .collect(Collectors.toList()); } } hashMap.put("slicedTime1", slicedTime1); hashMap.put("slicedTime2", slicedTime2); Map> sectionTimesMap = getSectionTimes(hashMap, O3Samples, years); Map params = new HashMap<>(); params.put("cityCode", cityCode); params.put("typeFormat", "%Y-%m-%d %H:%i:%s"); params.put("sensorKey", "O3"); params.put("sensorKey1", "O3C"); List times1 = sectionTimesMap.get("times1"); List times2 = sectionTimesMap.get("times2"); List times3 = sectionTimesMap.get("times3"); Double O3Avg1 = getAvg(params, times1); Double O3Avg2 = getAvg(params, times2); Double O3Avg3 = getAvg(params, times3); double resultO3 = O3Avg1 * 0.7 + O3Avg2 * 0.15 + O3Avg3 * 0.15; nextDayMap.put("O3C", String.valueOf(Math.round(resultO3))); //pm2.5,pm10颗粒物预测,温度,风向风级,气压 Map hashMap1 = new HashMap<>(); hashMap1.put("cityCode", cityCode); hashMap1.put("start", start); hashMap1.put("end", end); hashMap1.put("typeFormat", "%Y-%m-%d %H:%i:%s"); hashMap1.put("startTemp", temp - 1); hashMap1.put("endTemp", temp + 1); List> pmSamples = getSample(hashMap1, years); if (pmSamples.size() > 100) { pmSamples = pmSamples.parallelStream() .filter(sample -> Integer.parseInt(sample.get("windScale").toString()) == windScale) .collect(Collectors.toList()); if (pmSamples.size() > 100) { pmSamples = pmSamples.parallelStream() .filter(sample -> sample.get("windDir").toString().replace("\"", "").equals(windDir)) .collect(Collectors.toList()); if (pmSamples.size() > 100) { pmSamples = pmSamples.parallelStream() .filter(sample -> Integer.parseInt(sample.get("pressure").toString()) >= pressure - 5 && Integer.parseInt(sample.get("pressure").toString()) <= pressure + 5) .collect(Collectors.toList()); } } } hashMap1.put("slicedTime1", slicedTime1); hashMap1.put("slicedTime2", slicedTime2); Map> sectionTimesMap1 = getSectionTimes(hashMap1, pmSamples, years); List times4 = sectionTimesMap1.get("times1"); List times5 = sectionTimesMap1.get("times2"); List times6 = sectionTimesMap1.get("times3"); Map params1 = new HashMap<>(); params1.put("cityCode", cityCode); params1.put("typeFormat", "%Y-%m-%d %H:%i:%s"); params1.put("sensorKey", "PM2_5"); params1.put("sensorKey1", "PM25C"); Double PM25Avg1 = getAvg(params1, times4); Double PM25Avg2 = getAvg(params1, times5); Double PM25Avg3 = getAvg(params1, times6); params1.put("sensorKey", "PM10"); params1.put("sensorKey1", "PM10C"); Double PM10Avg1 = getAvg(params1, times4); Double PM10Avg2 = getAvg(params1, times5); Double PM10Avg3 = getAvg(params1, times6); double resultPM25 = PM25Avg1 * 0.7 + PM25Avg2 * 0.15 + PM25Avg3 * 0.15; nextDayMap.put("PM25C", String.valueOf(Math.round(resultPM25))); double resultPM10 = PM10Avg1 * 0.7 + PM10Avg2 * 0.15 + PM10Avg3 * 0.15; nextDayMap.put("PM10C", String.valueOf(Math.round(resultPM10))); params.put("time", time); String beam = weatherMapper.getBeam(params); if (beam != null) { nextDayMap.put("beam", beam.replace("\"", "")); } //每个小时一个map Map resultMap = new HashMap<>(); resultMap.put("cityCode", cityCode); resultMap.put("time", time); resultMap.put("json", JSONObject.toJSONString(nextDayMap)); resultList.add(resultMap); } Map parameters = new HashMap<>(); parameters.put("start", sdf1.parse(nextDay + " 01:00:00")); c.setTime(sdf1.parse(nextDay + " 01:00:00")); c.add(Calendar.DAY_OF_MONTH, 1); parameters.put("end", c.getTime()); parameters.put("cityCode", cityCode); weatherMapper.deleteByTime(parameters); weatherMapper.insertForecastWeather(resultList); } return state; } private List> getSample(Map params, List years) { List> samples = new ArrayList<>(); if (years.size() > 0) { for (Integer year : years) { params.put("timeUnits", year); samples.addAll(weatherMapper.getSampleFromHistoryWeather(params)); } } samples.addAll(weatherMapper.getSampleFromRealWeather(params)); return samples; } private Double getAvg(Map params, List times) { List values = new ArrayList<>(); if (times.size() == 0) { return 0.0; } for (String time : times) { String s = time.substring(0, 4); params.put("time", time); String value = aqiMapper.getAqiFromHangzhou(params); if (value == null) { params.put("timeUnits", s); value = aqiMapper.getAqiFromHistory(params); } if (value != null) { values.add(value.replace("\"", "")); } } double sum = 0.0; for (String v : values) { sum += Double.parseDouble(v); } return sum / values.size(); } private Map> getSectionTimes(Map params, List> samples, List years) throws ParseException { Map> hashMap = new HashMap<>(); //当天前15天 List times1 = new ArrayList<>(); //45-15 List times2 = new ArrayList<>(); //其他 List times3 = new ArrayList<>(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date slicedTime1 = (Date) (params.get("slicedTime1")); Date slicedTime2 = (Date) (params.get("slicedTime2")); for (Map sample : samples) { String time = sample.get("time").toString(); Date samTime = sdf.parse(time); if (samTime.getTime() >= slicedTime1.getTime()) { times1.add(time); } else if (samTime.getTime() >= slicedTime2.getTime()) { times2.add(time); } else { times3.add(time); } } hashMap.put("times1", times1); hashMap.put("times2", times2); hashMap.put("times3", times3); return hashMap; } @Override public int insertForecastWeather() throws ParseException { Calendar c = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); DecimalFormat df = new DecimalFormat("0.0"); c.add(Calendar.DAY_OF_MONTH, 1); String nextDay = sdf.format(c.getTime()); c.setTime(c.getTime()); Date start = sdf1.parse(nextDay + " 01:00:00"); c.add(Calendar.DAY_OF_MONTH, 1); String nextNextDay = sdf.format(c.getTime()) + " 00"; Date end = sdf1.parse(sdf.format(c.getTime()) + " 01:00:00"); RestTemplate restTemplate = new RestTemplate(); c.setTime(new Date()); Date endTime = sdf.parse(sdf.format(c.getTime())); c.add(Calendar.MONTH, -1); Date startTime = sdf.parse(sdf.format(c.getTime())); int state = 200; List> cityList = weatherMapper.getCityWeatherConfig(); for (Map map : cityList) { String id = map.get("cityId").toString(); Map dataMap = restTemplate.getForObject("https://api.heweather.net/v7/weather/72h?key=da05c6c4852d4f7aa3364a9236ee9e26&gzip=n&location={1}", Map.class, id); if (!dataMap.get("code").equals("200")) { return 500; } String json = JSONObject.toJSONString(dataMap); dataMap = (Map) JSONObject.parse(json); List> nextDayList = new ArrayList<>(); String string = dataMap.get("hourly").toString(); List> hourlyList = (List>) JSONObject.parse(string); for (Map hourlyMap : hourlyList) { String hour = hourlyMap.get("fxTime").toString().split("T")[0]; String hour1 = hourlyMap.get("fxTime").toString().split("\\+")[0].split(":")[0].replace("T", " "); if (hour.equals(nextDay)) { nextDayList.add(hourlyMap); } if (hour1.equals(nextNextDay)) { nextDayList.add(hourlyMap); } } nextDayList.remove(0); for (Map nextDayMap : nextDayList) { //风速km/h->m/s Double windSpeed = Double.valueOf(nextDayMap.get("windSpeed").toString()); windSpeed = windSpeed * 1000 / 3600; nextDayMap.put("windSpeed", df.format(windSpeed)); nextDayMap.put("windScale", String.valueOf(getWindScale(windSpeed))); String text = nextDayMap.get("text").toString(); nextDayMap.put("condition", getWeatherCondition(text)); } map.put("data", nextDayList); } for (Map map : cityList) { List> resultList = new ArrayList<>(); String cityCode = map.get("cityCode").toString(); String parentCode = ""; if (cityCode.endsWith("0000")) { parentCode = cityCode; } else if (cityCode.endsWith("00")) { parentCode = cityCode.substring(0, cityCode.length() - 4) + "0000"; } else { parentCode = cityCode.substring(0, cityCode.length() - 2) + "00"; } map.put("parentCode", parentCode); map.put("startTime", startTime); map.put("endTime", endTime); map.put("typeFormat", "%Y-%m-%d %H:%i:%s"); Map map1 = new HashMap<>(); map1.put("typeFormat", "%Y-%m-%d %H:%i:%s"); map1.put("cityCode", Integer.valueOf(cityCode)); //根据city_code获取所有monitorPoint Map params = new HashMap<>(); if (cityCode.endsWith("0000")) { params.put("provinceCode", Integer.valueOf(cityCode)); } else if (cityCode.endsWith("00")) { params.put("cityCode", Integer.valueOf(cityCode)); } else { params.put("areaCode", Integer.valueOf(cityCode)); } List pointList = new ArrayList<>(); if (cityCode.equals("130900")) { pointList.add(48); } else { pointList = monitorPointMapper.getMonitorList(params); } List macList = new ArrayList<>(); if (pointList.size() != 0) { macList = deviceMapper.getMacsByMonitorPointIds(pointList); } if (macList.size() != 0) { map.put("macs", macList); } ArrayList> dataList = (ArrayList>) map.get("data"); for (Map dataMap : dataList) { Map hashMap = new HashMap<>(); hashMap.put("cityCode", cityCode); String time = dataMap.get("fxTime").toString().split("\\+")[0].replace("T", " ") + ":00"; int hour = Integer.valueOf(time.substring(11, 13)); map.put("time", hour); hashMap.put("time", sdf1.parse(time)); String nextDayTemp = dataMap.get("temp").toString(); String nextDayCloud = dataMap.get("cloud").toString(); Integer condition = Integer.valueOf(dataMap.get("condition").toString()); Integer value = 0; if (condition >= 80) { value = 80; } else if (condition >= 40) { value = 40; } else if (condition >= 0) { value = 0; } map.put("condition", value); List> tempAndCloudList = weatherMapper.getTempAndCloud(map); List times = new ArrayList<>(); for (Map tempAndCloudMap : tempAndCloudList) { times.add(tempAndCloudMap.get("time").toString()); } map.put("times", times); map1.put("times", times); map1.put("time", hour); List> O3List = new ArrayList<>(); List> beamList = new ArrayList<>(); if (times.size() != 0) { O3List = aqiMapper.getO3(map1); if (O3List.size() == 0) { map1.put("cityCode", Integer.valueOf(map.get("parentCode").toString())); O3List = aqiMapper.getO3(map1); } if (map.get("macs") != null) { beamList = historyHourlyMapper.getBeamByMacs(map); } } for (Map tempAndCloudMap : tempAndCloudList) { String time1 = tempAndCloudMap.get("time").toString(); for (Map beamMap : beamList) { if (beamList.size() != 0) { String time2 = beamMap.get("time").toString(); if (time1.equals(time2)) { tempAndCloudMap.putAll(beamMap); } } } } for (Map tempAndCloudMap : tempAndCloudList) { String time1 = tempAndCloudMap.get("time").toString(); for (Map O3Map : O3List) { if (O3List.size() != 0) { String time3 = O3Map.get("time").toString(); if (time1.equals(time3)) { tempAndCloudMap.putAll(O3Map); } } } } double tempSum = 0.0;//温度和 double O3Sum = 0.0;//O3和 double sum1 = 0.0;// double sum2 = 0.0; double cloudSum = 0.0;//总云量和 double beamSum = 0.0;//光照和 double sum3 = 0.0;// double sum4 = 0.0; int size = tempAndCloudList.size(); Map cmap = new HashMap<>(); cmap.put("time", hour); for (Map listMap : tempAndCloudList) { //O3 double temp = Double.valueOf(listMap.get("temp").toString().replace("\"", "").split("\\.")[0]); if (listMap.get("O3") != null) { double O3 = Double.valueOf(listMap.get("O3").toString().replace("\"", "").split("\\.")[0]); tempSum = tempSum + temp; O3Sum = O3Sum + O3; sum1 = sum1 + temp * O3; sum2 = sum2 + temp * temp; } //光照 if (listMap.get("beam") != null&&listMap.get("cloud") != null) { double cloud = Double.valueOf(listMap.get("cloud").toString().replace("\"", "").split("\\.")[0]); double beam = Double.valueOf(listMap.get("beam").toString().replace("\"", "").split("\\.")[0]); cloudSum = cloudSum + cloud; beamSum = beamSum + beam; sum3 = sum3 + cloud * beam; sum4 = sum4 + cloud * cloud; } } if (tempSum != 0.0) { double tempAvg = tempSum / size; double O3Avg = O3Sum / size; double b = (sum1 - size * tempAvg * O3Avg) / (sum2 - size * tempAvg * tempAvg); double a = O3Avg - (b * tempAvg); cmap.put("a", a); cmap.put("b", b); } if (cloudSum != 0.0) { double cloudAvg = cloudSum / size; double beamAvg = beamSum / size; double n = (sum3 - size * cloudAvg * beamAvg) / (sum4 - size * cloudAvg * cloudAvg); double m = beamAvg - (n * cloudAvg); cmap.put("m", m); cmap.put("n", n); } if (cmap.get("a") != null) { Double a = Double.valueOf(cmap.get("a").toString()); Double b = Double.valueOf(cmap.get("b").toString()); double O3C = b * Double.valueOf(nextDayTemp) + a; if (O3C < 1.0) { O3C = 1.0; } dataMap.put("O3C", String.valueOf(Math.round(O3C))); } if (cmap.get("m") != null) { Double m = Double.valueOf(cmap.get("m").toString()); Double n = Double.valueOf(cmap.get("n").toString()); double beam = n * Double.valueOf(nextDayCloud) + m; if (beam < 1.0) { beam = 0.0; } dataMap.put("beam", String.valueOf(Math.round(beam))); } dataMap.remove("icon"); dataMap.remove("fxTime"); hashMap.put("json", JSONObject.toJSONString(dataMap)); resultList.add(hashMap); } Map parameters = new HashMap<>(); parameters.put("start", start); parameters.put("end", end); parameters.put("cityCode", cityCode); weatherMapper.deleteByTime(parameters); weatherMapper.insertForecastWeather(resultList); } return state; } @Override public int insertRealWeather() throws ParseException { DecimalFormat df = new DecimalFormat("0.0"); Calendar c = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH"); SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date now = sdf1.parse(sdf.format(c.getTime()) + ":00:00"); RestTemplate restTemplate = new RestTemplate(); List> cityList = weatherMapper.getCityWeatherConfig(); int state = 200; for (Map map : cityList) { String id = map.get("cityId").toString(); Map dataMap = restTemplate.getForObject("https://api.heweather.net/v7/weather/now?key=da05c6c4852d4f7aa3364a9236ee9e26&gzip=n&location={1}", Map.class, id); if (!dataMap.get("code").equals("200")) { return 500; } String json = JSONObject.toJSONString(dataMap); dataMap = (Map) JSONObject.parse(json); Map nowMap = (Map) dataMap.get("now"); map.put("data", nowMap); } List> resultList = new ArrayList<>(); for (Map map : cityList) { Map resultMap = new HashMap<>(); resultMap.put("cityCode", map.get("cityCode").toString()); resultMap.put("time", now); Map jsonMap = (Map) 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.remove("obsTime"); jsonMap.remove("icon"); String text = jsonMap.get("text").toString(); jsonMap.put("condition", getWeatherCondition(text)); resultMap.put("json", JSONObject.toJSONString(jsonMap)); resultList.add(resultMap); } weatherMapper.deleteRealWeather(sdf1.format(now)); weatherMapper.insertRealWeather(resultList); return state; } private int getWindScale(Double windSpeed) { int windScale = 0; if (windSpeed <= 1.5) { windScale = 1; } else if (windSpeed <= 3.3) { windScale = 2; } else if (windSpeed <= 5.4) { windScale = 3; } else if (windSpeed <= 7.9) { windScale = 4; } else if (windSpeed <= 10.7) { windScale = 5; } else if (windSpeed <= 13.8) { windScale = 6; } else if (windSpeed <= 17.1) { windScale = 7; } else if (windSpeed <= 20.7) { windScale = 8; } else if (windSpeed <= 24.4) { windScale = 9; } else if (windSpeed <= 28.4) { windScale = 10; } else if (windSpeed <= 32.6) { windScale = 11; } else if (windSpeed <= 36.9) { windScale = 12; } return windScale; } private String getWeatherCondition(String text) { 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"; } return condition; } }