|  |  |  | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | * Created by vincent on 2020/7/7 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | //@Component | 
|---|
|  |  |  | @Component | 
|---|
|  |  |  | public class OrderSyncScheduler { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Scheduled(cron = "0/5 * * * * ? ") | 
|---|
|  |  |  | //    @Scheduled(cron = "0/5 * * * * ? ") | 
|---|
|  |  |  | @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()); | 
|---|
|  |  |  | 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()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|