From 97aed6e19bac0fefaaf0270ba94492228ebf0bb1 Mon Sep 17 00:00:00 2001
From: zhaowenyu <35589726@qq.com>
Date: Wed, 03 Dec 2025 18:43:59 +0800
Subject: [PATCH] 2025-12-03 zwy 删除任务失败时返回错误码,不返回异常。

---
 ard-admin/src/main/java/com/ard/web/controller/sample/DeviceController.java |   81 +++++++++++++++++++++++++++++++++++++---
 1 files changed, 75 insertions(+), 6 deletions(-)

diff --git a/ard-admin/src/main/java/com/ard/web/controller/sample/DeviceController.java b/ard-admin/src/main/java/com/ard/web/controller/sample/DeviceController.java
index 0f2312d..291caac 100644
--- a/ard-admin/src/main/java/com/ard/web/controller/sample/DeviceController.java
+++ b/ard-admin/src/main/java/com/ard/web/controller/sample/DeviceController.java
@@ -1,5 +1,8 @@
 package com.ard.web.controller.sample;
 
+import com.ard.common.core.controller.BaseController;
+import com.ard.common.core.page.TableDataInfo;
+import com.ard.device.camera.domain.ArdCamera;
 import com.ard.sample.common.error.CommonErrorEnum;
 import com.ard.sample.common.model.PaginationData;
 import com.ard.sample.common.model.ResponseResult;
@@ -8,19 +11,27 @@
 import com.ard.sample.component.mqtt.model.CommonTopicResponse;
 import com.ard.sample.manage.model.dto.DeviceDTO;
 import com.ard.sample.manage.model.dto.DeviceFirmwareUpgradeDTO;
+import com.ard.sample.manage.model.entity.DeviceEntity;
+import com.ard.sample.manage.model.enums.DeviceFirmwareStatusEnum;
 import com.ard.sample.manage.model.enums.DeviceSetPropertyEnum;
 import com.ard.sample.manage.model.receiver.StatusGatewayReceiver;
 import com.ard.sample.manage.service.IDeviceService;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.fasterxml.jackson.databind.JsonNode;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.integration.annotation.ServiceActivator;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
+import java.time.ZoneId;
 import java.util.List;
 import java.util.Optional;
+
+import static com.ard.common.utils.PageUtils.startPage;
 
 /**
  * @author sean.zhou
@@ -31,7 +42,7 @@
 @RestController
 @Slf4j
 @RequestMapping("/dock/device")
-public class DeviceController {
+public class DeviceController extends BaseController {
 
     @Autowired
     private IDeviceService deviceService;
@@ -84,11 +95,25 @@
      * @return
      */
     @ApiOperation("设备列表")
+    @PreAuthorize("@ss.hasPermi('device:dock:list')")
     @GetMapping("/list")
-    public ResponseResult<List<DeviceDTO>> getDevices() {
-        List<DeviceDTO> devicesList = deviceService.getDevicesTopoForWeb();
+    public ResponseResult<List<DeviceDTO>> getDevices(@RequestParam(required = false) String nickname) {
+//        List<DeviceDTO> devicesList = deviceService.getDevicesTopoForWeb();
+        List<DeviceDTO> devicesList = deviceService.getDockList(nickname);
         return ResponseResult.success(devicesList);
     }
+
+//    /**
+//     * 获取按nickname筛选在线设备列表
+//     *
+//     * @return
+//     */
+//    @ApiOperation("设备列表-按nickname筛选")
+//    @GetMapping("/cameralist")
+//    public ResponseResult<List<DeviceDTO>> getCameraDevices(@RequestParam(required = false) String nickname) {
+//        List<DeviceDTO> devicesList = deviceService.getDockCameraList(nickname);
+//        return ResponseResult.success(devicesList);
+//    }
 
     /**
      * 绑定设备
@@ -121,6 +146,7 @@
 
     /**
      * Get the binding devices list
+     * 获取绑定设备列表
      *
      * @param page
      * @param pageSize
@@ -128,11 +154,13 @@
      */
     @ApiOperation("绑定设备列表")
     @GetMapping("/list/bound")
+    @PreAuthorize("@ss.hasPermi('device:dock:list')")
     public ResponseResult<PaginationData<DeviceDTO>> getBoundDevicesWithDomain(Integer domain,
                                                                                @RequestParam(defaultValue = "1") Long page,
                                                                                @RequestParam(value = "page_size",
-                                                                                       defaultValue = "50") Long pageSize) {
-        PaginationData<DeviceDTO> devices = deviceService.getBoundDevicesWithDomain(page, pageSize, domain);
+                                                                                       defaultValue = "50") Long pageSize,
+                                                                               @RequestParam(required = false) Long deptId) {
+        PaginationData<DeviceDTO> devices = deviceService.getBoundDevicesWithDomain(page, pageSize, domain, deptId);
 
         return ResponseResult.success(devices);
     }
@@ -197,7 +225,48 @@
         if (propertyEnumOpt.isEmpty()) {
             return ResponseResult.error(CommonErrorEnum.ILLEGAL_ARGUMENT);
         }
-        deviceService.devicePropertySet(dockSn, propertyEnumOpt.get(), param.get(property));
+        deviceService.devicePropertySet(dockSn, propertyEnumOpt.get(), param);
         return ResponseResult.success();
     }
+
+    //.get(property)
+
+//    /**
+//     * 查询机场设备列表
+//     */
+//    @PreAuthorize("@ss.hasPermi('device:camera:list')")
+//    @GetMapping("/test/list")
+//    @ApiOperation("查询机场设备列表")
+//    public TableDataInfo list(DeviceDTO device) {
+//        startPage();
+//        DeviceEntity deviceEntity = deviceDTO2Entity(device);
+//        QueryWrapper<DeviceEntity> queryWrapper=new QueryWrapper<>(deviceEntity);
+//        List<DeviceEntity> list = deviceService.selectList(queryWrapper);
+//        return getDataTable(list);
+//    }
+
+    private DeviceEntity deviceDTO2Entity(DeviceDTO dto) {
+        DeviceEntity.DeviceEntityBuilder builder = DeviceEntity.builder();
+        if (dto == null) {
+            return builder.build();
+        }
+
+        return builder.deviceSn(dto.getDeviceSn())
+                .userId(dto.getUserId())
+                .nickname(dto.getNickname())
+                .boundStatus(dto.getBoundStatus())
+                .loginTime(dto.getLoginTime() != null ?
+                        dto.getLoginTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() : null)
+                .boundTime(dto.getBoundTime() != null ?
+                        dto.getBoundTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() : null)
+                .childSn(dto.getChildDeviceSn())
+                .domain(dto.getDomain())
+                .firmwareVersion(dto.getFirmwareVersion())
+                .workType(dto.getWorkType())
+                .webrtcUrl(dto.getWebrtcUrl())
+                .cameraWebrtcUrl(dto.getCameraWebrtcUrl())
+                .compatibleStatus(dto.getFirmwareStatus() == null ? null :
+                        DeviceFirmwareStatusEnum.CONSISTENT_UPGRADE != DeviceFirmwareStatusEnum.find(dto.getFirmwareStatus()))
+                .build();
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3