大屏
This commit is contained in:
parent
b0ea9f6067
commit
1cccb28bc6
@ -0,0 +1,46 @@
|
||||
using DOAN.Model.MES.product.Dto;
|
||||
using DOAN.Service.MES.BI.IService;
|
||||
using DOAN.Service.MES.product.IService;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace DOAN.WebApi.Controllers.MES.BI.product
|
||||
{
|
||||
|
||||
[AllowAnonymous]
|
||||
[Route("mes/BI/planAchievementRate")]
|
||||
public class PlanAchievementRateController : BaseController
|
||||
{
|
||||
private readonly IProPlanAchievementrateService IPlanAchievementRate;
|
||||
|
||||
public PlanAchievementRateController(IProPlanAchievementrateService _iPlanAchievementRate)
|
||||
{
|
||||
_iPlanAchievementRate = IPlanAchievementRate;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("gettoday")]
|
||||
public IActionResult GetTodayList()
|
||||
{
|
||||
var response = IPlanAchievementRate.GetTodayList();
|
||||
return SUCCESS(response);
|
||||
}
|
||||
[HttpGet("getyesterday")]
|
||||
public IActionResult GetYesterdayList()
|
||||
{
|
||||
var response = IPlanAchievementRate.GetYesterdayList();
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("getmonth")]
|
||||
public IActionResult GetMonth()
|
||||
{
|
||||
var response = IPlanAchievementRate.GetListByMonth();
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -24,5 +24,13 @@ namespace DOAN.Service.MES.product.IService
|
||||
|
||||
int UpdateProPlanAchievementrate(ProPlanAchievementrate parm);
|
||||
|
||||
|
||||
|
||||
List<ProPlanAchievementrateDto> GetTodayList();
|
||||
|
||||
List<ProPlanAchievementrateDto> GetYesterdayList();
|
||||
|
||||
List<ProPlanAchievementrateDto> GetListByMonth();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ using System.Linq;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Infrastructure;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
using Mapster;
|
||||
namespace DOAN.Service.MES.product
|
||||
{
|
||||
/// <summary>
|
||||
@ -48,22 +49,22 @@ namespace DOAN.Service.MES.product
|
||||
/// <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)
|
||||
;
|
||||
(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()
|
||||
.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),
|
||||
Project = it.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),
|
||||
@ -119,7 +120,7 @@ namespace DOAN.Service.MES.product
|
||||
/// <returns></returns>
|
||||
public ProPlanAchievementrate AddProPlanAchievementrate(ProPlanAchievementrate model)
|
||||
{
|
||||
|
||||
|
||||
return Context.Insertable(model).IgnoreColumns(it => new { it.Id }).ExecuteReturnEntity();
|
||||
}
|
||||
|
||||
@ -169,5 +170,72 @@ namespace DOAN.Service.MES.product
|
||||
return Update(model, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<ProPlanAchievementrateDto> GetTodayList()
|
||||
{
|
||||
DateTime today = DateTime.Today;
|
||||
var response = Queryable()
|
||||
.Where(it => it.RecordDate == today)
|
||||
.ToList()
|
||||
.Adapt<List<ProPlanAchievementrate>, List<ProPlanAchievementrateDto>>()
|
||||
;
|
||||
return response;
|
||||
}
|
||||
|
||||
public List<ProPlanAchievementrateDto> GetYesterdayList()
|
||||
{
|
||||
DateTime yesterday = DateTime.Today.AddDays(-1);
|
||||
var response = Queryable()
|
||||
.Where(it => it.RecordDate == yesterday)
|
||||
.ToList()
|
||||
.Adapt<List<ProPlanAchievementrate>, List<ProPlanAchievementrateDto>>()
|
||||
;
|
||||
return response;
|
||||
}
|
||||
|
||||
public List<ProPlanAchievementrateDto> GetListByMonth()
|
||||
{
|
||||
(DateTime FirstDay, DateTime LastDay) Handlemonth = GetFirstAndLastDayOfMonth(DateTime.Today);
|
||||
var predicate = Expressionable.Create<ProPlanAchievementrate>()
|
||||
|
||||
.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 = it.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
|
||||
})
|
||||
.ToList()
|
||||
.Adapt<List<ProPlanAchievementrate>, List<ProPlanAchievementrateDto>>();
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user