From 34e6993ca48745f74a02b7457aad4411ec55aebf Mon Sep 17 00:00:00 2001 From: zhangc <zc@123> Date: 星期五, 13 十二月 2024 12:11:45 +0800 Subject: [PATCH] 修复配置及代码逻辑,优化异常处理和日志记录 --- src/main/java/com/zy/asrs/task/OrderSyncScheduler.java | 26 +++++++++++++++----------- 1 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/zy/asrs/task/OrderSyncScheduler.java b/src/main/java/com/zy/asrs/task/OrderSyncScheduler.java index 67082b5..9c764f4 100644 --- a/src/main/java/com/zy/asrs/task/OrderSyncScheduler.java +++ b/src/main/java/com/zy/asrs/task/OrderSyncScheduler.java @@ -1,10 +1,11 @@ package com.zy.asrs.task; +import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.mapper.EntityWrapper; -import com.baomidou.mybatisplus.mapper.Wrapper; import com.core.common.Cools; -import com.core.exception.CoolException; -import com.zy.asrs.entity.*; +import com.zy.asrs.entity.AgvLocDetl; +import com.zy.asrs.entity.Order; +import com.zy.asrs.entity.OrderDetl; import com.zy.asrs.service.AgvLocDetlService; import com.zy.asrs.service.ApiLogService; import com.zy.asrs.service.OrderDetlService; @@ -14,11 +15,11 @@ 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; +import java.util.stream.Collectors; /** * Created by vincent on 2020/7/7 @@ -49,14 +50,15 @@ } } - @Scheduled(cron = "0/5 * * * * ? ") + //@Scheduled(cron = "0/5 * * * * ? ") + @Scheduled(fixedDelay = 5000) //@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) { - //濡傛灉鏄姞宸ュ崟鍒欒繘琛屽垽鏂� + //濡傛灉鏄皟鎷ㄥ崟鍒欒繘琛屽垽鏂� if (order.getDocType() == 33) { //鏌ヨ搴撳瓨涓槸鍚﹀瓨鍦ㄨ璁㈠崟鐨勭墿鏂欎俊鎭紝瀛樺湪鍒欎笉澶勭悊璇ヨ鍗� List<OrderDetl> orderDetlList = orderDetlService.selectByOrderId(order.getId()); @@ -74,16 +76,17 @@ } ReturnT<String> result = orderSyncHandler.start(order); if (!result.isSuccess()) { - log.error("鍗曟嵁[orderNo={}]涓婃姤erp澶辫触", order.getOrderNo()); + //log.error("鍗曟嵁[orderNo={}]涓婃姤erp澶辫触", order.getOrderNo()); } } } } //@Scheduled(cron = "* 0/5 * * * ? ") - @Scheduled(cron = "0/5 * * * * ? ") - @Async("orderThreadPool") - public void reportOrder() { + //@Scheduled(cron = "0/30 * * * * ? ") + @Scheduled(fixedDelay = 30000) + //@Async("orderThreadPool") + public synchronized void reportOrder() { List<Order> orderList = orderService.selectList(new EntityWrapper<Order>().in("settle", 2, 4)); orderList.forEach(order -> { orderSyncHandler.timelyStart(order); @@ -94,7 +97,8 @@ /* 瀹氭椂鏌ヨ鐘舵�佷负2.浣滀笟涓殑鍗曟嵁锛屾鏌ユ槸鍚﹀畬鎴� */ - @Scheduled(cron = "0 */1 * * * ? ") + //@Scheduled(cron = "0 */1 * * * ? ") + @Scheduled(fixedDelay = 60000) public void completeOrder() { List<Order> orderList = orderService.selectList(new EntityWrapper<Order>().eq("settle", 2)); orderList.forEach(order -> { -- Gitblit v1.9.1