From 94f4b257fc30099054dbd2717d9035ea18035cf2 Mon Sep 17 00:00:00 2001 From: "jay.chang" Date: Tue, 12 Mar 2024 17:45:46 +0800 Subject: [PATCH] =?UTF-8?q?[webApi]=E4=BF=AE=E6=94=B9=E6=B0=B4=E9=9B=BB?= =?UTF-8?q?=E5=A0=B1=E8=A1=A8=E5=B0=8Fbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/TenantBillController.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/FrontendWebApi/ApiControllers/TenantBillController.cs b/FrontendWebApi/ApiControllers/TenantBillController.cs index 2c8f285..79e31c1 100644 --- a/FrontendWebApi/ApiControllers/TenantBillController.cs +++ b/FrontendWebApi/ApiControllers/TenantBillController.cs @@ -514,9 +514,9 @@ namespace FrontendWebApi.ApiControllers bill_perRCV, elec_result, water_result, - bill_perKWH * elec_result AS elec_bill, - bill_perRCV * water_result AS water_bill, - ROUND(bill_perKWH * elec_result + bill_perRCV * water_result) AS total_bill + elec_bill, + water_bill, + (elec_bill + water_bill) AS total_bill FROM ( SELECT a.tenant_name, @@ -525,13 +525,15 @@ namespace FrontendWebApi.ApiControllers bill_perKWH, bill_perRCV, SUM(CASE WHEN a.device_name_tag = 'E4' THEN result ELSE 0 END) AS elec_result, - SUM(CASE WHEN a.device_name_tag = 'W1' THEN result ELSE 0 END) AS water_result + SUM(CASE WHEN a.device_name_tag = 'W1' THEN result ELSE 0 END) AS water_result, + ROUND(bill_perKWH * SUM(CASE WHEN a.device_name_tag = 'E4' THEN result ELSE 0 END)) AS elec_bill, + ROUND(bill_perRCV * SUM(CASE WHEN a.device_name_tag = 'W1' THEN result ELSE 0 END)) AS water_bill 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} GROUP BY a.tenant_name - ) subquery_alias"; + ) AS subquery_alias;"; outputBill = await backendRepository.GetAllAsync(sqlString); string filePath = CreateOutputForm(outputBill);