质量报表导出修改,批量展示查询顺序修改
This commit is contained in:
@@ -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<QcQualityStatisticsFirstDto> 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))
|
||||
|
||||
Reference in New Issue
Block a user