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"
- };
-
-
-
-
-
- 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;
- }
- }
- }
-
- info.StartCount = 0;
- info.OnPowerCount = 0;
- return info;
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- }
- }
|