增加月度

This commit is contained in:
gcw_MV9p2JJN 2025-10-17 17:55:35 +08:00
parent 12ce078ed4
commit 1b1a118212
4 changed files with 79 additions and 0 deletions

View File

@ -40,6 +40,16 @@ namespace DOAN.Admin.WebApi.Controllers
}
//TODO 月度统计分类聚合
[HttpPost("month_list")]
[ActionPermissionFilter(Permission = "productManagement:proplanachievementrate:list")]
public IActionResult QueryProPlanAchievementrateByMonth([FromQuery] ProPlanAchievementrateQueryDto2 parm)
{
var response = _ProPlanAchievementrateService.GetListByMonth(parm);
return SUCCESS(response);
}
/// <summary>
/// 查询日计划达成率详情
/// </summary>
@ -106,5 +116,7 @@ namespace DOAN.Admin.WebApi.Controllers
}
}

View File

@ -9,6 +9,10 @@ namespace DOAN.Model.MES.product.Dto
{
public string Project { get; set; }
}
public class ProPlanAchievementrateQueryDto2 : ProPlanAchievementrateQueryDto
{
public DateTime SearchYearMonth { get; set; }
}
/// <summary>
/// 日计划达成率输入输出对象

View File

@ -14,6 +14,10 @@ namespace DOAN.Service.MES.product.IService
{
PagedInfo<ProPlanAchievementrateDto> GetList(ProPlanAchievementrateQueryDto parm);
PagedInfo<ProPlanAchievementrateDto> GetListByMonth(ProPlanAchievementrateQueryDto2 parm);
ProPlanAchievementrate GetInfo(int Id);
ProPlanAchievementrate AddProPlanAchievementrate(ProPlanAchievementrate parm);

View File

@ -11,6 +11,7 @@ using DOAN.Service.MES.product.IService;
using System.Linq;
using Microsoft.AspNetCore.Http;
using Infrastructure;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace DOAN.Service.MES.product
{
/// <summary>
@ -39,6 +40,64 @@ namespace DOAN.Service.MES.product
}
/// <summary>
/// 查询月计划达成率列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<ProPlanAchievementrateDto> GetListByMonth(ProPlanAchievementrateQueryDto2 parm)
{
(DateTime FirstDay, DateTime LastDay) Handlemonth= GetFirstAndLastDayOfMonth(parm.SearchYearMonth);
var predicate = Expressionable.Create<ProPlanAchievementrate>()
.AndIF(!string.IsNullOrEmpty(parm.Project), it => it.Project.Contains(parm.Project))
.And(it=>it.RecordDate>= Handlemonth.FirstDay&& it.RecordDate<= Handlemonth.LastDay)
;
var response = Queryable()
.Where(predicate.ToExpression())
.GroupBy(it=>it.Project)
.Select(it=>new ProPlanAchievementrate()
{
Project=parm.Project,
AgroupPlanNum=SqlFunc.AggregateSum(it.AgroupPlanNum??0),
AgroupProductNum= SqlFunc.AggregateSum(it.AgroupProductNum ?? 0),
AgroupCompletionRate= SqlFunc.AggregateAvg(it.AgroupCompletionRate),
BgroupPlanNum = SqlFunc.AggregateSum(it.BgroupPlanNum ?? 0),
BgroupProductNum = SqlFunc.AggregateSum(it.BgroupProductNum ?? 0),
BgroupCompletionRate = SqlFunc.AggregateAvg(it.BgroupCompletionRate),
SummaryActualNum = SqlFunc.AggregateSum(it.SummaryActualNum ?? 0),
SummaryPlanNum = SqlFunc.AggregateSum(it.SummaryPlanNum ?? 0),
SummaryPlanAchievementRate = SqlFunc.AggregateAvg(it.SummaryPlanAchievementRate),
DownQuality = SqlFunc.AggregateSum(it.DownQuality ?? 0),
DownSuppler = SqlFunc.AggregateSum(it.DownSuppler ?? 0),
DownDeviceFailure = SqlFunc.AggregateSum(it.DownDeviceFailure ?? 0),
DownDeviceDebug = SqlFunc.AggregateSum(it.DownDeviceDebug ?? 0),
DownLogisticsWaitMaterial = SqlFunc.AggregateSum(it.DownLogisticsWaitMaterial ?? 0),
DownLackMaterial = SqlFunc.AggregateSum(it.DownLackMaterial ?? 0),
DownInjection = SqlFunc.AggregateSum(it.DownInjection ?? 0),
DownAssembly = SqlFunc.AggregateSum(it.DownAssembly ?? 0),
AllLineStopTime = SqlFunc.AggregateSum(it.AllLineStopTime ?? 0),
RecordDate = Handlemonth.FirstDay
})
.ToPage<ProPlanAchievementrate, ProPlanAchievementrateDto>(parm);
return response;
}
private (DateTime FirstDay, DateTime LastDay) GetFirstAndLastDayOfMonth(DateTime date)
{
DateTime firstDay = new DateTime(date.Year, date.Month, 1);
int lastDay = DateTime.DaysInMonth(date.Year, date.Month);
DateTime lastDayDate = new DateTime(date.Year, date.Month, lastDay);
return (firstDay, lastDayDate);
}
/// <summary>
/// 获取详情
/// </summary>