From 3f051af871c6c5572631dc77e5344ae472aa1e12 Mon Sep 17 00:00:00 2001 From: wenjy Date: Thu, 7 Apr 2022 17:40:50 +0800 Subject: [PATCH] =?UTF-8?q?add=20-=20=E4=BC=A0=E6=84=9F=E5=99=A8=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E6=95=B0=E6=8D=AE=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../record/RecordSensorDataController.java | 65 ++++++++ .../static/js/Iot-ui/sensorTableList.js | 22 ++- .../recordSensorData/recordSensorData.html | 142 ++++++++++++++++++ .../system/domain/dto/BaseSensorInfoDto.java | 11 ++ .../system/mapper/RecordSensorDataMapper.java | 16 ++ .../service/IRecordSensorDataService.java | 16 ++ .../impl/RecordSensorDataServiceImpl.java | 28 ++++ .../mapper/system/RecordSensorDataMapper.xml | 39 +++++ 8 files changed, 337 insertions(+), 2 deletions(-) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/web/controller/record/RecordSensorDataController.java create mode 100644 ruoyi-admin/src/main/resources/templates/record/recordSensorData/recordSensorData.html create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/mapper/RecordSensorDataMapper.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/service/IRecordSensorDataService.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RecordSensorDataServiceImpl.java create mode 100644 ruoyi-system/src/main/resources/mapper/system/RecordSensorDataMapper.xml 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 new file mode 100644 index 0000000..aa9a70f --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/record/RecordSensorDataController.java @@ -0,0 +1,65 @@ +package com.ruoyi.web.controller.record; + +import com.alibaba.fastjson.JSONArray; +import com.ruoyi.system.domain.dto.BaseSensorInfoDto; +import com.ruoyi.system.service.IRecordSensorDataService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.*; + +import java.util.*; + +/** + * 传感器数据记录 + * + * @author WenJY + * @date 2022年04月07日 16:20 + */ +@Controller +@RequestMapping("/record/recordSensorData") +public class RecordSensorDataController { + + @Autowired private IRecordSensorDataService iRecordSensorDataService; + + private String prefix = "record/recordSensorData"; + + @GetMapping("/getPage") + public String recordSensorData(@RequestParam("id") String id, ModelMap mmap) { + mmap.put("sensorId", id); + return prefix + "/recordSensorData"; + } + + @PostMapping("/list") + @ResponseBody + public String _getList(BaseSensorInfoDto baseSensorInfoDto) { + baseSensorInfoDto.setTableName("record_" + baseSensorInfoDto.getSensorType()); + + Date date = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.add(Calendar.DATE, -5); + date = calendar.getTime(); + + Map paramMap = new HashMap(); + + if (baseSensorInfoDto.getBeginCollectTime() == null) { + paramMap.put("beginCollectTime", date); + } else { + paramMap.put("beginCollectTime", baseSensorInfoDto.getBeginCollectTime()); + } + + if (baseSensorInfoDto.getEndCollectTime() == null) { + paramMap.put("endCollectTime", new Date()); + } else { + paramMap.put("endCollectTime", baseSensorInfoDto.getEndCollectTime()); + } + + baseSensorInfoDto.setParams(paramMap); + + List> maps = + iRecordSensorDataService.selectSensorDataList(baseSensorInfoDto); + + return JSONArray.toJSONString(maps); + } +} diff --git a/ruoyi-admin/src/main/resources/static/js/Iot-ui/sensorTableList.js b/ruoyi-admin/src/main/resources/static/js/Iot-ui/sensorTableList.js index 7d8808f..090ce6b 100644 --- a/ruoyi-admin/src/main/resources/static/js/Iot-ui/sensorTableList.js +++ b/ruoyi-admin/src/main/resources/static/js/Iot-ui/sensorTableList.js @@ -53,6 +53,20 @@ const sensorInfoList = function (sensorTypeId) { }); columnsArray.push({field: "edgeId", title: "边设备ID", width: 180,height: 60, colspan: 1, rowspan: 1, align: "center"}); + columnsArray.push({ + title: "操作", + width: 100, + colspan: 1, + rowspan: 1, + align: "center", + height: 60, + formatter: function(value, row, index) { + var actions = []; + actions.push(' '); + return actions.join(''); + } + }); + } $('#table').bootstrapTable('destroy'); @@ -106,7 +120,7 @@ const onSearchByMonitorLocation = function (obj) { var storeId = document.getElementById('table'); var rowsLength = storeId.rows.length; var key = obj.value; - var searchCol = storeId.rows.item(0).cells.length-3; + var searchCol = storeId.rows.item(0).cells.length-4; for (var i = 1; i < rowsLength; i++) { var searchText = storeId.rows[i].cells[searchCol].innerHTML; if (searchText.match(key)) { @@ -140,7 +154,7 @@ const onSearchByCollectTime = function (obj) { var storeId = document.getElementById('table'); var rowsLength = storeId.rows.length; var key = obj.value; - var searchCol = storeId.rows.item(0).cells.length-2; + var searchCol = storeId.rows.item(0).cells.length-3; for (var i = 1; i < rowsLength; i++) { var searchText = storeId.rows[i].cells[searchCol].innerHTML; if (searchText.match(key)) { @@ -150,4 +164,8 @@ const onSearchByCollectTime = function (obj) { } } }, 500); +} + +const historyButton = function(id) { + location.href = '/record/recordSensorData/getPage?id='+id; } \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/record/recordSensorData/recordSensorData.html b/ruoyi-admin/src/main/resources/templates/record/recordSensorData/recordSensorData.html new file mode 100644 index 0000000..6154d08 --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/record/recordSensorData/recordSensorData.html @@ -0,0 +1,142 @@ + + + + + + +
+
+
+
+
+ +
+
+
+ + +
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BaseSensorInfoDto.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BaseSensorInfoDto.java index c71e5b5..37a49d7 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BaseSensorInfoDto.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BaseSensorInfoDto.java @@ -2,8 +2,10 @@ package com.ruoyi.system.domain.dto; import com.ruoyi.system.domain.BaseSensorInfo; import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; import java.math.BigDecimal; +import java.util.Date; /** * @author WenJY @@ -23,4 +25,13 @@ public class BaseSensorInfoDto extends BaseSensorInfo { private String reportParam; /** 数据采集时间 */ private String collectTime; + + private String tableName; + + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date beginCollectTime; + + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date endCollectTime; + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RecordSensorDataMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RecordSensorDataMapper.java new file mode 100644 index 0000000..ae6c8aa --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RecordSensorDataMapper.java @@ -0,0 +1,16 @@ +package com.ruoyi.system.mapper; + +import com.ruoyi.system.domain.dto.BaseSensorInfoDto; + +import java.util.List; +import java.util.Map; + +/** + * 传感器数据记录 + * @author WenJY + * @date 2022年04月07日 16:24 + */ +public interface RecordSensorDataMapper { + + List> selectSensorDataList(BaseSensorInfoDto baseSensorInfoDto); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IRecordSensorDataService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IRecordSensorDataService.java new file mode 100644 index 0000000..e0fc50d --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IRecordSensorDataService.java @@ -0,0 +1,16 @@ +package com.ruoyi.system.service; + +import com.ruoyi.system.domain.dto.BaseSensorInfoDto; + +import java.util.List; +import java.util.Map; + +/** + * @author WenJY + * @date 2022年04月07日 16:23 + */ +public interface IRecordSensorDataService { + + List> selectSensorDataList(BaseSensorInfoDto baseSensorInfoDto); + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RecordSensorDataServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RecordSensorDataServiceImpl.java new file mode 100644 index 0000000..74cbfe5 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RecordSensorDataServiceImpl.java @@ -0,0 +1,28 @@ +package com.ruoyi.system.service.impl; + +import com.ruoyi.system.domain.dto.BaseSensorInfoDto; +import com.ruoyi.system.mapper.RecordSensorDataMapper; +import com.ruoyi.system.service.IRecordSensorDataService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * 传感器数据记录 + * @author WenJY + * @date 2022年04月07日 16:23 + */ +@Service +public class RecordSensorDataServiceImpl implements IRecordSensorDataService { + + @Autowired + private RecordSensorDataMapper recordSensorDataMapper; + + @Override + public List> selectSensorDataList(BaseSensorInfoDto baseSensorInfoDto) { + System.out.println("打印表名:"+baseSensorInfoDto.getTableName()); + return recordSensorDataMapper.selectSensorDataList(baseSensorInfoDto); + } +} diff --git a/ruoyi-system/src/main/resources/mapper/system/RecordSensorDataMapper.xml b/ruoyi-system/src/main/resources/mapper/system/RecordSensorDataMapper.xml new file mode 100644 index 0000000..37b0c0c --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/system/RecordSensorDataMapper.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file