| | |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/carTrajectoryNew") |
| | | @ApiOperation(value = "显示走航车轨迹", notes = "显示走航车轨迹") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "mac", value = "设备mac(格式:p5dnd7a0392081)", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "startTime", value = "开始时间(格式:2020-03-19-14)", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "endTime", value = "结束时间(格式:2020-03-19-17)", required = true, paramType = "query", dataType = "String") |
| | | }) |
| | | public ModelAndView carTrajectoryNew(ModelAndView model, HttpServletRequest request) throws Exception { |
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); |
| | | String st = parameters.get("startTime").toString(); |
| | | String startYearAndDay = st.substring(0, st.lastIndexOf("-")); |
| | | String startHour = st.substring(st.lastIndexOf("-") + 1); |
| | | String startTime = startYearAndDay + " " + startHour + ":00:00"; |
| | | String et = parameters.get("endTime").toString(); |
| | | String endYearAndDay = et.substring(0, st.lastIndexOf("-")); |
| | | String endHour = et.substring(et.lastIndexOf("-") + 1); |
| | | String endTime = endYearAndDay + " " + endHour + ":00:00"; |
| | | parameters.put("startTime", startTime); |
| | | parameters.put("endTime", endTime); |
| | | String mac = parameters.get("mac").toString(); |
| | | if (mac != null && mac.length() != 0) { |
| | | List<List<Map<String, Object>>> sensorData = historyService.getCarSensorData(parameters); |
| | | Map<String, String> sensorsMap = sensorService.getSensorsMap(parameters); |
| | | List<Map<String, Object>> sensorList = new ArrayList<>(); |
| | | if (sensorData.size() == 3) { |
| | | sensorList = sensorData.get(0); |
| | | } |
| | | JSONObject params = new JSONObject(); |
| | | params.put("sensorInfo", sensorList); |
| | | params.put("sensorsMap", sensorsMap); |
| | | String paramsJson = params.toJSONString(); |
| | | model.addObject("carTrajectoryParams", paramsJson); |
| | | model.setViewName("cartrajectoryNew"); |
| | | return model; |
| | | } else { |
| | | StringBuilder msg = new StringBuilder(); |
| | | msg.append(" param[0] mac:"); |
| | | msg.append(mac); |
| | | log.warn(msg); |
| | | model.setViewName("403"); |
| | | return model; |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/trajectoryDataShow") |
| | | @ApiOperation(value = "轨迹及数据", notes = "轨迹及数据") |
| | | @ApiImplicitParams(value = { |
| | |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "monitorPointId", value = "公司Id", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "sensorKey", value = "因子", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "realTime", value = "实时", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "accountId", value = "用户id", required = false, paramType = "query", dataType = "String")}) |
| | | public ModelAndView unorganizedEmissionsBackupsV2(HttpServletRequest request, ModelAndView model) { |
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); |
| | |
| | | List<Device> deviceList = deviceService.getDevicesByMonitorPointId(539); |
| | | //获取五分钟数据 |
| | | Map<String,Object> pa = new HashMap<>(); |
| | | //获取开始时间和结束时间 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | Calendar beforeTime = Calendar.getInstance(); |
| | | Date newTime = beforeTime.getTime(); |
| | | beforeTime.add(Calendar.MINUTE,-5); |
| | | Date startTime = beforeTime.getTime(); |
| | | beforeTime.add(Calendar.MINUTE,6); |
| | | Date endTime = beforeTime.getTime(); |
| | | //pa.put("sensorKey","e1"); |
| | | pa.put("yearAndMonth","202012"); |
| | | pa.put("time","2020-12-03 10:10:00"); |
| | | pa.put("yearAndMonth",sdf.format(newTime).substring(0,7).replace("-","")); |
| | | pa.put("startTime",startTime); |
| | | pa.put("endTime",endTime); |
| | | List<String> macs = new ArrayList<>(); |
| | | List<String> sensorKeys = new ArrayList<>(); |
| | | for (Device device:deviceList) { |
| | |
| | | sensorKeys.add("e23"); |
| | | pa.put("macs",macs); |
| | | pa.put("sensorKeys",sensorKeys); |
| | | List<Map<String, Object>> fiveMinuteDataList = historyFiveMinutelyService.getFiveMinutesSersorDataByMacsAndTime(pa); |
| | | pa.put("macNumber",macs.size()); |
| | | List<Map<String, Object>> fiveMinuteDataList = historyFiveMinutelyService.getFiveMinutesDataByMacsAndTimeSolt(pa); |
| | | //声明数组,存放所有设备的数值 |
| | | double[] allDeviceData = new double[fiveMinuteDataList.size()]; |
| | | System.out.println(fiveMinuteDataList); |
| | | int i = 0; |
| | | //计算风向 |
| | | List<Map<String,Object>> windList = new ArrayList<>(); |
| | | for (Map map:fiveMinuteDataList) { |
| | | String[] wind_speed = map.get("e18").toString().split(","); |
| | | if (!map.containsKey("e23")){ |
| | | continue; |
| | | } |
| | | String[] wind_direction = map.get("e23").toString().split(","); |
| | | Map<String,Object> windMap = new HashMap<>(); |
| | | windMap.put("wind_speed",wind_speed[0].substring(1,wind_speed[0].length())); |
| | |
| | | //计算污染源点与设备点之间的距离 |
| | | double distance = mapUtils.getDistance(pollutionSourcePoint.getLongitude(),pollutionSourcePoint.getLatitude(),referenceDevice.getLongitude(),referenceDevice.getLatitude()); |
| | | //已知距离,角度,求x,y |
| | | double x = Math.cos(minDisparity.get().getValue())*distance; |
| | | double y = Math.sin(minDisparity.get().getValue())*distance; |
| | | double x = Math.cos(Math.toRadians(minDisparity.get().getValue()))*distance; |
| | | double y = Math.sin(Math.toRadians(minDisparity.get().getValue()))*distance; |
| | | //获取设备的数值 |
| | | String[] fiveMinuteData = fiveMinuteDataMap.get("e21").toString().split(","); |
| | | String[] fiveMinuteData = fiveMinuteDataMap.get(sensorKey).toString().split(","); |
| | | double c = Double.parseDouble(fiveMinuteData[0].substring(1,fiveMinuteData[0].length()))-deviceDataAvg; |
| | | System.out.println(c); |
| | | //计算源强 |
| | | double pollutionSourceIntensity = EmissionDataUtil.getPollutionSourceIntensity(c,x,y,res.get("wind_speed")); |
| | | System.out.println(pollutionSourceIntensity); |
| | | |
| | | //存放地图中心点 |
| | | Map<String,Object> center = new HashMap<>(); |
| | |
| | | numericalValueMap7.put("lat",31.450588); |
| | | numericalValueMap7.put("count",0.10); |
| | | numericalValueList.add(numericalValueMap7); |
| | | System.out.println(numericalValueList.toString()); |
| | | |
| | | |
| | | JSONObject params = new JSONObject(); |