[後端] 修改水電表現是欄位
This commit is contained in:
parent
9d36817c52
commit
9bd6ca4a31
@ -131,17 +131,38 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
order by fd.device_number, fd.date";
|
order by fd.device_number, fd.date";
|
||||||
var rawData = await backendRepository.GetAllAsync<HydroMeterRawDataOutput>(sql,
|
var rawData = await backendRepository.GetAllAsync<HydroMeterRawDataOutput>(sql,
|
||||||
new { startTime = startTime, endtime = endTime, building_tag = input.building_tag, floor_tag = input.floor_tag, dateFormat = dateFormat });
|
new { startTime = startTime, endtime = endTime, building_tag = input.building_tag, floor_tag = input.floor_tag, dateFormat = dateFormat });
|
||||||
var list = rawData
|
|
||||||
|
List<HydroMeterOutput> list = new List<HydroMeterOutput>();
|
||||||
|
if (tag_quantity == "5")
|
||||||
|
{
|
||||||
|
list = rawData
|
||||||
.GroupBy(x => new { building_tag = x.device_number.Split("_")[0], floor_tag = x.device_number.Split("_")[2], device_serial_tag = x.device_number.Split("_")[4] })
|
.GroupBy(x => new { building_tag = x.device_number.Split("_")[0], floor_tag = x.device_number.Split("_")[2], device_serial_tag = x.device_number.Split("_")[4] })
|
||||||
.Select(x => new HydroMeterOutput { building_tag = x.Key.building_tag, floor_tag = x.Key.floor_tag, device_serial_tag = x.Key.device_serial_tag })
|
.Select(x => new HydroMeterOutput { building_tag = x.Key.building_tag, floor_tag = x.Key.floor_tag, device_serial_tag = x.Key.device_serial_tag })
|
||||||
.ToList();
|
.ToList();
|
||||||
|
}
|
||||||
|
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("_")[3] })
|
||||||
|
.Select(x => new HydroMeterOutput { building_tag = x.Key.building_tag, floor_tag = x.Key.floor_tag, device_serial_tag = x.Key.device_serial_tag })
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var l in list)
|
foreach (var l in list)
|
||||||
{
|
{
|
||||||
l.rawData = new List<HydroMeterRawDataOutput>();
|
l.rawData = new List<HydroMeterRawDataOutput>();
|
||||||
l.rawData.AddRange(
|
if (tag_quantity == "5")
|
||||||
rawData.Where(x => x.device_number.Split("_")[0] == l.building_tag && x.device_number.Split("_")[2] == l.floor_tag && x.device_number.Split("_")[4] == l.device_serial_tag)
|
{
|
||||||
);
|
l.rawData.AddRange(
|
||||||
|
rawData.Where(x => x.device_number.Split("_")[0] == l.building_tag && x.device_number.Split("_")[2] == l.floor_tag && x.device_number.Split("_")[4] == l.device_serial_tag)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
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("_")[3] == l.device_serial_tag)
|
||||||
|
);
|
||||||
|
}
|
||||||
l.building_name = await backendRepository.GetOneAsync<string>("select full_name from building where building_tag = @building_tag and deleted = 0",
|
l.building_name = await backendRepository.GetOneAsync<string>("select full_name from building where building_tag = @building_tag and deleted = 0",
|
||||||
new { building_tag = l.building_tag });
|
new { building_tag = l.building_tag });
|
||||||
l.total = l.rawData.Sum(x => x.avg_rawdata).ToString();
|
l.total = l.rawData.Sum(x => x.avg_rawdata).ToString();
|
||||||
@ -271,17 +292,38 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
|
|
||||||
var rawData = await backendRepository.GetAllAsync<HydroMeterRawDataOutput>(sql,
|
var rawData = await backendRepository.GetAllAsync<HydroMeterRawDataOutput>(sql,
|
||||||
new { startTime = startTime, endTime = endTime, building_tag = input.building_tag, floor_tag = input.floor_tag, dateFormat = dateFormat });
|
new { startTime = startTime, endTime = endTime, building_tag = input.building_tag, floor_tag = input.floor_tag, dateFormat = dateFormat });
|
||||||
var list = rawData
|
|
||||||
|
List<HydroMeterOutput> list = new List<HydroMeterOutput>();
|
||||||
|
if (tag_quantity == "5")
|
||||||
|
{
|
||||||
|
list = rawData
|
||||||
.GroupBy(x => new { building_tag = x.device_number.Split("_")[0], floor_tag = x.device_number.Split("_")[2], device_serial_tag = x.device_number.Split("_")[4] })
|
.GroupBy(x => new { building_tag = x.device_number.Split("_")[0], floor_tag = x.device_number.Split("_")[2], device_serial_tag = x.device_number.Split("_")[4] })
|
||||||
.Select(x => new HydroMeterOutput { building_tag = x.Key.building_tag, floor_tag = x.Key.floor_tag, device_serial_tag = x.Key.device_serial_tag })
|
.Select(x => new HydroMeterOutput { building_tag = x.Key.building_tag, floor_tag = x.Key.floor_tag, device_serial_tag = x.Key.device_serial_tag })
|
||||||
.ToList();
|
.ToList();
|
||||||
|
}
|
||||||
|
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("_")[3] })
|
||||||
|
.Select(x => new HydroMeterOutput { building_tag = x.Key.building_tag, floor_tag = x.Key.floor_tag, device_serial_tag = x.Key.device_serial_tag })
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var l in list)
|
foreach (var l in list)
|
||||||
{
|
{
|
||||||
l.rawData = new List<HydroMeterRawDataOutput>();
|
l.rawData = new List<HydroMeterRawDataOutput>();
|
||||||
l.rawData.AddRange(
|
if (tag_quantity == "5")
|
||||||
rawData.Where(x => x.device_number.Split("_")[0] == l.building_tag && x.device_number.Split("_")[2] == l.floor_tag && x.device_number.Split("_")[4] == l.device_serial_tag)
|
{
|
||||||
);
|
l.rawData.AddRange(
|
||||||
|
rawData.Where(x => x.device_number.Split("_")[0] == l.building_tag && x.device_number.Split("_")[2] == l.floor_tag && x.device_number.Split("_")[4] == l.device_serial_tag)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
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("_")[3] == l.device_serial_tag)
|
||||||
|
);
|
||||||
|
}
|
||||||
l.building_name = await backendRepository.GetOneAsync<string>("select full_name from building where building_tag = @building_tag and deleted = 0",
|
l.building_name = await backendRepository.GetOneAsync<string>("select full_name from building where building_tag = @building_tag and deleted = 0",
|
||||||
new { building_tag = l.building_tag });
|
new { building_tag = l.building_tag });
|
||||||
l.total = l.rawData.Sum(x => x.avg_rawdata).ToString();
|
l.total = l.rawData.Sum(x => x.avg_rawdata).ToString();
|
||||||
|
Loading…
Reference in New Issue
Block a user