From 93abada9b38b10cb556abc24bd42acf53fe71ea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=AD=A3=E6=98=93?= Date: Mon, 20 May 2024 10:36:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=A8=E9=87=8F=E6=8A=A5=E8=A1=A8=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E4=BF=AE=E6=94=B9=EF=BC=8C=E6=89=B9=E9=87=8F=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E6=9F=A5=E8=AF=A2=E9=A1=BA=E5=BA=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mes/qc/FQC/QCStatisticsController.cs | 136 ++++++++++++------ .../mes/qc/IService/IQCStatisticsService.cs | 6 + ZR.Service/mes/qc/QCStatisticsService.cs | 76 +++++++++- .../mes/wms/WmGoodsBatchSearchService.cs | 16 +-- 4 files changed, 175 insertions(+), 59 deletions(-) diff --git a/ZR.Admin.WebApi/Controllers/mes/qc/FQC/QCStatisticsController.cs b/ZR.Admin.WebApi/Controllers/mes/qc/FQC/QCStatisticsController.cs index e8bcdb2e..f189bd94 100644 --- a/ZR.Admin.WebApi/Controllers/mes/qc/FQC/QCStatisticsController.cs +++ b/ZR.Admin.WebApi/Controllers/mes/qc/FQC/QCStatisticsController.cs @@ -9,6 +9,8 @@ using ZR.Model.MES.qc.DTO; using NPOI.HSSF.UserModel; using NPOI.XSSF.UserModel; using NPOI.SS.UserModel; +using ZR.Model.MES.wms; +using SqlSugar; namespace ZR.Admin.WebApi.Controllers.mes.qc.FQC { @@ -103,20 +105,35 @@ namespace ZR.Admin.WebApi.Controllers.mes.qc.FQC List excelDataList = qcStatistics.DownloadStatisticsTableExcel(starttime, endTime, workorderid, partnumber, product_description, team, pageNum, pageSize, type); XSSFWorkbook workbook = new XSSFWorkbook(); var sheet = workbook.CreateSheet(); - // 标题列 - var row0 = sheet.CreateRow(0); + // 单元格样式 ICellStyle style = workbook.CreateCellStyle(); style.Alignment = HorizontalAlignment.Center; style.VerticalAlignment = VerticalAlignment.Center; + // 标题列表 string[] titleDict = { "工单号", "零件号", "颜色", "描述", "生产投入数", "班次", "合格数", "合格率", "抛光总数", "打磨总数", "报废总数", "开始时间", "结束时间"}; - string[] titleDetailDict = { "备注", "缩孔", "针孔" }; - if(isShowDetail) + string[] titleGroupDict = {"油漆", "设备", "毛坯", "程序", "班组操作" }; + int[] titleGroupIndex = { 14, 20, 26, 32, 38 }; + string[] titleDetailDict = { "备注", "缩孔", "针孔", "失光","色差","点子","其他" }; + // 标题列位于第几行 + int startTitle = 0; + if (isShowDetail) { + // 调整第一行分组 + startTitle = 1; + var groupTitle = sheet.CreateRow(0); + for (int i = 0; i < titleGroupDict.Length;i++) + { + var cell = groupTitle.CreateCell(i); + cell.SetCellValue(titleGroupIndex[i]); + cell.CellStyle = style; + } + // 标题列表添加详情 titleDict.Concat(titleDetailDict); } + var rowTitle = sheet.CreateRow(startTitle); for (int i = 0; i < titleDict.Length; i++) { - var cell = row0.CreateCell(i); + var cell = rowTitle.CreateCell(i); cell.SetCellValue(titleDict[i]); cell.CellStyle = style; } @@ -124,57 +141,82 @@ namespace ZR.Admin.WebApi.Controllers.mes.qc.FQC int rowIndex = 1; for (int i = 0;i< excelDataList.Count;i++) { var item = excelDataList[i]; - if (_lastWorkOrderId == item.WorkorderId) + if (!isShowDetail &&_lastWorkOrderId == item.WorkorderId) { continue; } var row = sheet.CreateRow(rowIndex); - if (!isShowDetail) + var cell1 = row.CreateCell(0); + cell1.SetCellValue(item.WorkorderId); + cell1.CellStyle = style; + var cell2 = row.CreateCell(1); + cell2.SetCellValue(item.FinishedPartNumber); + cell2.CellStyle = style; + var cell3 = row.CreateCell(2); + cell3.SetCellValue(item.Color); + cell3.CellStyle = style; + + // 描述 + var cell4 = row.CreateCell(3); + cell4.SetCellValue(qcStatistics.GetDescription(item.FinishedPartNumber)); + cell4.CellStyle = style; + // ===== + + var cell5 = row.CreateCell(4); + cell5.SetCellValue(item.RequireNumber.ToString()); + cell5.CellStyle = style; + var cell6 = row.CreateCell(5); + cell6.SetCellValue(item.Team); + cell6.CellStyle = style; + var cell7 = row.CreateCell(6); + cell7.SetCellValue(item.QualifiedNumber.ToString()); + cell7.CellStyle = style; + var cell8 = row.CreateCell(7); + cell8.SetCellValue(((int)item.QualifiedRate).ToString() + "%"); + cell8.CellStyle = style; + var cell9 = row.CreateCell(8); + cell9.SetCellValue(item.PaoguangTotal.ToString()); + cell9.CellStyle = style; + var cell10 = row.CreateCell(9); + cell10.SetCellValue(item.DamoTotal.ToString()); + cell10.CellStyle = style; + var cell11 = row.CreateCell(10); + cell11.SetCellValue(item.BaofeiTotal.ToString()); + cell11.CellStyle = style; + var cell12 = row.CreateCell(11); + cell12.SetCellValue(item.StartTime.ToString()); + cell12.CellStyle = style; + var cell13 = row.CreateCell(12); + cell13.SetCellValue(item.EndTime.ToString()); + cell13.CellStyle = style; + if(isShowDetail) { - - var cell1 = row.CreateCell(0); - cell1.SetCellValue(item.WorkorderId); - cell1.CellStyle = style; - var cell2 = row.CreateCell(1); - cell2.SetCellValue(item.FinishedPartNumber); - cell2.CellStyle = style; - var cell3 = row.CreateCell(2); - cell3.SetCellValue(item.Color); - cell3.CellStyle = style; - var cell4 = row.CreateCell(3); - cell4.SetCellValue(item.ProductDescription); - cell4.CellStyle = style; - var cell5 = row.CreateCell(4); - cell5.SetCellValue(item.RequireNumber.ToString()); - cell5.CellStyle = style; - var cell6 = row.CreateCell(5); - cell6.SetCellValue(item.Team); - cell6.CellStyle = style; - var cell7 = row.CreateCell(6); - cell7.SetCellValue(item.RequireNumber.ToString()); - cell7.CellStyle = style; - var cell8 = row.CreateCell(7); - cell8.SetCellValue(item.QualifiedRate.ToString()); - cell8.CellStyle = style; - var cell9 = row.CreateCell(8); - cell9.SetCellValue(item.PaoguangTotal.ToString()); - cell9.CellStyle = style; - var cell10 = row.CreateCell(9); - cell10.SetCellValue(item.DamoTotal.ToString()); - cell10.CellStyle = style; - var cell11 = row.CreateCell(10); - cell11.SetCellValue(item.BaofeiTotal.ToString()); - cell11.CellStyle = style; - var cell12 = row.CreateCell(11); - cell12.SetCellValue(item.StartTime.ToString()); - cell12.CellStyle = style; - var cell13 = row.CreateCell(12); - cell13.SetCellValue(item.EndTime.ToString()); - cell13.CellStyle = style; + // 油漆 + var cell14 = row.CreateCell(13); + cell14.SetCellValue(item.PaintSuokong.ToString()); + cell14.CellStyle = style; + var cell15 = row.CreateCell(14); + cell15.SetCellValue(item.PaintZhengkong.ToString()); + cell15.CellStyle = style; + var cell16 = row.CreateCell(15); + cell16.SetCellValue(item.PaintShiguang.ToString()); + cell16.CellStyle = style; + var cell17 = row.CreateCell(16); + cell17.SetCellValue(item.PaintSecha.ToString()); + cell17.CellStyle = style; + var cell18 = row.CreateCell(17); + cell18.SetCellValue(item.PaintDianzi.ToString()); + cell18.CellStyle = style; + var cell19 = row.CreateCell(18); + cell19.SetCellValue(item.PaintOther.ToString()); + cell19.CellStyle = style; + // 设备 } _lastWorkOrderId = item.WorkorderId; rowIndex++; } + + // 导出 IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment)); string fullPath = Path.Combine(webHostEnvironment.WebRootPath, "QualityStatisticsExport", fileName); using (FileStream fs = new(fullPath, FileMode.Create, FileAccess.Write)) diff --git a/ZR.Service/mes/qc/IService/IQCStatisticsService.cs b/ZR.Service/mes/qc/IService/IQCStatisticsService.cs index 9e4dde6d..72abaefa 100644 --- a/ZR.Service/mes/qc/IService/IQCStatisticsService.cs +++ b/ZR.Service/mes/qc/IService/IQCStatisticsService.cs @@ -10,6 +10,12 @@ namespace ZR.Service.mes.qc.IService { public interface IQCStatisticsService { + /// + /// 获取描述清单数据 + /// + /// 成品零件号 + /// + public string GetDescription(string partnumber); #region 获取统计表 //获取 首检 diff --git a/ZR.Service/mes/qc/QCStatisticsService.cs b/ZR.Service/mes/qc/QCStatisticsService.cs index 93584228..e4319462 100644 --- a/ZR.Service/mes/qc/QCStatisticsService.cs +++ b/ZR.Service/mes/qc/QCStatisticsService.cs @@ -14,6 +14,8 @@ using ZR.Model.mes.md; using ZR.Model.MES.qc; using ZR.Model.MES.qc.DTO; using ZR.Model.MES.qu; +using ZR.Model.MES.wms; +using ZR.Model.MES.wms.Dto; using ZR.Service.mes.qc.IService; namespace ZR.Service.mes.qc @@ -62,7 +64,18 @@ namespace ZR.Service.mes.qc List data = Context.Queryable().Where(predicate).OrderBy(it => it.WorkorderId).OrderBy(it => it.Remark2).ToPageList(pageNum, pageSize, ref totalNum); - + foreach (QcQualityStatisticsFirst item in data) + { + WmMaterial material = Context.Queryable() + .Where(it => it.Partnumber == item.FinishedPartNumber) + .First(); + if (material == null) + { + item.ProductDescription = "此零件号不在物料清单内!"; + continue; + } + item.ProductDescription = !string.IsNullOrEmpty(material.Description) ? material.Description : material.ProductName; + } return (data, totalNum); } @@ -97,7 +110,18 @@ namespace ZR.Service.mes.qc List data = Context.Queryable().Where(predicate).OrderBy(it => it.WorkorderId).OrderBy(it => it.Remark2).ToPageList(pageNum, pageSize, ref totalNum); - + foreach (QcQualityStatisticsAgain item in data) + { + WmMaterial material = Context.Queryable() + .Where(it => it.Partnumber == item.FinishedPartNumber) + .First(); + if (material == null) + { + item.ProductDescription = "此零件号不在物料清单内!"; + continue; + } + item.ProductDescription = !string.IsNullOrEmpty(material.Description) ? material.Description : material.ProductName; + } return (data, totalNum); } @@ -133,7 +157,18 @@ namespace ZR.Service.mes.qc List data = Context.Queryable().Where(predicate).OrderBy(it => it.WorkorderId).OrderBy(it => it.Remark2).ToPageList(pageNum, pageSize, ref totalNum); - + foreach (QcQualityStatisticsFinal item in data) + { + WmMaterial material = Context.Queryable() + .Where(it => it.Partnumber == item.FinishedPartNumber) + .First(); + if (material == null) + { + item.ProductDescription = "此零件号不在物料清单内!"; + continue; + } + item.ProductDescription = !string.IsNullOrEmpty(material.Description) ? material.Description : material.ProductName; + } return (data, totalNum); } @@ -167,7 +202,18 @@ namespace ZR.Service.mes.qc .ToExpression(); List data = Context.Queryable().Where(predicate).OrderBy(it => it.WorkorderId).OrderBy(it => it.Remark2).ToPageList(pageNum, pageSize, ref totalNum); - + foreach (QcQualityStatisticsTotal item in data) + { + WmMaterial material = Context.Queryable() + .Where(it => it.Partnumber == item.FinishedPartNumber) + .First(); + if (material == null) + { + item.ProductDescription = "此零件号不在物料清单内!"; + continue; + } + item.ProductDescription = !string.IsNullOrEmpty(material.Description) ? material.Description : material.ProductName; + } return (data, totalNum); } @@ -307,5 +353,27 @@ namespace ZR.Service.mes.qc }).ToList(); return newList; } + + public string GetDescription(string partnumber) + { + try + { + WmMaterial material = Context.Queryable() + .Where(it => it.Partnumber == partnumber) + .First(); + if (material == null) + { + return "此零件号不在物料清单内!"; + } + else + { + return !string.IsNullOrEmpty(material.Description) ? material.Description : material.ProductName; + } + + }catch(Exception ex) + { + return "获取描述异常!"; + } + } } } diff --git a/ZR.Service/mes/wms/WmGoodsBatchSearchService.cs b/ZR.Service/mes/wms/WmGoodsBatchSearchService.cs index ef7ade90..4ed787fb 100644 --- a/ZR.Service/mes/wms/WmGoodsBatchSearchService.cs +++ b/ZR.Service/mes/wms/WmGoodsBatchSearchService.cs @@ -86,7 +86,7 @@ namespace ZR.Service.Business try { PagedInfo result = new PagedInfo(); - // 出库记录 + // 入库记录 List list = Context.Queryable() .Where(it => it.PackageCodeClient.Contains(parm.PackageCode)) .Select(it => new WmGoodsBatchTableDto @@ -105,7 +105,7 @@ namespace ZR.Service.Business Remark = it.Remark, HasChild = false }) - .OrderBy(it => it.Id) + .OrderByDescending(it => it.EntryWarehouseTime) .ToList(); foreach (WmGoodsBatchTableDto item in list) { @@ -157,7 +157,7 @@ namespace ZR.Service.Business "GROUP BY\n" + " Partnumber \n" + "ORDER BY\n" + - " ID DESC"; + " EntryWarehouseTime DESC"; PagedInfo result = Context.SqlQueryable(sql) .Where(exp) .Select() @@ -206,7 +206,7 @@ namespace ZR.Service.Business Remark = it.Remark, HasChild = false }) - .OrderBy(it => it.Id) + .OrderByDescending(it => it.EntryWarehouseTime) .ToList(); foreach (WmGoodsBatchTableDto item in list) { @@ -311,7 +311,7 @@ namespace ZR.Service.Business Remark = it.Remark, HasChild = false }) - .OrderBy(it => it.Id) + .OrderByDescending(it => it.OutTime) .ToList(); foreach (WmGoodsBatchTableDto item in list) { @@ -363,7 +363,7 @@ namespace ZR.Service.Business "GROUP BY\n" + " Partnumber \n" + "ORDER BY\n" + - " ID DESC"; + " OutTime DESC"; PagedInfo result = Context.SqlQueryable(sql) .Where(exp) .Select() @@ -411,7 +411,7 @@ namespace ZR.Service.Business Remark = it.Remark, HasChild = false }) - .OrderBy(it => it.Id) + .OrderByDescending(it => it.OutTime) .ToList(); foreach (WmGoodsBatchTableDto item in list) { @@ -504,7 +504,7 @@ namespace ZR.Service.Business Remark = it.Remark, HasChild = false }) - .OrderBy(it => it.Id) + .OrderByDescending(it => it.OutTime) .ToList(); foreach (WmGoodsBatchTableDto item in list) {