Merge branch 'master' of http://blit.7drlb.com:8888/r/screen_api_v2
| | |
| | | import com.moral.service.SensorService;
|
| | | import com.moral.service.SensorUnitService;
|
| | | import com.moral.service.WeatherService;
|
| | | import com.moral.util.AQICalculation;
|
| | | import com.moral.util.TempAllocationUtils;
|
| | |
|
| | | import io.swagger.annotations.Api;
|
| | |
| | | model.setViewName("pollutionsource");
|
| | | return model;
|
| | | }
|
| | | |
| | | @GetMapping("getAirQualityComparison")
|
| | | @ApiOperation(value = "空气质量对比", notes = "空气质量对比")
|
| | | @ApiImplicitParams(value = {
|
| | | @ApiImplicitParam(name = "organizationId", defaultValue = "5", value = "登录账号的组织id", required = true, paramType = "query", dataType = "String"),
|
| | | @ApiImplicitParam(name = "monitor_point_id", defaultValue = "5", value = "监控站点id", required = true, paramType = "query", dataType = "String")})
|
| | | public ResultBean<Map<String, Object>> getAirQualityComparison(HttpServletRequest request) throws Exception {
|
| | | Map<String, Object> parameters = getParametersStartingWith(request, null);
|
| | | Map<String, Object> map = weatherService.getWeatherDataByRegion(parameters);
|
| | | Map<String, Double> sensorMap = new HashMap<>();
|
| | | sensorMap.put("e1", Double.parseDouble(map.get("pm25").toString()));
|
| | | sensorMap.put("e2", Double.parseDouble(map.get("pm10").toString()));
|
| | | sensorMap.put("e11", Double.parseDouble(map.get("so2").toString()));
|
| | | sensorMap.put("e16", Double.parseDouble(map.get("no2").toString()));
|
| | | sensorMap.put("e10", Double.parseDouble(map.get("co").toString()));
|
| | | sensorMap.put("e15", Double.parseDouble(map.get("o3").toString()));
|
| | | Map<String, Object> StateControl = AQICalculation.hourlyAQI(sensorMap);
|
| | | System.out.println("StateControl:"+StateControl);
|
| | | Map<String, Object> hourAqi = historyService.gitHourlyAQIByMonitorPointIdAndTimeslot(parameters);
|
| | | System.out.println("hourAqi:"+hourAqi);
|
| | | Map<String, Object> returnMap = new HashMap<>();
|
| | | returnMap.put("站点AQI", hourAqi.get("AQI"));
|
| | | returnMap.put("国控AQI", StateControl.get("AQI"));
|
| | | return new ResultBean<Map<String, Object>>(returnMap);
|
| | | }
|
| | | |
| | |
|
| | | @GetMapping("mointorPointRank")
|
| | | @ApiOperation(value = "获取站点排名", notes = "获取站点排名")
|
| | | @ApiImplicitParams(value = {
|
| | | @ApiImplicitParam(name = "accountId", value = "账号id", required = true, paramType = "query", dataType = "String"),
|
| | | @ApiImplicitParam(name = "sensor", value = "因子", required = true, paramType = "query", dataType = "String")
|
| | | })
|
| | | public ResultBean<List<Map<String, Object>>> getMointorPointRank(HttpServletRequest request){
|
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
|
| | | String id = parameters.get("accountId").toString();
|
| | | String sensor = parameters.get("sensor").toString();
|
| | | Map<String, Object> account = accountService.getOrganizationIdByAccountId(id);
|
| | | //通过组织id来获取站点和设备信息
|
| | | account.put("sensor", sensor);
|
| | | List<Map<String, Object>> returnList = historyService.getMointorPointRankByOrganizationId(account);
|
| | | return new ResultBean<List<Map<String, Object>>>(returnList);
|
| | | }
|
| | | |
| | | }
|
| | |
| | | List<Map<String, Object>> getSensorDataToday(Map<String, Object> parameters);
|
| | |
|
| | | List<Map<String, Object>> getAVGSensorRankByMonitorPointIdList(@Param("sensor")String sensor, @Param("monitorPointIdList") List<Object> monitorPointIdList, @Param("before5Time")String before5Time, @Param("endTime")String endTime);
|
| | | |
| | | Map<String, Object> getMonitorPointAVGValueByMonitorPointIdAndTimeslot(@Param("monitor_point_id")String monitor_point_id, @Param("starttime")String starttime, @Param("endtime")String endtime);
|
| | |
|
| | | } |
| | |
| | | Map<String, Object> gitHourlyAQIByMacAndTimeslot(Map<String, Object> parameters);
|
| | |
|
| | | List<Map<String, Object>> getMointorPointRankByOrganizationId(Map<String, Object> parameters);
|
| | | |
| | | Map<String, Object> gitHourlyAQIByMonitorPointIdAndTimeslot(Map<String, Object> parameters);
|
| | |
|
| | | }
|
| | |
| | | List<Map<String, Object>> result = historyMapper.getAVGSensorRankByMonitorPointIdList(sensor, monitorPointIdList, before5Time, endTime);
|
| | | return result;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Map<String, Object> gitHourlyAQIByMonitorPointIdAndTimeslot(Map<String, Object> parameters) {
|
| | | String monitor_point_id = parameters.get("monitor_point_id").toString();
|
| | | //获取日期
|
| | | LocalDate localDate = LocalDate.now();
|
| | | Calendar c = Calendar.getInstance();//可以对每个时间域单独修改
|
| | | int endHour = c.get(Calendar.HOUR_OF_DAY);
|
| | | String endTime = localDate+" "+endHour+":00:00";
|
| | | |
| | | String startTime;
|
| | | if(endHour == 0) {
|
| | | LocalDate startDate = localDate.minusDays(1);
|
| | | startTime = startDate+" "+"23:00:00";
|
| | | }else {
|
| | | int startHour = endHour-1;
|
| | | startTime = localDate+" "+startHour+":00:00";
|
| | | }
|
| | | Map<String, Object> map = historyMapper.getMonitorPointAVGValueByMonitorPointIdAndTimeslot(monitor_point_id, startTime, endTime);
|
| | | System.out.println(map);
|
| | | Map<String, Object> returnMap = new HashMap<>();
|
| | | if (map.isEmpty()) {
|
| | | returnMap.put("AQI", "N/V");
|
| | | } else {
|
| | | Map<String, Double> AQIMap = new HashMap<>();
|
| | | for (Map.Entry<String, Object> entry : map.entrySet()) {
|
| | | String key = entry.getKey();
|
| | | Double value = Double.parseDouble(entry.getValue().toString());
|
| | | AQIMap.put(key, value);
|
| | | }
|
| | | returnMap = AQICalculation.hourlyAQI(AQIMap);
|
| | | }
|
| | | |
| | | return returnMap;
|
| | | }
|
| | | }
|
| | |
| | | GROUP BY d.monitor_point_id
|
| | | ORDER BY AVG(JSON_EXTRACT(h.value,'$.${sensor}[0]')) DESC
|
| | | </select>
|
| | | |
| | | <select id="getMonitorPointAVGValueByMonitorPointIdAndTimeslot" resultType="java.util.Map">
|
| | | SELECT AVG(JSON_EXTRACT(value,'$.e1[0]')) e1,AVG(JSON_EXTRACT(value,'$.e2[0]')) e2,AVG(JSON_EXTRACT(value,'$.e10[0]')) e10,AVG(JSON_EXTRACT(value,'$.e11[0]')) e11,AVG(JSON_EXTRACT(value,'$.e16[0]')) e16,AVG(JSON_EXTRACT(value,'$.e15[0]')) e15
|
| | | FROM device d,history h
|
| | | WHERE d.monitor_point_id = #{monitor_point_id}
|
| | | AND d.mac = h.mac
|
| | | AND h.time BETWEEN #{starttime} AND #{endtime}
|
| | | </select>
|
| | |
|
| | | </mapper> |