设备异常总停机时长

This commit is contained in:
chenlin 2026-01-27 17:24:07 +08:00
parent 26009b842e
commit 916ebf0da5
2 changed files with 9 additions and 2 deletions

View File

@ -89,6 +89,11 @@ namespace DOAN.Model.MES.report
/// 停机率
/// </summary>
public double DowntimeRate { get; set; }
/// <summary>
/// 停机总时长
/// </summary>
public double TotalDowntimeHours { get; set; }
}
public class ProductionCompletionModel

View File

@ -125,7 +125,8 @@ namespace DOAN.Service.MES.report
it.EndTime,
DowntimeHours = (it.EndTime.Value - it.StartTime.Value).TotalHours,
}).ToList();
var totalDowntimeHours = response.Sum(it => it.DowntimeHours);
var groupList = response.GroupBy(it => it.LineCode).Select(it => new
{
LineCode = it.Key,
@ -141,7 +142,8 @@ namespace DOAN.Service.MES.report
LineName = l.LineName,
PlanHours = l.PlanHours,
DowntimeHours = gList.FirstOrDefault()?.DowntimeHours ?? 0, // 如果没有停机时间则为0
DowntimeRate = l.PlanHours == 0 ? 0 : Math.Round((gList.FirstOrDefault()?.DowntimeHours ?? 0) / l.PlanHours, 2)
DowntimeRate = l.PlanHours == 0 ? 0 : Math.Round((gList.FirstOrDefault()?.DowntimeHours ?? 0) / l.PlanHours, 2),
TotalDowntimeHours = totalDowntimeHours
}).ToList();
return result;
}