| package com.zy.asrs.task; | 
|   | 
| import com.core.common.Cools; | 
| import com.zy.asrs.entity.Order; | 
| import com.zy.asrs.service.ApiLogService; | 
| import com.zy.asrs.service.OrderService; | 
| import com.zy.asrs.task.core.ReturnT; | 
| import com.zy.asrs.task.handler.OrderSyncHandler; | 
| import com.zy.common.entity.Parameter; | 
| import lombok.extern.slf4j.Slf4j; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.scheduling.annotation.Async; | 
| import org.springframework.scheduling.annotation.Scheduled; | 
| import org.springframework.stereotype.Component; | 
|   | 
| import java.util.List; | 
|   | 
| /** | 
|  * Created by vincent on 2020/7/7 | 
|  */ | 
| @Slf4j | 
| @Component | 
| public class OrderSyncScheduler { | 
|   | 
|     @Autowired | 
|     private OrderSyncHandler orderSyncHandler; | 
|     @Autowired | 
|     private OrderService orderService; | 
|     @Autowired | 
|     private ApiLogService apiLogService; | 
|   | 
|     @Scheduled(cron = "0 0 1 * * ? ") | 
|     public void clearApiLog(){ | 
|         try { | 
|             apiLogService.clearWeekBefore(); | 
|         } catch (Exception e) { | 
|             log.error("第三方接口日志自动清除失败(范围:一周之前", e); | 
|         } | 
|     } | 
|   | 
|     //@Scheduled(cron = "0/5 * * * * ? ") | 
|     @Async("orderThreadPool") | 
|     public void completeAndReport(){ | 
| //        String erpReport = Parameter.get().getErpReport(); | 
| //        if (!Cools.isEmpty(erpReport) && erpReport.equals("true")) { | 
| //            List<Order> orders = orderService.selectComplete(); | 
| //            for (Order order : orders) { | 
| //                ReturnT<String> result = orderSyncHandler.start(order); | 
| //                if (!result.isSuccess()) { | 
| //                    log.error("单据[orderNo={}]上报erp失败", order.getOrderNo()); | 
| //                } | 
| //            } | 
| //        } | 
|     } | 
|   | 
| } |