Merge remote-tracking branch 'origin/S04轨迹预警' into S04轨迹预警

This commit is contained in:
xiaolipro 2024-08-02 09:06:02 +08:00
commit f531551702
5 changed files with 60 additions and 1 deletions

View File

@ -98,10 +98,12 @@ public class TrackPushService : ApplicationService
foreach (var dateTime in dateTimes)
{
var rows = 0;
var pageindex = 1;
do
{
rows = await _orderRepository.PushWarnOrdersAsync(pageSize,dateTime);
rows = await _orderRepository.PushWarnOrdersAsync(pageSize,pageindex,dateTime);
total+=rows;
pageindex++;
await Task.Delay(waitTime);
}while (rows!= pageSize);
}

View File

@ -31,6 +31,12 @@ public interface IOrderRepository : IBasicRepository<OrderEntity>
/// <returns></returns>
Task<int> PushWarnOrdersAsync(int pageSize,DateTime createTime);
/// <summary>
/// 更新推送预警单
/// </summary>
/// <returns></returns>
Task<int> PushWarnOrdersAsync(int pageSize, int pageindex, DateTime createTime);
/// <summary>
/// 更新缺失标记,时区缺失和发生地缺失标记,1表示时区,2表示发生地,3表示两种
/// </summary>

View File

@ -68,4 +68,9 @@ public class GetTrackPullContentDetailOutputVO
/// 是否完结
/// </summary>
public bool IsCompleted { get; set; }
/// <summary>
/// 轨迹时区兜底地址值
/// </summary>
public int? TrackTimePlaceValue { get; set; }
}

View File

@ -1,5 +1,6 @@
using SJZY.Track.Domain;
using SJZY.Track.Domain.Aggregates.OrderAggregate;
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
using SJZY.Track.Domain.Consts;
using SJZY.Track.Domain.Dtos.Order;
@ -73,6 +74,50 @@ WHERE `b`.`IsCompleted` = 0 AND `b`.`QuestionType` != 1 AND `b`.`CreateTime` < @
AND `a`.`IsDeleted` = 0 AND `b`.`IsDeleted` = 0 limit @pageSize", new { pageSize,createTime });
}
/// <summary>
/// 更新推送预警单
/// </summary>
/// <param name="pageSize"></param>
/// <param name="pageindex"></param>
/// <param name="createTime"></param>
/// <returns></returns>
public async Task<int> PushWarnOrdersAsync(int pageSize,int pageindex, DateTime createTime)
{
var ordersToUpdate = await Context.Queryable<OrderEntity>()
.LeftJoin<TrackPushConfigEntity>((b, a) => a.SubSystemId == b.SubSystemId && a.CustomId == b.CustomId)
.Where((b, a) =>
!b.IsCompleted
&& b.QuestionType != 1
&& b.CreateTime < createTime
&& !a.IsDeleted
&& !b.IsDeleted)
.Select((b, a) => b)
.ToPageListAsync(pageindex,pageSize);
var latestPushTimeIds = new LinkedList<int>();
var questionZeroIds = new LinkedList<int>();
foreach (var item in ordersToUpdate)
{
var questionType = item.LatestPushTime == null
|| item.LatestPushTime < DateTime.Now.AddHours(-12) ? 2 : 0;
if(item.QuestionType== questionType) continue;
if(questionType==2) latestPushTimeIds.AddLast(item.Id);
else questionZeroIds.AddLast(item.Id);
}
int rows = 0;
if(latestPushTimeIds.Count>0)rows+= UpdateOrderQuestionType(2, latestPushTimeIds);
if(questionZeroIds.Count>0)rows+= UpdateOrderQuestionType(0, questionZeroIds);
return rows;
}
private int UpdateOrderQuestionType(int questionType, IEnumerable<int> ids)
{
var idsString = string.Join(",", ids);
return Context.Ado.ExecuteCommand(
$"UPDATE `t_order` SET `QuestionType` = @questionType ,UpdateTime= current_timestamp WHERE `Id` IN ({idsString})", new { questionType });
}
#region 订单关联
public async Task<List<LinkedOrderVO>> GetLinkedOrdersAsync(int[] orderIds)

View File

@ -87,6 +87,7 @@ public class TrackPullConfigRepository : BasicRepository<TrackPullConfigEntity>,
{
Id = pullContent.Id,
Code = trackContent.Code + "-" + trackContent.Content,
TrackTimePlaceValue = pullContent.TrackZonePlaceValue,
}, true)
.Mapper(x =>
{