From 1446994d504819c367e1ff667360eadb314f9ac6 Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期日, 18 十月 2026 16:52:18 +0800
Subject: [PATCH] 修改了诊室工号

---
 src/api/ecg/room/index.ts |  122 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 121 insertions(+), 1 deletions(-)

diff --git a/src/api/ecg/room/index.ts b/src/api/ecg/room/index.ts
index d78f8a1..af99804 100644
--- a/src/api/ecg/room/index.ts
+++ b/src/api/ecg/room/index.ts
@@ -6,12 +6,81 @@
   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[] | 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 {
@@ -96,6 +165,57 @@
   // 鎵嬪姩闂瘖
   closeBiz: async () => {
     return await request.get({ url: `/clinic/room/close-biz` })
+  },
+
+  /** 銆岄�夋嫨宸ヤ綅妯″紡銆嶆寜鏈満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` })
+  },
+
+  /** 鏌ヨ褰撳墠鐧诲綍浜哄凡鍏ュ骇鐨勫伐浣嶏紙绯荤粺椤舵爮"褰撳墠宸ヤ綅"鏍囩鐢級 */
+  getMySeat: async () => {
+    return await request.get({ url: `/clinic/room/my-seat` })
+  },
+
+  /**
+   * 瀹㈡埛绔� 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