|
|
|
@ -64,43 +64,51 @@ namespace WebStarter.Controllers.Ammeter
|
|
|
|
|
|
|
|
|
|
EmeterEnergyResp resp = new EmeterEnergyResp();
|
|
|
|
|
|
|
|
|
|
var config = new MapperConfiguration(cfg =>
|
|
|
|
|
{
|
|
|
|
|
cfg.CreateMap<EmeterResp, EmeterEnergy>().ReverseMap();
|
|
|
|
|
cfg.CreateMap<EmeterResp, EmeterEnergyChange>().ReverseMap();
|
|
|
|
|
});
|
|
|
|
|
IMapper mapper = config.CreateMapper();
|
|
|
|
|
|
|
|
|
|
List<EmeterResp> emeterEnergyList = mapper.Map<List<EmeterResp>>(sevenDaysElectrical);
|
|
|
|
|
List<EmeterResp> sevenEmeterResps = mapper.Map<List<EmeterResp>>(emeterEnergyChanges);
|
|
|
|
|
ChargeAssignment(sevenDaysElectrical, emeterEnergyChanges, resp);
|
|
|
|
|
|
|
|
|
|
resp.emeterEnergy = emeterEnergyList;
|
|
|
|
|
resp.emeterEnergyChange = sevenEmeterResps;
|
|
|
|
|
|
|
|
|
|
return Result<EmeterEnergyResp>.Success(resp,"成功");
|
|
|
|
|
}
|
|
|
|
|
#region 统计分析/电能表累计值信息
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 直流电能表累计值
|
|
|
|
|
/// 30天累计能耗
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("GetAllElectricalData")]
|
|
|
|
|
public async Task<Result<List<EmeterEnergy>>> GetAllElectricalData()
|
|
|
|
|
public async Task<Result<EmeterEnergyResp>> GetAllElectricalData()
|
|
|
|
|
{
|
|
|
|
|
// 直流表数据
|
|
|
|
|
return Result<List<EmeterEnergy>>.Success(await _emeterEnergyService.GetAllElectricalData(),"成功");
|
|
|
|
|
List<EmeterEnergy> emeterEnergy = await _emeterEnergyService.GetAllElectricalData();
|
|
|
|
|
List<EmeterEnergyChange> emeterEnergyChanges = await _emeterEnergyChangeService.GetAllElectricalData();
|
|
|
|
|
|
|
|
|
|
EmeterEnergyResp resp = new EmeterEnergyResp();
|
|
|
|
|
|
|
|
|
|
ChargeAssignment(emeterEnergy, emeterEnergyChanges, resp);
|
|
|
|
|
|
|
|
|
|
return Result<EmeterEnergyResp>.Success(resp,"成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 交流电能表累计值
|
|
|
|
|
/// 最近一天电表数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("GetAllEmeterEnergyChange")]
|
|
|
|
|
public async Task<Result<List<EmeterEnergyChange>>> GetAllEmeterEnergyChange()
|
|
|
|
|
[HttpGet("GetLastDayMeterData")]
|
|
|
|
|
public async Task<Result<EmeterEnergyResp>> GetLastDayMeterData()
|
|
|
|
|
{
|
|
|
|
|
// 交流表数据
|
|
|
|
|
return Result<List<EmeterEnergyChange>>.Success(await _emeterEnergyChangeService.GetAllElectricalData(),"成功");
|
|
|
|
|
// 获取最近一天直流和交流表数据
|
|
|
|
|
List<EmeterEnergy> daysElectrical = await _emeterEnergyService.GetTodayHourlyElectricalData();
|
|
|
|
|
List<EmeterEnergyChange> daysElectricalChange = await _emeterEnergyChangeService.GetTodayHourlyElectricalData();
|
|
|
|
|
|
|
|
|
|
EmeterEnergyResp resp = new EmeterEnergyResp();
|
|
|
|
|
|
|
|
|
|
ChargeAssignment(daysElectrical, daysElectricalChange, resp);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Result<EmeterEnergyResp>.Success(resp,"成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -134,11 +142,20 @@ namespace WebStarter.Controllers.Ammeter
|
|
|
|
|
public async Task<Result<EmeterEnergyResp>> GetTodayMinutelyElectricalData()
|
|
|
|
|
{
|
|
|
|
|
// 获取最近一个小时直流和交流表数据
|
|
|
|
|
List<EmeterEnergy> sevenDaysElectrical = await _emeterEnergyService.GetTodayMinutelyElectricalData();
|
|
|
|
|
List<EmeterEnergyChange> emeterEnergyChanges = await _emeterEnergyChangeService.GetTodayMinutelyElectricalData();
|
|
|
|
|
List<EmeterEnergy> minutesElectrical = await _emeterEnergyService.GetTodayMinutelyElectricalData();
|
|
|
|
|
List<EmeterEnergyChange> minutesElectricalChange = await _emeterEnergyChangeService.GetTodayMinutelyElectricalData();
|
|
|
|
|
|
|
|
|
|
EmeterEnergyResp resp = new EmeterEnergyResp();
|
|
|
|
|
|
|
|
|
|
ChargeAssignment(minutesElectrical, minutesElectricalChange, resp);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Result<EmeterEnergyResp>.Success(resp,"成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void ChargeAssignment(List<EmeterEnergy> emeterEnergy, List<EmeterEnergyChange> emeterEnergyChanges, EmeterEnergyResp resp)
|
|
|
|
|
{
|
|
|
|
|
var config = new MapperConfiguration(cfg =>
|
|
|
|
|
{
|
|
|
|
|
cfg.CreateMap<EmeterResp, EmeterEnergy>().ReverseMap();
|
|
|
|
@ -146,13 +163,16 @@ namespace WebStarter.Controllers.Ammeter
|
|
|
|
|
});
|
|
|
|
|
IMapper mapper = config.CreateMapper();
|
|
|
|
|
|
|
|
|
|
List<EmeterResp> emeterEnergyList = mapper.Map<List<EmeterResp>>(sevenDaysElectrical);
|
|
|
|
|
List<EmeterResp> sevenEmeterResps = mapper.Map<List<EmeterResp>>(emeterEnergyChanges);
|
|
|
|
|
List<EmeterResp> EnergyList = mapper.Map<List<EmeterResp>>(emeterEnergy);
|
|
|
|
|
// 类型赋值直流
|
|
|
|
|
EnergyList?.ForEach(emeterResp => emeterResp.Type = 0);
|
|
|
|
|
|
|
|
|
|
resp.emeterEnergy = emeterEnergyList;
|
|
|
|
|
resp.emeterEnergyChange = sevenEmeterResps;
|
|
|
|
|
List<EmeterResp> EnergyChangeList = mapper.Map<List<EmeterResp>>(emeterEnergyChanges);
|
|
|
|
|
// 类型赋值交流
|
|
|
|
|
EnergyChangeList?.ForEach(emeterResp => emeterResp.Type = 1);
|
|
|
|
|
|
|
|
|
|
return Result<EmeterEnergyResp>.Success(resp,"成功");
|
|
|
|
|
resp.emeterEnergy = EnergyList;
|
|
|
|
|
resp.emeterEnergyChange = EnergyChangeList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|