using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using IntelligentControlForsx.ChildForms; using IntelligentControlForsx.Template; using EntityDataSet; using IntelligentControlForsx.Model; using System.Collections; using WisdomClient.data; using log4net; namespace IntelligentControlForsx.Service { public class CacheService { private ILog logger = LogManager.GetLogger("AppInfoLog"); #region 构造方法--单例 private CacheService() { } public static CacheService Instance { get { return SingletonCreator.instance; } } class SingletonCreator { internal static readonly CacheService instance = new CacheService(); } #endregion #region 场站数据 private IList stationList; public IList StationList { get { if (stationList == null) stationList = LoadStationList(); return stationList; } } private IList LoadStationList() { using (wisdom_cs_entity ctx = new wisdom_cs_entity()) { return ctx.windpowerstation.ToList(); } } public IList GetFDCList() { return StationList.Where(q => q.ID.EndsWith("_FDC")).OrderByDescending(q => q.ID).ToList(); } private Dictionary stationStatusDictionary; public Dictionary StationStatusDictionary { get { if (stationStatusDictionary == null) stationStatusDictionary = LoadStationStatusDictionary(); return stationStatusDictionary; } } private Dictionary LoadStationStatusDictionary() { Dictionary result = new Dictionary(); try { var stationList = GetFDCList(); foreach (var station in stationList) { StationStatus ss = new StationStatus(station.ID); if (result.ContainsKey(ss.StationId) == false) { result.Add(ss.StationId, ss); } } } catch (Exception ex) { logger.Error(ex); } return result; } public string getStationName(string stationId) { return StationList.Where(q => q.ID == stationId).FirstOrDefault().NAME; } public windpowerstation getStationInfo(string stationId) { return StationList.Where(q => q.ID == stationId).FirstOrDefault(); } #endregion #region 风机数据 private IList windturbineList; public IList WindturbineList { get { if (windturbineList == null) windturbineList = LoadWindturbineList(); return windturbineList; } } private IList LoadWindturbineList() { using (wisdom_cs_entity ctx = new wisdom_cs_entity()) { return ctx.windturbine.Where(q => q.WINDPOWERSTATIONID.EndsWith("FDC")).ToList(); } } public IList GetWindturbineListByStationId(string stationId) { return WindturbineList.Where(q => q.WINDPOWERSTATIONID == stationId).OrderBy(q => q.LINEID).ToList(); } #endregion #region 设备矩阵 private string[] matrixStationPoints = new string[] { //0-停机-TJTS、 1-上电-SDTS、2-待机-DJTS、3-启动-QDTS、4-并网-BWTS、5-故障-GZTS、6-维护-WHTS、 7-离线-LXTS "TJTS8", "SDTS8", "DJTS8", "QDTS8", "BWTS8", "GZTS8", "WHTS8", "LXTS8", "RFDL", "YFDL", "NFDL", "ZFDL", "SSFS", "SSZGL" }; private string[] matrixWindturbinePoints = new string[] { "AI022", //10秒平均风速 "AI130", //功率 //"AI010", //风向角度 "FJZT8", //风机状态 "XDSL" //限电受累(挂牌) }; private Dictionary matrixPointMap; public Dictionary MatrixPointMap { get { if (matrixPointMap == null) LoadMatrixPointMap(); return matrixPointMap; } } private void LoadMatrixPointMap() { if (matrixPointMap == null) matrixPointMap = new Dictionary(); var lst1 = PointService.GetTestingPoints(PointType.Station, matrixStationPoints); if (lst1 != null && lst1.Count > 0) { foreach (var obj in lst1) { if (!matrixPointMap.ContainsKey(obj.PointId)) { matrixPointMap.Add(obj.PointId, obj); } } } var lst2 = PointService.GetTestingPoints(PointType.Windturbine, matrixWindturbinePoints); if (lst2 != null && lst2.Count > 0) { foreach (var obj in lst2) { if (!matrixPointMap.ContainsKey(obj.PointId)) { matrixPointMap.Add(obj.PointId, obj); } } } } #endregion #region 设备矩阵---启停推荐 private string[] matrixPowerPoints = new string[] { "YGSDZ", //AGC有功设定值 "SSZGL", //实时总功率 "ZLLGL", //理论功率 "FCFGCDQ0001", //15分钟预测功率 "FCFGCDQ0002", //30分钟预测功率 "FCFGCDQ0004", //60分钟预测功率 "FCFGCDQ0016" //4小时预测功率 }; private Dictionary matrixPopupPointMap; public Dictionary MatrixPopupPointMap { get { if (matrixPopupPointMap == null) LoadMatrixPopupPointMap(); return matrixPopupPointMap; } } private void LoadMatrixPopupPointMap() { if (matrixPopupPointMap == null) matrixPopupPointMap = new Dictionary(); var lst1 = PointService.GetTestingPoints(PointType.Station, matrixPowerPoints); if (lst1 != null && lst1.Count > 0) { foreach (var obj in lst1) { if (!matrixPopupPointMap.ContainsKey(obj.PointId)) { matrixPopupPointMap.Add(obj.PointId, obj); } } } } //场站功率曲线历史数据缓存 private Dictionary dictPowerCurveModel; public Dictionary DictPowerCurveModel { get { if (dictPowerCurveModel == null) { dictPowerCurveModel = createPowerCurveModelDictionary(); } return dictPowerCurveModel; } set { dictPowerCurveModel = value; } } private Dictionary createPowerCurveModelDictionary() { var result = new Dictionary(); var lstFDCStation = GetFDCList(); foreach (var st in lstFDCStation) { PowerCurveModel pcm = new PowerCurveModel(); pcm.StationId = st.ID; pcm.LastUpdateTime = DateTime.Today.AddDays(-1); pcm.FactPowerData = new List(); pcm.PredictPowerData = new List(); pcm.TheoryPowerData = new List(); pcm.AgcPowerData = new List(); pcm.WindSpeedData = new List(); pcm.CDQPredictPowerData = new TsData[16]; pcm.FactPowerPoint = PointService.GetStationTestingPointByUniformCode(st.ID, "SSZGL"); pcm.TheoryPowerPoint = PointService.GetStationTestingPointByUniformCode(st.ID, "ZLLGL"); pcm.AgcPowerPoint = PointService.GetStationTestingPointByUniformCode(st.ID, "YGSDZ"); pcm.PredictPowerPoint = PointService.GetStationTestingPointByUniformCode(st.ID, "FCFGCDQ0001"); result.Add(pcm.StationId, pcm); } return result; } private string[] matrixCDQPredictPoints = new string[] { "FCFGCDQ0001", "FCFGCDQ0002", "FCFGCDQ0003", "FCFGCDQ0004", "FCFGCDQ0005", "FCFGCDQ0006", "FCFGCDQ0007", "FCFGCDQ0008", "FCFGCDQ0009", "FCFGCDQ0010", "FCFGCDQ0011", "FCFGCDQ0012", "FCFGCDQ0013", "FCFGCDQ0014", "FCFGCDQ0015", "FCFGCDQ0016" }; private Dictionary matrixCDQPredictPointMap; public Dictionary MatrixCDQPredictPointMap { get { if (matrixCDQPredictPointMap == null) LoadatrixCDQPredictPointMap(); return matrixCDQPredictPointMap; } } private void LoadatrixCDQPredictPointMap() { if (matrixCDQPredictPointMap == null) matrixCDQPredictPointMap = new Dictionary(); var lst1 = PointService.GetTestingPoints(PointType.Station, matrixCDQPredictPoints); if (lst1 != null && lst1.Count > 0) { foreach (var obj in lst1) { if (!matrixCDQPredictPointMap.ContainsKey(obj.PointId)) { matrixCDQPredictPointMap.Add(obj.PointId, obj); } } } } #endregion #region 总貌图 #endregion } }