生产大屏达成率,合格率,异常率
This commit is contained in:
parent
eb6c4151f8
commit
ae57e0c2dc
@ -66,7 +66,7 @@ namespace DOAN.WebApi.Controllers
|
||||
public IActionResult ProductionCompletionRate([FromQuery] string groupName)
|
||||
{
|
||||
DateTime dt = new DateTime(2026, 1, 27);
|
||||
//dt = DateTime.Today;
|
||||
dt = DateTime.Today;
|
||||
var response = _ReportService.ProductionCompletionRate(groupName, dt); //DateTime.Today
|
||||
return SUCCESS(response);
|
||||
}
|
||||
@ -114,7 +114,7 @@ namespace DOAN.WebApi.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生产大屏达成率
|
||||
/// 生产大屏达成率,取消不需要
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("productionReportRate")]
|
||||
@ -122,8 +122,35 @@ namespace DOAN.WebApi.Controllers
|
||||
{
|
||||
DateTime dt = new DateTime(2026, 1, 27);
|
||||
//dt = DateTime.Now;
|
||||
var response = _ReportService.ProductionReportRate(dt);
|
||||
var response = _ReportService.ProductionReportRate2(dt);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生产大屏周达成率,合格率,异常率
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("productionReportWeekRate")]
|
||||
public IActionResult ProductionReportWeekRate()
|
||||
{
|
||||
DateTime dt = new DateTime(2026, 1, 27);
|
||||
//dt = DateTime.Now;
|
||||
var response = _ReportService.ProductionReportRate(dt,1);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生产大屏月达成率,合格率,异常率
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("productionReportMonthRate")]
|
||||
public IActionResult ProductionReportMonthRate()
|
||||
{
|
||||
DateTime dt = new DateTime(2026, 1, 27);
|
||||
//dt = DateTime.Now;
|
||||
var response = _ReportService.ProductionReportRate(dt, 2);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,6 +151,14 @@ namespace DOAN.Model.MES.report
|
||||
public int? Status { get; set; }
|
||||
}
|
||||
|
||||
public class ProductionReportToalRate
|
||||
{
|
||||
public double CompleteRate { get; set; }
|
||||
public double QualifiedRate { get; set; }
|
||||
public double UnqualifiedRate { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class ProductionReportRate
|
||||
{
|
||||
public string WorkTimePeriod { get; set; }
|
||||
|
||||
@ -15,6 +15,7 @@ namespace DOAN.Service.MES.report.IService
|
||||
public interface IReportService : IBaseService<BaseWorkRoute>
|
||||
{
|
||||
List<DevicePoweronRateModel> DevicePoweronRate(DeviceReportDto param);
|
||||
|
||||
List<DeviceDowntimeRateModel> DeviceDowntimeRate(DeviceReportDto param);
|
||||
|
||||
List<ProductionCompletionRate> ProductionCompletionRate(string groupName, DateTime dateTime);
|
||||
@ -22,6 +23,9 @@ namespace DOAN.Service.MES.report.IService
|
||||
List<ProductionCompletionRate> MonthlyProductionCompletionRate(DateTime dateTime);
|
||||
|
||||
List<ProductionReportModel> ProductionReport(DateTime dateTime);
|
||||
ProductionReportRateModel ProductionReportRate(DateTime dateTime);
|
||||
|
||||
ProductionReportToalRate ProductionReportRate(DateTime dateTime, int type);
|
||||
|
||||
ProductionReportRateModel ProductionReportRate2(DateTime dateTime);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ using DOAN.Model.MES.product;
|
||||
using DOAN.Model.MES.report;
|
||||
using DOAN.Service.MES.report.IService;
|
||||
using Infrastructure.Attribute;
|
||||
using JinianNet.JNTemplate.Dynamic;
|
||||
using System.Data;
|
||||
|
||||
namespace DOAN.Service.MES.report
|
||||
@ -331,7 +332,7 @@ namespace DOAN.Service.MES.report
|
||||
var woList = Context.Queryable<ProWorkorder>()
|
||||
.LeftJoin<ProReportwork>((a, b) => a.Workorder == b.FkWorkorder)
|
||||
.LeftJoin<BaseWorkRoute>((a, b, c) => a.LineCode == c.Code)
|
||||
.LeftJoin<BaseGroup>((a, b, c, d) => a.GroupCode == d.GroupCode)
|
||||
.LeftJoin<BaseGroup>((a, b, c, d) => a.GroupCode == d.GroupCode)
|
||||
.Where((a, b, c, d) => a.WorkorderDate.Value.ToString("yyyy-MM-dd") == dt)
|
||||
.Select((a, b, c, d) => new ProductionReportModel
|
||||
{
|
||||
@ -352,7 +353,71 @@ namespace DOAN.Service.MES.report
|
||||
return woList;
|
||||
}
|
||||
|
||||
public ProductionReportRateModel ProductionReportRate(DateTime dateTime)
|
||||
public ProductionReportToalRate ProductionReportRate(DateTime dateTime, int type)
|
||||
{
|
||||
DateTime startDate, endDate;
|
||||
if (type == 1)
|
||||
{
|
||||
var dateRange = GetWeekRange(dateTime);
|
||||
startDate = dateRange.StartOfWeek;
|
||||
endDate = dateRange.EndOfWeek;
|
||||
}
|
||||
else
|
||||
{
|
||||
var dateRange = GetMonthRange(dateTime);
|
||||
startDate = dateRange.StartOfMonth;
|
||||
endDate = dateRange.EndOfMonth;
|
||||
}
|
||||
var woList = Context.Queryable<ProWorkorder>()
|
||||
.LeftJoin<ProReportwork>((a, b) => a.Workorder == b.FkWorkorder)
|
||||
.Where((a, b) => a.WorkorderDate >= startDate && a.WorkorderDate <= endDate)
|
||||
.Select((a, b) => new
|
||||
{
|
||||
PlanNum = a.DeliveryNum ?? 0,
|
||||
CompletionNum = b.FinishedNum ?? 0,
|
||||
QualifiedNumber = b.QualifiedNumber ?? 0,
|
||||
UnqualifiedNumber = b.UnqualifiedNumber ?? 0
|
||||
}).ToList();
|
||||
|
||||
var totalPlanNum = woList.Sum(t => t.PlanNum);
|
||||
var totalCompletionNum = woList.Sum(t => t.CompletionNum);
|
||||
var totalQualifiedNum = woList.Sum(t => t.QualifiedNumber);
|
||||
var totalUnqualifiedNum = woList.Sum(t => t.UnqualifiedNumber);
|
||||
|
||||
ProductionReportToalRate rate = new ProductionReportToalRate()
|
||||
{
|
||||
CompleteRate = totalPlanNum == 0 ? 0 : Math.Round(totalCompletionNum * 100.0 / totalPlanNum, 2),
|
||||
QualifiedRate = totalCompletionNum == 0 ? 0 : Math.Round(totalQualifiedNum * 100.0 / totalCompletionNum, 2),
|
||||
UnqualifiedRate = totalCompletionNum == 0 ? 0 : Math.Round(totalUnqualifiedNum * 100.0 / totalCompletionNum, 2)
|
||||
};
|
||||
return rate;
|
||||
}
|
||||
|
||||
private (DateTime StartOfWeek, DateTime EndOfWeek) GetWeekRange(DateTime date)
|
||||
{
|
||||
// 计算本周第一天(周一)
|
||||
int diff = (7 + (date.DayOfWeek - DayOfWeek.Monday)) % 7;
|
||||
DateTime startOfWeek = date.AddDays(-1 * diff).Date;
|
||||
|
||||
// 计算本周最后一天(周日)
|
||||
DateTime endOfWeek = startOfWeek.AddDays(6);
|
||||
return (startOfWeek, endOfWeek);
|
||||
}
|
||||
|
||||
// 获取当月时间范围
|
||||
private (DateTime StartOfMonth, DateTime EndOfMonth) GetMonthRange(DateTime date)
|
||||
{
|
||||
// 本月第一天
|
||||
DateTime startOfMonth = new DateTime(date.Year, date.Month, 1);
|
||||
|
||||
// 本月最后一天
|
||||
int daysInMonth = DateTime.DaysInMonth(date.Year, date.Month);
|
||||
DateTime endOfMonth = new DateTime(date.Year, date.Month, daysInMonth);
|
||||
|
||||
return (startOfMonth, endOfMonth);
|
||||
}
|
||||
|
||||
public ProductionReportRateModel ProductionReportRate2(DateTime dateTime)
|
||||
{
|
||||
var dt = dateTime.ToString("yyyy-MM-dd");
|
||||
ProductionReportRateModel model = new ProductionReportRateModel();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user