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