From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目

---
 src/api/iot/device/device/index.ts |  165 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 165 insertions(+), 0 deletions(-)

diff --git a/src/api/iot/device/device/index.ts b/src/api/iot/device/device/index.ts
new file mode 100644
index 0000000..2311a9a
--- /dev/null
+++ b/src/api/iot/device/device/index.ts
@@ -0,0 +1,165 @@
+import request from '@/config/axios'
+
+// IoT 璁惧 VO
+export interface DeviceVO {
+  id: number // 璁惧 ID锛屼富閿紝鑷
+  deviceName: string // 璁惧鍚嶇О
+  productId: number // 浜у搧缂栧彿
+  productKey: string // 浜у搧鏍囪瘑
+  deviceType: number // 璁惧绫诲瀷
+  nickname: string // 璁惧澶囨敞鍚嶇О
+  gatewayId: number // 缃戝叧璁惧 ID
+  state: number // 璁惧鐘舵��
+  onlineTime: Date // 鏈�鍚庝笂绾挎椂闂�
+  offlineTime: Date // 鏈�鍚庣绾挎椂闂�
+  activeTime: Date // 璁惧婵�娲绘椂闂�
+  createTime: Date // 鍒涘缓鏃堕棿
+  ip: string // 璁惧鐨� IP 鍦板潃
+  firmwareVersion: string // 璁惧鐨勫浐浠剁増鏈�
+  deviceSecret: string // 璁惧瀵嗛挜锛岀敤浜庤澶囪璇侊紝闇�瀹夊叏瀛樺偍
+  mqttClientId: string // MQTT 瀹㈡埛绔� ID
+  mqttUsername: string // MQTT 鐢ㄦ埛鍚�
+  mqttPassword: string // MQTT 瀵嗙爜
+  authType: string // 璁よ瘉绫诲瀷
+  locationType: number // 瀹氫綅绫诲瀷
+  latitude?: number // 璁惧浣嶇疆鐨勭含搴�
+  longitude?: number // 璁惧浣嶇疆鐨勭粡搴�
+  areaId: number // 鍦板尯缂栫爜
+  address: string // 璁惧璇︾粏鍦板潃
+  serialNumber: string // 璁惧搴忓垪鍙�
+  config: string // 璁惧閰嶇疆
+  groupIds?: number[] // 娣诲姞鍒嗙粍 ID
+}
+
+// IoT 璁惧灞炴�ц缁� VO
+export interface IotDevicePropertyDetailRespVO {
+  identifier: string // 灞炴�ф爣璇嗙
+  value: string // 鏈�鏂板��
+  updateTime: Date // 鏇存柊鏃堕棿
+  name: string // 灞炴�у悕绉�
+  dataType: string // 鏁版嵁绫诲瀷
+  dataSpecs: any // 鏁版嵁瀹氫箟
+  dataSpecsList: any[] // 鏁版嵁瀹氫箟鍒楄〃
+}
+
+// IoT 璁惧灞炴�� VO
+export interface IotDevicePropertyRespVO {
+  identifier: string // 灞炴�ф爣璇嗙
+  value: string // 鏈�鏂板��
+  updateTime: Date // 鏇存柊鏃堕棿
+}
+
+// TODO @鑺嬭壙锛氳皟鏁村埌 constants
+// IoT 璁惧鐘舵�佹灇涓�
+export enum DeviceStateEnum {
+  INACTIVE = 0, // 鏈縺娲�
+  ONLINE = 1, // 鍦ㄧ嚎
+  OFFLINE = 2 // 绂荤嚎
+}
+
+// 璁惧璁よ瘉鍙傛暟 VO
+export interface IotDeviceAuthInfoVO {
+  clientId: string // 瀹㈡埛绔� ID
+  username: string // 鐢ㄦ埛鍚�
+  password: string // 瀵嗙爜
+}
+
+// IoT 璁惧鍙戦�佹秷鎭� Request VO
+export interface IotDeviceMessageSendReqVO {
+  deviceId: number // 璁惧缂栧彿
+  method: string // 璇锋眰鏂规硶
+  params?: any // 璇锋眰鍙傛暟
+}
+
+// 璁惧 API
+export const DeviceApi = {
+  // 鏌ヨ璁惧鍒嗛〉
+  getDevicePage: async (params: any) => {
+    return await request.get({ url: `/iot/device/page`, params })
+  },
+
+  // 鏌ヨ璁惧璇︽儏
+  getDevice: async (id: number) => {
+    return await request.get({ url: `/iot/device/get?id=` + id })
+  },
+
+  // 鏂板璁惧
+  createDevice: async (data: DeviceVO) => {
+    return await request.post({ url: `/iot/device/create`, data })
+  },
+
+  // 淇敼璁惧
+  updateDevice: async (data: DeviceVO) => {
+    return await request.put({ url: `/iot/device/update`, data })
+  },
+
+  // 淇敼璁惧鍒嗙粍
+  updateDeviceGroup: async (data: { ids: number[]; groupIds: number[] }) => {
+    return await request.put({ url: `/iot/device/update-group`, data })
+  },
+
+  // 鍒犻櫎鍗曚釜璁惧
+  deleteDevice: async (id: number) => {
+    return await request.delete({ url: `/iot/device/delete?id=` + id })
+  },
+
+  // 鍒犻櫎澶氫釜璁惧
+  deleteDeviceList: async (ids: number[]) => {
+    return await request.delete({ url: `/iot/device/delete-list`, params: { ids: ids.join(',') } })
+  },
+
+  // 瀵煎嚭璁惧
+  exportDeviceExcel: async (params: any) => {
+    return await request.download({ url: `/iot/device/export-excel`, params })
+  },
+
+  // 鑾峰彇璁惧鏁伴噺
+  getDeviceCount: async (productId: number) => {
+    return await request.get({ url: `/iot/device/count?productId=` + productId })
+  },
+
+  // 鑾峰彇璁惧鐨勭簿绠�淇℃伅鍒楄〃
+  getSimpleDeviceList: async (deviceType?: number, productId?: number) => {
+    return await request.get({ url: `/iot/device/simple-list?`, params: { deviceType, productId } })
+  },
+
+  // 鏍规嵁浜у搧缂栧彿锛岃幏鍙栬澶囩殑绮剧畝淇℃伅鍒楄〃
+  getDeviceListByProductId: async (productId: number) => {
+    return await request.get({ url: `/iot/device/simple-list?`, params: { productId } })
+  },
+
+  // 鑾峰彇瀵煎叆妯℃澘
+  importDeviceTemplate: async () => {
+    return await request.download({ url: `/iot/device/get-import-template` })
+  },
+
+  // 鑾峰彇璁惧灞炴�ф渶鏂版暟鎹�
+  getLatestDeviceProperties: async (params: any) => {
+    return await request.get({ url: `/iot/device/property/get-latest`, params })
+  },
+
+  // 鑾峰彇璁惧灞炴�у巻鍙叉暟鎹�
+  getHistoryDevicePropertyList: async (params: any) => {
+    return await request.get({ url: `/iot/device/property/history-list`, params })
+  },
+
+  // 鑾峰彇璁惧璁よ瘉淇℃伅
+  getDeviceAuthInfo: async (id: number) => {
+    return await request.get({ url: `/iot/device/get-auth-info`, params: { id } })
+  },
+
+  // 鏌ヨ璁惧娑堟伅鍒嗛〉
+  getDeviceMessagePage: async (params: any) => {
+    return await request.get({ url: `/iot/device/message/page`, params })
+  },
+
+  // 鏌ヨ璁惧娑堟伅閰嶅鍒嗛〉
+  getDeviceMessagePairPage: async (params: any) => {
+    return await request.get({ url: `/iot/device/message/pair-page`, params })
+  },
+
+  // 鍙戦�佽澶囨秷鎭�
+  sendDeviceMessage: async (params: IotDeviceMessageSendReqVO) => {
+    return await request.post({ url: `/iot/device/message/send`, data: params })
+  }
+}

--
Gitblit v1.8.0