fix:根据订单号查询时效预警
This commit is contained in:
parent
ec04a43d44
commit
60571b3224
@ -7,6 +7,11 @@ public class WarningOrderDto
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
/// </summary>
|
||||
public string OrderNo { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生时间
|
||||
/// </summary>
|
||||
|
||||
@ -20,7 +20,7 @@ public class TrackWarningCalcEvent
|
||||
/// <summary>
|
||||
/// 订单id
|
||||
/// </summary>
|
||||
public int[] OrderIds { get; set; } = null!;
|
||||
public int[] OrderIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生时间
|
||||
|
||||
@ -154,7 +154,7 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe
|
||||
{
|
||||
SubSystemId = @event.SubSystemId,
|
||||
CustomId = @event.CustomId,
|
||||
OrderIds = canNextOrderIds.ToArray(),
|
||||
OrderIds = insertTracks.Select(x => x.OrderId).ToArray(),
|
||||
TrackStatusId = trackContent.TrackStatusId,
|
||||
TrackTime = @event.TrackTime,
|
||||
});
|
||||
|
||||
@ -59,6 +59,7 @@ public class TrackWarningCalcEventHandler : ITransientDependency, ICapSubscribe
|
||||
Orders = orders.Select(order => new WarningOrderDto
|
||||
{
|
||||
Id = order.Id,
|
||||
OrderNo = order.OrderNo,
|
||||
TrackTime = @event.TrackTime,
|
||||
CargoType = order.CargoType,
|
||||
Month = order.CreateTime.Month,
|
||||
|
||||
@ -148,7 +148,9 @@ public class ForewarningNotifyService : IForewarningNotifyService, ITransientDep
|
||||
private async Task<List<WarningRecordIndex>> WriteWarningRecordAsync(List<WarningNotifyCacheEntry> entries,
|
||||
List<GetWarningNotifiesVo> notifyRules)
|
||||
{
|
||||
// todo:重复校验
|
||||
var orders = await _warningQueries.GetOrderNoByIdsAsync(entries.Select(x => x.OrderId).ToArray());
|
||||
var orderNoDict = orders.ToDictionary(x => x.Id, x => x.Name);
|
||||
|
||||
var warningRecords = new List<WarningRecordIndex>();
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
@ -169,6 +171,7 @@ public class ForewarningNotifyService : IForewarningNotifyService, ITransientDep
|
||||
Counter = entry.Counter,
|
||||
IsLast = rule.WarnCount == entry.Counter,
|
||||
OrderId = entry.OrderId,
|
||||
OrderNo = orderNoDict[entry.OrderId],
|
||||
WarningStatus = WarningStatus.UnProcessed,
|
||||
NotifyUserId = notifyUser.UserId,
|
||||
NotifyUserName = notifyUser.UserName,
|
||||
@ -177,6 +180,7 @@ public class ForewarningNotifyService : IForewarningNotifyService, ITransientDep
|
||||
}
|
||||
}
|
||||
|
||||
// 批量写入es
|
||||
await _warningRecordEsRepository.BulkInsertAsync(warningRecords);
|
||||
return warningRecords;
|
||||
}
|
||||
|
||||
@ -39,8 +39,7 @@ public class OrderWarningService : ApplicationService
|
||||
x.Id,
|
||||
x.LatestTrackContent,
|
||||
x.LatestTrackTime,
|
||||
x.LatestTrackPlace,
|
||||
x.OrderNo
|
||||
x.LatestTrackPlace
|
||||
});
|
||||
|
||||
var list = new List<GetOrderWarningPageOutput>();
|
||||
@ -61,7 +60,6 @@ public class OrderWarningService : ApplicationService
|
||||
};
|
||||
var order = orders.FirstOrDefault(o => o.Id == x.OrderId);
|
||||
if (order == default) return;
|
||||
item.OrderNo = order.OrderNo;
|
||||
item.LatestTrackTime = order.LatestTrackTime;
|
||||
item.LatestTrackPlace = order.LatestTrackPlace;
|
||||
item.LatestTrackContent = order.LatestTrackContent;
|
||||
|
||||
@ -47,6 +47,11 @@ public class WarningRecordIndex : IdBaseIndex
|
||||
/// </summary>
|
||||
public int OrderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
/// </summary>
|
||||
public string OrderNo { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 预警规则
|
||||
/// </summary>
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
using SJZY.Track.Domain.Dtos.Common;
|
||||
using SJZY.Track.Domain.Dtos.Forewarning;
|
||||
|
||||
namespace SJZY.Track.Domain.Queries;
|
||||
@ -24,4 +25,11 @@ public interface IWarningQueries
|
||||
/// <param name="areaId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<RuleAreaBaseInfoVo>> GetWarningRuleByAreaId(int areaId);
|
||||
|
||||
/// <summary>
|
||||
/// 订单id换name
|
||||
/// </summary>
|
||||
/// <param name="orderIds"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<IdWithNameDto>> GetOrderNoByIdsAsync(int[] orderIds);
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
using Newtonsoft.Json;
|
||||
using SJZY.Track.Domain.Aggregates.ForewarningAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.KPIAreaAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Common;
|
||||
using SJZY.Track.Domain.Dtos.Forewarning;
|
||||
using SJZY.Track.Domain.Queries;
|
||||
using SJZY.Track.Domain.VEntities;
|
||||
@ -93,4 +95,16 @@ public class WarningQueries : ISugarRepository, IWarningQueries,
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<List<IdWithNameDto>> GetOrderNoByIdsAsync(int[] orderIds)
|
||||
{
|
||||
return await Context.Queryable<OrderEntity>()
|
||||
.Where(x => orderIds.Contains(x.Id))
|
||||
.Select(x => new IdWithNameDto
|
||||
{
|
||||
Id = x.Id,
|
||||
Name = x.OrderNo
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ public class WarningRecordEsRepository : ElasticSearchContextAbstract<WarningRec
|
||||
(input.SubSystemId.HasValue ? q.Term(f => f.SubSystemId, input.SubSystemId) : null)
|
||||
&& (!input.OrderNos.IsNullOrEmpty()
|
||||
? q.Terms(t => t
|
||||
.Field(f => f.OrderId.Suffix("keyword"))
|
||||
.Field(f => f.OrderNo.Suffix("keyword"))
|
||||
.Terms(input.OrderNos))
|
||||
: null)
|
||||
&& (input.WarningStatus.HasValue ? q.Term(f => f.WarningStatus, input.WarningStatus) : null)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user