【调度系统】广东民航医疗快线调度系统源代码
克樊道人
2024-12-02 61ce8cc6883e5f94e6470141df3484167caf31ed
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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
var isInitFinished=false;//是否加载完视频插件???
var swfwidth=0;//swf插件窗口宽度
var swfheight=0;
var PlateNum=0; //url中车牌号
var chnCount = 4;//默认通道数
var maxChnCount = 16; //最大窗口数
var loginServer = null;
var isLoadLoginServer = false;
var jsession="";
var devIdno="";// 车辆对应设备号
var vehiIdno = ""; //车牌号
var isShowResidualSeconds=false; //是否显示视频播放剩余秒数
var isSelectFilled=false;//加载完通道菜单
var closeSecond = 3*60;//自动关闭视频秒数
var stopIndex = 0;
var serverIp = "";//请求的服务器ip
var serverPort = "";//请求的服务器端口
var isSuccessed="";
var lang = new langZhCn();
 
 
function langZhCn() {
    this.loginError = "登陆失败";
    this.jsessionError = "会话号不存在";
    this.deviceNoExist = "找不到车辆信息";
    this.errorVideoDevice = "这个设备不是视频设备";
    this.vehicleNotOperate = "没有车辆或者设备操作权限";
    this.closeTip = "秒后关闭视频";
    this.realtimeVideo = "实时视频";
    this.replayVideo = "历史视频";
    this.fourWindows = "四窗口";
    this.nineWindows = "九窗口";
    this.sixteenWindows = "十六窗口";
    this.monitor = "监听";
    this.talkback = "对讲";
    this.start = "启动";
    this.stop = "停止";
    this.cannotOperate="信息不完整,无法运行!";
    this.isTalking = "已在对讲中";
    this.noMic = "没有找到麦克风";
    this.forbiddenMic = "您禁用了麦克风";
    this.talkback_openMic = "请开启FLASH插件麦克风";
    this.talkback_flashMicStep1 = "第一步,请在视频窗上右键菜单中选择设置"; 
    this.talkback_flashMicStep2 = "第二步在设置窗口中 选择 “允许”,并勾选“记住”"; 
    this.talkback_flashMicStep3 = "关闭设置,并重新启动对讲";
    this.inTheRequest = "请求中……";
    this.running = "运行中……";
    this.haveStopped = "已停止";
    this.monitoring = "监听中……";
    this.talking = "对讲中……";
}
 
function langEn() {
    this.loginError = "Login failed";
    this.jsessionError = "Jsession error";
    this.deviceNoExist = "Can't not find vehicles";
    this.vehicleNotOperate = "No vehicle or device operating authority";
    this.errorVideoDevice = "This device is not video device";
    this.closeTip = " seconds later close video";
    this.realtimeVideo = "Realtime Video";
    this.replayVideo = "Replay Video";
    this.fourWindows = "four windows";
    this.nineWindows = "nine windows";
    this.sixteenWindows = "sixteen windows";
    this.monitor = "monitor";
    this.talkback = "talkback";
    this.start = "start";
    this.stop = "stop";
    this.cannotOperate="Can not operated since lack of information!";
    this.isTalking = "is already talking";
    this.noMic = "Can't find the microphone!";
    this.forbiddenMic = "The microphone have been forbidden!";
    this.talkback_openMic = "Please open the microphone of the FLASH plug-in";
    this.talkback_flashMicStep1 = "1. select Settings in the video window on the right-click menu"; 
    this.talkback_flashMicStep2 = "The second step in the Settings window select 'Allow' and check the 'Remember'"; 
    this.talkback_flashMicStep3 = "Close the settings and restart the intercom";
    this.inTheRequest = "In The Request";
    this.running = "Running...";
    this.haveStopped = "Have Stopped";
    this.monitoring = "Monitoring";
    this.talking = "talking";
}
 
function langChange(){
    if (getUrlParameter("lang") == "en") {
        lang = new langEn();
        return false;
    }else{
        return true;
    }
}
 
 
 
$(document).ready(function () {
    langChange();
    $("#closeTip").hide();
    $('#current').next().text(lang.realtimeVideo);
    $('#history').next().text(lang.replayVideo);
    $('#btn1').attr("title",lang.fourWindows);
    $('#btn2').attr("title",lang.nineWindows);
    $('#btn3').attr("title",lang.sixteenWindows);
    $('#monitor').next().text(lang.monitor);
    $('#talkback').next().text(lang.talkback);
    $('#operationBtn').text(lang.start);
    $('input:radio[name="voiceType"],.labelSelection').click(function(){
        var selectType=$('input:radio[name="voiceType"]:checked').val();
        if(selectType=="monitor"){
            $('#monitorChns').attr("disabled",false);
        }else{
            $('#monitorChns').attr("disabled",true);
        }
            
    });
    $('#operationBtn').click(function(){
        var text=$('#operationBtn').text();
        var type=$('input:radio[name="voiceType"]:checked').val();
        if(text==lang.start){
            $('#status').text(lang.inTheRequest);
            if(type=="monitor"){
                startMonitor();
            }else{
                startTalkback();
            }
            //是否成功连接
            if(isSuccessed){
                if(type=="monitor"){
                    $('#status').text(lang.monitoring);
                }else{
                    $('#status').text(lang.talking);
                }
                $('#operationBtn').text(lang.stop);
                $('input:radio[name="voiceType"],#monitorChns').attr("disabled",true);
            }else{
                $('#operationBtn').text(lang.start);
                $('#status').text("");
                if(type=="monitor"){
                    $('input:radio[name="voiceType"],#monitorChns').attr("disabled",false);
                }else{
                    $('input:radio[name="voiceType"]').attr("disabled",false);
                }
            }
 
        }else{
            if(type=="monitor"){
                stopMonitor();
                $('#operationBtn').text(lang.start);
                $('#status').text("");
                $('input:radio[name="voiceType"],#monitorChns').attr("disabled",false);
            }else{
                stopTalkback();
                $('#operationBtn').text(lang.start);
                $('#status').text("");
                $('input:radio[name="voiceType"]').attr("disabled",false);
            }
        }
    });
//    var channel = getUrlParameter("channel");
//    var channelNum=parseInt(channel, 10);
//    if (!isNaN(channelNum)) {
//        chnCount = channelNum;
//    }
    var temp = getUrlParameter("closeMins");
    if (temp) {
        closeSecond = parseInt(temp, 10)*60;
    }
    
    //加载页面
    loadPage();
    getServer();
    //配置页面信息
    $('#btn1').click(function() {
        doSwitchWindow(4);
    });
    $('#btn2').click(function() {
        doSwitchWindow(9);
    });
    $('#btn3').click(function() {
        doSwitchWindow(16);
    });
    $('#videoTitle').val(vehiIdno);
});
 
//填充通道菜单选项
function fillOptions(){
    for(var i=0;i<chnCount;i++){
        $('#monitorChns').append('<option value="'+i+'">CH'+(i+1)+'</option>');
    }
    isSelectFilled=true;
}
 
//视频插件要初始化完成后才能调用
//开始监听    startListen(jsession, devIdno, channel, ip, port)
function startMonitor() {
    isSuccessed=false;
    if(isInitFinished && isSelectFilled){
        //获取当前选择通道
        var c=$('#monitorChns option:selected').val();
        //开始监听
        swfobject.getObjectById("cmsv6flash").startListen(jsession,devIdno, c, serverIp,serverPort);
        isSuccessed=true;
    }else{
        alert(lang.cannotOperate);
    }
}
//停止监听
function stopMonitor() {
    swfobject.getObjectById("cmsv6flash").stopListen();
}
//视频插件要初始化完成后才能调用
//开始对讲
function startTalkback() {
    isSuccessed=false;
    if(isInitFinished && isSelectFilled){
        //开始对讲
        var ret = swfobject.getObjectById("cmsv6flash").startTalkback(jsession,devIdno, serverIp,serverPort);
        //返回 0成功,1表示正在对讲,2表示没有mic,3表示禁用了mic。
        if(Number(ret)==1){
            $.dialog.tips(lang.isTalking, 2);
            isSuccessed=true;
            return;
        }else if(Number(ret)==2){
            alert(lang.noMic);
            return;
        }else if(Number(ret)==3){
            $.dialog({id:'talkbacktip', title: lang.talkback_openMic, content: 'url:talkbacktipSP.html', min:false, max:false, lock:true
                , autoSize:true});
            return;
        }
        isSuccessed=true;
    }else{
        alert(lang.cannotOperate);
    }
}
 
////启动对讲    //0成功,1表示正在对讲,2表示没有mic,3表示禁用了mic
//var ret = ttxVideo.startTalkback(device.getIdno());
//if (ret == 0) {
//    //$("input[name='listing']").attr("disabled", "disabled");
//    this.isTalking = true;
//    $("#talkbackTip").html(lang.requiring);
//    $("#btnTalkback").html(lang.stop);
//} else if (ret == 1) {
//    //一般都不会到此接口
//} else if (ret == 2) {
//    alert(lang.talkback_noMic);
//} else if (ret == 3) {            
//    $.dialog({id:'talkbacktip', title: lang.talkback_openMic, content: 'url:LocationManagement/talkbacktip.html', min:false, max:false, lock:true
//            , autoSize:true});
//} else {
//    //一般都不会到此接口
//    //除非视频插件没有初始化完成
//}
 
//停止对讲
function stopTalkback() {
    swfobject.getObjectById("cmsv6flash").stopTalkback();
}
 
function loadPage(){
    setPanelWidth();
    //载入视频插件
    initPlayer();
    //获取车牌号
    vehiIdno=decodeURIComponent(getUrlParameter("PlateNum"));
    if(!vehiIdno ) {//为空
        alert(lang.deviceNoExist);
        return;
    }
    
    login();
}
//如果传入了用户名和密码,则继续加载信息
function login() {
    
    var account = getUrlParameter("account");
    var password = getUrlParameter("password");
    var param = [];
    param.push({name: 'account', value: account});
    param.push({name: 'password', value: password});
    
    doAjaxSubmit('StandardApiAction_login.action', param, function(json, action, success) {
        if(success) {
            //获取到会话号
            jsession = json.jsession;
            //取得会话号则加载视频
            loadDeviceInfo();
        }else {
            alert("登录失败!");
        }
    });
    
    
}
 
 
//初始化视频插件
function initPlayer() {
      //视频插件初始化参数
      var params = {
        allowFullscreen: "true",
        allowScriptAccess: "always",
        bgcolor: "#FFFFFF",
        wmode: "transparent"
        };
      //初始化flash
      swfobject.embedSWF("player.swf", "cmsv6flash", swfwidth, swfheight, "11.0.0", null, null, params, null);
      initFlash();
}
 
//设置flash窗口数量
function loadFlashWindowNum(num) {
    if (num <= 4) {
        swfobject.getObjectById('cmsv6flash').setWindowNum(4);
    } else if (num > 5 && num <= 9) {
        swfobject.getObjectById('cmsv6flash').setWindowNum(9);
    } else {
        swfobject.getObjectById('cmsv6flash').setWindowNum(16);
    }
}
//如果传入设备号,则直接判断设备号;
//如果没传入设备号,则判断传入的车牌号
//根据设备号或者车牌号获取设备信息,并判断是否有效和是否视频设备
//获取设备通道
function loadDeviceInfo() {
    var param = [];
    param.push({name: 'jsession', value: jsession});
    param.push({name: 'vehiIdno', value: vehiIdno});
    this.doAjaxSubmit('StandardApiAction_getVideoDevice.action', param, function(json, action, success) {
        if(success) {
            //不是视频设备
            if(!json.isVideoDevice) {
                alert(lang.errorVideoDevice);
            }else {
                devIdno = json.devIdno;
                chnCount = json.chnCount;
                //播放视频
                previewVideo();
                fillOptions();
            }
        }else {
            //没有操作权限
            if(json) {
                if(json.result == 5) {
                    alert(lang.jsessionError);
                }else if(json.result == 8) {
                    alert(lang.vehicleNotOperate);
                }else {
                    alert(lang.deviceNoExist);
                }
            }else {
                alert(lang.deviceNoExist);
            }
        }
    });
}
 
 
//开始预览视频
function previewVideo() {
    loadFlashWindowNum(chnCount)
    //视频插件初始化完成
    if (isInitFinished) {
//        //再一次设置flash窗口数量
//        loadFlashWindowNum(maxChnCount);
        if (closeSecond != 0) {
            if(isShowResidualSeconds){
                $("#closeTip").show();        
            }
            setTimeout(closeVideo, 1000);
        }
        
        for (var i = 0; i < chnCount; ++ i) {
            swfobject.getObjectById('cmsv6flash').setBufferTime(i, 4);
            swfobject.getObjectById('cmsv6flash').setVideoInfo(i, vehiIdno + " - CH" + (i + 1));
            swfobject.getObjectById('cmsv6flash').startVideo(i, jsession, devIdno, i, 1, true);
        }    
    } else {
        setTimeout(previewVideo, 500);
    }
}
 
function closeVideo() {
//    for (var i = 0; i < 4; ++ i) {
//        swfobject.getObjectById('cmsv6flash').stopVideo(i);
//    }
    if (closeSecond > 0) {
        closeSecond -- ;
        $("#spanCloseSecond").text(closeSecond + lang.closeTip);
        setTimeout(closeVideo, 1000);
    } else {
        $("#closeTip").hide();
        swfobject.getObjectById('cmsv6flash').stopVideo(stopIndex);
        stopIndex ++ ;
        if (stopIndex < chnCount) {
            setTimeout(closeVideo, 50);
        }
    }
}
//视频插件是否加载完成
function initFlash() {
    
    if (swfobject.getObjectById("cmsv6flash") == null ||
        typeof swfobject.getObjectById("cmsv6flash").setWindowNum == "undefined" ) {
        setTimeout(initFlash, 50);
    } else {
          //设置视频插件的语言
          if (getUrlParameter("lang") == "en") {
              swfobject.getObjectById('cmsv6flash').setLanguage("en.xml");
          } else {
              swfobject.getObjectById('cmsv6flash').setLanguage("cn.xml");
          }
          //先将全部窗口创建好
          swfobject.getObjectById("cmsv6flash").setWindowNum(16);
          //再配置当前的窗口数目
          loadFlashWindowNum(chnCount);
          //设置视频插件的服务器
          getLoginServer();
          isInitFinished = true;
//        swfobject.getObjectById("cmsv6flash").setServerInfo("192.168.1.210", "6605");
//          playAllVideos(num);
    }
}
 
//播放所有视频
function playAllVideos(num){
    for(i=0;i<num;i++){
        playVideo(i);
    }
    setTimeout("stopAllVideos(num)",3*60*1000);
}
 
//停止所有视频
function stopAllVideos(num){
    for(i=0;i<num;i++){
        stopVideo(i);
    }
}
 
//视频插件要初始化完成后才能调用
//播放视频
function playVideo(index) {
  //停止播放视频
  swfobject.getObjectById("cmsv6flash").stopVideo(index);
  //设置视频窗口标题
  swfobject.getObjectById("cmsv6flash").setVideoInfo(index, PlateNum+"-CH"+(index+1));
  //播放视频
  swfobject.getObjectById("cmsv6flash").startVideo(index, jsession , devi, 0, 1, true);
}
 
//停止播放视频
function stopVideo(index) {
  swfobject.getObjectById("cmsv6flash").stopVideo(index);
}
 
////重置视频窗口
//function reSetVideo(index) {
//  swfobject.getObjectById("cmsv6flash").reSetVideo(index);
//}
 
 
//获取URL参数信息
function getUrlParameter(name){
    if(location.search==''){
        return '';
    }
    
    var o={};
    var search=location.search.replace(/\?/,'');//只替换第一个问号,如果参数中带有问号,当作普通文本
    var s=search.split('&');
    for(var i=0;i<s.length;i++){
        o[s[i].split('=')[0]]=s[i].split('=')[1];
    }
    return o[name]==undefined?'':o[name];
}
 
//切换窗口数目
function doSwitchWindow(num) {
    swfobject.getObjectById('cmsv6flash').setWindowNum(num);
//    maxChnCount=num;
//    loadDeviceInfo();
}
 
//提交ajax
function doAjaxSubmit(action, params, callback) {
    $.ajax({
        type: 'POST',
        url: action,
        data: params,
        cache:false,/*禁用浏览器缓存*/
        dataType: 'json',
        success: function (json) {
            if(json.result == 0){
                callback.call(this, json, action, true);
            } else {
                callback.call(this, json, action, false);
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            try {
                if (p.onError) p.onError(XMLHttpRequest, textStatus, errorThrown);
            } catch (e) {}
            callback.call(this, null, action, false);
        }
    });
}
 
/**
 * 判断clientIp与url是否相同,取相同的clientIp  公用方法
 */
function getLoginServer() {
    if(isLoadLoginServer) {
        serverIp = loginServer.ip;
        serverPort = loginServer.port;
        swfobject.getObjectById('cmsv6flash').setServerInfo(serverIp,serverPort);
//        isInitFinished = true;
//        setViewSize();
//        setBufferTime();
//        setPanelWidth();
    }else {
        setTimeout(getLoginServer,50);
    }
}
 
//获取服务器地址
function getServer() {
    $.myajax.jsonGet('StandardLoginAction_getLoginServer.action', function(json,action,success){
        if(success) {
            var server = json.loginServer;
            var lstSvrIp = [];
            lstSvrIp.push(server[0].clientIp);
            lstSvrIp.push(server[0].lanip);
            lstSvrIp.push(server[0].clientIp2);
            loginServer = {};
            loginServer.ip = getComServerIp(lstSvrIp);
            loginServer.port = server[0].clientPort;
            isLoadLoginServer = true;
        } 
    }, null);
}
function setPanelWidth(){
    
//    var _width = document.body.clientWidth;
//    var _height = document.body.clientHeight;
    var _width =min($(window).innerWidth(),document.body.clientWidth,document.documentElement.clientWidth);
    var _height =min($(window).innerHeight(),document.body.clientHeight,document.documentElement.clientHeight) - 39;
    if(_width<600){
        $('body').width(600);
        swfwidth=600-7;
        $('#bottomSelection').width(swfwidth);
    }else{
        $('body').width(_width-8);
        swfwidth=_width-15;
        $('#bottomSelection').width(swfwidth);
    }
    swfheight=_height-39-$('#bottomSelection').height();
    $("#cmsv6flash").width(swfwidth);
    $("#cmsv6flash").height(swfheight);
    
}
function min(a,b,c){
    var i=a;
    if(a>b){
        i=b;
    }else if(i>c){
        i=c
    }
    return c;
}