From 32eb62814462a484ca3849f2c18865aee5fd36fc Mon Sep 17 00:00:00 2001 From: wenjy Date: Tue, 15 Mar 2022 16:17:45 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E4=BC=A0=E6=84=9F=E5=99=A8?= =?UTF-8?q?=E6=B1=87=E6=80=BB=E9=A1=B5=E9=9D=A2=E6=8E=A5=E5=8F=A3=E5=88=9D?= =?UTF-8?q?=E6=AD=A5=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/SensorSummaryController.java | 34 +++++++++-- .../static/js/Iot-ui/sensorSummary.js | 57 +++++++------------ .../static/js/Iot-ui/sensorTableList.js | 7 ++- .../templates/iot-ui/sensorSummary.html | 7 +-- .../ruoyi/system/domain/BaseSensorType.java | 6 ++ 5 files changed, 62 insertions(+), 49 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/SensorSummaryController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/SensorSummaryController.java index fd5cc08..fa982fd 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/SensorSummaryController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/SensorSummaryController.java @@ -5,6 +5,12 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.system.domain.BaseSensorInfo; +import com.ruoyi.system.domain.BaseSensorType; +import com.ruoyi.system.domain.dto.BaseSensorInfoDto; +import com.ruoyi.system.service.IBaseSensorInfoService; +import com.ruoyi.system.service.IBaseSensorTypeService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.GetMapping; @@ -28,7 +34,11 @@ import java.util.UUID; @RequestMapping("/iot/sensorSummary") public class SensorSummaryController extends BaseController { + @Autowired + private IBaseSensorTypeService baseSensorTypeService; + @Autowired + private IBaseSensorInfoService baseSensorInfoService; @GetMapping() public String sensorSummary() @@ -36,24 +46,38 @@ public class SensorSummaryController extends BaseController { return "iot-ui/sensorSummary"; } + @GetMapping("/getSensorType") + @ResponseBody + public String getSensorType(){ + List baseSensorTypeList = baseSensorTypeService.selectBaseSensorTypeList(new BaseSensorType(null,null,0L)); + + return JSONArray.toJSONString(baseSensorTypeList); + } + @GetMapping("/getSensorInfo") @ResponseBody - public String getSensorInfo(){ + public String getSensorInfo(String sensorTypeId){ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + List baseSensorInfoDtos = baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo(sensorTypeId, 0L)); + List sensorTableModelList = new ArrayList<>(); - for (int i =1;i<24;i++){ + for (int i =1;i{ - // alert("成功") - const sensorInfo = [ - { - sensorCode:"E001", - sensorName:"温度传感器" - },{ - sensorCode:"E002", - sensorName:"湿度传感器" - },{ - sensorCode:"E003", - sensorName:"振动传感器" - },{ - sensorCode:"E004", - sensorName:"水浸传感器" - },{ - sensorCode:"E005", - sensorName:"烟雾传感器" - },{ - sensorCode:"E006", - sensorName:"门磁传感器" - },{ - sensorCode:"E007", - sensorName:"AI识别" - } - ]; - document.getElementById("sensorType").contentWindow.document.designMode = "on"; document.getElementById("sensorType").contentWindow.document.contentEditable = true; @@ -34,16 +8,29 @@ $(()=>{ cssLink.type = "text/css"; document.getElementById("sensorType").contentWindow.document.body.appendChild(cssLink); - for(let i=0;i { + $("#sensorType").html(""); + res.map(x=>{ + var div = document.getElementById("sensorType").contentWindow.document.createElement("button"); + div.id = x.sensortypeId; + div.innerText = x.sensortypeName; + div.onclick = btnBaby1_onclick; + div.setAttribute("class","sensorTypeItem"); + document.getElementById("sensorType").contentWindow.document.body.appendChild(div); + }) + sensorInfoList(res[0].sensortypeId); + }, + error: () => { + console.log("失败"); + } + }) + }) function btnBaby1_onclick(){ - alert("切换传感器") + sensorInfoList(this.id); } \ No newline at end of file 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 5a47fea..8bac2ae 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 @@ -1,6 +1,7 @@ -$(()=>{ +const sensorInfoList = function(sensorTypeId) { + $('#table').bootstrapTable('destroy'); $('#table').bootstrapTable({ - url: '/iot/sensorSummary/getSensorInfo', // 表格数据来源 + url: '/iot/sensorSummary/getSensorInfo?sensorTypeId='+sensorTypeId, // 表格数据来源 pageNumber: 1, pagination: true, sidePagination: 'client', @@ -42,7 +43,7 @@ $(()=>{ align: 'center', }] }); -}) +} const onSearchByMonitorLocation = function (obj) { setTimeout(function(){ diff --git a/ruoyi-admin/src/main/resources/templates/iot-ui/sensorSummary.html b/ruoyi-admin/src/main/resources/templates/iot-ui/sensorSummary.html index 2c410b3..82a6e44 100644 --- a/ruoyi-admin/src/main/resources/templates/iot-ui/sensorSummary.html +++ b/ruoyi-admin/src/main/resources/templates/iot-ui/sensorSummary.html @@ -23,6 +23,7 @@