123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- var colors = [
- '#C1232B', '#B5C334', '#FCCE10', '#E87C25', '#27727B',
- '#FE8463', '#9BCA63', '#FAD860', '#F3A43B', '#60C0DD',
- '#D7504B', '#C6E579', '#F4E001', '#F0805A', '#26C0C0'
- ];
- var gzLevel = ['电网停机', '快速停机', '变桨停机', '安全链停机']; //属于故障的报警级别
- //获取条件搜索集合
- (function (W) {
- function getFilterCondition(beginTime, endTime, dataAreaName, alarmlevel) {
- var condition = [];
- if (beginTime != null || beginTime != "") {
- var contionTimeInfo = new FieldCondition();
- contionTimeInfo.field = "alarm_time";
- contionTimeInfo.value = beginTime;
- contionTimeInfo.method = 4; //>=
- condition.push(contionTimeInfo);
- }
- if (endTime != null || endTime != "") {
- var contionTimeInfo = new FieldCondition();
- contionTimeInfo.field = "alarm_time";
- contionTimeInfo.value = endTime;
- contionTimeInfo.method = 5; //<=
- condition.push(contionTimeInfo);
- }
-
- if (dataAreaName != null && dataAreaName != "*") {
- var conditionAreainfo = new FieldCondition();
- conditionAreainfo.field = "state1";
- if (JSON.stringify(alarmAreaDicName) != "{}") {
-
- conditionAreainfo.value = typeof (alarmAreaDicName[dataAreaName]) == "undefined" ? -1 : alarmAreaDicName[dataAreaName].id;
- }
-
- conditionAreainfo.method = 0;
- condition.push(conditionAreainfo);
- }
-
- if (alarmlevel != null && alarmlevel != "*") {
- for (var i = 0; i < alarmlevel.length; i++) {
- var conditionLevelInfo = new FieldCondition();
- conditionLevelInfo.field = "state0";
- if (JSON.stringify(alarmLevelDicName) != "{}") {
-
- conditionLevelInfo.value = alarmLevelDicName[alarmlevel[i]] && alarmLevelDicName[alarmlevel[i]].level; //getAlarmLevelNameByName(alarmlevel);
- }
-
- conditionLevelInfo.method = 0;
- condition.push(conditionLevelInfo);
- }
- }
-
-
- //筛选首出故障
- var conditionIsFirstfo = new FieldCondition();
- conditionIsFirstfo.field = "is_first";
- conditionIsFirstfo.value = 1;
- conditionIsFirstfo.method = 0;
- condition.push(conditionIsFirstfo);
-
- return condition;
-
- }
- //获取报警级别统计数据
- function getAlarmLevelChartData(beginTime, endTime, alarmAreaName, chartType, chartName, callback) {
- getAlarmGroups(function (data) {
- if (!GD.isEmptyObj(data)) {
- getAlarmLevelsData(function (levelData) {
- if (!GD.isEmptyObj(data)) {
- var condition = getFilterCondition(beginTime, endTime, alarmAreaName);
- var reqData = {
- "method": "GetHistoryCountByLevel",
- "param": {
- "groupby": "state0",
- "condition": condition
- }
- };
- var flag = 'GetHistoryCountByLevel';
- var eventName = "/alarm/doservice?" + flag;
- socket.alarmPost(eventName, reqData, function (data) {
- if (data && data.success) {
- var alarmLevelInfos = data.data.data;
- if (chartType == "alarmLevelPie") {
- //pie图参数
- chartName.option.legend.data = [];
- chartName.option.series[0].data = [];
- } else if (chartType == "alarmLevelBar") {
- chartName.option.legend.data = [];
- chartName.lables = [];
- chartName.option.xAxis[0].data = [];
- chartName.option.series[0].data = [];
- chartName.option.series[1].data = [];
- }
- for (key in alarmLevelDic) {
- if (key > 10) continue;
- if (chartType == "alarmLevelPie") {
- chartName.option.legend.data.push(alarmLevelDic[key].level_name);
- } else if (chartType == "alarmLevelBar") {
- //给柱状图赋值
- chartName.lables.push(alarmLevelDic[key].level_name);
- chartName.option.legend.data.push(alarmLevelDic[key].level_name);
- chartName.option.xAxis[0].data.push(alarmLevelDic[key].level_name);
- }
- if (alarmLevelInfos.length == 0) {
- if (chartType == "alarmLevelPie") {
- var obj = new Object();
- obj.name = alarmLevelDic[key].level_name;
- obj.value = 0;
- chartName.option.series[0].data.push(obj);
- } else if (chartType == "alarmLevelBar") {
- chartName.option.series[1].data.push(0);
- }
- }
- for (var i = 0; i < alarmLevelInfos.length; i++) {
- if (chartType == "alarmLevelPie") {
- //给pie图赋值
- if (key != alarmLevelInfos[i].level_id) {
- if (i == alarmLevelInfos.length - 1) {
- var obj = new Object();
- obj.name = alarmLevelDic[key].level_name;
- obj.value = 0;
- chartName.option.series[0].data.push(obj);
- }
- continue;
- } else {
- var obj = new Object();
- obj.name = alarmLevelDic[alarmLevelInfos[i].level_id].level_name;
- obj.value = alarmLevelInfos[i].count;
- chartName.option.series[0].data.push(obj);
- break;
- }
- } else if (chartType == "alarmLevelBar") {
- //给柱状图赋值
- if (key != alarmLevelInfos[i].level_id) {
- if (i == alarmLevelInfos.length - 1) {
- chartName.option.series[1].data.push(0);
- }
- continue;
- } else {
- chartName.option.series[1].data.push(alarmLevelInfos[i].count);
- break;
- }
- }
- }
- }
- callback(chartName.option, chartName.lables);
- }
- })
- }
- })
- }
- })
- }
- //-------------------获取报警组数据绘制图表-------------------------
- function getAlarmGroupChartData(beginTime, endTime, alarmAreaName, chartType, chartName, callback) {
- getAlarmGroups(function (data) {
- if (!GD.isEmptyObj(data)) {
- var condition = getFilterCondition(beginTime, endTime, alarmAreaName, gzLevel);
- var reqData = {
- "method": "GetHistoryCountByType",
- "param": {
- "groupby": "state2",
- "condition": condition
- }
- };
- var flag = "GetHistoryCountByType";
- var eventName = "/alarm/doservice?" + flag;
- socket.alarmPost(eventName, reqData, function (data) {
- if (data && data.success) {
- var alarmGroupInfos = data.data.data;
- if (chartType == "alarmGroupPie") {
- //pie图参数
- chartName.option.legend.data = [];
- chartName.option.series[0].data = [];
- } else if (chartType == "alarmGroupBar") {
- chartName.option.legend.data = [];
- chartName.lables = [];
- chartName.option.xAxis[0].data = [];
- chartName.option.series[0].data = [];
- chartName.option.series[1].data = [];
- }
- // console.log(alarmGroupDicName);
- // for(var key in alarmGroupDicName){
- // for(var i=0;i<alarmGroupInfos.length;i++){
- // if(key==alarmGroupInfos[i].type_id){
- // alarmGroupInfos[i].group_name=alarmGroupDicName[key].group_name;
- // }
- // }
- // }
- // console.log(alarmGroupInfos);
- for (var key in alarmGroupDicName) {
- if (chartType == "alarmGroupPie") {
- chartName.option.legend.data.push(alarmGroupDicName[key].group_name);
- } else if (chartType == "alarmGroupBar") {
- chartName.lables.push(alarmGroupDicName[key]).group_name;
- chartName.option.legend.data.push(alarmGroupDicName[key].group_name);
- chartName.option.xAxis[0].data.push(alarmGroupDicName[key].group_name);
- }
- if (alarmGroupInfos.length == 0) {
- if (chartType == "alarmGroupPie") {
- var obj = new Object();
- obj.name = alarmGroupDicName[key].group_name;
- obj.value = 0;
- chartName.option.series[0].data.push(obj);
- } else if (chartType == "alarmGroupBar") {
- chartName.option.series[1].data.push(0);
- }
- }
- for (var i = 0; i < alarmGroupInfos.length; i++) {
- if (chartType == "alarmGroupPie") {
- //给pie图赋值
- if (key != alarmGroupInfos[i].type_id) {
- if (i == alarmGroupInfos.length - 1) {
- var obj = new Object();
- obj.name = alarmGroupDicName[key].group_name;
- obj.value = 0;
- chartName.option.series[0].data.push(obj);
- }
- continue;
- } else {
- var obj = new Object();
- obj.name = alarmGroupDicName[alarmGroupInfos[i].type_id].group_name;
- obj.value = alarmGroupInfos[i].count
- chartName.option.series[0].data.push(obj);
- break;
- }
- } else if (chartType == "alarmGroupBar") {
- //给柱状图赋值
- if (key != alarmGroupInfos[i].type_id) {
- if (i == alarmGroupInfos.length - 1) {
- chartName.option.series[1].data.push(0);
- }
- continue;
- } else {
- chartName.option.series[1].data.push(alarmGroupInfos[i].count);
- break;
- }
- }
- }
- }
- }
- callback(chartName.option, chartName.lables);
- })
- }
- })
- }
- W.getAlarmGroupChartData = getAlarmGroupChartData;
- W.getAlarmLevelChartData = getAlarmLevelChartData;
- })(window);
|