From 2a70a285e2a67eda4187b97e84bdca5b9cce2487 Mon Sep 17 00:00:00 2001 From: dev02 Date: Tue, 1 Aug 2023 18:29:25 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=89=8D=E7=AB=AF]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=9F=A5=E8=A9=A2=E5=96=AE=E8=99=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/_operation.html | 2 + .../ApiControllers/OperationController.cs | 60 +++++++++++-------- .../operation/維修_2023-07-31_2023-07-31.xlsx | 0 3 files changed, 36 insertions(+), 26 deletions(-) create mode 100644 FrontendWebApi/wwwroot/excel/operation/維修_2023-07-31_2023-07-31.xlsx diff --git a/Frontend/_operation.html b/Frontend/_operation.html index c605d4f..e58d435 100644 --- a/Frontend/_operation.html +++ b/Frontend/_operation.html @@ -946,6 +946,8 @@ function snSearch() { clearPageAct(); + pageAct.startdate = $('#startdate').val() + "T00:00:00"; + pageAct.enddate = $('#enddate').val() + "T23:59:59" pageAct.serial_number = $('#serial_number').val() || null; refTable(); } diff --git a/FrontendWebApi/ApiControllers/OperationController.cs b/FrontendWebApi/ApiControllers/OperationController.cs index 6f53423..a9acb76 100644 --- a/FrontendWebApi/ApiControllers/OperationController.cs +++ b/FrontendWebApi/ApiControllers/OperationController.cs @@ -351,35 +351,35 @@ namespace FrontendWebApi.ApiControllers cell = row.CreateCell(i); if (i == 0) { - cell.SetCellValue(of.system_key); + cell.SetCellValue(of.system_key ?? ""); } if (i == 1) { - cell.SetCellValue(of.name); + cell.SetCellValue(of.name ?? ""); } if (i == 2) { - cell.SetCellValue(of.contact_person); + cell.SetCellValue(of.contact_person ?? ""); } if (i == 3) { - cell.SetCellValue(of.phone); + cell.SetCellValue(of.phone ?? ""); } if (i == 4) { - cell.SetCellValue(of.email); + cell.SetCellValue(of.email ?? ""); } if (i == 5) { - cell.SetCellValue(of.tax_id_number); + cell.SetCellValue(of.tax_id_number ?? ""); } if (i == 6) { - cell.SetCellValue(of.remark); + cell.SetCellValue(of.remark ?? ""); } if (i == 7) { - cell.SetCellValue(of.Created_at); + cell.SetCellValue(of.Created_at ?? ""); } cell.CellStyle = style12; @@ -395,7 +395,7 @@ namespace FrontendWebApi.ApiControllers and d.device_building_tag = SUBSTRING_INDEX(SUBSTRING_INDEX(opr.fix_do_code, '_', 2), '_', -1) and d.device_floor_tag = SUBSTRING_INDEX(SUBSTRING_INDEX(opr.fix_do_code, '_', 5), '_', -1) and d.device_system_tag = opr.device_system_category_layer2 and d.device_name_tag = opr.device_system_category_layer3 left join userinfo ui on opr.work_person_id = ui.userinfo_guid - where opr.deleted = 0 and opr.work_type = 1 and opr.created_at >= '{ee.startdate.ToString().Split("T")[0]}' and opr.created_at <= '{ee.enddate.ToString().Split("T")[0]}';"; + where opr.deleted = 0 and opr.work_type = 1 and opr.created_at >= '{ee.startdate}' and opr.created_at <= '{ee.enddate}';"; var sheet = workbook.CreateSheet("廠商資料"); var operation_record = backendRepository.GetAllAsync(sqlString); List operation_record_file = new List(); @@ -465,27 +465,27 @@ namespace FrontendWebApi.ApiControllers cell = row.CreateCell(i); if (i == 0) { - cell.SetCellValue(or.work_type_name); + cell.SetCellValue(or.work_type_name == "null" ? "" : or.work_type_name); } if (i == 1) { - cell.SetCellValue(or.location); + cell.SetCellValue(or.location == "null" ? "" : or.location); } if (i == 2) { - cell.SetCellValue(or.formId); + cell.SetCellValue(or.formId == "null" ? "" : or.formId); } if (i == 3) { - cell.SetCellValue(or.device_name); + cell.SetCellValue(or.device_name == "null" ? "" : or.device_name); } if (i == 4) { - cell.SetCellValue(or.status_name); + cell.SetCellValue(or.status_name == "null" ? "" : or.status_name); } if (i == 5) { - cell.SetCellValue(or.user_full_name); + cell.SetCellValue(or.user_full_name == "null" ? "" : or.user_full_name); } if (i == 6) { @@ -547,7 +547,7 @@ namespace FrontendWebApi.ApiControllers } if (i == 9) { - cell.SetCellValue(or.Created_at); + cell.SetCellValue(or.Created_at ?? ""); } cell.CellStyle = style12; @@ -559,13 +559,20 @@ namespace FrontendWebApi.ApiControllers } else if (ee.work_type == 2) { + + + + + + + var sqlString = $@"select opr.*, d.full_name as device_name, ui.full_name as user_full_name from operation_record opr left join device d on opr.fix_do_code = d.device_number and d.deleted = 0 and d.device_area_tag = SUBSTRING_INDEX(opr.fix_do_code, '_', 1) and d.device_building_tag = SUBSTRING_INDEX(SUBSTRING_INDEX(opr.fix_do_code, '_', 2), '_', -1) and d.device_floor_tag = SUBSTRING_INDEX(SUBSTRING_INDEX(opr.fix_do_code, '_', 5), '_', -1) and d.device_system_tag = opr.device_system_category_layer2 and d.device_name_tag = opr.device_system_category_layer3 left join userinfo ui on opr.work_person_id = ui.userinfo_guid - where opr.deleted = 0 and opr.work_type = 2 and opr.created_at >= '{ee.startdate.ToString().Split("T")[0]}' and opr.created_at <= '{ee.enddate.ToString().Split("T")[0]}';"; + where opr.deleted = 0 and opr.work_type = 2 and opr.created_at >= '{ee.startdate}' and opr.created_at <= '{ee.enddate}';"; var sheet = workbook.CreateSheet("廠商資料"); var operation_record = backendRepository.GetAllAsync(sqlString); @@ -576,7 +583,8 @@ namespace FrontendWebApi.ApiControllers if (operation_record.Result.Count > 0) { foreach (var or in operation_record.Result) - { + + sqlString = $@"select * from operation_record_file where record_id = @record_id"; var param = new { @record_id = or.id }; operation_record_file = backendRepository.GetAllAsync(sqlString, param).Result; @@ -641,32 +649,32 @@ namespace FrontendWebApi.ApiControllers cell = row.CreateCell(i); if (i == 0) { - cell.SetCellValue(or.work_type_name); + cell.SetCellValue(or.work_type_name == "null" ? "" : or.work_type_name); } if (i == 1) { - cell.SetCellValue(or.location); + cell.SetCellValue(or.location == "null" ? "" : or.location); } if (i == 2) { - cell.SetCellValue(or.error_code); + cell.SetCellValue(or.error_code == "null" ? "" : or.error_code); sheet.AutoSizeColumn(i); } if (i == 3) { - cell.SetCellValue(or.formId); + cell.SetCellValue(or.formId == "null" ? "" : or.formId); } if (i == 4) { - cell.SetCellValue(or.device_name); + cell.SetCellValue(or.device_name == "null" ? "" : or.device_name); } if (i == 5) { - cell.SetCellValue(or.status_name); + cell.SetCellValue(or.status_name == "null" ? "" : or.status_name); } if (i == 6) { - cell.SetCellValue(or.user_full_name); + cell.SetCellValue(or.user_full_name == "null" ? "" : or.user_full_name); } if (i == 7) { @@ -728,7 +736,7 @@ namespace FrontendWebApi.ApiControllers } if (i == 10) { - cell.SetCellValue(or.Created_at); + cell.SetCellValue(or.Created_at == "null" ? "" : or.Created_at); } cell.CellStyle = style12; diff --git a/FrontendWebApi/wwwroot/excel/operation/維修_2023-07-31_2023-07-31.xlsx b/FrontendWebApi/wwwroot/excel/operation/維修_2023-07-31_2023-07-31.xlsx new file mode 100644 index 0000000..e69de29