lxw
2020-07-11 9db52f2f2dd3665fe9da1ae5657e0167c3a34d40
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
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE HTML>
<html>
  <head>
      <!-- 默认使用最高内核 -->
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" >
    <base href="<%=basePath%>">
    <title><s:text name="Device_history_event_query"/></title>                <!-- 设备状态记录查询 -->
    <link rel="stylesheet" href="css/basic.css">
    <link rel="stylesheet" type="text/css" href="css/nocontent.css">
    <link rel="stylesheet" type="text/css" href="css/loading.css">
    <link rel="stylesheet" type="text/css" href="css/basic-layout.css"/>
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" type="text/css" href="css/popup-tbl.css">
    <link rel="stylesheet" href="src/css/layui.css">
    <style>
        #lside {
            position: absolute;
            top: 30px;
            left: 0;
            bottom: 0;
            right: 0;
        }
    </style>
  </head>
  
  <body>
    <!--头部内容开始-->
    <jsp:include page="Top.jsp" flush="true"/>
    <!--头部内容结束-->
    <!--导航开始-->
    <jsp:include page="nav.jsp" flush="true"/>
    <div class="page-content">
        <div class="content-item side-bar-container">
            <div class="siderbar-tools">
                <div class="siderbar-tools-right">
                    <i class="fa fa-file-text-o" title="机历卡" id="siderbarToolsCard"></i>
                    <i class="fa fa-search" title="查询机房" id="siderbarToolsSearch"></i>
                    <i class="fa fa-outdent" title="全部收缩" id="siderbarToolsHide"></i>
                </div>
            </div>
            <div class="lside" id="lside"></div>
        </div>
        <div class="content-item data-show">
            <div class="data-container">
                <!-- 筛选条件 -->
                <div class="filter-container">
                    <div class="filter-title"><a href="javascript:changeFilterStats();"><s:text name="Device_history_event_query"/>--&gt;<s:text name="Show/hide_the_query_conditions"/></a></div>    <!-- 显示或隐藏查询条件 -->
                    <div class="filter-content">
                        <table>
                            <tbody>
                                <tr>
                                    <th style="width: 30%">状态切换原因</th>
                                    <th colspan="2">查询时间段</th>
                                    <th rowspan="2" style="width: 20%">
                                        <div style="position: relative">
                                            <div id="radio">
                                                <input type="radio" id="tblRadio" name="radio" checked><label for="tblRadio">数据表格</label>
                                                <input type="radio" id="graphRadio" name="radio" disabled><label for="graphRadio">分布图</label>
                                            </div>
                                        </div>
                                    </th>
                                </tr>
                                <tr>
                                    <td>
                                        <select name="" id="statsList">
                                            <option value="-1">全部</option>
                                            <option value="0">手动停止</option>
                                            <option value="1">放电时间到</option>
                                            <option value="2">放电容量到</option>
                                            <option value="3">单体下限到</option>
                                            <option value="4">组端下限到</option>
                                            <option value="5">市电中断</option>
                                            <option value="6">内存不足</option>
                                            <option value="7">温度异常</option>
                                        </select>
                                    </td>
                                    <td><input type="text" id="record_start_time" value="2012-12-01" readonly="readonly"/></td>
                                    <td><input type="text" id="record_end_time" value="2018-03-24" readonly="readonly"/></td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <!-- 数据表格显示 -->
                <div class="tbl-header"></div>
                <div class="tbl-body"></div>
                <!-- 用于导出表格的功能 -->
                <form id="export_excel" action="ExportTable.servlet" method="post">
                    <input type="hidden" name="PageName" value="equip-stats-change.jsp"/>
                    <input type="hidden" id="table_th_arr" name="table_th_arr"/>
                    <input type="hidden" id="table_td_arr" name="table_td_arr"/>
                </form>    
                <div class="data-footer">
                    <!-- 分页内容 -->
                    <div id="paging">
                        <a href="javascript:" class="search"><s:text name="Search"/></a>        <!-- 查询 -->
                        <a href="javascript:" id="export_table"><s:text name="Export"/></a>        <!-- 导出 -->
                        <span id="current">1/1</span>
                        <span><s:text name="Each_page"/><!-- 每页 --><input type="text" id="number" value="10"/><s:text name="Item"/><!-- 条 --></span>
                        <s:text name="Total_data"/><!-- 数据总量 --><span id="total">0</span>&nbsp;&nbsp;
                        <a href="javascript:" id="home"><s:text name="HomePage"/><!-- 首页 --></a> 
                        <a href="javascript:" id="pre"><s:text name="Page_Up"/><!-- 上一页 --></a>
                        <a href="javascript:" id="next_p"><s:text name="Page_Down"/><!-- 下一页 --></a>
                        <a href="javascript:" id="last"><s:text name="End_Page"/><!-- 尾页 --></a>
                        <span id="cont">
                            <s:text name="Goto"/><!-- 转到 --><input type="text" id="page_num" value="1"/>
                            <a href="javascript:" id="go"><s:text name="Jump"/><!-- 跳转 --></a>
                        </span>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="popup"></div>
    <!-- 导航定位  -->
    <div class="popup w500 mr250" id="localNav">
        <div class="popup-title"><span>机房查询</span><a href="javascript:;" class="close">X</a></div>
        <div class="popup-content">
            <div class="popup-tbl">
                <table>
                    <tbody>
                        <tr>
                            <th>机房名称/机房id</th>
                        </tr>
                        <tr>
                            <td>
                                <input name="popupHomeName" id="popupHomeName" type="text">
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        
        <div class="popup-footer">
            <input type="button" name="" id="localNav_en" class="status-change-btn" value="确定" > <!-- 确定 -->
            <input type="button" name="" class="close" value="取消" >                <!-- 取消 -->
        </div>
    </div>
    
    <!-- iframe数据临时存储位置 -->
    <div id="homeInfoIframeData"></div>
    <script type="text/javascript" src="src/layui.all.js"></script>
    <script type="text/javascript" src="jqueryui/jquery-ui.min.js"></script>
    <script type="text/javascript" src="js/equip-stats-change.jquery.ui.js"></script>
    <script type="text/javascript" src="js/basic-layout.js"></script>
    <script type="text/javascript" src="pages/js/pages/siderbar.js"></script>
    <script type="text/javascript" src="js/pageUtil.js"></script>
    <script type="text/javascript" src="js/popup.js"></script>
    <script type="text/javascript" src="pages/js/pages/homeInfo.js"></script>
    <script type="text/javascript">
        var arrTh = [];
        var arrTd = [];
        var Page = {
            pageCurr:1,
            pageSize:10,
            pageAll:0
        };
        var layerMsg;
        
        var localNav = new Popup($('#localNav'));
        // 初始化localNav弹出框
        $('#localNav').find('.close').bind('click', function() {
            localNav.hidePopup();    // 隐藏localNav弹出框和遮罩层
        });
        
        // 窗口大小改变
        $(window).resize(function() {
            localNav.hidePopup();
        }); 
        
        // 生成页面中的表格
        $(function () {
            arrTh = ['设备Id', '机房名称', '事件类型', '变迁前状态', '变迁后状态', '变迁原因','模块编号','变迁时间'];
            createFullTbl($('.tbl-header'), $('.tbl-body'), arrTh, arrTd);
            var stop_types = [
                '手动停止', '暂停', '正在放电测试', '正在等待放电', '正在限流放电', 
                '正在直流充电', '正在等待充电', '放电时间到', '放电容量到', '单体下限到', 
                '组端下限到', '市电中断停止', '存储数据满', '机内温度异常', '放电电流过流',
                '后台通信中断', '负载模块中断', '在线模块中断', '负载模块过功率', '内部程序异常' 
            ];
            createSel($('#statsList'), stop_types);
            
            // 切换下拉选项更改表格内容
            $('#statsList').on('change', function() {
                searchDevHistoryRecord();
            });
            
            // 查询时间段改变
            $('#record_start_time').on('change', function() {
                searchDevHistoryRecord();
            });
            $('#record_stop_time').on('change', function() {
                searchDevHistoryRecord();
            });
            /**
             * 生成下拉框 
             *@param jquery ele 下拉元素
             *@param array dataList 数据列表
             */
            function createSel(ele, dataList) {
                ele.text(" ");
                
                var $opt = '<option value="-1">全部</option>';
                
                // 遍历dataList向ele添加更多的选项
                for(var i=0; i<dataList.length; i++) {
                    $opt += '<option value="'+i+'">'+dataList[i]+'</option>';
                }
                ele.html($opt);
            }
        });
        
        //根据维护区查询所有的机房
        function searchDevHistoryRecord(){
            // 关闭msg
            layer.close(layerMsg);
            // 生成内容
            arrTd = new Array();
            loading.showLoading($('.tbl-body'));
            $.ajax({     
                type:"post",                 
                url: "Fbsdev_Statechange_infAction!serchByCondition",                
                async:true,                
                dataType:'text',
                data:"json="+JSON.stringify(createSearchParam()),
                success: function(data){ 
                    data = eval('('+data+')');
                    var model = eval('('+data.result+')');
                    console.info(model);
                    if(model.code == 1){
                        for(var i=0;i<model.data.length;i++){
                            var _data = model.data[i];                        
                            arrTd.push(_data.dev_id);                        //设备id
                            arrTd.push(_data.note);                            //机房名称
                            arrTd.push(_data.eve_type_name);                //变迁前事件类型
                            arrTd.push(_data.last_stat_name);                //变换前状态
                            arrTd.push(_data.now_stat_name);                //变化后状态
                            arrTd.push(_data.state_change_reason_name);        //变换原因
                            arrTd.push(_data.module_num);                                            //模块编号
                            arrTd.push(_data.rec_time);                        //变换时间
                            
                            if(model.data[i].page != undefined){                            
                                Page.pageAll = model.data[i].page.pageAll;            //总记录条数
                            }
                        }
                    }else{
                        layerMsg = layer.msg("未查询到状态变换记录");
                        Page.pageAll = 0;
                    }
                    $('#total').text(Page.pageAll);
                    var pageNum = Math.ceil(Page.pageAll/Page.pageSize);
                    $('#current').text(Page.pageCurr+"/"+pageNum);
                    
                    loading.hideLoading($('.tbl-body'));    
                    createFullTbl($('.tbl-header'), $('.tbl-body'), arrTh, arrTd);            
                }                 
            });
        }
        
        // 事件类型
        function getTextByVal(num) {
            var _num = Number(num);
            var rs = '';
            switch(_num){
                case 0:
                    rs = 'BTS工作状态:';
                break;
                case 11:
                    rs = 'SD卡故障:';
                break;
                case 12:
                    rs = '电池离线状态:';
                break;
                case 20:
                    rs = 'DCDC模块告警状态:';
                break;
            }
            
            return rs;
        }
        
        /**
        **    构造查询 条件
        */
        function createSearchParam(){
            var temp ={
                state_change_reason: -1,
                dev_id:"910000012",                //设备id
                rec_time:$('#record_start_time').val()+" 00:00:00",                //设备id
                rec_time1:$('#record_end_time').val()+" 23:59:59",                //设备id
                page:Page,
            };
            var battGroupInfo = getBatt();
            temp.dev_id = battGroupInfo.FBSDeviceId;
            temp.state_change_reason = $('#statsList').val();
            return temp;
        }
        
        // 获取被选中电池组的信息
        function getBatt() {
            var rs = $('#lside .sider-menu-file.active').data('attr');
            return rs;
        }
        
        $(function(){
            $('#paging .search').click(function (){
                searchDevHistoryRecord();
            });
            
            //点击首页
            $('#home').click(function(){
                GotoFirstPage(Page,searchDevHistoryRecord);
            });
            
            //点击上一页
            $('#pre').click(function(){
                GotoPrePage(Page,searchDevHistoryRecord);
            });
            
            //点击下一页
            $('#next_p').click(function(){
                GotoNextPage(Page,searchDevHistoryRecord);
            });
            
            //点击尾页
            $('#last').click(function(){
                GotoLastPage(Page,searchDevHistoryRecord);
            });
            
            //设置每页大小数
            $('#number').blur(function(){
                var pageSize = $(this).val();
                if(pageSize>0){
                    Page.pageSize = parseInt(pageSize);
                }else{
                    $(this).val(Page.pageSize);
                }
            });
            
            //设置跳转到的页数
            $('#page_num').blur(function(){
                var pageCurr = $(this).val();
                if(pageCurr>0){
                    Page.pageCurr = parseInt(pageCurr);
                }else{
                    $(this).val(Page.pageCurr);
                }
            });
            
            //点击跳转
            $('#go').click(function(){
                GotoAppointPage($('#page_num'),Page,searchDevHistoryRecord);
            });
        });
        
        //点击导出按钮        $('.tbl-header'), $('.tbl-body')
        $('#export_table').click(function(){
            console.info($('#tbHead .tbFixed thead th').length);
            exprotTable($('.tbl-body th'),$('.tbl-body tbody td'),$('#export_excel'),$('#table_th_arr'),$('#table_td_arr'));
        });
        // 导出内容
        function exprotTable(eleTh,eleTd,eleform,eleTh_Text,eleTd_Text){
            //alert("导出");
            var ArrTh=new Array();
            for(var i=0;i<eleTh.length;i++)
            {
                 ArrTh[i]=eleTh.eq(i).text();
            }
            var ArrTd="";
            for(var i=0;i<eleTd.length;i++)
            {
                     ArrTd+=eleTd.eq(i).text()+"&";
            }
            eleTh_Text.attr('value',ArrTh);
            eleTd_Text.attr('value',ArrTd);
            //console.info(ArrTh);
            //console.info(ArrTd);
            eleform.submit();
        }
        
        // siderbar模块
        $(function() {
            var TreeView = GLOBAL.pages.TreeView;
            var first = GLOBAL.pages.siderbar.first;    // 一级导航
            var second = GLOBAL.pages.siderbar.second;    // 二级导航
            var third = GLOBAL.pages.siderbar.third;    // 三级导航
            var fourth = GLOBAL.pages.siderbar.fourth;    // 四级导航
            var fifth = GLOBAL.pages.siderbar.fifth;    // 五级导航
            var localSideBar = GLOBAL.pages.siderbar.localSideBar;    // 定位机房
            var treeView = new TreeView($('#lside'));
            $('#lside').width($('#ele_content').width());
            treeView.setContainer();
            // 设置页面的左侧可以左右缩放
            $('.page-content .content-item.side-bar-container').resizable({
                handles: 'e',
                maxWidth: 520,
                minWidth: 200,
                //alsoResize: $('#lside'),
                resize:function() {
                    treeView.setContainer();
                }
            });
            
            // 生成一级导航-省
            first(treeView, treeView.container);
            
            // 省->市
            treeView.ele.on('click', '.province', function() {
                var province = $(this).data('attr');
                second(treeView, $(this).parent(), province);
            });
            
            // 市->区/县
            treeView.ele.on('click', '.city', function() {
                var city = $(this).data('attr');
                third(treeView, $(this).parent(), city);
            });
            
            // 市->机房
            treeView.ele.on('click', '.county', function() {
                var city = $(this).data('attr');
                fourth(treeView, $(this).parent(), city);
            });
            
            
            
            battinlist = [];
            // 机房->电池组
            treeView.ele.on('click', '.home', function() {
                var home = $(this).data('attr');
                var tmp = {
                    StationName1: home.StationName1,
                    StationName2: home.StationName2,
                    StationName5: home.StationName5,
                    StationName: home.StationName,
                    StationId: home.StationId
                };
                fifth(treeView, $(this).parent(), tmp);
            });
            
            // 电池组
            treeView.ele.on('click', '.eleGroup', function() {
                var eleGroup = $(this).data('attr');
                searchDevHistoryRecord();
            });
            
            // 工具条-全部收缩
            $('#siderbarToolsHide').click(function(){
                treeView.ele.find('li').removeClass('sider-menu-open');
            });
            
            // 工具条-机历卡
            $('#siderbarToolsCard').click(function(){
                var batt = getBatt();
                var tmp = {
                    province: batt.StationName1,
                    city: batt.StationName2,
                    county: batt.StationName5,
                    home: batt.StationName,
                    homeid: batt.StationId,
                    battid: batt.BattGroupId
                };
                // 显示基站机历卡
                showHomeInfo(batt.StationId);
                // 根据数据定位
                localSideBar(treeView, treeView.container, tmp);
            });
            
            // 工具条-查询
            $('#siderbarToolsSearch').click(function(){
                localNav.homeInfo = undefined;
                $('#popupHomeName').val('');
                localNav.showPopup();
            });
            
            // 点击面板的确定按钮
            $('#localNav_en').click(function() {
                // 定位
                if(localNav.homeInfo) {
                    localNav.hidePopup();
                    localSideBar(treeView, treeView.container, localNav.homeInfo);
                }else {
                    
                }
            });
            
            // 查询机房并更新source
            var homeSource = [];
            findHome();
            
            // 定义机房查询信息
            $( "#popupHomeName" ).autocomplete({
                source: homeSource,
                select: function(event, ui) {
                    localNav.homeInfo = ui.item;    // 设置机房信息内容
                }
            });
            
            // 查询机房
            function findHome() {
                var tmp = {
                    StationName1:'',
                    StationName2: '',
                    StationName5:''
                };
                
                // 查询将信息
                $.post("BattInfAction!serchStationName3","json="+JSON.stringify(tmp),function(result){
                    var rs = JSON.parse(result.result);
                    if(rs.code==1){
                        homeSource = [];
                        var data = rs.data;
                        for(var i=0; i<data.length; i++) {
                            var _data = data[i];
                            var tmp = {
                                label: _data.StationName+'('+_data.StationId+')',
                                province: _data.StationName1,
                                city: _data.StationName2,
                                county: _data.StationName5,
                                home: _data.StationName,
                                homeid: _data.StationId,
                                battid: undefined
                            };
                            
                            // 添加到资源
                            homeSource.push(tmp);
                        }
                        $( "#popupHomeName" ).autocomplete('option', 'source', homeSource);
                    }
                });
            }
            
        });
        
        //根据当前选中的电池组id获取当前电池组的信息
        function getBatt(){
            var activeFile = $('.whyc-sider-menu .sider-menu-file.active');
            if(activeFile.length == 1) {
                return activeFile.data('attr');
            }else {
                return undefined;
            }
            
        }
    </script>
  </body>
</html>