using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using EntityDataSet; using WisdomClient; using WisdomClient.data; namespace IntelligentControlForsx.Service.Control.FormInfo { public class StatInfoSvc { private StatInfoSvc() { } public static StatInfoSvc Instance { get { return SingletonCreator.instance; } } class SingletonCreator { internal static readonly StatInfoSvc instance = new StatInfoSvc(); } IList uniformCodeList = new List() { "SFDL",//总发电量 "NFDL",//年发电量 "YFDLB",//月发电量 "RFDLB",//日发电量 "SSZGL",//实时总功率 "SSFS",//实时风速 "BWTS8",//并网数量 "DJTS8",//待机数量 "GZTS8",//故障数量 "WHTS8",//维护数量 "QDTS8",//启动台数 "LXTS8",//离线数量 "SDTS8",//上电台数 "TJTS8"//停机数量 }; /// /// 根据场站编号查询相关统计信息 /// /// 场站编码,0为全场,-1为风电,-2为光伏 /// public StatInfo GetStatInfoByStation(string station) { StatInfo info = new StatInfo(); try { using (wisdom_cs_entity ctx = new wisdom_cs_entity()) { IList list = ctx.view_tspoint.Where(s => uniformCodeList.Contains(s.uniform_code) && s.thing_id == station).ToList(); Dictionary resultGridDic = RestfulClient.findLatestByTagNames(list.Select(s => s.id).ToArray()); foreach (var tsData in resultGridDic) { view_tspoint data = list.Where(s => s.id == tsData.Key).FirstOrDefault(); if (data != null) { switch (data.uniform_code) { case "SFDL": info.PowerAll = Double.Parse(tsData.Value.getValue()); break; case "NFDL": info.PowerByYear = Double.Parse(tsData.Value.getValue()); break; case "YFDLB": info.PowerByMonth = Double.Parse(tsData.Value.getValue()); break; case "RFDLB": info.PowerByDay = Double.Parse(tsData.Value.getValue()); break; case "SSZGL": info.Power = Double.Parse(tsData.Value.getValue()); break; case "SSFS": info.Speed = Double.Parse(tsData.Value.getValue()); break; case "BWTS8": info.OnlineCount = Convert.ToInt32(tsData.Value.getValue()); break; case "DJTS8": info.StandByCount = Convert.ToInt32(tsData.Value.getValue()); break; case "GZTS8": info.FaultCount = Convert.ToInt32(tsData.Value.getValue()); break; case "WHTS8": info.MaintainCount = Convert.ToInt32(tsData.Value.getValue()); break; case "LXTS8": info.OfflineCount = Convert.ToInt32(tsData.Value.getValue()); break; case "TJTS8": info.StopCount = Convert.ToInt32(tsData.Value.getValue()); break; case "SDTS8": info.OnPowerCount = Convert.ToInt32(tsData.Value.getValue()); break; case "QDTS8": info.StartCount = Convert.ToInt32(tsData.Value.getValue()); break; default: break; } } } IList windturbineList = ctx.windturbine.Where(s => s.WINDPOWERSTATIONID == station).ToList(); windpowerstation stationData = ctx.windpowerstation.Where(s => s.ID == station).FirstOrDefault(); info.StationId = station; if (stationData != null) info.StationName = stationData.NAME; info.LinkCount = windturbineList.Count; return info; } } catch (Exception ex) { throw ex; } } public StatInfo GeStatInfo() { StatInfo info = new StatInfo(); IList allStationUniformCodeList = new List(); allStationUniformCodeList.Add("SFDL");//总发电量 allStationUniformCodeList.Add("NFDLB");//年发电量 allStationUniformCodeList.Add("YFDLB");//月发电量 allStationUniformCodeList.Add("RFDLB");//日发电量 allStationUniformCodeList.Add("SSZGL");//全省运行台数 allStationUniformCodeList.Add("YXTS");//全省运行台数 allStationUniformCodeList.Add("YXTS");//全省运行台数 allStationUniformCodeList.Add("GZTJ"); //全省故障台数 allStationUniformCodeList.Add("DJTS"); //全省待机台数 allStationUniformCodeList.Add("TXZD"); //全省离线台数 allStationUniformCodeList.Add("TJNUM"); //全省停机台数 allStationUniformCodeList.Add("WHTJ"); //全省维护台数 allStationUniformCodeList.Add("SSFS"); //风速 try { using (wisdom_cs_entity ctx = new wisdom_cs_entity()) { IList list = ctx.view_tspoint.Where(s => allStationUniformCodeList.Contains(s.uniform_code) && s.thing_id == "-1" && s.thing_type == "station").ToList(); Dictionary resultGridDic = RestfulClient.findLatestByTagNames(list.Select(s => s.id).ToArray()); foreach (var tsData in resultGridDic) { view_tspoint data = list.Where(s => s.id == tsData.Key).FirstOrDefault(); if (data != null) { switch (data.uniform_code) { case "SFDL": info.PowerAll = Double.Parse(tsData.Value.getValue()); break; case "NFDLB": info.PowerByYear = Double.Parse(tsData.Value.getValue()); break; case "YFDLB": info.PowerByMonth = Double.Parse(tsData.Value.getValue()); break; case "RFDLB": info.PowerByDay = Double.Parse(tsData.Value.getValue()); break; case "SSZGL": info.Power = Double.Parse(tsData.Value.getValue()); break; case "SSFS": info.Speed = Double.Parse(tsData.Value.getValue()); break; case "YXTS": info.OnlineCount = Convert.ToInt32(tsData.Value.getValue()); break; case "DJTS": info.StandByCount = Convert.ToInt32(tsData.Value.getValue()); break; case "GZTJ": info.FaultCount = Convert.ToInt32(tsData.Value.getValue()); break; case "WHTJ": info.MaintainCount = Convert.ToInt32(tsData.Value.getValue()); break; case "TXZD": info.OfflineCount = Convert.ToInt32(tsData.Value.getValue()); break; case "TJNUM": info.StopCount = Convert.ToInt32(tsData.Value.getValue()); break; default: break; } } } /* IList windturbineList = ctx.windturbine.Where(s => s.WINDPOWERSTATIONID == station).ToList(); windpowerstation stationData = ctx.windpowerstation.Where(s => s.ID == station).FirstOrDefault(); info.StationId = ""; if (stationData != null) info.StationName = stationData.NAME; info.LinkCount = windturbineList.Count;*/ info.StartCount = 0; info.OnPowerCount = 0; return info; } } catch (Exception ex) { throw ex; } } } }