<%@ page import="org.apache.commons.lang.StringUtils" %>
<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String basePath = request.getContextPath();
%>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="../../../common/admin/head.jsp"></jsp:include>
    <link  rel="stylesheet" type="text/css" href="<%=basePath%>/resource/css/admin/home/index.css">

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
        body, html {width: 100%;height: 100%;margin:0;font-family:"微软雅黑";}
        #allmap{width:100%;height:500px;}
    </style>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=RleRpI1DQegNo17XGsVvUUS1e3oiubUG"></script>

</head>
<body>
    <jsp:include page="../../../common/admin/body_pre.jsp"></jsp:include>
    <div class="row hidden-print">
        <div class="col-lg-12">
            <div class="ibox">
                <div class="ibox-title">
                    <h2>城市运行监测预警</h2>
                    <ol class="breadcrumb">
                        <li>
                            <a href="javascript:void(0);" >运行分析</a>
                        </li>
                        <li class="active">
                            <strong>通信运行</strong>
                        </li>
                    </ol>
                </div>
            </div>
        </div>
    </div>
    <%--////////////////--%>
    <div class="row hidden-print">
        <div style="position: absolute;z-index: 999; font-weight: bold;font-size: 20px;background: #fff;left:26px">视频监控</div>
        <div class="col-lg-12 col-md-12" style="position: relative;">
            <div class="ibox shortcut">
                <div id="divChart1" style="width: 100%;height: 400px;"></div>
            </div>
        </div>
    </div>
    <div class="row hidden-print">
        <div class="col-lg-9 col-md-9">
            <div class="ibox shortcut">
                <div id="divChart2" style="width: 100%;height: 400px;"></div>
            </div>
        </div>
        <div class="col-lg-3 col-md-3">
            <div class="ibox shortcut">
                <div id="divChart3" style="width: 100%;height: 400px;"></div>
            </div>
        </div>
        <div class="col-lg-6 col-md-6">
            <div class="ibox shortcut">
                <div id="divChart4" style="width: 100%;height: 400px;"></div>
            </div>
        </div>
        <div class="col-lg-6 col-md-6">
            <div class="ibox shortcut">
                <div id="divChart5" style="width: 100%;height: 400px;"></div>
            </div>
        </div>
    </div>
    <jsp:include page="../../../common/admin/body_post.jsp"></jsp:include>
</body>
    <script type="text/javascript">
        var myChart1 = echarts.init(document.getElementById('divChart1'));
        var map = new BMap.Map("divChart1",{enableMapClick:false,mapType: BMAP_NORMAL_MAP});            // 创建Map实例
        map.setCurrentCity("衡水市");
        map.centerAndZoom(new BMap.Point(115.675402, 37.745191), 15);
        //var point = new BMap.Point(115.675402, 37.745191); // 创建点坐标
        //map.centerAndZoom(point,15);
        map.enableScrollWheelZoom();                 //启用滚轮放大缩小


        // 自定义一个控件类
        function ZoomControl(){
            // 默认停靠位置和偏移量
            this.defaultAnchor = BMAP_ANCHOR_TOP_RIGHT;
            this.defaultOffset = new BMap.Size(10, 5);
        }
        // 通过JavaScript的prototype属性继承于BMap.Control
        ZoomControl.prototype = new BMap.Control();
        // 自定义控件必须实现自己的initialize方法,并且将控件的DOM元素返回
        // 在本方法中创建个div元素作为控件的容器,并将其添加到地图容器中
        ZoomControl.prototype.initialize = function(map){
            // 创建一个DOM元素
            var div = document.createElement("div");
            // 添加文字说明
            div.innerHTML+="<a onclick='fnShowNormal()' style='background: green;color: #fff';text:>&nbsp;正&nbsp;&nbsp;常&nbsp;</a><a style='background: red;color: #fff' onclick='fnShowBreak()'>&nbsp;故&nbsp;&nbsp;障&nbsp;</a>";
            // 设置样式
            div.style.cursor = "pointer";
            div.style.border = "1px solid";
            // 添加DOM元素到地图中
            map.getContainer().appendChild(div);
            // 将DOM元素返回
            return div;
        }
        // 创建控件
        var myZoomCtrl = new ZoomControl();
        // 添加到地图当中
        map.addControl(myZoomCtrl);

        /*/////////////////////////////////////////////////////////*/
        // 编写自定义函数,创建标注
        function addMarker(point){
            var marker = new BMap.Marker(point);
            map.addOverlay(marker);
        }
        //添加信息窗口
        var opts = {
            width : 250,     // 信息窗口宽度
            height: 80,     // 信息窗口高度
            title : "详细信息" , // 信息窗口标题
        };
        //添加点击事件监听器
        function addClickHandler(content,marker){
            marker.addEventListener("click",function(e){
                openInfo(content,e)}
            );
        }
        function openInfo(content,e){
            var p = e.target;
            var infoPoint = new BMap.Point(p.getPosition().lng, p.getPosition().lat);
            var infoWindow = new BMap.InfoWindow(content,opts);  // 创建信息窗口对象
            map.openInfoWindow(infoWindow,infoPoint); //开启信息窗口
        }
        //正常
        function fnNormal() {
            for (var i = 0; i < normalArray.length; i++) {
                var vectorMarker = new BMap.Marker(new BMap.Point(normalArray[i].lng,normalArray[i].lat),{
                    // 指定Marker的icon属性为Symbol
                    icon: new BMap.Symbol(BMap_Symbol_SHAPE_POINT, {
                        scale: 1,//图标缩放大小
                        fillColor: "green",//填充颜色
                        fillOpacity: 0.8//填充透明度
                    })
                });
                var content = "所属部门："+normalArray[i].sectorName+"<br/>电话："+ normalArray[i].phone;
                map.addOverlay(vectorMarker);
                addClickHandler(content,vectorMarker);
            }
            vectorMarker.show();
        }
        //故障
        function fnBreak() {
            for (var j = 0; j <breakArray.length; j++) {
                var vectorMarker = new BMap.Marker(new BMap.Point(breakArray[j].lng,breakArray[j].lat),{
                    // 指定Marker的icon属性为Symbol
                    icon: new BMap.Symbol(BMap_Symbol_SHAPE_POINT, {
                        scale: 1,//图标缩放大小
                        fillColor: "red",//填充颜色
                        fillOpacity: 0.8//填充透明度
                    })
                });
                var content = "所属部门："+breakArray[j].sectorName+"<br/>电话："+ breakArray[j].phone;
                map.addOverlay(vectorMarker);
                addClickHandler(content,vectorMarker);
            }
            vectorMarker.show();
        }
        //只显示正常
        function fnShowNormal(){
            map.clearOverlays();
            fnNormal();
        }
        //只显示故障
        function fnShowBreak(){
            map.clearOverlays();
            fnBreak();
        }
        $.get('<%=basePath%>/admin/commu/videomonitor.action',function(result){
             normalArray=result.data.normal;
            breakArray=result.data.break;
            fnNormal();
            fnBreak();
        });
        /*////////////////////////////*/
        var myChart2 = echarts.init(document.getElementById('divChart2'));
        option = {
            title: {
                text: '数字电视与WIFI',
                subtext:''
            },
            backgroundColor:'#fff',
            legend:{left:'right',data:['数字电视','WIFI']},
            xAxis: [{
                type: 'value',
                min:-70,max:0,interval:30,
                gridIndex: 0,
                axisTick:{inside:false},
                axisLabel : {
                    formatter: function(v){
                        return -v;
                    }
                }
            },{
                type: 'value',
                gridIndex: 1, min:0,max:70,interval:30,
                axisTick:{inside:false},
                axisLabel : {
                    formatter: function(v){
                        return v;
                    }
                }
            }],
            yAxis: [{
                type: 'category',gridIndex: 0,
                data: [],
                axisTick:{inside:true},
                axisLabel : {show:false}
            },{
                type: 'category',gridIndex: 1,
                data: [],
            }],
            grid: [{
                top: 10,
                width: '40%',
                left: 45,gridIndex: 0,
            }, {
                top: 10,
                width: '40%',
                left: '50%',gridIndex: 1,
            }],
            color:['#2FACFA','#F5A623'],
            series: [
                {
                    name: '数字电视',
                    type: 'bar',
                    barWidth:'10',gridIndex: 0,
                    label:{
                        show:true,position:'left',
                        formatter:function(v){
                            return -v.value;
                        }
                    },
                    data:[]
                },
                {
                    name: 'WIFI',
                    type: 'bar',
                    barWidth:'10',
                    xAxisIndex: 1,
                    yAxisIndex: 1,
                    label:{
                        show:true,position:'right',
                        formatter:function(v){
                            return v.value;
                        }
                    },
                    data: []
                }

            ]
        };
        myChart2.setOption(option);
        var fnMyChart2=function(){
            $.get('<%=basePath%>/admin/commu/tvandwifi.action', function (result) {
                var tvdata=new Array();
                var oriData = result.data.tvAmount;
                var len = oriData.length;
                for(var i=0;i<len;i++) {
                    tvdata.push(oriData[i] *= -1);
                }

                myChart2.setOption({
                    legend: {
                        data: result.data.names
                    },
                    yAxis: [{
                        data: result.data.areas
                    },{
                        data: result.data.areas
                    }],
                    series: [
                        // 根据名字对应到相应的系列
                        {data: tvdata},
                        {data: result.data.wifiAmount}
                    ]
                });
            })
        }
        fnMyChart2();
        /*////////////////////////////*/
        var myChart3 = echarts.init(document.getElementById('divChart3'));
        option = {
            title:{
                text:'通信故障',
                subtext: '',
            },
            tooltip: {},
            legend: {
                orient: 'vertical',
                right: 10,
                top: 10,
                data:['故障数量','同比']
            },
            xAxis: [
                {
                    type: 'category',
                    data: [],
                    axisPointer: {
                        type: 'shadow'
                    }
                }
            ],
            yAxis: [
                {
                    type: 'value'

                },
                {
                    type: 'value',
                    axisLabel: {
                        formatter: '{value}%'
                    }

                }
            ],
            series: [
                {
                    name:'故障数量',
                    type:'bar',
                    data:[]
                },
                {
                    name:'同比',
                    type:'line',
                    yAxisIndex: 1,
                    data:[]
                }
            ]
        };
        myChart3.setOption(option);
        var fnMyChart3=function(){
            $.get('<%=basePath%>/admin/commu/areacommbreak.action', function (result) {
                myChart3.setOption({
                    title: {
                        subtext: "故障量:"+result.data.total+"起  同比数据值:"+result.data.newGrowth+"%"
                    },
                    xAxis: {
                        data: result.data.years
                    },
                    series: [
                        // 根据名字对应到相应的系列
                        {data: result.data.amount},
                        {data: result.data.growth}
                    ]
                });
            })
        }
        fnMyChart3();
        /*////////////////////////////*/
        var myChart4 = echarts.init(document.getElementById('divChart4'));
        option = {
            title : {
                text: '故障占比',
                subtext:'单位:%'
            },
            tooltip : {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c} ({d}%)"
            },
            legend: {
                orient: 'vertical',
                left: 'right',
                top:15,
                data: []
            },
            series : [
                {
                    name: '访问来源',
                    type: 'pie',
                    radius : '55%',
                    center: ['50%', '60%'],
                    data:[],
                    itemStyle: {
                        emphasis: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                }
            ]
        };
        myChart4.setOption(option);
        var fnMyChart4=function(){
            $.get('<%=basePath%>/admin/commu/areacommbreakprop.action', function (result) {
                myChart4.setOption({
                    legend: {
                        data:result.data.name
                    },
                    series: [{
                        // 根据名字对应到相应的系列
                        data: result.data.list
                    }]
                });
            })
        }
        fnMyChart4();
        /*////////////////////////////*/
        var myChart5 = echarts.init(document.getElementById('divChart5'));
        option = {
            title:{
                text:'光纤长度',
                subtext: '',
            },
            tooltip: {},
            legend: {
                orient: 'vertical',
                right: 10,
                top: 10,
                data:['长度','同比']
            },
            grid: {
                left: '1%',
                right: '1%',
                bottom: '2%',
                containLabel: true
            },
            xAxis: [
                {
                    type: 'category',
                    data: [],
                    axisPointer: {
                        type: 'shadow'
                    }
                }
            ],
            yAxis: [
                {
                    type: 'value',
                    axisLabel: {
                        formatter: '{value}km'
                    }
                },
                {
                    type: 'value',
                    axisLabel: {
                        formatter: '{value}%'
                    }
                }
            ],
            series: [
                {
                    name:'长度',
                    type:'bar',
                    data:[]
                },
                {
                    name:'同比',
                    type:'line',
                    yAxisIndex: 1,
                    data:[]
                }
            ]
        };
        myChart5.setOption(option);
        var fnMyChart5=function(){
            $.get('<%=basePath%>/admin/commu/fiber.action', function (result) {
                myChart5.setOption({
                    title: {
                        subtext: "总长度:"+result.data.total+"km   同比数据值:"+result.data.newGrowth+"%"
                    },
                    xAxis: {
                        data: result.data.years
                    },
                    series: [
                        // 根据名字对应到相应的系列
                        {data: result.data.amount},
                        {data: result.data.growth}
                    ]
                });
            })
        }
        fnMyChart5();
        /*////////////////////////////*/
    </script>
</html>
