| | |
| | | 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 com.zy.system.entity.Config; |
| | | import com.zy.system.mapper.ConfigMapper; |
| | | 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 javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | private OrderService orderService; |
| | | @Autowired |
| | | private ApiLogService apiLogService; |
| | | @Resource |
| | | private ConfigMapper configMapper; |
| | | |
| | | @Scheduled(cron = "0 0 1 * * ? ") |
| | | public void clearApiLog(){ |
| | |
| | | |
| | | @Scheduled(cron = "0/9 * * * * ? ") |
| | | @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) { |
| | | try{ |
| | | ReturnT<String> result = orderSyncHandler.start(order); |
| | | if (!result.isSuccess()) { |
| | | log.error("单据[orderNo={}]上报erp失败", order.getOrderNo()); |
| | | } |
| | | }catch (Exception e){ |
| | | public void completeAndReport() { |
| | | Config config = configMapper.selectConfigByCode("erpReport"); |
| | | if (config == null || config.getStatus() == 0) { |
| | | return; |
| | | } |
| | | |
| | | List<Order> orders = orderService.selectComplete(); |
| | | for (Order order : orders) { |
| | | try { |
| | | ReturnT<String> result = orderSyncHandler.start(order); |
| | | if (!result.isSuccess()) { |
| | | log.error("单据[orderNo={}]上报erp失败", order.getOrderNo()); |
| | | log.error("订单"+order+"处理失败,异常信息:"+e); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("单据[orderNo={}]上报erp失败", order.getOrderNo()); |
| | | log.error("订单" + order + "处理失败,异常信息:" + e); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |