From 9781c2318d35f761de83fffe20f66e099d00988e Mon Sep 17 00:00:00 2001 From: lizijie <lzjiiie@163.com> Date: Wed, 12 Jun 2019 14:07:08 +0800 Subject: [PATCH] 加入单位 --- src/main/java/com/moral/controller/ScreenController.java | 44 +++++++++++++++++++++++++++++++++----------- 1 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/moral/controller/ScreenController.java b/src/main/java/com/moral/controller/ScreenController.java index 96c1709..5370d11 100644 --- a/src/main/java/com/moral/controller/ScreenController.java +++ b/src/main/java/com/moral/controller/ScreenController.java @@ -904,7 +904,7 @@ return new ResultBean<Map<String, Object>>(map); }*/ - @GetMapping("getSensorByMonitorPointId") + /*@GetMapping("getSensorByMonitorPointId") @ApiOperation(value = "������������", notes = "������������") @ApiImplicitParams(value = { @ApiImplicitParam(name = "monitor_point_id", value = "������������id", required = true, paramType = "query", dataType = "String") @@ -916,7 +916,7 @@ Map<String, Object> map = sensorUnitService.getSensorsByMonitPointId(monitor_point_id); System.out.println("ScreenController-----getSensorByMonitorPointId-----map:"+map); return new ResultBean<Map<String, Object>>(map); - } + }*/ @GetMapping("AIForecast") @ApiOperation(value = "AI������", notes = "AI������") @@ -934,19 +934,41 @@ Object sensorKey = parameters.remove("sensorKey"); parameters.put("sensors", Arrays.asList(sensorKey)); List<Map<String, Object>> list = historyMinutelyService.getMonitorPointOrDeviceAvgData(parameters); + System.out.println("ScreenController-----AIForecast-----list:"+list); //������������������ - Map<String, Object> sensorMap = sensorUnitService.getSensorsByMonitPointId(monitor_point_id); + Map<String, Map<String, Object>> sensorMap = sensorUnitService.getSensorsByMonitPointId(monitor_point_id); - for (Map<String, Object> map : list) { - String time = map.get("time").toString(); - time = time.substring(time.length() - 2); - map.put("time", Integer.valueOf(time)); - map.put("value", map.remove(sensorKey)); + if(sensorMap!=null && !sensorMap.isEmpty()) { + for (Map<String, Object> map : list) { + String time = map.get("time").toString(); + time = time.substring(time.length() - 2); + map.put("time", Integer.valueOf(time)); + map.put("value", map.remove(sensorKey)); + String sensor = map.get("sensorKey").toString(); + if(sensorMap.get(sensor)!=null) { + map.put("unit", sensorMap.get("unit")); + map.put("name", sensorMap.get("name")); + map.put("rules", sensorMap.get("rules")); + }else { + map.put("unit", null); + map.put("name", null); + map.put("rules", null); + } + } + }else { + for (Map<String, Object> map : list) { + String time = map.get("time").toString(); + time = time.substring(time.length() - 2); + map.put("time", Integer.valueOf(time)); + map.put("value", map.remove(sensorKey)); + map.put("unit", null); + map.put("name", null); + map.put("rules", null); + } } - - return null; - //return new ResultBean<List<Map<String, Object>>>(result); + //return null; + return new ResultBean<List<Map<String, Object>>>(list); } } -- Gitblit v1.8.0