feat: 解决接口Track/PushWarnForTask的锁长时间占领的问题
This commit is contained in:
parent
6b43722fa6
commit
010408985e
@ -92,9 +92,21 @@ public class TrackPushService : ApplicationService
|
||||
[HttpPost("Track/PushWarnForTask")]
|
||||
public async Task<string> PushWarnForTaskAsync()
|
||||
{
|
||||
// todo:订单数据上来后一次性update是否会引发长时间X独占?
|
||||
var count = await _orderRepository.PushWarnOrdersAsync();
|
||||
return $"本次预警扫描了:{count}个订单";
|
||||
int total = 0, pageSize = 1000,waitTime = 1000;
|
||||
var dateTimes = Enumerable.Range(1, 12).Select(val => DateTime.Now.AddHours(-val)).ToList();
|
||||
|
||||
foreach (var dateTime in dateTimes)
|
||||
{
|
||||
var rows = 0;
|
||||
do
|
||||
{
|
||||
rows = await _orderRepository.PushWarnOrdersAsync(pageSize,dateTime);
|
||||
total+=rows;
|
||||
await Task.Delay(waitTime);
|
||||
}while (rows!= pageSize);
|
||||
}
|
||||
|
||||
return $"本次预警扫描了:{total}个订单";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -29,7 +29,7 @@ public interface IOrderRepository : IBasicRepository<OrderEntity>
|
||||
/// 更新推送预警单
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<int> PushWarnOrdersAsync();
|
||||
Task<int> PushWarnOrdersAsync(int pageSize,DateTime createTime);
|
||||
|
||||
/// <summary>
|
||||
/// 更新缺失标记,时区缺失和发生地缺失标记,1表示时区,2表示发生地,3表示两种
|
||||
|
||||
@ -61,7 +61,7 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
||||
tran.Complete();
|
||||
}
|
||||
|
||||
public async Task<int> PushWarnOrdersAsync()
|
||||
public async Task<int> PushWarnOrdersAsync(int pageSize, DateTime createTime)
|
||||
{
|
||||
return await Context.Ado.ExecuteCommandAsync(@"UPDATE `t_track_push_config` `a`
|
||||
LEFT JOIN `t_order` `b` ON `a`.`SubSystemId` = `b`.`SubSystemId` AND `a`.`CustomId` = `b`.`CustomId`
|
||||
@ -69,8 +69,8 @@ SET `b`.`QuestionType` = CASE
|
||||
WHEN `b`.`LatestPushTime` IS NULL THEN 2
|
||||
WHEN `b`.`LatestPushTime` < DATE_SUB(NOW(), INTERVAL 12 HOUR) THEN 2
|
||||
ELSE 0 END
|
||||
WHERE `b`.`IsCompleted` = 0 AND `b`.`QuestionType` != 1 AND `b`.`CreateTime` < DATE_SUB(NOW(), INTERVAL 12 HOUR)
|
||||
AND `a`.`IsDeleted` = 0 AND `b`.`IsDeleted` = 0;");
|
||||
WHERE `b`.`IsCompleted` = 0 AND `b`.`QuestionType` != 1 AND `b`.`CreateTime` < @createTime
|
||||
AND `a`.`IsDeleted` = 0 AND `b`.`IsDeleted` = 0 limit @pageSize", new { pageSize,createTime });
|
||||
}
|
||||
|
||||
#region 订单关联
|
||||
|
||||
Loading…
Reference in New Issue
Block a user