修改电价配置查询

master
lch 6 months ago
parent 1023065654
commit 558664b2df

@ -191,10 +191,9 @@ namespace WebStarter.Controllers.BasicConfig
StartTime = new TimeSpan(item.StartHour, item.StartMinute, item.StartSecond), StartTime = new TimeSpan(item.StartHour, item.StartMinute, item.StartSecond),
EndTime = new TimeSpan(item.EndHour, item.EndMinute, item.EndSecond), EndTime = new TimeSpan(item.EndHour, item.EndMinute, item.EndSecond),
Price = item.Price, Price = item.Price,
Type = item.Price Type = item.Type
}); });
} }
return Result<List<ElecPriceModelVersionDetailResp>>.Success(elecPriceModelVersionDetailResps); return Result<List<ElecPriceModelVersionDetailResp>>.Success(elecPriceModelVersionDetailResps);
} }
@ -257,14 +256,6 @@ namespace WebStarter.Controllers.BasicConfig
{ {
Result<bool>.Fail("参数不能为空"); Result<bool>.Fail("参数不能为空");
} }
List<ElecPriceModelVersionDetail> modelFromDbs =
await _elecPriceModelVersionDetailServices.QueryListByClauseAsync(u => u.Version == model[0].Version);
if (modelFromDbs != null)
{
await _elecPriceModelVersionDetailServices.DeleteAsync(i => i.Version == model[0].Version);
}
List<ElecPriceModelVersionDetail> elecPriceModelVersionDetails = new List<ElecPriceModelVersionDetail>(); List<ElecPriceModelVersionDetail> elecPriceModelVersionDetails = new List<ElecPriceModelVersionDetail>();
foreach (var item in model) foreach (var item in model)
{ {
@ -281,14 +272,19 @@ namespace WebStarter.Controllers.BasicConfig
Type = item.Type Type = item.Type
}); });
} }
if (!TimeListIfContains(elecPriceModelVersionDetails))
{
return Result<bool>.Fail("时间区间重复请检查");
}
if (TimeListIfContains(elecPriceModelVersionDetails)) List<ElecPriceModelVersionDetail> modelFromDbs = await _elecPriceModelVersionDetailServices.QueryListByClauseAsync(u => u.Version == model[0].Version);
if (modelFromDbs != null)
{ {
await _elecPriceModelVersionDetailServices.InsertAsync(elecPriceModelVersionDetails); await _elecPriceModelVersionDetailServices.DeleteAsync(i => i.Version == model[0].Version);
return Result<bool>.Success(true);
} }
await _elecPriceModelVersionDetailServices.InsertAsync(elecPriceModelVersionDetails);
return Result<bool>.Success(true);
return Result<bool>.Fail("时间区间重复请检查");
} }
@ -300,7 +296,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 = true; bool notHasOverlap = true;
for (int i = 0; i < timePeriods.Count; i++) for (int i = 0; i < timePeriods.Count; i++)
{ {
@ -308,13 +304,13 @@ 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 = false; notHasOverlap = false;
return hasOverlap; return notHasOverlap;
} }
} }
} }
return hasOverlap; return notHasOverlap;
} }
/// <summary> /// <summary>

Loading…
Cancel
Save