From 65ee306fe1fb48842b981c0aa281c84ec176d11a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=AD=A3=E6=98=93?= Date: Mon, 25 Nov 2024 09:58:29 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=9C=8B=E6=9D=BF=E7=9A=84?= =?UTF-8?q?=E5=80=92=E8=BD=A6=E9=9B=B7=E8=BE=BE=E5=8E=BB=E9=99=A4=EF=BC=8C?= =?UTF-8?q?=E6=8A=9B=E5=85=89=EF=BC=8C=E4=B8=80=E6=AC=A1=E4=BB=93=E5=BA=93?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mes/qc/FQC/QCStatisticsController.cs | 12 ++++ .../mes/qc/IService/IQCStatisticsService.cs | 11 ++++ ZR.Service/mes/qc/QCStatisticsService.cs | 66 ++++++++++++++++++- .../mes/wms/WmOneTimeInventoryService.cs | 35 +++++----- .../mes/wms/WmPolishInventoryService.cs | 37 +++++------ 5 files changed, 123 insertions(+), 38 deletions(-) diff --git a/ZR.Admin.WebApi/Controllers/mes/qc/FQC/QCStatisticsController.cs b/ZR.Admin.WebApi/Controllers/mes/qc/FQC/QCStatisticsController.cs index 55a143fa..523ffa3b 100644 --- a/ZR.Admin.WebApi/Controllers/mes/qc/FQC/QCStatisticsController.cs +++ b/ZR.Admin.WebApi/Controllers/mes/qc/FQC/QCStatisticsController.cs @@ -76,6 +76,18 @@ namespace ZR.Admin.WebApi.Controllers.mes.qc.FQC } + /// + /// 获取 首检 倒车雷达数量 + /// + /// + [HttpGet("getParkingSensorTotal")] + public IActionResult GetParkingSensorTotal(DateTime starttime, DateTime endTime, string workorderid, string partnumber, string product_description, string team, int pageNum, int pageSize) + { + int result = qcStatistics.GetParkingSensorTotal(starttime, endTime, workorderid, partnumber, product_description, team, pageNum, pageSize); + + return SUCCESS(result); + } + /// /// 导出对应报表 /// diff --git a/ZR.Service/mes/qc/IService/IQCStatisticsService.cs b/ZR.Service/mes/qc/IService/IQCStatisticsService.cs index b780b840..b730b1c8 100644 --- a/ZR.Service/mes/qc/IService/IQCStatisticsService.cs +++ b/ZR.Service/mes/qc/IService/IQCStatisticsService.cs @@ -68,6 +68,17 @@ namespace ZR.Service.mes.qc.IService ); #endregion + public int GetParkingSensorTotal( + DateTime starttime, + DateTime endTime, + string workorderid, + string partnumber, + string product_description, + string team, + int pageNum, + int pageSize + ); + public int DeleteStatisticsTable(string workorderid); /// diff --git a/ZR.Service/mes/qc/QCStatisticsService.cs b/ZR.Service/mes/qc/QCStatisticsService.cs index 9db17301..d8d51f60 100644 --- a/ZR.Service/mes/qc/QCStatisticsService.cs +++ b/ZR.Service/mes/qc/QCStatisticsService.cs @@ -72,7 +72,6 @@ namespace ZR.Service.mes.qc List data = Context .Queryable() .Where(predicate) - .OrderByIF(sortType == 1, it => it.QualifiedRate, OrderByType.Desc) .OrderByIF(sortType == 2, it => it.ProductDescription, OrderByType.Asc) .OrderByIF(sortType == 0 || sortType == 2, it => it.StartTime, OrderByType.Asc) @@ -815,5 +814,70 @@ namespace ZR.Service.mes.qc return "获取描述异常!"; } } + + /// + /// 获取首检倒车雷达数量 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public int GetParkingSensorTotal( + DateTime starttime, + DateTime endTime, + string workorderid, + string partnumber, + string product_description, + string team, + int pageNum, + int pageSize + ) + { + try + { + // 倒车雷达提取 + string[] checkStrArray2 = { "倒车雷达" }; + var ParkingSensorPartNumberCheck = Expressionable.Create(); + foreach (string checkStr in checkStrArray2) + { + ParkingSensorPartNumberCheck.Or(it => it.Description.Contains(checkStr)); + } + ; + ParkingSensorPartNumberCheck.And(it => it.Type == 1).And(it => it.Status == 1); + List ParkingSensorPartNumberList = Context + .Queryable() + .Where(ParkingSensorPartNumberCheck.ToExpression()) + .Select(it => it.Partnumber) + .ToList(); + var predicateParkingSensor = Expressionable + .Create() + .And(it => ParkingSensorPartNumberList.Contains(it.FinishedPartNumber)) + .AndIF(!string.IsNullOrEmpty(workorderid), it => it.WorkorderId == workorderid) + .AndIF(!string.IsNullOrEmpty(partnumber), it => it.FinishedPartNumber == partnumber) + .AndIF( + !string.IsNullOrEmpty(product_description), + it => it.ProductDescription == product_description + ) + .AndIF(!string.IsNullOrEmpty(team), it => it.Team == team) + .AndIF(starttime > DateTime.MinValue, it => it.StartTime >= starttime.ToLocalTime()) + .AndIF(endTime > DateTime.MinValue, it => it.StartTime <= endTime.ToLocalTime()) + .ToExpression(); + return (Context + .Queryable() + .Where(predicateParkingSensor) + .Sum(it => it.QualifiedNumber) ?? 0) / 3; + } + catch (Exception e) + { + throw new Exception(e.Message ?? string.Empty); + } + + } } } diff --git a/ZR.Service/mes/wms/WmOneTimeInventoryService.cs b/ZR.Service/mes/wms/WmOneTimeInventoryService.cs index 8b6ff8c4..507af37a 100644 --- a/ZR.Service/mes/wms/WmOneTimeInventoryService.cs +++ b/ZR.Service/mes/wms/WmOneTimeInventoryService.cs @@ -44,25 +44,24 @@ namespace ZR.Service.mes.wms ) .Where((m, p) => m.Status == 1) .Where((m, p) => m.Type == 1) - .WhereIF(parm.Status > -1, (m, p) => p.Status == parm.Status) - .WhereIF(parm.Type > 0, (m, p) => p.Type == parm.Type) + .WhereIF(string.IsNullOrEmpty(parm.Partnumber), (m, p) => p.Status == 1) .OrderBy((m, p) => m.Description) .Select( (m, p) => new WmOneTimeInventoryDto { RealQuantity = 0, + Partnumber = m.Partnumber, Color = m.Color, Specification = m.Specification, Description = m.Description, - Id = p.Id, + Id = p.Id ?? m.Id, BlankNum = p.BlankNum, - Partnumber = p.Partnumber, - Quantity = p.Quantity, + Quantity = p.Quantity ?? 0, MaxNum = p.MaxNum, MinNum = p.MinNum, WarnNum = p.WarnNum, - Type = p.Type, + Type = p.Type ?? 1, Status = p.Status, Remark = p.Remark, CreatedBy = p.CreatedBy, @@ -75,10 +74,7 @@ namespace ZR.Service.mes.wms foreach (WmOneTimeInventoryDto item in list) { // 获取实际库存 - List partnumbers = new() - { - item.Partnumber - }; + List partnumbers = new() { item.Partnumber }; Dictionary dict = GetBatchOneTimeRealPartNum(partnumbers); item.RealQuantity = dict.TryGetValue(item.Partnumber, out int value) ? value : 0; } @@ -96,14 +92,17 @@ namespace ZR.Service.mes.wms int QuantitySum = list.Sum(it => it.Quantity) ?? 0; // 仓库当前查询实际零件数 int RealQuantitySum = list.Sum(it => it.RealQuantity); - WmOneTimeInventoryTableDto response = new() - { - Total = total, - StocktakingTotal = StocktakingTotal, - QuantitySum = QuantitySum, - RealQuantitySum = RealQuantitySum, - Result = list.Skip((parm.PageNum - 1) * parm.PageSize).Take(parm.PageSize).ToList(), - }; + WmOneTimeInventoryTableDto response = + new() + { + Total = total, + StocktakingTotal = StocktakingTotal, + QuantitySum = QuantitySum, + RealQuantitySum = RealQuantitySum, + Result = list.Skip((parm.PageNum - 1) * parm.PageSize) + .Take(parm.PageSize) + .ToList(), + }; return response; /*List partnumberByDescription = new(); diff --git a/ZR.Service/mes/wms/WmPolishInventoryService.cs b/ZR.Service/mes/wms/WmPolishInventoryService.cs index 703bd943..783a5ffd 100644 --- a/ZR.Service/mes/wms/WmPolishInventoryService.cs +++ b/ZR.Service/mes/wms/WmPolishInventoryService.cs @@ -57,25 +57,24 @@ namespace ZR.Service.mes.wms ) .Where((m, p) => m.Status == 1) .Where((m, p) => m.Type == 1) - .WhereIF(parm.Status > -1, (m, p) => p.Status == parm.Status) - .WhereIF(parm.Type > 0, (m, p) => p.Type == parm.Type) + .WhereIF(string.IsNullOrEmpty(parm.Partnumber), (m, p) => p.Status == 1) .OrderBy((m, p) => m.Description) .Select( (m, p) => new WmPolishInventoryDto { RealQuantity = 0, + Partnumber = m.Partnumber, Color = m.Color, Specification = m.Specification, Description = m.Description, - Id = p.Id, + Id = p.Id ?? m.Id, BlankNum = p.BlankNum, - Partnumber = p.Partnumber, - Quantity = p.Quantity, + Quantity = p.Quantity ?? 0, MaxNum = p.MaxNum, MinNum = p.MinNum, WarnNum = p.WarnNum, - Type = p.Type, + Type = p.Type ?? 1, Status = p.Status, Remark = p.Remark, CreatedBy = p.CreatedBy, @@ -88,14 +87,11 @@ namespace ZR.Service.mes.wms foreach (WmPolishInventoryDto item in list) { // 获取实际库存 - List partnumbers = new() - { - item.Partnumber - }; + List partnumbers = new() { item.Partnumber }; Dictionary dict = GetBatchPolishRealPartNum(partnumbers); item.RealQuantity = dict.TryGetValue(item.Partnumber, out int value) ? value : 0; } - + list = list.Where(it => it.RealQuantity != 0 || it.Quantity != 0) .Where(it => !string.IsNullOrEmpty(it.Partnumber)) .DistinctBy(it => it.Partnumber) @@ -109,14 +105,17 @@ namespace ZR.Service.mes.wms int QuantitySum = list.Sum(it => it.Quantity) ?? 0; // 仓库当前查询实际零件数 int RealQuantitySum = list.Sum(it => it.RealQuantity); - WmPolishInventoryTableDto response = new() - { - Total = total, - StocktakingTotal = StocktakingTotal, - QuantitySum = QuantitySum, - RealQuantitySum = RealQuantitySum, - Result = list.Skip((parm.PageNum - 1)* parm.PageSize).Take(parm.PageSize).ToList(), - }; + WmPolishInventoryTableDto response = + new() + { + Total = total, + StocktakingTotal = StocktakingTotal, + QuantitySum = QuantitySum, + RealQuantitySum = RealQuantitySum, + Result = list.Skip((parm.PageNum - 1) * parm.PageSize) + .Take(parm.PageSize) + .ToList(), + }; return response; //TODO 历史查询