|
|
@@ -17,6 +17,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -84,10 +85,8 @@ public class OrderScheduler {
|
|
|
* 每分钟30秒时运行一次
|
|
|
*/
|
|
|
@Async
|
|
|
- @Scheduled(cron = "30 */1 * * * ?")
|
|
|
+ @Scheduled(cron = "30 */2 * * * ?")
|
|
|
public void prodIngOrderAutoCompleted(){
|
|
|
- RLock lock = redissonClient.getLock(SchedulerLock.ORDER_OF_PROD_AUTO_COMPLETED_LOCK);
|
|
|
- lock.lock();
|
|
|
try {
|
|
|
log.info("自动制作完成制作中订单任务开始运行");
|
|
|
// 获取配置:是否开启制作中订单自动完成
|
|
|
@@ -101,6 +100,8 @@ public class OrderScheduler {
|
|
|
if (CollUtil.isEmpty(orders)) {
|
|
|
log.info("当前时间段没有需要自动制作完成的订单");
|
|
|
} else {
|
|
|
+ // 订单随机排序
|
|
|
+ Collections.shuffle(orders);
|
|
|
for (TbOrder order: orders){
|
|
|
try {
|
|
|
log.info("订单:{},开始自动制作完成", order.getOrderId());
|
|
|
@@ -117,8 +118,6 @@ public class OrderScheduler {
|
|
|
log.info("自动制作完成制作中订单任务运行成功");
|
|
|
} catch (Exception e) {
|
|
|
log.error("制作中订单自动制作完成任务运行失败失败原因:【{}】", e);
|
|
|
- } finally {
|
|
|
- lock.unlock();
|
|
|
}
|
|
|
}
|
|
|
|