定时推送账单添加执行日志;
This commit is contained in:
+9
-12
@@ -50,18 +50,15 @@ public class BillingScheduler {
|
|||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
// 乐观锁更新状态,防止重复执行
|
// 乐观锁更新状态,防止重复执行
|
||||||
int updated = scheduledTaskMapper.updateStatusIfPending(
|
//int updated = scheduledTaskMapper.updateStatusIfPending(task.getId(), "PENDING", "PROCESSING");
|
||||||
task.getId(), "PENDING", "PROCESSING");
|
|
||||||
|
|
||||||
if (updated > 0) {
|
// 异步执行具体业务
|
||||||
// 异步执行具体业务
|
CompletableFuture.runAsync(() -> {
|
||||||
CompletableFuture.runAsync(() -> {
|
executeTask(task);
|
||||||
executeTask(task);
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
scheduledTaskMapper.updateStatus(task.getId(), "FAILED");
|
//scheduledTaskMapper.updateStatus(task.getId(), "FAILED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,16 +69,16 @@ public class BillingScheduler {
|
|||||||
// 执行具体的出账逻辑
|
// 执行具体的出账逻辑
|
||||||
scheduledTaskService.executeBilling(task.getBusId());
|
scheduledTaskService.executeBilling(task.getBusId());
|
||||||
|
|
||||||
scheduledTaskMapper.updateStatus(task.getId(), "SUCCESS");
|
//scheduledTaskMapper.updateStatus(task.getId(), "SUCCESS");
|
||||||
status = "SUCCESS";
|
status = "SUCCESS";
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// 重试机制
|
// 重试机制
|
||||||
scheduledTaskMapper.incrementRetryCount(task.getId());
|
scheduledTaskMapper.incrementRetryCount(task.getId());
|
||||||
if (task.getRetryCount() < 3) {
|
if (task.getRetryCount() < 3) {
|
||||||
scheduledTaskMapper.updateStatus(task.getId(), "PENDING");
|
//scheduledTaskMapper.updateStatus(task.getId(), "PENDING");
|
||||||
} else {
|
} else {
|
||||||
status = "FAILED";
|
status = "FAILED";
|
||||||
scheduledTaskMapper.updateStatus(task.getId(), "FAILED");
|
//scheduledTaskMapper.updateStatus(task.getId(), "FAILED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ScheduledTaskLog log = new ScheduledTaskLog();
|
ScheduledTaskLog log = new ScheduledTaskLog();
|
||||||
|
|||||||
Reference in New Issue
Block a user