From 09dc74e264b6262cbe41c9c8476e24705871d4a6 Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期日, 08 十一月 2026 23:31:17 +0800
Subject: [PATCH] yxh
---
src/api/ecg/room/index.ts | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 162 insertions(+), 6 deletions(-)
diff --git a/src/api/ecg/room/index.ts b/src/api/ecg/room/index.ts
index b8eaea9..ca73801 100644
--- a/src/api/ecg/room/index.ts
+++ b/src/api/ecg/room/index.ts
@@ -6,17 +6,92 @@
roomId: number | null // 璇婂缂栧彿
roomName: string | null // 璇婂鍚嶇О
bedNo: string | null // 璇婄枟搴婄紪鍙�
- ip: string | null // 璇婂IP
+ ip: string | null // 璇婂宸ヤ綅IP
status: number | null //寮�璇婄姸鎬� 0-鍏抽棴 1-鍏抽棴涓� 10-宸插紑閫� 20-鏈夊尰鐢� 30-鏆傚仠
docId: number | null
docName: string | null
- checkTypes: number[]
+ checkTypes: number[] | null
+ opType: number | null
+ occupied?: boolean | null // 璇ュ伐浣嶆槸鍚﹀凡琚尰鐢熷崰鐢紙鎸塈P鍖归厤宸ヤ綅鏃剁敤锛�
+}
+
+// 銆岄�夋嫨宸ヤ綅妯″紡銆�- 鎸夋湰鏈篒P鍖归厤宸ヤ綅鐨勫�欓�夊伐浣�
+export interface RoomSelectBedItem {
+ id: number // 宸ヤ綅涓婚敭 clinic_room.id
+ roomId: number | null
+ roomName: string | null
+ bedNo: string | null
+ ip: string | null
+ docId: number | null
+ docName: string | null
+ opType: number | null
+ checkTypes: number[] | null
+ status: number | null
+ occupied: boolean | null
+ mine: boolean | null
+}
+
+// 銆岄�夋嫨宸ヤ綅妯″紡銆�- 鎸夋湰鏈篒P鍖归厤宸ヤ綅鐨勭粨鏋�
+export interface RoomSelectBedResp {
+ clientIp: string | null // 鍚庣瀹為檯璇嗗埆鍒扮殑鏉ヨIP锛堝凡瑙勮寖鍖栵級
+ ipValid: boolean | null // 璇P鏄惁鍙敤浜庣粦瀹�
+ ipLoopback: boolean | null // 璇P鏄惁鏄湰鏈哄洖鐜紙127.x / ::1锛夆啋 璇存槑娴忚鍣ㄤ笌鏈嶅姟鍦ㄥ悓涓�鍙版満鍣�
+ ipv6: boolean | null // 璇P鏄惁鏄� IPv6锛堟湰绯荤粺宸ヤ綅缁戝畾浠呴噰鐢� IPv4锛�
+ ipBound: boolean | null // 璇P鏄惁宸茬粦瀹氬伐浣�
+ matched: boolean | null // 鏄惁鏈夊彲鐩存帴鍏ュ骇鐨勫伐浣�
+ beds: RoomSelectBedItem[]
+}
+
+/**
+ * 璇P鑳藉惁鐢ㄤ簬鑷姩鍖归厤/缁戝畾宸ヤ綅銆�
+ * **鏈郴缁熷伐浣嶇粦瀹氬彧閲囩敤 IPv4**锛欼Pv6锛堝惈 ::1銆乫e80::銆�2408:: 绛夛級涓�寰嬩笉鍙敤銆�
+ * 绌哄�笺��0.0.0.0銆�127.x 鍚屾牱涓嶅彲鐢紱`::ffff:32.88.65.208` 鐢卞悗绔繕鍘熸垚 IPv4 鍚庡彲鐢ㄣ��
+ */
+export const isUsableSeatIp = (ip?: string | null): boolean => {
+ const v = (ip || '').trim()
+ if (!v || v === '0.0.0.0' || v.startsWith('127.')) return false
+ if (v.includes(':')) return false // IPv6 涓嶉噰鐢�
+ if (!/^(\d{1,3}\.){3}\d{1,3}$/.test(v)) return false
+ return v.split('.').every((seg) => Number(seg) <= 255)
+}
+
+
+/**
+ * 銆屽伐浣嶅叆搴с�嶇粨鏋滐紙鑷姩鍏ュ骇 / 鏌ヨ鎴戠殑宸ヤ綅 鍏辩敤锛夈��
+ *
+ * reason 鍙栧�硷細
+ * - ip_invalid 鏈満IP涓嶅彲鐢紙鍥炵幆/IPv6/鏈寚瀹�/闈炴硶锛�
+ * - nomatch 璇P娌″尮閰嶅埌宸ヤ綅锛堝伐浣嶆病褰旾P 鎴� 宸插叧闂級
+ * - multi 璇P瀵瑰簲澶氫釜绌洪棽宸ヤ綅锛岄渶浜哄伐鐐归��
+ * - occupied 鍖归厤鍒扮殑宸ヤ綅宸茶**浠栦汉**鍗犵敤锛堜笉鎸ゆ帀锛�
+ * - error 鍏ュ骇鍐欏簱鏈敓鏁�
+ */
+export interface RoomSeatResp {
+ seated: boolean
+ reason?: string | null
+ clientIp?: string | null
+ ownerName?: string | null
+ id?: number | null
+ roomId?: number | null
+ roomName?: string | null
+ bedNo?: string | null
+ ip?: string | null
+ status?: number | null
+ docId?: number | null
+ docName?: string | null
+ checkTypes?: number[] | null
+ opType?: number | null
}
export interface MonitorInfo {
- queueNum : number
- activeQueueNum : number
+ openingBedNum : number
+ /** 鍦ㄥ骇宸ヤ綅鏁帮紙涓�浜哄宸ヤ綅鏃朵細澶т簬鍖荤敓鏁帮級 */
+ docBedNum : number
+ /** 銆愭湰闇�姹偮风粺璁℃寜浜哄悎骞躲�戝湪搴у尰鐢熸暟锛堟寜 doc_id 鍘婚噸锛� */
+ docNum : number
+ routingBedNum : number
openingFlag : number
+ checkTypeBedInfo: object
}
// 璇婂鍜岃瘖鐤楀簥 API
@@ -32,8 +107,12 @@
},
// 鏌ヨ璇婂鍜岃瘖鐤楀簥璇︽儏
- getRoomByIP: async () => {
- return await request.get({ url: `/clinic/room/get-room-by-ip`})
+ getRoomByIP: async (roomId :number) => {
+ if (roomId == null || roomId === 0) {
+ return await request.get({url: `/clinic/room/get-room-by-ip`})
+ }
+
+ return await request.get({url: `/clinic/room/get-room-by-ip?roomId=` + roomId})
},
// 鏂板璇婂鍜岃瘖鐤楀簥
@@ -89,6 +168,83 @@
// 鎵嬪姩闂瘖
closeBiz: async () => {
return await request.get({ url: `/clinic/room/close-biz` })
+ },
+
+ /**
+ * 绠$悊鍛樺己鍒舵竻绌哄伐浣嶏紙鍖荤敓涓嬬彮蹇樼搴� / 鎹汉浣跨敤鍚屼竴宸ヤ綅锛夈��
+ *
+ * 涓庡尰鐢熻嚜宸辩殑銆岀搴с�嶄笉鍚岋細杩欓噷鍙互娓�**浠讳綍浜�**鍗犵敤鐨勫伐浣嶃��
+ * 鍚庣鍙湪璇ュ伐浣嶅浜庛�屽尰鐢熷湪宀� / 鏆傚仠銆嶄笖宸茶鍗犵敤鏃舵墠鐢熸晥锛岀┖闂插伐浣嶄細鎶�"鐘舵�佷笉鍏佽"銆�
+ */
+ forceClearBed: async (params: { roomId: number | null; bedNo: string | null }) => {
+ return await request.post({ url: `/clinic/room/force-clear-bed`, params })
+ },
+
+ /** 銆岄�夋嫨宸ヤ綅妯″紡銆嶆寜鏈満IP鍖归厤宸ヤ綅锛堟ā寮� 1/3锛夛細杩斿洖鍚庣璇嗗埆鍒扮殑IP + 鍊欓�夊伐浣嶏紙宸叉帓搴忥級 */
+ getIpBed: async () => {
+ return await request.get({ url: `/clinic/room/get-ip-bed` })
+ },
+
+ /**
+ * 涓�閿嚜鍔ㄥ叆搴э紙妯″紡 1/3锛夛細鍚庣鎸夋潵璁縄P鍖归厤宸ヤ綅骞剁洿鎺ヨ惤搴с��
+ *
+ * 鐩告瘮鍘熸潵銆実etIpBed 鈫� bindIpToBed 鈫� bedDoctorOn銆嶄笁姝ユ嫾瑁咃紝杩欓噷鍙け璐ヤ竴娆″嵆鍙帓鏌ワ細
+ * 杩斿洖浣撳甫 clientIp 涓� reason锛坕p_invalid / nomatch / multi / occupied / error锛夈��
+ * 鏈嶅姟绔繚璇侊細鍛戒腑"鎴戠殑宸ヤ綅"鏃跺箓绛夋仮澶嶏紱涓嶄細閲嶅鏂板锛堜竴浜哄宸ヤ綅鐢卞墠绔垏鎹級銆�
+ */
+ autoSeat: async () => {
+ return await request.post({ url: `/clinic/room/auto-seat` })
+ },
+
+ /** 鏌ヨ褰撳墠鐧诲綍浜哄凡鍏ュ骇鐨勫伐浣嶏紙绯荤粺椤舵爮"褰撳墠宸ヤ綅"鏍囩鐢紝鍗曞�硷紱澶氬伐浣嶈鐢� getMySeats锛� */
+ getMySeat: async () => {
+ return await request.get({ url: `/clinic/room/my-seat` })
+ },
+
+ /**
+ * 銆愭湰闇�姹偮蜂竴浜哄宸ヤ綅銆戞煡璇㈠綋鍓嶇櫥褰曚汉鍗犳嵁鐨�**鍏ㄩ儴**宸ヤ綅锛堣妭鍋囨棩鍊肩彮澶氬矖浣嶏級銆�
+ * 杩斿洖鏁扮粍锛屾寜 roomId + bedNo 鍗囧簭锛涙湭鍗犲伐浣嶈繑鍥炵┖鏁扮粍銆�
+ */
+ getMySeats: async () => {
+ return await request.get({ url: `/clinic/room/my-seats` })
+ },
+
+ /**
+ * 銆愭湰闇�姹偮锋帴鐝嚜鍔╂帴绠°�戞妸璇ュ伐浣嶄粠"鍒汉鍗犵敤"鏀逛负"鎴戝崰鐢�"銆�
+ * 鍚庣锛氬璁℃棩蹇� 鈫� 寮哄埗鍘熷崰鐢ㄤ汉绂诲骇 鈫� 绔嬪嵆璁╂垜鍏ュ骇锛堝悓涓�浜嬪姟锛夈��
+ */
+ takeOverBed: async (params: { roomId: number | null; bedNo: string | null }) => {
+ return await request.post({ url: `/clinic/room/take-over-bed`, params })
+ },
+
+ /**
+ * 瀹㈡埛绔� IP 璇嗗埆璇婃柇锛氳繑鍥炲悇浠g悊澶淬�佺洿杩炲湴鍧�銆佽鑼冨寲缁撴灉銆佹槸鍚︽湇鍔″櫒鑷韩鍦板潃銆佹湇鍔″櫒缃戝崱鍒楄〃涓庣粨璁恒��
+ * 鐜板満鎺掓煡"宸ヤ綅缁戝畾鐨� IP 涓嶅"鐢紙閫夊伐浣嶉〉鐨勩�孖P 璇婃柇銆嶆寜閽級銆�
+ */
+ ipDebug: async () => {
+ return await request.get({ url: `/clinic/room/ip-debug` })
+ },
+
+ /**
+ * 宸ヤ綅鐘舵�佽瘖鏂細杩斿洖璇ュ伐浣�**搴撳唴鍘熷琛�**锛堝惈 bed_no 闀垮害/HEX銆乻tatus銆乨oc_id銆乨eleted锛変笌缁撹銆�
+ * 鐢ㄤ簬鎺掓煡"宸ヤ綅鏄庢槑绌洪棽鍗村叆搴уけ璐ワ紙鎶ョ姸鎬佸紓甯革級"銆�
+ */
+ bedState: async (params: { id?: number | null; roomId?: number | null; bedNo?: string | null }) => {
+ const query: string[] = []
+ if (params?.id != null) query.push(`id=${params.id}`)
+ if (params?.roomId != null) query.push(`roomId=${params.roomId}`)
+ if (params?.bedNo != null) query.push(`bedNo=${encodeURIComponent(params.bedNo)}`)
+ return await request.get({ url: `/clinic/room/bed-state?${query.join('&')}` })
+ },
+
+ /**
+ * 銆岄�夋嫨宸ヤ綅妯″紡銆嶆妸鏈満IP缁戝畾鍒版寚瀹氬伐浣嶏紙妯″紡 2/3锛夈��
+ * force=false 鏃惰嫢璇P宸茬粦鍦ㄥ埆鐨勫伐浣嶏紝杩斿洖 code=409 + 鍐茬獊宸ヤ綅淇℃伅锛岀敱鐣岄潰纭鍚庡啀甯� force=true 瑕嗙洊銆�
+ */
+ bindIpToBed: async (id: number, force = false) => {
+ return await request.post({
+ url: `/clinic/room/bind-ip?id=${id}&force=${force}`
+ })
}
}
--
Gitblit v1.9.3