Quellcode durchsuchen

新增:设备组管理页面
优化:鉴权接口返回

范志成 vor 4 Monaten
Ursprung
Commit
1d7e2253ec
17 geänderte Dateien mit 329 neuen und 30 gelöschten Zeilen
  1. 15 0
      smsb-modules/smsb-device/src/main/java/com/inspur/device/controller/SmsbDeviceGroupController.java
  2. 12 0
      smsb-modules/smsb-device/src/main/java/com/inspur/device/controller/SmsbDeviceGroupRelController.java
  3. 51 0
      smsb-modules/smsb-device/src/main/java/com/inspur/device/domain/vo/AgentAuthRes.java
  4. 4 0
      smsb-modules/smsb-device/src/main/java/com/inspur/device/mapper/SmsbDeviceGroupMapper.java
  5. 2 1
      smsb-modules/smsb-device/src/main/java/com/inspur/device/service/ISmsbDeviceAuthService.java
  6. 3 0
      smsb-modules/smsb-device/src/main/java/com/inspur/device/service/ISmsbDeviceGroupRelService.java
  7. 11 0
      smsb-modules/smsb-device/src/main/java/com/inspur/device/service/ISmsbDeviceGroupService.java
  8. 32 10
      smsb-modules/smsb-device/src/main/java/com/inspur/device/service/impl/SmsbDeviceAuthServiceImpl.java
  9. 5 0
      smsb-modules/smsb-device/src/main/java/com/inspur/device/service/impl/SmsbDeviceGroupRelServiceImpl.java
  10. 12 0
      smsb-modules/smsb-device/src/main/java/com/inspur/device/service/impl/SmsbDeviceGroupServiceImpl.java
  11. 10 1
      smsb-modules/smsb-device/src/main/resources/mapper/device/SmsbDeviceGroupMapper.xml
  12. 2 2
      smsb-modules/smsb-device/src/main/resources/mapper/device/SmsbDeviceGroupRelMapper.xml
  13. 2 2
      smsb-modules/smsb-source/src/main/java/com/inspur/source/controller/SmsbFrontController.java
  14. 13 0
      smsb-plus-ui/src/api/smsb/digital/deviceGroup/index.ts
  15. 2 2
      smsb-plus-ui/src/api/smsb/digital/deviceGroupRel/types.ts
  16. 144 3
      smsb-plus-ui/src/views/smsb/deviceGroup/index.vue
  17. 9 9
      smsb-plus-ui/src/views/smsb/deviceGroupRel/index.vue

+ 15 - 0
smsb-modules/smsb-device/src/main/java/com/inspur/device/controller/SmsbDeviceGroupController.java

@@ -2,6 +2,8 @@ package com.inspur.device.controller;
 
 import java.util.List;
 
+import com.inspur.device.domain.SmsbDevice;
+import com.inspur.device.domain.vo.SmsbDeviceVo;
 import lombok.RequiredArgsConstructor;
 import jakarta.servlet.http.HttpServletResponse;
 import jakarta.validation.constraints.*;
@@ -102,4 +104,17 @@ public class SmsbDeviceGroupController extends BaseController {
                           @PathVariable Long[] ids) {
         return toAjax(smsbDeviceGroupService.deleteWithValidByIds(List.of(ids), true));
     }
+
+    /**
+     * 获取设备详情
+     *
+     * @param id 主键串
+     */
+    @SaCheckPermission("digital:deviceGroup:query")
+    @Log(title = "设备组信息", businessType = BusinessType.DELETE)
+    @GetMapping("/getDevicesInfo/{id}")
+    public R<List<SmsbDeviceVo>> getDevicesInfo(@NotNull(message = "主键不能为空")
+                          @PathVariable Long id) {
+        return R.ok(smsbDeviceGroupService.selectDevicesInfo(id));
+    }
 }

+ 12 - 0
smsb-modules/smsb-device/src/main/java/com/inspur/device/controller/SmsbDeviceGroupRelController.java

@@ -114,4 +114,16 @@ public class SmsbDeviceGroupRelController extends BaseController {
                           @PathVariable Long[] ids) {
         return toAjax(smsbDeviceGroupRelService.deleteWithValidByIds(List.of(ids), true));
     }
+
+    /**
+     * 根据设备组id获取设备组内的设备
+     *
+     * @param id 设备组id
+     */
+    @SaCheckPermission("digital:deviceGroupRel:query")
+    @GetMapping("getGroupRelByGroupId/{id}")
+    public R<List<SmsbDeviceGroupRelVo>> getGroupRelByGroupId(@NotNull(message = "主键不能为空")
+                          @PathVariable Long id) {
+        return R.ok(smsbDeviceGroupRelService.getGroupRelByGroupId(id));
+    }
 }

+ 51 - 0
smsb-modules/smsb-device/src/main/java/com/inspur/device/domain/vo/AgentAuthRes.java

@@ -0,0 +1,51 @@
+package com.inspur.device.domain.vo;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * @author fan
+ */
+public class AgentAuthRes {
+
+    private Long groupId;
+
+    private List<Map<String, String>> deviceList;
+
+    public Long getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(Long groupId) {
+        this.groupId = groupId;
+    }
+
+    public List<Map<String, String>> getDeviceList() {
+        return deviceList;
+    }
+
+    public void setDeviceList(List<Map<String, String>> deviceList) {
+        this.deviceList = deviceList;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (o == null || getClass() != o.getClass()) return false;
+        AgentAuthRes that = (AgentAuthRes) o;
+        return Objects.equals(groupId, that.groupId) && Objects.equals(deviceList, that.deviceList);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(groupId, deviceList);
+    }
+
+    @Override
+    public String toString() {
+        return "AgentAuthRes{" +
+            "groupId=" + groupId +
+            ", deviceList=" + deviceList +
+            '}';
+    }
+}

+ 4 - 0
smsb-modules/smsb-device/src/main/java/com/inspur/device/mapper/SmsbDeviceGroupMapper.java

@@ -2,8 +2,11 @@ package com.inspur.device.mapper;
 
 import com.inspur.device.domain.SmsbDeviceGroup;
 import com.inspur.device.domain.vo.SmsbDeviceGroupVo;
+import com.inspur.device.domain.vo.SmsbDeviceVo;
 import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
 
+import java.util.List;
+
 /**
  * 设备组信息Mapper接口
  *
@@ -12,4 +15,5 @@ import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
  */
 public interface SmsbDeviceGroupMapper extends BaseMapperPlus<SmsbDeviceGroup, SmsbDeviceGroupVo> {
 
+    List<SmsbDeviceVo> selectDevicesInfo(Long id);
 }

+ 2 - 1
smsb-modules/smsb-device/src/main/java/com/inspur/device/service/ISmsbDeviceAuthService.java

@@ -2,6 +2,7 @@ package com.inspur.device.service;
 
 import com.inspur.device.domain.bo.HttpHeartbeatReq;
 import com.inspur.device.domain.bo.SmsbDeviceAuthBo;
+import com.inspur.device.domain.vo.AgentAuthRes;
 import com.inspur.device.domain.vo.SmsbDeviceAuthVo;
 import com.inspur.device.domain.vo.SmsbDeviceGroupRelVo;
 import org.dromara.common.core.domain.R;
@@ -83,5 +84,5 @@ public interface ISmsbDeviceAuthService {
      * @return
      */
 //    test for fan 智能体设备鉴权
-    R<List<SmsbDeviceGroupRelVo>> deviceAgentAuth(HttpHeartbeatReq requestParam);
+    R<AgentAuthRes> deviceAgentAuth(HttpHeartbeatReq requestParam);
 }

+ 3 - 0
smsb-modules/smsb-device/src/main/java/com/inspur/device/service/ISmsbDeviceGroupRelService.java

@@ -2,6 +2,7 @@ package com.inspur.device.service;
 
 import com.inspur.device.domain.vo.SmsbDeviceGroupRelVo;
 import com.inspur.device.domain.bo.SmsbDeviceGroupRelBo;
+import jakarta.validation.constraints.NotNull;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.common.mybatis.core.page.PageQuery;
 
@@ -68,4 +69,6 @@ public interface ISmsbDeviceGroupRelService {
 
     // test for fan 待删除
     List<SmsbDeviceGroupRelVo> testList(String number);
+
+    List<SmsbDeviceGroupRelVo> getGroupRelByGroupId(@NotNull(message = "主键不能为空") Long groupId);
 }

+ 11 - 0
smsb-modules/smsb-device/src/main/java/com/inspur/device/service/ISmsbDeviceGroupService.java

@@ -2,6 +2,9 @@ package com.inspur.device.service;
 
 import com.inspur.device.domain.vo.SmsbDeviceGroupVo;
 import com.inspur.device.domain.bo.SmsbDeviceGroupBo;
+import com.inspur.device.domain.vo.SmsbDeviceVo;
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotNull;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.common.mybatis.core.page.PageQuery;
 
@@ -65,4 +68,12 @@ public interface ISmsbDeviceGroupService {
      * @return 是否删除成功
      */
     Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+
+    /**
+     * 获取设备组中的设备信息
+     *
+     * @param id     设备组信息主键
+     * @return 是否删除成功
+     */
+    List<SmsbDeviceVo> selectDevicesInfo(@NotNull(message = "主键不能为空") Long id);
 }

+ 32 - 10
smsb-modules/smsb-device/src/main/java/com/inspur/device/service/impl/SmsbDeviceAuthServiceImpl.java

@@ -4,14 +4,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.inspur.device.domain.SmsbDeviceAuth;
+import com.inspur.device.domain.SmsbDeviceXfApi;
 import com.inspur.device.domain.bo.HttpHeartbeatReq;
 import com.inspur.device.domain.bo.SmsbDeviceAuthBo;
 import com.inspur.device.domain.constants.DeviceConstants;
-import com.inspur.device.domain.vo.SmsbDeviceAuthVo;
-import com.inspur.device.mapper.SmsbDeviceAuthMapper;
-import com.inspur.device.mapper.SmsbDeviceGroupRelMapper;
+import com.inspur.device.domain.vo.*;
+import com.inspur.device.mapper.*;
 import com.inspur.device.service.ISmsbDeviceAuthService;
-import com.inspur.device.domain.vo.SmsbDeviceGroupRelVo;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.dromara.common.core.domain.R;
@@ -23,9 +22,7 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.common.redis.utils.RedisUtils;
 import org.springframework.stereotype.Service;
 
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 设备鉴权Service业务层处理
@@ -40,6 +37,9 @@ public class SmsbDeviceAuthServiceImpl implements ISmsbDeviceAuthService {
 
     private final SmsbDeviceAuthMapper baseMapper;
     private final SmsbDeviceGroupRelMapper deviceGroupRelMapper;
+    private final SmsbDeviceMapper deviceMapper;
+    private final SmsbDeviceXfApiMapper xfApiMapper;
+    private final SmsbDeviceChatKeyMapper chatKeyMapper;
 
     /**
      * 查询设备鉴权
@@ -199,7 +199,7 @@ public class SmsbDeviceAuthServiceImpl implements ISmsbDeviceAuthService {
 
 //  test for fan 这里是鉴权实现
     @Override
-    public R<List<SmsbDeviceGroupRelVo>> deviceAgentAuth(HttpHeartbeatReq requestParam) {
+    public R<AgentAuthRes> deviceAgentAuth(HttpHeartbeatReq requestParam) {
         SmsbDeviceAuth insert = new SmsbDeviceAuth();
         String deviceIp = requestParam.getDeviceIp();
         insert.setDeviceIp(deviceIp);
@@ -251,9 +251,31 @@ public class SmsbDeviceAuthServiceImpl implements ISmsbDeviceAuthService {
         insert.setAuthRemark(authRemark);
         baseMapper.insert(insert);
 
+        AgentAuthRes agentAuthRes = new AgentAuthRes();
         List<SmsbDeviceGroupRelVo> groupVoList = deviceGroupRelMapper.queryGroupRelVoListByIdentifier(identifier);
-//        return R.ok(authRemark);
-        return R.ok(groupVoList);
+        if (groupVoList.isEmpty()) {
+            return R.fail("未找到设备组");
+        }
+        agentAuthRes.setGroupId(groupVoList.get(0).getDeviceGroupId());
+        ArrayList<Map<String, String>> deviceList = new ArrayList<>();
+        for (int i = 0; i < groupVoList.size(); i++) {
+            Map<String, String> device = new HashMap<>();
+            String deviceIdentifier = groupVoList.get(i).getDeviceIdentifier();
+            SmsbDeviceVo deviceVo = deviceMapper.getDeviceVoByIdentifier(deviceIdentifier);
+            device.put("deviceName", deviceVo.getName());
+            device.put("sceneName", groupVoList.get(i).getSceneName());
+            SmsbDeviceChatKeyVo chatKeyVo = chatKeyMapper.selectVoByDeviceId(deviceVo.getId());
+            device.put("apiKey", chatKeyVo.getApiKey());
+            device.put("apiUrl", chatKeyVo.getApiUrl());
+            device.put("deviceMac", deviceIdentifier);
+            SmsbDeviceXfApiVo xfApiVo = xfApiMapper.selectVoOne(new LambdaQueryWrapper<SmsbDeviceXfApi>().last("limit 1"));
+            device.put("xfAppId", xfApiVo.getAppId());
+            device.put("xfApiSecret", xfApiVo.getApiSecret());
+            device.put("xfApiKey", xfApiVo.getApiKey());
+            deviceList.add(device);
+        }
+        agentAuthRes.setDeviceList(deviceList);
+        return R.ok(agentAuthRes);
     }
 
 }

+ 5 - 0
smsb-modules/smsb-device/src/main/java/com/inspur/device/service/impl/SmsbDeviceGroupRelServiceImpl.java

@@ -134,4 +134,9 @@ public class SmsbDeviceGroupRelServiceImpl implements ISmsbDeviceGroupRelService
     public List<SmsbDeviceGroupRelVo> testList(String number) {
         return baseMapper.queryGroupRelVoListByIdentifier(number);
     }
+
+    @Override
+    public List<SmsbDeviceGroupRelVo> getGroupRelByGroupId(Long groupId) {
+        return baseMapper.queryGroupRelVoListByGoupId(groupId);
+    }
 }

+ 12 - 0
smsb-modules/smsb-device/src/main/java/com/inspur/device/service/impl/SmsbDeviceGroupServiceImpl.java

@@ -1,5 +1,6 @@
 package com.inspur.device.service.impl;
 
+import com.inspur.device.domain.vo.SmsbDeviceVo;
 import com.inspur.device.mapper.SmsbDeviceGroupMapper;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
@@ -127,4 +128,15 @@ public class SmsbDeviceGroupServiceImpl implements ISmsbDeviceGroupService {
         }
         return baseMapper.deleteByIds(ids) > 0;
     }
+
+    /**
+     * 获取设备组中的设备信息
+     *
+     * @param id     设备组id主键
+     * @return 是否删除成功
+     */
+    @Override
+    public List<SmsbDeviceVo> selectDevicesInfo(Long id) {
+        return baseMapper.selectDevicesInfo(id);
+    }
 }

+ 10 - 1
smsb-modules/smsb-device/src/main/resources/mapper/device/SmsbDeviceGroupMapper.xml

@@ -2,6 +2,15 @@
 <!DOCTYPE mapper
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.inspur.digital.mapper.SmsbDeviceGroupMapper">
+<mapper namespace="com.inspur.device.mapper.SmsbDeviceGroupMapper">
+
+    <select id="selectDevicesInfo" resultType="com.inspur.device.domain.vo.SmsbDeviceVo">
+        SELECT *
+        FROM smsb_device
+        WHERE identifier IN
+              (SELECT device_identifier
+               FROM smsb_device_group_rel
+               WHERE device_group_id = #{id})
+    </select>
 
 </mapper>

+ 2 - 2
smsb-modules/smsb-device/src/main/resources/mapper/device/SmsbDeviceGroupRelMapper.xml

@@ -2,7 +2,7 @@
 <!DOCTYPE mapper
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.inspur.digital.mapper.SmsbDeviceGroupRelMapper">
+<mapper namespace="com.inspur.device.mapper.SmsbDeviceGroupRelMapper">
 
     <select id="queryGroupRelVoListByIdentifier" resultType="com.inspur.device.domain.vo.SmsbDeviceGroupRelVo">
         SELECT *
@@ -21,4 +21,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ORDER BY scene_sort
     </select>
 
-</mapper>
+</mapper>

+ 2 - 2
smsb-modules/smsb-source/src/main/java/com/inspur/source/controller/SmsbFrontController.java

@@ -7,7 +7,7 @@ import com.inspur.device.domain.constants.DeviceTaskConstants;
 import com.inspur.device.domain.vo.*;
 import com.inspur.device.mapper.SmsbDeviceTaskMapper;
 import com.inspur.device.service.*;
-import com.inspur.device.domain.vo.SmsbDeviceGroupRelVo;
+import com.inspur.device.domain.vo.AgentAuthRes;
 import com.inspur.source.domain.vo.FrontItemSourceVO;
 import com.inspur.source.domain.vo.FrontPushInfoVo;
 import com.inspur.source.service.ISmsbItemPushDeviceService;
@@ -151,7 +151,7 @@ public class SmsbFrontController {
     @PostMapping("/agentAuth")
 ////    这里返回设备组mac list(8位 第一位错误码标识,后面是mac地址)
 ////    test for fan 这里我需要有个表维护设备组信息 结构:设备组id,设备组名称,设备组描述
-    public R<List<SmsbDeviceGroupRelVo>> deviceAgentAuth(@RequestBody HttpHeartbeatReq requestParam) {
+    public R<AgentAuthRes> deviceAgentAuth(@RequestBody HttpHeartbeatReq requestParam) {
         return smsbDeviceAuthService.deviceAgentAuth(requestParam);
     }
 

+ 13 - 0
smsb-plus-ui/src/api/smsb/digital/deviceGroup/index.ts

@@ -1,6 +1,8 @@
 import request from '@/utils/request';
 import { AxiosPromise } from 'axios';
 import { DeviceGroupVO, DeviceGroupForm, DeviceGroupQuery } from '@/api/smsb/digital/deviceGroup/types';
+import {DeviceVO} from "@/api/smsb/device/device_type";
+import {DeviceGroupRelVO} from "@/api/smsb/digital/deviceGroupRel/types";
 
 /**
  * 查询设备组信息列表
@@ -16,6 +18,17 @@ export const listDeviceGroup = (query?: DeviceGroupQuery): AxiosPromise<DeviceGr
   });
 };
 
+/**
+ * 查询设备详情
+ * @param id
+ */
+export const getDevicesInfo = (id: string | number): AxiosPromise<DeviceGroupRelVO[]> => {
+  return request({
+    url: '/digital/deviceGroupRel/getGroupRelByGroupId/' + id,
+    method: 'get'
+  });
+};
+
 /**
  * 查询设备组信息详细
  * @param id

+ 2 - 2
smsb-plus-ui/src/api/smsb/digital/deviceGroupRel/types.ts

@@ -12,7 +12,7 @@ export interface DeviceGroupRelVO {
   deviceGroupId: string | number;
 
   /**
-   * 设备id
+   * 设备标识
 
    */
   deviceIdentifier: string | number;
@@ -51,7 +51,7 @@ export interface DeviceGroupRelForm extends BaseEntity {
   deviceGroupId?: string | number;
 
   /**
-   * 设备id
+   * 设备标识
 
    */
   deviceIdentifier?: string | number;

+ 144 - 3
smsb-plus-ui/src/views/smsb/deviceGroup/index.vue

@@ -49,6 +49,9 @@
             <el-tooltip content="修改" placement="top">
               <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['digital:deviceGroup:edit']"></el-button>
             </el-tooltip>
+            <el-tooltip content="详情" placement="top">
+              <el-button link type="primary" icon="View" @click="handleDevicesInfo(scope.row)" v-hasPermi="['digital:deviceGroup:query']"></el-button>
+            </el-tooltip>
             <el-tooltip content="删除" placement="top">
               <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['digital:deviceGroup:remove']"></el-button>
             </el-tooltip>
@@ -78,16 +81,74 @@
         </div>
       </template>
     </el-dialog>
+    <!-- 查看设备组内的设备详情 -->
+    <el-dialog :title="devicesLog.title" v-model="devicesLog.visible" width="800px" append-to-body>
+      <el-table v-loading="loading" :data="deviceList" @selection-change="handleDevicesSelectionChange">
+        <el-table-column type="selection" width="55" align="center" />
+        <el-table-column label="设备标识" align="center" prop="deviceIdentifier" />
+        <el-table-column label="场景名称" align="center" prop="sceneName" />
+        <el-table-column label="备注" align="center" prop="remark" />
+        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+          <template #default="scope">
+            <el-tooltip content="修改" placement="top">
+              <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['digital:deviceGroup:edit']"></el-button>
+            </el-tooltip>
+            <el-tooltip content="删除" placement="top">
+              <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['digital:deviceGroup:remove']"></el-button>
+            </el-tooltip>
+          </template>
+        </el-table-column>
+      </el-table>
+
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button @click="cancel">新 增</el-button>
+          <el-button @click="cancel">取 消</el-button>
+        </div>
+      </template>
+    </el-dialog>
+
+    <el-dialog :title="addDeviceLog.title" v-model="addDeviceLog.visible" width="500px" append-to-body>
+      <el-form ref="deviceGroupRelFormRef" :model="form" :rules="rules" label-width="80px">
+        <el-form-item label="设备组id" prop="deviceGroupId">
+          <el-input v-model="form.name" placeholder="请输入设备组id" />
+        </el-form-item>
+        <el-form-item label="设备标识" prop="deviceIdentifier">
+          <el-input v-model="form.capacity" placeholder="请输入设备标识" />
+        </el-form-item>
+        <el-form-item label="场景名称" prop="sceneName">
+          <el-input v-model="form.sceneName" placeholder="请输入场景名称" />
+        </el-form-item>
+        <el-form-item label="备注" prop="remark">
+          <el-input v-model="form.remark" placeholder="请输入备注" />
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
+          <el-button @click="cancel">取 消</el-button>
+        </div>
+      </template>
+    </el-dialog>
   </div>
 </template>
 
 <script setup name="DeviceGroup" lang="ts">
-import { listDeviceGroup, getDeviceGroup, delDeviceGroup, addDeviceGroup, updateDeviceGroup } from '@/api/digital/deviceGroup';
-import { DeviceGroupVO, DeviceGroupQuery, DeviceGroupForm } from '@/api/digital/deviceGroup/types';
+import {
+  listDeviceGroup,
+  getDeviceGroup,
+  delDeviceGroup,
+  addDeviceGroup,
+  updateDeviceGroup,
+  getDevicesInfo
+} from '@/api/smsb/digital/deviceGroup';
+import { DeviceGroupVO, DeviceGroupQuery, DeviceGroupForm } from '@/api/smsb/digital/deviceGroup/types';
+import { DeviceGroupRelVO, DeviceGroupRelForm, DeviceGroupRelQuery } from '@/api/smsb/digital/deviceGroupRel/types';
 
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 
 const deviceGroupList = ref<DeviceGroupVO[]>([]);
+const deviceList = ref<DeviceGroupRelVO[]>([]);
 const buttonLoading = ref(false);
 const loading = ref(true);
 const showSearch = ref(true);
@@ -98,12 +159,23 @@ const total = ref(0);
 
 const queryFormRef = ref<ElFormInstance>();
 const deviceGroupFormRef = ref<ElFormInstance>();
+const deviceGroupRelFormRef = ref<ElFormInstance>();
 
 const dialog = reactive<DialogOption>({
   visible: false,
   title: ''
 });
 
+const devicesLog = reactive<DialogOption>({
+  visible: false,
+  title: ''
+});
+
+const addDeviceLog = reactive<DialogOption>({
+  visible: false,
+  title: ''
+});
+
 const initFormData: DeviceGroupForm = {
   id: undefined,
   name: undefined,
@@ -131,7 +203,49 @@ const data = reactive<PageData<DeviceGroupForm, DeviceGroupQuery>>({
       { required: true, message: "设备组容量不能为空", trigger: "blur" }
     ],
     remark: [
-      { required: true, message: "备注不能为空", trigger: "blur" }
+      { required: false, message: "备注不能为空", trigger: "blur" }
+    ],
+  }
+});
+
+const initFormDataRel: DeviceGroupRelForm = {
+  id: undefined,
+  deviceGroupId: undefined,
+  deviceIdentifier: undefined,
+  sceneSort: undefined,
+  sceneName: undefined,
+  remark: undefined,
+}
+const dataRel = reactive<PageData<DeviceGroupRelForm, DeviceGroupRelQuery>>({
+  form: {...initFormDataRel},
+  queryParams: {
+    pageNum: 1,
+    pageSize: 10,
+    deviceGroupId: undefined,
+    deviceIdentifier: undefined,
+    sceneSort: undefined,
+    sceneName: undefined,
+    params: {
+    }
+  },
+  rules: {
+    id: [
+      {required: true, message: "对应表id不能为空", trigger: "blur"}
+    ],
+    deviceGroupId: [
+      {required: true, message: "设备组id不能为空", trigger: "blur"}
+    ],
+    deviceIdentifier: [
+      {required: true, message: "设备标识不能为空", trigger: "blur"}
+    ],
+    sceneSort: [
+      {required: true, message: "场景序号不能为空", trigger: "blur"}
+    ],
+    sceneName: [
+      {required: true, message: "场景名称不能为空", trigger: "blur"}
+    ],
+    remark: [
+      {required: true, message: "备注不能为空", trigger: "blur"}
     ],
   }
 });
@@ -147,10 +261,30 @@ const getList = async () => {
   loading.value = false;
 }
 
+/** 设备组详情 */
+const handleDevicesInfo = async (row?: DeviceGroupVO) => {
+  loading.value = true;
+  const _id = row?.id || ids.value[0]
+  const res = await getDevicesInfo(_id);
+  deviceList.value = res.data;
+  devicesLog.visible = true;
+  devicesLog.title = "设备组详情";
+  loading.value = false;
+}
+
+/** 新增按钮操作 */
+const handleAddDevice = () => {
+  reset();
+  addDeviceLog.visible = true;
+  addDeviceLog.title = "添加设备";
+}
+
 /** 取消按钮 */
 const cancel = () => {
   reset();
   dialog.visible = false;
+  devicesLog.visible = false;
+  addDeviceLog.visible = false;
 }
 
 /** 表单重置 */
@@ -178,6 +312,13 @@ const handleSelectionChange = (selection: DeviceGroupVO[]) => {
   multiple.value = !selection.length;
 }
 
+/** 多选框选中数据 */
+const handleDevicesSelectionChange = (selection: DeviceGroupRelVO[]) => {
+  ids.value = selection.map(item => item.id);
+  single.value = selection.length != 1;
+  multiple.value = !selection.length;
+}
+
 /** 新增按钮操作 */
 const handleAdd = () => {
   reset();

+ 9 - 9
smsb-plus-ui/src/views/smsb/deviceGroupRel/index.vue

@@ -10,8 +10,8 @@
 " clearable @keyup.enter="handleQuery" />
             </el-form-item>
             <el-form-item label="设备id
-" prop="deviceId">
-              <el-input v-model="queryParams.deviceId" placeholder="请输入设备id
+" prop="deviceIdentifier">
+              <el-input v-model="queryParams.deviceIdentifier" placeholder="请输入设备id
 " clearable @keyup.enter="handleQuery" />
             </el-form-item>
             <el-form-item label="场景序号
@@ -90,7 +90,7 @@
         </el-form-item>
         <el-form-item label="设备id
 " prop="deviceId">
-          <el-input v-model="form.deviceId" placeholder="请输入设备id
+          <el-input v-model="form.deviceIdentifier" placeholder="请输入设备id
 " />
         </el-form-item>
         <el-form-item label="场景序号
@@ -120,8 +120,8 @@
 </template>
 
 <script setup name="DeviceGroupRel" lang="ts">
-import { listDeviceGroupRel, getDeviceGroupRel, delDeviceGroupRel, addDeviceGroupRel, updateDeviceGroupRel } from '@/api/digital/deviceGroupRel';
-import { DeviceGroupRelVO, DeviceGroupRelQuery, DeviceGroupRelForm } from '@/api/digital/deviceGroupRel/types';
+import { listDeviceGroupRel, getDeviceGroupRel, delDeviceGroupRel, addDeviceGroupRel, updateDeviceGroupRel } from '@/api/smsb/digital/deviceGroupRel';
+import { DeviceGroupRelVO, DeviceGroupRelQuery, DeviceGroupRelForm } from '@/api/smsb/digital/deviceGroupRel/types';
 
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 
@@ -145,7 +145,7 @@ const dialog = reactive<DialogOption>({
 const initFormData: DeviceGroupRelForm = {
   id: undefined,
   deviceGroupId: undefined,
-  deviceId: undefined,
+  deviceIdentifier: undefined,
   sceneSort: undefined,
   sceneName: undefined,
   remark: undefined,
@@ -156,7 +156,7 @@ const data = reactive<PageData<DeviceGroupRelForm, DeviceGroupRelQuery>>({
     pageNum: 1,
     pageSize: 10,
     deviceGroupId: undefined,
-    deviceId: undefined,
+    deviceIdentifier: undefined,
     sceneSort: undefined,
     sceneName: undefined,
     params: {
@@ -169,8 +169,8 @@ const data = reactive<PageData<DeviceGroupRelForm, DeviceGroupRelQuery>>({
     deviceGroupId: [
       { required: true, message: "设备组id不能为空", trigger: "blur" }
     ],
-    deviceId: [
-      { required: true, message: "设备id不能为空", trigger: "blur" }
+    deviceIdentifier: [
+      { required: true, message: "设备标识不能为空", trigger: "blur" }
     ],
     sceneSort: [
       { required: true, message: "场景序号不能为空", trigger: "blur" }