/** * Created by mac on 18/4/10. */ //时间初始化 /*进场时间筛选框*/ $('#incomeprofile-dateTime input').val(moment().subtract('days', 0).format('YYYY-MM-DD') + ' - ' + moment().subtract('days', 0).format('YYYY-MM-DD')); $('#incomeprofile-dateTime').daterangepicker({ // timePicker: true, // timePickerIncrement: 20, // minDate: moment().subtract('months', 2), startDate: moment().subtract('days', 0), endDate: moment().subtract('days', 0), opens: 'left', //日期选择框的弹出位置 // dateLimit : { // days : 6 // }, locale: { applyLabel: '确定', cancelLabel: '取消', customRangeLabel: '自定义', daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'], monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'], // format: 'MM/DD/YYYY HH:mm:ss' }, ranges: { '今天': [moment().subtract('days', 0), moment().subtract('days', 0)], '昨天': [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', 2), moment().subtract('days', 1)], }, maxDate: moment().subtract('days', 0), //最大时间 }, function (start, end) { $('#incomeprofile-dateTime input').val(start.format('YYYY-MM-DD') + ' - ' + end.format('YYYY-MM-DD')); //选择日期触发查询 fun.queryIncomeStatisticForPayType(plNos); fun.queryIncomeStatistic(plNos); } ); //地图 部分 var map; //Map实例 var clear_flag = false; //收益-按收益程度计数 var incomeArray = [0, 0, 0, 0, 0]; //数据 mapData = []; var mapFun = { init: function () { map = new BMap.Map("allmap", {enableMapClick: false}); //设置地图中心点,当前城市 var point = new BMap.Point(mapData[0].lat, mapData[0].lot); //初始化地图,设置中心点坐标和地图级别。 map.centerAndZoom(point, 13); //启用滚轮放大缩小 map.enableScrollWheelZoom(true); //检测浏览器兼容 if (typeof(Worker) === "undefined") { if (navigator.userAgent.indexOf("MSIE 9.0") <= 0) { alert("定制个性地图示例:IE9以下不兼容,推荐使用百度浏览器、chrome、firefox、safari、IE10"); } } mapFun.drawMarker(mapData); incomeStatic(); }, // drawMarker: function (mapData) { //清除以前的点位 map.clearOverlays(); //第7步:绘制点 var marker = []; var poilat = null;//坐标 var poilot = null; var parkNo = null;//编号 var popAllnum = null;//总计 var popltnum = null;//临停 var popvipnum = null;//会员卡 var popbjnum = null;//补缴 var popalinum = null;//支付宝 var popwxnum = null;//微信 var popxjnum = null;//现金 var popyynum = null;//余额 var plname = null;//停车场名称 incomeArray = [0, 0, 0, 0, 0]; for (var i = 0; i < mapData.length; i++) { console.log(mapData) poilat = mapData[i].lat; poilot = mapData[i].lot; parkNo = mapData[i].parkNo; popAllnum = (mapData[i].allnum == undefined || mapData[i].allnum == null)?0:mapData[i].allnum; popltnum = mapData[i].ltnum; popvipnum = mapData[i].vipnum; popbjnum = mapData[i].bjnum; popalinum = mapData[i].alinum; popwxnum = mapData[i].wxnum; popxjnum = mapData[i].xjnum; popyynum = mapData[i].yynum; plname = mapData[i].plname; var point = new BMap.Point(poilat, poilot); incomeArray[4]++; if (popAllnum > 1000) { incomeArray[3]++; var myIcon = new BMap.Icon("../../assets/pages/img/mmap/its-park1.png", new BMap.Size(30, 40), { offset: new BMap.Size(10, 40), textColor: '#fff' }); marker[i] = new BMap.Marker(point, {icon: myIcon}); map.addOverlay(marker[i]); } else if (popAllnum > 500 && popAllnum <= 1000) { incomeArray[2]++; var myIcon2 = new BMap.Icon("../../assets/pages/img/mmap/its-park2.png", new BMap.Size(30, 40), { offset: new BMap.Size(10, 40), textColor: '#fff' }); marker[i] = new BMap.Marker(point, {icon: myIcon2}); map.addOverlay(marker[i]); } else if (popAllnum > 100 && popAllnum <= 500) { incomeArray[1]++; var myIcon3 = new BMap.Icon("../../assets/pages/img/mmap/its-park3.png", new BMap.Size(30, 40), { offset: new BMap.Size(10, 40), textColor: '#fff' }); marker[i] = new BMap.Marker(point, {icon: myIcon3}); map.addOverlay(marker[i]); } else if (popAllnum <= 100 || popAllnum == undefined || popAllnum == "" || popAllnum == null) { incomeArray[0]++; var myIcon4 = new BMap.Icon("../../assets/pages/img/mmap/its-park4.png", new BMap.Size(30, 40), { offset: new BMap.Size(10, 40), textColor: '#fff' }); marker[i] = new BMap.Marker(point, {icon: myIcon4}); map.addOverlay(marker[i]); } //debugger; marker[i].poilat = mapData[i].lat; marker[i].poilot = mapData[i].lot; marker[i].parkNo = mapData[i].parkNo; marker[i].popAllnum = mapData[i].allnum; marker[i].popltnum = mapData[i].ltnum; marker[i].popvipnum = mapData[i].vipnum; marker[i].popbjnum = mapData[i].bjnum; marker[i].popalinum = mapData[i].alinum; marker[i].popwxnum = mapData[i].wxnum; marker[i].popxjnum = mapData[i].xjnum; marker[i].popyynum = mapData[i].yynum; marker[i].plname = mapData[i].plname; marker[i].addEventListener("mouseover", function (n) { var poilat = n.target.poilat; var parkNo = n.target.parkNo; var plname = n.target.plname; var poilot = n.target.poilot; var popAllnum = Number(n.target.popAllnum); var popltnum = Number(n.target.popltnum); var popvipnum = Number(n.target.popvipnum); var popbjnum = Number(n.target.popbjnum); var popalinum = Number(n.target.popalinum); var popwxnum = Number(n.target.popwxnum); var popxjnum = Number(n.target.popxjnum); var popyynum = Number(n.target.popyynum); addInfoWindow(poilat, parkNo, plname, poilot, popAllnum, popltnum, popvipnum, popbjnum,popalinum,popwxnum,popxjnum,popyynum); }); marker[i].addEventListener("mouseout", function () { closeInfoWindow(); }) } removeCluster(marker); } }; //mapFun.init(); //占用率统计条 function incomeStatic() { var t1 = (incomeArray[0] * 100 / incomeArray[4]).toFixed(2); var t2 = (incomeArray[1] * 100 / incomeArray[4]).toFixed(2); var t3 = (incomeArray[2] * 100 / incomeArray[4]).toFixed(2); // var t4=(incomeArray[3]*100/incomeArray[4]).toFixed(2); var t4 = (100 - t1 - t2 - t3).toFixed(2); $(".incomeprofile-per-main").find('li').eq(0).css("width", t1 + '%'); $(".incomeprofile-per-main").find('li').eq(1).css("width", t2 + '%'); $(".incomeprofile-per-main").find('li').eq(2).css("width", t3 + '%'); $(".incomeprofile-per-main").find('li').eq(3).css("width", t4 + '%'); $(".incomeprofile-per-area").find('span').eq(1).html(t1 + '%'); $(".incomeprofile-per-area").find('span').eq(3).html(t2 + '%'); $(".incomeprofile-per-area").find('span').eq(5).html(t3 + '%'); $(".incomeprofile-per-area").find('span').eq(7).html(t4 + '%'); }; function removeCluster(marker) { if (clear_flag) { markerClusterer.clearMarkers(); //此步骤需要 } markerClusterer = new BMapLib.MarkerClusterer(map, { markers: marker, styles: [{ url: '../../assets/pages/img/mmap/parkicon_culter.png', size: new BMap.Size(53, 52), zIndex: 0 }], }); markerClusterer.setMaxZoom(13); clear_flag = true; } //close pop弹窗 function closeInfoWindow() { $(".pop_models").css('display', 'none'); } //停车场信息弹窗 function addInfoWindow(poilat, parkNo, plname, poilot, popAllnum, popltnum, popvipnum, popbjnum,popalinum,popwxnum,popxjnum,popyynum) { $('.BMapLabel').empty(); var parkNo = parkNo; var poilat = poilat; var poilot = poilot; var plname = plname; var popAllnum = popAllnum; var popltnum = popltnum; var popvipnum = popvipnum; var popbjnum = popbjnum; var popalinum = popalinum; var popwxnum = popwxnum; var popxjnum = popxjnum; var popyynum = popyynum; var point = new BMap.Point(poilat, poilot); var myLabel = new BMap.Label('
' + '
' + plname + '
' + '
总计:' + popAllnum + '
' + '
临停:' + popltnum + '
' + '
会员卡:' + popvipnum + '
' + '
补缴:' + popbjnum + '
' + '
支付方式:
' + '
支付宝:' + popalinum + '
' + '
微信:' + popwxnum + '
' + '
现金:' + popxjnum + '
' + '
余额:' + popyynum + '
' + '
', { offset: new BMap.Size(30, -85), //label的偏移量,为了让label的中心显示在点上 position: point }); myLabel.setStyle({ color: "#F0F0F0", fontSize: "12px", padding: "5px", whiteSpace: "normal", backgroundColor: "rgba(0, 0, 0, 0)", border: "0px", zIndex: "1000" } ); map.addOverlay(myLabel); $('.pop_models').parent().parent().css('z-index', 99999999) } function drawPie(id, color, subtext, text, seriesData, seriesName) { var chart = echarts.init(document.getElementById(id)); chart.setOption( { color: [color, '#D7D7D7'], title: { subtext: text, text: subtext, textStyle: { color: 'rgba(0,0,0,0.5)', fontSize: '12', align: 'middle', verticalAlign: 'middle', }, subtextStyle: { color: '#000', fontSize: '18', align: 'middle', verticalAlign: 'middle', }, left: 'center', top: '50', }, tooltip: { trigger: 'item', show: false, formatter: "{a}
{b}: {c} ({d}%)" }, series: [ { name: seriesName, hoverAnimation: false, legendHoverLink: false, type: 'pie', hoverOffset: 5, selectedOffset: 3, radius: ['78%', '88%'], avoidLabelOverlap: false, label: { normal: { show: false, position: 'center' }, emphasis: { show: false, textStyle: { fontSize: '30', fontWeight: 'bold' } } }, labelLine: { normal: { show: false } }, data: seriesData } ] } ); }; //停车场实时收入 function queryParkRealTimeListByPlNos(plNos) { var result = []; var req = { sysCode: sysComm.sysCode, plNos: plNos, }; var realTimeAjax = { method: "post", url: dataUrl.util.queryParkRealTimeListByPlNos(), data: JSON.stringify(req), contentType: 'application/json; charset=utf-8', dataType: 'json', async: false, success: function (res) { if (res.code == '8888') { var data = res.data; result = data; } else { console.log(res); } } }; sysAjax(realTimeAjax); return result; }; //停车场实时收入 function queryParkRealTimeDatasByPlNos(plNos) { var result = []; var req = { sysCode: sysComm.sysCode, plNos: plNos, }; var realTimeAjax = { method: "post", url: dataUrl.util.queryParkRealTimeDatasByPlNos(), data: JSON.stringify(req), contentType: 'application/json; charset=utf-8', dataType: 'json', async: false, success: function (res) { if (res.code == '8888') { var data = res.data; result = data; } else { console.log(res); } } }; sysAjax(realTimeAjax); return result; }; //得到map function queryPlMap() { var map = {}; var data = fn.getParkLot(); $.each(data, function (index, item) { map[item.code]= item.name; }); return map; } var chart = echarts.init(document.getElementById('tytj-echarts')); var option = { series: [{ type: 'liquidFill', color: ['#63BBFF'], radius: '60%', data: [0.4], outline: { show: true, borderDistance: 5, itemStyle: { color: 'none', borderColor: '#38A2FF', borderWidth: 5, shadowBlur: 0, shadowColor: 'rgba(255, 255, 255, 0)' } }, backgroundStyle: { color: '#fff' }, label: { normal: { formatter: '', textStyle: { fontSize: 98 } } } // label: { // // normal: { // // formatter: '{a}\n{b}\nValue: {c}', // textStyle: { // color: 'red', // insideColor: 'yellow', // fontSize: 50 // } // } // }, }] }; var plNos = []; chart.setOption(option); var fun = { //时间处理 datetimeFormatter: function (value, row, index) { if (value == null) { return ""; } else { return DateUtils.long2String(value, 7); } }, getQueryParams: function () { var times = ($('#incomeprofile-dateTime input').val()).split(" - "); var beginTime = times[0] + " 00:00:00"; var endTime = times[1] + " 23:59:59"; beginTime = new Date(beginTime.replace(new RegExp(/-/gm), "/")); endTime = new Date(endTime.replace(new RegExp(/-/gm), "/")); var req = { baseRequest: { pageNum: 1, pageSize: 0 }, plNos: plNos, beginTime: beginTime, endTime: endTime, sysCode: sysComm.sysCode }; return req; }, initPark: function () { var data = fn.getParkLot(); mapData = []; for (var i = 0; i < data.length; i++) { plNos.push(data[i].code); //填充mapData var mapItem = { parkNo: "", plname: "", lat: "0", lot: "0", allnum: "0", ltnum: "0", vipnum: "0", bjnum: "0" }; mapItem.parkNo = data[i].code; mapItem.plname = data[i].name; mapItem.lat = data[i].lonId; mapItem.lot = data[i].latId; mapData.push(mapItem); } }, drawParkIncomeDatas: function (data) { var allIncomeFee = 0; var vipIncomeFee = 0; var backIncomeFee = 0; var tempIncomeFee = 0; if (data.length > 0) { $.each(data, function (index, item) { allIncomeFee += item.allIncomeFee; vipIncomeFee += item.vipIncomeFee; backIncomeFee += item.backIncomeFee; }); } tempIncomeFee = allIncomeFee - vipIncomeFee - backIncomeFee; $("#allIncome").html(fun.moneyFomatter(allIncomeFee)); $("#tempIncome").html(fun.moneyFomatter(tempIncomeFee)); $("#vipIncome").html(fun.moneyFomatter(vipIncomeFee)); $("#backIncome").html(fun.moneyFomatter(backIncomeFee)); }, drawParkIncomeList: function (data) { //debugger; var html = ''; var i = 1; if (data.length > 0) { //收入相同的情况下,按中文排序 data.sort(function (a, b) { if (b.allIncomeFee == a.allIncomeFee) { return (a.plName).localeCompare(b.plName, 'zh'); } else { return b.allIncomeFee - a.allIncomeFee; } }); $.each(data, function (index, item) { html += '
  • ' + (index + 1) + '' + item.plName + '' + fun.moneyFomatter(item.allIncomeFee) + '
  • '; }); } else { //按中文排序 mapData.sort(function (a, b) { return (a.plname).localeCompare(b.plname, 'zh'); }); $.each(mapData, function (index, item) { if (index < 10) { html += '
  • ' + (index + 1) + '' + item.plname + '' + fun.moneyFomatter(0) + '
  • '; } }); } $(".incomeprofile-ranking").html(html); }, drawParkIncomeMap: function (data) { //mapData初始化 $.each(mapData, function (_index, _item) { //开始填充mapData _item.allnum = fun.moneyFomatter(0); _item.ltnum = fun.moneyFomatter(0); _item.vipnum = fun.moneyFomatter(0); _item.bjnum = fun.moneyFomatter(0); _item.alinum = fun.moneyFomatter(0); _item.wxnum = fun.moneyFomatter(0); _item.xjnum = fun.moneyFomatter(0); _item.yynum = fun.moneyFomatter(0); }); if (data != null && data.length > 0) { $.each(data, function (index, item) { $.each(mapData, function (_index, _item) { //开始填充mapData if (item.plNo == _item.parkNo) { _item.allnum = fun.moneyFomatter(item.allIncomeFee); _item.ltnum = fun.moneyFomatter(item.allIncomeFee - item.vipIncomeFee - item.backIncomeFee); _item.vipnum = fun.moneyFomatter(item.vipIncomeFee); _item.bjnum = fun.moneyFomatter(item.backIncomeFee); _item.alinum = fun.moneyFomatter(item.aliFee); _item.wxnum = fun.moneyFomatter(item.wxFee); _item.xjnum = fun.moneyFomatter(item.cashFee); _item.yynum = fun.moneyFomatter(item.balanceFee); } }); }); currentLon = mapData[0].lot; currentLat = mapData[0].lat; } //加载地图 mapFun.init(); }, queryIncomeStatistic: function (plNos) { var req = fun.getQueryParams(); var endTime = moment().format('YYYY-MM-DD'); var reqEndTime = moment(req.endTime.getTime()).format('YYYY-MM-DD'); var reqStartTime = moment(req.beginTime.getTime()).format('YYYY-MM-DD'); if (reqStartTime==endTime && reqEndTime == endTime){ var map = queryPlMap(); var data = queryParkRealTimeListByPlNos(plNos) var transDatas = []; //debugger; $.each(data, function (index, item) { var transData = { /**停车场编号*/ plNo: item.plNo, /**停车场名称*/ plName: map[item.plNo], /**订单应收金额 单位:分*/ totalFee: item.parkIncome, /**订单实收金额 单位:分*/ actFee: item.parkIncome, /**欠费金额 单位:分*/ arrearageFee: item.escapeFee, /**支付宝费用*/ aliFee: item.allAliIncome, /**微信费用*/ wxFee: item.allWxIncome, /**现金费用*/ cashFee: item.allCashIncome, /**余额费用*/ balanceFee: item.allBalanceIncome, /**停车收入 **/ parkIncomeFee: item.parkIncome, /**会员卡收入 **/ vipIncomeFee: item.vipCardIncome, /**补缴收入 **/ backIncomeFee: item.backIncome, /**总的收入 **/ allIncomeFee: item.allIncome }; transDatas.push(transData); }) //停车收入概况 fun.drawParkIncomeDatas(transDatas); //停车排行榜 fun.drawParkIncomeList(transDatas); //停车收入地图数据 fun.drawParkIncomeMap(transDatas); return; } var commonAjax = { method: "post", url: dataUrl.util.queryIncomeStatistic(), async: false, data: JSON.stringify(req), contentType: 'application/json; charset=utf-8', dataType: 'json', success: function (res) { console.log(res); if (res.code == '8888') { if (res.data != null) { var data = res.data; //停车收入概况 fun.drawParkIncomeDatas(data); //停车排行榜 fun.drawParkIncomeList(data); //停车收入地图数据 fun.drawParkIncomeMap(data); } } else { console.log(res); } } }; sysAjax(commonAjax); }, drawIncomeStatisticForPayType: function (data) { var wxFee = data.wxFee; var cashFee = data.cashFee; var aliFee = data.aliFee; var actFee = data.actFee; var arrearageFee = data.arrearageFee; var aliRate = ((aliFee * 100) / (actFee < 1 ? 1 : actFee)).toFixed(0); var wxRate = ((wxFee * 100) / (actFee < 1 ? 1 : actFee)).toFixed(0); var cashRate = ((cashFee * 100) / (actFee < 1 ? 1 : actFee)).toFixed(0); var otherRate = 100 - aliRate - wxRate - cashRate; if (actFee < 1 || otherRate < 0) { otherRate = (0).toFixed(0); } var totalFee = arrearageFee + actFee; var arrearageRate = ((arrearageFee == null ? 0 : arrearageFee) / (totalFee < 1 ? 1 : totalFee)).toFixed(4); var zfbData = [ {value: Number(aliRate), name: '支付宝', selected: true}, {value: Number(100 - aliRate), name: '总计'}, ]; var zfbName = '支付宝'; drawPie('zfbMoney', '#1890FF', '支付宝', aliRate + '%', zfbData, zfbName); var wxData = [ {value: Number(wxRate), name: '微信', selected: true}, {value: Number(100 - wxRate), name: '总计'}, ]; var wxName = '微信'; drawPie('wxMoney', '#5fe98f', '微信', wxRate + '%', wxData, wxName); var xjData = [ {value: Number(cashRate), name: '现金', selected: true}, {value: Number(100 - cashRate), name: '总计'}, ]; var xjName = '现金'; drawPie('xjMoney', '#FACC14', '现金', cashRate + '%', xjData, xjName); var qtData = [ {value: Number(otherRate), name: '其他', selected: true}, {value: Number(100 - otherRate), name: '总计',}, ]; var qtName = '其他'; drawPie('qtMoney', '#37CBCB', '其他', otherRate + '%', qtData, qtName); //逃逸金额 $("#arrearageRate").html((arrearageRate * 100).toFixed(2) + '%'); option.series[0].data[0] = arrearageRate; chart.setOption(option); }, queryIncomeStatisticForPayType: function (plNos) { var req = fun.getQueryParams(); var endTime = moment().format('YYYY-MM-DD'); var reqEndTime = moment(req.endTime.getTime()).format('YYYY-MM-DD'); var reqStartTime = moment(req.beginTime.getTime()).format('YYYY-MM-DD') if (reqStartTime==endTime && reqEndTime == endTime) { var map = queryPlMap(); var item = queryParkRealTimeDatasByPlNos(plNos) console.log('item:'); console.log(JSON.stringify(item)); var transData = { /**停车场编号*/ plNo: item.plNo, /**停车场名称*/ plName: map[item.plNo], /**订单应收金额 单位:分*/ totalFee: item.allIncome + item.escapeFee, /**订单实收金额 单位:分*/ actFee: item.allIncome, /**欠费金额 单位:分*/ arrearageFee: item.escapeFee, /**支付宝费用*/ aliFee: item.allAliIncome, /**微信费用*/ wxFee: item.allWxIncome, /**现金费用*/ cashFee: item.allCashIncome, /**余额费用*/ balanceFee: item.allBalanceIncome, /**停车收入 **/ parkIncomeFee: item.parkIncome, /**会员卡收入 **/ vipIncomeFee: item.vipCardIncome, /**补缴收入 **/ backIncomeFee: item.backIncome, /**总的收入 **/ allIncomeFee: item.allIncome }; console.log('transData:'); console.log(JSON.stringify(transData)); //收入占比、逃逸统计 fun.drawIncomeStatisticForPayType(transData); return; } var commonAjax = { method: "post", url: dataUrl.util.queryIncomeStatisticForPayType(), async: false, data: JSON.stringify(req), contentType: 'application/json; charset=utf-8', dataType: 'json', success: function (res) { console.log(res); if (res.code == '8888') { if (res.data != null) { var data = res.data; //收入占比、逃逸统计 fun.drawIncomeStatisticForPayType(data); } } else { console.log(res); } } }; sysAjax(commonAjax); }, moneyFomatter: function (value) { if (value == null) { return "0.00"; } else { return (value / 100).toFixed(2); } }, }; fun.initPark(); fun.queryIncomeStatisticForPayType(plNos); fun.queryIncomeStatistic(plNos); //定位停车场位置 documentBindFunc.on('click','.incomeprofile-ranking li',function(){ // debugger var plNo = $(this).find(".ITD-cursor-pointer").attr("value"); var lot = ""; var lat=""; $.each(mapData,function(index,rows){ if(rows.parkNo == plNo){ lat = rows.lat; lot = rows.lot; return ; } }); var point = new BMap.Point(lat, lot); map.setCenter(point); map.centerAndZoom(point, 20); });