123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- 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<string> uniformCodeList = new List<string>()
- {
- "SFDL",//总发电量
- "NFDL",//年发电量
- "YFDLB",//月发电量
- "RFDLB",//日发电量
- "SSZGL",//实时总功率
- "SSFS",//实时风速
- "BWTS8",//并网数量
- "DJTS8",//待机数量
- "GZTS8",//故障数量
- "WHTS8",//维护数量
- "QDTS8",//启动台数
- "LXTS8",//离线数量
- "SDTS8",//上电台数
- "TJTS8"//停机数量
- };
- /// <summary>
- /// 根据场站编号查询相关统计信息
- /// </summary>
- /// <param name="station">场站编码,0为全场,-1为风电,-2为光伏</param>
- /// <returns></returns>
- public StatInfo GetStatInfoByStation(string station)
- {
- StatInfo info = new StatInfo();
- try
- {
- using (wisdom_cs_entity ctx = new wisdom_cs_entity())
- {
- IList<view_tspoint> list = ctx.view_tspoint.Where(s => uniformCodeList.Contains(s.uniform_code) && s.thing_id == station).ToList();
- Dictionary<string, TsData> 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<windturbine> 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<string> allStationUniformCodeList = new List<string>();
- 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<view_tspoint> list = ctx.view_tspoint.Where(s => allStationUniformCodeList.Contains(s.uniform_code) && s.thing_id == "-1" && s.thing_type == "station").ToList();
- Dictionary<string, TsData> 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<windturbine> 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;
- }
- }
- }
- }
|