From 1f23e7dfc186c65434eda46fd6756d41fd01e867 Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期三, 11 十一月 2026 00:00:37 +0800
Subject: [PATCH] ai优化
---
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java | 73 +++++++++++++++++++++++++++++++++---
1 files changed, 67 insertions(+), 6 deletions(-)
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java
index 6c3f1e9..e97c3eb 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java
@@ -22,6 +22,8 @@
import org.apache.cxf.common.util.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.support.TransactionSynchronization;
+import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.validation.annotation.Validated;
import cn.lihu.jh.module.ecg.dal.dataobject.room.RoomDO;
@@ -316,9 +318,45 @@
@Override
public void startHurryUpOneBed(Long roomId, String bedNo) {
- singleThreadExecutor.execute(() -> {
- queueServiceTxFunctions.hurryupOneBed(roomId, bedNo);
- });
+ // 銆愮己闄蜂慨澶嶃�戝繀椤荤瓑浜嬪姟鎻愪氦鍚庡啀璺戯細瑙� runAfterCommit 鐨勮鏄�
+ runAfterCommit(() -> singleThreadExecutor.execute(() -> {
+ try {
+ queueServiceTxFunctions.hurryupOneBed(roomId, bedNo);
+ } catch (Exception e) {
+ // 鍘熷疄鐜颁笉鎹曡幏锛氬紓甯稿彧鐣欏湪宸ヤ綔绾跨▼閲岋紝鏃ュ織涓�鏉¢兘娌℃湁锛岀幇鍦烘棤浠庢帓鏌�
+ log.error("[hurryupOneBed] 鑷姩琛ヤ汉鎵ц寮傚父. 宸ヤ綅={}/{}锛堜笉褰卞搷涓绘祦绋嬶紝涓嬩竴杞細閲嶈瘯锛�",
+ roomId, bedNo, e);
+ }
+ }));
+ }
+
+ /**
+ * 鎶娿�岃Е鍙戣嚜鍔ㄥ垎娴併�嶆帹杩熷埌**浜嬪姟鎻愪氦涔嬪悗**鍐嶆墽琛岋紱涓嶅湪浜嬪姟閲屽垯鐩存帴鎵ц銆�
+ *
+ * <p>銆愮己闄蜂慨澶嵚风幇鍦哄弽棣堛�戣繍鍔ㄨ瘯楠岀鍒板悗锛屾偅鑰呬竴鐩村仠鍦ㄥ尰鐢熷伐浣滃彴鐨�
+ * 銆屾湰璇婂鎺掗槦涓紙鏈垎閰嶅伐浣嶏級銆嶏紝蹇呴』鎵嬪伐鐐广�屾媺鍏ャ�嶆墠杩涘�欒瘖鍖恒��
+ *
+ * <p>鍘熷洜锛歿@link #queue} 鏄� {@code @Transactional}锛屾彃鍏ャ�屾帓闃熶腑銆嶈涔嬪悗**绔嬪嵆**鎶�
+ * 鍒嗘祦浠诲姟涓㈢粰 {@code singleThreadExecutor}銆傚伐浣滅嚎绋嬬敤鐨勬槸**鍙︿竴涓暟鎹簱杩炴帴**锛�
+ * READ COMMITTED 涓嬬湅涓嶅埌涓讳簨鍔″皻鏈彁浜ょ殑閭d竴琛� 鈬�
+ * {@code getFirstWaitingByCheckTypes} 杩斿洖 null 鈬� 杩欐鍒嗘祦浠�涔堥兘娌″仛灏遍��鍑猴紱
+ * 浜嬪姟鎻愪氦鍚庡張娌℃湁浠讳綍琛ュ伩 鈬� 鎮h�呮案杩滅暀鍦ㄣ�屾帓闃熶腑銆嶃��
+ *
+ * <p>涓轰粈涔堜綆棰戞鏌ラ」鐩紙杩愬姩璇曢獙銆侀閬撶數鐢熺悊锛夊嚑涔庡繀鐒朵腑鎷涖�侀珮棰戠殑鍗�"鐪嬭捣鏉ユ甯�"锛�
+ * 鎵ц鍣ㄥ钩鏃剁┖闂诧紝浠诲姟鑳�**绔嬪埢**鎵ц锛堝繀鐒舵棭浜庢彁浜わ級锛涢珮棰戦」鐩换鍔′細鎺掗槦锛�
+ * 杞埌鏃朵簨鍔″線寰�宸茬粡鎻愪氦锛屼簬鏄茎骞告垚鍔熴��
+ */
+ private void runAfterCommit(Runnable task) {
+ if (TransactionSynchronizationManager.isSynchronizationActive()) {
+ TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
+ @Override
+ public void afterCommit() {
+ task.run();
+ }
+ });
+ } else {
+ task.run();
+ }
}
@Override
@@ -329,9 +367,32 @@
@Override
public void startHurryUpOneCheckType(Integer checkType) {
- singleThreadExecutor.execute(() -> {
- queueServiceTxFunctions.hurryupOneCheckType(checkType);
- });
+ // 銆愮己闄蜂慨澶嶃�戝繀椤荤瓑浜嬪姟鎻愪氦鍚庡啀璺戯細瑙� runAfterCommit 鐨勮鏄�
+ runAfterCommit(() -> singleThreadExecutor.execute(() -> {
+ try {
+ queueServiceTxFunctions.hurryupOneCheckType(checkType);
+ } catch (Exception e) {
+ log.error("[hurryupOneCheckType] 鑷姩鍒嗘祦鎵ц寮傚父. checkType={}锛堜笉褰卞搷涓绘祦绋嬶紝涓嬩竴杞細閲嶈瘯锛�",
+ checkType, e);
+ }
+ }));
+ }
+
+ /**
+ * 鍏滃簳锛氬**鏈夊尰鐢熷湪搴�**鐨勫伐浣嶈Е鍙戜竴娆¤嚜鍔ㄨˉ浜猴紙鐢� {@code QueueAutoRefillJob} 鍛ㄦ湡璋冪敤锛夈��
+ *
+ * <p>娉ㄦ剰鐢ㄧ殑鏄� {@code hurryupAllSeatedBeds} 鑰屼笉鏄� {@code hurryupAllBed}锛�
+ * 鍚庤�呬細鎶婃偅鑰呮帹杩�"宸插紑閫氫絾娌″尰鐢�"鐨勫伐浣嶏紝鍛ㄦ湡璺戜細鏀惧ぇ璇ュ壇浣滅敤銆�
+ */
+ @Override
+ public void startHurryUpAll() {
+ runAfterCommit(() -> singleThreadExecutor.execute(() -> {
+ try {
+ queueServiceTxFunctions.hurryupAllSeatedBeds();
+ } catch (Exception e) {
+ log.error("[hurryupAllSeatedBeds] 鍛ㄦ湡琛ヤ汉鎵ц寮傚父锛堜笅涓�杞户缁級", e);
+ }
+ }));
}
@Override
--
Gitblit v1.9.3