CZT
2023-10-21 3e7773504d6bd15e6ed20ecf5c6236b163ba0fe8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
var layer = layui.layer;
var table;
var depotId;
var depotData;
var listDevice;
 
(function() {
    layui.use([ 'layer', 'laydate', 'table', 'form' ], function() {
        table = layui.table;
        layer = layui.layer;
        var form = layui.form;
        var laydate = layui.laydate;
 
        // 监听仓库选择
        form.on('select(select_depotId)', function(obj) {
            flushData();
            // 更新当前仓库信息
            updateDepotInfo();
        });
    });
 
    // 初始化WebSocket
    initWS(deptId, bizType,null, userId);
 
}).call(this);
 
// socket信息返回處理
function socketOnMessage(pocket) {
    if (pocket.orderResp == "MSG_SUCCESS") {// 信息解析成功刷新当前数据
        flushData();
    }
    // 调用通知信息
    window.parent.sysNotify(pocket.data);
    //layer.msg(pocket.data);
};
 
// 点击刷新操作
function flushData() {
    depotId = $("#depotId").val();
    if (!depotId) {
        layer.msg("请先选择仓库!");
        return;
    }
    $.ajax({
        type : "POST",
        url : "../../basic/temp/list-device-manual",
        data : JSON.stringify({
            depotId : depotId
        }),
        dataType : "json",
        contentType : "application/json;charset=UTF-8",
        success : function(result) {
            console.log(result);
            if (result.code != "0000") {
                layer.msg(result.msg);
            } else {
                listDevice = result.data;
 
                renderDeviceInfo();
            }
        },
        error : function() {
            layer.msg("根据条件获取设备列表失败!");
        }
    });
 
};
 
function renderDeviceInfo() {
    table.render({
        elem : '#tableDevice',
        data : listDevice,
        page : false,
        id : 'tableDevice',
        cols : [ [ {
            type : 'radio'
        }, {
            field : 'name',
            title : '设备名称',
            align : 'center',
            sort : true
        }, {
            field : 'statusName',
            title : '设备状态',
            align : 'center',
            sort : true
        }, {
            field : 'ext1',
            title : '设定温度(℃)',
            align : 'center',
        }, {
            field : 'ext2',
            title : '空调模式',
            align : 'center',
            templet: '#templeteModel'
        } ] ]
    });
};
 
/**
 * 更新仓库信息
 */
function updateDepotInfo() {
    $.each(listDepot, function(index, data) {
        if (data.id == depotId) {
            renderDepotInfo(data);
            return;
        }
    });
};
 
// 填写数据
function renderDepotInfo(data) {
    $("#storeKeeperName").attr("value",data.storeKeeperName);
    $("#broken").attr("value",data.broken);
    $("#perImpurity").attr("value",data.perImpurity);
    $("#bulkWeight").attr("value",data.bulkWeight);
    $("#foodLocation").attr("value",data.foodLocation);
    $("#perWet").attr("value",data.perWet);
    $("#foodLevelName").attr("value",data.foodLevelName);
    $("#storageReal").attr("value",data.storageReal);
    $("#storeDate").attr("value",data.storeDate);
    $("#depotTypeName").attr("value",data.depotTypeName);
};
 
function queryStatus() {
    depotId = $("#depotId").val()
 
    if (!depotId) {
        layer.msg("请先选择仓库!");
        return;
    }
    var data = {
        depotId : depotId,
    }
    $.ajax({
        type : "POST",
        url : "../../basic/temp/query-status",
        data : JSON.stringify(data),
        dataType : "json",
        contentType : "application/json;charset=UTF-8",
        success : function(result) {
            if ("ORDER_SUCCESS" == result.code) {
                layer.msg("状态查询发送成功,请请等待执行结果……");
            } else {
                layer.msg("执行失败,信息:" + result.msg);
            }
        },
        error : function() {
            layer.msg("温控执行失败,后台出现错误!");
        }
    });
};
 
// 空调控制
function tempControl() {
    depotId = $("#depotId").val()
 
    if (!depotId) {
        layer.msg("请先选择仓库!");
        return;
    }
    var checkStatus = table.checkStatus('tableDevice');
    var selectDevice = checkStatus.data;
 
    if (!selectDevice || selectDevice.length == 0) {
        layer.msg("请先选择需要操作的空调!");
        return;
    }
 
    // 弹出选择框
    layer.open({
        type : 1,
        title : '空调操作配置',
        area : [ '400px', '300px' ],
        shade : 0,
        content : $('#dialogTempControl'),
        btn : [ '确定执行', '取消操作' ],
        yes : function() {
            tempControlTodo(selectDevice[0]);
            layer.msg("开始执行……");
            layer.closeAll();
        },
        btn2 : function() {
            layer.closeAll();
        },
        closeBtn : 0
    });
};
 
// 开始操作空调
function tempControlTodo(exeDevice) {
 
    var targetStatus = $('input[name="targetStatus"]:checked').val();
    var targetTemp = $("#targetTemp").val();
    var targetModel = $('input[name="targetModel"]:checked').val();
    
    console.log(targetStatus);
 
    var data = {
        depotId : depotId,
        targetStatus : targetStatus,
        targetTemp : targetTemp,
        targetModel : targetModel,
        exeDevice : exeDevice
    }
 
    $.ajax({
        type : "POST",
        url : "../../basic/temp/control",
        data : JSON.stringify(data),
        dataType : "json",
        contentType : "application/json;charset=UTF-8",
        success : function(result) {
            if ("ORDER_SUCCESS" == result.code) {
                layer.msg("温控命令发送成功,请请等待执行结果……");
            } else {
                layer.msg("执行失败,信息:" + result.msg);
            }
        },
        error : function() {
            layer.msg("温控执行失败,后台出现错误!");
        }
    });
};