From 68ff33beff11310e830b0615b5a81f83fad0f683 Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期日, 08 十一月 2026 23:33:14 +0800
Subject: [PATCH] ai优化

---
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Utils.java |  104 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 103 insertions(+), 1 deletions(-)

diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Utils.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Utils.java
index 4b40db7..32694b3 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Utils.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Utils.java
@@ -1,14 +1,37 @@
 package cn.lihu.jh.module.ecg;
 
-import jodd.typeconverter.impl.LocalTimeConverter;
+import cn.lihu.jh.module.ecg.dal.dataobject.queue.QueueDO;
 
 import java.time.LocalTime;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
+import java.util.Objects;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 public class Utils {
+    public static LocalTime parseTime(String strTime) {
+        String regex = "(\\d+)[:锛歖(\\d+)";
+        Pattern pattern = Pattern.compile(regex);
+        Matcher matcher = pattern.matcher(strTime);
+
+        if (!matcher.find())
+            return null;
+
+        // 鑾峰彇鏁翠釜鍖归厤鐨勫瓧绗︿覆
+        String fullMatch = matcher.group();
+
+        // 鑾峰彇绗竴涓崟鑾风粍锛堝皬鏃讹級
+        String strOpenHour = matcher.group(1);
+
+        // 鑾峰彇绗簩涓崟鑾风粍锛堝垎閽燂級
+        String strOpenMinute = matcher.group(2);
+
+        LocalTime localTime = LocalTime.of(Integer.valueOf(strOpenHour), Integer.valueOf(strOpenMinute));
+        return localTime;
+    }
+
     public static List<LocalTime> parseOpeningTime(String strOpeningTime) {
         String regex = "(\\d+)[:锛歖(\\d+)~(\\d+)[:锛歖(\\d+)";
         Pattern pattern = Pattern.compile(regex);
@@ -39,5 +62,84 @@
         openCloseTime.add(localCloseTime);
         return openCloseTime;
     }
+
+    public static String  formatRoomBed(Long roomId, String bedNo) {
+        return String.format("%09d%s", roomId, bedNo);
+    }
+
+    public static List<LocalTime> parseTimeSlotList(String strTimeSlotList, Integer timeslotLength) {
+        List<LocalTime> localTimeList = new ArrayList<>();
+
+        // 7:30,8:30,9:30,10:30,11:30,12:30,13:30,14:30,15:30
+        String[] arrTimeSlotItemStr = strTimeSlotList.split(",|锛�");
+        Arrays.stream(arrTimeSlotItemStr).forEach( strTimeSlot -> {
+            String regex = "(\\d+)[:锛歖(\\d+)";
+            Pattern pattern = Pattern.compile(regex);
+            Matcher matcher = pattern.matcher(strTimeSlot);
+            if (!matcher.find())
+                return;
+
+            // 鑾峰彇鏁翠釜鍖归厤鐨勫瓧绗︿覆
+            String fullMatch = matcher.group();
+
+            // 鑾峰彇绗竴涓崟鑾风粍锛堝皬鏃讹級
+            String strHour = matcher.group(1);
+
+            // 鑾峰彇绗簩涓崟鑾风粍锛堝垎閽燂級
+            String strMinute = matcher.group(2);
+
+            LocalTime localTimeSlot = LocalTime.of(Integer.valueOf(strHour), Integer.valueOf(strMinute));
+            localTimeList.add( localTimeSlot );
+        } );
+
+        return localTimeList;
+    }
+
+    /**
+     * 鎶娿�屼翰鍜岄」銆嶆彃鍥炲埌瀹冪殑銆屼富椤广�嶅悗闈紝浣夸袱鑰呭湪鐣岄潰涓婄揣鎸ㄧ潃鏄剧ず銆�
+     *
+     * <p>浜插拰椤� = 鍚屼竴鎮h�呯殑鍙︿竴涓鏌ラ」鐩細涓婚」杩涘�欒瘖鏃跺畠涓�璧疯繘锛屼富椤瑰仛瀹屾椂瀹冧竴璧峰仛瀹�
+     * 锛堣 {@code QueueServiceTxFunctions#procAffinityWhenPreempt}锛夈��
+     *
+     * <p>涔嬫墍浠ユ娊鎴愪竴涓柟娉曪細杩欐閫昏緫鍦ㄥ伐浣滃彴鍒楄〃銆佽瘖闂村睆銆佸ぇ灞忓叡 <b>5 澶�</b>閲嶅锛�
+     * 鑰屽師瀹炵幇鏈変袱涓潙锛堥殢銆屾帓闃熷彿缁熶竴銆嶆敼閫犱竴骞朵慨姝o級锛�
+     * <ol>
+     *   <li>鍙敤 {@code seqNum} 鐩哥瓑鏉ュ畾浣嶄富椤广�傛帓闃熷彿鏀逛负銆屾寜妫�鏌ョ被鍨嬪悇鑷紪鍙枫�嶅悗鍙蜂細璺ㄦ鏌ョ被鍨嬮噸澶嶏紝
+     *       鍙兘鎶婁翰鍜岄」鎻掑埌<b>鍒殑妫�鏌ョ被鍨�</b>鐨勬偅鑰呭悗闈紱鏁呭悓鏃惰姹� {@code patId} 鐩稿悓銆�</li>
+     *   <li>鐢� {@code ==} 姣旇緝 {@code Integer}锛氬彿澶т簬 127 鏃舵槸寮曠敤姣旇緝銆佹案杩滀笉鐩哥瓑锛�
+     *       浜插拰椤硅 {@code remove} 涔嬪悗鎻掍笉鍥炲幓 鈥斺�� 琛ㄧ幇涓�<b>浜插拰椤瑰湪鍒楄〃閲屾秷澶�</b>
+     *       锛堟椂娈靛彿瑙勫垯涓嬪彿寰堝鏄撹秴杩� 127锛夈�傛敼涓烘寜鍊兼瘮杈冿紝骞跺姞"鎵句笉鍒颁富椤瑰氨杩藉姞鍒版湯灏�"鐨勫厹搴曘��</li>
+     * </ol>
+     *
+     * @param list          宸叉帓濂藉簭鐨勫垪琛紙璋冪敤鏂归渶鍏堟妸浜插拰椤逛粠涓Щ闄わ級
+     * @param affinityItems 琚Щ闄ゅ嚭鏉ョ殑浜插拰椤�
+     */
+    public static void insertAffinityItemsAfterMain(List<QueueDO> list, List<QueueDO> affinityItems) {
+        if (list == null || affinityItems == null || affinityItems.isEmpty()) {
+            return;
+        }
+        for (QueueDO affinityItem : affinityItems) {
+            boolean inserted = false;
+            for (int i = list.size() - 1; i >= 0; i--) {
+                QueueDO mainItem = list.get(i);
+                if (isSameSeqNum(affinityItem.getSeqNum(), mainItem.getSeqNum())
+                        && Objects.equals(affinityItem.getPatId(), mainItem.getPatId())) {
+                    list.add(i + 1, affinityItem);
+                    inserted = true;
+                    break;
+                }
+            }
+            if (!inserted) {
+                // 涓婚」涓嶅湪鏈垪琛紙渚嬪宸插氨璇婂畬鎴愯鐘舵�佽繃婊ゆ帀锛夛細鍏滃簳杩藉姞鍒版湯灏撅紝
+                // 瀹佸彲浣嶇疆涓嶅畬缇庯紝涔熶笉鑳借鍊欒瘖涓殑鎮h�呬粠鍒楄〃閲�"娑堝け"銆�
+                list.add(affinityItem);
+            }
+        }
+    }
+
+    /** 鎺掗槦鍙锋寜鍊兼瘮杈冿紙{@code Integer} 鐢� {@code ==} 鍦ㄥぇ浜� 127 鏃舵槸寮曠敤姣旇緝锛屼細璇垽涓轰笉绛夛級 */
+    private static boolean isSameSeqNum(Integer a, Integer b) {
+        return a != null && b != null && a.intValue() == b.intValue();
+    }
 }
 

--
Gitblit v1.9.3