carflowport.js 22.7 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
/**
 * Created by mac on 18/5/17.
 */



$('#devicereport-toptab li').on('click',function () {
    var _index = $(this).index();
    switch (_index){
        case 0:
            $('.parkincome-choosedatemonth').addClass('display-none');
            $('.parkincome-choosedateweek').addClass('display-none');
            $('.parkincome-choosedateday').removeClass('display-none');
            $('#devicereport-toptab li').eq(0).addClass('ITD-graynav-topbaractive').siblings().removeClass('ITD-graynav-topbaractive');

            $("#timeType").val(1);
            break;
        case 1:
            $('.parkincome-choosedateday').addClass('display-none');
            $('.parkincome-choosedatemonth').addClass('display-none');
            $('.parkincome-choosedateweek').removeClass('display-none');
            $('#devicereport-toptab li').eq(1).addClass('ITD-graynav-topbaractive').siblings().removeClass('ITD-graynav-topbaractive');

            $("#timeType").val(3);
            break;
        case 2:
            $('.parkincome-choosedateday').addClass('display-none');
            $('.parkincome-choosedateweek').addClass('display-none');
            $('.parkincome-choosedatemonth').removeClass('display-none');
            $('#devicereport-toptab li').eq(2).addClass('ITD-graynav-topbaractive').siblings().removeClass('ITD-graynav-topbaractive');
            fun.monthDate();
            $("#timeType").val(2);

    }
    fun.ltsrcreateTableData();
    fun.carFlowQueryData();
});
var fun= {
    init: function () {
        fun.dayDate();
        fun.weekDate();
        fun.monthDate();
        fun.ltsrcreateTableData();
        fun.carFlowQueryData();
    },
    dayDate:function() {
        $('#incomepark-daydaterange-btnsta').val(moment().subtract('days', 1).format('YYYY-MM-DD'));
        $('#incomepark-daydaterange-btnsta').datetimepicker({
            endDate: moment().subtract('days', 1).format('YYYY-MM-DD'),
            format: 'yyyy-mm-dd',
            autoclose: true,
            startView: 2,
            //maxDate:moment().subtract('months', 3),
            minView: 2,
            forceParse: false,
            locale: "zh-CN",
            language: 'zh-CN',
            pickerPosition: "bottom-right"
        })
    },
    weekDate:function() {
      $('#incomepark-weekdaterange-btnsta').attr('data-text',moment().subtract('days', 7).format('YYYY-MM-DD')+'-'+moment().subtract('days', 1).format('YYYY-MM-DD'))
        $('#incomepark-weekdaterange-btnsta').html(moment().subtract('days', 7).format('YYYY-MM-DD')+' 至 '+moment().subtract('days', 1).format('YYYY-MM-DD'));

    },

    monthDate:function() {
        $('#incomepark-monthdaterange-btnsta').val(moment().subtract('months', 1).format('YYYY-MM'));
        $('#incomepark-monthdaterange-btnsta').datetimepicker({
            endDate: moment().subtract('months', 1).format('YYYY-MM'),
            format: 'yyyy-mm',
            autoclose: true,
            startView: 3,
            //maxDate:moment().subtract('months', 3),
            minView: 3,
            forceParse: false,
            locale: "zh-CN",
            language: 'zh-CN',
            pickerPosition: "bottom-right"
        })
    },
    srzbChartsFun:function (dataValue) {
        console.log(dataValue);
        var srzbechartsPie = echarts.init(document.getElementById('parkinglengthport-echart'));
        srzboption = {
            color:['#1E95CD','#5fe98f','#fdc94d','#50c0f5'],
            title: {
                // subtext: "" + totalFee,
                // text: '总计',
                textStyle: {
                    color: '#c2c2c2',
                    fontSize: '14',
                    align: 'middle',
                    verticalAlign: 'middle',
                },
                subtextStyle: {
                    color: '#000',
                    fontSize: '24',
                    align: 'middle',
                    verticalAlign: 'middle',
                },
                left: 'center',
                top: '60',

            },
            tooltip: {
                trigger: 'item',
                formatter: "{a} <br/>{b}: {c} ({d}%)"
            },
            legend: {
                selectedMode:false,
                orient: 'horizontal',
                bottom: '0',
                icon:'circle',
                data:['支付宝','微信','余额','现金']
            },

            series: [
                {
                    name:'支付方式占比',
                    type:'pie',
                    radius: ['50%', '70%'],
                    center: ['50%', '50%'],
                    hoverAnimation: false,
                    avoidLabelOverlap: false,
                    legendHoverLink: false,
                    label: {
                        normal: {
                            show: false,
                            position: 'center'
                        },
                        emphasis: {
                            show: false,
                            textStyle: {
                                fontSize: '14',
                            }
                        }
                    },
                    labelLine: {
                        normal: {
                            show: false
                        }
                    },
                    data:[1,2,3,4]
                }
            ]
        }
        srzbechartsPie.setOption(srzboption, true);
        window.srzbechartsPie=srzbechartsPie;
        //自适应
        window.onresize = function(){
            srzbechartsPie.resize();
        };
    },
    ltsrcreateTableData: function () {
        $('#devicereport-table').bootstrapTable('destroy').bootstrapTable({
            striped: true,//表格显示条纹
            pagination: true, //启动分页
            pageNumber: 1, //当前第几页
            pageSize: 10,  //每页显示的记录数
            pageList: [10, 15, 20],  //记录数可选列表
            sidePagination: 'server',//表示服务端分页
            queryParamsType: 'limit',
            sortable: true,                     //是否启用排序
            sortOrder: "asc",
            method: 'POST',//请求方法
            paginationPreText: '<',
            paginationNextText: '>',
            ajax: incomeparktableLoadRequest,//自定义ajax加载数据
            // uniqueId:'id',
            columns: [
                {
                    field: 'number',
                    title: '序号',
                    width: '15%',
                    align: "left",
                    formatter:function(value,row,index){
                        //return index+1; //序号正序排序从1开始
                        var pageSize=$('#devicereport-table').bootstrapTable('getOptions').pageSize;//通过表的#id 可以得到每页多少条
                        var pageNumber=$('#devicereport-table').bootstrapTable('getOptions').pageNumber;//通过表的#id 可以得到当前第几页
                        var operStr='';
                        var topNo=pageSize * (pageNumber - 1) + index + 1;
                        /*if(topNo==1){
                            operStr ='<span class="ITD-popNo-one">'+topNo+'</span>';
                            return operStr;    //返回每条的序号: 每页条数 * (当前页 - 1 )+ 序号
                        }else if(topNo==2){
                            operStr ='<span class="ITD-popNo-two">'+topNo+'</span>';
                            return operStr;    //返回每条的序号: 每页条数 * (当前页 - 1 )+ 序号
                        }else if(topNo==3){
                            operStr ='<span class="ITD-popNo-three">'+topNo+'</span>';
                            return operStr;    //返回每条的序号: 每页条数 * (当前页 - 1 )+ 序号
                        }else {

                        }*/
                        operStr ='<span class="ITD-popNo-origin">'+topNo+'</span>';
                        return operStr;    //返回每条的序号: 每页条数 * (当前页 - 1 )+ 序号

                    }

                },
                {
                    field: 'plName',
                    title: '车场名称',
                    width: '25%',
                    align: "left",
                    formatter:commonObj.replacenull
                },
                {
                    field: 'plType',
                    title: '车场类型',
                    width: '25%',
                    align: "left",
                    formatter: plTypeFormatter
                },

                {
                    field: 'totalBerths',
                    title: '泊位数量',
                    width: '20%',
                    align: "left",
                    formatter:commonObj.replacenull
                },
                {
                    field: 'inParkCount',
                    title: '进场',
                    width: '20%',
                    align: "left",
                    formatter:commonObj.replacenull

                },
                {
                    field: 'outParkCount',
                    title: '出场',
                    width: '20%',
                    align: "left",
                    formatter:commonObj.replacenull

                },
                {
                    field: 'turnoverRatio',
                    title: '周转次数',
                    width: '20%',
                    align: "left",
                    formatter: turnOverFormatter
                },
                {
                    field: 'freeRatio',
                    title: '占用率',
                    width: '20%',
                    align: "left",
                    formatter: freeRatioFormatter

                },

            ]
        });
    },
    /*获取查询参数*/
    incomeparkgetQueryParam: function () {

        var data = fn.getParkLot();
        var plNos = [];
        for (var i = 0; i < data.length; i++) {
            plNos.push(data[i].code);

        }
        if (plNos.length < 1) {
            plNos.push("-1X");
        }
        /*开始时间*/
        var beginTime;
        /*结束时间*/
        var endTime;

        var  timeType=$("#timeType").val();

        if(timeType==1){
            var reportDate=$("#incomepark-daydaterange-btnsta").val();
            $("#carFlowTitle").text("日");
            $("#carFlowTitleTime").text(reportDate);
            beginTime=reportDate+" 00:00:00";
            endTime=reportDate+" 23:59:59";
        }else if(timeType==3){
            var reportDate=$("#incomepark-weekdaterange-btnsta").attr('data-text');
            $("#carFlowTitle").text("周");
            var reportDateStr=$("#incomepark-weekdaterange-btnsta").html();
            $("#carFlowTitleTime").text(reportDateStr);
           // console.log(reportDate);
            beginTime=reportDate.substring(0,11)+" 00:00:00";
            endTime=reportDate.substring(11,21)+" 23:59:59";
            //console.log(endTime);
        }else if(timeType==2){
            var reportDate=$("#incomepark-monthdaterange-btnsta").val();
            $("#carFlowTitle").text("月");
            $("#carFlowTitleTime").text(reportDate);
            beginTime = reportDate + "-01 00:00:00";
            var dates = reportDate.split("-");
            if (dates[1] == '02') {
                endTime = reportDate + "-28 23:59:59";
            } else if (dates[1] == '01' || dates[1] == '03' || dates[1] == '05' || dates[1] == '07'
                || dates[1] == '08' || dates[1] == '10' || dates[1] == '12') {
                endTime = reportDate + "-31 23:59:59";
            } else {
                endTime = reportDate + "-30 23:59:59";
            }
        }
        beginTime = beginTime == null || beginTime.length == 0 ? null : new Date((beginTime).replace(/-/g, "/"));
        endTime = endTime == null || endTime.length == 0 ? null : new Date((endTime).replace(/-/g, "/"));
        var req = {
            sysCode: sysComm.sysCode,
            plNos: plNos,
            beginTime: beginTime,
            endTime:endTime,
            timeType:timeType

        };
        return req;

    },
    carFlowQueryData:function () {
        var data = fn.getParkLot();
        $("#orgNameTitle").text(data[0].orgName==null?"":data[0].orgName);

        $("#allParkCount").text(0);
        $("#openParkCount").text(0);
        $("#closeParkCount").text(0);
        $("#berthsNum").text(0);
        $("#openBerthNum").text(0);
        $("#closeBerthNum").text(0);
        $("#allInCarCount").text(0);
        $("#closeInCarCount").text(0);
        $("#openInCarCount").text(0);
        $("#allOutCarCount").text(0);
        $("#closeOutCarCount").text(0);
        $("#openOutCarCount").text(0);
        $("#allTurnRatioCount").text(0);
        $("#closeTurnRatioCount").text(0);
        $("#openTurnRatioCount").text(0);




        var req=fun.incomeparkgetQueryParam();
        //条件查询
        req.baseRequest = {
            pageNum: 1,
            pageSize:0
        };
        req.sysCode = sysComm.sysCode;

        var opt = {
            method: 'post',
            url: dataUrl.util.queryCarFlowByDayForListForPage(),
            data: JSON.stringify(req),
            contentType: 'application/json; charset=utf-8',
            dataType: 'json',
            success: function (res) {
                console.log(res);
                if (res.code == '8888') {
                    var data=res.data;
                    var openInCarCount = 0;
                    var closeInCarCount = 0;
                    var allInCarCount = 0;
                    var openOutCarCount = 0;
                    var closeOutCarCount = 0;
                    var allOutCarCount = 0;
                    var openTurnRatioCount = 0;
                    var closeTurnRatioCount = 0;
                    var allTurnRatioCount = 0;
                    var openUseRatio = 0;
                    var closeUseRatio = 0;
                    var allUseRatio = 0;
                    var openCount=0;
                    var closeCount=0;
                    var count=0;
                    var outParkCount=0;

                    var berthsNum = 0;
                    var openBerthNum=0;
                    var closeBerthNum=0;
                    if(data!=null && data.rows!=null && data.rows.length>0){
                        var data=data.rows;
                        for (var i = 0; i < data.length; i++) {
                            if (parseInt(data[i].plType) == 1) {
                                openInCarCount +=parseInt(data[i].inParkCount);
                                openOutCarCount +=parseInt(data[i].outParkCount);
                                openTurnRatioCount +=parseInt(data[i].turnoverRatio);
                                openUseRatio +=((1-data[i].freeRatio)*100);
                                openCount+=1;
                                openBerthNum +=parseInt(data[i].totalBerths);
                            } else {
                                closeInCarCount +=parseInt(data[i].inParkCount);
                                closeOutCarCount +=parseInt(data[i].outParkCount);
                                closeTurnRatioCount +=parseInt(data[i].turnoverRatio);
                                closeUseRatio +=((1-data[i].freeRatio)*100);
                                closeCount+=1;
                                closeBerthNum +=parseInt(data[i].totalBerths);
                            }
                            allInCarCount += parseInt(data[i].inParkCount);
                            allOutCarCount += parseInt(data[i].outParkCount);
                            allTurnRatioCount += parseInt(data[i].turnoverRatio);
                            allUseRatio += ((1-data[i].freeRatio)*100);
                            count+=1;
                            berthsNum += parseInt(data[i].totalBerths);

                        }
                    }


                    $("#allParkCount").text(count);
                    $("#openParkCount").text(openCount);
                    $("#closeParkCount").text(closeCount);
                    $("#berthsNum").text(berthsNum);
                    $("#openBerthNum").text(openBerthNum);
                    $("#closeBerthNum").text(closeBerthNum);

                    $("#allInCarCount").text(allInCarCount);
                    $("#closeInCarCount").text(closeInCarCount);
                    $("#openInCarCount").text(openInCarCount);
                    $("#allOutCarCount").text(allOutCarCount);
                    $("#closeOutCarCount").text(closeOutCarCount);
                    $("#openOutCarCount").text(openOutCarCount);
                    //周转次数=进场次数/泊位数
                   // $("#allTurnRatioCount").text((allInCarCount/berthsNum).toFixed(2));
                   // $("#closeTurnRatioCount").text((closeInCarCount/closeBerthNum).toFixed(2));
                   // $("#openTurnRatioCount").text((openInCarCount/openBerthNum).toFixed(2));
                  $("#allTurnRatioCount").text((allInCarCount/(berthsNum<1?1:berthsNum)).toFixed(2));
                    $("#closeTurnRatioCount").text((closeInCarCount/(closeBerthNum<1?1:closeBerthNum)).toFixed(2));
                    $("#openTurnRatioCount").text((openInCarCount/(openBerthNum<1?1:openBerthNum)).toFixed(2)); 
		   // console.log(allUseRatio);
                    // console.log(count);
                    // console.log(closeUseRatio);
                    // console.log(closeCount);
                    // console.log(openUseRatio);
                    // console.log(openCount);

                    if(count==0){
                        $("#allUseRatio").text(allUseRatio.toFixed(2));
                    }else{
                        $("#allUseRatio").text((allUseRatio/count).toFixed(2));
                    }
                    if(closeCount==0){
                        $("#closeUseRatio").text(closeUseRatio.toFixed(2));
                    }else{
                        $("#closeUseRatio").text((closeUseRatio/closeCount).toFixed(2));
                    }
                    if(openCount==0){
                        $("#openUseRatio").text(openUseRatio.toFixed(2));
                    }else{
                        $("#openUseRatio").text((openUseRatio/openCount).toFixed(2));
                    }






                }
            }
        };
        sysAjax(opt);

    },

};
fun.init();
/**
 * 默认table 函数
 * 自定义table AJAX请求
 * @param {Object} params
 */
function incomeparktableLoadRequest(params) {
    var req = fun.incomeparkgetQueryParam();

    //设置请求参数
    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.queryCarFlowByDayForListForPage(),
        data: JSON.stringify(req),
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        success: function (res) {
            console.log(res);
            if (res.code == '8888') {
                params.success(res.data);
            }
        }
    };
    sysAjax(opt);
}



function plTypeFormatter(value){
    if(1==parseInt(value)){
        return "路侧"
    }else if(2==parseInt(value)){
        return "封闭"
    }else{
        return "未知"
    }
}
function turnOverFormatter(value){
    if(value==null || value==undefined || value=="0"){
        return "0";
    }else{
        return value.toFixed(2);
    }
}
function freeRatioFormatter(value){
    var useRatio=(1-value)*100;
    if(parseInt(useRatio)<=0){
        return "0%"
    }else if(parseInt(useRatio)>0 && parseInt(useRatio)<100){
        return useRatio.toFixed(2)+"%";
    }else{
        return "100%"
    }
}


//点击搜索
documentBindFunc.on('click', '#incomepark-billQueryBnt', function () {
    fun.ltsrcreateTableData();
    fun.carFlowQueryData();
});



//车流量打印
$(document).on('click','#carFlowPrint',function(){
    //;

    var data = fn.getParkLot();
    var orgName="";
    var plNos = [];
    for (var i = 0; i < data.length; i++) {
        plNos.push(data[i].code);
        orgName=data[i].orgName;
    }
    if (plNos.length < 1) {
        plNos.push("-1X");
    }
    /*开始时间*/
    var beginTime;
    /*结束时间*/
    var endTime;

    var  timeType=$("#timeType").val();

    if(timeType==1){
        var reportDate=$("#incomepark-daydaterange-btnsta").val();
        $("#carFlowTitle").text("日");
        $("#carFlowTitleTime").text(reportDate);
        beginTime=reportDate+" 00:00:00";
        endTime=reportDate+" 23:59:59";
    }else if(timeType==3){
        var reportDate=$("#incomepark-weekdaterange-btnsta").attr('data-text');
        $("#carFlowTitle").text("周");
        $("#carFlowTitleTime").text(reportDate);
        beginTime=reportDate.substring(0,10)+" 00:00:00";
        endTime=reportDate.substring(11,reportDate.length)+" 23:59:59";
    }else if(timeType==2){
        var reportDate=$("#incomepark-monthdaterange-btnsta").val();
        $("#carFlowTitle").text("月");
        $("#carFlowTitleTime").text(reportDate);
        beginTime = reportDate + "-01 00:00:00";
        var dates = reportDate.split("-");
        if (dates[1] == '02') {
            endTime = reportDate + "-28 23:59:59";
        } else if (dates[1] == '01' || dates[1] == '03' || dates[1] == '05' || dates[1] == '07'
            || dates[1] == '08' || dates[1] == '10' || dates[1] == '12') {
            endTime = reportDate + "-31 23:59:59";
        } else {
            endTime = reportDate + "-30 23:59:59";
        }
    }



    var orgId=fn.getOrgId();
    //var orgName="中兴智能";
    var userName=fn.getUserName();
    var url = dataUrl.util.carFlowPrint();
    var openUrl = "";//弹出窗口的url
    var iWidth=800; //弹出窗口的宽度;
    var iHeight=800; //弹出窗口的高度;
    var iTop = (window.screen.availHeight-80-iHeight)/2; //获得窗口的垂直位置;
    var iLeft = (window.screen.availWidth-10-iWidth)/2; //获得窗口的水平位置;
    var win= window.open('',"","height="+iHeight+", width="+iWidth+", top="+iTop+", left="+iLeft+",location=no,resizable=no");

    var html="<html><head></head><body><form action='"+url+"' method='get' id='printForm' accept-charset='UTF-8'>";
    html+="<input type='hidden' name='beginTime' value='"+beginTime+"'/>";
    html+="<input type='hidden' name='endTime' value='"+endTime+"'/>";
    html+="<input type='hidden' name='timeType' value='"+timeType+"'/>";
    html+="<input type='hidden' name='orgId' value='"+orgId+"'/>";
    html+="<input type='hidden' name='orgName' value='"+orgName+"'/>";
    html+="<input type='hidden' name='userName' value='"+userName+"'/>";
    html+="<input type='hidden' name='plNos' value='"+plNos+"'/>";
    html+="</form>";
    html += "</form><script type='text/javascript'>document.getElementById('printForm').submit();";
    html += "<\/script></body></html>".toString().replace(/^.+?\*|\\(?=\/)|\*.+?$/gi, "");

    win.document.write(html);



    return false;

});