jiazx0107@163.com
2023-05-17 620eab6cca2bc9ef9ea6d3067a0a5ba1deadbd1c
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
var layer;
var timer1;
var timer2;
var screen = true;
var pageNo = 1;
var pageSize = 10;
var pageTotal = 1;
var inoutData = {};
var weightData = {};
var mediaAddr = camera.mediaAddr;
$(function() {
    layui.use([ 'layer', 'laydate', 'form' ], function() {
        layer = layui.layer;
        // 初始页面
        init();
        $("body").dblclick(function() {
            if (screen) {
                requestFullScreen();
            } else {
                exitFullscreen();
            }
        });
    });
});
 
function init() {
    // 初始背景效果
    initBg();
    //标语
    initDicSlogan();
    //气象站信息
    initWeather();
    //时间
    initTime();
    // clearInterval(timer1);
    // clearInterval(timer2);
    //定时换页
    timing();
    //定时刷新视频
    timingVideo();
    // 初始化WebSocket
    initWS(deptId, bizType, bizTag, userId);
    initInoutData();
};
 
// socket信息返回處理
function socketOnMessage(pocket) {
    console.log(pocket);
    if (pocket.bizId == "slogan") {
        var data = pocket.data;
        dicSlogan = data;
        initDicSlogan();
    }
    if (pocket.bizId == "weather") {
        weatherInfo = pocket.data;
        initWeather()
    }
    if (pocket.bizId == "IN_OUT_SUMMARY") {
        //对数据进行过滤,只要入库且处于登记、称重和化验状态的数据
        inoutData = filter(pocket.data.curList);
        renderinoutData(inoutData,pageNo);
    }
    if (pocket.bizId == "WEIGHT_FULL") {
 
        weightData = pocket.data;
        renderweightData(weightData);
    }
};
 
//过滤出入库状态为登记、满车称重和化验的数据
function filter(allData) {
    var partData = [];
    if(allData.length>0){
        for (var i = 0; i < allData.length; i++) {
            //只显示入库信息
            if(allData[i].type === "IN" ) {
                if(allData[i].progress==="WEIGHT_FULL" || allData[i].progress==="CHECK"){
                    partData.push(allData[i]);
                }
            }
        }
    }
    return partData;
}
 
//定时换页
function timing() {
    timer1 = setInterval(function() {
        pageNo++;
        if (pageNo > pageTotal) {
            pageNo = 1;
        }
        renderinoutData(inoutData,pageNo);
    }, 15000);
}
 
//定时更新监控
function timingVideo() {
    timer2 = setInterval(function() {
        updateVideo();
        }, 3600000);
}
 
function updateVideo() {
    $("#video").html("");
    var html = "";
    html += "<object type='application/x-vlc-plugin' id='video-1'" +
        "events='true' width='100%' height='100%'" +
        "pluginspage='http://www.videolan.org'" +
        "th:codebase='@{../../static/plugins/vlc/npapi-vlc-2.2.2.tar.xz}'>\n" +
        "<param name='mrl' value='"+mediaAddr+"'/>\n" +
        "<param name='volume' value='50'/>\n" +
        "<param name='autoplay' value='true'/>\n" +
        "<param name='loop' value='false'/>\n" +
        "<param name='fullscreen' value='true'/>\n" +
        "<param name='toolbar' value='false'/>\n" +
        "</object>";
    $("#video").append(html);
}
 
/**
 * 时间等
 */
function initTime() {
    setInterval(function() {
        var now = new Date();
        var time = now.toLocaleString('chinese', {
            hour12 : false
        });
        $(".time-info").text(time);
    }, 1000);
}
 
//入库列表
function  renderinoutData(inoutData,pNo) {
    // 先清空,在渲染
    $("#inoutShowMainDiv").html("");
    if (inoutData == null || inoutData.length <= 0){
        return;
    }
    pageNo = pNo - 1;
    // 计算总页数
    pageTotal = inoutData.length / pageSize;
    if (!(inoutData.length % pageSize == 0)) {
        pageTotal++;
    }
    var html = "";
    for (var i = pageNo * pageSize + 1; i <= inoutData.length; i++) {
        html += "<dl class=\"i-m1-dl\">" + "<dt>"
            + (inoutData[i - 1].id == null ? "" : inoutData[i - 1].id.substring(6))
            + "</dt>";
        html += "<dd> " +inoutData[i - 1].plateNum + "</dd>";
        html += "<dd> " +  dateFormatStr(inoutData[i - 1].registerTime)  + "</dd>";
        html += "</dl>" ;
        if (i == ((pageNo + 1) * pageSize)) {
            break;
        }
    }
    $("#inoutShowMainDiv").html(html);
    pageNo++;
}
 
/**
 * 通知后台推送一次出入库数据
 */
function initInoutData(){
    $.ajax({
        type : "POST",
        url : "../../basic/databoard/init-check-data",
        dataType : "json",
        contentType : "application/json;charset=UTF-8",
        data : JSON.stringify({
            "companyId" : companyId
        }),
        success : function() {
            console.log("初始成功!");
        },
        error : function(error) {
            console.log(error);
            console.log("初始失败!");
        }
    });
}
 
//称重信息
function  renderweightData(weightData) {
    // 先清空,在渲染
    $("#showIdAndPlateNum").html("");
    var html = "";
    html += "当前称重&nbsp;&nbsp;单据号:"+weightData.checkId.substring(4)+"&nbsp;&nbsp;&nbsp;&nbsp;车牌号:"+weightData.plateNum;
    $("#showIdAndPlateNum").html(html);
}
 
//格式化时间
function dateFormatStr(time) {
    if(time){
        var d = new Date(time);
        return dateFtt("hh:mm",d);
    }
    return "";
}
 
//标语
function initDicSlogan() {
    if (dicSlogan) {
        if (dicSlogan.color == "red") {
            $("#sloganText").css({
                color : "#DE2910"
            });
        } else {
            $("#sloganText").css({
                color : "#7ddfff"
            });
        }
        $("#sloganText").text(dicSlogan.content);
    }
}
 
//气象站信息
function initWeather() {
    if (weatherInfo) {
        // console.log(weatherInfo);
        var wendu = '';
        if(weatherInfo.temp){
            wendu = weatherInfo.temp.replace("℃", "");
        }
        $("#weather_wendu").html("<span>" + wendu + "</span>℃");
 
 
        var shidu = '';
        if(weatherInfo.humidity){
            shidu = weatherInfo.humidity.replace("%", "");
        }
        $("#weather_shidu").html("<span>" + shidu + "</span>%");
 
        var tianqi = '';
        if(weatherInfo.weather){
            tianqi = weatherInfo.weather;
        }
        $("#weather_tianqi").html("<em>" + tianqi + "</em>");
 
        var windSpeed = '';
        if(weatherInfo.windSpeed){
            windSpeed = weatherInfo.windSpeed;
        }
        $("#windSpeed").html("<span>" + windSpeed + "</span>");
 
        var fengxiang = '';
        if(weatherInfo.windDirection){
            fengxiang = weatherInfo.windDirection;
        }
        $("#weather_fengxiang").html("<em>" + fengxiang + "</em>");
 
        var time = '';
        if(weatherInfo.updateTimeStr){
            time = weatherInfo.updateTimeStr;
        }
        $("#weather_time").text("更新时间 : " + time);
    }
}
 
//双击退出全屏
function exitFullscreen() {
    var de = document;
    if (de.exitFullscreen) {
        de.exitFullscreen();
    } else if (de.mozCancelFullScreen) {
        de.mozCancelFullScreen();
    } else if (de.webkitCancelFullScreen) {
        de.webkitCancelFullScreen();
    }
    screen = true;
}
//双击进入全屏
function requestFullScreen() {
    var de = document.documentElement;
    if (de.requestFullscreen) {
        de.requestFullscreen();
    } else if (de.mozRequestFullScreen) {
        de.mozRequestFullScreen();
    } else if (de.webkitRequestFullScreen) {
        de.webkitRequestFullScreen();
    }
    screen = false;
}