From 337746fee651f91e9c63bd1c33a474c236d51889 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期三, 06 十一月 2024 10:33:34 +0800 Subject: [PATCH] # --- zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java | 2 zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TrafficService.java | 38 +++---------------- zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/SegmentServiceImpl.java | 27 +++++++++++++ zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/SegmentService.java | 2 + 4 files changed, 36 insertions(+), 33 deletions(-) diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java index cb6fd28..89d03da 100644 --- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java +++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java @@ -1355,7 +1355,7 @@ } // segment call back - trafficService.callback(segmentList); + segmentService.processNext(segmentList); log.info("Agv [{}] {}浣滀笟瀹屾瘯 ==========>> ", protocol.getAgvNo(), serialNo); diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TrafficService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TrafficService.java index b32dc23..0325a9c 100644 --- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TrafficService.java +++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TrafficService.java @@ -189,28 +189,6 @@ } } - public void callback(List<Segment> segmentList) { - Date now = new Date(); - - segmentList.stream().max(Comparator.comparingInt(Segment::getSerial)).ifPresent(segment -> { - Segment nextSegment = segmentService.getNextStepOfInit(segment.getTravelId(), segment.getSerial()); - - if (null != nextSegment) { - - nextSegment.setState(SegmentStateType.WAITING.toString()); - nextSegment.setUpdateTime(now); - if (!segmentService.updateById(nextSegment)) { - log.error("Segment [{}] 鏇存柊澶辫触 锛侊紒锛�", nextSegment.getGroupId() + " - " + nextSegment.getSerial()); - } - - } else { - - travelService.checkFinish(segment.getTravelId()); - } - }); - - } - private List<String> checkoutPath(Agv agv, Code startCode, Code endCode, Segment segment) { Integer lev = null; String agvNo = agv.getUuid(); @@ -261,7 +239,6 @@ return pathList; } - boolean initJamCache = false; if (null == jam) { jam = new Jam(); jam.setUuid(String.valueOf(snowflakeIdWorker.nextId()).substring(3)); @@ -274,7 +251,11 @@ log.error("{}鍙疯溅杈嗗湪{}瀹氫綅琚樆濉烇紝璁板綍闃诲鐘舵�佸け璐ワ紒锛侊紒", agvNo, startCode.getData()); return pathList; } - initJamCache = true; + } else { + jam.setDuration(System.currentTimeMillis() - jam.getStartTime().getTime()); + if (!jamService.updateById(jam)) { + log.error("{}缂栧彿闃诲璁板綍鏇存柊澶辫触锛侊紒锛�", jam.getUuid()); + } } long previousTimestamp = jam.getStartTime().getTime(); @@ -388,13 +369,6 @@ } - if (!initJamCache) { - jam.setDuration(System.currentTimeMillis() - jam.getStartTime().getTime()); - if (!jamService.updateById(jam)) { - log.error("{}缂栧彿闃诲璁板綍鏇存柊澶辫触锛侊紒锛�", jam.getUuid()); - } - } - } } @@ -409,7 +383,7 @@ log.error("{}缂栧彿闃诲璁板綍瀹屾垚淇敼澶辫触锛侊紒锛�", jam.getUuid()); } } - // expired jam + // deal expired jam for (Jam expiredJam : jamService.list(new LambdaQueryWrapper<Jam>() .eq(Jam::getJamAgv, agv.getId()) .eq(Jam::getState, JamStateType.RUNNING.toString()))) { diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/SegmentService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/SegmentService.java index 3772f0d..02803e3 100644 --- a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/SegmentService.java +++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/SegmentService.java @@ -8,6 +8,8 @@ public interface SegmentService extends IService<Segment> { + void processNext(List<Segment> segmentList); + Segment getNextStepOfInit(Long travelId, Integer serial); Segment getJustWaitingSeg(Long agvId); diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/SegmentServiceImpl.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/SegmentServiceImpl.java index 02f2a82..da6a106 100644 --- a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/SegmentServiceImpl.java +++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/SegmentServiceImpl.java @@ -8,10 +8,13 @@ import com.zy.acs.manager.manager.service.AgvService; import com.zy.acs.manager.manager.service.SegmentService; import com.zy.acs.framework.common.Cools; +import com.zy.acs.manager.manager.service.TravelService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Comparator; +import java.util.Date; import java.util.List; @Slf4j @@ -20,6 +23,30 @@ @Autowired private AgvService agvService; + @Autowired + private TravelService travelService; + + @Override + public void processNext(List<Segment> segmentList) { + Date now = new Date(); + + segmentList.stream().max(Comparator.comparingInt(Segment::getSerial)).ifPresent(segment -> { + Segment nextSegment = this.getNextStepOfInit(segment.getTravelId(), segment.getSerial()); + + if (null != nextSegment) { + + nextSegment.setState(SegmentStateType.WAITING.toString()); + nextSegment.setUpdateTime(now); + if (!this.updateById(nextSegment)) { + log.error("Segment [{}] failed to update 锛侊紒锛�", nextSegment.getGroupId() + " - " + nextSegment.getSerial()); + } + + } else { + + travelService.checkFinish(segment.getTravelId()); + } + }); + } @Override public Segment getNextStepOfInit(Long travelId, Integer serial) { -- Gitblit v1.9.1