123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948 |
- 'use strict';
- app.controller('watchMapCtrl', ['$rootScope', '$scope', '$http', '$state', '$modal', '$templateCache', '$compile', 'Restangular', 'api_bpm_domain', function($rootScope, $scope, $http, $state, $modal, $templateCache, $compile, Restangular, api_bpm_domain) {
- // var ip = document.location.protocol + "//" + document.location.hostname + ":8080";
- //更改响应时间
- function changeTime(txt) {
- //填充字符串
- txt = (txt * 1000).toFixed(0);
- var time = $("#responseTime");
- time.empty();
- time.html(txt + "<span style='font:normal normal normal 50px arial,sans-serif;'>ms</span>");
- }
- //更改响应率
- function changePercent(txt) {
- //填充字符串
- txt = (txt * 100).toFixed(2);
- var percent = $("#packetPercent");
- percent.empty();
- percent.html(txt + "<span style='font:normal normal normal 50px arial,sans-serif;'>%</span>");
- }
- //鼠标放上支行点,显示tip
- // $scope.htmlTooltip = '<div>2314132432</div>';
- $scope.showBankTip = function(thisObj, id) {
- // var bankId = $(thisObj).attr("bankId");
- // var url = ip + "/service/api/bpm/bpm/getWatchAreaData/" + id;
- // $.getJSON(url, function(data) {
- api_bpm_domain.getWatchAreaData(id).then(function(data) {
- // var data = { "handler": 1, "resolved": 2, "close": 3 };
- if (data) {
- // var name = $(thisObj).attr("name");
- // var left = $(thisObj).position().left;
- // var top = $(thisObj).position().top - 92;
- // $("#toaster").remove(); //移除之前的toast
- // var settings = {
- // timeout: 100000,
- // toaster: {
- // 'id': 'toaster',
- // 'container': 'body',
- // 'template': '<div></div>',
- // 'class': 'toaster',
- // 'css': {
- // 'position': 'absolute',
- // 'left': thisObj.x,
- // 'top': thisObj.y - 92,
- // 'right': '10px',
- // 'width': '200px',
- // 'zIndex': 50000
- // }
- // },
- // toast: {
- // 'template': '<div class="alert alert-%priority% alert-dismissible" role="alert">' +
- // '<button type="button" class="close" onclick="$(\'#toaster\').remove()" data-dismiss="alert">' +
- // '<span aria-hidden="true">×</span>' +
- // '<span class="sr-only">Close</span>' +
- // '</button>' +
- // '<span class="title"></span><span class="message"></span>' +
- // '</div>',
- // 'css': {},
- // 'cssm': {},
- // 'csst': { 'fontWeight': 'bold' },
- // 'fade': 'slow',
- // 'display': function($toast) {
- // return $toast.fadeIn(this.fade);
- // },
- // 'remove': function($toast, callback) {
- // return $toast.animate({
- // opacity: '0',
- // padding: '0px',
- // margin: '0px',
- // height: '0px'
- // }, {
- // duration: this.fade,
- // complete: callback
- // });
- // }
- // }
- // };
- var handler = $scope.handler = data.handler; //处理中
- var resolved = $scope.resolved = data.resolved; //已解决
- var close = $scope.close = data.close; //已关闭
- var priority = 'info';
- settings.toaster.css.left = thisObj.x;
- settings.toaster.css.top = thisObj.y - 92;
- // $.toaster({
- // priority: priority,
- // title: name,
- // message: '处理中:' + handler + '<br>已解决:' + resolved +
- // '<br/>已关闭:' + close,
- // settings: settings
- // });
- }
- });
- }
- //初始化地图上的点
- function initPointer() {
- // var data = [{ "id": 1, "area": "主院区", "x": 625, "y": 420 }, { "id": 2, "area": "东院区", "x": 650, "y": 250 }, { "id": 3, "area": "同济院区", "x": 250, "y": 350 }, { "id": 4, "area": "商学院", "x": 426, "y": 500 }]
- // var url = "192.168.3.19:8080/service/api/bpm/bpm/getWatchAreaPosition";
- // $.getJSON(url, function(data) {
- api_bpm_domain.getWatchAreaPosition().then(function(data) {
- if (data) {
- $scope.arr = data;
- $scope.imgName = "green.png";
- //移除支行点
- // $(".area").remove();
- // for (var i = 0; i < $scope.arr.length; i++) {
- // var bean = $scope.arr[i];
- // $scope.width = 150;
- // $scope.height = 22;
- // var imgName = "green.png";
- // //TODO 一个方法搞定
- // $(".showtip").append("<img class='area' onclick='showBankTip(this, " + bean.id + ");'" +
- // " src='assets/images/" + imgName + "' style='cursor:pointer;position:absolute;left:" + bean.x + "px;top:" + bean.y + "px;' " +
- // " name='" + bean.area + "' areaId='" + bean.id + "' width='16' height='16'/>");
- // }
- }
- });
- }
- //计算鼠标相对于body的坐标
- function mousePosition(ev) {
- if (ev.pageX || ev.pageY) {
- return {
- x: ev.pageX,
- y: ev.pageY
- };
- }
- return {
- x: ev.clientX + document.body.scrollLeft - document.body.clientLeft,
- y: ev.clientY + document.body.scrollTop - document.body.clientTop
- };
- }
- //初始化
- function init() {
- //初始化网络拓扑图数据
- initPointer();
- //点击其他地方,隐藏设备列表
- $("body").click(function(event) {
- var pos = mousePosition(event),
- x = pos.x,
- y = pos.y;
- var ele = $("#deviceList"),
- elePos = ele.position(),
- left = elePos.left,
- top = elePos.top;
- // alert("x = " + x + "\ny = " + y);
- if (x >= left && x <= (left + 500) && y >= top && y <= (top + ele.height())) { //点击了设备列表范围内
- return false;
- } else {
- ele.hide();
- }
- });
- //定时5分钟刷新一次
- setTimeout(init, 1000 * 60 * 5);
- }
- $(function() {
- var canvas = document.getElementById('supportHtml5');
- if (!canvas.getContext) {
- $("link").remove();
- var body = $("body");
- body.empty();
- body.append("<p>您的浏览器不支持HTML5,图表无法展示,请升级到支持HTML5的浏览器,如IE9及以上版本、最新的Chrome、Firefox等浏览器。</p>");
- return false;
- }
- if (!(canvas.style.backgroundSize === '')) {
- alert("您的浏览器不支持CSS3特性,部分功能受到影响。");
- return false;
- }
- var width = window.screen.width,
- height = window.screen.height;
- if (width >= 1920) {
- $("body").css("overflow-x", "hidden");
- }
- init(); //初始化
- });
- }]);
- app.controller('watchListCtrl', ['$rootScope', '$scope', '$http', '$state', '$modal', '$templateCache', '$compile', 'Restangular', 'api_bpm_domain', 'api_bpm_data', function($rootScope, $scope, $http, $state, $modal, $templateCache, $compile, Restangular, api_bpm_domain, api_bpm_data) {
- // var keydata = "pending";
- // $scope.showdivs = function(name, id, num) {
- // for (var i = 1; i < num + 1; i++) {
- // document.getElementById(name + i).style.display = "none"; //隐藏其他层
- // }
- // document.getElementById(name + id).style.display = "block"; //显示当前层
- // if (id == 1) {
- // keydata = "pending"; //待接单
- // } else if (id == 2) {
- // keydata = "reassign"; //待处理
- // } else if (id == 3) {
- // keydata = "handler"; //重新指派
- // }
- // $scope.refreshData(keydata);
- // }
- //待接单
- $scope.refreshData = function() {
- $scope.myData = [];
- var defaultFilterData = {
- "incident": {
- "statusId": "pending"
- },
- "idx": 0,
- "sum": 20
- };
- var fildata = {
- "incident": {
- "statusId": "reassign"
- },
- "idx": 0,
- "sum": 20
- };
- var fileData = {
- "incident": {
- "statusId": "handler"
- },
- "idx": 0,
- "sum": 20
- };
- api_bpm_data.fetchDataList("incident", defaultFilterData).then(function(data) {
- if (data.list) {
- var myData = Restangular.stripRestangular(data);
- $scope.myPending = myData.list;
- } else {}
- }, function() {});
- api_bpm_data.fetchDataList("incident", fildata).then(function(data) {
- if (data.list) {
- var myData = Restangular.stripRestangular(data);
- $scope.myReassign = myData.list;
- } else {}
- }, function() {});
- api_bpm_data.fetchDataList("incident", fileData).then(function(data) {
- if (data.list) {
- var myData = Restangular.stripRestangular(data);
- $scope.myHandler = myData.list;
- } else {}
- }, function() {});
- };
- $scope.refreshData();
- // //待处理
- // $scope.refresh = function() {
- // $scope.myData = [];
- // api_bpm_data.fetchDataList("incident", defaultFilterData).then(function(data) {
- // if (data.list) {
- // var myData = Restangular.stripRestangular(data);
- // var list = [];
- // $scope.myData = myData.list;
- // } else {
- // // Alert.swal({
- // // title: "系统错误",
- // // text: "请稍后再试!",
- // // type: "error"
- // // });
- // }
- // }, function() {});
- // };
- }]);
- app.controller('watchweekCtrl', ["$scope", "$rootScope", "$state", "$timeout", "$interval", "$http", "$cookieStore", "Restangular", "api_report", "api_statistic", function($scope, $rootScope, $state, $timeout, $interval, $http, $cookieStore, Restangular, api_report, api_statistic) {
- api_report.getLicenseKey().then(function(response) {
- $cookieStore.put('Auth-Token', response.token);
- $scope.try_async_load();
- });
- $scope.try_async_load = function() {
- $scope.my_data = [];
- api_report.list().then(function(response) {
- var dataList = Restangular.stripRestangular(response);
- getRepoRoot(dataList, '/homes/home:admin/ITSM报表');
- $scope.repoRoot.name = "事件报表"
- convertRepoObject($scope.repoRoot);
- $scope.my_data.push($scope.repoRoot);
- });
- };
- $scope.repoRoot = null;
- function getRepoRoot(repo, path) {
- angular.forEach(repo, function(value, key) {
- if (value.path == path) {
- $scope.repoRoot = value;
- } else {
- if ($scope.repoRoot == null && angular.isDefined(value.repoObjects)) {
- getRepoRoot(value.repoObjects, path);
- } else {
- }
- }
- });
- }
- function convertRepoObject(repo) {
- if (angular.isArray(repo)) {
- angular.forEach(repo, function(value, key) {
- convertRepoObject(value);
- })
- } else {
- if (angular.isDefined(repo.name)) {
- if (repo.name.indexOf(".") >= 0) {
- repo.label = repo.name.substr(0, repo.name.lastIndexOf("."));
- } else {
- repo.label = repo.name;
- }
- //delete repo.name;
- }
- if (angular.isDefined(repo.repoObjects)) {
- repo.children = [];
- repo.children = repo.repoObjects;
- delete repo.repoObjects;
- convertRepoObject(repo.children);
- }
- }
- }
- function parseDateParameter(parameters) {
- var result = undefined;
- if (angular.isArray(parameters)) {
- // angular.forEach(parmeters,function(param){
- // param.
- // })
- } else {
- result = {};
- for (var k in parameters) {
- if (k.indexOf("Date") > 0) {
- if (angular.isString(parameters[k])) {
- result[k] = moment(parameters[k], "YYYYMMDD").format("YYYY-MM-DD");
- //result[k] = ''+parameters[k]+'';//= moment(parameters[k], "YYYYMMDD").toDate();
- }
- }
- }
- }
- return result;
- }
- function ConvertDateParameter(parameters) {
- var result = undefined;
- if (angular.isArray(parameters)) {
- //
- } else {
- result = {};
- for (var k in parameters) {
- if (k.indexOf("Date") > 0) {
- if (angular.isDate(parameters[k])) {
- result[k] = moment(parameters[k]).format("YYYYMMDD");
- } else if (angular.isString(parameters[k])) {
- result[k] = parameters[k];
- }
- }
- }
- }
- return result;
- }
- var pathuser = "/homes/home:admin/ITSM报表/事件报表/处理人员统计分析.saiku";
- var pathstate = "/homes/home:admin/ITSM报表/事件报表/事件状态占比.saiku";
- var pathreason = "/homes/home:admin/ITSM报表/事件报表/事件原因.saiku";
- var queryUUID;
- function genUUID() {
- var uuid = 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,
- function(c) {
- var r = Math.random() * 16 | 0,
- v = c == 'x' ? r : (r & 0x3 | 0x8);
- return v.toString(16);
- }).toUpperCase();
- return uuid;
- }
- queryUUID = genUUID();
- var workspace = {};
- var pathuserkey = [];
- var pathreasonkey = [];
- var pathreasonkey = [];
- var getreportdata = function(key, path) {
- $scope.isMaskuser = true;
- $scope.isMaskreason = true;
- $scope.isMaskreason = true;
- api_report.getMdx(path, queryUUID).then(function(response) {
- var mdxquery = Restangular.stripRestangular(response);
- workspace.query = mdxquery;
- $scope.shows = false;
- workspace.query.parameters.paramDateFrom = $scope.starttimes;
- workspace.query.parameters.paramDateTo = $scope.endtimes;
- $scope.parameters = parseDateParameter(workspace.query.parameters);
- weekuser(key, mdxquery);
- });
- }
- var weekuser = function(keys, mdxquery) {
- var key = [];
- api_report.execute(mdxquery).then(function(data) {
- $scope.rheaders = [];
- $scope.rRows = [];
- var reportData = Restangular.stripRestangular(data);
- if (reportData.cellset == null || reportData.cellset.length == 0) {
- $scope.shows = true;
- $scope.empty = "数据为空!"
- } else {
- angular.forEach(reportData.cellset, function(item, index) {
- if (item.length > 1 && index > 0 && item[1].value != '') {
- key.push([item[0].value, Number(item[1].value)]);
- }
- })
- }
- if (keys == 'pathuserkey') {
- $scope.isMaskuser = false;
- containerfun(key);
- } else if (keys == 'pathstatekey') {
- $scope.isMaskreason = false;
- statesfun(key);
- } else if (keys == 'pathreasonkey') {
- $scope.isMaskreason = false;
- reasonfun(key);
- }
- })
- }
- $scope.parameters = {};
- var weeks = new Date().getDay();
- $scope.starttimes = moment(new Date().getTime() - 86400000 * (weeks)).format('YYYYMMDD');
- $scope.endtimes = moment(new Date()).format('YYYYMMDD');
- $scope.parameters.paramDateFrom = $scope.starttimes;
- $scope.parameters.paramDateTo = $scope.endtimes;
- $scope.parameters = parseDateParameter($scope.parameters);
- getreportdata('pathuserkey', pathuser);
- getreportdata('pathstatekey', pathstate);
- getreportdata('pathreasonkey', pathreason);
- //待处理事件饼形图
- var containerfun = function(pathuserkey) {
- $(function() {
- $('#container').highcharts({
- chart: {
- type: 'pie',
- options3d: {
- enabled: true,
- alpha: 45,
- beta: 0
- }
- },
- title: {
- text: '待处理事件人员统计图'
- },
- tooltip: {
- pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
- },
- plotOptions: {
- pie: {
- allowPointSelect: true,
- cursor: 'pointer',
- depth: 35,
- dataLabels: {
- enabled: true,
- format: '{point.name}'
- }
- }
- },
- series: [{
- type: 'pie',
- name: '人员占比',
- data: pathuserkey
- }]
- });
- });
- }
- // Create the chart
- var statesfun = function(pathstatekey) {
- Highcharts.chart('incidentstates', {
- chart: {
- type: 'bar'
- },
- title: {
- text: '事件状态统计图'
- },
- subtitle: {
- // text: 'Source: <a href="http://en.wikipedia.org/wiki/List_of_cities_proper_by_population">Wikipedia</a>'
- },
- xAxis: {
- type: 'category',
- labels: {
- rotation: -45,
- style: {
- fontSize: '13px',
- fontFamily: 'Verdana, sans-serif'
- }
- }
- },
- yAxis: {
- min: 0,
- title: {
- text: ''
- }
- },
- legend: {
- enabled: false
- },
- tooltip: {
- pointFormat: '<b>{point.y}</b>'
- },
- series: [{
- name: 'Population',
- colorByPoint: true,
- data: pathstatekey,
- borderWidth: 0,
- dataLabels: {
- enabled: false,
- rotation: -90,
- color: '#FFFFFF',
- align: 'right',
- format: '{point.y}', // one decimal
- y: 10, // 10 pixels down from the top
- style: {
- fontSize: '13px',
- fontFamily: 'Verdana, sans-serif'
- }
- }
- }]
- });
- }
- var reasonfun = function(pathreasonkey) {
- $(function() {
- $('#incidentreason').highcharts({
- chart: {
- type: 'pie',
- options3d: {
- enabled: true,
- alpha: 45,
- beta: 0
- }
- },
- title: {
- text: '事件原因统计图'
- },
- tooltip: {
- pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
- },
- plotOptions: {
- pie: {
- allowPointSelect: true,
- cursor: 'pointer',
- depth: 35,
- dataLabels: {
- enabled: true,
- format: '{point.name}'
- }
- }
- },
- series: [{
- type: 'pie',
- name: '事件原因占比',
- data: pathreasonkey
- }],
- lang: {
- noData: "Nichts zu anzeigen" //真正显示的文本
- },
- noData: {
- // Custom positioning/aligning options
- position: { //相对于绘图区定位无数据标签的位置。 默认值:[object Object].
- align: 'right',
- verticalAlign: 'bottom'
- },
- // Custom svg attributes
- attr: { //无数据标签中额外的SVG属性
- 'stroke-width': 1,
- stroke: '#cccccc'
- },
- // Custom css
- style: { //对无数据标签的CSS样式。 默认值:[object Object].
- //fontWeight: 'bold',
- //fontSize: '15px',
- //color: '#202030'
- }
- }
- });
- });
- }
- }]);
- //月统计图
- app.controller('watchmonthCtrl', ["$scope", "$rootScope", "$state", "$timeout", "$interval", "$http", "$cookieStore", "Restangular", "api_report", "api_statistic", function($scope, $rootScope, $state, $timeout, $interval, $http, $cookieStore, Restangular, api_report, api_statistic) {
- api_report.getLicenseKey().then(function(response) {
- $cookieStore.put('Auth-Token', response.token);
- $scope.try_async_load();
- });
- $scope.try_async_load = function() {
- $scope.my_data = [];
- api_report.list().then(function(response) {
- var dataList = Restangular.stripRestangular(response);
- getRepoRoot(dataList, '/homes/home:admin/ITSM报表');
- $scope.repoRoot.name = "事件报表"
- convertRepoObject($scope.repoRoot);
- $scope.my_data.push($scope.repoRoot);
- });
- };
- var workspace = {};
- $scope.repoRoot = null;
- function getRepoRoot(repo, path) {
- angular.forEach(repo, function(value, key) {
- if (value.path == path) {
- $scope.repoRoot = value;
- } else {
- if ($scope.repoRoot == null && angular.isDefined(value.repoObjects)) {
- getRepoRoot(value.repoObjects, path);
- } else {
- }
- }
- });
- }
- function convertRepoObject(repo) {
- if (angular.isArray(repo)) {
- angular.forEach(repo, function(value, key) {
- convertRepoObject(value);
- })
- } else {
- if (angular.isDefined(repo.name)) {
- if (repo.name.indexOf(".") >= 0) {
- repo.label = repo.name.substr(0, repo.name.lastIndexOf("."));
- } else {
- repo.label = repo.name;
- }
- //delete repo.name;
- }
- if (angular.isDefined(repo.repoObjects)) {
- repo.children = [];
- repo.children = repo.repoObjects;
- delete repo.repoObjects;
- convertRepoObject(repo.children);
- }
- }
- }
- function parseDateParameter(parameters) {
- var result = undefined;
- if (angular.isArray(parameters)) {
- // angular.forEach(parmeters,function(param){
- // param.
- // })
- } else {
- result = {};
- for (var k in parameters) {
- if (k.indexOf("Date") > 0) {
- if (angular.isString(parameters[k])) {
- result[k] = moment(parameters[k], "YYYYMMDD").format("YYYY-MM-DD");
- //result[k] = ''+parameters[k]+'';//= moment(parameters[k], "YYYYMMDD").toDate();
- }
- }
- }
- }
- return result;
- }
- function ConvertDateParameter(parameters) {
- var result = undefined;
- if (angular.isArray(parameters)) {
- //
- } else {
- result = {};
- for (var k in parameters) {
- if (k.indexOf("Date") > 0) {
- if (angular.isDate(parameters[k])) {
- result[k] = moment(parameters[k]).format("YYYYMMDD");
- } else if (angular.isString(parameters[k])) {
- result[k] = parameters[k];
- }
- }
- }
- }
- return result;
- }
- var lastmonth = "/homes/home:admin/ITSM报表/事件报表/地点统计.saiku";
- var thismonth = "/homes/home:admin/ITSM报表/事件报表/地点统计.saiku";
- var incidentchart = "/homes/home:admin/ITSM报表/事件报表/日统计报表.saiku";
- var queryUUID;
- function genUUID() {
- var uuid = 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,
- function(c) {
- var r = Math.random() * 16 | 0,
- v = c == 'x' ? r : (r & 0x3 | 0x8);
- return v.toString(16);
- }).toUpperCase();
- return uuid;
- }
- queryUUID = genUUID();
- var pathlastmonthkey = [];
- var paththismonthkey = [];
- var pathincidenttimekey = [];
- var lastmonthtime = {
- 'starttimes': moment((new Date(moment().startOf('month'))).setMonth((new Date()).getMonth() - 1)).format('YYYYMMDD'),
- 'endtimes': moment((new Date(moment().startOf('month'))).setMonth((new Date()).getMonth()) - 86400000).format('YYYYMMDD')
- };
- var thismonthtime = {
- 'starttimes': moment((new Date(moment().startOf('month'))).setMonth((new Date()).getMonth())).format('YYYYMMDD'),
- 'endtimes': moment(new Date()).format('YYYYMMDD')
- };
- var incidenttime = {
- 'starttimes': moment(new Date().getTime() - 86400000 * 14).format('YYYYMMDD'),
- 'endtimes': moment(new Date()).format('YYYYMMDD')
- };
- var thisday = moment(new Date().getTime() + 86400000).format('YYYYMMDD');
- var thisdaymine = Date.parse(thisday.substr(4, 2) + "/" + thisday.substr(6, 2) + "/" + thisday.substr(0, 4))
- var averages = [
- [thisdaymine - 86400000 * 14, 0],
- [thisdaymine - 86400000 * 13, 0],
- [thisdaymine - 86400000 * 12, 0],
- [thisdaymine - 86400000 * 11, 0],
- [thisdaymine - 86400000 * 10, 0],
- [thisdaymine - 86400000 * 9, 0],
- [thisdaymine - 86400000 * 8, 0],
- [thisdaymine - 86400000 * 7, 0],
- [thisdaymine - 86400000 * 6, 0],
- [thisdaymine - 86400000 * 5, 0],
- [thisdaymine - 86400000 * 4, 0],
- [thisdaymine - 86400000 * 3, 0],
- [thisdaymine - 86400000 * 2, 0],
- [thisdaymine - 86400000 * 1, 0],
- [thisdaymine, 0]
- ];
- var getreportdata = function(key, thistime, path) {
- // $scope.isMasklastmon = true;
- // $scope.isMaskthismon = true;
- // $scope.isMaskincident = true;
- api_report.getMdx(path, queryUUID).then(function(response) {
- var mdxquery = Restangular.stripRestangular(response);
- workspace.query = mdxquery;
- workspace.query.parameters.paramDateFrom = thistime.starttimes;
- workspace.query.parameters.paramDateTo = thistime.endtimes;
- $scope.parameters = parseDateParameter(workspace.query.parameters);
- weekuser(key, mdxquery);
- });
- }
- var weekuser = function(keys, mdxquery) {
- var key = [];
- api_report.execute(mdxquery).then(function(data) {
- $scope.rheaders = [];
- $scope.rRows = [];
- var reportData = Restangular.stripRestangular(data);
- if (reportData.cellset == null || reportData.cellset.length == 0) {
- $scope.shows = true;
- $scope.empty = "数据为空!"
- } else {
- // angular.forEach(reportData.cellset, function(item, index) {
- // if (item.length > 1 && index > 0 && item[1].value != '') {
- // key.push([item[0].value, Number(item[1].value)]);
- // }
- // })
- if (keys == 'lastmonthkey') {
- angular.forEach(reportData.cellset, function(item, index) {
- if (item.length > 1 && index > 0 && item[1].value != '') {
- key.push([item[0].value, Number(item[1].value)]);
- }
- })
- lastmonthfun(key);
- } else if (keys == 'thismonthkey') {
- angular.forEach(reportData.cellset, function(item, index) {
- if (item.length > 1 && index > 0 && item[1].value != '') {
- key.push([item[0].value, Number(item[1].value)]);
- }
- })
- thismonthfun(key);
- } else if (keys == 'incidentchartkey') {
- angular.forEach(reportData.cellset, function(item, i) {
- angular.forEach(averages, function(index, j) {
- // angular.forEach(averages, function(item, index) {
- if (item.length > 1 && i > 0 && item[1].value != '') {
- if (index[0] == Date.parse(item[0].value.substr(4, 2) + "/" + item[0].value.substr(6, 2) + "/" + item[0].value.substr(0, 4)) + 86400000) {
- index[1] = Number(item[1].value);
- }
- // key.push([Date.parse(item[0].value.substr(4, 2) + "/" + item[0].value.substr(6, 2) + "/" + item[0].value.substr(0, 4)), Number(item[1].value)]);
- }
- // })
- })
- })
- incidentchartfun(averages);
- }
- }
- })
- }
- // $scope.parameters = {};
- var weeks = new Date().getDay();
- // $scope.starttimes = moment(new Date().getTime() - 86400000 * (weeks)).format('YYYYMMDD');
- // $scope.endtimes = moment(new Date()).format('YYYYMMDD');
- // $scope.parameters.paramDateFrom = $scope.starttimes;
- // $scope.parameters.paramDateTo = $scope.endtimes;
- // $scope.parameters = parseDateParameter($scope.parameters);
- getreportdata('lastmonthkey', lastmonthtime, lastmonth);
- getreportdata('thismonthkey', thismonthtime, thismonth);
- getreportdata('incidentchartkey', incidenttime, incidentchart);
- // 上月区域多发top10
- var lastmonthfun = function(lastmonthkey) {
- // $scope.isMasklastmon = flase;
- Highcharts.chart('lastmonth', {
- chart: {
- type: 'bar'
- },
- title: {
- text: '上月区域多发top10统计图'
- },
- subtitle: {
- // text: 'Source: <a href="http://en.wikipedia.org/wiki/List_of_cities_proper_by_population">Wikipedia</a>'
- },
- xAxis: {
- type: 'category',
- labels: {
- rotation: -45,
- style: {
- fontSize: '13px',
- fontFamily: 'Verdana, sans-serif'
- }
- }
- },
- yAxis: {
- min: 0,
- title: {
- text: ''
- }
- },
- legend: {
- enabled: false
- },
- tooltip: {
- pointFormat: '<b>{point.y}</b>'
- },
- series: [{
- name: 'Population',
- colorByPoint: true,
- data: lastmonthkey,
- borderWidth: 0,
- dataLabels: {
- enabled: false,
- rotation: -90,
- color: '#FFFFFF',
- align: 'right',
- format: '{point.y}', // one decimal
- y: 10, // 10 pixels down from the top
- style: {
- fontSize: '13px',
- fontFamily: 'Verdana, sans-serif'
- }
- }
- }]
- });
- }
- // 本月区域多发top10
- var thismonthfun = function(lastmonthkey) {
- // $scope.isMaskthismon = false;
- Highcharts.chart('thismonth', {
- chart: {
- type: 'bar'
- },
- title: {
- text: '本月区域多发top10统计图'
- },
- subtitle: {
- // text: 'Source: <a href="http://en.wikipedia.org/wiki/List_of_cities_proper_by_population">Wikipedia</a>'
- },
- xAxis: {
- type: 'category',
- labels: {
- rotation: -45,
- style: {
- fontSize: '13px',
- fontFamily: 'Verdana, sans-serif'
- }
- }
- },
- yAxis: {
- min: 0,
- title: {
- text: ''
- }
- },
- legend: {
- enabled: false
- },
- tooltip: {
- pointFormat: '<b>{point.y}</b>'
- },
- series: [{
- name: 'Population',
- colorByPoint: true,
- data: lastmonthkey,
- borderWidth: 0,
- dataLabels: {
- enabled: false,
- rotation: -90,
- color: '#FFFFFF',
- align: 'right',
- format: '{point.y}', // one decimal
- y: 10, // 10 pixels down from the top
- style: {
- fontSize: '13px',
- fontFamily: 'Verdana, sans-serif'
- }
- }
- }]
- });
- }
- // 最近15天事件
- var incidentchartfun = function(incidentchartkey) {
- // $scope.isMaskincident = false;
- Highcharts.chart('incidentchart', {
- title: {
- text: '事件近15天趋势图'
- },
- xAxis: {
- type: 'datetime',
- labels: {
- align: 'left',
- step: 1
- }
- },
- yAxis: {
- title: {
- text: null
- }
- },
- tooltip: {
- crosshairs: true,
- shared: true,
- valueSuffix: '条'
- },
- legend: {},
- series: [{
- name: '生成事件',
- data: incidentchartkey,
- zIndex: 1,
- marker: {
- fillColor: 'white',
- lineWidth: 2,
- lineColor: Highcharts.getOptions().colors[0]
- }
- }]
- });
- }
- }]);
|