自动化立体仓库 - WMS系统
#1
dubin
2025-11-20 0ee5fb34623360eb8b43a8a032023890de1401d8
#1
1个文件已添加
4个文件已修改
167 ■■■■ 已修改文件
src/main/java/com/zy/asrs/controller/BasSensorController.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/entity/BasSensor.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/task/SensorWarningScheduler.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/basSensor/basSensor.js 117 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/BasSensorController.java
@@ -124,4 +124,16 @@
        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);
    }
}
src/main/java/com/zy/asrs/entity/BasSensor.java
@@ -38,13 +38,13 @@
     * 传感器温度
     */
    @ApiModelProperty(value= "传感器温度")
    private String temperature;
    private Double temperature;
    /**
     * 传感器湿度
     */
    @ApiModelProperty(value= "传感器湿度")
    private String humidity;
    private Double humidity;
    /**
     * 创建时间
@@ -54,7 +54,7 @@
    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;
src/main/java/com/zy/asrs/task/SensorWarningScheduler.java
New file
@@ -0,0 +1,28 @@
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());
            }
        }
    }
}
src/main/resources/application.yml
@@ -53,14 +53,14 @@
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},
  ]
src/main/webapp/static/js/basSensor/basSensor.js
@@ -9,8 +9,82 @@
    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')},
@@ -27,9 +101,6 @@
                ,{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',
@@ -52,10 +123,16 @@
                }
                pageCurr=curr;
                limit();
                // 应用颜色样式 - 使用多个setTimeout确保DOM完全渲染
                setTimeout(function() {
                    setTimeout(function() {
                        applyColorStyles();
                    }, 200);
                }, 100);
            }
        });
    },1000);
//    clearInterval(timer);
    },3000);
    // 监听排序事件
    table.on('sort(basSensor)', function (obj) {
@@ -79,14 +156,14 @@
                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=[];
@@ -211,6 +288,8 @@
    form.on('submit(search)', function (data) {
        pageCurr = 1;
        tableReload(false);
        // 搜索后重新应用样式
        setTimeout(applyColorStyles, 500);
    });
    // 重置
@@ -218,6 +297,8 @@
        pageCurr = 1;
        clearFormVal($('#search-box'));
        tableReload(false);
        // 重置后重新应用样式
        setTimeout(applyColorStyles, 500);
    });
    // 时间选择器
@@ -228,7 +309,6 @@
                ,type: 'datetime'
                ,range: true
            });
        }, 300);
    }
    layDateRender();
@@ -248,10 +328,7 @@
    tableIns.reload({
        where: searchData,
        page: {curr: pageCurr}
     });
    });
}
// let timer = setInterval(function () {
//     $(".layui-laypage-btn")[0].click();
// },1000);
clearInterval(timer);
clearInterval(timer);