diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/DeviceMonitorController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/DeviceMonitorController.java index 0496ea8..14afa12 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/DeviceMonitorController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/DeviceMonitorController.java @@ -18,10 +18,9 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; import java.util.stream.Collectors; /** @@ -40,6 +39,8 @@ public class DeviceMonitorController { @Autowired private StringRedisTemplate redisTemplate; + private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + /** * 获取监控单元列表 * @@ -143,6 +144,8 @@ public class DeviceMonitorController { info = JsonUtils.JSONObjectToMap(datavalue); + info.put("collectTime",jsonObject.get("collectTime").toString()); + info.put("datatype", data.get("datatype")); } @@ -156,6 +159,8 @@ public class DeviceMonitorController { info.put("sensorLocation", y.getSensorLocation()); + info.put("sensorStatus",y.getSensorStatus()); + result.add(info); }); }); diff --git a/ruoyi-admin/src/main/resources/static/js/Iot-ui/deviceMonitor.js b/ruoyi-admin/src/main/resources/static/js/Iot-ui/deviceMonitor.js index de61696..47a585e 100644 --- a/ruoyi-admin/src/main/resources/static/js/Iot-ui/deviceMonitor.js +++ b/ruoyi-admin/src/main/resources/static/js/Iot-ui/deviceMonitor.js @@ -23,63 +23,147 @@ const getParameter = function (dataType){ } const sensorCollectionRefresh = function (monitorUnitId) { - setInterval(function() { - $.ajax({ - url: "/iot/deviceMonitor/getSensorInfo?monitorunitId=" + monitorUnitId, - type: "get", - dataType: 'JSON', - success: (res) => { - $("#sensor-card-group").html(""); - res.map(x=>{ - let params = getParameter(x.datatype); - createDeviceModule(x,params); - }) - }, - error: () => { - console.log("失败"); - } - }) - }, 5000); + /*setInterval(function() { + + }, 5000);*/ + + $.ajax({ + url: "/iot/deviceMonitor/getSensorInfo?monitorunitId=" + monitorUnitId, + type: "get", + dataType: 'JSON', + success: (res) => { + $("#sensor-card-group").html(""); + res.map(x=>{ + let params = getParameter(x.datatype); + createDeviceModule(x,params); + }) + }, + error: () => { + console.log("失败"); + } + }) } const createDeviceModule = function (sensor,params) { - let html = '
${sensor['sensorStatus'] == null ? "-" : sensorStatus(sensor['sensorStatus'])}
`; + html+=`${sensor['collectTime'] == null ? "-" : collectTime(sensor['collectTime'])}
`; + html += '${sensor['sensorStatus'] == null ? "-" : sensorStatus(sensor['sensorStatus'])}
`; + html+=`${sensor['collectTime'] == null ? "-" : collectTime(sensor['collectTime'])}
`; + html += '${sensor['sensorStatus'] == null ? "-" : sensorStatus(sensor['sensorStatus'])}
`; + html+=`${sensor['collectTime'] == null ? "-" : collectTime(sensor['collectTime'])}
`; + html += '