<%@ 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 class="col-lg-3 col-md-3">
        <div class="ibox shortcut">
            <div id="divChart1" style="width: 100%;height: 400px;"></div>
        </div>
    </div>
    <div class="col-lg-3 col-md-3">
        <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-3 col-md-3">
        <div class="ibox shortcut">
            <div id="divChart6" style="width: 100%;height: 400px;">
                <img src="<%=basePath%>/resource/images/jingcha1.png" width="100%"/>
            </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-9 col-md-9">
        <div class="ibox shortcut">
            <div id="divChart5" style="width: 100%;height: 400px;"></div>
        </div>
    </div>
    <div class="col-lg-3 col-md-3">
        <div class="ibox shortcut">
            <div id="divChart4" style="width: 100%;height: 400px;"></div>
        </div>
    </div>
</div>
<jsp:include page="../../../common/admin/body_post.jsp"></jsp:include>
<script type="text/javascript" src="<%=basePath%>/resource/plugins/echarts/echarts-liquidfill.js"></script>
</body>
<script type="text/javascript">
    var myChart1 = echarts.init(document.getElementById('divChart1'));
    option = {
        title : {
            text: '万人刑事犯罪率',
        },
        series: [{
            name: '处理率',
            type: 'liquidFill',
            data: [],
            radius: '80%'
        }]
    };
    myChart1.setOption(option);
   var fnChart1=function(){
        $.get('<%=basePath%>/admin/societySecurity/criminalrate.action').done(function (result) {
            // 填入数据
            myChart1.setOption({
                series: [{
                    data: [result.data]
                }]
            });
        })
    }
    fnChart1();
    /*//////////////////////////////////*/
    var myChart2 = echarts.init(document.getElementById('divChart2'));
    option = {
        title : {
            text: '区域立案数占比',
            subtext:''
        },
        legend: {
            orient: 'vertical',
            left: 'right',
            top:15,
            data:  []
        },
        tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b}: {c} ({d}%)"
        },
        series: [
            {
                name:'区域工伤事故占比',
                type:'pie',
                radius: ['50%', '70%'],
                avoidLabelOverlap: false,
                label: {
                    normal: {
                        show: false,
                        position: 'center'
                    },
                    emphasis: {
                        show: true,
                        textStyle: {
                            fontSize: '30',
                            fontWeight: 'bold'
                        }
                    }
                },
                labelLine: {
                    normal: {
                        show: false
                    }
                },
                data:[]
            }
        ]
    };
    myChart2.setOption(option);
    var fnMyChart2=function() {
        $.get('<%=basePath%>/admin/societySecurity/registerlegalpro.action', function (result) {
            myChart2.setOption({
                title:{
                    subtext: "最新总事故数:"+result.data.total +"起"
                },
                legend: {
                    data: result.data.names
                },
                series: [{
                    // 根据名字对应到相应的系列
                    data: result.data.list
                }]
            });
        })
    }
    fnMyChart2();
    /*///////////////////////////////////*/
    var myChart3 = echarts.init(document.getElementById('divChart3'));
    var colors = ['#5793f3', '#d14a61', '#675bba'];
    option = {
        title: {
            text: '万人犯罪率趋势',
        },
        tooltip : {
            trigger: 'axis',
            axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
            }
        },
        legend: {
            orient:'horizontal',
            left: 'right',
            itemWidth:5,
            itemHeight:5,
            top:23,
            data: ['犯罪人数(人)','犯罪率(%)']
        },
        grid: {
            left:'15%',
            top:'20%'
        },
        xAxis:  {
            type: 'category',
            data: []

        },
        yAxis: [
            {
                type: 'value',
                name: '犯罪人数(人)',
                min: 0,
                max: 100,
                position: 'left',
                axisLine: {
                    lineStyle: {
                        color: colors[1]
                    }
                }
            },
            {
                type: 'value',
                name: '犯罪率(%)',
                min: 0,
                max: 100,
                position: 'right',
                offset: 0,
                axisLine: {
                    lineStyle: {
                        color: colors[0]
                    }
                }
            }
        ],

        series: [
            {
                name: '犯罪人数(人)',
                type: 'bar',
                stack: '总量',
                label: {
                    normal: {
                        show: true,
                        position: 'insideRight'
                    }
                },
                data: []
            },
            {
                name: '犯罪率(%)',
                type: 'line',
                stack: '总量',
                label: {
                    normal: {
                        show: true,
                        position: 'insideRight'
                    }
                },
                data: []
            }
        ]
    };
    myChart3.setOption(option);
    var fnMyChart3=function() {
        $.get('<%=basePath%>/admin/societySecurity/registerlegalten.action', function (result) {
            myChart3.setOption({
                xAxis : [{
                        data : result.data.years
                }],
                series: [{
                    // 根据名字对应到相应的系列
                    data: result.data.crimeAmount
                },{
                    data: result.data.proportionAmount
                }]
            });
        })
    }
    fnMyChart3();
    /*///////////////////////////////////*/
    var myChart4 = echarts.init(document.getElementById('divChart4'));
    option = {
        title : {
            text: '刑事案件立案率',
        },
        tooltip : {
            trigger: 'axis',
            axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
            }
        },
        legend: {
            left: 'right',
            top:20,
            data:['发案数','立案数','立案率']
        },
        xAxis: [
            {
                type: 'category',
                data: [],
                axisPointer: {
                    type: 'shadow'
                }
            }
        ],
        yAxis: [
            {
                type: 'value',
                name: '发案总数',
                min: 0,
                max: 200,
                interval: 50,
                axisLabel: {
                    formatter: '{value}起'
                }
            },
            {
                type: 'value',
                name: '立案总数',
                min: 0,
                max: 200,
                interval: 50,
                axisLabel: {
                    formatter: '{value}起'
                }
            }
        ],
        series: [
            {
                name:'发案数',
                type:'bar',
                data:[]
            },
            {
                name:'立案数',
                type:'bar',
                data:[]
            },
            {
                name:'立案率',
                type:'line',
                yAxisIndex: 1,
                data:[]
            }
        ]
    };
    myChart4.setOption(option);
    var fnMyChart4=function() {
        $.get('<%=basePath%>/admin/societySecurity/criregpro.action', function (result) {
            myChart4.setOption({
                xAxis: {
                    data: result.data.years
                },
                series: [
                    // 根据名字对应到相应的系列
                    {data: result.data.criminalAmount},
                    {data: result.data.registerAmount},
                    {data: result.data.proportionAmount}
                ]
            });
        })
    }
    fnMyChart4();
    /*///////////////////////////////////*/
    var myChart5 = echarts.init(document.getElementById('divChart5'));
    var map = new BMap.Map("divChart5",{enableMapClick:false,mapType: BMAP_NORMAL_MAP});            // 创建Map实例
    map.setCurrentCity("衡水市");
    map.centerAndZoom(new BMap.Point(115.675402, 37.745191), 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,//图标缩放大小 37.745191   115.675402
                    fillColor: "blue",//填充颜色
                    fillOpacity: 0.8//填充透明度
                })
            });
            var content = "所属部门："+normalArray[i].sectorName+"<br/>电话："+ normalArray[i].phone+"<br/>"+(normalArray[i].isNormal==0?"正常":"故障");
            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: "yellow",//填充颜色
                    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/societySecurity/importantareamonitor.action',function(result){
        debugger;
        normalArray=result.data.array;
        //breakArray=result.data.break;
        fnNormal();
       // fnBreak();
    });

    var fnMyChart6=function() {
        $.get('<%=basePath%>/admin/societySecurity/policepro.action', function (result) {
            var html='<div style="font-size:40px;text-align:center;">警员配置数：<br>';
            if(result!=null){
                html+= result.data[1].name+":"+result.data[0].name+"="+result.data[1].value+":"+result.data[0].value;
                html+='</div>'
            }
            $('#divChart6').append(html);
        })
    }
    fnMyChart6();

</script>
</html>

