#
luxiaotao1123
12 小时以前 80f5003a640db7795d69c5e3a73caa685c289b80
zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/KernelScheduler.java
@@ -5,6 +5,7 @@
import com.zy.acs.manager.core.service.MainLockWrapService;
import com.zy.acs.manager.core.service.MainService;
import com.zy.acs.manager.core.service.TrafficService;
import com.zy.acs.manager.core.service.TransferStationHandler;
import com.zy.acs.manager.manager.entity.Bus;
import com.zy.acs.manager.manager.entity.Segment;
import com.zy.acs.manager.manager.entity.Task;
@@ -20,6 +21,7 @@
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.support.TransactionTemplate;
import javax.annotation.PreDestroy;
import java.util.ArrayList;
@@ -47,6 +49,8 @@
    private Thread actionPublicThread;
    @Autowired
    private TransactionTemplate txTemplate;
    @Autowired
    private AgvService agvService;
    @Autowired
    private BusService busService;
@@ -68,6 +72,8 @@
    private LocService locService;
    @Autowired
    private AgvModelService agvModelService;
    @Autowired
    private TransferStationHandler transferStationHandler;
    @Scheduled(cron = "0/1 * * * * ? ")
    private void startupBus() throws InterruptedException {
@@ -116,11 +122,17 @@
                            .eq(Segment::getState, SegmentStateType.WAITING.toString())
                    );
                    for (Segment segment : segments) {
                        long startTime = System.currentTimeMillis();
                        trafficService.trigger(segment);
//                        log.info("traffic calculation spend {} ms", System.currentTimeMillis() - startTime);
                        if (transferStationHandler.hasDelayAtSta(segment)) {
                            continue;
                        }
                        try {
                            txTemplate.executeWithoutResult(status -> {
                                trafficService.trigger(segment);
                            });
                        } catch (Exception e) {
                            log.error("trigger fail segId={}", segment.getId(), e);
                        }
                    }
                } catch (Exception e) {
                    log.error("KernelScheduler.trafficCalcThread fail", e);
                }