diff --git a/FrontendWebApi/ApiControllers/HydroMeterController.cs b/FrontendWebApi/ApiControllers/HydroMeterController.cs index bd27c93..0b9d40d 100644 --- a/FrontendWebApi/ApiControllers/HydroMeterController.cs +++ b/FrontendWebApi/ApiControllers/HydroMeterController.cs @@ -142,6 +142,11 @@ namespace FrontendWebApi.ApiControllers var rawData = await backendRepository.GetAllAsync(sql, new { startTime = startTime, endtime = endTime, building_tag = input.building_tag, floor_tag = input.floor_tag, dateFormat = dateFormat }); + foreach (var rd in rawData) + { + rd.device_full_name = await backendRepository.GetOneAsync($"select full_name from device where device_number = '{rd.device_number}' and deleted = 0"); + } + List list = new List(); if (tag_quantity == "5") { @@ -314,6 +319,11 @@ namespace FrontendWebApi.ApiControllers var rawData = await backendRepository.GetAllAsync(sql, new { startTime = startTime, endTime = endTime, building_tag = input.building_tag, floor_tag = input.floor_tag, dateFormat = dateFormat }); + foreach (var rd in rawData) + { + rd.device_full_name = await backendRepository.GetOneAsync($"select full_name from device where device_number = '{rd.device_number}' and deleted = 0"); + } + List list = new List(); if (tag_quantity == "5") { @@ -325,8 +335,8 @@ namespace FrontendWebApi.ApiControllers else { list = rawData - .GroupBy(x => new { building_tag = x.device_number.Split("_")[1], floor_tag = x.device_number.Split("_")[4], device_serial_tag = x.device_number.Split("_")[7] }) - .Select(x => new HydroMeterOutput { building_tag = x.Key.building_tag, floor_tag = x.Key.floor_tag, device_serial_tag = x.Key.device_serial_tag }) + .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] }) + .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 }) .ToList(); } @@ -342,7 +352,7 @@ namespace FrontendWebApi.ApiControllers else { l.rawData.AddRange( - rawData.Where(x => x.device_number.Split("_")[1] == l.building_tag && x.device_number.Split("_")[4] == l.floor_tag && x.device_number.Split("_")[7] == l.device_serial_tag) + rawData.Where(x => x.device_number.Split("_")[1] == l.building_tag && x.device_number.Split("_")[4] == l.floor_tag && x.device_number.Split("_")[5] == l.device_master && x.device_number.Split("_")[7] == l.device_serial_tag) ); } l.building_name = await backendRepository.GetOneAsync("select full_name from building where building_tag = @building_tag and deleted = 0", diff --git a/FrontendWebApi/Models/HydroMeter.cs b/FrontendWebApi/Models/HydroMeter.cs index a3ffd70..3afd783 100644 --- a/FrontendWebApi/Models/HydroMeter.cs +++ b/FrontendWebApi/Models/HydroMeter.cs @@ -36,6 +36,7 @@ namespace FrontendWebApi.Models public string timeStamp { get; set; } public string device_number { get; set; } public decimal avg_rawdata { get; set; } + public string device_full_name { get; set; } } public class HydroMeterPriceInput