geodynamicreport.js 36.2 KB
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 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043
//设置最早时间-早于这个时间之前数据库内无数据,查询会报错
var initDate = new Date("2017/11/01 00:00:00");
//停车时长区间
var parkDuration = [[0,365*24*60*60],[0,10],[10,30],[30,60],[60,3*60],[3*60,5*60],[5*60,30*60],[30*60,60*60],
    [60*60,2*60*60],[2*60*60,5*60*60],[5*60*60,10*60*60],[10*60*60,365*24*60*60]];
var secondAreas = ["所有时长","0-10s","10-30s","30s-1min","1-3min","3-5min", "5-30min","30min-1h","1-2h", "2-5h","5-10h","10h 以上"];

//停车周转次数
var parkTurnOver = ['所有次数','0次','1次','2-5次','5-10次','10-20次','20-50次','50次以上'];
var turnOverTimes = [[null,null],[0,0],[1,1],[2,5],[5,10],[10,20],[20,50],[50,2147483647]];
//定义泊位区间缓存区
var berthRangeCache = {};
//导出功能
window.downloadFile = function (sUrl) {

    //iOS devices do not support downloading. We have to inform user about this.
    if (/(iP)/g.test(navigator.userAgent)) {
        alert('Your device does not support files downloading. Please try again in desktop browser.');
        return false;
    }

    //If in Chrome or Safari - download via virtual link click
    if (window.downloadFile.isChrome || window.downloadFile.isSafari) {
        //Creating new link node.
        var link = document.createElement('a');
        link.href = sUrl;

        if (link.download !== undefined) {
            //Set HTML5 download attribute. This will prevent file from opening if supported.
            var fileName = sUrl.substring(sUrl.lastIndexOf('/') + 1, sUrl.length);
            link.download = fileName;
        }

        //Dispatching click event.
        if (document.createEvent) {
            var e = document.createEvent('MouseEvents');
            e.initEvent('click', true, true);
            link.dispatchEvent(e);
            return true;
        }
    }

    // Force file download (whether supported by server).
    if (sUrl.indexOf('?') === -1) {
        sUrl += '?download';
    }

    window.open(sUrl, '_self');
    return true;
}

window.downloadFile.isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
window.downloadFile.isSafari = navigator.userAgent.toLowerCase().indexOf('safari') > -1;
$("#queryBtn").click(function () {
    if(!validDateForDuration()){
        return;
    }
    funinit.queryGeoDurationDatas();
    funinit.queryGeoDurationDetailDatas();

});
var funinit = {
    init:function () {
        //初始化块下拉框
        funinit.initParkBlock(-1);
        //块下拉框变化,停车场下拉框变化
        funinit.queryBlockChange();
        //初始化状态
        $('#inType').selectpicker('refresh');
        //日历插件 停车时长
        $('#daterange-btn input').val(moment().subtract('days', 1).format('YYYY-MM-DD') + '  -  ' + moment().subtract('days',1).format('YYYY-MM-DD'));
        $('#daterange-btn').daterangepicker({
                startDate: moment().subtract('days', 1),
                endDate: moment().subtract('days', 1),
                opens: 'right', //日期选择框的弹出位置
                dateLimit : {
                    days : 30
                }, //起止时间的最大间隔
                locale: {
                    applyLabel: '确定',
                    cancelLabel: '取消',
                    customRangeLabel: '自定义',
                    daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
                    monthNames: ['一月', '二月', '三月', '四月', '五月', '六月',
                        '七月', '八月', '九月', '十月', '十一月', '十二月'
                    ],

                },

                ranges: {
                    '昨天': [moment().subtract('days', 1), moment().subtract('days', 1)],
                    '最近一周': [moment().subtract('days', 7), moment().subtract('days', 1)],
                    '最近一个月': [moment().subtract('months', 1), moment().subtract('days', 1)],
                },
                maxDate: moment().subtract('days',1), //最大时间

            },
            function(start, end) {
                $('#daterange-btn input').val(start.format('YYYY-MM-DD ') + '  -  ' + end.format('YYYY-MM-DD '));
                //alert(start.format('YYYYMMDD') + " " + end.format('YYYYMMDD'));
            }
        );


    },
    //查询并过滤没有地磁的办事处
    getParkBlockFilter:function(datas){
        var data = [];
        var blockIdsFilter = [];
        var blockIds = [];
        $.each(datas, function(index,item) {
            blockIds.push(item.code);
        });
        var req = {
            sysCode:sysComm.sysCode,
            areaBlockIds:blockIds
        };
        var opt = {
            async: false,
            data: JSON.stringify(req),
            method: "POST",
            url: dataUrl.util.getBlockIdListByBlockIds(),
            success: function (res) {
                if (res.code == '8888') {
                    blockIdsFilter = res.data;
                    $.each(datas, function(index,item) {
                        $.each(blockIdsFilter, function(_index,_item) {
                            if(item.code == _item){
                                data.push(item);
                            }
                        });

                    });
                }
            }
        }
        sysAjax(opt);
        return data;
    },
    //停车区域-块  flag:-1加载所有的,0-加载第一个 1-加载第二个 2-加载第三个
    initParkBlock: function (flag) {
        var datas = fn.getParkBlock();
        var data = funinit.getParkBlockFilter(datas);
        var html = '';
        var htmls = '';
        var blockIds = [-1];
        for (var i = 0; i < data.length; i++) {
            blockIds.push(data[i].code);
            html += "<option value='[\"" + data[i].code + "\"]'>" + data[i].name + "</option>";
        }
        var blockIdsStr = JSON.stringify(blockIds);
        htmls = '<option value=' + blockIdsStr + ' selected>所有办事处</option>' + html;
        if(flag == -1){
            $("#plAreaBlockIds").empty();
            $("#plAreaBlockIds1").empty();
            $("#plAreaBlockIds2").empty();
            $("#plAreaBlockIds").append(htmls);
            $('#plAreaBlockIds').selectpicker('render');
            //加载周转次数页面的街道办事处
            //右上角
            $("#plAreaBlockIds1").append(htmls);
            $('#plAreaBlockIds1').selectpicker('render');
            //单个停车场的街道办事处
            //$("#plAreaBlockIds2").append('<option value="[-1]" selected>选择街道办事处</option>'+html);
            $("#plAreaBlockIds2").append(htmls);
            $('#plAreaBlockIds2').selectpicker('render');
            //加载下拉框
            funinit.initParkSelect(-1);
        }
        else if(flag == 0){
            $("#plAreaBlockIds").empty();
            $("#plAreaBlockIds").append(htmls);
            $('#plAreaBlockIds').selectpicker('render');
            funinit.initParkSelect(0);
        }
        else if(flag == 1){
            $("#plAreaBlockIds1").empty();
            $("#plAreaBlockIds1").append(htmls);
            $('#plAreaBlockIds1').selectpicker('render');
            funinit.initParkSelect(1);
        }
        else if(flag == 2){
            $("#plAreaBlockIds2").empty();
            $("#plAreaBlockIds2").append('<option value="[-1]" selected>选择街道办事处</option>'+html);
            $('#plAreaBlockIds2').selectpicker('render');
            funinit.initParkSelect(2);
        }
        else{
            return;
        }

    },
    //根据块信息查询停车场信息
    initParkSelect:function(flag){
        //停车场下拉框
        var data = funinit.getParkingLotMsg(flag);
        var htmls = '';
        var html = '';
        var plNos = [];
        for (var i = 0; i < data.length; i++) {
            plNos.push(data[i].plNo);
            html += "<option value='[\"" + data[i].plNo + "\"]'>" + data[i].plName + "</option>";
        }
        var plnosStr = JSON.stringify(plNos);
        htmls = '<option value=' + plnosStr + ' selected>所有停车场</option>' + html;
        if(flag == -1){
            $("#parkIds").empty();
            $("#parkIds").append(htmls);
            $('#parkIds').selectpicker('render');
            $("#parkIds1").empty();
            $("#parkIds1").append(htmls);
            $('#parkIds1').selectpicker('render');
            $("#parkIds2").empty();
            $("#parkIds2").append(htmls);
            $('#parkIds2').selectpicker('render');
            $("#parkIds3").empty();
            $("#parkIds3").append(htmls);
            $('#parkIds3').selectpicker('render');
        }
        else if (flag ==0){
            $("#parkIds").empty();
            $("#parkIds").append(htmls);
            $('#parkIds').selectpicker('refresh');

            $("#parkIds3").empty();
            $("#parkIds3").append(htmls);
            $('#parkIds3').selectpicker('refresh');
        }
        else if (flag ==1){
            $("#parkIds1").empty();
            $("#parkIds1").append(htmls);
            $('#parkIds1').selectpicker('refresh');
        }
        else if (flag ==2){
            $("#parkIds2").empty();
            //$("#parkIds2").append("<option value='[\"-1X\"]' selected>选择停车场</option>"+html);
            $("#parkIds2").append(htmls);
            $('#parkIds2').selectpicker('refresh');
        }
        else{
            return;
        }

    },
    getParkingLotMsg:function(flag){
        var plAreaBlockIds;
        if(flag == -1){
            plAreaBlockIds = JSON.parse($("#plAreaBlockIds").val());
        }
        else if(flag == 0){
            plAreaBlockIds = JSON.parse($("#plAreaBlockIds").val());
        }
        else if(flag == 1){
            plAreaBlockIds = JSON.parse($("#plAreaBlockIds1").val());
        }
        else if(flag == 2){
            plAreaBlockIds = JSON.parse($("#plAreaBlockIds2").val());
        }
        else{
            return;
        }
        var parkLot = "";
        var req = {
            sysCode:sysComm.sysCode,
            areaBlockIds: plAreaBlockIds
        };
        var opt = {
            async: false,
            data:JSON.stringify(req),
            method: "POST",
            //contentType:"application/x-www-form-urlencoded; charset=UTF-8",
            url: dataUrl.util.getParkListByBlockIds(),
            success: function (res) {
                if (res.code == '8888') {
                    parkLot = JSON.stringify(res.data);
                }
            }
        }
        sysAjax(opt);
        return JSON.parse(parkLot);
    },
    //块改变查询停车场
    queryBlockChange:function(){
        /*$("#plAreaBlockIds").change(function(){
         funinit.initParkSelect(-1);
         });*/
        $("#plAreaBlockIds").change(function(){
            funinit.initParkSelect(0);
        });
        $("#plAreaBlockIds1").change(function(){
            funinit.initParkSelect(1);
            //重新加载地磁厂商统计图
            factoryTurnOverAjax();
        });
        $("#plAreaBlockIds2").change(function(){
            funinit.initParkSelect(2);
        });

    },
    //详细-停车场下拉框初始化
    initParkIdsSelect:function(){
        var plno = $("#parkIds").val();
        $("#parkIds3").selectpicker('val',plno);
    },
    //详细-分布区间初始化
    initSecondArea:function(name){
        var html;
        $.each(secondAreas,function(index,item){
            html+='<option value=' + index + ' selected>'+item+'</option>';
        });
        $("#secondArea").empty();
        $("#secondArea").append(html);
        $("#secondArea").selectpicker('refresh');
        if(name == null || name == undefined){
            return;
        }
        $("#secondArea").selectpicker('val',secondAreas.indexOf(name));
    },
    //详细-选择时间初始化
    initDurationDate:function(dates){
        //日历插件 停车时长
        $('#daterangeedit-btngeo input').val(moment().subtract('days', 0).format('YYYY-MM-DD') + '  -  ' + moment().subtract('days',0).format('YYYY-MM-DD'));
        $('#daterangeedit-btngeo').daterangepicker({
                // startDate: moment().subtract('days', 1),
                endDate: moment().subtract('days',0),
                opens: 'left', //日期选择框的弹出位置
                dateLimit : {
                    days : 30
                }, //起止时间的最大间隔
                locale: {
                    applyLabel: '确定',
                    cancelLabel: '取消',
                    customRangeLabel: '自定义',
                    daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
                    monthNames: ['一月', '二月', '三月', '四月', '五月', '六月',
                        '七月', '八月', '九月', '十月', '十一月', '十二月'
                    ],

                },

                ranges: {
                    '昨天': [moment().subtract('days', 1), moment().subtract('days', 1)],
                    '最近一周': [moment().subtract('days', 7), moment().subtract('days', 1)],
                    '最近一个月': [moment().subtract('months', 1), moment().subtract('days', 1)],
                    '最近三个月': [moment().subtract('months', 3), moment().subtract('days', 1)],
                },
                maxDate: moment().subtract('days', 0), //最大时间

            },

            function(start, end) {
                $('#daterangeedit-btngeo input').val(start.format('YYYY-MM-DD ') + '  -  ' + end.format('YYYY-MM-DD '));
            }
        );
        $('#daterangeedit-btngeo input').val(dates);
    },
    getQueryParams:function(){
        var plBlockIds = JSON.parse($("#plAreaBlockIds").val());
        var plNos = JSON.parse($("#parkIds").val());
        if(plNos.length<1){
            plNos.push("-1X");
        }
        var inType = $("#inType").val();
        var dateValue = $("#daterange-btn input").val();
        var dates=dateValue.split(" - ");
        var beginTime = dates[0]+" 00:00:00";
        var endTime = dates[1]+" 23:59:59";
        var req= {
            sysCode:sysComm.sysCode,
            plBlockIds: plBlockIds,
            plNos: plNos,
            inType: inType,
            beginTime: new Date(beginTime.replace(new RegExp(/-/gm) ,"/")),
            endTime: new Date(endTime.replace(new RegExp(/-/gm) ,"/")),
        };
        return req;
    },
    getDetailQueryParams:function(){
        var plNos = JSON.parse($("#parkIds3").val());
        if(plNos.length<1){
            plNos.push("-1X");
        }
        var secondArea = $("#secondArea").val();
        var inType = $("#inType").val();
        var eqpStayBegin = parkDuration[secondArea][0];
        var eqpStayEnd = parkDuration[secondArea][1];
        var dateValue = $("#daterangeedit-btngeo input").val();
        var dates=dateValue.split(" - ");
        var beginTime = dates[0]+" 00:00:00";
        var endTime = dates[1]+" 23:59:59";
        var req= {
            sysCode:sysComm.sysCode,
            plNos: plNos,
            inType: inType,
            eqpStayBegin: eqpStayBegin,
            eqpStayEnd: eqpStayEnd,
            beginTime: new Date(beginTime.replace(new RegExp(/-/gm) ,"/")),
            endTime: new Date(endTime.replace(new RegExp(/-/gm) ,"/")),
        };
        return req;
    },
    //查询地磁停车时长数据
    queryGeoDurationDatas:function(){
        var req = funinit.getQueryParams();
        var opt= {
            method: 'POST',
            url: dataUrl.util.queryEqpInOutPark(),
            data: JSON.stringify(req),
            contentType: 'application/json; charset=utf-8',
            dataType:'json',
            success: function(res){
                console.log("图01 02:",res);
                if(res.code = "8888"){
                    var data = res.data;
                    funinit.drawGeoDurationCharts(data);
                }else{

                }
            }
        };
        sysAjax(opt);
    },
    //查询地磁平均停车时长数据
    queryGeoDurationDetailDatas:function(){
        var req = funinit.getQueryParams();
        var opt= {
            method: 'POST',
            url: dataUrl.util.queryEqpDurByTime(),
            data: JSON.stringify(req),
            contentType: 'application/json; charset=utf-8',
            dataType:'json',
            success: function(res){
                console.log("图03:",res);
                if(res.code = "8888"){
                    var data = res.data;
                    funinit.drawDurationDetailChart(data);
                }else{

                }
            }
        };
        sysAjax(opt);
    },
    //填充两个停车时长扇形图
    drawGeoDurationCharts:function(data){
        var normalDatas = [{value:0, name:'5-30min'},{value:0, name:'30min-1h'},{value:0, name:'1-2h'},
            {value:0, name:'2-5h'},{value:0, name:'5-10h'},{value:0, name:'10h 以上'}];
        var nonormalDatas = [{value:0, name:'0-10s'},{value:0, name:'10-30s'},{value:0, name:'30s-1min'},
            {value:0, name:'1-3min'},{value:0, name:'3-5min'}];

        normalDatas[0].value=data.normalNum1;
        normalDatas[1].value=data.normalNum2;
        normalDatas[2].value=data.normalNum3;
        normalDatas[3].value=data.normalNum4;
        normalDatas[4].value=data.normalNum5;
        normalDatas[5].value=data.normalNum6;

        nonormalDatas[0].value=data.nuNum1;
        nonormalDatas[1].value=data.nuNum2;
        nonormalDatas[2].value=data.nuNum3;
        nonormalDatas[3].value=data.nuNum4;
        nonormalDatas[4].value=data.nuNum5;
        // 地磁正常
        var nomalmainoption = {
            color:['#1e95cd','#5fe98f','#fdc94d','#50c0f5','#5ed8a6','#2bb97f','#50c0f5','#fd714b','#a5dff3'],
            tooltip: {
                trigger: 'item',
                formatter: "{a} <br/>{b}: {c} ({d}%)"
            },
            legend: {
                orient: 'vertical',
                right:'15%',
                top:'10%',
                selectedMode:false,
                hoverAnimation: false,
                avoidLabelOverlap: false,
                textStyle: {
                    color: 'rgba(0,0,0,0.5)',
                    fontSize:'12px',
                    fontFamily:'微软雅黑'
                },
                itemWidth:16,
                itemHeight:10,
                data:['5-30min','30min-1h','1-2h','2-5h','5-10h','10h 以上']
            },
            series: [
                {
                    name:'地磁正常',
                    type:'pie',
                    radius: ['60%', '70%'],
                    center:['30%', '50%'],
                    avoidLabelOverlap: false,
                    hoverAnimation: false,
                    legendHoverLink: false,
                    label: {
                        normal: {
                            show: false,
                            position: 'center'
                        },
                        emphasis: {
                            show: false,
                            textStyle: {
                                fontSize: '12',
                                fontWeight: 'bold'
                            }
                        }
                    },
                    labelLine: {
                        normal: {
                            show: false
                        }
                    },
                    data:normalDatas
                }
            ]
        };
        nomalmain.setOption(nomalmainoption,true);
        // nomalmain.dispatchAction({
        //     type: 'downplay',
        //     seriesIndex: 0,
        //     dataIndex: 0
        // });
        // nomalmain.dispatchAction({
        //     type: 'highlight',
        //     seriesIndex: 0,
        //     dataIndex: 0
        // });
        // nomalmain.resize();
        // 地磁异常
        var anomalmainoption = {
            color:['#1e95cd','#5fe98f','#fdc94d','#50c0f5','#5ed8a6','#2bb97f','#50c0f5','#fd714b','#a5dff3'],
            tooltip: {
                trigger: 'item',
                formatter: "{a} <br/>{b}: {c} ({d}%)"
            },
            legend: {
                orient: 'vertical',
                right:'15%',
                top:'10%',
                selectedMode:false,
                textStyle: {
                    color: 'rgba(0,0,0,0.5)',
                    fontSize:'12px',
                    fontFamily:'微软雅黑'
                },
                itemWidth:16,
                itemHeight:10,
                data:['0-10s','10-30s','30s-1min','1-3min','3-5min',]
            },
            series: [
                {
                    name:'地磁异常',
                    type:'pie',
                    // radius: ['50%', '70%'],
                    center:['30%', '50%'],
                    avoidLabelOverlap: false,
                    label: {
                        normal: {
                            show: false,
                            position: 'center'
                        },
                        emphasis: {
                            show: false,
                            textStyle: {
                                fontSize: '20',
                                fontWeight: 'bold'
                            }
                        }
                    },
                    labelLine: {
                        normal: {
                            show: false
                        }
                    },
                    data:nonormalDatas
                }
            ]
        };
        anomalmain.setOption(anomalmainoption);
        // anomalmain.dispatchAction({
        //     type: 'downplay',
        //     seriesIndex: 0,
        //     dataIndex: 0
        // });
        // anomalmain.dispatchAction({
        //     type: 'highlight',
        //     seriesIndex: 0,
        //     dataIndex: 0
        // });
        // anomalmain.resize();

    },
    //渲染平均停车时长趋势图
    drawDurationDetailChart:function(data){
        //data = [{avgTime:1111,queryDate:"2017-11-22",tatolNum:3456,tatolTime:365},{avgTime:111,queryDate:"2017-11-23",tatolNum:345,tatolTime:36},{avgTime:580,queryDate:"2017-11-24",tatolNum:500,tatolTime:79}];
        var dates = new Array();
        var avgTimes = new Array();
        if(data != null && data.length>0){
            $.each(data, function(index,item) {
                dates.push(item.queryDate);
                avgTimes.push(((item.avgTime)/(60*60)).toFixed(1));//秒->小时
            });
        }
        console.log(dates)
        var MeantimeEchartsoption = {
            tooltip : {
                trigger: 'axis',
                axisPointer : {            // 坐标轴指示器,坐标轴触发有效
                    type : 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
                }
            },
            grid: {
                left: '1%',
                right: '4%',
                bottom: '3%',
                top:'14%',
                containLabel: true
            },
            xAxis : [
                {
                    type : 'category',
                    data : dates,
                    axisLabel: {
                        // interval:2,
                        show: true,
                        textStyle: {
                            color: 'rgba(0,0,0,0.5)',
                            fontSize:'12px',
                            fontFamily:'微软雅黑'
                        }
                    },
                    // splitNumber:10,
                    // minInterval:2,
                    axisTick: {
                        show: false,
                    },
                    splitLine:{
                        lineStyle:{
                            color:'rgba(0,0,0,0.1)',
                        }
                    },

                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: 'rgba(0,0,0,0.1)',
                            // width: 1,//这里是为了突出显示加上的
                        }
                    },
                }
            ],
            yAxis : [
                {

                    type : 'value',
                    // name:"(小时)",
                    textStyle: {
                        color: 'rgba(0,0,0,0.5)',
                        fontSize:'12px',
                        fontFamily:'微软雅黑'
                    },
                    axisLabel: {
                        show: true,
                        textStyle: {
                            color: 'rgba(0,0,0,0.5)',
                            fontSize:'12px',
                            fontFamily:'微软雅黑'
                        }
                    },
                    axisTick: {
                        show: false,
                    },
                    splitLine:{
                        lineStyle:{
                            color:'rgba(0,0,0,0.1)',
                        }
                    },

                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: 'rgba(0,0,0,0.1)',
                            // width: 1,//这里是为了突出显示加上的
                        }
                    },
                }
            ],
            series : [
                {
                    name:'平均停车时长',
                    type:'bar',
                    barWidth : 20,
                    data:avgTimes,
                    itemStyle: {
                        normal: {
                            color:'#5cb3d8',
                           /* color: new echarts.graphic.LinearGradient(
                                0, 0, 0, 1,
                                [
                                    {offset: 0, color: '#2abb9b'},
                                    {offset: 1, color: '#57cbf6'}
                                ]
                            )*/
                        },
                        emphasis: {
                            color:'#5cb3d8',
                            /*color: new echarts.graphic.LinearGradient(
                                0, 0, 0, 1,
                                [
                                    {offset: 0, color: '#2abb9b'},
                                    {offset: 1, color: '#57cbf6'}
                                ]
                            )*/
                        }
                    },
                    markLine: {
                        symbolSize:0,
                        lineStyle:{
                            normal:{
                                color:'#5fe890'
                            }
                        },
                        data: [
                            {type: 'average', name: '平均值',},
                        ]
                    }
                }
            ]
        };
        MeantimeEcharts.setOption(MeantimeEchartsoption,true);
        MeantimeEcharts.resize();
    },
    //加载停车时长详细表信息
    createDurationTableData: function() {
        $('#turnoveroentabgeo').bootstrapTable('destroy').bootstrapTable({
            striped: true, //表格显示条纹
            pagination: true, //启动分页
            pageNumber: 1, //当前第几页
            // showColumns: true,
            pageSize: 10, //每页显示的记录数
            pageList: [10, 15, 20], //记录数可选列表
            sidePagination: 'server', //表示服务端分页
            queryParamsType: 'limit',
            method: 'POST', //请求方法
            // fixedColumns:true,
            // fixedNumber:1,
            // leftFixedColumns: true,
            // leftFixedNumber: 2,
            // selectItemName: 'personCustName',
            paginationPreText: '<',
            paginationNextText: '>',
            ajax: loadDurationDetailRequest, //自定义ajax加载数据
            uniqueId: 'id',
            columns: [
                {
                    field: 'plAreaBlockName',
                    title: '街道办事处',
                    width: '10%',
                    visible: true,
                    align: 'left'
                },
                {
                    field: 'plName',
                    title: '车场名称',
                    width: '10%',
                    align: 'left'
                },

                {
                    field: 'parkAreaName',
                    title: '泊位区间',
                    width: '10%',
                    align: 'left',
                },
                {
                    field: 'berthNo',
                    title: '泊位编号',
                    width: '8%',
                    align: 'left',
                },
                {
                    field: 'eqpNo',
                    title: '地磁编号',
                    width: '8%',
                    align: 'left',
                },
                {
                    field: 'eqpInTime',
                    title: '进场时间',
                    width: '10%',
                    align: 'left',
                    formatter:funinit.dateTimeFormatter
                },
                {
                    field: 'eqpOutTime',
                    title: '出场时间',
                    width: '10%',
                    align: 'left',
                    formatter:funinit.dateTimeFormatter
                },
                {
                    field: 'eqpParkingDuration',
                    title: '停车时长',
                    width: '10%',
                    align: 'left',
                    formatter:funinit.timeFormatter
                },
                {
                    field: 'pdaInType',
                    title: 'PDA是否录入',
                    width: '8%',
                    align: 'left',
                    formatter:funinit.pdaInTipeFormatter
                },
                {
                    field: 'inChargerCode',
                    title: '入场收费员编号',
                    width: '8%',
                    align: 'left'
                },
                {
                    field: 'inType',
                    title: '入场录入状态',
                    width: '8%',
                    align: 'left',
                    formatter:funinit.inTipeFormatter
                },
                {
                    field: 'outChargerCode',
                    title: '出场收费员编号',
                    width: '8%',
                    align: 'left'
                },
                {
                    field: 'outType',
                    title: '出场录入状态',
                    width: '8%',
                    align: 'left',
                    formatter:funinit.inTipeFormatter
                },
            ]
        });
        $("#geopopmodel").modal('show');
    },
    timeFormatter:function(value) {
        var theTime = parseInt(value);// 秒
        var theTime1 = 0;// 分
        var theTime2 = 0;// 小时
        var theTime3 = 0;//天
        if(theTime<60){
            return theTime+'秒';
        }
        if (theTime >= 60) {
            theTime1 = parseInt(theTime / 60);
            theTime = parseInt(theTime % 60);
            if (theTime1 >= 60) {
                theTime2 = parseInt(theTime1 / 60);
                theTime1 = parseInt(theTime1 % 60);
                if(theTime2 >= 24){
                    theTime3 = parseInt(theTime2/24);
                    theTime2 = parseInt(theTime2%24);
                }
            }
        }
        var result = '';
        if (theTime1 > 0) {
            result = "" + parseInt(theTime1) + "分钟" + result;
        }
        if (theTime2 > 0) {
            result = "" + parseInt(theTime2) + "小时" + result;
        }
        if (theTime3 > 0) {
            result = "" + parseInt(theTime3) + "天" + result;
        }
        return result;
    },
    dateTimeFormatter: function(value, row, index) {
        if(value == null) {
            return "";
        } else {
            return DateUtils.long2String(value, 7);
        }
    },
    inTipeFormatter:function(value){
        if(value==null){
            return "";
        }
        else if(value == "0"){
            return "不一致";
        }
        else if(value == "1"){
            return "一致";
        }
        else{
            return "未知";
        }
    },
    pdaInTipeFormatter:function(value){
        if(value==null){
            return "";
        }
        else if(value == "0"){
            return "否";
        }
        else if(value == "1"){
            return "是";
        }
        else{
            return "未知";
        }
    }
};
funinit.init();

//绑定下拉框的change事件
documentBindFunc.on('change', '#plAreaBlockIds1', function () {
    funinit.initParkSelect(1);
    //重新加载地磁厂商统计图
    factoryTurnOverAjax();
});
/**
 * 自定义table AJAX请求
 * @param {Object} params
 */
function loadDurationDetailRequest(params) {
    var req = funinit.getDetailQueryParams();
    //设置请求参数
    var pageNum = (params.data.offset / params.data.limit) + 1;

    //条件查询
    req.baseRequest = {
        pageNum: pageNum,
        pageSize: params.data.limit
    };
    req.sysCode = sysComm.sysCode;
    var opt = {
        method: 'post',
        url: dataUrl.util.queryEqpInOutParkForList(),
        data: JSON.stringify(req),
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        success: function(res) {
            console.log("图04:",res);
            if(res.code == '8888') {
                params.success(res.data);
            }
            else{

            }
        }
    };
    sysAjax(opt);
}
function durationsClickFun(param){
    console.log(param)
    //初始化弹窗表格查询条件
    funinit.initParkIdsSelect();
    var name = "所有时长";//param.data.name;
    funinit.initSecondArea(name);
    var dates = $("#daterange-btn input").val();
    funinit.initDurationDate(dates);
    funinit.createDurationTableData();
}
// 地磁正常 弹窗
documentBindFunc.on('click','#geopopnormalBtn',function () {
    if(!validDateForDuration()){
        return;
    }
    durationsClickFun();
})
var nomalmain = echarts.init(document.getElementById('nomalmain'));
/*nomalmain.on('click',function(param){
    if(!validDateForDuration()){
        return;
    }
    durationsClickFun(param);
});*/

//地磁异常 弹窗
documentBindFunc.on('click','#geopopabnormalBtn',function () {
    if(!validDateForDuration()){
        return;
    }
    durationsClickFun();
})
var anomalmain = echarts.init(document.getElementById('anomalmain'));
/*anomalmain.on('click',function(param){
    if(!validDateForDuration()){
        return;
    }
    durationsClickFun(param);
});*/

documentBindFunc.on('click', '#queryBtngeo', function() {
    var dateValue = $("#daterangeedit-btngeo input").val();
    var dates=dateValue.split(" - ");
    var beginTime = dates[0]+" 00:00:00";
    beginTime = new Date(beginTime.replace(new RegExp(/-/gm) ,"/"));
    if(beginTime<initDate){
        $('#error_title').text('2017年11月1日之前无数据 !');
        $('#errormodel').modal('show');
        setTimeout(function () {
            $('#errormodel').modal('hide');
        },2000);
        return;
    }
    funinit.createDurationTableData();
});
//平均停车时长趋势图
var MeantimeEcharts = echarts.init(document.getElementById('MeantimeEcharts'));
funinit.queryGeoDurationDatas();
funinit.queryGeoDurationDetailDatas();
$('#durationDownload').on('click',function () {
    //校验日期
    if(!validDateForDuration()){
        return;
    }
    var plBlockIds = JSON.parse($("#plAreaBlockIds").val());
    var plNos = JSON.parse($("#parkIds").val());
    if(plNos.length<1){
        plNos.push("-1X");
    }
    var inType = $("#inType").val();
    var dateValue = $("#daterange-btn input").val();
    var dates=dateValue.split(" - ");
    var beginTime = dates[0]+" 00:00:00";
    var endTime = dates[1]+" 23:59:59";

    var url = dataUrl.util.exportEqpInOutParkAllStatisticExcel() + '?plNos=' + plNos + '&plBlockIds=' + plBlockIds + '&inType=' + inType + '&beginTime=' + beginTime + '&endTime=' + endTime +'&sysCode='+sysComm.sysCode;
    window.downloadFile(url);
});
//校验时间
function validDateForDuration(){
    var dateValue = $("#daterange-btn input").val();
    var dates=dateValue.split(" - ");
    var beginTime = dates[0]+" 00:00:00";
    beginTime = new Date(beginTime.replace(new RegExp(/-/gm) ,"/"));
    if(beginTime<initDate){
        swal({title:"提示",text:"2017年11月1日之前无数据 !",type:"warning",timer:3000,allowOutsideClick:true});
        return false;
    }
    return true;
}