$("#helper").click(function () {
    toHelper("#dyrrd");
});
$("#interval").val("月份");
//初始化所有数据
var staticData, picHeight;
var allData = [];
//初始化容忍度计数
var standI = 0;
var unstandI = 0;
var standF = 0;
var unstandF = 0;
var total = 0;
var causeImage, typeImage;
var volLength = 0;
var loadTypeLength = 0;
var $cause = $("#cause");
var $causeTable = $("#causeTable");
var $type = $("#type");
var $typeTable = $("#typeTable");
var $eventTable = $("#eventTable");
var $tolerance = $("#tolerance");
var $area=$("#area");
var $startTime = $("#startTime");
var $endTime = $("#endTime");

/**
 * 绘制暂降原因饼图
 * */
function initCause(reasons) {
    var height = picHeight * 0.5-30;

    $("#cause").css("height",height);
    var reaArray = [];
    var valueArray = [];
    if (null === reasons) {
        reaArray = ['组合暂降', '变压器激磁', '短路故障', '大型感应电动机启动', '未明'];
        valueArray = [{name: '组合暂降', value: 0}, {name: '变压器激磁', value: 0}, {
            name: '短路故障',
            value: 0
        }, {name: '大型感应电动机启动', value: 0}, {name: '未明', value: 0}];
    } else {
        reasons.reverse();
        for (var i = 0; i < reasons.length; i++) {
            reaArray.push(reasons[i].reason);
            var causeValue = {};
            causeValue.name = reasons[i].reason;
            causeValue.value = reasons[i].times;
            valueArray.push(causeValue)
        }
    }
    var option = {
        backgroundColor: '#F9F9F9',
        animation: false,
        title: {
            text: '暂降原因',
            x: 'center'
        },
        tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        legend: {
            orient: 'vertical',
            left: 'left',
            data: reaArray
        },
        series: [
            {
                name: '暂降原因',
                type: 'pie',
                radius: '70%',
                center: ['50%', '53%'],
                label: {
                    normal: {
                        show: false
                    },
                    emphasis: {
                        show: true
                    }
                },
                lableLine: {
                    normal: {
                        show: false
                    },
                    emphasis: {
                        show: true
                    }
                },
                data: valueArray,
                itemStyle: {
                    emphasis: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };
    echarts.dispose($cause[0]);
    var cause = echarts.init($cause[0]);
    cause.setOption(option);
    causeImage = cause.getDataURL();
}


/**
 * 暂降原因表格
 * */
function initCauseTable(reasons) {
    var height = picHeight * 0.5 - 60;
    if (reasons == null) {
        reasons = [];
    } else {
        //计算总计
        var reason = '总计';
        var times = 0;
        for (var i = 0; i < reasons.length; i++) {
            times = reasons[i].times + times;
        }
        var reasonPojo = {};
        reasonPojo.reason = reason;
        reasonPojo.times = times;
        reasons.push(reasonPojo);
        reasons.reverse();
    }
    $causeTable.eq(0).DataTable({
        data: reasons,
        autoWidth: false,
        columnDefs: [
            {"width": "50%", "targets": 0},
            {"width": "50%", "targets": 1},
            {
                orderable: false,
                targets: [0]
            }
        ],
        order: [1, "desc"],
        paging: false,
        lengthChange: false,
        searching: false,
        destroy: true,
        scrollY: height,
        info: false,
        pageLength: 100,
        language: {
            url: '/pqs9200/json/chine.json'
        },
        columns: [
            {data: 'reason'},
            {data: 'times'}
        ]
    })
}


/**
 * 绘制暂降类型饼图
 * */
function initType(types) {
    var height = picHeight * 0.5 -30;

    $("#type").css("height",height);

    var typeArray = [];
    var valueArray = [];
    if (null === types) {
        typeArray = ['单相接地', '两相接地', '三相短路',  '相间故障', '未知'];
        valueArray = [{name: '单相接地', value: 0}, {name: '两相接地', value: 0}, {name: '三相短路', value: 0}, {
            name: '相间故障',
            value: 0
        }, {name: '未知', value: 0}];
    } else {
        for (var i = 0; i < types.length; i++) {
            typeArray.push(types[i].type)
            var typeValue = {};
            typeValue.name = types[i].type;
            typeValue.value = types[i].times;
            valueArray.push(typeValue)
        }
    }
    var option = {
        backgroundColor: '#F9F9F9',
        animation: false,
        title: {
            text: '暂降类型',
            x: 'center',
        },
        tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        legend: {
            orient: 'vertical',
            left: 'left',
            data: typeArray
        },
        series: [
            {
                name: '暂降类型',
                type: 'pie',
                radius: '70%',
                center: ['50%', '60%'],
                label: {
                    normal: {
                        show: false
                    },
                    emphasis: {
                        show: true
                    }
                },
                lableLine: {
                    normal: {
                        show: false
                    },
                    emphasis: {
                        show: true
                    }
                },
                data: valueArray,
                itemStyle: {
                    emphasis: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };
    echarts.dispose($type[0]);
    var type = echarts.init($type[0]);
    type.setOption(option);
    typeImage = type.getDataURL();
}


/**
 * 暂降类型表格
 * */
function initTypeTable(types) {
    var height = picHeight * 0.5 - 56;
    if (types == null) {
        types = [];
    } else {
        types.reverse();
        //计算总计
        var type = '总计';
        var times = 0;
        for (var i = 0; i < types.length; i++) {
            times = types[i].times + times;
        }
        var typePojo = {};
        typePojo.type = type;
        typePojo.times = times;
        types.push(typePojo);
        types.reverse();
    }
    $typeTable.eq(0).DataTable({
        data: types,
        autoWidth: false,
        columnDefs: [
            {"width": "50%", "targets": 0},
            {"width": "50%", "targets": 1},
            {
                orderable: false,
                targets: [0]
            }
        ],
        order: [1, "desc"],
        paging: false,
        lengthChange: false,
        searching: false,
        scrollY: height,
        destroy: true,
        info: false,
        pageLength: 100,
        language: {
            url: '/pqs9200/json/chine.json'
        },
        columns: [
            {data: 'type'},
            {data: 'times'}
        ]
    })
}


/**
 * ITIC曲线上浮动事件数量统计的表格
 * */
function initTable(i, uni) {
    var total = i.length + uni.length;
    $eventTable.eq(0).DataTable({
        data: [["事件个数", total, i.length, uni.length]],
        autoWidth: false,
        ordering: false,
        paging: false,
        lengthChange: false,
        searching: false,
        destroy: true,
        info: false,
        language: {
            url: '/pqs9200/json/chine.json'
        }
    })
}

/**
 * 绘制ITIC曲线
 * **/
function initTolerance(pointI, pointIun) {
    var termHeight = $("#term").height();
    var height = picHeight - termHeight;
    $("#tolerance").css("height", height);
    initTable(pointI, pointIun);
    var option = {
        backgroundColor: canvasBG,// 背景色,
        title: {
            text: 'ITIC曲线',
            x: 'center'
        },
        tooltip: {
            trigger: 'item',
            showDelay: 0,
            formatter: function (a) {
                var relVal = "";
                var color = a.color;
                if (color === green) {
                    relVal = '可容忍事件信息：<br/>';
                } else {
                    relVal = '不可容忍事件信息：<br/>';
                }
                if (typeof (a.value[3]) !== "undefined") {
                    relVal += ' 供电公司：' + a.value[3] + '<br/>';
                }
                if (typeof (a.value[4]) !== "undefined") {
                    relVal += '变电站：' + a.value[4] + '<br/>';
                }
                if (typeof (a.value[2]) !== "undefined") {
                    relVal += '发生时刻：' + a.value[2] + '<br/>';
                }
                relVal += '持续时间：' + a.value[0] + 's<br/>';
                relVal += '特征幅值：' + a.value[1] + '%';
                return relVal;
            }
        },
        toolbox: {
            show: true,
            feature: {
                mark: {show: true},
                dataZoom: {show: true},
                restore: {show: true},
                saveAsImage: {show: true}
            }
        },
        //控制图标在dataroom中的位置大小
        grid: {
            left: '2%',
            right: '6%',
            bottom: '3%',
            containLabel: true
        },
        legend: {
            data: ['上限', '下限', '可容忍事件', '不可容忍事件'],
            selectedMode: false,
            x: 'left'
        },
        xAxis: [{
            type: 'log',
            min: '0.001',
            max: '1000',
            splitLine: {
                show: false
            },
            name: '(时间:s)'
        }],
        yAxis: [{
            type: 'value',
            splitNumber: 10,
            minInterval: 3,
            name: '(%)'
        }],
        series: [
            {
                name: '可容忍事件',
                type: 'scatter',
                symbolSize: 8,
                symbol: 'circle',
                data: pointI
            },
            {
                name: '不可容忍事件',
                type: 'scatter',
                symbolSize: 8,
                symbol: 'circle',
                data: pointIun
            },
            {
                name: '上限',
                type: 'line',
                data: [[0.001, 200], [0.003, 140], [0.003, 120],
                    [0.5, 120], [0.5, 110], [10, 110],
                    [100, 110], [1000, 110]]
            },
            {
                name: '下限',
                type: 'line',
                data: [[0.02, 0], [0.02, 70], [0.5, 70],
                    [0.5, 80], [10, 80], [10, 90], [100, 90], [1000, 90]]
            }

        ],
        color: [green, red, ITICTop, ITICBottom]
    };
    echarts.dispose($tolerance[0]);
    var tolerance = echarts.init($tolerance[0]);
    tolerance.setOption(option);
    tolerance.on('click', function (params) {
        eConsole(params);
    });

}

/**
 * 绘制F47曲线
 * **/
function initF47(pointF, pointFun) {
    initTable(pointF, pointFun);
    var part = [];
    part[0] = [0.05, 0];
    part[1] = [0.05, 50];
    part[2] = [0.2, 50];
    part[3] = [0.2, 70];
    part[4] = [0.5, 70];
    part[5] = [0.5, 80];
    part[6] = [10, 80];
    part[7] = [10, 90];
    part[8] = [1000, 90];
    var option = {
        backgroundColor: canvasBG,//背景色,
        title: {
            text: 'SEMI F47曲线',
            x: 'center'
        },
        tooltip: {
            trigger: 'item',
            showDelay: 0,
            formatter: function (a) {
                var relVal = "";
                var color = a.color;
                if (color === green) {
                    relVal = '可容忍事件信息：<br/>';
                } else {
                    relVal = '不可容忍事件信息：<br/>';
                }
                if (typeof (a.value[3]) !== "undefined") {
                    relVal += ' 供电公司：' + a.value[3] + '<br/>';
                }
                if (typeof (a.value[4]) !== "undefined") {
                    relVal += '变电站：' + a.value[4] + '<br/>';
                }
                if (typeof (a.value[2]) !== "undefined") {
                    relVal += '发生时刻：' + a.value[2] + '<br/>';
                }
                relVal += '持续时间：' + a.value[0] + 's<br/>';
                relVal += '特征幅值：' + a.value[1] + '%';
                return relVal;
            }
        },
        toolbox: {
            show: true,
            feature: {
                mark: {show: true},
                dataZoom: {show: true},
                restore: {show: true},
                saveAsImage: {show: true}
            }
        },
        //控制图标在dataroom中的位置大小
        grid: {
            left: '2%',
            right: '6%',
            bottom: '3%',
            containLabel: true
        },
        legend: {
            data: ['分割线', '可容忍事件', '不可容忍事件'],
            selectedMode: false,
            x: 'left'
        },
        xAxis: [{
            type: 'log',
            min: '0.001',
            max: '1000',
            splitLine: {
                show: false
            },
            name: '(时间:s)'
        }],
        yAxis: [{
            type: 'value',
            splitNumber: 10,
            name: '(%)'
        }],
        series: [
            {
                name: '可容忍事件',
                type: 'scatter',
                symbolSize: 8,
                symbol: 'circle',
                data: pointF
            },
            {
                name: '不可容忍事件',
                type: 'scatter',
                symbolSize: 8,
                symbol: 'circle',
                data: pointFun
            },
            {
                name: '分割线',
                type: 'line',
                data: part
            }
        ],
        color: [green, red, ITICTop]
    };
    echarts.dispose($tolerance[0]);
    var tolerance = echarts.init($tolerance[0]);
    tolerance.setOption(option);
    tolerance.on('click', function (params) {
        eConsole(params);
    });
}

/**
 * 监听曲线图中点的点击事件，展示波形
 * */
function eConsole(param) {
    var data = param.value;
    if (typeof data[5] === 'undefined') {
        return;
    }
    if (param.type === 'click') {
        layer.open({
            type: 2,
            title: '波形分析',
            maxmin: false,
            shadeClose: true, //点击遮罩关闭层
            area: ['100%', '100%'],
            content: 'vdwaveform?eventIndex=' + data[5],
            scrollbar: false
        });
    }
}

$(function () {
    var height = $(window).height() - 270;
    $("#tolerance").css("height", height)

    //初始化电压等级列表
    $.ajax({
        url: '/pqs9200/device/voltage',
        type: 'post',
        dataType: 'json',
        success: function (data) {
            var $voltages = $("#voltages");
            $voltages.eq(0).empty();
            if (data.code === 500) {
                $voltages.eq(0).append("数据字典中没有电压等级数据");
            } else {
                volLength = data.body.length;
                $voltages.eq(0).append("电压等级：<input type='checkbox' id='allVol' checked><label for='allVol'>全选</label> ");
                for (var i = 0; i < data.body.length; i++) {
                    $voltages.eq(0).append("<input type='checkbox' class='ml20' name='vol'  id='" + data.body[i].dicName + "' value='" + data.body[i].dicName + "' checked ><label for='" + data.body[i].dicName + "'>" + data.body[i].dicName + "</label>");
                }
            }

        }
    });
    //初始化干扰源类型列表
    $.ajax({
        url: '/pqs9200/device/loadType',
        type: 'post',
        dataType: 'json',
        success: function (data) {
            var $loadTypes = $("#loadTypes");
            $loadTypes.eq(0).empty();
            if (data.code === 500) {
                $loadTypes.eq(0).append("数据字典中没有干扰源类型数据");
            } else {
                loadTypeLength = data.body.length;
                $loadTypes.eq(0).append("干扰源类型：<input type='checkbox' id='allType' checked><label for='allType'>全选</label> ");
                for (var i = 0; i < data.body.length; i++) {
                    $loadTypes.eq(0).append("<input type='checkbox' class='ml20' name='type'  id='" + data.body[i].dicName + "' value='" + data.body[i].dicName + "' checked ><label for='" + data.body[i].dicName + "'>" + data.body[i].dicName + "</label>");
                }
            }

        }
    });
    $tolerance.eq(0).css("width", $tolerance.eq(0).width() - 2);
    // 初始化图表以及表格数据
    $.ajax({
        type: "POST",
        url: "/pqs9200/user/getAreasInfo",
        dataType:'json',
        success:function (data) {
            $("#area").val(data[0].name);
            $("#area").attr("index", data[0].id);
            areaTree = $.fn.zTree.init($("#areaTree"), settingAreaTree, data);
            //初始化页面内容
            var area = $area.eq(0).attr("index");
            var startTime = $startTime.eq(0).val();
            var endTime = $endTime.eq(0).val();
            refresh(area, startTime, endTime);
        }
    })
});


//点击确定，去后台请求参数
$("#query").click(function () {
    // 初始化图表以及表格数据
    var area = $area.eq(0).attr("index");
    var startTime = $startTime.eq(0).val();
    var endTime = $endTime.eq(0).val();
    refresh(area, startTime, endTime);
});


/**
 * 获取时间范围的暂降数据
 * **/
function refresh(area,startTime, endTime) {
    picHeight = ($(window).height() - 104);
    var idea;
    $.ajax({
        type: "POST",
        url: "/pqs9200/area/getAreaStatistics",
        dataType: "json",
        data: {
            area:area,
            startTime: startTime,
            endTime: endTime
        },
        beforeSend: function () {
            idea = ityzl_SHOW_LOAD_LAYER();
        },
        success: function (data) {
            startTime = startTime.replace(/-/g, "/");
            endTime = endTime.replace(/-/g, "/");
            staticData = data;
            startQuery()
            //***********关闭loading
            ityzl_CLOSE_LOAD_LAYER(idea);
        }
    });

}


/**
 * 根据后台获取的数据，解析出ITIC/F47曲线的数据
 * */
function initLine() {
    var pointI = [];
    var pointIun = [];
    var pointF = [];
    var pointFun = [];
    if (allData !== null) {

        //电压等级获取
        var voltages = "";
        var voltageO = $("input[name='vol']:checked");
        for (var i = 0; i < voltageO.length; i++) {
            voltages = voltages + "a" + voltageO[i].value + ",";
        }

        //获取干扰源类型
        var types = "";
        var typeO = $("input[name='type']:checked");
        for (var i = 0; i < typeO.length; i++) {
            types = types + typeO[i].value + ",";
        }

        //初始化
        standI = 0;
        unstandI = 0;
        standF = 0;
        unstandF = 0;
        total = 0;

        //根据电压等级先筛选一部分
        for (var i = 0; i < allData.length; i++) {
            if (voltages.indexOf("a" + allData[i].scale) >= 0 & types.indexOf(allData[i].loadType) >= 0) {
                var point = [];
                var xx = allData[i].persistTime;
                var yy = allData[i].eventValue;
                var time = allData[i].time;
                var gdName = allData[i].gdName;
                var subName = allData[i].subName;
                var index = allData[i].eventDetailIndex;
                point = [xx, yy, time, gdName, subName, index];
                if (xx <= 0.003) {
                    var line = 0;
                    line = 230 - 30000 * xx;
                    if (yy > line) {
                        unstandI++;
                    } else {
                        standI++;
                        pointI.push({value: point});
                    }
                } else if (xx <= 0.02) {
                    if (yy > 120) {
                        unstandI++;
                        pointIun.push({value: point});
                    } else {
                        standI++;
                        pointI.push({value: point});
                    }
                } else if (xx <= 0.5) {
                    if (yy > 120 || yy < 70) {
                        unstandI++;
                        pointIun.push({value: point});
                    } else {
                        standI++;
                        pointI.push({value: point});
                    }
                } else if (xx <= 10) {
                    if (yy > 110 || yy < 80) {
                        unstandI++;
                        pointIun.push({value: point});
                    } else {
                        standI++;
                        pointI.push({value: point});
                    }
                } else {
                    if (yy > 110 || yy < 90) {
                        unstandI++;
                        pointIun.push({value: point});
                    } else {
                        standI++;
                        pointI.push({value: point});
                    }
                }

                if (xx < 0.05) {
                    standF++;
                    pointF.push({value: point});
                } else if (xx < 0.2) {
                    if (yy > 50) {
                        standF++;
                        pointF.push({value: point});
                    } else {
                        unstandF++;
                        pointFun.push({value: point});
                    }
                } else if (xx < 0.5) {
                    if (yy > 70) {
                        standF++;
                        pointF.push({value: point});
                    } else {
                        unstandF++;
                        pointFun.push({value: point});
                    }
                } else if (xx < 10) {
                    if (yy > 80) {
                        standF++;
                        pointF.push({value: point});
                    } else {
                        unstandF++;
                        pointFun.push({value: point});
                    }
                }else {
                    if (yy > 90) {
                        standF++;
                        pointF.push({value: point});
                    } else {
                        unstandF++;
                        pointFun.push({value: point});
                    }
                }
            }
        }
        total = standI + unstandI;
    }
    //根据当前曲线类型展示数据
    var line = $("input[name='lineName']:checked").val();
    if (line === "ITIC") {
        initTolerance(pointI, pointIun);
    } else {
        initF47(pointF, pointFun);
    }
}

/**
 * 切换曲线类型，重新绘制
 * */
$("input[name='lineName']").on('change', function () {
    initLine();
});


/**
 * 电压等级是否选中全部，重新绘制曲线
 * */
$("#voltages").on('change', '#allVol', function () {
    var flag = $(this).is(":checked");
    if (flag) {
        $("input[name='vol']").prop("checked", "true");
    } else {
        $("input[name='vol']").removeProp("checked");
        $("input[name='vol']:first").prop('checked', 'true');
    }
    initLine();
})

/**
 * 干扰源类型是否选中全部，重新绘制曲线
 * */
$("#loadTypes").on('change', '#allType', function () {
    var flag = $(this).is(":checked");
    if (flag) {
        $("input[name='type']").prop("checked", "true");
    } else {
        $("input[name='type']").removeProp("checked");
        $("input[name='type']:first").prop('checked', 'true');
    }
    initLine();
})


/**
 * 电压等级有变动，重新绘制曲线
 * */
$("#voltages").on('change', "input[name='vol']", function () {
    var flag = judgeVol();
    if (flag) {
        $(this).prop("checked", "true");
    }
    if ($("input[name='vol']:checked").length < volLength) {
        $("#allVol").removeProp("checked");
    } else {
        $("#allVol").prop('checked', 'true');
    }
    initLine();
})


/**
 * 干扰源类型有变动，重新绘制曲线
 * */
$("#loadTypes").on('change', "input[name='type']", function () {
    var flag = judgeType();
    if (flag) {
        $(this).prop("checked", "true");
    }
    if ($("input[name='type']:checked").length < loadTypeLength) {
        $("#allType").removeProp("checked");
    } else {
        $("#allType").prop('checked', 'true');
    }
    initLine();
})

//多选框电压等级至少选择一个
function judgeVol() {
    var flag = false;
    if ($("input[name='vol']:checked").length === 0) {
        flag = true;
    }
    return flag;
}

//多选框干扰源类型至少选择一个
function judgeType() {
    var flag = false;
    if ($("input[name='type']:checked").length === 0) {
        flag = true;
    }
    return flag;
}


//点击保存图片
$('#saveImage').on('click', function () {
    var startTime = $startTime.eq(0).val();
    var endTime = $endTime.eq(0).val();
    var cityName = $area.eq(0).val();
    var name = cityName + "：" + startTime + '到' + endTime + "的暂降分析";
    drawOnCanvas(causeImage, typeImage, name);
});

//特殊处理，表头紧缩问题--start
var it = null;

function startQuery() {
    //实时刷新时间单位为毫秒
    it = setInterval('refreshQuery()', 100);

}

/* 刷新查询 */
function refreshQuery() {
    var width = $("#typeTable").width();
    var startTime = $startTime.eq(0).val();
    var endTime = $endTime.eq(0).val();
    startTime = startTime.replace(/-/g, "/");
    endTime = endTime.replace(/-/g, "/");
    startTime=filterXSS(startTime);
    endTime=filterXSS(endTime);
    if (width > 100) {
        if (staticData.code === null) {
            return;
        }
        $(".tongjiTime").html(startTime + "-" + endTime)
        cityName = staticData.body.cityName;
        $(".tongjiArea").html(cityName);
        if (staticData.code === 500) {
            $(".tongjiCounts").html(0);
            //初始化三个图表
            if (staticData.body.detail == null || staticData.body.detail.length === 0) {
                allData = null;
            } else {
                allData = [];
                allData = staticData.body.detail;
            }
            initLine();
            initCause(staticData.body.reasons);
            initCauseTable(staticData.body.reasons);
            initType(staticData.body.types);
            initTypeTable(staticData.body.types);
        } else {
            $(".tongjiCounts").html(staticData.body.totalTimes );
            if (staticData.body.detail == null || staticData.body.detail.length === 0) {
                allData = null;
            } else {
                allData = [];
                allData = staticData.body.detail;
            }
            initLine();
            initCause(staticData.body.reasons);
            initCauseTable(staticData.body.reasons);
            initType(staticData.body.types);
            initTypeTable(staticData.body.types);
        }
        window.clearInterval(it)
    }
}

//特殊处理，表头紧缩问题--end


//点击导出报表数据
$("#exportData").on("click", function () {
    var area = $area.eq(0).attr("index");
    var name = $area.eq(0).val();
    var startTime = $startTime.eq(0).val();
    var endTime = $endTime.eq(0).val();
    var xhr = new XMLHttpRequest();
    xhr.open('post', '/pqs9200/area/downloadStatisticsData', true);
    xhr.responseType = 'blob';
    xhr.setRequestHeader('Content-Type', 'application/json;charset=utf-8');
    var commontParamter = {};
    commontParamter.area = area;
    commontParamter.startTime = startTime;
    commontParamter.endTime = endTime;
    var i = ityzl_SHOW_LOAD_LAYER();
    xhr.send(JSON.stringify(commontParamter))
    xhr.onload = function () {
        if (this.status === 200) {
            var blob = this.response;
            var a = document.createElement('a');
            var url = window.URL.createObjectURL(blob);
            a.href = url;
            //设置文件名称
            a.download = name + '暂降综合统计_' + startTime + '_' + endTime + '.xlsx';
            a.click();
            a.remove();
        }
        //***********关闭loading
        ityzl_CLOSE_LOAD_LAYER(i);
    }

})
