diff --git a/src/SJZY.Track.Application.Contract/Dtos/Warning/Transport/TransportWarningDetailsDto.cs b/src/SJZY.Track.Application.Contract/Dtos/Warning/Transport/TransportWarningDetailsDto.cs index 1ef707f3..55dfafeb 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/Warning/Transport/TransportWarningDetailsDto.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/Warning/Transport/TransportWarningDetailsDto.cs @@ -3,147 +3,147 @@ namespace SJZY.Track.Application.Contract.Dtos.Warning.Transport; /// /// 运输时效预警明细 /// -public sealed class TransportWarningDetailsDto // todo:需要根据状态排序 +public sealed class TransportWarningDetailsDto { - /// - /// 预警明细唯一id - /// - public string EsId { get; set; } + /// + /// 预警明细唯一id + /// + public string EsId { get; set; } - /// - /// 子系统id - /// - public int SubSystemId { get; set; } + /// + /// 子系统id + /// + public int SubSystemId { get; set; } - /// - /// 子系统名称 - /// - public string SubSystemName { get; set; } // todo:id换名称 + /// + /// 子系统名称 + /// + public string SubSystemName { get; set; } - /// - /// 客户id - /// - public int CustomId { get; set; } + /// + /// 客户id + /// + public int CustomId { get; set; } - /// - /// 客户简称 - /// - public string CustomName { get; set; } // todo:id换名称 + /// + /// 客户简称 + /// + public string CustomName { get; set; } - /// - /// 订单id - /// - public int OrderId { get; set; } + /// + /// 订单id + /// + public int OrderId { get; set; } - /// - /// 订单号 - /// - public string OrderNo { get; set; } + /// + /// 订单号 + /// + public string OrderNo { get; set; } - /// - /// 订单类型 - /// - public int OrderType { get; set; } + /// + /// 订单类型 + /// + public int OrderType { get; set; } - /// - /// 订单类型名称 - /// - public string OrderTypeName { get; set; } // todo:type换名称 + /// + /// 订单类型名称 + /// + public string OrderTypeName { get; set; } - // 实时属性 todo:从es查询 + // 实时属性 tips:从es查询 - /// - /// 最新轨迹内容 - /// - public string? LatestTrackContent { get; set; } + /// + /// 最新轨迹内容 + /// + public string? LatestTrackContent { get; set; } - /// - /// 最新轨迹时间 - /// - public DateTime? LatestTrackTime { get; set; } + /// + /// 最新轨迹时间 + /// + public DateTime? LatestTrackTime { get; set; } - /// - /// 最新轨迹发生时区 - /// - public float? LatestTrackTimeZone { get; set; } + /// + /// 最新轨迹发生时区 + /// + public float? LatestTrackTimeZone { get; set; } - /// - /// 最新轨迹发生地 - /// - public string? LatestTrackPlace { get; set; } + /// + /// 最新轨迹发生地 + /// + public string? LatestTrackPlace { get; set; } - /// - /// 通知对象 - /// - public string NotifyUserNames { get; set; } + /// + /// 通知对象 + /// + public string NotifyUserNames { get; set; } - /// - /// 起始轨迹状态 - /// - public string StartTrackStatus { get; set; } + /// + /// 起始轨迹状态 + /// + public string StartTrackStatus { get; set; } - /// - /// 起始轨迹内容 - /// - public string StartTrackContent { get; set; } + /// + /// 起始轨迹内容 + /// + public string StartTrackContent { get; set; } - /// - /// 起始轨迹发生时间 - /// - public DateTime StartTrackTime { get; set; } + /// + /// 起始轨迹发生时间 + /// + public DateTime StartTrackTime { get; set; } - /// - /// 起始轨迹时区 - /// - public float StartTrackTimeZone { get; set; } + /// + /// 起始轨迹时区 + /// + public float StartTrackTimeZone { get; set; } - /// - /// 截止轨迹状态 - /// - public string EndTrackStatus { get; set; } + /// + /// 截止轨迹状态 + /// + public string EndTrackStatus { get; set; } - /// - /// 截止轨迹内容 - /// - public string? EndTrackContent { get; set; } + /// + /// 截止轨迹内容 + /// + public string? EndTrackContent { get; set; } - /// - /// 截止轨迹发生时间 - /// - public DateTime? EndTrackTime { get; set; } + /// + /// 截止轨迹发生时间 + /// + public DateTime? EndTrackTime { get; set; } - /// - /// 截止轨迹时区 - /// - public float? EndTrackTimeZone { get; set; } + /// + /// 截止轨迹时区 + /// + public float? EndTrackTimeZone { get; set; } - /// - /// 预警名称 (预警主体名称 如字节全程时效) - /// - public string WarningName { get; set; } + /// + /// 预警名称 (预警主体名称 如字节全程时效) + /// + public string WarningName { get; set; } - /// - /// 预警规则描述(用于tooltip展示) - /// - public string WarningRuleDescription { get; set; } + /// + /// 预警规则描述(用于tooltip展示) + /// + public string WarningRuleDescription { get; set; } - /// - /// 累计运输时间 - /// - public string CumulativeTimeSpan { get; set; } // todo:需要转换为某个格式 + /// + /// 累计运输时间 + /// + public string CumulativeTimeSpan { get; set; } - /// - /// 预警状态 (根据key展示对应名称,即将超时需要标红) - /// 1:即将超时 2:已超时 3:已完成 4:超时完成 5:已关闭,初始为【即将超时】 - /// - public int Status { get; set; } + /// + /// 预警状态 (根据key展示对应名称,即将超时需要标红) + /// 1:即将超时 2:已超时 3:已完成 4:超时完成 5:已关闭,初始为【即将超时】 + /// + public int Status { get; set; } - /// - /// 预警创建时间 - /// - public DateTime CreateTime { get; set; } + /// + /// 预警创建时间 + /// + public DateTime CreateTime { get; set; } } diff --git a/src/SJZY.Track.Application/Services/Warning/Handlers/TransportWarningHandler.cs b/src/SJZY.Track.Application/Services/Warning/Handlers/TransportWarningHandler.cs index cc167d95..7d25b21e 100644 --- a/src/SJZY.Track.Application/Services/Warning/Handlers/TransportWarningHandler.cs +++ b/src/SJZY.Track.Application/Services/Warning/Handlers/TransportWarningHandler.cs @@ -1235,8 +1235,6 @@ public class TransportWarningHandler : ITransportWarningHandler, ITransientDepen CreateTime = DateTime.Now, }; - // 一开始创建预警就可能为已超时的状态 - detail.Status = detail.CalcStatus(); return detail; } diff --git a/src/SJZY.Track.Application/Services/Warning/TransportWarningService.cs b/src/SJZY.Track.Application/Services/Warning/TransportWarningService.cs index cd0bbc28..5cc3abba 100644 --- a/src/SJZY.Track.Application/Services/Warning/TransportWarningService.cs +++ b/src/SJZY.Track.Application/Services/Warning/TransportWarningService.cs @@ -171,6 +171,9 @@ public class TransportWarningService : ApplicationService public async Task> GetPageTransportWarningDetails(GetPageTransportWarningDetailsInput input) { var vo = ObjectMapper.Map(input); + // 存储只存即将超时,对于已超时的则是查出计算后过滤 + if (input.Status == (int) TransportWarningStatus.已超时) + vo.Status = (int) TransportWarningStatus.即将超时; var result = await _warningDetailsEsRepository.GetPageTransportWarningDetailsAsync(vo); if (result.List.Count == 0) { @@ -247,19 +250,23 @@ public class TransportWarningService : ApplicationService }; }); - var sorted = map.OrderBy(x => + // 计算后的状态过滤 + var filtered = map.WhereIf(input.Status > 0, x => x.Status == input.Status); + + // 按状态排序 + var sorted = filtered.OrderBy(x => { // 即将超时,已超时置顶 if (x.Status is 1 or 2) return x.Status; // 其他按创建时间从早到晚 return DateTimeHelper.ConvertToUnixTimestamp(x.CreateTime); - }); + }).ToList(); return new UnifyPageResultDto( - sorted.ToList(), + sorted, result.Pagination.PageIndex, result.Pagination.PageSize, - result.Pagination.Total); + sorted.Count); // 通知用户提取用户名称 string ToUserNames(string notifyUsers)