157 lines
5.2 KiB
C#

using DOAN.Admin.WebApi.Filters;
using DOAN.Model;
using DOAN.Model.MES;
using DOAN.Model.MES.product.Dto;
using DOAN.Service.MES.product;
using DOAN.Service.MES.product.IService;
using DOAN.Service.MES.report.IService;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using NPOI.HPSF;
namespace DOAN.WebApi.Controllers
{
//[Verify]
[Route("mes/reportManagement/report")]
[ApiExplorerSettings(GroupName = "MES")]
public class ReportController : BaseController
{
private readonly IProPlanAchievementrateVersion2Service _ProPlanAchievementrateVersion2Service;
private readonly IReportService _ReportService;
public ReportController(IProPlanAchievementrateVersion2Service ProPlanAchievementrateService, IReportService ReportService)
{
_ProPlanAchievementrateVersion2Service = ProPlanAchievementrateService;
_ReportService = ReportService;
}
/// <summary>
/// 月生产数据统计列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
[HttpGet("listMonth")]
public IActionResult QueryMonthProduct([FromQuery] MonthProductDto parm)
{
var response = _ProPlanAchievementrateVersion2Service.GetQueryMonthProduct(parm);
return SUCCESS(response);
}
/// <summary>
/// 设备开机率
/// </summary>
/// <returns></returns>
[HttpGet("devicePoweronRate")]
public IActionResult DevicePoweronRate([FromQuery] DeviceReportDto param)
{
var response = _ReportService.DevicePoweronRate(param);
return SUCCESS(response);
}
/// <summary>
/// 设备停机率
/// </summary>
/// <returns></returns>
[HttpGet("deviceDowntimeRate")]
public IActionResult DeviceDowntimeRate([FromQuery] DeviceReportDto param)
{
var response = _ReportService.DeviceDowntimeRate(param);
return SUCCESS(response);
}
/// <summary>
/// 实时产出
/// </summary>
/// <returns></returns>
[HttpGet("productionCompletionRate")]
public IActionResult ProductionCompletionRate([FromQuery] string groupName)
{
DateTime dt = new DateTime(2026, 1, 27);
dt = DateTime.Today;
var response = _ReportService.ProductionCompletionRate(groupName, dt); //DateTime.Today
return SUCCESS(response);
}
/// <summary>
/// 月生产完成率
/// </summary>
/// <returns></returns>
[HttpGet("monthlyProductionCompletionRate")]
public IActionResult MonthlyProductionCompletionRate()
{
var response = _ReportService.MonthlyProductionCompletionRate(DateTime.Today);
return SUCCESS(response);
}
/// <summary>
/// 月生产数据导出
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
[HttpGet("exportMonthProduct")]
[Log(Title = "工单导出", BusinessType = BusinessType.EXPORT)]
[AllowAnonymous]
public IActionResult ExportMonthProduct([FromQuery] MonthProductDto parm)
{
var (fileBytes, fileName) = _ProPlanAchievementrateVersion2Service.ExportMonthProduct(parm);
string contnetType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
return File(fileBytes,contnetType,fileName);
}
/// <summary>
/// 生产大屏报表
/// </summary>
/// <returns></returns>
[HttpGet("productionReport")]
public IActionResult ProductionReport()
{
DateTime dt = new DateTime(2026, 1, 27);
//dt = DateTime.Now;
var response = _ReportService.ProductionReport(dt);
return SUCCESS(response);
}
/// <summary>
/// 生产大屏达成率,取消不需要
/// </summary>
/// <returns></returns>
[HttpGet("productionReportRate")]
public IActionResult ProductionReportRate()
{
DateTime dt = new DateTime(2026, 1, 27);
//dt = DateTime.Now;
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);
}
}
}