Пример #1
0
        /// <summary>
        ///     创建发动机滑油消耗数据
        /// </summary>
        /// <param name="engineReg">发动机</param>
        /// <param name="date">日期</param>
        /// <param name="tsn">TSN</param>
        /// <param name="tsr">TSR</param>
        /// <param name="totalRate">总消耗率</param>
        /// <param name="intervalRate">区间消耗率</param>
        /// <param name="deltaIntervalRate">区间消耗率增量</param>
        /// <returns>滑油消耗数据</returns>
        public static OilMonitor CreateEngineOil(
            EngineReg engineReg,
            DateTime date,
            decimal tsn,
            decimal tsr,
            decimal totalRate,
            decimal intervalRate,
            decimal deltaIntervalRate)
        {
            var oilMonitor = new OilMonitor
            {
                Date = date,
                TSN = tsn,
                TSR = tsr,
                TotalRate = totalRate,
                IntervalRate = intervalRate,
                DeltaIntervalRate = deltaIntervalRate,
            };
            oilMonitor.GenerateNewIdentity();

            var user = oilMonitor.SetEngineOil(engineReg);
            if (!user.NeedMonitor)
                user.NeedMonitor = true;

            return oilMonitor;
        }
Пример #2
0
        /// <summary>
        ///     创建发动机序号件
        /// </summary>
        /// <param name="installDate">初始安装日期</param>
        /// <param name="pnReg">附件</param>
        /// <param name="thrust"></param>
        /// <param name="sn">序号</param>
        /// <returns>发动机序号件</returns>
        public static EngineReg CreateEngineReg(
            DateTime installDate,
            PnReg pnReg,
            Thrust thrust,
            string sn)
        {
            var engineReg = new EngineReg
            {
                InstallDate = installDate,
                Sn = sn,
            };
            engineReg.GenerateNewIdentity();
            engineReg.SetPnReg(pnReg);
            engineReg.SetThrust(thrust);
            engineReg.SetSnStatus(SnStatus.装机);
            engineReg.SetIsLife(false, false, 0, 0);
            engineReg.SetMonitorStatus((OilMonitorStatus.正常));
            engineReg.CreateDate = DateTime.Now;
            engineReg.UpdateDate = DateTime.Now;

            return engineReg;
        }
Пример #3
0
        /// <summary>
        ///     设置发动机滑油用户
        /// </summary>
        /// <param name="snReg">发动机滑油用户</param>
        /// <returns>滑油用户</returns>
        public EngineReg SetEngineOil(EngineReg snReg)
        {
            if (snReg == null || snReg.IsTransient())
            {
                throw new ArgumentException("发动机滑油用户参数为空!");
            }

            SnRegID = snReg.Id;
            return snReg;
        }
Пример #4
0
        /// <summary>
        ///     更新发动机序号件
        /// </summary>
        /// <param name="installDate">初始安装日期</param>
        /// <param name="pnReg">附件</param>
        /// <param name="thrust"></param>
        /// <param name="sn">序号</param>
        /// <returns>发动机序号件</returns>
        public static EngineReg UpdateEngineReg(
            DateTime installDate,
            PnReg pnReg,
            Thrust thrust,
            string sn)
        {
            var engineReg = new EngineReg
            {
                InstallDate = installDate,
                Sn = sn,
            };
            engineReg.GenerateNewIdentity();
            engineReg.SetPnReg(pnReg);
            engineReg.SetThrust(thrust);
            engineReg.UpdateDate = DateTime.Now;

            return engineReg;
        }
Пример #5
0
 /// <summary>
 ///     设置发动机滑油监控状态
 /// </summary>
 /// <param name="engineReg">发动机序号件</param>
 private void SetEngineOilStatus(EngineReg engineReg)
 {
     var threshold = _unitOfWork.CreateSet<Threshold>().FirstOrDefault(t => t.PnRegId == engineReg.PnRegId);
     if (threshold == null) return;
     var weekOils =
         _unitOfWork.CreateSet<OilMonitor>()
             .Where(o => o.SnRegID == engineReg.Id && o.Date > DateTime.Today.AddDays(-8));
     if (
         weekOils.Any(
             o =>
                 o.TotalRate > threshold.TotalThreshold || o.IntervalRate > threshold.IntervalThreshold ||
                 o.DeltaIntervalRate > threshold.DeltaIntervalThreshold ||
                 o.AverageRate3 > threshold.Average3Threshold || o.AverageRate7 > threshold.Average7Threshold))
     {
         engineReg.SetMonitorStatus(OilMonitorStatus.警告);
         return;
     }
     var monthOils =
         _unitOfWork.CreateSet<OilMonitor>()
             .Where(o => o.SnRegID == engineReg.Id && o.Date > DateTime.Today.AddDays(-31));
     if (
         monthOils.Any(
             o =>
                 o.TotalRate > threshold.TotalThreshold || o.IntervalRate > threshold.IntervalThreshold ||
                 o.DeltaIntervalRate > threshold.DeltaIntervalThreshold ||
                 o.AverageRate3 > threshold.Average3Threshold || o.AverageRate7 > threshold.Average7Threshold))
     {
         engineReg.SetMonitorStatus(OilMonitorStatus.关注);
         return;
     }
     engineReg.SetMonitorStatus(OilMonitorStatus.正常);
 }
Пример #6
0
 /// <summary>
 ///     创建发动机滑油监控记录。
 /// </summary>
 /// <remarks>
 ///     对每一台发动机,自滑油监控最后一条记录至当天,每天计算一条监控记录。
 ///     初始的时候,从最近一次装上开始计算。
 /// </remarks>
 /// <param name="lastTSR">最近一次装上记录</param>
 /// <param name="engineReg">发动机</param>
 /// <param name="flights">最近一次装上以来的飞行日志集合</param>
 private List<OilMonitor> CreateEngineOils(SnHistory lastTSR, EngineReg engineReg,
     IReadOnlyList<FlightLog> flights)
 {
     if (lastTSR == null) throw new ArgumentNullException("lastTSR");
     var oilMonitors = new List<OilMonitor>();
     // 开始计算日期
     var startDate = GetStartDate(lastTSR, flights);
     if (!flights.Any()) return oilMonitors;
     // 计算截止日期,飞行日志最后一天的次日,最后一天为当天的则为当天。
     var endDate = flights.Last().FlightDate.Date == DateTime.Today
         ? DateTime.Today
         : flights.Last().FlightDate.Date.AddDays(1);
     while (endDate.Subtract(startDate).TotalDays > 0)
     {
         decimal qsr, interval, deltaInterval, lastInterval;
         var tsr = flights.TakeWhile(f => f.FlightDate < startDate.AddDays(1)).Sum(f => f.FlightHours);
         switch (lastTSR.Position)
         {
             case Position.发动机1:
                 qsr =
                     flights.TakeWhile(f => f.FlightDate < startDate.AddDays(1))
                         .Sum(f => f.ENG1OilDep + f.ENG1OilArr);
                 lastInterval =
                     _unitOfWork.CreateSet<OilMonitor>()
                         .Where(o => o.IntervalRate > 0)
                         .Select(o => o.IntervalRate)
                         .FirstOrDefault();
                 CalIntervalOil(
                     flights.Select(
                         f => Tuple.Create(f.FlightDate, f.TakeOff, f.ENG1OilDep, f.ENG1OilArr, f.FlightHours))
                         .ToList(), startDate, out interval);
                 deltaInterval = lastInterval > 0 ? interval - lastInterval : 0;
                 oilMonitors.Add(CreateEngineOil(lastTSR, engineReg, startDate, tsr, qsr, interval, deltaInterval));
                 break;
             case Position.发动机2:
                 qsr =
                     flights.TakeWhile(f => f.FlightDate < startDate.AddDays(1))
                         .Sum(f => f.ENG2OilDep + f.ENG2OilArr);
                 lastInterval =
                     _unitOfWork.CreateSet<OilMonitor>()
                         .Where(o => o.IntervalRate > 0)
                         .Select(o => o.IntervalRate)
                         .FirstOrDefault();
                 CalIntervalOil(
                     flights.Select(
                         f => Tuple.Create(f.FlightDate, f.TakeOff, f.ENG2OilDep, f.ENG2OilArr, f.FlightHours))
                         .ToList(), startDate, out interval);
                 deltaInterval = lastInterval > 0 ? interval - lastInterval : 0;
                 oilMonitors.Add(CreateEngineOil(lastTSR, engineReg, startDate, tsr, qsr, interval, deltaInterval));
                 break;
             case Position.发动机3:
                 qsr =
                     flights.TakeWhile(f => f.FlightDate < startDate.AddDays(1))
                         .Sum(f => f.ENG3OilDep + f.ENG3OilArr);
                 lastInterval =
                     _unitOfWork.CreateSet<OilMonitor>()
                         .Where(o => o.IntervalRate > 0)
                         .Select(o => o.IntervalRate)
                         .FirstOrDefault();
                 CalIntervalOil(
                     flights.Select(
                         f => Tuple.Create(f.FlightDate, f.TakeOff, f.ENG3OilDep, f.ENG3OilArr, f.FlightHours))
                         .ToList(), startDate, out interval);
                 deltaInterval = lastInterval > 0 ? interval - lastInterval : 0;
                 oilMonitors.Add(CreateEngineOil(lastTSR, engineReg, startDate, tsr, qsr, interval, deltaInterval));
                 break;
             case Position.发动机4:
                 qsr =
                     flights.TakeWhile(f => f.FlightDate < startDate.AddDays(1))
                         .Sum(f => f.ENG4OilDep + f.ENG4OilArr);
                 lastInterval =
                     _unitOfWork.CreateSet<OilMonitor>()
                         .Where(o => o.IntervalRate > 0)
                         .Select(o => o.IntervalRate)
                         .FirstOrDefault();
                 CalIntervalOil(
                     flights.Select(
                         f => Tuple.Create(f.FlightDate, f.TakeOff, f.ENG4OilDep, f.ENG4OilArr, f.FlightHours))
                         .ToList(), startDate, out interval);
                 deltaInterval = lastInterval > 0 ? interval - lastInterval : 0;
                 oilMonitors.Add(CreateEngineOil(lastTSR, engineReg, startDate, tsr, qsr, interval, deltaInterval));
                 break;
             default:
                 throw new ArgumentOutOfRangeException();
         }
         startDate = startDate.AddDays(1);
     }
     return oilMonitors;
 }
Пример #7
0
 /// <summary>
 ///     创建发动机滑油监控记录。
 /// </summary>
 /// <param name="lastTSR">最近一次装上记录</param>
 /// <param name="engineReg">发动机</param>
 /// <param name="calDate">计算日期</param>
 /// <param name="tsr">自上一次装上以来飞行时间</param>
 /// <param name="qsr">自上一次装上以来滑油添加总量</param>
 /// <param name="interval">区间滑油消耗率</param>
 /// <param name="deltaInterval">区间滑油消耗率变化量</param>
 /// <returns>滑油监控记录</returns>
 private static OilMonitor CreateEngineOil(SnHistory lastTSR, EngineReg engineReg, DateTime calDate, decimal tsr,
     decimal qsr, decimal interval, decimal deltaInterval)
 {
     var tsn = lastTSR.TSN + tsr;
     var toc = tsr == 0 ? 0 : Math.Round(qsr/tsr, 4);
     var oilMonitor = OilMonitorFactory.CreateEngineOil(engineReg, calDate, tsn, tsr, toc, interval,
         deltaInterval);
     return oilMonitor;
 }