2 changed files with 60 additions and 2 deletions
@ -0,0 +1,58 @@
|
||||
package com.logpm.factorydata.olo.job; |
||||
|
||||
import cn.hutool.core.collection.CollUtil; |
||||
import cn.hutool.core.date.DateTime; |
||||
import cn.hutool.core.date.DateUtil; |
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.logpm.factorydata.olo.entity.DeliveryNoteEntity; |
||||
import com.logpm.factorydata.olo.service.DeliveryNoteService; |
||||
import com.xxl.job.core.biz.model.ReturnT; |
||||
import com.xxl.job.core.handler.annotation.XxlJob; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 我乐定时生成暂存单 |
||||
* |
||||
* @author zhaoqiaobo |
||||
* @create 2024-04-02 |
||||
*/ |
||||
@AllArgsConstructor |
||||
@Component |
||||
@Slf4j |
||||
public class AdvanceJob { |
||||
|
||||
private final DeliveryNoteService deliveryNoteService; |
||||
|
||||
/** |
||||
* 定时扫描数据库 |
||||
* 背景:我乐每天晚上凌晨1点拉取订单数据,然后存入我乐订单池。 |
||||
* 任务:1点半去定时生成暂存单 |
||||
* |
||||
* @param param |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
@XxlJob("createAdvance") |
||||
public ReturnT<String> createAdvance(String param) throws Exception { |
||||
// 指定天数生成暂存单或者系统自动处理
|
||||
DateTime time = DateUtil.date(); |
||||
if (StrUtil.isNotEmpty(param)) { |
||||
time = DateUtil.parseDate(param); |
||||
} |
||||
// 1 查询出当前拉取的数据
|
||||
// 大于等于 time 的开始 小于 time 的结束
|
||||
List<DeliveryNoteEntity> list = deliveryNoteService.list(Wrappers.<DeliveryNoteEntity>lambdaQuery().between(DeliveryNoteEntity::getCreateTime, DateUtil.beginOfDay(time), DateUtil.endOfDay(time))); |
||||
// 2 按订单和发货单分组作为一个暂存单
|
||||
if (CollUtil.isNotEmpty(list)) { |
||||
// 3 生成暂存单
|
||||
deliveryNoteService.buildAdvance(list); |
||||
} |
||||
return ReturnT.SUCCESS; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue