diff --git a/DOAN.Admin.WebApi/Controllers/MES/product/ProPlanAchievementrateController.cs b/DOAN.Admin.WebApi/Controllers/MES/product/ProPlanAchievementrateController.cs index 4c9536f..1b740cb 100644 --- a/DOAN.Admin.WebApi/Controllers/MES/product/ProPlanAchievementrateController.cs +++ b/DOAN.Admin.WebApi/Controllers/MES/product/ProPlanAchievementrateController.cs @@ -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); + } + + /// /// 查询日计划达成率详情 /// @@ -106,5 +116,7 @@ namespace DOAN.Admin.WebApi.Controllers + + } } \ No newline at end of file diff --git a/DOAN.Model/MES/product/Dto/ProPlanAchievementrateDto.cs b/DOAN.Model/MES/product/Dto/ProPlanAchievementrateDto.cs index 6fa99c4..b9bdd7f 100644 --- a/DOAN.Model/MES/product/Dto/ProPlanAchievementrateDto.cs +++ b/DOAN.Model/MES/product/Dto/ProPlanAchievementrateDto.cs @@ -9,6 +9,10 @@ namespace DOAN.Model.MES.product.Dto { public string Project { get; set; } } + public class ProPlanAchievementrateQueryDto2 : ProPlanAchievementrateQueryDto + { + public DateTime SearchYearMonth { get; set; } + } /// /// 日计划达成率输入输出对象 diff --git a/DOAN.Service/MES/product/IService/IProPlanAchievementrateService.cs b/DOAN.Service/MES/product/IService/IProPlanAchievementrateService.cs index d6f7dbe..af35ee9 100644 --- a/DOAN.Service/MES/product/IService/IProPlanAchievementrateService.cs +++ b/DOAN.Service/MES/product/IService/IProPlanAchievementrateService.cs @@ -14,6 +14,10 @@ namespace DOAN.Service.MES.product.IService { PagedInfo GetList(ProPlanAchievementrateQueryDto parm); + PagedInfo GetListByMonth(ProPlanAchievementrateQueryDto2 parm); + + + ProPlanAchievementrate GetInfo(int Id); ProPlanAchievementrate AddProPlanAchievementrate(ProPlanAchievementrate parm); diff --git a/DOAN.Service/MES/product/ProPlanAchievementrateService.cs b/DOAN.Service/MES/product/ProPlanAchievementrateService.cs index a36ff6d..f8e4dfa 100644 --- a/DOAN.Service/MES/product/ProPlanAchievementrateService.cs +++ b/DOAN.Service/MES/product/ProPlanAchievementrateService.cs @@ -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 { /// @@ -39,6 +40,64 @@ namespace DOAN.Service.MES.product } + + /// + /// 查询月计划达成率列表 + /// + /// + /// + public PagedInfo GetListByMonth(ProPlanAchievementrateQueryDto2 parm) + { + (DateTime FirstDay, DateTime LastDay) Handlemonth= GetFirstAndLastDayOfMonth(parm.SearchYearMonth); + var predicate = Expressionable.Create() + .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(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); + } + + /// /// 获取详情 ///