|  |  |  | 
|---|
|  |  |  | package com.zy.asrs.task; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.mapper.EntityWrapper; | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | private OrderSyncHandler orderSyncHandler; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OrderService orderService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ApiLogService apiLogService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Scheduled(cron = "0/3 * * * * ? ") | 
|---|
|  |  |  | private void queryAndSave(){ | 
|---|
|  |  |  | //        for (WrkMast wrkMast : wrkMasts) { | 
|---|
|  |  |  | //            ReturnT<String> result = workLogHandler.start(wrkMast); | 
|---|
|  |  |  | //            if (!result.isSuccess()) { | 
|---|
|  |  |  | //                log.error("工作档[workNo={}]历史档处理失败", wrkMast.getWrkNo()); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | @Scheduled(cron = "0 0 1 * * ? ") | 
|---|
|  |  |  | public void clearApiLog(){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | apiLogService.clearWeekBefore(); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("第三方接口日志自动清除失败(范围:一周之前", e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Scheduled(cron = "0/5 * * * * ? ") | 
|---|
|  |  |  | private 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()); | 
|---|
|  |  |  | //    @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()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|