| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping("/getWarning") |
| | | public R getWarning(){ |
| | | List<BasSensor> warning = new ArrayList<>(); |
| | | List<BasSensor> basSensors = basSensorService.selectList(new EntityWrapper<>(new BasSensor())); |
| | | for (BasSensor basSensor : basSensors) { |
| | | if ((basSensor.getTemperature() < 15 || basSensor.getTemperature() > 25) || basSensor.getHumidity() > 60){ |
| | | warning.add(basSensor); |
| | | } |
| | | } |
| | | return R.ok(warning); |
| | | } |
| | | |
| | | } |
| | |
| | | * 传感器温度 |
| | | */ |
| | | @ApiModelProperty(value= "传感器温度") |
| | | private String temperature; |
| | | private Double temperature; |
| | | |
| | | /** |
| | | * 传感器湿度 |
| | | */ |
| | | @ApiModelProperty(value= "传感器湿度") |
| | | private String humidity; |
| | | private Double humidity; |
| | | |
| | | /** |
| | | * 创建时间 |
| | |
| | | |
| | | public BasSensor() {} |
| | | |
| | | public BasSensor(Double number,String location,String temperature,String humidity) { |
| | | public BasSensor(Double number,String location,Double temperature,Double humidity) { |
| | | this.number = number; |
| | | this.location = location; |
| | | this.temperature = temperature; |
| New file |
| | |
| | | package com.zy.asrs.task; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.zy.asrs.entity.BasSensor; |
| | | import com.zy.asrs.service.BasSensorService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | @Slf4j |
| | | public class SensorWarningScheduler { |
| | | @Autowired |
| | | private BasSensorService sensorService; |
| | | |
| | | @Scheduled(cron = "0/3 * * * * ?") |
| | | private void warning(){ |
| | | List<BasSensor> basSensors = sensorService.selectList(new EntityWrapper<>(new BasSensor())); |
| | | for (BasSensor basSensor : basSensors) { |
| | | if ((basSensor.getTemperature() < 15 || basSensor.getTemperature() > 25) || basSensor.getHumidity() > 60){ |
| | | log.info(basSensor.getLocation() + "温湿度异常,温度:" + basSensor.getTemperature() + ",湿度:" + basSensor.getHumidity()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | wcs-slave: |
| | | # 由浅入深 |
| | | locGroupAscOrder: [ |
| | | {rowList: [1],minBay: 1,maxBay: 1}, |
| | | {rowList: [1],minBay: 1,maxBay: 2}, |
| | | # {rowList: [3,4,5,6],minBay: 1,maxBay: 16}, |
| | | # {rowList: [10,9,8,7],minBay: 1,maxBay: 16}, |
| | | # {rowList: [10,9,8,7,6,5,4,3],minBay: 17,maxBay: 22}, |
| | | # {rowList: [12,13],minBay: 1,maxBay: 22}, |
| | | # {rowList: [15,14],minBay: 1,maxBay: 22}, |
| | | # {rowList: [17,18,19,20,21,22,23],minBay: 1,maxBay: 22}, |
| | | {rowList: [2],minBay: 1,maxBay: 1}, |
| | | # {rowList: [2],minBay: 1,maxBay: 1}, |
| | | # {rowList: [11],minBay: 1,maxBay: 22}, |
| | | # {rowList: [16],minBay: 1,maxBay: 22}, |
| | | ] |
| | |
| | | var form = layui.form; |
| | | var admin = layui.admin; |
| | | |
| | | // 颜色判断函数 |
| | | function applyColorStyles() { |
| | | // 使用更精确的选择器 |
| | | $('.layui-table-box .layui-table-body table tbody tr').each(function() { |
| | | var $tr = $(this); |
| | | // 跳过表头行 |
| | | if ($tr.hasClass('layui-table-header') || $tr.find('td').length === 0) return; |
| | | |
| | | var $tempCell = $tr.find('td').eq(3); // 第3列:温度 |
| | | var $humiCell = $tr.find('td').eq(4); // 第4列:湿度 |
| | | |
| | | if ($tempCell.length && $humiCell.length) { |
| | | var tempText = $tempCell.text().trim(); |
| | | var humiText = $humiCell.text().trim(); |
| | | |
| | | // console.log('温度:', tempText, '湿度:', humiText); // 调试用 |
| | | |
| | | // 重置样式 |
| | | $tempCell.css({ |
| | | 'background-color': '', |
| | | 'color': '', |
| | | 'font-weight': '' |
| | | }); |
| | | $humiCell.css({ |
| | | 'background-color': '', |
| | | 'color': '', |
| | | 'font-weight': '' |
| | | }); |
| | | |
| | | // 温度判断 |
| | | if (tempText) { |
| | | var temp = parseFloat(tempText); |
| | | if (!isNaN(temp)) { |
| | | if (temp > 25 || temp < 15) { |
| | | $tempCell.css({ |
| | | 'background-color': 'red', |
| | | 'color': 'white', |
| | | 'font-weight': 'bold' |
| | | }); |
| | | // console.log('温度超出范围:', temp); // 调试用 |
| | | }else { |
| | | $tempCell.css({ |
| | | 'background-color': 'green', |
| | | 'color': 'white', |
| | | 'font-weight': 'bold' |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 湿度判断 |
| | | if (humiText) { |
| | | var humi = parseFloat(humiText); |
| | | if (!isNaN(humi)) { |
| | | if (humi > 60) { |
| | | $humiCell.css({ |
| | | 'background-color': 'red', |
| | | 'color': 'white', |
| | | 'font-weight': 'bold' |
| | | }); |
| | | // console.log('湿度超出范围:', humi); // 调试用 |
| | | }else { |
| | | $humiCell.css({ |
| | | 'background-color': 'green', |
| | | 'color': 'white', |
| | | 'font-weight': 'bold' |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // 数据渲染 |
| | | var timer = setInterval(function () { |
| | | var timer = setInterval(function () { |
| | | tableIns = table.render({ |
| | | elem: '#basSensor', |
| | | headers: {token: localStorage.getItem('token')}, |
| | |
| | | ,{field: 'location', align: 'center',title: '传感器位置'} |
| | | ,{field: 'temperature', align: 'center',title: '传感器温度(°c)'} |
| | | ,{field: 'humidity', align: 'center',title: '传感器湿度(%)'} |
| | | // ,{field: 'createTime', align: 'center',title: '创建时间'} |
| | | |
| | | // ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:120} |
| | | ]], |
| | | request: { |
| | | pageName: 'curr', |
| | |
| | | } |
| | | pageCurr=curr; |
| | | limit(); |
| | | |
| | | // 应用颜色样式 - 使用多个setTimeout确保DOM完全渲染 |
| | | setTimeout(function() { |
| | | setTimeout(function() { |
| | | applyColorStyles(); |
| | | }, 200); |
| | | }, 100); |
| | | } |
| | | }); |
| | | },1000); |
| | | // clearInterval(timer); |
| | | },3000); |
| | | |
| | | // 监听排序事件 |
| | | table.on('sort(basSensor)', function (obj) { |
| | |
| | | showEditModel(); |
| | | break; |
| | | case 'deleteData': |
| | | if (checkStatus.length === 0) { |
| | | layer.msg('请选择要删除的数据', {icon: 2}); |
| | | return; |
| | | } |
| | | del(checkStatus.map(function (d) { |
| | | return d.id; |
| | | })); |
| | | break; |
| | | if (checkStatus.length === 0) { |
| | | layer.msg('请选择要删除的数据', {icon: 2}); |
| | | return; |
| | | } |
| | | del(checkStatus.map(function (d) { |
| | | return d.id; |
| | | })); |
| | | break; |
| | | case 'exportData': |
| | | admin.confirm('确定导出Excel吗', {shadeClose: true}, function(){ |
| | | var titles=[]; |
| | |
| | | form.on('submit(search)', function (data) { |
| | | pageCurr = 1; |
| | | tableReload(false); |
| | | // 搜索后重新应用样式 |
| | | setTimeout(applyColorStyles, 500); |
| | | }); |
| | | |
| | | // 重置 |
| | |
| | | pageCurr = 1; |
| | | clearFormVal($('#search-box')); |
| | | tableReload(false); |
| | | // 重置后重新应用样式 |
| | | setTimeout(applyColorStyles, 500); |
| | | }); |
| | | |
| | | // 时间选择器 |
| | |
| | | ,type: 'datetime' |
| | | ,range: true |
| | | }); |
| | | |
| | | }, 300); |
| | | } |
| | | layDateRender(); |
| | |
| | | tableIns.reload({ |
| | | where: searchData, |
| | | page: {curr: pageCurr} |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | // let timer = setInterval(function () { |
| | | // $(".layui-laypage-btn")[0].click(); |
| | | // },1000); |
| | | clearInterval(timer); |
| | | clearInterval(timer); |