From 4389555a911b3cf1aa520c1059f6ac25fd408c49 Mon Sep 17 00:00:00 2001 From: wenjy Date: Mon, 11 Apr 2022 13:18:56 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E8=AE=BE=E5=A4=87=E6=9B=B2?= =?UTF-8?q?=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../record/RecordSensorDataController.java | 53 ++++++++++++------- .../recordSensorData/temperatureTrend.html | 32 +++++------ .../mapper/system/RecordSensorDataMapper.xml | 13 +++-- 3 files changed, 58 insertions(+), 40 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/record/RecordSensorDataController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/record/RecordSensorDataController.java index 110bc6b..86753c0 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/record/RecordSensorDataController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/record/RecordSensorDataController.java @@ -31,8 +31,7 @@ public class RecordSensorDataController { @Autowired private IRecordSensorDataService iRecordSensorDataService; - @Autowired - private IBaseSensorInfoService baseSensorInfoService; + @Autowired private IBaseSensorInfoService baseSensorInfoService; private String prefix = "record/recordSensorData"; @@ -45,11 +44,19 @@ public class RecordSensorDataController { } @GetMapping("/getTemperatureTrend") - public String getTemperatureTrend(@RequestParam("id") String id, ModelMap mmap){ + public String getTemperatureTrend(@RequestParam("id") String id, ModelMap mmap) { mmap.put("sensorId", id); return prefix + "/temperatureTrend"; } + /** + * 获取设备历史数据 + * + * @author WenJY + * @date 2022/4/11 13:18 + * @param baseSensorInfoDto + * @return java.lang.String + */ @PostMapping("/list") @ResponseBody public String _getList(BaseSensorInfoDto baseSensorInfoDto) { @@ -82,9 +89,17 @@ public class RecordSensorDataController { return JSONArray.toJSONString(maps); } + /** + * 温度趋势曲线 + * + * @author WenJY + * @date 2022/4/11 13:17 + * @param baseSensorInfoDto + * @return java.lang.String + */ @PostMapping("/getTemperatureTrendJson") @ResponseBody - public String getTemperatureTrendJson(BaseSensorInfoDto baseSensorInfoDto){ + public String getTemperatureTrendJson(BaseSensorInfoDto baseSensorInfoDto) { baseSensorInfoDto.setTableName("record_" + baseSensorInfoDto.getSensorType()); @@ -110,18 +125,23 @@ public class RecordSensorDataController { baseSensorInfoDto.setParams(paramMap); - List baseSensorInfoDtos = baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo(baseSensorInfoDto.getSensorId())); + List baseSensorInfoDtos = + baseSensorInfoService.selectBaseSensorInfoList( + new BaseSensorInfo(baseSensorInfoDto.getSensorId())); - List baseSensorInfoDtos1 = baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo(null,null,null,baseSensorInfoDtos.get(0).getMonitorunitId())); + List baseSensorInfoDtos1 = + baseSensorInfoService.selectBaseSensorInfoList( + new BaseSensorInfo(null, null, null, baseSensorInfoDtos.get(0).getMonitorunitId())); List> maps = new ArrayList<>(); for (BaseSensorInfoDto sensorInfoDto : baseSensorInfoDtos1) { baseSensorInfoDto.setSensorId(sensorInfoDto.getSensorId()); - maps.addAll(maps.size(),iRecordSensorDataService.selectTemperatureList(baseSensorInfoDto)); + maps.addAll(maps.size(), iRecordSensorDataService.selectTemperatureList(baseSensorInfoDto)); } - Map>> sensorId = maps.stream().collect(Collectors.groupingBy(m -> (m.get("sensorName").toString()))); + Map>> sensorId = + maps.stream().collect(Collectors.groupingBy(m -> (m.get("sensorName").toString()))); List legend = new ArrayList<>(); List xAxis = new ArrayList<>(); @@ -137,25 +157,21 @@ public class RecordSensorDataController { xAxis.add(map.get("collectTime").toString()); data.add(Convert.toBigDecimal(map.get("value"))); } - series.add(new Series(entry.getKey(),"line","Total",data)); - + series.add(new Series(entry.getKey(), "line", "Total", data)); } List collect = xAxis.stream().distinct().collect(Collectors.toList()); String s = JSONArray.toJSONString(new Root(legend, collect, series)); - System.out.println("曲线趋势数据格式打印:"+s); - return s; } } @Data -class Root{ +class Root { - public Root() { - } + public Root() {} public Root(List legend, List xAxis, List series) { this.legend = legend; @@ -171,10 +187,9 @@ class Root{ } @Data -class Series{ +class Series { - public Series() { - } + public Series() {} public Series(String name, String type, String stack, List data) { this.name = name; @@ -190,4 +205,4 @@ class Series{ private String stack; private List data; -} \ No newline at end of file +} diff --git a/ruoyi-admin/src/main/resources/templates/record/recordSensorData/temperatureTrend.html b/ruoyi-admin/src/main/resources/templates/record/recordSensorData/temperatureTrend.html index 8bd97bf..0e2ab53 100644 --- a/ruoyi-admin/src/main/resources/templates/record/recordSensorData/temperatureTrend.html +++ b/ruoyi-admin/src/main/resources/templates/record/recordSensorData/temperatureTrend.html @@ -60,10 +60,10 @@ - - + + - +