123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334 |
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Diagnostics;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using EntityDataSet;
- using IntelligentControlForsx.Service.WindturbineControl.Domain;
- using IntelligentControlForsx.Service.WindturbineControl.Domain.Cmd;
- using Gyee_Control.Svc.Cache;
- namespace IntelligentControlForsx.Service.WindturbineControl.IntPtrSvc
- {
- /// <summary>
- /// 风机控制筛选
- /// </summary>
- public class CmdInfoScreenSvc
- {
- private static CmdInfoScreenSvc screenSvc = new CmdInfoScreenSvc();
- private CmdInfoScreenSvc()
- {
- }
- public static CmdInfoScreenSvc GetCmdInfoScreenSvc()
- {
- return screenSvc;
- }
- /// <summary>
- /// 允许控制的风机信息集合
- /// </summary>
- /// <param name="infoList">控制风机信息集合</param>
- /// <param name="allowTable">允许控制风机信息Table</param>
- /// <param name="forbidenList">允许控制风机信息Table</param>
- /// <param name="forbidenTable">允许控制风机信息Table</param>
- /// <returns>允许控制风机集合</returns>
- public IList<WindturbineCmdInfo> GetAllowInfo(IList<WindturbineCmdInfo> infoList, out DataTable allowTable, out IList<WindturbineCmdInfo> forbidenList, out DataTable forbidenTable)
- {
- #region 状态判断 风机是否允许操作
- string stationId = infoList[0].StationId;
- IList<string> lockWindturbineId = new List<string>();
- for (int i = 0; i < infoList.Count; i++)
- {
- if (CacheInfo.CacheWindturbineDataDic.ContainsKey(infoList[i].WindturbineId))
- {
- WindturbinePointData d = CacheInfo.CacheWindturbineDataDic[infoList[i].WindturbineId];
- if (d.HungType != HungType.UnLock)
- lockWindturbineId.Add(d.WindturbineName);
- }
- }
- IList<WindturbineCmdInfo> allowList = new List<WindturbineCmdInfo>();
- forbidenList = new List<WindturbineCmdInfo>();
- CmdType type = infoList[0].CmdType;
- IList<WindturbinePointData> cacheDataList = new List<WindturbinePointData>();
- for (int i = 0; i < infoList.Count; i++)
- {
- if (CacheInfo.CacheWindturbineDataDic.ContainsKey(infoList[i].WindturbineId))
- cacheDataList.Add(CacheInfo.CacheWindturbineDataDic[infoList[i].WindturbineId]);
- }
- allowList = infoList;
- IList<WindturbineCmdInfo> busyList = new List<WindturbineCmdInfo>();
- switch (type)
- {
- case CmdType.Start://风机在待机状态下才能进行启动操作
- allowList = infoList.Where(s => cacheDataList.Where(r => r.Status == WindturbineStatus.Standby).ToList().Select(t => t.WindturbineName).Contains(s.WindturbineId)).ToList().Where(k => !TaskQueueSvc.dicTask.ContainsKey(k.WindturbineId)).ToList().Where(m => !lockWindturbineId.Contains(m.WindturbineId)).ToList();
- //操作过频繁的风机
- busyList = infoList.Where(s => TaskQueueSvc.dicTask.ContainsKey(s.WindturbineId)).ToList();
- //排除状态允许操作,且操作过频繁的风机
- forbidenList = infoList.Except(allowList).ToList();
- for (int i = 0; i < forbidenList.Count; i++)
- {
- if (busyList.Contains(forbidenList[i]))
- forbidenList[i].ForbidenDescription = "风机操作过于频繁";
- else if (lockWindturbineId.Contains(forbidenList[i].WindturbineId))
- forbidenList[i].ForbidenDescription = "风机已被挂牌";
- else
- forbidenList[i].ForbidenDescription = "风机只有待机状态下才能进行启动操作";
- }
- break;
- case CmdType.Stop://风机在运行状态,启动状态才能进行停机操作
- //风机状态为并网,且任务队列中没有的风机编号,为允许操作的风机
- allowList = infoList.Where(s => cacheDataList.Where(r => r.Status == WindturbineStatus.Online || r.Status == WindturbineStatus.Start).ToList().Select(t => t.WindturbineName).Contains(s.WindturbineId)).ToList().Where(k => !TaskQueueSvc.dicTask.ContainsKey(k.WindturbineId)).ToList().Where(m => !lockWindturbineId.Contains(m.WindturbineId)).ToList();
- //操作过频繁的风机
- busyList = infoList.Where(s => TaskQueueSvc.dicTask.ContainsKey(s.WindturbineId)).ToList();
- //排除状态允许操作,且操作过频繁的风机
- forbidenList = infoList.Except(allowList).ToList().Union(busyList).ToList();
- for (int i = 0; i < forbidenList.Count; i++)
- {
- if (busyList.Contains(forbidenList[i]))
- forbidenList[i].ForbidenDescription = "风机操作过于频繁";
- else if (lockWindturbineId.Contains(forbidenList[i].WindturbineId))
- forbidenList[i].ForbidenDescription = "风机已被挂牌";
- else
- forbidenList[i].ForbidenDescription = "风机只有在运行状态才能进行停机操作";
- }
- break;
- case CmdType.Maintain://风机在待机状态下才可以进行维护
- allowList = infoList.Where(s => cacheDataList.Where(r => r.Status == WindturbineStatus.Standby).ToList().Select(t => t.WindturbineName).Contains(s.WindturbineId)).ToList().Where(k => !TaskQueueSvc.dicTask.ContainsKey(k.WindturbineId)).ToList().Where(m => !lockWindturbineId.Contains(m.WindturbineId)).ToList();
- //操作过频繁的风机
- busyList = infoList.Where(s => TaskQueueSvc.dicTask.ContainsKey(s.WindturbineId)).ToList();
- //排除状态允许操作,且操作过频繁的风机
- forbidenList = infoList.Except(allowList).ToList();
- for (int i = 0; i < forbidenList.Count; i++)
- {
- if (busyList.Contains(forbidenList[i]))
- forbidenList[i].ForbidenDescription = "风机操作过于频繁";
- else if (lockWindturbineId.Contains(forbidenList[i].WindturbineId))
- forbidenList[i].ForbidenDescription = "风机已被挂牌";
- else
- forbidenList[i].ForbidenDescription = "风机只有在非运行,非离线状态下才可以进行维护";
- }
- break;
- case CmdType.UnMaintain://风机在维护状态下才可以进行取消维护
- allowList = infoList.Where(s => cacheDataList.Where(r => r.Status == WindturbineStatus.Maintain).ToList().Select(t => t.WindturbineName).Contains(s.WindturbineId)).ToList().Where(k => !TaskQueueSvc.dicTask.ContainsKey(k.WindturbineId)).ToList().Where(m => !lockWindturbineId.Contains(m.WindturbineId)).ToList();
- //操作过频繁的风机
- busyList = infoList.Where(s => TaskQueueSvc.dicTask.ContainsKey(s.WindturbineId)).ToList();
- //排除状态允许操作,且操作过频繁的风机
- forbidenList = infoList.Except(allowList).ToList();
- for (int i = 0; i < forbidenList.Count; i++)
- {
- if (busyList.Contains(forbidenList[i]))
- forbidenList[i].ForbidenDescription = "风机操作过于频繁";
- else if (lockWindturbineId.Contains(forbidenList[i].WindturbineId))
- forbidenList[i].ForbidenDescription = "风机已被挂牌";
- else
- forbidenList[i].ForbidenDescription = "风机只有在维护状态下才可以进行取消维护";
- }
- break;
- case CmdType.Reset://只有故障状态的的风机才能进行复位,且故障不为12种主要故障
- allowList = infoList.Where(s => cacheDataList.Where(r => r.Status == WindturbineStatus.Fault).ToList().Select(t => t.WindturbineName).Contains(s.WindturbineId)).ToList().Where(k => !TaskQueueSvc.dicTask.ContainsKey(k.WindturbineId)).ToList().Where(m => !lockWindturbineId.Contains(m.WindturbineId)).ToList();
- //操作过频繁的风机
- busyList = infoList.Where(s => TaskQueueSvc.dicTask.ContainsKey(s.WindturbineId)).ToList();
- //排除状态允许操作,且操作过频繁的风机
- forbidenList = infoList.Except(allowList).ToList();
- for (int i = 0; i < forbidenList.Count; i++)
- {
- if (busyList.Contains(forbidenList[i]))
- forbidenList[i].ForbidenDescription = "风机操作过于频繁";
- else if (lockWindturbineId.Contains(forbidenList[i].WindturbineId))
- forbidenList[i].ForbidenDescription = "风机已被挂牌";
- else
- forbidenList[i].ForbidenDescription = "风机只有在故障状态才能进行复位,且故障不为12种主要故障";
- }
- break;
- default: break;
- }
- allowTable = GetAllowTable(allowList);
- forbidenTable = GetForbidenTable(forbidenList);
- return allowList;
- #endregion
- }
- public DataTable GetAllowTable(IList<WindturbineCmdInfo> infoList)
- {
- DataTable dataTable = new DataTable();
- dataTable.Columns.Add("风机名称");
- dataTable.Columns.Add("风速");
- dataTable.Columns.Add("功率");
- dataTable.Columns.Add("状态");
- dataTable.Columns.Add("电机转速");
- dataTable.Columns.Add("叶轮转速");
- dataTable.Columns.Add("桨叶角度1");
- dataTable.Columns.Add("桨叶角度2");
- dataTable.Columns.Add("桨叶角度3");
- for (int i = 0; i < infoList.Count; i++)
- {
- if (CacheInfo.CacheWindturbineDataDic.ContainsKey(infoList[i].WindturbineId))
- {
- WindturbinePointData data = CacheInfo.CacheWindturbineDataDic[infoList[i].WindturbineId];
- if (data != null)
- {
- DataRow row = dataTable.NewRow();
- row["风机名称"] = data.WindturbineName;
- row["风速"] = data.WindSpeed.ToString("f2") + "m/s";
- row["功率"] = data.Power.ToString("f2") + "kW";
- #region 风机状态
- switch (data.Status)
- {
- case WindturbineStatus.Standby:
- row["状态"] = "待机";
- break;
- case WindturbineStatus.Online:
- row["状态"] = "并网";
- break;
- case WindturbineStatus.Maintain:
- row["状态"] = "维护";
- break;
- case WindturbineStatus.Fault:
- row["状态"] = "故障";
- break;
- case WindturbineStatus.Offline:
- row["状态"] = "离线";
- break;
- case WindturbineStatus.Start:
- row["状态"] = "启动";
- break;
- case WindturbineStatus.OnPower:
- row["状态"] = "上电";
- break;
- case WindturbineStatus.Stop:
- row["状态"] = "停机";
- break;
- }
- #endregion
- row["电机转速"] = data.AlternatorSpeed.ToString("f2") + "rpm";
- row["叶轮转速"] = data.LaminaSpeed.ToString("f2") + "rpm";
- row["桨叶角度1"] = data.LaminaAngle1.ToString("f2") + "°";
- row["桨叶角度2"] = data.LaminaAngle2.ToString("f2") + "°";
- row["桨叶角度3"] = data.LaminaAngle3.ToString("f2") + "°";
- dataTable.Rows.Add(row);
- }
- }
- }
- return dataTable;
- }
- public DataTable GetForbidenTable(IList<WindturbineCmdInfo> infoList)
- {
- DataTable dataTable = new DataTable();
- dataTable.Columns.Add("风机名称");
- dataTable.Columns.Add("原因");
- for (int i = 0; i < infoList.Count; i++)
- {
- DataRow row = dataTable.NewRow();
- row["风机名称"] = infoList[i].WindturbineId;
- row["原因"] = infoList[i].ForbidenDescription;
- dataTable.Rows.Add(row);
- }
- return dataTable;
- }
- public DataTable GetControlOverTable(IList<WindturbineCmdInfo> list, out DataTable unSuccessTable)
- {
- IList<WindturbineCmdInfo> successList = list.Where(s => s.IsSuccessSend == true).ToList();
- IList<WindturbineCmdInfo> unSuccessList = list.Except(successList).ToList();
- DataTable successDataTable = new DataTable();
- unSuccessTable = new DataTable();
- #region 操作成功数据
- successDataTable.Columns.Add("风机名称");
- successDataTable.Columns.Add("风速");
- successDataTable.Columns.Add("功率");
- successDataTable.Columns.Add("状态");
- successDataTable.Columns.Add("电机转速");
- successDataTable.Columns.Add("叶轮转速");
- successDataTable.Columns.Add("桨叶角度1");
- successDataTable.Columns.Add("桨叶角度2");
- successDataTable.Columns.Add("桨叶角度3");
- for (int i = 0; i < successList.Count; i++)
- {
- WindturbinePointData data = CacheInfo.CacheWindturbineDataList.Where(s => s.WindturbineName == successList[i].WindturbineId)
- .FirstOrDefault();
- if (data != null)
- {
- DataRow row = successDataTable.NewRow();
- row["风机名称"] = data.WindturbineName;
- row["风速"] = data.WindSpeed.ToString("f2") + "m/s";
- row["功率"] = data.Power.ToString("f2") + "kW";
- row["状态"] = data.Status;
- row["发电机转速"] = data.AlternatorSpeed.ToString("f2") + "rpm";
- row["叶轮转速"] = data.LaminaSpeed.ToString("f2") + "rpm";
- row["桨叶角度1"] = data.LaminaAngle1.ToString("f2") + "°";
- row["桨叶角度2"] = data.LaminaAngle2.ToString("f2") + "°";
- row["桨叶角度3"] = data.LaminaAngle3.ToString("f2") + "°";
- successDataTable.Rows.Add(row);
- }
- }
- #endregion
- #region 操作失败数据
- unSuccessTable.Columns.Add("风机名称");
- unSuccessTable.Columns.Add("风速");
- unSuccessTable.Columns.Add("功率");
- unSuccessTable.Columns.Add("状态");
- unSuccessTable.Columns.Add("电机转速");
- unSuccessTable.Columns.Add("叶轮转速");
- unSuccessTable.Columns.Add("桨叶角度1");
- unSuccessTable.Columns.Add("桨叶角度2");
- unSuccessTable.Columns.Add("桨叶角度3");
- for (int i = 0; i < unSuccessList.Count; i++)
- {
- WindturbinePointData data = CacheInfo.CacheWindturbineDataList.Where(s => s.WindturbineName == unSuccessList[i].WindturbineId)
- .FirstOrDefault();
- if (data != null)
- {
- DataRow row = unSuccessTable.NewRow();
- row["风机名称"] = data.WindturbineName;
- row["风速"] = data.WindSpeed.ToString("f2") + "m/s";
- row["功率"] = data.Power.ToString("f2") + "kW";
- row["状态"] = data.Status;
- row["电机转速"] = data.AlternatorSpeed.ToString("f2") + "rpm";
- row["叶轮转速"] = data.LaminaSpeed.ToString("f2") + "rpm";
- row["桨叶角度1"] = data.LaminaAngle1.ToString("f2") + "°";
- row["桨叶角度2"] = data.LaminaAngle2.ToString("f2") + "°";
- row["桨叶角度3"] = data.LaminaAngle3.ToString("f2") + "°";
- unSuccessTable.Rows.Add(row);
- }
- }
- #endregion
- return successDataTable;
- }
- }
- }
|