| | |
| | | package com.zy.asrs.task; |
| | | |
| | | import com.zy.asrs.entity.Order; |
| | | import com.zy.asrs.service.OrderService; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.asrs.task.handler.OrderLogHandler; |
| | | 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 OrderLogScheduler { |
| | | // @Autowired |
| | | // private OrderLogHandler orderLogHandler; |
| | | // @Autowired |
| | | // private OrderService orderService; |
| | | @Autowired |
| | | private OrderLogHandler orderLogHandler; |
| | | @Autowired |
| | | private OrderService orderService; |
| | | // |
| | | // @Value("${erp.enable}") |
| | | // private boolean isERP; |
| | | // |
| | | // @Scheduled(cron = "0/10 * * * * ? ") |
| | | // private void execute(){ |
| | | // List<Order> orders = orderService.selectToBeHistoryOrder(isERP); |
| | | // if (orders.isEmpty()) { |
| | | // return; |
| | | // } |
| | | // for (Order order : orders) { |
| | | // ReturnT<String> result = orderLogHandler.start(order); |
| | | // if (!result.isSuccess()) { |
| | | // log.error("单据档[orderNo={}]历史档处理失败", order.getOrderNo()); |
| | | // } |
| | | // } |
| | | // } |
| | | //@Scheduled(cron = "0/10 * * * * ? ") |
| | | @Scheduled(fixedDelay = 10000) |
| | | private void execute(){ |
| | | List<Order> orders = orderService.selectToBeHistoryOrder(); |
| | | if (orders.isEmpty()) { |
| | | return; |
| | | } |
| | | for (Order order : orders) { |
| | | ReturnT<String> result = orderLogHandler.start(order); |
| | | if (!result.isSuccess()) { |
| | | log.error("单据档[orderNo={}]历史档处理失败", order.getOrderNo()); |
| | | } |
| | | } |
| | | } |
| | | } |