Exemple #1
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;
        }
Exemple #2
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.正常);
 }