kaiyu
2020-12-01 296d509996b9500c35be0b81860fa14c1d275048
src/main/java/com/moral/controller/WebController.java
@@ -66,28 +66,11 @@
    MapPathService mapPathService;
    @GetMapping("test")
    public ResultBean<List<WebProvince>> add(HttpServletRequest request) {
        String token = request.getHeader("token");
        List<WebProvince> mapPath = mapPathService.getMapPath(token);
        if (ObjectUtils.isEmpty(mapPath))
            return new ResultBean<>("获取地图信息失败", ResultBean.FAIL);
        return new ResultBean<>(mapPath);
    }
    @GetMapping("redisTest")
    public ResultBean<List<WebProvince>> redisTest(HttpServletRequest request) {
        String token = request.getHeader("token");
        List<WebProvince> mapPath = mapPathService.getMapPath(token);
        if (ObjectUtils.isEmpty(mapPath))
            return new ResultBean<>("获取地图信息失败", ResultBean.FAIL);
        return new ResultBean<>(mapPath);
    }
    @GetMapping("sqlTest")
    public ResultBean<List<WebProvince>> sqlTest(HttpServletRequest request) {
        String token = request.getHeader("token");
        List<WebProvince> mapPath = mapPathService.getMapPathTest(token);
        if (ObjectUtils.isEmpty(mapPath))
            return new ResultBean<>("获取地图信息失败", ResultBean.FAIL);
        return new ResultBean<>(mapPath);
@@ -224,17 +207,29 @@
    @GetMapping("fiveMinuteAvgData")
    public ResultBean<Map<String, Object>> getSensorFiveMinuteAvgData(HttpServletRequest request) {
        //获取参数,传感器和monitorpointId
        //获取参数,传感器和regionCode
        Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
        if ((!parameters.containsKey("sensorKey")) || (!parameters.containsKey("monitorPointId")))
        if ((!parameters.containsKey("sensorKey")) || (!parameters.containsKey("regionCode")))
            return ResultBean.fail("参数为null");
        String sensorKey = (String) parameters.get("sensorKey");
        Integer monitorPointId = Integer.parseInt((String) parameters.get("monitorPointId"));
        String regionCode = (String) parameters.get("regionCode");
        String token = request.getHeader("token");
        //根据monitorpointId获取该站点下所有设备mac集合
        List<Device> devices = deviceService.getDevicesByMonitorPointId(monitorPointId);
        //根据orgId获取该站点下所有设备mac集合
        String accountId = WebTokenUtils.getIdBytoken(token);
        Account account = accountService.getAccountById(Integer.parseInt(accountId));
        parameters.put("organizationId",account.getOrganizationId());
        List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsAndDevicesByRegion(parameters);
        if(ObjectUtils.isEmpty(monitorPoints))
            return ResultBean.fail("该账号对应地区无站点");
        List<Device> devices = new ArrayList<>();
        for (MonitorPoint monitorPoint : monitorPoints) {
             devices.addAll(monitorPoint.getDevices());
        }
        if (ObjectUtils.isEmpty(devices))
            return ResultBean.fail("站点下无设备或monitorPointId错误");
            return ResultBean.fail("该账号对应地区无设备");
        List<String> macs = new ArrayList<>();
        devices.forEach(p -> {
            macs.add(p.getMac());
@@ -259,9 +254,7 @@
        //根据monitorPointId获取国控站坐标
        List<Map<String, Object>> coordinate = new ArrayList<>();
        MonitorPoint monitorPoint = monitorPointService.queryMonitorPointById(monitorPointId);
        Integer orgId = monitorPoint.getOrganizationId();
        List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsByOrganizationId(orgId);
        Integer orgId = account.getOrganizationId();
        monitorPoints.forEach(value -> {
            if ("国控站".equals(value.getDescription())) {
                List list = LatLngTransformation.Convert_BD09_To_GCJ02(value.getLatitude(), value.getLongitude());
@@ -430,7 +423,7 @@
    @UserLoginToken
    @GetMapping("mapPath")
    public ResultBean<List<WebProvince>> mapPath(HttpServletRequest request) {
    public ResultBean<List<WebProvince>> getMapPath(HttpServletRequest request) {
        String token = request.getHeader("token");
        List<WebProvince> mapPath = mapPathService.getMapPath(token);
        if (ObjectUtils.isEmpty(mapPath))
@@ -438,6 +431,21 @@
        return new ResultBean<>(mapPath);
    }
    @UserLoginToken
    @GetMapping("monitor-points")
    public ResultBean<List<MonitorPoint>> getmMnitorPoints(HttpServletRequest request){
        String accountId = WebTokenUtils.getIdBytoken(request.getHeader("token"));
        Account account = accountService.getAccountById(Integer.parseInt(accountId));
        String regionCode = request.getParameter("regionCode");
        Map<String,Object> paramMap = new HashMap<>();
        paramMap.put("organizationId",account.getOrganizationId());
        paramMap.put("regionCode",regionCode);
        List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsAndDevicesByRegion(paramMap);
        if (ObjectUtils.isEmpty(monitorPoints))
            return new ResultBean<>("无对应站点设备信息", ResultBean.FAIL);
        return new ResultBean<>(monitorPoints);
    }
    /**
     * @Description: 返回结果添加设备经纬度以及state