设备停机率
This commit is contained in:
parent
dc37fe2496
commit
6f4d0efdff
@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace DOAN.WebApi.Controllers
|
||||
{
|
||||
[Verify]
|
||||
//[Verify]
|
||||
[Route("mes/reportManagement/report")]
|
||||
[ApiExplorerSettings(GroupName = "MES")]
|
||||
public class ReportController : BaseController
|
||||
@ -27,19 +27,32 @@ namespace DOAN.WebApi.Controllers
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("listMonth")]
|
||||
//[ActionPermissionFilter(Permission = "productManagement:proplanachievementrate:list")]
|
||||
public IActionResult QueryMonthProuct([FromQuery] MonthProuctDto parm)
|
||||
{
|
||||
var response = _ProPlanAchievementrateVersion2Service.GetQueryMonthProucth(parm);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设备开机率
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("devicePoweronRate")]
|
||||
//[ActionPermissionFilter(Permission = "productManagement:proplanachievementrate:list")]
|
||||
public IActionResult DevicePoweronRate()
|
||||
{
|
||||
var response = _ReportService.DevicePoweronRate(DateTime.Today);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设备停机率
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("deviceDowntimeRate")]
|
||||
public IActionResult DeviceDowntimeRate()
|
||||
{
|
||||
var response = _ReportService.DeviceDowntimeRate(DateTime.Today);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,4 +66,28 @@ namespace DOAN.Model.MES.report
|
||||
/// </summary>
|
||||
public double PoweronRate { get; set; }
|
||||
}
|
||||
|
||||
public class DeviceDowntimeRateModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 产线编码
|
||||
/// </summary>
|
||||
public string LineCode { get; set; }
|
||||
/// <summary>
|
||||
/// 产线名称
|
||||
/// </summary>
|
||||
public string LineName { get; set; }
|
||||
/// <summary>
|
||||
/// 运行时长
|
||||
/// </summary>
|
||||
public double PlanHours { get; set; }
|
||||
/// <summary>
|
||||
/// 停机时长
|
||||
/// </summary>
|
||||
public double DowntimeHours { get; set; }
|
||||
/// <summary>
|
||||
/// 停机率
|
||||
/// </summary>
|
||||
public double DowntimeRate { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,5 +15,6 @@ namespace DOAN.Service.MES.report.IService
|
||||
public interface IReportService : IBaseService<BaseWorkRoute>
|
||||
{
|
||||
List<DevicePoweronRateModel> DevicePoweronRate(DateTime dateTime);
|
||||
List<DeviceDowntimeRateModel> DeviceDowntimeRate(DateTime dateTime);
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,6 +28,7 @@ using DOAN.Model.MES.group;
|
||||
using System.Xml.Linq;
|
||||
using Aliyun.OSS;
|
||||
using AlibabaCloud.SDK.Dingtalkdoc_1_0.Models;
|
||||
using DOAN.Model.MES.andon;
|
||||
|
||||
namespace DOAN.Service.MES.report
|
||||
{
|
||||
@ -105,5 +106,52 @@ namespace DOAN.Service.MES.report
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<DeviceDowntimeRateModel> DeviceDowntimeRate(DateTime dateTime)
|
||||
{
|
||||
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)
|
||||
.Select((a, b) =>
|
||||
new DeviceDowntimeRateModel
|
||||
{
|
||||
LineCode = b.Code,
|
||||
LineName = b.Name,
|
||||
PlanHours = SqlFunc.Round((a.Beat * a.DeliveryNum ?? 0) / 3600.0,2)
|
||||
}).ToList();
|
||||
|
||||
var response = Context.Queryable<AndonFaultRecord>()
|
||||
.Where(t=>t.FaultDict== "设备异常" && t.StartTime.HasValue && t.EndTime.HasValue && t.EndTime.Value.ToString("yyyy-MM-dd") ==dt)
|
||||
.Select(it => new
|
||||
{
|
||||
it.LineCode,
|
||||
it.StartTime,
|
||||
it.EndTime,
|
||||
DowntimeHours = (it.EndTime.Value - it.StartTime.Value).TotalHours,
|
||||
}).ToList();
|
||||
|
||||
var groupList = response.GroupBy(it => it.LineCode).Select(it => new
|
||||
{
|
||||
LineCode = it.Key,
|
||||
DowntimeHours = it.ToList().Sum(t=>t.DowntimeHours)
|
||||
}).ToList();
|
||||
|
||||
var result = list.GroupJoin(groupList,
|
||||
l => l.LineCode,
|
||||
g => g.LineCode,
|
||||
(l, gList) => new DeviceDowntimeRateModel
|
||||
{
|
||||
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)
|
||||
}).ToList();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user