| | |
| | | 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; |
| | |
| | | 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 |
| | |
| | | @RestController |
| | | @Slf4j |
| | | @RequestMapping("/dock/device") |
| | | public class DeviceController { |
| | | public class DeviceController extends BaseController { |
| | | |
| | | @Autowired |
| | | private IDeviceService deviceService; |
| | |
| | | * @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); |
| | | // } |
| | | |
| | | /** |
| | | * 绑定设备 |
| | |
| | | */ |
| | | @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); |
| | | } |
| | |
| | | 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(); |
| | | } |
| | | } |