From 34635571a95f3ddb333314196427a1be1849af2f Mon Sep 17 00:00:00 2001 From: "jay.chang" Date: Mon, 29 Jan 2024 18:24:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=AB=E6=99=82=E9=97=9C=E9=96=89=E8=AA=87?= =?UTF-8?q?=E6=9C=88=E6=9F=A5=E8=A9=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/TenantBillController.cs | 64 ++++++++++--------- FrontendWebApi/appsettings.Development.json | 4 +- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/FrontendWebApi/ApiControllers/TenantBillController.cs b/FrontendWebApi/ApiControllers/TenantBillController.cs index 5e7b31f..cc131b3 100644 --- a/FrontendWebApi/ApiControllers/TenantBillController.cs +++ b/FrontendWebApi/ApiControllers/TenantBillController.cs @@ -75,7 +75,7 @@ namespace FrontendWebApi.ApiControllers catch (Exception exception) { apiResult.Code = "9999"; - apiResult.Msg = "系統內部錯誤,請聯絡管理者。" + exception.Message; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } @@ -106,7 +106,7 @@ namespace FrontendWebApi.ApiControllers catch (Exception exception) { apiResult.Code = "9999"; - apiResult.Msg = "系統內部錯誤,請聯絡管理者。" + exception.Message; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; if (exception.Message.Contains($" for key 'PRIMARY'")) { apiResult.Msg = "已有相同使用者。"; @@ -140,7 +140,7 @@ namespace FrontendWebApi.ApiControllers catch (Exception exception) { apiResult.Code = "9999"; - apiResult.Msg = "系統內部錯誤,請聯絡管理者。" + exception.Message; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; if (exception.Message.Contains($"a foreign key constraint")) { apiResult.Msg = "水電報表仍有該用戶,無法修改名稱。"; @@ -167,7 +167,7 @@ namespace FrontendWebApi.ApiControllers catch (Exception exception) { apiResult.Code = "9999"; - apiResult.Msg = "系統內部錯誤,請聯絡管理者。" + exception.Message; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; if (exception.Message.Contains($"a foreign key constraint")) { apiResult.Msg = "水電報表仍有該用戶,無法刪除。"; @@ -222,7 +222,7 @@ namespace FrontendWebApi.ApiControllers catch (Exception exception) { apiResult.Code = "9999"; - apiResult.Msg = "系統內部錯誤,請聯絡管理者。" + exception.Message; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } @@ -273,27 +273,29 @@ namespace FrontendWebApi.ApiControllers } else { - sqlString = - $"UPDATE {TenantBilltable} " + - $"set tenant_name = (SELECT tenant_name from archive_electric_meter_tenant_list WHERE tenant_guid = '{tb.tenant_guid}'), start_timestamp = '{start_timestamp}',end_timestamp = '{end_timestamp}' , " + - $"result= " + - $"(SELECT sum(sub_result) " + - $"FROM ( " + - $" SELECT start_timestamp,device_number, sub_result " + - $" FROM archive_electric_water_meter_day_{startMonth} " + - $" WHERE device_number = '{tb.device_number}' " + - $" UNION ALL " + - $" SELECT start_timestamp,device_number, sub_result " + - $" FROM archive_electric_water_meter_day_{endMonth} " + - $" WHERE device_number = '{tb.device_number}' " + - $") combined_result " + - $"WHERE start_timestamp BETWEEN '{start_timestamp}' and '{end_timestamp}' " + - $"GROUP BY device_number) ," + - $"bill = " + - $"ROUND(result *(SELECT {bill_per} from {TenantListtable} WHERE tenant_guid = '{tb.tenant_guid}') ), " + - $"updated_at = '{updated_at}', " + - $"tenant_guid = '{tb.tenant_guid}' " + - $"WHERE device_number = '{tb.device_number}'"; + //sqlString = + // $"UPDATE {TenantBilltable} " + + // $"set tenant_name = (SELECT tenant_name from archive_electric_meter_tenant_list WHERE tenant_guid = '{tb.tenant_guid}'), start_timestamp = '{start_timestamp}',end_timestamp = '{end_timestamp}' , " + + // $"result= " + + // $"(SELECT sum(sub_result) " + + // $"FROM ( " + + // $" SELECT start_timestamp,device_number, sub_result " + + // $" FROM archive_electric_water_meter_day_{startMonth} " + + // $" WHERE device_number = '{tb.device_number}' " + + // $" UNION ALL " + + // $" SELECT start_timestamp,device_number, sub_result " + + // $" FROM archive_electric_water_meter_day_{endMonth} " + + // $" WHERE device_number = '{tb.device_number}' " + + // $") combined_result " + + // $"WHERE start_timestamp BETWEEN '{start_timestamp}' and '{end_timestamp}' " + + // $"GROUP BY device_number) ," + + // $"bill = " + + // $"ROUND(result *(SELECT {bill_per} from {TenantListtable} WHERE tenant_guid = '{tb.tenant_guid}') ), " + + // $"updated_at = '{updated_at}', " + + // $"tenant_guid = '{tb.tenant_guid}' " + + // $"WHERE device_number = '{tb.device_number}'"; + apiResult.Code = "9999"; + apiResult.Msg = "請選擇同一個月份"; } @@ -307,7 +309,7 @@ namespace FrontendWebApi.ApiControllers catch (Exception exception) { apiResult.Code = "9999"; - apiResult.Msg = "系統內部錯誤,請聯絡管理者。" + exception.Message; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } @@ -347,8 +349,8 @@ namespace FrontendWebApi.ApiControllers }; } catch (Exception exception) - { - _logger.LogError(exception.ToString()); + { + //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } return new FileContentResult(new byte[0], "application/pdf") { @@ -431,7 +433,7 @@ namespace FrontendWebApi.ApiControllers { string path = Configuration.GetValue("FilePath:OutputFormTemplate"); //string path = _webHostEnvironment.ContentRootPath + "\\StaticFiles\\import.html"; - if (!File.Exists(path)) + if (!System.IO.File.Exists(path)) { return ""; } @@ -445,7 +447,7 @@ namespace FrontendWebApi.ApiControllers { bill += $"
" + $"
" + - $" \"Taipei " + + $" \"Taipei " + $"

水電費用明細

" + $"
" + $"
" + diff --git a/FrontendWebApi/appsettings.Development.json b/FrontendWebApi/appsettings.Development.json index fedd6f3..cf16b64 100644 --- a/FrontendWebApi/appsettings.Development.json +++ b/FrontendWebApi/appsettings.Development.json @@ -13,8 +13,8 @@ "JwtLifeSeconds": 3600 }, "FilePath": { - "OutputForm": "D:\\jay.chang\\FrontendWebApi\\wwwroot\\upload\\OutputForm\\", //水電報表 檔案儲存位置 - "OutputFormTemplate": "D:\\jay.chang\\FrontendWebApi\\wwwroot\\upload\\OutputFormTemplate\\import.html" // 水電報表範本檔位置 + "OutputForm": "C:\\jay.chang\\ibms\\FrontendWebApi\\wwwroot\\upload\\OutputForm\\", //水電報表 檔案儲存位置 + "OutputFormTemplate": "C:\\jay.chang\\ibms\\FrontendWebApi\\wwwroot\\upload\\OutputFormTemplate\\import.html" // 水電報表範本檔位置 }, "DBConfig": { "MySqlDBConfig": {