| | |
| | | package com.zy.asrs.task; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.zy.asrs.entity.Order; |
| | | import com.zy.asrs.entity.OrderPakin; |
| | | import com.zy.asrs.entity.OrderPakout; |
| | | import com.zy.asrs.service.ApiLogService; |
| | | import com.zy.asrs.service.OrderService; |
| | | import com.zy.asrs.service.OrderPakinService; |
| | | import com.zy.asrs.service.OrderPakoutService; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.asrs.task.handler.OrderSyncHandler; |
| | | 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 java.util.List; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/7/7 |
| | | * updated by IX in 2024/12/17 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class OrderSyncScheduler { |
| | | |
| | | @Autowired |
| | | private OrderSyncHandler orderSyncHandler; |
| | | private OrderPakinSyncHandler orderPakinSyncHandler; |
| | | @Autowired |
| | | private OrderService orderService; |
| | | private OrderPakoutSyncHandler orderPakoutSyncHandler; |
| | | @Autowired |
| | | private OrderPakinService orderPakinService; |
| | | @Autowired |
| | | private OrderPakoutService orderPakoutService; |
| | | @Autowired |
| | | private ApiLogService apiLogService; |
| | | @Autowired |
| | | private LoadingConfigTimer loadingConfigTimer; |
| | | |
| | | |
| | | @Scheduled(cron = "0 0 1 * * ? ") |
| | | public void clearApiLog(){ |
| | | public void clearApiLog() { |
| | | try { |
| | | apiLogService.clearWeekBefore(); |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | } |
| | | |
| | | @Scheduled(cron = "0/5 * * * * ? ") |
| | | |
| | | @Scheduled(cron = "0/30 * * * * ? ") |
| | | @Async("orderThreadPool") |
| | | public void completeAndReport(){ |
| | | List<Order> orders = orderService.selectList(new EntityWrapper<Order>().eq("settle", 4L).eq("status", 1)); |
| | | for (Order order : orders) { |
| | | ReturnT<String> result = orderSyncHandler.start(order); |
| | | if (!result.isSuccess()) { |
| | | log.error("单据[orderNo={}]上报erp失败", order.getOrderNo()); |
| | | public void completeOrderPakin() { |
| | | if (loadingConfigTimer.getErpReport()) { |
| | | List<OrderPakin> orders = orderPakinService.selectComplete(); |
| | | for (OrderPakin order : orders) { |
| | | try { |
| | | ReturnT<String> result = orderPakinSyncHandler.startOrderReport(order); |
| | | if (!result.isSuccess()) { |
| | | log.error("单据[orderNo={}]上报erp失败", order.getOrderNo()); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | log.error("单据[orderNo={}]上报erp失败", order.getOrderNo()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | @Scheduled(cron = "0/30 * * * * ? ") |
| | | @Async("orderThreadPool") |
| | | public void completeOrderPakout() { |
| | | if (loadingConfigTimer.getErpReport()) { |
| | | List<OrderPakout> orders = orderPakoutService.selectComplete(); |
| | | for (OrderPakout order : orders) { |
| | | try { |
| | | ReturnT<String> result = orderPakoutSyncHandler.startOrderReport(order); |
| | | if (!result.isSuccess()) { |
| | | log.error("单据[orderNo={}]上报erp失败", order.getOrderNo()); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | log.error("单据[orderNo={}]上报erp失败", order.getOrderNo()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |