123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace GDNXFD.Data
- {
- public class AlertSnapFactory
- {
- public static AlertSnap CreateAlertSnap(AlertRule ar)
- {
- AlertSnap snap = new AlertSnap();
- snap.Id = 0;// Guid.NewGuid().ToString();
- snap.AlertText = ar.Name.Trim();
- snap.AlertValue = ar.EdnaValue;
- snap.Category1 = "custom";
- snap.Category2 = ar.Category;
- snap.Rank = ar.Rank;
- snap.LastUpdatePerson = "system";
- snap.LastUpdateTime = DateTime.Now;
- return snap;
- }
- public static AlertSnap CreateAlertSnap(AlertRule ar, WindPowerStation wps)
- {
- AlertSnap snap = CreateAlertSnap(ar);
- snap.StationId = wps.Id;
- snap.StationName = wps.Name;
- return snap;
- }
- public static AlertSnap CreateAlertSnap(AlertRule ar, Project obj)
- {
- AlertSnap snap = CreateAlertSnap(ar);
- snap.ProjectId = obj.Id;
- snap.ProjectName = obj.Name;
- snap.StationId = obj.WindPowerStationId;
- WindPowerStation wps = DataCache.Instance.GetWindPowerStationByID(obj.WindPowerStationId);
- if (wps != null)
- snap.StationName = wps.Name;
- return snap;
- }
- public static AlertSnap CreateAlertSnap(AlertRule ar, Line obj)
- {
- AlertSnap snap = CreateAlertSnap(ar);
- snap.LineId = obj.Id;
- snap.LineName = obj.Name;
- snap.ProjectId = obj.ProjectId;
- Project prj = DataCache.Instance.GetProjectsByID(obj.ProjectId);
- if (prj != null)
- snap.ProjectName = prj.Name;
- snap.StationId = prj.WindPowerStationId;
- WindPowerStation wps = DataCache.Instance.GetWindPowerStationByID(prj.WindPowerStationId);
- snap.StationName = wps.Name;
- if (wps != null)
- snap.StationName = wps.Name;
- return snap;
- }
- public static AlertSnap CreateAlertSnap(AlertRule ar, WindTurbine obj)
- {
- AlertSnap snap = CreateAlertSnap(ar);
- snap.WindturbineId = obj.Id;
- snap.WindturbineName = obj.Name;
- snap.LineId = obj.LineId;
- snap.ModelId = obj.ModelId;
- Line ln = DataCache.Instance.GetLinesByID(obj.LineId);
- if (ln != null)
- snap.LineName = ln.Name;
- snap.ProjectId = obj.ProjectId;
- Project prj = DataCache.Instance.GetProjectsByID(obj.ProjectId);
- if (prj != null)
- snap.ProjectName = prj.Name;
- snap.StationId = obj.WindPowerStationId;
- WindPowerStation wps = DataCache.Instance.GetWindPowerStationByID(prj.WindPowerStationId);
- if (wps != null)
- snap.StationName = wps.Name;
- return snap;
- }
- public static AlertSnap CreateAlertSnap(Warning ar)
- {
- AlertSnap snap = new AlertSnap();
- snap.Id = 0;// Guid.NewGuid().ToString();
- snap.AlertText = ar.EnglishText.Trim();
- snap.AlertValue = ar.EDnaValue;
- snap.Category1 = "windturbine";
- snap.Category2 = ar.WarningClassifyId;
- snap.Rank = CommonMethod.ConvertWindturbineAlertRank(ar.LevelID);
- snap.LastUpdatePerson = "system";
- snap.LastUpdateTime = DateTime.Now;
- return snap;
- }
- public static AlertSnap CreateAlertSnap(Warning ar, WindTurbine obj)
- {
- AlertSnap snap = CreateAlertSnap(ar);
- snap.WindturbineId = obj.Id;
- snap.WindturbineName = obj.Name;
- snap.LineId = obj.LineId;
- snap.ModelId = obj.ModelId;
- Line ln = DataCache.Instance.GetLinesByID(obj.LineId);
- if (ln != null)
- snap.LineName = ln.Name;
- snap.ProjectId = obj.ProjectId;
- Project prj = DataCache.Instance.GetProjectsByID(obj.ProjectId);
- if (prj != null)
- snap.ProjectName = prj.Name;
- snap.StationId = obj.WindPowerStationId;
- WindPowerStation wps = DataCache.Instance.GetWindPowerStationByID(prj.WindPowerStationId);
- if (wps != null)
- snap.StationName = wps.Name;
- return snap;
- }
- public static AlertSnap CreateAlertSnap(IFixBJTestingPointDI ar)
- {
- AlertSnap snap = new AlertSnap();
- snap.Id = 0;// Guid.NewGuid().ToString();
- snap.AlertText = ar.Description.Trim();
- //snap.AlertValue = ar.EDnaValue;
- snap.Category1 = ar.Area1;
- if (ar.Area1 == "GF")
- snap.Category2 = "NBQ";
- else
- snap.Category2 = ar.Area3;
- //snap.Category3 = ar.Area2;
- snap.Rank = CommonMethod.ConvertIFixAlertRank(ar.LevelId);
- snap.LastUpdatePerson = "system";
- snap.LastUpdateTime = DateTime.Now;
- snap.TestingPointKey = ar.PointKey;
- snap.StationId = ar.StationId;
- snap.IFixPicture = ar.AlmExt1;
- snap.IFixTag = ar.AlmExt2;
- var obj = DataCache.Instance.DictStation2[ar.StationId] as WindPowerStation;
- if (obj != null)
- snap.StationName = obj.Name;
- return snap;
- }
- public static AlertHistory CreateAlertHistory(AlertSnap snap)
- {
- AlertHistory his = new AlertHistory();
- his.Id = 0;// Guid.NewGuid().ToString();
- his.SnapID = snap.Id;
- his.AlertTime = snap.LastUpdateTime == null ? (DateTime)snap.LastUpdateTime : DateTime.Now;
- his.ObjectId = snap.LastUpdatePerson;
- his.DataInfo = snap.DataInfo;
- if (snap.IsConfirmed)
- his.MessageType = "2"; //确认报警
- else if (snap.IsOpened)
- his.MessageType = "1"; //触发报警
- else
- {
- his.MessageType = "3"; //解除报警
- his.AlertTime = snap.LastCloseTime == null ? (DateTime)snap.LastCloseTime : DateTime.Now;
- his.ObjectId = snap.LastClosePerson;
- }
- return his;
- }
- }
- }
|