|  |  |  | 
|---|
|  |  |  | package com.zy.asrs.task.kingdee; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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.kingdee.handler.ReviewOrderSyncHandler; | 
|---|
|  |  |  | import com.zy.asrs.utils.OrderInAndOutUtil; | 
|---|
|  |  |  | import com.zy.common.entity.Parameter; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Value; | 
|---|
|  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * Created by vincent on 2020/7/7 | 
|---|
|  |  |  | * Created by vincent on 2023/10/21 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Component | 
|---|
|  |  |  | 
|---|
|  |  |  | private ReviewOrderSyncHandler reviewOrderSyncHandler; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OrderService orderService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ApiLogService apiLogService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Value("${erp.switch.ReviewOrderSwitch}") | 
|---|
|  |  |  | private boolean ReviewOrderSwitch; | 
|---|
|  |  |  | //    @Scheduled(cron = "0 0 1 * * ? ") | 
|---|
|  |  |  | public void clearApiLog(){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | apiLogService.clearWeekBefore(); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("第三方接口日志自动清除失败(范围:一周之前", e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Scheduled(cron = "0/3 * * * * ? ") | 
|---|
|  |  |  | @Async("orderThreadPool") | 
|---|
|  |  |  | 
|---|
|  |  |  | if(!ReviewOrderSwitch){ | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Order> orders = orderService.selectComplete(); | 
|---|
|  |  |  | for (Order order : orders) { | 
|---|
|  |  |  | ReturnT<String> result = reviewOrderSyncHandler.start(order); | 
|---|
|  |  |  | if (!result.isSuccess()) { | 
|---|
|  |  |  | log.error("单据[orderNo={}]上报erp失败", order.getOrderNo()); | 
|---|
|  |  |  | String erpReport = Parameter.get().getErpReport(); | 
|---|
|  |  |  | if (!Cools.isEmpty(erpReport) && erpReport.equals("true")) { | 
|---|
|  |  |  | //        List<Order> orders = orderService.selectComplete(); | 
|---|
|  |  |  | List<Order> orders = OrderInAndOutUtil.selectComplete(null); | 
|---|
|  |  |  | for (Order order : orders) { | 
|---|
|  |  |  | ReturnT<String> result = reviewOrderSyncHandler.start(order); | 
|---|
|  |  |  | if (!result.isSuccess()) { | 
|---|
|  |  |  | log.error("单据[orderNo={}]向erp审核失败", order.getOrderNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|