diff --git a/src/SJZY.Track.Application/Services/Warning/TransportWarningService.cs b/src/SJZY.Track.Application/Services/Warning/TransportWarningService.cs index e4878a3b..ccb06380 100644 --- a/src/SJZY.Track.Application/Services/Warning/TransportWarningService.cs +++ b/src/SJZY.Track.Application/Services/Warning/TransportWarningService.cs @@ -296,6 +296,12 @@ public class TransportWarningService : ApplicationService var oldScene = await _warningRuleRepository.GetTransportSceneAsync(input.WarningId, input.Id); var oldBo = oldScene != null ? TransportWarningSceneBO.From(oldScene) : null; + // 如果有月份则排序之后在写入 + if (!string.IsNullOrWhiteSpace(postBo.Months)) + { + var sorted = postBo.Months.Split('/').Select(int.Parse).OrderBy(x => x).ToList(); + postBo.Months = string.Join('/', sorted); + } // 更新或者新增 var id = await _warningRuleRepository.UpsertTransportSceneReturnIdAsync(postBo.ToEntity()); diff --git a/src/SJZY.Track.Domain/Aggregates/WarningAggregate/Transport/TransportWarningDetailsGenerateTaskEntity.cs b/src/SJZY.Track.Domain/Aggregates/WarningAggregate/Transport/TransportWarningDetailsGenerateTaskEntity.cs index 4c6593ea..89969ff3 100644 --- a/src/SJZY.Track.Domain/Aggregates/WarningAggregate/Transport/TransportWarningDetailsGenerateTaskEntity.cs +++ b/src/SJZY.Track.Domain/Aggregates/WarningAggregate/Transport/TransportWarningDetailsGenerateTaskEntity.cs @@ -1,7 +1,7 @@ namespace SJZY.Track.Domain.Aggregates.WarningAggregate.Transport; [SugarTable("t_warning_transport_generate_task", TableDescription = "运输时效预警明细生成任务")] -[SugarIndex("IDX_IsClosed_PlanExecutionTime", nameof(IsClosed), OrderByType.Desc, nameof(PlanExecutionTime), OrderByType.Asc)] +[SugarIndex("IDX_PlanExecutionTime_IsClosed", nameof(PlanExecutionTime), OrderByType.Asc, nameof(IsClosed), OrderByType.Asc)] public sealed class TransportWarningDetailsGenerateTaskEntity : IFullAuditedBasicEntitys, IEntity { [SugarColumn(ColumnName = "Id", IsPrimaryKey = true, IsIdentity = true)] @@ -39,4 +39,4 @@ public sealed class TransportWarningDetailsGenerateTaskEntity : IFullAuditedBasi [SugarColumn(ColumnName = "IsClosed", ColumnDescription = "是否关闭")] public bool IsClosed { get; set; } //是否关闭,执行完成被关闭/手动关闭 -} \ No newline at end of file +} diff --git a/src/SJZY.Track.Domain/Aggregates/WarningAggregate/WarningRuleEntity.cs b/src/SJZY.Track.Domain/Aggregates/WarningAggregate/WarningRuleEntity.cs index ab944a56..40f4a993 100644 --- a/src/SJZY.Track.Domain/Aggregates/WarningAggregate/WarningRuleEntity.cs +++ b/src/SJZY.Track.Domain/Aggregates/WarningAggregate/WarningRuleEntity.cs @@ -4,6 +4,7 @@ namespace SJZY.Track.Domain.Aggregates.WarningAggregate; // 预警规则主体 [SugarTable("t_warning_0", TableDescription = "预警规则主体(用于将来替换t_warning)")] +[SugarIndex("IDX_CustomId_SubSystemId", nameof(CustomId), OrderByType.Asc, nameof(SubSystemId), OrderByType.Asc)] public sealed class WarningRuleEntity : IFullAuditedBasicEntitys, IAggregateRoot { [SugarColumn(ColumnName = "Id", IsPrimaryKey = true, IsIdentity = true)] diff --git a/src/SJZY.Track.Repository/Repositories/WarningRuleRepository.cs b/src/SJZY.Track.Repository/Repositories/WarningRuleRepository.cs index d97997df..4b2f5e9d 100644 --- a/src/SJZY.Track.Repository/Repositories/WarningRuleRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/WarningRuleRepository.cs @@ -89,10 +89,11 @@ public class WarningRuleRepository : BasicRepository, IWarnin public async Task GetWarningRuleForEnabledAsync(int subSystemId, int customId, WarningRuleType warningType) { var warningRules = await Context.Queryable() - .Where(x => x.IsEnabled) - .Where(x => x.SubSystemId == subSystemId) - .Where(x => x.CustomId == customId) - .Where(x => x.WarningType == (int) warningType) + .Where(x => x.CustomId == customId + && x.SubSystemId == subSystemId + && x.WarningType == (int) warningType + && x.IsEnabled + ) .ToListAsync(); return warningRules.FirstOrDefault(); diff --git a/src/SJZY.Track.Repository/Repositories/WarningTaskRepository.cs b/src/SJZY.Track.Repository/Repositories/WarningTaskRepository.cs index a74a27ca..be4bc9ff 100644 --- a/src/SJZY.Track.Repository/Repositories/WarningTaskRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/WarningTaskRepository.cs @@ -113,7 +113,7 @@ public sealed class WarningTaskRepository : BasicRepository> ScanTransportWarningDetailsGenerateTaskAsync() { return Context.Queryable() - .Where(x => x.IsClosed == false && DateTime.Now >= x.PlanExecutionTime) + .Where(x => DateTime.Now >= x.PlanExecutionTime && x.IsClosed == false) .ToListAsync(); }