add:定时清理
This commit is contained in:
parent
e78427521c
commit
42e2d6bc96
@ -18,9 +18,13 @@ public class OrderPullStatusScanner : BackgroundService
|
||||
var count = await _orderRepository.UpdatePullStatusBySilenceAsync();
|
||||
if (count > 0)
|
||||
{
|
||||
LogHelper.Info($"{nameof(OrderPullStatusScanner)}本次扫描更新了{count}条订单的拉取状态");
|
||||
LogHelper.Info($"{nameof(OrderPullStatusScanner)}本次扫描更新了{count}条订单拉取状态");
|
||||
}
|
||||
|
||||
// real del
|
||||
count = await _orderRepository.ClearPullStatus();
|
||||
LogHelper.Info($"{nameof(OrderPullStatusScanner)}本次扫描删除了{count}条订单拉取状态");
|
||||
|
||||
await Task.Delay(TimeSpan.FromMinutes(1), stoppingToken);
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,22 +53,6 @@ public interface IOrderRepository : IBasicRepository<OrderEntity>
|
||||
/// <returns></returns>
|
||||
Task<List<(string code, int id)>> GetSubSystemListByCodesAsync(List<string> codes);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新订单拉取状态为静默,Init->SilenceBeforeStart,Pulling->SilenceAfterEnd
|
||||
/// </summary>
|
||||
/// <param name="orderIds"></param>
|
||||
/// <param name="trackCode"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdatePullStatusToSilenceAsync(List<int> orderIds, string trackCode);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新订单拉取状态根据静默,SilenceBeforeStart->Pulling,SilenceAfterEnd->Completed
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<int> UpdatePullStatusBySilenceAsync();
|
||||
|
||||
#region 订单关联
|
||||
|
||||
/// <summary>
|
||||
@ -93,4 +77,30 @@ public interface IOrderRepository : IBasicRepository<OrderEntity>
|
||||
Task UnLinkByIdsAsync(List<int> linkIds);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 订单拉取状态
|
||||
|
||||
/// <summary>
|
||||
/// 更新订单拉取状态为静默,Init->SilenceBeforeStart,Pulling->SilenceAfterEnd
|
||||
/// </summary>
|
||||
/// <param name="orderIds"></param>
|
||||
/// <param name="trackCode"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdatePullStatusToSilenceAsync(List<int> orderIds, string trackCode);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新订单拉取状态根据静默,SilenceBeforeStart->Pulling,SilenceAfterEnd->Completed
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<int> UpdatePullStatusBySilenceAsync();
|
||||
|
||||
/// <summary>
|
||||
/// 清理拉取状态
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<int> ClearPullStatus();
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -228,6 +228,14 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
||||
return cnt1 + cnt2;
|
||||
}
|
||||
|
||||
public Task<int> ClearPullStatus()
|
||||
{
|
||||
var time = DateTime.Now.Subtract(TimeSpan.FromDays(30));
|
||||
return Context.Deleteable<OrderPullStatusEntity>().Where(x =>
|
||||
x.PullStatus == TrackPullStatus.Completed || x.StartTime < time)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
private int UpdateOrderQuestionType(int questionType, IEnumerable<int> ids)
|
||||
{
|
||||
var idsString = string.Join(",", ids);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user