fix:CalcRuleList
This commit is contained in:
parent
e4b8fb4fcf
commit
0be6d452ee
@ -3,6 +3,7 @@ using SJZY.Track.Application.Contract.Dtos.Forewarning;
|
||||
using SJZY.Track.Domain.Aggregates.ForewarningAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.KPIAreaAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Forewarning;
|
||||
using Volo.Abp.AutoMapper;
|
||||
|
||||
namespace SJZY.Track.Application.AutoMapper;
|
||||
|
||||
@ -10,7 +11,8 @@ public class ForewarningMapperProfile :Profile
|
||||
{
|
||||
public ForewarningMapperProfile()
|
||||
{
|
||||
CreateMap<CreateWarningInput, WarningEntity>(MemberList.None);
|
||||
CreateMap<CreateWarningInput, WarningEntity>(MemberList.None)
|
||||
.Ignore(x => x.WarningFactors);
|
||||
CreateMap<WarningTimeSpanDto, WarningRuleEntity>(MemberList.None);
|
||||
CreateMap<RuleAreaEntity, AreaDto>();
|
||||
CreateMap<UpdateRuleAreaRequest, RuleAreaEntity>(MemberList.None);
|
||||
|
||||
@ -23,14 +23,14 @@ public class ForewarningHelper
|
||||
{
|
||||
throw new BusinessException(message: "轨迹状态区间或因素列表为空");
|
||||
}
|
||||
|
||||
|
||||
var len = statusSpans.Count * factors.Select(f => f.FactorValue.Count).Aggregate((pre, cur) => pre * cur);
|
||||
if (len == 0)
|
||||
{
|
||||
throw new BusinessException(message: "轨迹状态区间或因素列表为空");
|
||||
}
|
||||
|
||||
var rules = new List<WarningRuleEntity>(len);
|
||||
var rules = Enumerable.Repeat(new WarningRuleEntity(), len).ToList();
|
||||
|
||||
var repeat = len / statusSpans.Count;
|
||||
|
||||
@ -39,7 +39,7 @@ public class ForewarningHelper
|
||||
foreach (var factor in factors)
|
||||
{
|
||||
var factorValueCount = factor.FactorValue.Count;
|
||||
|
||||
|
||||
// repeat梯度下降,与times成反比关系
|
||||
repeat /= factor.FactorValue.Count;
|
||||
var times = len / repeat / factorValueCount;
|
||||
@ -52,13 +52,11 @@ public class ForewarningHelper
|
||||
|
||||
private static void FillStatus(List<WarningNitifyDto> statusSpans, List<WarningRuleEntity> rules, int repeat)
|
||||
{
|
||||
for (var i = 0; i < statusSpans.Count; i++)
|
||||
var row = 0;
|
||||
foreach (var span in statusSpans)
|
||||
{
|
||||
var span = statusSpans[i];
|
||||
|
||||
for (var j = 0; j < repeat; j++)
|
||||
for (var i = 0; i < repeat; i++, row++)
|
||||
{
|
||||
var row = i * repeat + j;
|
||||
rules[row].StartTrackStatusId = span.StartTrackStatusId;
|
||||
rules[row].EndTrackStatusId = span.EndTrackStatusId;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user