|
|
@ -263,50 +263,85 @@ namespace WebStarter.Controllers.BasicConfig
|
|
|
|
/// <param name="model"></param>
|
|
|
|
/// <param name="model"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("AddStationElecPriceInfoList")]
|
|
|
|
[HttpPost("AddStationElecPriceInfoList")]
|
|
|
|
public async Task<Result<bool>> AddStationElecPriceInfoList([FromBody] List<ElecPriceModelVersionDetail> model)
|
|
|
|
public async Task<Result<bool>> AddStationElecPriceInfoList([FromBody] List<ElecPriceModelVersionDetailReq> model)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (null == model || model.Count == 0)
|
|
|
|
if (null == model || model.Count == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Result<bool>.Fail("参数不能为空");
|
|
|
|
Result<bool>.Fail("参数不能为空");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var queryByClauseAsync =
|
|
|
|
List<ElecPriceModelVersionDetail> elecPriceModelVersionDetails = new List<ElecPriceModelVersionDetail>();
|
|
|
|
_elecPriceModelVersionDetailServices.QueryByClauseAsync(u => u.Version == model[0].Version);
|
|
|
|
foreach (var item in model)
|
|
|
|
if (queryByClauseAsync != null)
|
|
|
|
|
|
|
|
await _elecPriceModelVersionDetailServices.DeleteAsync(i => i.Version == model[0].Version);
|
|
|
|
|
|
|
|
if (TimeListIfContains(model))
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await _elecPriceModelVersionDetailServices.InsertAsync(model);
|
|
|
|
elecPriceModelVersionDetails.Add(new ElecPriceModelVersionDetail()
|
|
|
|
return Result<bool>.Success(true);
|
|
|
|
{
|
|
|
|
|
|
|
|
Version = item.Version,
|
|
|
|
|
|
|
|
StartHour = item.StartTime.Hour,
|
|
|
|
|
|
|
|
StartMinute = item.StartTime.Minute,
|
|
|
|
|
|
|
|
StartSecond = item.StartTime.Second,
|
|
|
|
|
|
|
|
EndHour = item.EndTime.Hour,
|
|
|
|
|
|
|
|
EndMinute = item.EndTime.Minute,
|
|
|
|
|
|
|
|
EndSecond = item.EndTime.Second,
|
|
|
|
|
|
|
|
Price = item.Price,
|
|
|
|
|
|
|
|
Type = item.Type
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ElecPriceModelVersionDetail> modelFromDbs = await _elecPriceModelVersionDetailServices.QueryListByClauseAsync(u => u.Version == model[0].Version);
|
|
|
|
|
|
|
|
if (modelFromDbs != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
modelFromDbs.AddRange(elecPriceModelVersionDetails);
|
|
|
|
|
|
|
|
if ( TimeListIfContains(modelFromDbs))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
await _elecPriceModelVersionDetailServices.InsertAsync(elecPriceModelVersionDetails);
|
|
|
|
|
|
|
|
return Result<bool>.Success(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Result<bool>.Fail("时间区间重复请检查");
|
|
|
|
return Result<bool>.Fail("时间区间重复请检查");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 修改电价信息
|
|
|
|
/// 更新电价信息
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="model"></param>
|
|
|
|
/// <param name="model"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("UpdateStationElecPriceInfo")]
|
|
|
|
[HttpPost("UpdateStationElecPriceInfoList")]
|
|
|
|
public async Task<Result<bool>> UpdateStationElecPriceInfo([FromBody] List<ElecPriceModelVersionDetail> model)
|
|
|
|
public async Task<Result<bool>> UpdateStationElecPriceInfoList([FromBody] List<ElecPriceModelVersionDetailReq> model)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (null == model || model.Count == 0)
|
|
|
|
if (null == model || model.Count == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Result<bool>.Fail("参数不能为空");
|
|
|
|
Result<bool>.Fail("参数不能为空");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var queryByClauseAsync =
|
|
|
|
List<ElecPriceModelVersionDetail> modelFromDbs = await _elecPriceModelVersionDetailServices.QueryListByClauseAsync(u => u.Version == model[0].Version);
|
|
|
|
_elecPriceModelVersionDetailServices.QueryByClauseAsync(u => u.Version == model[0].Version);
|
|
|
|
if (modelFromDbs != null)
|
|
|
|
if (queryByClauseAsync != null)
|
|
|
|
{
|
|
|
|
await _elecPriceModelVersionDetailServices.DeleteAsync(i => i.Version == model[0].Version);
|
|
|
|
await _elecPriceModelVersionDetailServices.DeleteAsync(i => i.Version == model[0].Version);
|
|
|
|
if (TimeListIfContains(model))
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ElecPriceModelVersionDetail> elecPriceModelVersionDetails = new List<ElecPriceModelVersionDetail>();
|
|
|
|
|
|
|
|
foreach (var item in model)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await _elecPriceModelVersionDetailServices.InsertAsync(model);
|
|
|
|
elecPriceModelVersionDetails.Add(new ElecPriceModelVersionDetail()
|
|
|
|
return Result<bool>.Success(true);
|
|
|
|
{
|
|
|
|
|
|
|
|
Version = item.Version,
|
|
|
|
|
|
|
|
StartHour = item.StartTime.Hour,
|
|
|
|
|
|
|
|
StartMinute = item.StartTime.Minute,
|
|
|
|
|
|
|
|
StartSecond = item.StartTime.Second,
|
|
|
|
|
|
|
|
EndHour = item.EndTime.Hour,
|
|
|
|
|
|
|
|
EndMinute = item.EndTime.Minute,
|
|
|
|
|
|
|
|
EndSecond = item.EndTime.Second,
|
|
|
|
|
|
|
|
Price = item.Price,
|
|
|
|
|
|
|
|
Type = item.Type
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( TimeListIfContains(elecPriceModelVersionDetails))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
await _elecPriceModelVersionDetailServices.InsertAsync(elecPriceModelVersionDetails);
|
|
|
|
|
|
|
|
return Result<bool>.Success(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
return Result<bool>.Fail("时间区间重复请检查");
|
|
|
|
return Result<bool>.Fail("时间区间重复请检查");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -319,7 +354,7 @@ namespace WebStarter.Controllers.BasicConfig
|
|
|
|
[ApiExplorerSettings(IgnoreApi = true)]
|
|
|
|
[ApiExplorerSettings(IgnoreApi = true)]
|
|
|
|
public bool TimeListIfContains(List<ElecPriceModelVersionDetail> timePeriods)
|
|
|
|
public bool TimeListIfContains(List<ElecPriceModelVersionDetail> timePeriods)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool hasOverlap = false;
|
|
|
|
bool hasOverlap = true;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < timePeriods.Count; i++)
|
|
|
|
for (int i = 0; i < timePeriods.Count; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -327,7 +362,7 @@ namespace WebStarter.Controllers.BasicConfig
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (timePeriods[i].Contains(timePeriods[j]) || timePeriods[j].Contains(timePeriods[i]))
|
|
|
|
if (timePeriods[i].Contains(timePeriods[j]) || timePeriods[j].Contains(timePeriods[i]))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
hasOverlap = true;
|
|
|
|
hasOverlap = false;
|
|
|
|
return hasOverlap;
|
|
|
|
return hasOverlap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|