| | |
| | | return new ResultBean<Map<String,Object>>(datasMap); |
| | | } |
| | | |
| | | @GetMapping("cangzhouMIdGetAllDevice") |
| | | public ResultBean<Map<String,Object>> cangzhouMIdGetAllDevice(HttpServletRequest request) { |
| | | //获取参数,传感器和monitorpointId |
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); |
| | | if ((!parameters.containsKey("sensorKey")) || (!parameters.containsKey("monitorPointId"))) |
| | | return ResultBean.fail("参数为null"); |
| | | String sensorKey = (String) parameters.get("sensorKey"); |
| | | Integer monitorPointId = Integer.parseInt((String) parameters.get("monitorPointId")); |
| | | MonitorPoint mPoint = monitorPointService.queryMonitorPointById(monitorPointId); |
| | | Integer code = mPoint.getCityCode(); |
| | | List<Device> devices = null; |
| | | if (code == 130900){ |
| | | devices = deviceService.getDeviceByCode(); |
| | | }else { |
| | | devices = deviceService.getDevicesByMonitorPointId(monitorPointId); |
| | | } |
| | | //根据monitorpointId获取该站点下所有设备mac集合 |
| | | if (ObjectUtils.isEmpty(devices)) |
| | | return ResultBean.fail("站点下无设备或monitorPointId错误"); |
| | | List<String> macs = new ArrayList<>(); |
| | | devices.forEach(p -> { |
| | | macs.add(p.getMac()); |
| | | }); |
| | | |
| | | //根据时间和mac号集合以及传感器参数查询五分钟平均数据 |
| | | Map<String, Object> timeAndYearMonth = getTimeAndYearMonthForFiveMinuteData(); |
| | | String time = (String) timeAndYearMonth.get("time"); |
| | | String yearAndMonth = (String) timeAndYearMonth.get("yearAndMonth"); |
| | | parameters.put("time", time); |
| | | parameters.put("yearAndMonth", yearAndMonth); |
| | | parameters.put("macs", macs); |
| | | List<Map<String, Object>> datas = historyFiveMinutelyService.getFiveMinutesDataByMacsAndTime(parameters); |
| | | |
| | | //如果当前五分钟数据还没有插入,则提取前五分钟数据返回 |
| | | if (ObjectUtils.isEmpty(datas)) { |
| | | time = getFiveMinuteAgoTime(time); |
| | | parameters.put("time", time); |
| | | datas = historyFiveMinutelyService.getFiveMinutesDataByMacsAndTime(parameters); |
| | | } |
| | | datas = insertDeviceInfo(datas, devices); |
| | | |
| | | //根据monitorPointId获取国控站坐标 |
| | | List<Map<String,Object>> coordinate = new ArrayList<>(); |
| | | MonitorPoint monitorPoint = monitorPointService.queryMonitorPointById(monitorPointId); |
| | | Integer orgId = monitorPoint.getOrganizationId(); |
| | | List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsByOrganizationId(orgId); |
| | | monitorPoints.forEach(value->{ |
| | | if("国控站".equals(value.getDescription())) { |
| | | List list = LatLngTransformation.Convert_BD09_To_GCJ02(value.getLatitude(), value.getLongitude()); |
| | | Map<String,Object> controlStation = new HashMap<>(); |
| | | controlStation.put("name",value.getName()); |
| | | controlStation.put("longitude", list.get(0)); |
| | | controlStation.put("latitude", list.get(1)); |
| | | coordinate.add(controlStation); |
| | | } |
| | | }); |
| | | |
| | | Map<String,Object> datasMap = new HashMap<>(); |
| | | datasMap.put("coordinate",coordinate); |
| | | datasMap.put("device",datas); |
| | | |
| | | return new ResultBean<Map<String,Object>>(datasMap); |
| | | } |
| | | |
| | | /** |
| | | * @Description: 根据mac号获取单台设备信息,特殊客户只显示客户需要的传感器信息 |
| | | * @Param: [request] |