From 96c3c2426f128790b40573dac7e23485f9496237 Mon Sep 17 00:00:00 2001 From: keke Date: Tue, 29 Aug 2023 15:47:56 +0800 Subject: [PATCH] =?UTF-8?q?[FE=20API]=20=E6=9B=B4=E6=96=B0=20HydroMeterOut?= =?UTF-8?q?put=20=E6=9E=B6=E6=A7=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/HydroMeterController.cs | 19 ++++++------------- FrontendWebApi/Models/HydroMeter.cs | 15 --------------- 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/FrontendWebApi/ApiControllers/HydroMeterController.cs b/FrontendWebApi/ApiControllers/HydroMeterController.cs index 902cd2d..c195bfa 100644 --- a/FrontendWebApi/ApiControllers/HydroMeterController.cs +++ b/FrontendWebApi/ApiControllers/HydroMeterController.cs @@ -830,15 +830,8 @@ namespace FrontendWebApi.ApiControllers public FileResult OpeExportEachTotalCompareExcelElec([FromBody] HydroMeterInput input) { List> result = new List>(); - var building = backendRepository.GetAllAsync("select * from building where deleted = 0").Result; - StringBuilder fix_buildingTag = new StringBuilder(); - foreach (var b in building) - { - fix_buildingTag.Append("'").Append(b.building_tag.Trim()).Append("', "); - } - input.building_tag = fix_buildingTag.ToString().TrimEnd(',', ' '); - // result.Add(ElectricListEachTotal(input).Result.Value.Data.ToList()); + result.Add(ElectricListEachTotal(input).Result.Value.Data.ToList()); // --- 8/24 修改到這裡囉 --- @@ -999,9 +992,9 @@ namespace FrontendWebApi.ApiControllers [HttpPost] [Route("api/ElectricListEachTotal")] - public async Task>>> ElectricListEachTotal([FromBody] HydroMeterInput input) + public async Task>>> ElectricListEachTotal([FromBody] HydroMeterInput input) { - ApiResult> apiResult = new ApiResult>(jwt_str); + ApiResult> apiResult = new ApiResult>(jwt_str); if (!jwtlife) { apiResult.Code = "5000"; @@ -1053,7 +1046,7 @@ namespace FrontendWebApi.ApiControllers if (string.IsNullOrEmpty(isTable)) //check for has table or not { apiResult.Code = "0000"; - apiResult.Data = new List() { }; + apiResult.Data = new List() { }; return Ok(apiResult); } @@ -1073,11 +1066,11 @@ order by a.priority"; Logger.LogInformation("SQL = " + sql + " building=" + input.building_tag + " floor_tag = " + input.floor_tag); var rawData = await backendRepository.GetAllAsync(sql); - List ResultData = new List(); + List ResultData = new List(); ResultData = rawData .GroupBy(x => new { building_tag = x.device_number.Split("_")[1], floor_tag = x.device_number.Split("_")[4], device_master = x.device_number.Split("_")[5], device_serial_tag = x.device_number.Split("_")[7], device_number = x.device_number }) - .Select(x => new HydroMeterEachTotalOutput { building_tag = x.Key.building_tag, floor_tag = x.Key.floor_tag, device_serial_tag = x.Key.device_serial_tag, device_master = x.Key.device_master, device_number = x.Key.device_number }) + .Select(x => new HydroMeterOutput { building_tag = x.Key.building_tag, floor_tag = x.Key.floor_tag, device_serial_tag = x.Key.device_serial_tag, device_master = x.Key.device_master, device_number = x.Key.device_number }) .ToList(); foreach (var l in ResultData) diff --git a/FrontendWebApi/Models/HydroMeter.cs b/FrontendWebApi/Models/HydroMeter.cs index db1de3a..3590b60 100644 --- a/FrontendWebApi/Models/HydroMeter.cs +++ b/FrontendWebApi/Models/HydroMeter.cs @@ -49,21 +49,6 @@ namespace FrontendWebApi.Models public string avg_rawdata { get; set; } } - public class HydroMeterEachTotalOutput - { - public string building_name { get; set; } - public string building_tag { get; set; } - public string floor_tag { get; set; } - public string device_serial_tag { get; set; } - public string device_master { get; set; } - public string device_number { get; set; } - public string device_full_name { get; set; } - public string total { get; set; } - public string price { get; set; } - public string total_price { get; set; } - public List rawData { get; set; } - } - public class HydroMeterRawDataEachTotalOutput { public string building_name { get; set; }