|
|
|
@ -58,19 +58,19 @@ namespace WebStarter.Controllers.Ammeter
|
|
|
|
|
[HttpGet("SevenDaysElectrical")]
|
|
|
|
|
public async Task<Result<EmeterEnergyResp>> SevenDaysElectrical()
|
|
|
|
|
{
|
|
|
|
|
// 获取直流和交流表数据
|
|
|
|
|
List<EmeterEnergy> sevenDaysElectrical = await _emeterEnergyService.SevenDaysElectrical();
|
|
|
|
|
List<EmeterEnergyChange> emeterEnergyChanges = await _emeterEnergyChangeService.SevenDaysElectrical();
|
|
|
|
|
|
|
|
|
|
List<EmeterDayEnergy> sevenDaysElectrical = await _emeterDayEnergyService.SevenDaysElectrical(1);
|
|
|
|
|
List<EmeterDayEnergy> emeterEnergyChanges = await _emeterDayEnergyService.SevenDaysElectrical(2);
|
|
|
|
|
|
|
|
|
|
EmeterEnergyResp resp = new EmeterEnergyResp();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ChargeAssignment(sevenDaysElectrical, emeterEnergyChanges, resp);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ElectricEnergyDay(sevenDaysElectrical, emeterEnergyChanges, resp);
|
|
|
|
|
|
|
|
|
|
return Result<EmeterEnergyResp>.Success(resp, "成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 30天累计能耗
|
|
|
|
@ -79,13 +79,13 @@ namespace WebStarter.Controllers.Ammeter
|
|
|
|
|
[HttpGet("GetAllElectricalData")]
|
|
|
|
|
public async Task<Result<EmeterEnergyResp>> GetAllElectricalData()
|
|
|
|
|
{
|
|
|
|
|
List<EmeterEnergy> emeterEnergy = await _emeterEnergyService.GetAllElectricalData();
|
|
|
|
|
List<EmeterEnergyChange> emeterEnergyChanges = await _emeterEnergyChangeService.GetAllElectricalData();
|
|
|
|
|
|
|
|
|
|
List<EmeterDayEnergy> emeterEnergy = await _emeterDayEnergyService.GetAllElectricalData(1);
|
|
|
|
|
List<EmeterDayEnergy> emeterEnergyChanges = await _emeterDayEnergyService.GetAllElectricalData(2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EmeterEnergyResp resp = new EmeterEnergyResp();
|
|
|
|
|
|
|
|
|
|
ChargeAssignment(emeterEnergy, emeterEnergyChanges, resp);
|
|
|
|
|
|
|
|
|
|
ElectricEnergyDay(emeterEnergy, emeterEnergyChanges, resp);
|
|
|
|
|
return Result<EmeterEnergyResp>.Success(resp, "成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -98,15 +98,29 @@ namespace WebStarter.Controllers.Ammeter
|
|
|
|
|
public async Task<Result<EmeterEnergyResp>> GetLastDayMeterData()
|
|
|
|
|
{
|
|
|
|
|
// 获取最近一天直流和交流表数据
|
|
|
|
|
List<EmeterEnergy> daysElectrical = await _emeterEnergyService.GetTodayHourlyElectricalData();
|
|
|
|
|
List<EmeterEnergyChange> daysElectricalChange =
|
|
|
|
|
await _emeterEnergyChangeService.GetTodayHourlyElectricalData();
|
|
|
|
|
List<EmeterHourEnergy> daysElectrical = await _emeterHourEnergyService.GetTodayHourlyElectricalData(1);
|
|
|
|
|
List<EmeterHourEnergy> daysElectricalChange =
|
|
|
|
|
await _emeterHourEnergyService.GetTodayHourlyElectricalData(2);
|
|
|
|
|
|
|
|
|
|
EmeterEnergyResp resp = new EmeterEnergyResp();
|
|
|
|
|
|
|
|
|
|
var config = new MapperConfiguration(cfg =>
|
|
|
|
|
{
|
|
|
|
|
cfg.CreateMap<EmeterResp, EmeterHourEnergy>().ReverseMap();
|
|
|
|
|
});
|
|
|
|
|
IMapper mapper = config.CreateMapper();
|
|
|
|
|
|
|
|
|
|
ChargeAssignment(daysElectrical, daysElectricalChange, resp);
|
|
|
|
|
List<EmeterResp> EnergyList = mapper.Map<List<EmeterResp>>(daysElectrical);
|
|
|
|
|
// 类型赋值直流
|
|
|
|
|
EnergyList?.ForEach(emeterResp => emeterResp.Type = 0);
|
|
|
|
|
|
|
|
|
|
List<EmeterResp> EnergyChangeList = mapper.Map<List<EmeterResp>>(daysElectricalChange);
|
|
|
|
|
// 类型赋值交流
|
|
|
|
|
EnergyChangeList?.ForEach(emeterResp => emeterResp.Type = 1);
|
|
|
|
|
|
|
|
|
|
resp.emeterEnergy = EnergyList.OrderBy(i => i.Code).ToList();
|
|
|
|
|
resp.emeterEnergyChange = EnergyChangeList.OrderBy(i => i.Code).ToList();
|
|
|
|
|
|
|
|
|
|
return Result<EmeterEnergyResp>.Success(resp, "成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -115,10 +129,10 @@ namespace WebStarter.Controllers.Ammeter
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("GetTodayHourlyEnergy")]
|
|
|
|
|
public async Task<Result<List<EmeterEnergy>>> GetTodayHourlyElectricalData()
|
|
|
|
|
public async Task<Result<List<EmeterHourEnergy>>> GetTodayHourlyElectricalData()
|
|
|
|
|
{
|
|
|
|
|
// 直流表数据
|
|
|
|
|
return Result<List<EmeterEnergy>>.Success(await _emeterEnergyService.GetTodayHourlyElectricalData(), "成功");
|
|
|
|
|
return Result<List<EmeterHourEnergy>>.Success(await _emeterHourEnergyService.GetTodayHourlyElectricalData(1), "成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -127,11 +141,11 @@ namespace WebStarter.Controllers.Ammeter
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("GetTodayHourlyEnergyChange")]
|
|
|
|
|
public async Task<Result<List<EmeterEnergyChange>>> GetTodayHourlyElectricalChangeData()
|
|
|
|
|
public async Task<Result<List<EmeterHourEnergy>>> GetTodayHourlyElectricalChangeData()
|
|
|
|
|
{
|
|
|
|
|
// 交流表数据
|
|
|
|
|
return Result<List<EmeterEnergyChange>>.Success(
|
|
|
|
|
await _emeterEnergyChangeService.GetTodayHourlyElectricalData(), "成功");
|
|
|
|
|
return Result<List<EmeterHourEnergy>>.Success(
|
|
|
|
|
await _emeterHourEnergyService.GetTodayHourlyElectricalData(2), "成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -142,13 +156,28 @@ namespace WebStarter.Controllers.Ammeter
|
|
|
|
|
public async Task<Result<EmeterEnergyResp>> GetTodayMinutelyElectricalData()
|
|
|
|
|
{
|
|
|
|
|
// 获取最近一个小时直流和交流表数据
|
|
|
|
|
List<EmeterEnergy> minutesElectrical = await _emeterEnergyService.GetTodayMinutelyElectricalData();
|
|
|
|
|
List<EmeterEnergyChange> minutesElectricalChange =
|
|
|
|
|
await _emeterEnergyChangeService.GetTodayMinutelyElectricalData();
|
|
|
|
|
List<EmeterMinutesEnergy> minutesElectrical = await _emeterMinutesEnergyService.GetTodayMinutelyElectricalData(1);
|
|
|
|
|
List<EmeterMinutesEnergy> minutesElectricalChange =
|
|
|
|
|
await _emeterMinutesEnergyService.GetTodayMinutelyElectricalData(2);
|
|
|
|
|
|
|
|
|
|
EmeterEnergyResp resp = new EmeterEnergyResp();
|
|
|
|
|
|
|
|
|
|
ChargeAssignment(minutesElectrical, minutesElectricalChange, resp);
|
|
|
|
|
var config = new MapperConfiguration(cfg =>
|
|
|
|
|
{
|
|
|
|
|
cfg.CreateMap<EmeterResp, EmeterMinutesEnergy>().ReverseMap();
|
|
|
|
|
});
|
|
|
|
|
IMapper mapper = config.CreateMapper();
|
|
|
|
|
|
|
|
|
|
List<EmeterResp> EnergyList = mapper.Map<List<EmeterResp>>(minutesElectrical);
|
|
|
|
|
// 类型赋值直流
|
|
|
|
|
EnergyList?.ForEach(emeterResp => emeterResp.Type = 0);
|
|
|
|
|
|
|
|
|
|
List<EmeterResp> EnergyChangeList = mapper.Map<List<EmeterResp>>(minutesElectricalChange);
|
|
|
|
|
// 类型赋值交流
|
|
|
|
|
EnergyChangeList?.ForEach(emeterResp => emeterResp.Type = 1);
|
|
|
|
|
|
|
|
|
|
resp.emeterEnergy = EnergyList.OrderBy(i => i.Code).ToList();
|
|
|
|
|
resp.emeterEnergyChange = EnergyChangeList.OrderBy(i => i.Code).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Result<EmeterEnergyResp>.Success(resp, "成功");
|
|
|
|
@ -170,30 +199,42 @@ namespace WebStarter.Controllers.Ammeter
|
|
|
|
|
endTime = parsedEndTime.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
// 获取实时直流和交流表数据
|
|
|
|
|
List<EmeterEnergy> minutesElectrical = await _emeterEnergyService.GetEnergyMeterRealTime(endTime);
|
|
|
|
|
List<EmeterEnergyChange> minutesElectricalChange =
|
|
|
|
|
await _emeterEnergyChangeService.GetEnergyMeterRealTime(endTime);
|
|
|
|
|
|
|
|
|
|
EmeterEnergyResp resp = new EmeterEnergyResp();
|
|
|
|
|
|
|
|
|
|
ChargeAssignment(minutesElectrical, minutesElectricalChange, resp);
|
|
|
|
|
List<EmeterHourEnergy> minutesElectrical = await _emeterHourEnergyService.GetEnergyMeterRealTime(endTime, 1);
|
|
|
|
|
List<EmeterHourEnergy> minutesElectricalChange = await _emeterHourEnergyService.GetEnergyMeterRealTime(endTime, 2);
|
|
|
|
|
|
|
|
|
|
EmeterEnergyResp resp = new EmeterEnergyResp
|
|
|
|
|
{
|
|
|
|
|
emeterEnergy = TransformEnergyData(minutesElectrical, 0),
|
|
|
|
|
emeterEnergyChange = TransformEnergyData(minutesElectricalChange, 1)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return Result<EmeterEnergyResp>.Success(resp, "成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void ChargeAssignment(List<EmeterEnergy> emeterEnergy,
|
|
|
|
|
List<EmeterEnergyChange> emeterEnergyChanges, EmeterEnergyResp resp)
|
|
|
|
|
private List<EmeterResp> TransformEnergyData(List<EmeterHourEnergy> energyData, int type)
|
|
|
|
|
{
|
|
|
|
|
return energyData.Select(hourEnergy =>
|
|
|
|
|
{
|
|
|
|
|
DateTime? uploadTime = DateTime.TryParse(hourEnergy.Time, out DateTime parsedTime) ? parsedTime : (DateTime?)null;
|
|
|
|
|
|
|
|
|
|
return new EmeterResp
|
|
|
|
|
{
|
|
|
|
|
Code = hourEnergy.Code,
|
|
|
|
|
Value = hourEnergy.RealTimeValue,
|
|
|
|
|
UploadTime = uploadTime,
|
|
|
|
|
Type = type
|
|
|
|
|
};
|
|
|
|
|
}).OrderBy(e => e.Code).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void ElectricEnergyDay(List<EmeterDayEnergy> daysElectrical, List<EmeterDayEnergy> emeterEnergyChanges, EmeterEnergyResp resp)
|
|
|
|
|
{
|
|
|
|
|
var config = new MapperConfiguration(cfg =>
|
|
|
|
|
{
|
|
|
|
|
cfg.CreateMap<EmeterResp, EmeterEnergy>().ReverseMap();
|
|
|
|
|
cfg.CreateMap<EmeterResp, EmeterEnergyChange>().ReverseMap();
|
|
|
|
|
cfg.CreateMap<EmeterResp, EmeterDayEnergy>().ReverseMap();
|
|
|
|
|
});
|
|
|
|
|
IMapper mapper = config.CreateMapper();
|
|
|
|
|
|
|
|
|
|
List<EmeterResp> EnergyList = mapper.Map<List<EmeterResp>>(emeterEnergy);
|
|
|
|
|
List<EmeterResp> EnergyList = mapper.Map<List<EmeterResp>>(daysElectrical);
|
|
|
|
|
// 类型赋值直流
|
|
|
|
|
EnergyList?.ForEach(emeterResp => emeterResp.Type = 0);
|
|
|
|
|
|
|
|
|
|