package com.zy.asrs.task;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.zy.asrs.entity.OrderDetlPakin;
|
import com.zy.asrs.entity.OrderDetlPakout;
|
import com.zy.asrs.entity.OrderPakin;
|
import com.zy.asrs.entity.OrderPakout;
|
import com.zy.asrs.service.*;
|
import com.zy.asrs.service.impl.OrderDetlPakinServiceImpl;
|
import com.zy.asrs.task.core.ReturnT;
|
import com.zy.asrs.task.handler.OrderPakinSyncHandler;
|
import com.zy.asrs.task.handler.OrderPakoutSyncHandler;
|
import com.zy.system.timer.LoadingConfigTimer;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.stereotype.Component;
|
|
import javax.annotation.Resource;
|
import java.util.Iterator;
|
import java.util.List;
|
|
/**
|
* updated by IX in 2024/12/17
|
*/
|
@Slf4j
|
@Component
|
public class OrderSyncScheduler {
|
|
@Autowired
|
private OrderPakinSyncHandler orderPakinSyncHandler;
|
@Autowired
|
private OrderPakoutSyncHandler orderPakoutSyncHandler;
|
@Autowired
|
private OrderPakinService orderPakinService;
|
@Autowired
|
private OrderPakoutService orderPakoutService;
|
@Autowired
|
private ApiLogService apiLogService;
|
@Autowired
|
private LoadingConfigTimer loadingConfigTimer;
|
|
@Resource
|
private OrderDetlPakoutService orderDetlPakoutService;
|
|
@Resource
|
private OrderDetlPakinService orderDetlPakinService;
|
|
|
@Scheduled(cron = "0 0 1 * * ? ")
|
public void clearApiLog() {
|
try {
|
apiLogService.clearWeekBefore();
|
} catch (Exception e) {
|
log.error("第三方接口日志自动清除失败(范围:一周之前", e);
|
}
|
}
|
|
/**
|
* 定时上报已入库的订单数量
|
*/
|
// @Scheduled(cron = "0 0/5 * * * ?")
|
@Scheduled(cron = "0 0/1 * * * ?")
|
@Async("orderThreadPool")
|
public void reportInStockOrders() {
|
if (loadingConfigTimer.getErpReport()) {
|
List<OrderDetlPakin> orderDetlPakinList = orderDetlPakinService.selectList(new EntityWrapper<OrderDetlPakin>().where("qty > units"));
|
if (!orderDetlPakinList.isEmpty()) {
|
orderPakinSyncHandler.reportInStockOrders(orderDetlPakinList);
|
}
|
}
|
}
|
|
/**
|
* 定时上报已出库的订单数量,定时任务5分钟上报一次,出入库错开上报
|
*/
|
// @Scheduled(cron = "0 3/5 * * * ?")
|
@Scheduled(cron = "0/10 * * * * ?")
|
@Async("orderThreadPool")
|
public void reportOutStockOrders() {
|
if (loadingConfigTimer.getErpReport()) {
|
List<OrderDetlPakout> orderDetlPakoutList = orderDetlPakoutService.selectList(new EntityWrapper<OrderDetlPakout>().where("qty > units"));
|
if (!orderDetlPakoutList.isEmpty()) {
|
orderPakoutSyncHandler.reportOutStockOrders(orderDetlPakoutList);
|
}
|
}
|
}
|
|
/**
|
* 订单已完成,上报已完成,订单状态变已上报
|
*/
|
@Scheduled(cron = "0 * * * * ?")
|
@Async("orderThreadPool")
|
public void completeOrderReport() {
|
// 入库订单已完成转已上报
|
orderPakinSyncHandler.completeOrderReport();
|
// 出库订单已完成转已上报
|
orderPakoutSyncHandler.completeOrderReport();
|
}
|
|
// @Scheduled(cron = "0/15 * * * * ? ")
|
@Async("orderThreadPool")
|
public void completeOrderPakin() {
|
if (loadingConfigTimer.getErpReport()) {
|
List<OrderPakin> orders = orderPakinService.selectComplete();
|
for (OrderPakin order : orders) {
|
orderPakinSyncHandler.startOrderReport(order);
|
}
|
}
|
}
|
|
|
// @Scheduled(cron = "0/15 * * * * ? ")
|
@Async("orderThreadPool")
|
public void completeOrderPakout() {
|
if (loadingConfigTimer.getErpReport()) {
|
List<OrderPakout> orders = orderPakoutService.selectComplete();
|
for (OrderPakout order : orders) {
|
orderPakoutSyncHandler.startOrderReport(order);
|
}
|
}
|
}
|
}
|