diff --git a/FrontendWebApi/ApiControllers/TenantBillController.cs b/FrontendWebApi/ApiControllers/TenantBillController.cs index c60292a..f98ef55 100644 --- a/FrontendWebApi/ApiControllers/TenantBillController.cs +++ b/FrontendWebApi/ApiControllers/TenantBillController.cs @@ -269,7 +269,7 @@ namespace FrontendWebApi.ApiControllers // 找出資料庫存在的水電月份表 string checkTabelSql = $@"SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES - WHERE TABLE_SCHEMA = 'ibms_dome_dome' and TABLE_NAME like 'archive_electric_water_meter_day_%'"; + WHERE TABLE_SCHEMA like 'ibms_dome_%' and TABLE_NAME like 'archive_electric_water_meter_day_%'"; var existTable = await backendRepository.GetAllAsync(checkTabelSql); for (var i = 0; i <= monthsApart; i++) @@ -477,7 +477,8 @@ namespace FrontendWebApi.ApiControllers FROM archive_electric_meter_tenant_bill a JOIN archive_electric_meter_tenant_list b ON a.tenant_guid = b.tenant_guid join device c on a.device_number = c.device_number - where {building_tag} "; + where {building_tag} + GROUP BY a.tenant_name;"; outputBill = await backendRepository.GetAllAsync(sqlString); string filePath = CreateOutputForm(outputBill);