/// <summary> /// 创建APU序号件 /// </summary> /// <param name="installDate">初始安装日期</param> /// <param name="pnReg">附件</param> /// <param name="sn">序号</param> /// <returns>APU序号件</returns> public static APUReg CreateAPUReg( DateTime installDate, PnReg pnReg, string sn) { var apuReg = new APUReg { InstallDate = installDate, Sn = sn, }; apuReg.GenerateNewIdentity(); apuReg.SetPnReg(pnReg); apuReg.SetSnStatus(SnStatus.装机); apuReg.SetIsLife(false, false, 0, 0); apuReg.SetMonitorStatus((OilMonitorStatus.正常)); apuReg.CreateDate = DateTime.Now; apuReg.UpdateDate = DateTime.Now; return apuReg; }
/// <summary> /// 设置APU滑油监控状态 /// </summary> /// <param name="apuReg">APU序号件</param> private void SetAPUOilStatus(APUReg apuReg) { var threshold = _unitOfWork.CreateSet<Threshold>().FirstOrDefault(t => t.PnRegId == apuReg.PnRegId); if (threshold == null) return; var weekOils = _unitOfWork.CreateSet<OilMonitor>() .Where(o => o.SnRegID == apuReg.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)) { apuReg.SetMonitorStatus(OilMonitorStatus.警告); return; } var monthOils = _unitOfWork.CreateSet<OilMonitor>() .Where(o => o.SnRegID == apuReg.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)) { apuReg.SetMonitorStatus(OilMonitorStatus.关注); return; } apuReg.SetMonitorStatus(OilMonitorStatus.正常); }