package com.zy.asrs.task; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.core.common.Cools; import com.zy.asrs.entity.DocType; import com.zy.asrs.entity.Order; import com.zy.asrs.service.DocTypeService; import com.zy.asrs.service.OrderService; import com.zy.asrs.task.handler.AutoReplenishmentHandler; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import java.util.List; @Slf4j @Component public class AutoReplenishmentScheduler { @Autowired private OrderService orderService; @Autowired private DocTypeService docTypeService; @Autowired private AutoReplenishmentHandler autoReplenishmentHandler; /* 定时处理自动补货单据 */ @Scheduled(cron = "0/5 * * * * ? ") public void excute(){ DocType docType = docTypeService.selectOne(new EntityWrapper().eq("doc_name", "自动补货单")); List orderList = orderService.selectList(new EntityWrapper() .eq("doc_type", docType.getDocId()) .eq("settle",1)); if(!Cools.isEmpty(orderList)){ orderList.forEach(order -> { autoReplenishmentHandler.start(order); }); } } }