1
zhang
14 小时以前 70ff4954fec4483883e2485bc8c0ed59054b91a9
zy-acs-manager/src/main/java/com/zy/acs/manager/core/third/ReportThirdScheduler.java
@@ -4,6 +4,7 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.acs.framework.common.Cools;
import com.zy.acs.manager.core.third.dto.TaskEvent;
import com.zy.acs.manager.core.utils.HttpHandler;
import com.zy.acs.manager.manager.entity.TaskReport;
import com.zy.acs.manager.manager.entity.TaskReportLog;
@@ -43,10 +44,10 @@
        if (report) {
            String wmsUrl = configService.getVal("WMS_URL", String.class);
            String wmsPath = configService.getVal("WMS_PATH", String.class);
            String codes = configService.getVal("CODES", String.class, "1457;1612");
            List<TaskReport> list = taskReportService.list(new LambdaQueryWrapper<TaskReport>().eq(TaskReport::getCompleted, 0).le(TaskReport::getReportTimes, 3));
            for (TaskReport taskReport : list) {
                if (report(taskReport, wmsUrl, wmsPath)) {
                log.info("开始上报:{}", taskReport);
                if (report(new TaskEvent(taskReport.getSeqNum(), taskReport.getEventType()), wmsUrl, wmsPath)) {
                    taskReport.setReportTimes((Cools.isEmpty(taskReport.getReportTimes()) ? 0 : taskReport.getReportTimes()) + 1);
                    taskReport.setUpdateTime(new Date());
                    taskReport.setCompleted(1);
@@ -59,27 +60,33 @@
        }
    }
    /**
     * 删除超过一天的上报历史记录
     */
    @Scheduled(fixedDelay = 3000)
    public void execute2() {
        Calendar instance = Calendar.getInstance();
        instance.add(Calendar.DATE, 1);
        List<TaskReport> list = taskReportService.list(new LambdaQueryWrapper<TaskReport>().eq(TaskReport::getCompleted, 1).ge(TaskReport::getUpdateTime, instance.getTime()));
        Integer times = configService.getVal("REPORT_TIMES", Integer.class, 3);
        for (TaskReport taskReport : list) {
            if ((Cools.isEmpty(taskReport.getReportTimes()) ? 0 : taskReport.getReportTimes()) > times) {
                toLog(taskReport);
        Boolean report = configService.getVal("REPORT", Boolean.class, false);
        if (report) {
            Calendar instance = Calendar.getInstance();
            instance.add(Calendar.DATE, 1);
            List<TaskReport> list = taskReportService.list(new LambdaQueryWrapper<TaskReport>().eq(TaskReport::getCompleted, 1).ge(TaskReport::getUpdateTime, instance.getTime()));
            Integer times = configService.getVal("REPORT_TIMES", Integer.class, 3);
            for (TaskReport taskReport : list) {
                if ((Cools.isEmpty(taskReport.getReportTimes()) ? 0 : taskReport.getReportTimes()) > times) {
                    toLog(taskReport);
                }
            }
        }
        list = taskReportService.list(new LambdaQueryWrapper<TaskReport>().eq(TaskReport::getReportTimes, 4).ge(TaskReport::getUpdateTime, instance.getTime()));
        for (TaskReport taskReport : list) {
            if ((Cools.isEmpty(taskReport.getReportTimes()) ? 0 : taskReport.getReportTimes()) > times) {
                toLog(taskReport);
            list = taskReportService.list(new LambdaQueryWrapper<TaskReport>().eq(TaskReport::getReportTimes, 4).ge(TaskReport::getUpdateTime, instance.getTime()));
            for (TaskReport taskReport : list) {
                if ((Cools.isEmpty(taskReport.getReportTimes()) ? 0 : taskReport.getReportTimes()) > times) {
                    toLog(taskReport);
                }
            }
        }
    }
    @Transactional
    public boolean report(TaskReport taskReport, String wmsUrl, String wmsPath) {
    public boolean report(TaskEvent taskReport, String wmsUrl, String wmsPath) {
        String response = null;
        try {
            response = new HttpHandler.Builder()
@@ -95,7 +102,6 @@
            }
        } catch (IOException e) {
            log.info("报错了,{}", e);
            taskReport.setMemo(e.getMessage());
            e.printStackTrace();
        }