自动化立体仓库 - WCS系统
Junjie
2023-05-19 ae2036c5a1394c2923e84cc6286579dcc3cc0062
设备异常列表
8个文件已添加
4个文件已修改
676 ■■■■■ 已修改文件
src/main/java/com/zy/asrs/controller/DeviceErrorController.java 124 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/entity/DeviceError.java 76 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/mapper/DeviceErrorMapper.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/DeviceErrorService.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/DeviceErrorServiceImpl.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/LedThread.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/ScaleThread.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/SiemensCrnThread.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/SiemensDevpThread.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/DeviceErrorMapper.xml 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/wms/js/deviceError/deviceError.js 249 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/deviceError/deviceError.html 104 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/DeviceErrorController.java
New file
@@ -0,0 +1,124 @@
package com.zy.asrs.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.core.common.DateUtils;
import com.zy.asrs.entity.DeviceError;
import com.zy.asrs.service.DeviceErrorService;
import com.core.annotations.ManagerAuth;
import com.core.common.BaseRes;
import com.core.common.Cools;
import com.core.common.R;
import com.zy.common.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;
@RestController
public class DeviceErrorController extends BaseController {
    @Autowired
    private DeviceErrorService deviceErrorService;
    @RequestMapping(value = "/deviceError/{id}/auth")
    @ManagerAuth
    public R get(@PathVariable("id") String id) {
        return R.ok(deviceErrorService.selectById(String.valueOf(id)));
    }
    @RequestMapping(value = "/deviceError/list/auth")
    @ManagerAuth
    public R list(@RequestParam(defaultValue = "1")Integer curr,
                  @RequestParam(defaultValue = "10")Integer limit,
                  @RequestParam(required = false)String orderByField,
                  @RequestParam(required = false)String orderByType,
                  @RequestParam Map<String, Object> param){
        EntityWrapper<DeviceError> wrapper = new EntityWrapper<>();
        excludeTrash(param);
        convert(param, wrapper);
        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
        return R.ok(deviceErrorService.selectPage(new Page<>(curr, limit), wrapper));
    }
    private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){
        for (Map.Entry<String, Object> entry : map.entrySet()){
            String val = String.valueOf(entry.getValue());
            if (val.contains(RANGE_TIME_LINK)){
                String[] dates = val.split(RANGE_TIME_LINK);
                wrapper.ge(entry.getKey(), DateUtils.convert(dates[0]));
                wrapper.le(entry.getKey(), DateUtils.convert(dates[1]));
            } else {
                wrapper.like(entry.getKey(), val);
            }
        }
    }
    @RequestMapping(value = "/deviceError/add/auth")
    @ManagerAuth
    public R add(DeviceError deviceError) {
        deviceError.setCreateTime(new Date());
        deviceErrorService.insert(deviceError);
        return R.ok();
    }
    @RequestMapping(value = "/deviceError/update/auth")
    @ManagerAuth
    public R update(DeviceError deviceError){
        if (Cools.isEmpty(deviceError) || null==deviceError.getId()){
            return R.error();
        }
        deviceErrorService.updateById(deviceError);
        return R.ok();
    }
    @RequestMapping(value = "/deviceError/delete/auth")
    @ManagerAuth
    public R delete(@RequestParam(value="ids[]") Long[] ids){
         for (Long id : ids){
            deviceErrorService.deleteById(id);
        }
        return R.ok();
    }
    @RequestMapping(value = "/deviceError/export/auth")
    @ManagerAuth
    public R export(@RequestBody JSONObject param){
        EntityWrapper<DeviceError> wrapper = new EntityWrapper<>();
        List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class);
        Map<String, Object> map = excludeTrash(param.getJSONObject("deviceError"));
        convert(map, wrapper);
        List<DeviceError> list = deviceErrorService.selectList(wrapper);
        return R.ok(exportSupport(list, fields));
    }
    @RequestMapping(value = "/deviceErrorQuery/auth")
    @ManagerAuth
    public R query(String condition) {
        EntityWrapper<DeviceError> wrapper = new EntityWrapper<>();
        wrapper.like("id", condition);
        Page<DeviceError> page = deviceErrorService.selectPage(new Page<>(0, 10), wrapper);
        List<Map<String, Object>> result = new ArrayList<>();
        for (DeviceError deviceError : page.getRecords()){
            Map<String, Object> map = new HashMap<>();
            map.put("id", deviceError.getId());
            map.put("value", deviceError.getId());
            result.add(map);
        }
        return R.ok(result);
    }
    @RequestMapping(value = "/deviceError/check/column/auth")
    @ManagerAuth
    public R query(@RequestBody JSONObject param) {
        Wrapper<DeviceError> wrapper = new EntityWrapper<DeviceError>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val"));
        if (null != deviceErrorService.selectOne(wrapper)){
            return R.parse(BaseRes.REPEAT).add(getComment(DeviceError.class, String.valueOf(param.get("key"))));
        }
        return R.ok();
    }
}
src/main/java/com/zy/asrs/entity/DeviceError.java
New file
@@ -0,0 +1,76 @@
package com.zy.asrs.entity;
import com.core.common.Cools;import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.enums.IdType;
import com.baomidou.mybatisplus.annotations.TableField;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.springframework.format.annotation.DateTimeFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import com.baomidou.mybatisplus.annotations.TableName;
import java.io.Serializable;
@Data
@TableName("wcs_device_error")
public class DeviceError implements Serializable {
    private static final long serialVersionUID = 1L;
    @ApiModelProperty(value= "")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    /**
     * 设备
     */
    @ApiModelProperty(value= "设备")
    private String device;
    /**
     * 设备ID
     */
    @ApiModelProperty(value= "设备ID")
    @TableField("device_id")
    private Integer deviceId;
    /**
     * 创建时间
     */
    @ApiModelProperty(value= "创建时间")
    @TableField("create_time")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    /**
     * 异常信息
     */
    @ApiModelProperty(value= "异常信息")
    private String msg;
    public DeviceError() {}
    public DeviceError(String device,Integer deviceId,Date createTime,String msg) {
        this.device = device;
        this.deviceId = deviceId;
        this.createTime = createTime;
        this.msg = msg;
    }
//    DeviceError deviceError = new DeviceError(
//            null,    // 设备
//            null,    // 设备ID
//            null,    // 创建时间
//            null    // 异常信息
//    );
    public String getCreateTime$(){
        if (Cools.isEmpty(this.createTime)){
            return "";
        }
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.createTime);
    }
}
src/main/java/com/zy/asrs/mapper/DeviceErrorMapper.java
New file
@@ -0,0 +1,16 @@
package com.zy.asrs.mapper;
import com.zy.asrs.entity.DeviceError;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
@Mapper
@Repository
public interface DeviceErrorMapper extends BaseMapper<DeviceError> {
    DeviceError selectByDeviceAndDeviceId(String device, Integer deviceId);
    Integer deleteByDeviceAndDeviceId(String device, Integer deviceId);
}
src/main/java/com/zy/asrs/service/DeviceErrorService.java
New file
@@ -0,0 +1,14 @@
package com.zy.asrs.service;
import com.zy.asrs.entity.DeviceError;
import com.baomidou.mybatisplus.service.IService;
public interface DeviceErrorService extends IService<DeviceError> {
    DeviceError selectByDeviceAndDeviceId(String device, Integer deviceId);
    Boolean addDeviceError(String device, Integer deviceId, String msg);
    Integer deleteDeviceError(String device, Integer deviceId);
}
src/main/java/com/zy/asrs/service/impl/DeviceErrorServiceImpl.java
New file
@@ -0,0 +1,40 @@
package com.zy.asrs.service.impl;
import com.zy.asrs.mapper.DeviceErrorMapper;
import com.zy.asrs.entity.DeviceError;
import com.zy.asrs.service.DeviceErrorService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.zy.core.enums.SlaveType;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
@Service("deviceErrorService")
public class DeviceErrorServiceImpl extends ServiceImpl<DeviceErrorMapper, DeviceError> implements DeviceErrorService {
    @Override
    public DeviceError selectByDeviceAndDeviceId(String device, Integer deviceId) {
        return this.baseMapper.selectByDeviceAndDeviceId(device, deviceId);
    }
    @Override
    public Boolean addDeviceError(String device, Integer deviceId, String msg) {
        DeviceError error = this.selectByDeviceAndDeviceId(device, deviceId);
        if (error == null) {
            DeviceError deviceError = new DeviceError();
            deviceError.setDevice(device);
            deviceError.setDeviceId(deviceId);
            deviceError.setMsg(msg);
            deviceError.setCreateTime(new Date());
            return this.baseMapper.insert(deviceError) > 0;
        }
        return true;
    }
    @Override
    public Integer deleteDeviceError(String device, Integer deviceId) {
        return this.baseMapper.deleteByDeviceAndDeviceId(device, deviceId);
    }
}
src/main/java/com/zy/core/thread/LedThread.java
@@ -5,6 +5,7 @@
import com.core.common.SpringUtils;
import com.zy.asrs.entity.CommandInfo;
import com.zy.asrs.service.CommandInfoService;
import com.zy.asrs.service.DeviceErrorService;
import com.zy.common.entity.Parameter;
import com.zy.common.model.MatDto;
import com.zy.core.Slave;
@@ -203,10 +204,13 @@
            screen.turnOn();
        } catch (Exception ignore) {
        }
        DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
        if (connRes) {
            log.info("led连接成功 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            deviceErrorService.deleteDeviceError("led", slave.getId());
        } else {
            log.error("led连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            deviceErrorService.addDeviceError("led", slave.getId(), "led连接失败");
        }
        return connRes;
    }
src/main/java/com/zy/core/thread/ScaleThread.java
@@ -6,6 +6,7 @@
import com.core.common.SpringUtils;
import com.zy.asrs.entity.BasDevp;
import com.zy.asrs.service.BasDevpService;
import com.zy.asrs.service.DeviceErrorService;
import com.zy.core.Slave;
import com.zy.core.ThreadHandler;
import com.zy.core.cache.OutputQueue;
@@ -83,6 +84,7 @@
    @Override
    public boolean connect() {
        try {
            close();  //1.主动释放连接 //2.某些服务器对指定ip有链路数限制
            socket = new Socket();
@@ -92,9 +94,13 @@
            dataOutputStream = new DataOutputStream(socket.getOutputStream());
            dataInputStream = new DataInputStream(socket.getInputStream());
//            log.info("条码扫描仪连接成功 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
            deviceErrorService.deleteDeviceError("scale", slave.getId());
        } catch (Exception e) {
            socket = null;
            log.error("磅秤连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
            deviceErrorService.addDeviceError("scale", slave.getId(), "磅秤连接失败");
            return false;
        }
        return true;
src/main/java/com/zy/core/thread/SiemensCrnThread.java
@@ -13,6 +13,7 @@
import com.zy.asrs.service.BasCrnOptService;
import com.zy.asrs.service.BasCrnpService;
import com.zy.asrs.service.CommandInfoService;
import com.zy.asrs.service.DeviceErrorService;
import com.zy.core.CrnThread;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.OutputQueue;
@@ -51,7 +52,7 @@
        this.connect();
        while (true) {
            try {
                int step = 3;
                int step = 1;
                Task task = MessageQueue.poll(SlaveType.Crn, slave.getId());
                if (task != null) {
                    step = task.getStep();
@@ -124,6 +125,8 @@
        } else {
            OutputQueue.CRN.offer(MessageFormat.format("【{0}】堆垛机plc连接失败!!! ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
            log.error("堆垛机plc连接失败!!! ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
            DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
            deviceErrorService.addDeviceError("crn", slave.getId(), "堆垛机plc连接失败");
        }
        siemensNet.ConnectClose();
        return result;
@@ -338,9 +341,13 @@
                }
            } catch (Exception ignore){}
            DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
            deviceErrorService.deleteDeviceError("crn", slave.getId());
        } else {
            OutputQueue.CRN.offer(MessageFormat.format("【{0}】读取堆垛机plc状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
            log.error("读取堆垛机plc状态信息失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
            DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
            deviceErrorService.addDeviceError("crn", slave.getId(), "读取堆垛机plc状态信息失败");
        }
    }
src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -12,6 +12,7 @@
import com.zy.asrs.entity.CommandInfo;
import com.zy.asrs.service.BasDevpService;
import com.zy.asrs.service.CommandInfoService;
import com.zy.asrs.service.DeviceErrorService;
import com.zy.core.DevpThread;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.OutputQueue;
@@ -115,6 +116,8 @@
        } else {
            OutputQueue.DEVP.offer(MessageFormat.format( "【{0}】输送线plc连接失败!!! ===>> [id:{1}] [ip:{2}] [port:{3}]  [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
            log.error("输送线plc连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
            deviceErrorService.addDeviceError("devp", slave.getId(), "输送线plc连接失败");
        }
        siemensS7Net.ConnectClose();
        return result;
@@ -224,9 +227,13 @@
                log.error("更新数据库数据失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
            }
            DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
            deviceErrorService.deleteDeviceError("devp", slave.getId());
        } else {
            OutputQueue.DEVP.offer(MessageFormat.format("【{0}】读取输送线plc状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
//            log.error("读取输送线plc状态信息失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
            DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
            deviceErrorService.addDeviceError("devp", slave.getId(), "读取输送线plc状态信息失败");
        }
    }
src/main/resources/mapper/DeviceErrorMapper.xml
New file
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zy.asrs.mapper.DeviceErrorMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.zy.asrs.entity.DeviceError">
        <id column="id" property="id" />
        <result column="device" property="device" />
        <result column="device_id" property="deviceId" />
        <result column="create_time" property="createTime" />
        <result column="msg" property="msg" />
    </resultMap>
    <select id="selectByDeviceAndDeviceId" resultMap="BaseResultMap">
        select top 1 * from wcs_device_error
        where device = #{device}
        and device_id = #{deviceId}
    </select>
    <delete id="deleteByDeviceAndDeviceId">
        delete from wcs_device_error
        where device = #{device}
        and device_id = #{deviceId}
    </delete>
</mapper>
src/main/webapp/static/wms/js/deviceError/deviceError.js
New file
@@ -0,0 +1,249 @@
var pageCurr;
layui.config({
    base: baseUrl + "/static/wms/layui/lay/modules/"
}).use(['table','laydate', 'form', 'admin'], function(){
    var table = layui.table;
    var $ = layui.jquery;
    var layer = layui.layer;
    var layDate = layui.laydate;
    var form = layui.form;
    var admin = layui.admin;
    // 数据渲染
    tableIns = table.render({
        elem: '#deviceError',
        headers: {token: localStorage.getItem('token')},
        url: baseUrl+'/deviceError/list/auth',
        page: true,
        limit: 15,
        limits: [15, 30, 50, 100, 200, 500],
        toolbar: '#toolbar',
        cellMinWidth: 50,
        height: 'full-120',
        cols: [[
            {type: 'checkbox'}
            ,{field: 'id', align: 'center',title: '编号'}
            ,{field: 'device', align: 'center',title: '设备'}
            ,{field: 'deviceId', align: 'center',title: '设备ID'}
            ,{field: 'msg', align: 'center',title: '异常信息'}
            ,{field: 'createTime$', align: 'center',title: '创建时间'}
            ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:120}
        ]],
        request: {
            pageName: 'curr',
            pageSize: 'limit'
        },
        parseData: function (res) {
            return {
                'code': res.code,
                'msg': res.msg,
                'count': res.data.total,
                'data': res.data.records
            }
        },
        response: {
            statusCode: 200
        },
        done: function(res, curr, count) {
            if (res.code === 403) {
                top.location.href = baseUrl+"/";
            }
            pageCurr=curr;
            limit();
        }
    });
    // 监听排序事件
    table.on('sort(deviceError)', function (obj) {
        var searchData = {};
        $.each($('#search-box [name]').serializeArray(), function() {
            searchData[this.name] = this.value;
        });
        searchData['orderByField'] = obj.field;
        searchData['orderByType'] = obj.type;
        tableIns.reload({
            where: searchData,
            page: {curr: 1}
        });
    });
    // 监听头工具栏事件
    table.on('toolbar(deviceError)', function (obj) {
        var checkStatus = table.checkStatus(obj.config.id).data;
        switch(obj.event) {
            case 'addData':
                showEditModel();
                break;
            case 'deleteData':
               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=[];
                    var fields=[];
                    obj.config.cols[0].map(function (col) {
                        if (col.type === 'normal' && col.hide === false && col.toolbar == null) {
                            titles.push(col.title);
                            fields.push(col.field);
                        }
                    });
                    var exportData = {};
                    $.each($('#search-box [name]').serializeArray(), function() {
                        exportData[this.name] = this.value;
                    });
                    var param = {
                        'deviceError': exportData,
                        'fields': fields
                    };
                    $.ajax({
                        url: baseUrl+"/deviceError/export/auth",
                        headers: {'token': localStorage.getItem('token')},
                        data: JSON.stringify(param),
                        dataType:'json',
                        contentType:'application/json;charset=UTF-8',
                        method: 'POST',
                        success: function (res) {
                            layer.closeAll();
                            if (res.code === 200) {
                                table.exportFile(titles,res.data,'xls');
                            } else if (res.code === 403) {
                                top.location.href = baseUrl+"/";
                            } else {
                                layer.msg(res.msg, {icon: 2})
                            }
                        }
                    });
                });
                break;
        }
    });
    // 监听行工具事件
    table.on('tool(deviceError)', function(obj){
        var data = obj.data;
        switch (obj.event) {
            case 'edit':
                showEditModel(data);
                break;
            case "del":
                del([data.id]);
                break;
        }
    });
    /* 弹窗 - 新增、修改 */
    function showEditModel(mData) {
        admin.open({
            type: 1,
            area: '600px',
            title: (mData ? '修改' : '添加') + '设备异常',
            content: $('#editDialog').html(),
            success: function (layero, dIndex) {
                layDateRender(mData);
                form.val('detail', mData);
                form.on('submit(editSubmit)', function (data) {
                    var loadIndex = layer.load(2);
                    $.ajax({
                        url: baseUrl+"/deviceError/"+(mData?'update':'add')+"/auth",
                        headers: {'token': localStorage.getItem('token')},
                        data: data.field,
                        method: 'POST',
                        success: function (res) {
                            layer.close(loadIndex);
                            if (res.code === 200){
                                layer.close(dIndex);
                                layer.msg(res.msg, {icon: 1});
                                tableReload();
                            } else if (res.code === 403){
                                top.location.href = baseUrl+"/";
                            }else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }
                    })
                    return false;
                });
                $(layero).children('.layui-layer-content').css('overflow', 'visible');
                layui.form.render('select');
            }
        });
    }
    /* 删除 */
    function del(ids) {
        layer.confirm('确定要删除选中数据吗?', {
            skin: 'layui-layer-admin',
            shade: .1
        }, function (i) {
            layer.close(i);
            var loadIndex = layer.load(2);
            $.ajax({
                url: baseUrl+"/deviceError/delete/auth",
                headers: {'token': localStorage.getItem('token')},
                data: {ids: ids},
                method: 'POST',
                success: function (res) {
                    layer.close(loadIndex);
                    if (res.code === 200){
                        layer.msg(res.msg, {icon: 1});
                        tableReload();
                    } else if (res.code === 403){
                        top.location.href = baseUrl+"/";
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }
            })
        });
    }
    // 搜索
    form.on('submit(search)', function (data) {
        pageCurr = 1;
        tableReload(false);
    });
    // 重置
    form.on('submit(reset)', function (data) {
        pageCurr = 1;
        clearFormVal($('#search-box'));
        tableReload(false);
    });
    // 时间选择器
    function layDateRender(data) {
        setTimeout(function () {
            layDate.render({
                elem: '#createTime\\$',
                type: 'datetime',
                value: data!==undefined?data['createTime\\$']:null
            });
        }, 300);
    }
    layDateRender();
});
// 关闭动作
$(document).on('click','#data-detail-close', function () {
    parent.layer.closeAll();
});
function tableReload(child) {
    var searchData = {};
    $.each($('#search-box [name]').serializeArray(), function() {
        searchData[this.name] = this.value;
    });
    tableIns.reload({
        where: searchData,
        page: {curr: pageCurr}
     });
}
src/main/webapp/views/deviceError/deviceError.html
New file
@@ -0,0 +1,104 @@
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../static/wms/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../static/wms/css/admin.css?v=318" media="all">
    <link rel="stylesheet" href="../../static/wms/css/cool.css" media="all">
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-form toolbar" id="search-box">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <input class="layui-input" type="text" name="id" placeholder="编号" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <input class="layui-input" type="text" name="device" placeholder="设备" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <input class="layui-input" type="text" name="device_id" placeholder="设备ID" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-inline">&emsp;
                        <button class="layui-btn icon-btn" lay-filter="search" lay-submit>
                            <i class="layui-icon">&#xe615;</i>搜索
                        </button>
                        <button class="layui-btn icon-btn" lay-filter="reset" lay-submit>
                            <i class="layui-icon">&#xe666;</i>重置
                        </button>
                    </div>
                </div>
            </div>
            <table class="layui-hide" id="deviceError" lay-filter="deviceError"></table>
        </div>
    </div>
</div>
<script type="text/html" id="toolbar">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" id="btn-add" lay-event="addData">新增</button>
        <button class="layui-btn layui-btn-sm layui-btn-danger" id="btn-delete" lay-event="deleteData">删除</button>
        <button class="layui-btn layui-btn-primary layui-btn-sm" id="btn-export" lay-event="exportData" style="float: right">导出</button>
    </div>
</script>
<script type="text/html" id="operate">
    <a class="layui-btn layui-btn-primary layui-btn-xs btn-edit" lay-event="edit">修改</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs btn-edit" lay-event="del">删除</a>
</script>
<script type="text/javascript" src="../../static/wms/js/jquery/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="../../static/wms/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="../../static/wms/js/common.js" charset="utf-8"></script>
<script type="text/javascript" src="../../static/wms/js/cool.js" charset="utf-8"></script>
<script type="text/javascript" src="../../static/wms/js/deviceError/deviceError.js" charset="utf-8"></script>
</body>
<!-- 表单弹窗 -->
<script type="text/html" id="editDialog">
    <form id="detail" lay-filter="detail" class="layui-form admin-form model-form">
        <input name="id" type="hidden">
        <div class="layui-row">
            <div class="layui-col-md12">
                <div class="layui-form-item">
                    <label class="layui-form-label">设备: </label>
                    <div class="layui-input-block">
                        <input class="layui-input" name="device" placeholder="请输入设备">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">设备ID: </label>
                    <div class="layui-input-block">
                        <input class="layui-input" name="deviceId" placeholder="请输入设备ID">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">异常信息: </label>
                    <div class="layui-input-block">
                        <input class="layui-input" name="msg" placeholder="请输入异常信息">
                    </div>
                </div>
             </div>
        </div>
        <hr class="layui-bg-gray">
        <div class="layui-form-item text-right">
            <button class="layui-btn" lay-filter="editSubmit" lay-submit="">保存</button>
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        </div>
    </form>
</script>
</html>