设备停机率

This commit is contained in:
chenlin 2026-01-23 15:30:37 +08:00
parent 5a694f7288
commit 146747a1ed

View File

@ -39,7 +39,7 @@ namespace DOAN.Service.MES.report
public List<DevicePoweronRateModel> DevicePoweronRate(DateTime dateTime)
{
List<DevicePoweronRateModel> list = new List<DevicePoweronRateModel>();
var response = Context.Queryable<BaseWorkRoute>().ToList();
var response = Context.Queryable<BaseWorkRoute>().OrderBy(t => t.Id).ToList();
var dt = dateTime.ToString("yyyy-MM-dd");
var shiftList = Context.Queryable<GroupSchedule>()
@ -113,15 +113,15 @@ namespace DOAN.Service.MES.report
List<DeviceDowntimeRateModel> list = new List<DeviceDowntimeRateModel>();
var dt = dateTime.ToString("yyyy-MM-dd");
list = Context.Queryable<ProWorkorder>()
.InnerJoin<BaseWorkRoute>((a, b) => a.LineCode == b.Code)
.Where((a, b) => a.WorkorderDate.Value.ToString("yyyy-MM-dd") == dt)
list = Context.Queryable<BaseWorkRoute>()
.LeftJoin<ProWorkorder>((a, b) => a.Code == b.LineCode && b.WorkorderDate.Value.ToString("yyyy-MM-dd") == dt)
.OrderBy((a,b)=>a.Id)
.Select((a, b) =>
new DeviceDowntimeRateModel
{
LineCode = b.Code,
LineName = b.Name,
PlanHours = SqlFunc.Round((a.Beat * a.DeliveryNum ?? 0) / 3600.0,2)
LineCode = a.Code,
LineName = a.Name,
PlanHours = SqlFunc.Round((b.Beat * b.DeliveryNum ?? 0) / 3600.0, 2)
}).ToList();
var response = Context.Queryable<AndonFaultRecord>()
@ -148,16 +148,14 @@ namespace DOAN.Service.MES.report
LineCode = l.LineCode,
LineName = l.LineName,
PlanHours = l.PlanHours,
DowntimeHours = gList.FirstOrDefault()?.DowntimeHours ?? l.PlanHours, // 如果没有停机时间则为计划时间
DowntimeRate= Math.Round((gList.FirstOrDefault()?.DowntimeHours ?? l.PlanHours) / l.PlanHours, 2)
DowntimeHours = gList.FirstOrDefault()?.DowntimeHours ?? 0, // 如果没有停机时间则为0
DowntimeRate = l.PlanHours == 0 ? 0 : Math.Round((gList.FirstOrDefault()?.DowntimeHours ?? 0) / l.PlanHours, 2)
}).ToList();
return result;
}
public List<ProductionCompletionRate> ProductionCompletionRate(DateTime dateTime)
{
//dateTime = new DateTime(2025, 11, 2);
List<ProductionCompletionRate> list = new List<ProductionCompletionRate>();
var dt = dateTime.ToString("yyyy-MM-dd");