生产大屏
This commit is contained in:
parent
2b2c84e8a8
commit
ca741525e9
@ -200,7 +200,7 @@ namespace DOAN.Admin.WebApi.Controllers
|
||||
/// <returns></returns>
|
||||
[HttpPost("setWorkorderStatus")]
|
||||
[Log(Title = "设置工单状态", BusinessType = BusinessType.UPDATE)]
|
||||
public IActionResult SetWorkorderStatus(ProWorkorderStatusDto param)
|
||||
public IActionResult SetWorkorderStatus([FromBody] ProWorkorderStatusDto param)
|
||||
{
|
||||
if (string.IsNullOrEmpty(param.Id))
|
||||
{
|
||||
|
||||
@ -97,7 +97,6 @@ namespace DOAN.WebApi.Controllers
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 生产大屏报表
|
||||
/// </summary>
|
||||
@ -108,5 +107,16 @@ namespace DOAN.WebApi.Controllers
|
||||
var response = _ReportService.ProductionReport(DateTime.Now);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生产大屏达成率
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("productionReportRate")]
|
||||
public IActionResult ProductionReportRate()
|
||||
{
|
||||
var response = _ReportService.ProductionReportRate(DateTime.Now);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,4 +135,17 @@ namespace DOAN.Model.MES.report
|
||||
public string StatusName { get; set; }
|
||||
public int? Status { get; set; }
|
||||
}
|
||||
|
||||
public class ProductionReportRate
|
||||
{
|
||||
public string WorkTimePeriod { get; set; }
|
||||
public double Rate { get; set; }
|
||||
}
|
||||
public class ProductionReportRateModel
|
||||
{
|
||||
public List<ProductionReportRate> CompletionRateList { get; set; }=new List<ProductionReportRate>();
|
||||
public List<ProductionReportRate> QualifiedRateList { get; set; }= new List<ProductionReportRate>();
|
||||
public List<ProductionReportRate> UnqualifiedRateList { get; set; } = new List<ProductionReportRate>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -22,5 +22,6 @@ namespace DOAN.Service.MES.report.IService
|
||||
List<ProductionCompletionRate> MonthlyProductionCompletionRate(DateTime dateTime);
|
||||
|
||||
List<ProductionReportModel> ProductionReport(DateTime dateTime);
|
||||
ProductionReportRateModel ProductionReportRate(DateTime dateTime);
|
||||
}
|
||||
}
|
||||
|
||||
@ -339,5 +339,55 @@ namespace DOAN.Service.MES.report
|
||||
|
||||
return woList;
|
||||
}
|
||||
|
||||
public ProductionReportRateModel ProductionReportRate(DateTime dateTime)
|
||||
{
|
||||
var dt = dateTime.ToString("yyyy-MM-dd");
|
||||
ProductionReportRateModel model = new ProductionReportRateModel();
|
||||
var productionCompletionRate = ProductionCompletionRate("", dateTime);
|
||||
model.CompletionRateList = productionCompletionRate.Select(t =>
|
||||
new ProductionReportRate
|
||||
{
|
||||
WorkTimePeriod = t.WorkTimePeriod,
|
||||
Rate = t.CompletionRate
|
||||
}).ToList();
|
||||
|
||||
string sql = @"SELECT FROM_UNIXTIME( FLOOR( UNIX_TIMESTAMP( d.created_time ) / 3600 ) * 3600 ) AS TimePeriod,
|
||||
sum(number) AS Count
|
||||
FROM pro_workorder AS r
|
||||
RIGHT JOIN qc_finishedproduct_defect_collection AS d ON r.workorder = d.workorder
|
||||
WHERE r.workorder_date = @dt
|
||||
GROUP BY FLOOR( UNIX_TIMESTAMP( d.created_time ) / 600 )
|
||||
ORDER BY TimePeriod";
|
||||
|
||||
var defectList = Context.Ado.SqlQuery<ProductionCompletionModel>(sql, new { dt = dt, });
|
||||
|
||||
var tempList = defectList.Select(t =>
|
||||
new
|
||||
{
|
||||
Count = t.Count,
|
||||
WorkTimePeriod = t.TimePeriod.ToString("HH:00")
|
||||
}
|
||||
).ToList();
|
||||
|
||||
productionCompletionRate.ForEach(t =>
|
||||
{
|
||||
var defectModel = tempList.Where(d => d.WorkTimePeriod == t.WorkTimePeriod).FirstOrDefault();
|
||||
var rate= defectModel==null ? 0 : Math.Round(defectModel.Count * 100.0 / t.DeliveryNum, 2);
|
||||
|
||||
model.UnqualifiedRateList.Add(new ProductionReportRate
|
||||
{
|
||||
WorkTimePeriod = t.WorkTimePeriod,
|
||||
Rate = rate
|
||||
});
|
||||
model.QualifiedRateList.Add(new ProductionReportRate
|
||||
{
|
||||
WorkTimePeriod = t.WorkTimePeriod,
|
||||
Rate = 100 - rate
|
||||
});
|
||||
});
|
||||
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user