[webApi]修改水電報表小bug

This commit is contained in:
張家睿 2024-03-12 17:45:46 +08:00
parent b223e6a75f
commit 94f4b257fc

View File

@ -514,9 +514,9 @@ namespace FrontendWebApi.ApiControllers
bill_perRCV, bill_perRCV,
elec_result, elec_result,
water_result, water_result,
bill_perKWH * elec_result AS elec_bill, elec_bill,
bill_perRCV * water_result AS water_bill, water_bill,
ROUND(bill_perKWH * elec_result + bill_perRCV * water_result) AS total_bill (elec_bill + water_bill) AS total_bill
FROM ( FROM (
SELECT SELECT
a.tenant_name, a.tenant_name,
@ -525,13 +525,15 @@ namespace FrontendWebApi.ApiControllers
bill_perKWH, bill_perKWH,
bill_perRCV, 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 = '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 FROM archive_electric_meter_tenant_bill a
JOIN archive_electric_meter_tenant_list b ON a.tenant_guid = b.tenant_guid JOIN archive_electric_meter_tenant_list b ON a.tenant_guid = b.tenant_guid
JOIN device c ON a.device_number = c.device_number JOIN device c ON a.device_number = c.device_number
WHERE {building_tag} WHERE {building_tag}
GROUP BY a.tenant_name GROUP BY a.tenant_name
) subquery_alias"; ) AS subquery_alias;";
outputBill = await backendRepository.GetAllAsync<OutputBill>(sqlString); outputBill = await backendRepository.GetAllAsync<OutputBill>(sqlString);
string filePath = CreateOutputForm(outputBill); string filePath = CreateOutputForm(outputBill);