| | |
| | | @ApiOperation(value = "预测和实际臭氧对比", notes = "预测和实际臭氧对比") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "monitorPointId", defaultValue = "1", value = "监控站id", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "time", value = "时6间(格式:2020-03-19)", required = true, paramType = "query", dataType = "String")}) |
| | | @ApiImplicitParam(name = "time", value = "时间(格式:2020-03-19)", required = true, paramType = "query", dataType = "String")}) |
| | | public ResultBean<List<Map<String, Object>>> getWeatherNextDayDataByRegion(HttpServletRequest request) throws Exception { |
| | | Map<String, Object> parameters = getParametersStartingWith(request, null); |
| | | List<String> sensorKeys=new ArrayList<>(); |
| | | sensorKeys.add("e15"); |
| | | parameters.put("sensorKeys",sensorKeys); |
| | | List<Map<String, Object>> resultList = weatherService.getForecastAndReal(parameters); |
| | | return new ResultBean<List<Map<String, Object>>>(resultList); |
| | | } |
| | | |
| | | |
| | | @GetMapping("forecastPM") |
| | | @ApiOperation(value = "预测和实测颗粒物对比", notes = "预测和实测颗粒物对比") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "monitorPointId", defaultValue = "1", value = "监控站id", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "time", value = "时间(格式:2020-03-19)", required = true, paramType = "query", dataType = "String")}) |
| | | public ResultBean<List<Map<String, Object>>> getForecastAndRealPM(HttpServletRequest request) throws Exception { |
| | | Map<String, Object> parameters = getParametersStartingWith(request, null); |
| | | List<String> sensorKeys=new ArrayList<>(); |
| | | sensorKeys.add("e1"); |
| | | sensorKeys.add("e2"); |
| | | parameters.put("sensorKeys",sensorKeys); |
| | | List<Map<String, Object>> resultList = weatherService.getForecastAndReal(parameters); |
| | | return new ResultBean<List<Map<String, Object>>>(resultList); |
| | | } |
| | |
| | |
|
| | | @Override
|
| | | public List<Map<String, Object>> getForecastAndReal(Map<String, Object> parameters) throws ParseException {
|
| | | ArrayList<String> sensorKeys = (ArrayList<String>) parameters.get("sensorKeys");
|
| | | List<Map<String, Object>> resultList = new ArrayList<>();
|
| | | for (int i = 0; i < 24; i++) {
|
| | | Map<String, Object> map = new HashMap<>();
|
| | | List<String> arrayList = new ArrayList<>();
|
| | | map.put("values", arrayList);
|
| | | map.put("time", i + 1);
|
| | | resultList.add(map);
|
| | | }
|
| | |
|
| | | for (String sensorKey : sensorKeys) {
|
| | | parameters.put("sensorKey", sensorKey);
|
| | | List<Map<String, Object>> list = forecastAndReal(parameters);
|
| | | for (Map<String, Object> map : list) {
|
| | | Object time = map.get("time");
|
| | | ArrayList<String> values = (ArrayList<String>) map.get("values");
|
| | | for (Map<String, Object> resultMap : resultList) {
|
| | | if (time.equals(resultMap.get("time"))) {
|
| | | ArrayList<String> resultValues = (ArrayList<String>) resultMap.get("values");
|
| | | resultValues.addAll(values);
|
| | | resultMap.put("values", resultValues);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | return resultList;
|
| | | }
|
| | |
|
| | | public List<Map<String, Object>> forecastAndReal(Map<String, Object> parameters) throws ParseException {
|
| | | Object sensorKey = parameters.remove("sensorKey");
|
| | | String sensor1;
|
| | | String sensor2;
|
| | | if ("e1".equals(sensorKey)) {
|
| | | sensor1 = "PM25C";
|
| | | sensor2 = "PM2_5";
|
| | | } else if ("e2".equals(sensorKey)) {
|
| | | sensor1 = "PM10C";
|
| | | sensor2 = "PM10";
|
| | | } else {
|
| | | sensor1 = "O3C";
|
| | | sensor2 = "O3";
|
| | | }
|
| | | parameters.put("sensor1", sensor1);
|
| | | parameters.put("sensor2", sensor2);
|
| | | parameters.put("typeFormat", "%Y-%m-%d %H:%i:%s");
|
| | | String monitorPointId = parameters.get("monitorPointId").toString();
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
| | |
| | | forecastList = forecastWeatherMapper.getForecastHour(parameters);
|
| | | }
|
| | | for (Map<String, Object> map : aqiList) {
|
| | | int s = (int)Double.parseDouble(map.get("O3").toString().replace("\"", ""));
|
| | | map.put("O3", String.valueOf(s));
|
| | | int s = (int) Double.parseDouble(map.get(sensor2).toString().replace("\"", ""));
|
| | | map.put(sensor2, String.valueOf(s));
|
| | | }
|
| | |
|
| | | List<Map<String, Object>> resultList = new ArrayList<>();
|
| | |
| | | }
|
| | | map.put("time", Integer.valueOf(hour));
|
| | | values.add("");
|
| | | values.add(aqiMap.get("O3").toString());
|
| | | values.add(aqiMap.get(sensor2).toString());
|
| | | map.put("values", values);
|
| | | resultList.add(map);
|
| | | }
|
| | |
| | | hour = "24";
|
| | | }
|
| | | map.put("time", Integer.valueOf(hour));
|
| | | if (forecastMap.get("O3") != null) {
|
| | | values.add(forecastMap.get("O3").toString().replace("\"", ""));
|
| | | if (forecastMap.get(sensor2) != null) {
|
| | | values.add(forecastMap.get(sensor2).toString().replace("\"", ""));
|
| | | } else {
|
| | | values.add("");
|
| | | }
|
| | |
| | | hour = "24";
|
| | | }
|
| | | map.put("time", Integer.valueOf(hour));
|
| | | if (forecastMap.get("O3") != null) {
|
| | | values.add(forecastMap.get("O3").toString().replace("\"", ""));
|
| | | if (forecastMap.get(sensor2) != null) {
|
| | | values.add(forecastMap.get(sensor2).toString().replace("\"", ""));
|
| | | } else {
|
| | | values.add("");
|
| | | }
|
| | | for (Map<String, Object> aqiMap : aqiList) {
|
| | | if (forecastMap.get("time").equals(aqiMap.get("time"))) {
|
| | | values.add(aqiMap.get("O3").toString());
|
| | | values.add(aqiMap.get(sensor2).toString());
|
| | | }
|
| | | }
|
| | | map.put("values", values);
|
| | |
| | | <select id="getForecastHour" resultType="java.util.Map"> |
| | | SELECT |
| | | DATE_FORMAT(time, #{typeFormat}) time, |
| | | json->'$.O3C' 'O3' |
| | | json->'$.${sensor1}' '${sensor2}' |
| | | from forecast_weather |
| | | where time >= #{start} |
| | | AND time <![CDATA[<]]> #{end} |
| | |
| | | <select id="getAqiDataByAreaCode" resultType="java.util.Map"> |
| | | SELECT |
| | | DATE_FORMAT(time, #{typeFormat}) time, |
| | | ifnull(aqi_json->'$.O3C',aqi_json->'$.O3') as 'O3' |
| | | ifnull(aqi_json->'$.${sensor1}',aqi_json->'$.${sensor2}') as '${sensor2}' |
| | | FROM |
| | | hangzhou_aqi |
| | | WHERE |
| | |
| | | <select id="getHistoryO3" resultType="java.util.Map"> |
| | | SELECT |
| | | DATE_FORMAT(time, #{typeFormat}) time, |
| | | value->'$.O3' as 'O3' |
| | | value->'$.${sensor2}' as '${sensor2}' |
| | | FROM |
| | | history_aqi_${timeUnits} |
| | | WHERE |