设备开机停机率增加时间段查询
This commit is contained in:
parent
cd45025324
commit
8cf5bf6e5f
@ -41,9 +41,9 @@ namespace DOAN.WebApi.Controllers
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("devicePoweronRate")]
|
||||
public IActionResult DevicePoweronRate()
|
||||
public IActionResult DevicePoweronRate(DeviceReportDto param)
|
||||
{
|
||||
var response = _ReportService.DevicePoweronRate(DateTime.Today);
|
||||
var response = _ReportService.DevicePoweronRate(param);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
@ -52,9 +52,9 @@ namespace DOAN.WebApi.Controllers
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("deviceDowntimeRate")]
|
||||
public IActionResult DeviceDowntimeRate()
|
||||
public IActionResult DeviceDowntimeRate(DeviceReportDto param)
|
||||
{
|
||||
var response = _ReportService.DeviceDowntimeRate(DateTime.Today);
|
||||
var response = _ReportService.DeviceDowntimeRate(param);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
|
||||
@ -10,4 +10,10 @@ namespace DOAN.Model.MES
|
||||
{
|
||||
public DateTime SearchYearMonth { get; set; }
|
||||
}
|
||||
|
||||
public class DeviceReportDto //: PagerInfo
|
||||
{
|
||||
public DateTime StartDate { get; set; }
|
||||
public DateTime EndDate { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,8 +14,8 @@ namespace DOAN.Service.MES.report.IService
|
||||
{
|
||||
public interface IReportService : IBaseService<BaseWorkRoute>
|
||||
{
|
||||
List<DevicePoweronRateModel> DevicePoweronRate(DateTime dateTime);
|
||||
List<DeviceDowntimeRateModel> DeviceDowntimeRate(DateTime dateTime);
|
||||
List<DevicePoweronRateModel> DevicePoweronRate(DeviceReportDto param);
|
||||
List<DeviceDowntimeRateModel> DeviceDowntimeRate(DeviceReportDto param);
|
||||
|
||||
List<ProductionCompletionRate> ProductionCompletionRate(DateTime dateTime);
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Aliyun.OSS;
|
||||
using DOAN.Model.MES;
|
||||
using DOAN.Model.MES.andon;
|
||||
using DOAN.Model.MES.base_;
|
||||
using DOAN.Model.MES.group;
|
||||
@ -13,16 +14,17 @@ namespace DOAN.Service.MES.report
|
||||
[AppService(ServiceType = typeof(IReportService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class ReportService : BaseService<BaseWorkRoute>, IReportService
|
||||
{
|
||||
public List<DevicePoweronRateModel> DevicePoweronRate(DateTime dateTime)
|
||||
public List<DevicePoweronRateModel> DevicePoweronRate(DeviceReportDto param)
|
||||
{
|
||||
List<DevicePoweronRateModel> list = new List<DevicePoweronRateModel>();
|
||||
var response = Context.Queryable<BaseWorkRoute>().OrderBy(t => t.Id).ToList();
|
||||
var dt = dateTime.ToString("yyyy-MM-dd");
|
||||
//var dt = dateTime.ToString("yyyy-MM-dd");
|
||||
|
||||
var shiftList = Context.Queryable<GroupSchedule>()
|
||||
.LeftJoin<GroupShift>((a, b) => a.FkShift == b.Id)
|
||||
.LeftJoin<ProWorkorder>((a, b, c) => a.GroupCode == c.GroupCode && c.WorkorderDate.Value.ToString("yyyy-MM-dd") == dt)
|
||||
.Where((a, b, c) => a.ScheduleDate.Value.ToString("yyyy-MM-dd") == dt)
|
||||
.LeftJoin<ProWorkorder>((a, b, c) => a.GroupCode == c.GroupCode
|
||||
&& c.WorkorderDate.Value.ToString("yyyy-MM-dd") == a.ScheduleDate.Value.ToString("yyyy-MM-dd"))
|
||||
.Where((a, b, c) => a.ScheduleDate.Value>= param.StartDate && a.ScheduleDate.Value <= param.EndDate)
|
||||
.Select((a, b, c) =>
|
||||
new
|
||||
{
|
||||
@ -30,7 +32,7 @@ namespace DOAN.Service.MES.report
|
||||
b.WorkHours,
|
||||
b.StartTime,
|
||||
b.EndTime,
|
||||
c.LineCode
|
||||
c.LineCode,
|
||||
}).ToList();
|
||||
|
||||
var tempList = response.Select(it => new
|
||||
@ -85,13 +87,15 @@ namespace DOAN.Service.MES.report
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<DeviceDowntimeRateModel> DeviceDowntimeRate(DateTime dateTime)
|
||||
public List<DeviceDowntimeRateModel> DeviceDowntimeRate(DeviceReportDto param)
|
||||
{
|
||||
List<DeviceDowntimeRateModel> list = new List<DeviceDowntimeRateModel>();
|
||||
var dt = dateTime.ToString("yyyy-MM-dd");
|
||||
//var dt = dateTime.ToString("yyyy-MM-dd");
|
||||
|
||||
list = Context.Queryable<BaseWorkRoute>()
|
||||
.LeftJoin<ProWorkorder>((a, b) => a.Code == b.LineCode && b.WorkorderDate.Value.ToString("yyyy-MM-dd") == dt)
|
||||
.LeftJoin<ProWorkorder>((a, b) => a.Code == b.LineCode
|
||||
&& b.WorkorderDate.Value>= param.StartDate
|
||||
&& b.WorkorderDate.Value<= param.EndDate)
|
||||
.OrderBy((a,b)=>a.Id)
|
||||
.Select((a, b) =>
|
||||
new DeviceDowntimeRateModel
|
||||
@ -101,8 +105,19 @@ namespace DOAN.Service.MES.report
|
||||
PlanHours = SqlFunc.Round((b.Beat * b.DeliveryNum ?? 0) / 3600.0, 2)
|
||||
}).ToList();
|
||||
|
||||
var groupListWorkRoute = list.GroupBy(it => new { it.LineCode,it.LineName }).Select(it => new
|
||||
{
|
||||
LineCode = it.Key.LineCode,
|
||||
LineName = it.Key.LineName,
|
||||
PlanHours = it.ToList().Sum(t => t.PlanHours)
|
||||
}).ToList();
|
||||
|
||||
var response = Context.Queryable<AndonFaultRecord>()
|
||||
.Where(t=>t.FaultDict== "设备异常" && t.StartTime.HasValue && t.EndTime.HasValue && t.EndTime.Value.ToString("yyyy-MM-dd") ==dt)
|
||||
.Where(t=>t.FaultDict== "设备异常"
|
||||
&& t.StartTime.HasValue
|
||||
&& t.EndTime.HasValue
|
||||
&& t.EndTime.Value>= param.StartDate
|
||||
&& t.EndTime.Value<= param.EndDate)
|
||||
.Select(it => new
|
||||
{
|
||||
it.LineCode,
|
||||
@ -117,7 +132,7 @@ namespace DOAN.Service.MES.report
|
||||
DowntimeHours = it.ToList().Sum(t=>t.DowntimeHours)
|
||||
}).ToList();
|
||||
|
||||
var result = list.GroupJoin(groupList,
|
||||
var result = groupListWorkRoute.GroupJoin(groupList,
|
||||
l => l.LineCode,
|
||||
g => g.LineCode,
|
||||
(l, gList) => new DeviceDowntimeRateModel
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user