123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using EntityDataSet;
- using IntelligentControlForsx.Service.WindturbineControl.Domain;
- using IntelligentControlForsx.Service.ZM.Domain;
- using WisdomClient;
- using WisdomClient.data;
- namespace IntelligentControlForsx.Service.ZM
- {
- public class ZmWindturbineInfoSvc
- {
- #region 单例方法
- private ZmWindturbineInfoSvc()
- {
- }
- class SingletonCreator
- {
- internal static readonly ZmWindturbineInfoSvc instance = new ZmWindturbineInfoSvc();
- }
- public static ZmWindturbineInfoSvc Instance
- {
- get { return SingletonCreator.instance; }
- }
- #endregion
- public static IList<ZmWindturbineInfo> infoList = new List<ZmWindturbineInfo>();
- public static void GetInfo(string stationId, string projectId)
- {
- IList<ZmWindturbineInfo> list = new List<ZmWindturbineInfo>();
- list = infoList.Where(s => s.StationId == stationId && s.ProjectId == projectId).ToList();
- if (list.Count == 0)
- {
- if (stationId == "QS_FDC")
- {
- list = GetStationProjectItemsInfo(stationId, projectId);// 青山
- }
- else
- {
- using (wisdom_cs_entity ctx = new wisdom_cs_entity())
- {
- IList<windturbine> windturbineList =
- ctx.windturbine.Where(s => s.PROJECTID == projectId && s.WINDPOWERSTATIONID == stationId)
- .ToList();
- IList<windturbine_uniform_code> uniformCodeList =
- ctx.windturbine_uniform_code.Where(s => s.project_id == projectId && s.station_id == stationId)
- .ToList();
- for (int i = 0; i < windturbineList.Count; i++)
- {
- ZmWindturbineInfo info = new ZmWindturbineInfo();
- info.WindturbineId = windturbineList[i].ID;
- info.StationId = windturbineList[i].WINDPOWERSTATIONID;
- info.ProjectId = windturbineList[i].PROJECTID;
- windturbine_uniform_code uniformCodeData =
- uniformCodeList.Where(s => s.windturbine_id == windturbineList[i].ID).FirstOrDefault();
- if (uniformCodeData != null)
- {
- info.PowerUniformCode = uniformCodeData.power_uniform_code;
- info.WindSpeedUniformCode = uniformCodeData.wind_speed_uniform_code;
- info.StatusUniformCode = uniformCodeData.status_uniform_code;
- }
- var data =
- infoList.Where(
- s =>
- s.ProjectId == projectId && s.WindturbineId == windturbineList[i].ID &&
- s.StationId == windturbineList[i].WINDPOWERSTATIONID).FirstOrDefault();
- if (data == null)
- {
- list.Add(info);
- infoList.Add(info);
- }
- }
- }
- }
- }
- for (int i = 0; i < list.Count; i++)
- {
- string[] uniformCodeArr = new string[]
- {
- list[i].PowerUniformCode ,
- list[i].WindSpeedUniformCode,
- list[i].StatusUniformCode
- };
- Dictionary<string, TsData> dic = RestfulClient.findLatestByThingCodes("windturbine", list[i].WindturbineId, uniformCodeArr);
- if (dic != null)
- {
- foreach (KeyValuePair<string, TsData> kv in dic)
- {
- #region 风机状态
- if (kv.Key == list[i].StatusUniformCode)
- {
- int statusValue = Convert.ToInt32(kv.Value.getValue());
- switch (statusValue)
- {
- case 0:
- list[i].Status = WindturbineStatus.Stop;
- break;
- case 1:
- list[i].Status = WindturbineStatus.OnPower;
- break;
- case 2:
- list[i].Status = WindturbineStatus.Standby;
- break;
- case 3:
- list[i].Status = WindturbineStatus.Start;
- break;
- case 4:
- list[i].Status = WindturbineStatus.Online;
- break;
- case 5:
- list[i].Status = WindturbineStatus.Fault;
- break;
- case 6:
- list[i].Status = WindturbineStatus.Maintain;
- break;
- case 7:
- list[i].Status = WindturbineStatus.Offline;
- break;
- }
- }
- #endregion
- if (kv.Key == list[i].PowerUniformCode)
- list[i].Power = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].WindSpeedUniformCode)
- list[i].WindSpeed = Convert.ToDouble(kv.Value.getValue());
- }
- }
- }
- }
- // FOR 青山
- public static IList<ZmWindturbineInfo> GetStationProjectItemsInfo(string stationId, string projectId)
- {
- IList<ZmWindturbineInfo> list= new List<ZmWindturbineInfo>();
- using (wisdom_cs_entity ctx = new wisdom_cs_entity())
- {
- IList<windturbine> windturbineList =
- ctx.windturbine.Where(s => s.PROJECTID == projectId && s.WINDPOWERSTATIONID == stationId)
- .ToList();
- for (int i = 0; i < windturbineList.Count; i++)
- {
- ZmWindturbineInfo info = new ZmWindturbineInfo();
- info.WindturbineId = windturbineList[i].ID;
- info.StationId = windturbineList[i].WINDPOWERSTATIONID;
- info.ProjectId = windturbineList[i].PROJECTID;
- info.StatusUniformCode = "FJZT8";
- info.WindSpeedUniformCode = "AI022";
- info.PowerUniformCode = "AI130";
- infoList.Add(info);
- list.Add(info);
- }
- }
- return list;
- }
- }
- }
|