From 2fedf94894787a55d01d37cb7e3d999b0f05a8c9 Mon Sep 17 00:00:00 2001 From: chenshuichuan <1154693969@qq.com> Date: Sat, 10 Aug 2024 22:18:19 +0800 Subject: [PATCH] fix device and alert --- src/api/iot/alert/index.ts | 76 +++++ src/api/iot/alertrecord/index.ts | 57 ++++ src/api/iot/device/index.ts | 45 +-- src/utils/dict.ts | 2 + src/views/iot/alert/AlertForm.vue | 171 +++++++++++ .../iot/alert/components/AlertRecordForm.vue | 196 ++++++++++++ .../iot/alert/components/AlertRecordList.vue | 160 ++++++++++ src/views/iot/alert/index.vue | 255 ++++++++++++++++ src/views/iot/alertrecord/AlertRecordForm.vue | 201 ++++++++++++ src/views/iot/alertrecord/index.vue | 287 ++++++++++++++++++ src/views/iot/device/DeviceForm.vue | 249 +++------------ .../device/components/DeviceAttributeForm.vue | 221 ++++---------- .../device/components/DeviceAttributeList.vue | 43 ++- src/views/iot/device/index.vue | 153 +++------- 14 files changed, 1568 insertions(+), 548 deletions(-) create mode 100644 src/api/iot/alert/index.ts create mode 100644 src/api/iot/alertrecord/index.ts create mode 100644 src/views/iot/alert/AlertForm.vue create mode 100644 src/views/iot/alert/components/AlertRecordForm.vue create mode 100644 src/views/iot/alert/components/AlertRecordList.vue create mode 100644 src/views/iot/alert/index.vue create mode 100644 src/views/iot/alertrecord/AlertRecordForm.vue create mode 100644 src/views/iot/alertrecord/index.vue diff --git a/src/api/iot/alert/index.ts b/src/api/iot/alert/index.ts new file mode 100644 index 00000000..9995b943 --- /dev/null +++ b/src/api/iot/alert/index.ts @@ -0,0 +1,76 @@ +import request from '@/config/axios' + +// 告警配置 VO +export interface AlertVO { + id: number // ID + alertCode: string // 编码 + alertName: string // 名称 + alertType: string // 告警类型 + alertLevel: string // 告警等级 + content: string // 告警内容 + condition: string // 告警条件 + conditionFormula: string // 逻辑表达式 + alertAudio: string // 告警音频 + isRepeat: boolean // 重复告警 + noRepeatDuration: number // 不重复间隔 + isEnable: boolean // 是否启用 +} + +// 告警配置 API +export const AlertApi = { + // 查询告警配置分页 + getAlertPage: async (params: any) => { + return await request.get({ url: `/iot/alert/page`, params }) + }, + + // 查询告警配置详情 + getAlert: async (id: number) => { + return await request.get({ url: `/iot/alert/get?id=` + id }) + }, + + // 新增告警配置 + createAlert: async (data: AlertVO) => { + return await request.post({ url: `/iot/alert/create`, data }) + }, + + // 修改告警配置 + updateAlert: async (data: AlertVO) => { + return await request.put({ url: `/iot/alert/update`, data }) + }, + + // 删除告警配置 + deleteAlert: async (id: number) => { + return await request.delete({ url: `/iot/alert/delete?id=` + id }) + }, + + // 导出告警配置 Excel + exportAlert: async (params) => { + return await request.download({ url: `/iot/alert/export-excel`, params }) + }, + +// ==================== 子表(告警记录) ==================== + + // 获得告警记录分页 + getAlertRecordPage: async (params) => { + return await request.get({ url: `/iot/alert/alert-record/page`, params }) + }, + // 新增告警记录 + createAlertRecord: async (data) => { + return await request.post({ url: `/iot/alert/alert-record/create`, data }) + }, + + // 修改告警记录 + updateAlertRecord: async (data) => { + return await request.put({ url: `/iot/alert/alert-record/update`, data }) + }, + + // 删除告警记录 + deleteAlertRecord: async (id: number) => { + return await request.delete({ url: `/iot/alert/alert-record/delete?id=` + id }) + }, + + // 获得告警记录 + getAlertRecord: async (id: number) => { + return await request.get({ url: `/iot/alert/alert-record/get?id=` + id }) + } +} \ No newline at end of file diff --git a/src/api/iot/alertrecord/index.ts b/src/api/iot/alertrecord/index.ts new file mode 100644 index 00000000..cd8559f8 --- /dev/null +++ b/src/api/iot/alertrecord/index.ts @@ -0,0 +1,57 @@ +import request from '@/config/axios' + +// 告警记录 VO +export interface AlertRecordVO { + id: number // ID + alertCode: string // 编码 + alertName: string // 名称 + alertType: string // 告警类型 + alertLevel: string // 告警等级 + content: string // 告警内容 + condition: string // 告警条件 + conditionFormula: string // 逻辑表达式 + dataValue: string // 数据值 + dataType: string // 数据类型 + dataUnit: string // 单位 + dataTypeRemark: string // 描述 + alertId: number // 告警ID + alertAudio: string // 告警音频 + isRepeat: boolean // 重复告警 + noRepeatDuration: number // 不重复间隔 + dataId: number // 来源ID + dataCode: string // 来源编码 + dataName: string // 来源名称 +} + +// 告警记录 API +export const AlertRecordApi = { + // 查询告警记录分页 + getAlertRecordPage: async (params: any) => { + return await request.get({ url: `/iot/alert-record/page`, params }) + }, + + // 查询告警记录详情 + getAlertRecord: async (id: number) => { + return await request.get({ url: `/iot/alert-record/get?id=` + id }) + }, + + // 新增告警记录 + createAlertRecord: async (data: AlertRecordVO) => { + return await request.post({ url: `/iot/alert-record/create`, data }) + }, + + // 修改告警记录 + updateAlertRecord: async (data: AlertRecordVO) => { + return await request.put({ url: `/iot/alert-record/update`, data }) + }, + + // 删除告警记录 + deleteAlertRecord: async (id: number) => { + return await request.delete({ url: `/iot/alert-record/delete?id=` + id }) + }, + + // 导出告警记录 Excel + exportAlertRecord: async (params) => { + return await request.download({ url: `/iot/alert-record/export-excel`, params }) + } +} \ No newline at end of file diff --git a/src/api/iot/device/index.ts b/src/api/iot/device/index.ts index 343e1b9a..2993c2df 100644 --- a/src/api/iot/device/index.ts +++ b/src/api/iot/device/index.ts @@ -3,42 +3,18 @@ import request from '@/config/axios' // 物联设备 VO export interface DeviceVO { id: number // ID - deviceConfigId: string // 设备配置id deviceCode: string // 设备编号 deviceName: string // 设备名称 deviceType: string // 设备类型 - siemensSeries: string // Siemens系列(S7-300、S7-1500) - siemensConnectParam: string // 连接参数(波特率,数据位,停止位,校验位 例如:9600,8,1,N) - readCronType: string // 读取任务方式(0无,1有) - readRepeatValue: number // 读取任务时间间隔 - readRepeatUnit: string // 读取任务时间间隔单位 - readCron: string // 读取任务时间表达式 - writeCronType: string // 写入任务时间间隔 - writeRepeatValue: number // 写入任务时间间隔 - writeRepeatUnit: string // 写入任务时间间隔单位 - writeCron: string // 写入任务时间表达式 - localPersistent: string // 是否持久化(0不持久化,1持久化) - uploadRate: string // 上传方式(1实时,2自定义) - rateCount: number // 上传频率 - modbusProtocol: string // modbus协议类型(serial-rtu) - modbusPattern: string // modbus模式(client) - portName: string // modbus串口号 - modbusConnectParam: string // 连接参数(波特率,数据位,停止位,校验位 例如:9600,8,1,N) - modbusReadAddrGap: string // 读地址是否连续(0否,1是) - isUpload: string // 是否已下发(0下,1没下) + status: string // 状态 + readTopic: string // 读主题 + writeTopic: string // 写主题 gatewayId: number // 网关id - orgId: number // 组织设备id + deviceBrandId: number // 设备品牌id + offLineDuration: number // 离线间隔 + lastOnlineTime: Date // 最后上线时间 remark: string // 备注 isEnable: boolean // 是否启用 - - deviceUseType: string // 数采设备类型 - apIp: string // ap_ip - gateBridgeIp: string // 网桥ip - comServerIp: string // 串口服务器IP - comServerPort: string // 串口服务器端口 - plcControllerIp: string // PLC控制器地址 - plcScreenIp: string // PLC触控屏地址 - orgMachineId: number // i机台id } // 物联设备 API @@ -72,10 +48,7 @@ export const DeviceApi = { exportDevice: async (params) => { return await request.download({ url: `/iot/device/export-excel`, params }) }, - // 物联设备配置下发 - pushDevice: async (id: number) => { - return await request.get({ url: `/iot/device/pushDevice?id=` + id }) - }, + // ==================== 子表(设备属性) ==================== // 获得设备属性分页 @@ -100,5 +73,5 @@ export const DeviceApi = { // 获得设备属性 getDeviceAttribute: async (id: number) => { return await request.get({ url: `/iot/device/device-attribute/get?id=` + id }) - }, -} + } +} \ No newline at end of file diff --git a/src/utils/dict.ts b/src/utils/dict.ts index 6d63f004..7a3f2e2f 100644 --- a/src/utils/dict.ts +++ b/src/utils/dict.ts @@ -272,4 +272,6 @@ export enum DICT_TYPE { IOT_DEVICE_DATA_TYPE = "iot_device_data_type", IOT_PROXY_SERVER_STATUS = "iot_proxy_server_status", IOT_DEVICE_USE_TYPE = "iot_device_use_type", + + IOT_ALERT_TYPE = "iot_alert_type", } diff --git a/src/views/iot/alert/AlertForm.vue b/src/views/iot/alert/AlertForm.vue new file mode 100644 index 00000000..e04f3560 --- /dev/null +++ b/src/views/iot/alert/AlertForm.vue @@ -0,0 +1,171 @@ + + \ No newline at end of file diff --git a/src/views/iot/alert/components/AlertRecordForm.vue b/src/views/iot/alert/components/AlertRecordForm.vue new file mode 100644 index 00000000..4ebcb72a --- /dev/null +++ b/src/views/iot/alert/components/AlertRecordForm.vue @@ -0,0 +1,196 @@ + + \ No newline at end of file diff --git a/src/views/iot/alert/components/AlertRecordList.vue b/src/views/iot/alert/components/AlertRecordList.vue new file mode 100644 index 00000000..4a42e4fa --- /dev/null +++ b/src/views/iot/alert/components/AlertRecordList.vue @@ -0,0 +1,160 @@ + + diff --git a/src/views/iot/alert/index.vue b/src/views/iot/alert/index.vue new file mode 100644 index 00000000..2ec44baa --- /dev/null +++ b/src/views/iot/alert/index.vue @@ -0,0 +1,255 @@ + + + diff --git a/src/views/iot/alertrecord/AlertRecordForm.vue b/src/views/iot/alertrecord/AlertRecordForm.vue new file mode 100644 index 00000000..d2da6d22 --- /dev/null +++ b/src/views/iot/alertrecord/AlertRecordForm.vue @@ -0,0 +1,201 @@ + + \ No newline at end of file diff --git a/src/views/iot/alertrecord/index.vue b/src/views/iot/alertrecord/index.vue new file mode 100644 index 00000000..b6e1a28c --- /dev/null +++ b/src/views/iot/alertrecord/index.vue @@ -0,0 +1,287 @@ + + + diff --git a/src/views/iot/device/DeviceForm.vue b/src/views/iot/device/DeviceForm.vue index e310cdd2..9f9d84d2 100644 --- a/src/views/iot/device/DeviceForm.vue +++ b/src/views/iot/device/DeviceForm.vue @@ -7,9 +7,6 @@ label-width="100px" v-loading="formLoading" > - - - @@ -17,20 +14,19 @@ - - + - {{ dict.label }} - - + :label="dict.label" + :value="dict.value" + /> + - - + + @@ -38,160 +34,22 @@ - - - - - - - - - - - - - {{ dict.label }} - - + + - - + + - - + + - - - - - - - {{ dict.label }} - - - - - - - - - - {{ dict.label }} - - - - - - - {{ dict.label }} - - - - - - - - - - {{ dict.label }} - - - - - - - {{ dict.label }} - - - - - - - {{ dict.label }} - - - - - - - - - - {{ dict.label }} - - + + + + + - - - - - - - - - - {{ dict.label }} - - - - - - - - - - - - - - - - - - - - - - - - @@ -214,7 +72,7 @@ + \ No newline at end of file diff --git a/src/views/iot/device/components/DeviceAttributeList.vue b/src/views/iot/device/components/DeviceAttributeList.vue index 971452e9..8b1e23ea 100644 --- a/src/views/iot/device/components/DeviceAttributeList.vue +++ b/src/views/iot/device/components/DeviceAttributeList.vue @@ -10,41 +10,31 @@ 新增 - - - - + + + - + - + - - - - - - - - - - - + - - - + + + + - + @@ -54,9 +44,10 @@ align="center" prop="createTime" :formatter="dateFormatter" - width="180px" + width="170px" + fixed="right" /> - +