自动化立体仓库 - WMS系统
13
zhang
23 小时以前 d7c7cbbe2ba964b92e31e36d15c6941b4328b9b4
src/main/java/com/zy/asrs/task/OrderSyncScheduler.java
@@ -1,11 +1,20 @@
package com.zy.asrs.task;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.zy.asrs.entity.*;
import com.zy.asrs.service.*;
import com.zy.asrs.task.core.ReturnT;
import com.zy.asrs.task.handler.OrderSyncHandler;
import com.zy.common.entity.Parameter;
import com.zy.common.utils.Synchro;
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
@@ -26,6 +35,10 @@
    private OrderDetlReportService orderDetlReportService;
    @Autowired
    private OrderDetlReportLogService orderDetlReportLogService;
    @Autowired
    private OrderReportService orderReportService;
    @Autowired
    private OrderReportLogService orderReportLogService;
    @Scheduled(cron = "0 0 1 * * ? ")
    public void clearApiLog() {
@@ -36,31 +49,16 @@
        }
    }
   /* @Scheduled(cron = "0/30 * * * * ? ")
    public void clearReportLog() {
        try {
            List<OrderDetlReport> orderDetls = orderDetlReportService.selectList(new EntityWrapper<OrderDetlReport>());
            for (OrderDetlReport orderDetl : orderDetls) {
                OrderPakin order = orderService.selectByNo(orderDetl.getOrderNo());
                if (order == null) {
                    OrderDetlReportLog orderDetlReportLog = new OrderDetlReportLog();
                    orderDetlReportLog.sync(orderDetl);
                    orderDetlReportLog.setId(null);
                    orderDetlReportLogService.insert(orderDetlReportLog);
                    orderDetlReportService.deleteById(orderDetl.getId());
                }
            }
        } catch (Exception e) {
            log.error("上报日志删除", e);
        }
    }
    /**
     * 订单状态4至6,并且写入上报表
     */
    @Scheduled(cron = "0/5 * * * * ? ")
    @Async("orderThreadPool")
    public void completeAndReport() {
    public void completeOrderPakin() {
        String erpReport = Parameter.get().getErpReport();
        if (!Cools.isEmpty(erpReport) && erpReport.equals("true")) {
            List<OrderPakin> orders = orderService.selectComplete();
            List<OrderPakin> orders = orderPakinService.selectComplete();
            for (OrderPakin order : orders) {
                ReturnT<String> result = orderSyncHandler.start(order);
                if (!result.isSuccess()) {
@@ -68,6 +66,48 @@
                }
            }
        }
    }*/
    }
    /**
     * 订单状态4至6,并且写入上报表
     */
    @Scheduled(cron = "0/5 * * * * ? ")
    @Async("orderThreadPool")
    public void completeOrderPakout() {
        String erpReport = Parameter.get().getErpReport();
        if (!Cools.isEmpty(erpReport) && erpReport.equals("true")) {
            List<OrderPakout> orders = orderPakoutService.selectComplete();
            for (OrderPakout order : orders) {
                ReturnT<String> result = orderSyncHandler.start(order);
                if (!result.isSuccess()) {
                    log.error("单据[orderNo={}]上报erp失败", order.getOrderNo());
                }
            }
        }
    }
    //@Scheduled(cron = "0 0 3 * * ? ")
    @Scheduled(cron = "0/5 * * * * ? ")
    public void clearReportLog() {
        try {
            List<OrderReport> orderReports = orderReportService.selectList(new EntityWrapper<OrderReport>().eq("status", 1).eq("settle", 4));
            for (OrderReport orderReport : orderReports) {
                List<OrderDetlReportLog> orderId = orderDetlReportLogService.selectList(new EntityWrapper<OrderDetlReportLog>().eq("order_id", orderReport.getId()));
                for (OrderDetlReportLog orderDetl : orderId) {
                    OrderDetlReportLog orderDetlReportLog = new OrderDetlReportLog();
                    orderDetlReportLog.sync(orderDetl);
                    orderDetlReportLog.setId(null);
                    orderDetlReportLogService.insert(orderDetlReportLog);
                    orderDetlReportService.deleteById(orderDetl.getId());
                }
                OrderReportLog reportLog = new OrderReportLog();
                Synchro.Copy(orderReport, reportLog);
                orderReportLogService.insert(reportLog);
                orderReportService.deleteById(orderReport.getId());
            }
        } catch (Exception e) {
            log.error("上报日志删除", e);
        }
    }
}