#update
This commit is contained in:
@@ -2,10 +2,8 @@ package com.maibu.uav.controller;
|
||||
|
||||
import com.maibu.core.controller.BaseController;
|
||||
import com.maibu.core.domain.AjaxResult;
|
||||
import com.maibu.uav.dto.CameraLiveParamDTO;
|
||||
import com.maibu.uav.dto.FlightTaskCommandDTO;
|
||||
import com.maibu.uav.dto.FlightTaskCreateDTO;
|
||||
import com.maibu.uav.dto.UavDeviceStateResponseDTO;
|
||||
import com.maibu.core.page.TableDataInfo;
|
||||
import com.maibu.uav.dto.*;
|
||||
import com.maibu.uav.service.UAVService;
|
||||
import io.minio.errors.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -15,6 +13,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import java.io.IOException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/iot/UAV")
|
||||
@@ -30,6 +29,29 @@ public class UAVController extends BaseController {
|
||||
return AjaxResult.success(result);
|
||||
}
|
||||
|
||||
@GetMapping("/getSiteUAVList")
|
||||
public TableDataInfo getSiteUAVList(@RequestParam(required = false) Long siteId,
|
||||
@RequestParam(required = false) Integer status,
|
||||
@RequestParam(required = false) String sn) {
|
||||
startPage();
|
||||
Long roleId = getLoginUser().getRoleId();
|
||||
Long userId = getLoginUser().getUserId();
|
||||
return getDataTable(uavService.getSiteUAVList(siteId, roleId, userId, status, sn));
|
||||
}
|
||||
|
||||
@GetMapping("/getUAVList")
|
||||
public TableDataInfo getUAVList(@RequestParam(required = false) Integer status,
|
||||
@RequestParam(required = false) String sn) {
|
||||
startPage();
|
||||
Long roleId = getLoginUser().getRoleId();
|
||||
Long orgId = getLoginUser().getOrgId();
|
||||
Long sId = getLoginUser().getSiteId();
|
||||
Long userId = getLoginUser().getUserId();
|
||||
List<UavDeviceStateResponseDetailDTO> result = uavService.getUAVList(sId, orgId, roleId, userId, status, sn);
|
||||
return getDataTable(result);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/getDeviceHMS")
|
||||
public String getDeviceHMS(@RequestParam String deviceSn) {
|
||||
return uavService.getDeviceHMS(deviceSn);
|
||||
@@ -71,9 +93,9 @@ public class UAVController extends BaseController {
|
||||
return AjaxResult.success(uavService.liveStream(dto));
|
||||
}
|
||||
|
||||
@GetMapping("/getFlightTask")
|
||||
public String getFlightTask(@RequestParam String sn) {
|
||||
return uavService.flightTaskList(sn);
|
||||
@PostMapping("/getFlightTask")
|
||||
public AjaxResult getFlightTask(@RequestBody FlightTaskDTO dto) {
|
||||
return AjaxResult.success(uavService.flightTaskList(dto));
|
||||
}
|
||||
|
||||
@GetMapping("/getFlightTaskDetail")
|
||||
@@ -130,9 +152,40 @@ public class UAVController extends BaseController {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 机场相机切换
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/changeCamera")
|
||||
public String changeCamera(@RequestParam String sn, @RequestParam String cameraIndex, @RequestParam String cameraPosition) {
|
||||
return uavService.changeCamera(sn, cameraIndex, cameraPosition);
|
||||
public AjaxResult changeCamera(@RequestBody CameraLiveStreamParamDTO dto) {
|
||||
return AjaxResult.success(uavService.changeCamera(dto.getSn(), dto.getCameraIndex(), dto.getCameraPosition(), dto.getQualityType(), dto.getVideoExpire()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 飞行器镜头切换
|
||||
*/
|
||||
@PostMapping("/changeLens")
|
||||
public AjaxResult changeLens(@RequestBody CameraLiveStreamParamDTO dto) {
|
||||
return AjaxResult.success(uavService.changeLens(dto.getSn(), dto.getCameraIndex(), dto.getLensType(), dto.getQualityType(), dto.getVideoExpire()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 绑定设备
|
||||
*/
|
||||
@PostMapping("/bind")
|
||||
public AjaxResult bind(@RequestBody UavBindDTO dto) {
|
||||
return AjaxResult.success(uavService.bind(dto));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解绑设备
|
||||
*/
|
||||
@PostMapping("/unbind")
|
||||
public AjaxResult unbind(@RequestBody UavUnBindDTO dto) {
|
||||
return AjaxResult.success(uavService.unbind(dto));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.maibu.uav.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CameraLiveStreamParamDTO {
|
||||
private String sn;
|
||||
private String cameraIndex;
|
||||
private Long videoExpire;
|
||||
private String qualityType; //adaptive 自动 smooth流畅 ultra_high_definition超清
|
||||
private String cameraPosition;
|
||||
private String lensType;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.maibu.uav.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class FlightTaskDTO {
|
||||
private List<String> sns;
|
||||
private Long beginAt;
|
||||
private Long endAt;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.maibu.uav.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class UavBindDTO {
|
||||
private Long siteId;
|
||||
private Long orgId;
|
||||
private List<String> sns;
|
||||
private Long userId;
|
||||
}
|
||||
@@ -27,4 +27,8 @@ public class UavDeviceStateResponseDetailDTO {
|
||||
|
||||
private List<CameraInfo> gateway_camera_list;
|
||||
private List<CameraInfo> drone_camera_list;
|
||||
|
||||
private Long orgId;
|
||||
private Long siteId;
|
||||
private Long userId;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.maibu.uav.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class UavUnBindDTO {
|
||||
|
||||
private List<String> sns;
|
||||
private Integer type; //1清除人 2清除场站 3清除组织
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.maibu.uav.scheduled;
|
||||
|
||||
import com.maibu.core.business.uav.IotUAVDevice;
|
||||
import com.maibu.mapper.UAVDeviceMapper;
|
||||
import com.maibu.uav.dto.UavDeviceStateResponseDTO;
|
||||
import com.maibu.uav.dto.UavDeviceStateResponseDetailDTO;
|
||||
import com.maibu.uav.service.UAVService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class UAVScheduled {
|
||||
|
||||
@Autowired
|
||||
private UAVService uavService;
|
||||
|
||||
@Autowired
|
||||
private UAVDeviceMapper uavDeviceMapper;
|
||||
|
||||
|
||||
//10分钟执行一次同步无人机设备
|
||||
@Scheduled(cron = "0 */10 * * * ?")
|
||||
public void updateUAVDevice() {
|
||||
UavDeviceStateResponseDTO dto = uavService.getProjectDeviceList();
|
||||
List<IotUAVDevice> removeList = new ArrayList<>();
|
||||
List<IotUAVDevice> addList = new ArrayList<>();
|
||||
List<IotUAVDevice> list = uavDeviceMapper.selectList();
|
||||
if (dto != null && !CollectionUtils.isEmpty(dto.getDetail())) {
|
||||
|
||||
List<UavDeviceStateResponseDetailDTO> detailList = dto.getDetail();
|
||||
|
||||
// 数据库 SN 集合
|
||||
Set<String> dbSnSet = list.stream()
|
||||
.map(IotUAVDevice::getSn)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 远程 SN 集合
|
||||
Set<String> remoteSnSet = detailList.stream()
|
||||
.map(UavDeviceStateResponseDetailDTO::getGateway_sn)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// ========================
|
||||
// 1. 获取新增设备
|
||||
// 远程有,数据库没有
|
||||
// ========================
|
||||
detailList.stream()
|
||||
.filter(x -> !dbSnSet.contains(x.getGateway_sn()))
|
||||
.forEach(x -> {
|
||||
IotUAVDevice device = new IotUAVDevice();
|
||||
device.setSn(x.getGateway_sn());
|
||||
device.setName(x.getGateway_sn());
|
||||
device.setDroneSn(x.getDevice_sn());
|
||||
device.setLastSyncTime(LocalDateTime.now());
|
||||
device.setOlineStatus(1);
|
||||
device.setCreateTime(LocalDateTime.now());
|
||||
device.setCreateBy("system");
|
||||
addList.add(device);
|
||||
});
|
||||
|
||||
// ========================
|
||||
// 2. 获取删除设备
|
||||
// 数据库有,远程没有
|
||||
// ========================
|
||||
list.stream()
|
||||
.filter(x -> !remoteSnSet.contains(x.getSn()))
|
||||
.forEach(removeList::add);
|
||||
|
||||
} else {
|
||||
//数据库有 则跟更新不在
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
removeList.addAll(list);
|
||||
}
|
||||
}
|
||||
uavDeviceMapper.saveOrUpdateBatch(addList);
|
||||
if (!CollectionUtils.isEmpty(removeList)) {
|
||||
removeList.forEach(y -> {
|
||||
y.setOlineStatus(2);
|
||||
// y.setDelFlag(true);
|
||||
});
|
||||
uavDeviceMapper.saveOrUpdateBatch(removeList);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,12 @@
|
||||
package com.maibu.uav.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.maibu.core.business.uav.IotUAVDevice;
|
||||
import com.maibu.core.domain.entity.SysRole;
|
||||
import com.maibu.mapper.UAVDeviceMapper;
|
||||
import com.maibu.service.ISysRoleService;
|
||||
import com.maibu.uav.dto.*;
|
||||
import com.maibu.uav.entity.UavDevice;
|
||||
import com.maibu.uav.entity.UavDeviceState;
|
||||
@@ -24,15 +29,10 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@@ -45,6 +45,12 @@ public class UAVService {
|
||||
@Autowired
|
||||
private UavHttpUtils httpService;
|
||||
|
||||
@Autowired
|
||||
private ISysRoleService roleService;
|
||||
|
||||
@Autowired
|
||||
private UAVDeviceMapper uavDeviceMapper;
|
||||
|
||||
|
||||
public static final Map<String, Long> latestActiveTime = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -52,6 +58,95 @@ public class UAVService {
|
||||
|
||||
public static final Long outTime = 30000L;
|
||||
|
||||
public List<UavDeviceStateResponseDetailDTO> getSiteUAVList(Long siteId, Long roleId, Long userId, Integer status, String sn) {
|
||||
SysRole sysRole = roleService.selectRoleById(roleId);
|
||||
if (sysRole != null) {
|
||||
String roleKey = sysRole.getRoleKey();
|
||||
LambdaQueryWrapper<IotUAVDevice> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (!StringUtils.isEmpty(roleKey)) {
|
||||
if ("manager".equals(roleKey) || "siteManager".equals(roleKey) || "admin".equals(roleKey)) {
|
||||
queryWrapper.eq(IotUAVDevice::getSiteId, siteId);
|
||||
} else {
|
||||
queryWrapper.eq(IotUAVDevice::getTenantId, userId);
|
||||
}
|
||||
if (!StringUtils.isEmpty(sn)) {
|
||||
queryWrapper.eq(IotUAVDevice::getSn, sn);
|
||||
}
|
||||
queryWrapper.eq(IotUAVDevice::getOlineStatus, 1);
|
||||
List<IotUAVDevice> list = uavDeviceMapper.selectList(queryWrapper);
|
||||
List<UavDeviceStateResponseDetailDTO> res = transferData(list);
|
||||
if (status!=null && !CollectionUtils.isEmpty(res)) {
|
||||
return res.stream().filter(x->status.equals(x.getOnlineStatus())).collect(Collectors.toList());
|
||||
}else {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
public List<UavDeviceStateResponseDetailDTO> getUAVList(Long siteId, Long orgId, Long roleId, Long userId,Integer status, String sn) {
|
||||
SysRole sysRole = roleService.selectRoleById(roleId);
|
||||
if (sysRole != null) {
|
||||
String roleKey = sysRole.getRoleKey();
|
||||
LambdaQueryWrapper<IotUAVDevice> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (!StringUtils.isEmpty(roleKey)) {
|
||||
if ("manager".equals(roleKey)) {
|
||||
queryWrapper.eq(IotUAVDevice::getOrgId, orgId);
|
||||
} else if ("siteManager".equals(roleKey)) {
|
||||
queryWrapper.eq(IotUAVDevice::getSiteId, siteId);
|
||||
} else if (!"admin".equals(roleKey)) {
|
||||
queryWrapper.eq(IotUAVDevice::getTenantId, userId);
|
||||
}
|
||||
queryWrapper.eq(IotUAVDevice::getOlineStatus, 1);
|
||||
if (!StringUtils.isEmpty(sn)) {
|
||||
queryWrapper.eq(IotUAVDevice::getSn, sn);
|
||||
}
|
||||
List<IotUAVDevice> list;
|
||||
// if ("admin".equals(roleKey)) {
|
||||
// list = uavDeviceMapper.selectList(queryWrapper);
|
||||
// } else {
|
||||
// list = uavDeviceMapper.selectList(queryWrapper);
|
||||
// }
|
||||
list = uavDeviceMapper.selectList(queryWrapper);
|
||||
List<UavDeviceStateResponseDetailDTO> res = transferData(list);
|
||||
if (status!=null && !CollectionUtils.isEmpty(res)) {
|
||||
return res.stream().filter(x->status.equals(x.getOnlineStatus())).collect(Collectors.toList());
|
||||
}else {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
public List<UavDeviceStateResponseDetailDTO> transferData(List<IotUAVDevice> list) {
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
Map<String, IotUAVDevice> deviceMap = list.stream()
|
||||
.collect(Collectors.toMap(
|
||||
IotUAVDevice::getSn,
|
||||
item -> item
|
||||
));
|
||||
UavDeviceStateResponseDTO dto = getProjectDeviceList();
|
||||
List<UavDeviceStateResponseDetailDTO> details = dto.getDetail();
|
||||
if (!CollectionUtils.isEmpty(details)) {
|
||||
List<UavDeviceStateResponseDetailDTO> fiList = details.stream().filter(x -> deviceMap.containsKey(x.getGateway_sn())).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(fiList)) {
|
||||
fiList.forEach(k -> {
|
||||
IotUAVDevice device = deviceMap.get(k.getGateway_sn());
|
||||
if (device != null) {
|
||||
k.setSiteId(device.getSiteId());
|
||||
k.setOrgId(device.getOrgId());
|
||||
k.setUserId(device.getTenantId());
|
||||
}
|
||||
});
|
||||
}
|
||||
return fiList;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public UavDeviceStateResponseDTO getProjectDeviceList() {
|
||||
try {
|
||||
@@ -277,13 +372,46 @@ public class UAVService {
|
||||
return list;
|
||||
}
|
||||
|
||||
public String flightTaskList(String sn) {
|
||||
public Map<String, Object> flightTaskList(FlightTaskDTO dto) {
|
||||
List<String> sns = dto.getSns();
|
||||
Long beginAt = dto.getBeginAt() == null ? 1735692484 : dto.getBeginAt();
|
||||
Long endAt = dto.getEndAt() == null ? 1830306933 : dto.getEndAt();
|
||||
|
||||
String url = baseUrl + "/openapi/v0.1/flight-task/list";
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("begin_at", 1735692484); //2025-1-1
|
||||
map.put("end_at", 1830306933);//2028-1-1
|
||||
map.put("sn", sn);
|
||||
return httpService.doGet(url, map);
|
||||
// 线程池
|
||||
ExecutorService executor = Executors.newFixedThreadPool(10);
|
||||
try {
|
||||
List<CompletableFuture<Map<String, Object>>> futures = sns.stream()
|
||||
.map(sn -> CompletableFuture.supplyAsync(() -> {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("begin_at", beginAt);
|
||||
map.put("end_at", endAt);
|
||||
map.put("sn", sn);
|
||||
try {
|
||||
String res = httpService.doGet(url, map);
|
||||
SK2ResultDTO sk2ResultDTO = JsonUtils.parseObject(res, SK2ResultDTO.class);
|
||||
Object data = null;
|
||||
if (sk2ResultDTO != null && sk2ResultDTO.getCode() == 0) {
|
||||
data = sk2ResultDTO.getData();
|
||||
}
|
||||
Map<String, Object> m = new HashMap<>();
|
||||
m.put(sn, data);
|
||||
return m;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}, executor))
|
||||
.collect(Collectors.toList());
|
||||
// 等待全部完成
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
futures.stream()
|
||||
.map(CompletableFuture::join)
|
||||
.forEach(result::putAll);
|
||||
return result;
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
public String flightTaskDetail(String taskId) {
|
||||
@@ -395,13 +523,136 @@ public class UAVService {
|
||||
}
|
||||
|
||||
|
||||
public String changeCamera(String sn, String cameraIndex, String cameraPosition) {
|
||||
public CameraLiveResultDTO changeCamera(String sn, String cameraIndex, String cameraPosition, String qualityType, Long videoExpire) {
|
||||
String url = baseUrl + "/openapi/v0.1/device/change-camera";
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("sn", sn);
|
||||
map.put("camera_index", cameraIndex);
|
||||
map.put("camera_position", cameraPosition);
|
||||
return httpService.doPut(url, map);
|
||||
String result = httpService.doPost(url, map);
|
||||
if (!StringUtils.isEmpty(result)) {
|
||||
SK2ResultDTO sk2ResultDTO = JsonUtils.parseObject(result, SK2ResultDTO.class);
|
||||
if (sk2ResultDTO != null && sk2ResultDTO.getCode() == 0) {
|
||||
return singleLiveStream(sn, cameraIndex, qualityType, videoExpire);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public CameraLiveResultDTO changeLens(String sn, String cameraIndex, String lensType, String qualityType, Long videoExpire) {
|
||||
String result = droneCameraControl(sn, cameraIndex);
|
||||
if (!StringUtils.isEmpty(result)) {
|
||||
SK2ResultDTO sk2ResultDTO = JsonUtils.parseObject(result, SK2ResultDTO.class);
|
||||
if (sk2ResultDTO != null && sk2ResultDTO.getCode() == 0) {
|
||||
String url = baseUrl + "/openapi/v0.1/device/change-lens";
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("sn", sn);
|
||||
map.put("camera_index", cameraIndex);
|
||||
map.put("lens_type", lensType);
|
||||
String str = httpService.doPost(url, map);
|
||||
SK2ResultDTO sk2Str = JsonUtils.parseObject(str, SK2ResultDTO.class);
|
||||
if (sk2Str != null && sk2ResultDTO.getCode() == 0) {
|
||||
return singleLiveStream(sn, cameraIndex, qualityType, videoExpire);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取控制权
|
||||
*/
|
||||
public String droneCameraControl(String sn, String cameraIndex) {
|
||||
String url = baseUrl + "/openapi/v0.1/device/control";
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("drone_sn", sn);
|
||||
map.put("payload_index", Arrays.asList(cameraIndex));
|
||||
return httpService.doPost(url, map);
|
||||
}
|
||||
|
||||
public CameraLiveResultDTO singleLiveStream(String sn, String cameraIndex, String qualityType, Long videoExpire) {
|
||||
try {
|
||||
String url = baseUrl + "/openapi/v0.1/live-stream/start";
|
||||
CameraLiveResultDTO cameraLiveResultDTO = null;
|
||||
CameraLiveStreamDTO d = new CameraLiveStreamDTO();
|
||||
d.setSn(sn);
|
||||
d.setCamera_index(cameraIndex);
|
||||
d.setQuality_type(qualityType);
|
||||
d.setVideo_expire(videoExpire);
|
||||
String res = httpService.doPost(url, d);
|
||||
if (!StringUtils.isEmpty(res)) {
|
||||
SK2ResultDTO sk2ResultDTO = JsonUtils.parseObject(res, SK2ResultDTO.class);
|
||||
if (sk2ResultDTO != null && sk2ResultDTO.getData() != null) {
|
||||
CameraLiveStreamResultDTO resultDTO = JsonUtils.parseObject(
|
||||
JsonUtils.toJsonString(sk2ResultDTO.getData()), // 先转JSON字符串
|
||||
new TypeReference<CameraLiveStreamResultDTO>() {
|
||||
}
|
||||
);
|
||||
if (resultDTO != null) {
|
||||
cameraLiveResultDTO = new CameraLiveResultDTO();
|
||||
cameraLiveResultDTO.setUrl(resultDTO.getUrl());
|
||||
cameraLiveResultDTO.setExpire_ts(resultDTO.getExpire_ts());
|
||||
cameraLiveResultDTO.setUrl_type(resultDTO.getUrl_type());
|
||||
cameraLiveResultDTO.setSn(sn);
|
||||
cameraLiveResultDTO.setCamera_index(cameraIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
return cameraLiveResultDTO;
|
||||
} catch (
|
||||
Exception e) {
|
||||
log.error("开启直播发生错误", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
//todo 更新同步状态
|
||||
|
||||
|
||||
public boolean bind(UavBindDTO dto) {
|
||||
List<String> sns = dto.getSns();
|
||||
if (!CollectionUtils.isEmpty(sns)) {
|
||||
Long orgId = dto.getOrgId();
|
||||
Long siteId = dto.getSiteId();
|
||||
Long userId = dto.getUserId();
|
||||
|
||||
LambdaQueryWrapper<IotUAVDevice> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(IotUAVDevice::getSn, sns);
|
||||
List<IotUAVDevice> list = uavDeviceMapper.selectList(queryWrapper);
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
list.forEach(x -> {
|
||||
x.setOrgId(orgId);
|
||||
x.setSiteId(siteId);
|
||||
x.setTenantId(userId);
|
||||
});
|
||||
return uavDeviceMapper.saveOrUpdateBatch(list);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean unbind(UavUnBindDTO dto) {
|
||||
List<String> sns = dto.getSns();
|
||||
if (!CollectionUtils.isEmpty(sns)) {
|
||||
LambdaQueryWrapper<IotUAVDevice> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(IotUAVDevice::getSn, sns);
|
||||
List<IotUAVDevice> list = uavDeviceMapper.selectList(queryWrapper);
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
list.forEach(x -> {
|
||||
x.setTenantId(null);
|
||||
if (dto.getType() == 2) {
|
||||
x.setSiteId(null);
|
||||
}
|
||||
if (dto.getType() == 3) {
|
||||
x.setSiteId(null);
|
||||
x.setOrgId(null);
|
||||
}
|
||||
});
|
||||
return uavDeviceMapper.saveOrUpdateBatch(list);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user