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