ZhuDongming
2020-04-15 8110506221e3c34a62202e34b7dd28227c13c714
update
1 files modified
24 ■■■■ changed files
src/main/java/com/moral/controller/ScreenController.java 24 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/ScreenController.java
@@ -1388,17 +1388,29 @@
    @ApiOperation(value = "获取设备数据报表", notes = "获取设备数据报表")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "sensorKey", value = "传感器key", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "organizationId", value = "登录账号的组织id(如99)", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "organizationId", defaultValue = "8", value = "登录账号的组织id", required = true, paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "regionCode", defaultValue = "320583", value = "区域码", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "time", value = "时间(格式:2020-04-09或2019-04)", required = true, paramType = "query", dataType = "String")})
    public ResultBean<List<Map<String, Object>>> getDevicesDataToExcel(HttpServletRequest request) throws Exception {
        Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
        ParameterUtils.getTimeType4Time(parameters);
        parameters.put("sensorKeys", Arrays.asList(parameters.get("sensorKey")));
        Object organizationId = parameters.get("organizationId");
        Set<Integer> organizationIds = organizationService.getChildOrganizationIds(Integer.valueOf(organizationId.toString()));
        List<String> macList = deviceService.getMacsByOrganizationId(new ArrayList<>(organizationIds));
        Object sensorKey = parameters.get("sensorKey");
        parameters.put("sensorKeys", Arrays.asList(sensorKey));
        List<String> macList = new ArrayList<>();
        List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsAndDevicesByRegion(parameters);
        for (MonitorPoint m : monitorPoints) {
            for (Device d : m.getDevices()) {
                macList.add(d.getMac());
            }
        }
        parameters.put("macs", macList);
        List<Map<String, Object>> list = historyMinutelyService.getDevicesAvgDataToExcel(parameters);
        List<Map<String, Object>> list = new ArrayList<>();
        if (!CollectionUtils.isEmpty(macList)) {
            list = historyMinutelyService.getDevicesAvgDataToExcel(parameters);
        }
        for (Map<String, Object> map : list) {
            map.put("value", map.remove(sensorKey));
        }
        return new ResultBean<List<Map<String, Object>>>(list);
    }