From 572b447708c47d2208632b76b72555f06721091b Mon Sep 17 00:00:00 2001
From: vincentlu <t1341870251@gmail.com>
Date: 星期一, 24 二月 2025 08:21:01 +0800
Subject: [PATCH] #

---
 zy-acs-framework/src/main/java/com/zy/acs/framework/common/DateUtils.java                    |    4 ++
 zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/FuncStaService.java          |    2 +
 zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/FuncStaServiceImpl.java |   31 +++++++++++++++
 zy-acs-manager/src/main/java/com/zy/acs/manager/core/domain/type/BlockSeverityType.java      |    2 
 zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/AnnealedScheduler.java        |   34 +++++++++++++++++
 5 files changed, 72 insertions(+), 1 deletions(-)

diff --git a/zy-acs-framework/src/main/java/com/zy/acs/framework/common/DateUtils.java b/zy-acs-framework/src/main/java/com/zy/acs/framework/common/DateUtils.java
index 79fc51b..41b0144 100644
--- a/zy-acs-framework/src/main/java/com/zy/acs/framework/common/DateUtils.java
+++ b/zy-acs-framework/src/main/java/com/zy/acs/framework/common/DateUtils.java
@@ -77,6 +77,10 @@
         return Math.abs(date2.getTime() - date1.getTime())/1000;
     }
 
+    public static long diffToMilliseconds(Date date1, Date date2) {
+        return Math.abs(date2.getTime() - date1.getTime());
+    }
+
     private static int getDaysByTimestamp(long timestamp){
         double daysPoint = Arith.divides(2, timestamp, (1000 * 3600 * 24));
         int daysPoint1 = (int) daysPoint;
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/domain/type/BlockSeverityType.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/domain/type/BlockSeverityType.java
index b8bb92b..63eeb5d 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/domain/type/BlockSeverityType.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/domain/type/BlockSeverityType.java
@@ -6,7 +6,7 @@
 
 //    NONE(0),
     NONE(0),
-    SEVERE(5 * MapDataConstant.MAX_JAM_TIMEOUT),
+    SEVERE(5L * MapDataConstant.MAX_JAM_TIMEOUT),
     ;
 
     public long duration;
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/AnnealedScheduler.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/AnnealedScheduler.java
new file mode 100644
index 0000000..08112c2
--- /dev/null
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/AnnealedScheduler.java
@@ -0,0 +1,34 @@
+package com.zy.acs.manager.core.scheduler;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zy.acs.framework.common.Cools;
+import com.zy.acs.manager.manager.entity.Agv;
+import com.zy.acs.manager.manager.entity.Segment;
+import com.zy.acs.manager.manager.enums.SegmentStateType;
+import com.zy.acs.manager.manager.enums.StatusType;
+import com.zy.acs.manager.manager.service.AgvService;
+import com.zy.acs.manager.manager.service.SegmentService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+@Slf4j
+@Component
+public class AnnealedScheduler {
+
+    @Autowired
+    private AgvService agvService;
+    @Autowired
+    private SegmentService segmentService;
+
+//    @Scheduled(cron = "0/1 * * * * ? ")
+    private void init() throws InterruptedException {
+
+
+    }
+
+}
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/FuncStaService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/FuncStaService.java
index e3b4c57..83fb232 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/FuncStaService.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/FuncStaService.java
@@ -16,6 +16,8 @@
 
     FuncSta checkoutClosestFunSta(Long codeId, List<FuncSta> funcStaList);
 
+    FuncSta checkoutFurthestFunSta(Long codeId, List<FuncSta> funcStaList);
+
     Boolean isCanBeIdle(FuncSta funcSta);
 
 }
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/FuncStaServiceImpl.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/FuncStaServiceImpl.java
index 7286830..2e52f4c 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/FuncStaServiceImpl.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/FuncStaServiceImpl.java
@@ -171,6 +171,37 @@
     }
 
     @Override
+    public FuncSta checkoutFurthestFunSta(Long codeId, List<FuncSta> funcStaList) {
+        if (Cools.isEmpty(funcStaList)) {
+            return null;
+        }
+
+        if (null != codeId) {
+            Code currCode = codeService.getCacheById(codeId);
+            Double[] startPos = new Double[]{currCode.getX(), currCode.getY()};
+
+            // checkout one funSta which is the closest
+
+            // compare => compare杩斿洖璐熸暟锛屽垯鎺掑湪闆嗗悎鍓嶉潰 锛坅sc锛�
+            funcStaList.sort(new Comparator<FuncSta>() {
+                @Override
+                public int compare(FuncSta o1, FuncSta o2) {
+                    Code o1Code = codeService.getCacheById(o1.getCode());
+                    int o1Distance = CommonUtil.calcDistance(startPos, new Double[]{o1Code.getX(), o1Code.getY()});
+
+                    Code o2Code = codeService.getCacheById(o2.getCode());
+                    int o2Distance = CommonUtil.calcDistance(startPos, new Double[]{o2Code.getX(), o2Code.getY()});
+
+                    return o2Distance - o1Distance;
+                }
+            });
+
+        }
+
+        return funcStaList.stream().findFirst().orElse(null);
+    }
+
+    @Override
     public Boolean isCanBeIdle(FuncSta funcSta) {
         Agv agv;
         switch (Objects.requireNonNull(FuncStaType.query(funcSta.getType()))) {

--
Gitblit v1.9.1