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": {