Files
ruoyi-java/ruoyi-system/src/main/java/com/ruoyi/jarvis/task/GoofishScheduledTasks.java
2026-04-23 16:04:45 +08:00

64 lines
2.1 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package com.ruoyi.jarvis.task;
import com.ruoyi.jarvis.config.JarvisGoofishProperties;
import com.ruoyi.jarvis.domain.ErpOpenConfig;
import com.ruoyi.jarvis.service.IErpGoofishOrderService;
import com.ruoyi.jarvis.service.IErpOpenConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
* 闲管家 ERP定时拉单与运单同步/自动发货
*/
@Component
public class GoofishScheduledTasks {
private static final Logger log = LoggerFactory.getLogger(GoofishScheduledTasks.class);
@Resource
private IErpOpenConfigService erpOpenConfigService;
@Resource
private IErpGoofishOrderService erpGoofishOrderService;
@Resource
private JarvisGoofishProperties goofishProperties;
@Scheduled(cron = "${jarvis.goofish-order.pull-cron:0 0/10 * * * ?}")
public void scheduledPull() {
List<ErpOpenConfig> cfgs = erpOpenConfigService.selectEnabledOrderBySort();
if (cfgs == null || cfgs.isEmpty()) {
return;
}
int hours = goofishProperties.getPullLookbackHours();
int n = 0;
for (ErpOpenConfig c : cfgs) {
try {
n += erpGoofishOrderService.pullOrdersForAppKey(c.getAppKey(), hours);
} catch (Exception e) {
log.warn("定时拉单失败 appKey={} {}", c.getAppKey(), e.getMessage());
}
}
if (n > 0) {
log.info("闲管家定时拉单本轮处理约 {} 条子订单项", n);
}
}
@Scheduled(cron = "${jarvis.goofish-order.auto-ship-cron:0 2/10 * * * ?}")
public void scheduledWaybillAndShip() {
try {
int k = erpGoofishOrderService.syncWaybillAndTryShipBatch(goofishProperties.getAutoShipBatchSize());
if (k > 0) {
log.info("闲管家运单同步与发货扫描处理 {} 条", k);
}
} catch (Exception e) {
log.warn("闲管家自动发货扫描异常 {}", e.getMessage());
}
}
}