#update
This commit is contained in:
@@ -1,18 +1,21 @@
|
|||||||
package com.maibu.config;
|
package com.maibu.config;
|
||||||
|
|
||||||
import io.minio.MinioClient;
|
import io.minio.MinioClient;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class MinioConfig {
|
public class MinioConfig {
|
||||||
|
|
||||||
|
@Value("${minio.endpoint}")
|
||||||
|
private String endpoint;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public MinioClient minioClient() {
|
public MinioClient minioClient() {
|
||||||
return MinioClient.builder()
|
return MinioClient.builder()
|
||||||
.endpoint("https://oss.satabot.com")
|
.endpoint(endpoint)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class VehicleMessage {
|
|||||||
private double linear_speed; // 实时线速度
|
private double linear_speed; // 实时线速度
|
||||||
private double angular_speed; // 实时角速度
|
private double angular_speed; // 实时角速度
|
||||||
|
|
||||||
private Integer systemMode; // 当前 没有遥控器控制的模式 control_mode 为0,当前的系统控制的模式 只有2,3
|
private Integer system_mode; // 当前 没有遥控器控制的模式 control_mode 为0,当前的系统控制的模式 只有2,3
|
||||||
|
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
|||||||
@@ -209,15 +209,15 @@ public class SiteMemory {
|
|||||||
public synchronized void saveVehicleSystemMode(String deviceId, Integer systemMode) {
|
public synchronized void saveVehicleSystemMode(String deviceId, Integer systemMode) {
|
||||||
VehicleMessage vehicleMessage = getVehicleMessage(deviceId);
|
VehicleMessage vehicleMessage = getVehicleMessage(deviceId);
|
||||||
if (vehicleMessage != null) {
|
if (vehicleMessage != null) {
|
||||||
vehicleMessage.setSystemMode(systemMode);
|
vehicleMessage.setSystem_mode(systemMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void saveVehicleMessage(String deviceId, VehicleMessage vehicleMessage) {
|
public synchronized void saveVehicleMessage(String deviceId, VehicleMessage vehicleMessage) {
|
||||||
VehicleMessage oldVehicle = getVehicleMessage(deviceId);
|
// VehicleMessage oldVehicle = getVehicleMessage(deviceId);
|
||||||
if (oldVehicle != null) {
|
// if (oldVehicle != null) {
|
||||||
vehicleMessage.setSystemMode(oldVehicle.getSystemMode());
|
// vehicleMessage.setSystemMode(oldVehicle.getSystemMode());
|
||||||
}
|
// }
|
||||||
vehicleMessage.setDeviceId(deviceId);
|
vehicleMessage.setDeviceId(deviceId);
|
||||||
vehicleMessageMap.put(deviceId, vehicleMessage);
|
vehicleMessageMap.put(deviceId, vehicleMessage);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|||||||
dto.setCm(vehicleMessage.getControl_mode());
|
dto.setCm(vehicleMessage.getControl_mode());
|
||||||
dto.setMs(vehicleMessage.getMotion());
|
dto.setMs(vehicleMessage.getMotion());
|
||||||
dto.setB(vehicleMessage.getBattery_percentage());
|
dto.setB(vehicleMessage.getBattery_percentage());
|
||||||
dto.setSm(vehicleMessage.getSystemMode());
|
dto.setSm(vehicleMessage.getSystem_mode());
|
||||||
dto.setE(vehicleMessage.getEmergency_stop());
|
dto.setE(vehicleMessage.getEmergency_stop());
|
||||||
}
|
}
|
||||||
dto.setWk(nettyDevice.getTask() != null ? nettyDevice.getTask().getWorkName() : "");
|
dto.setWk(nettyDevice.getTask() != null ? nettyDevice.getTask().getWorkName() : "");
|
||||||
@@ -303,8 +303,7 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|||||||
return webStatusMessageDTO;
|
return webStatusMessageDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebStatusMessageDTO createWebDeviceRealtimeMessage(HostVehicleRelTimeDTO vehicleRelTimeDTO,
|
public WebStatusMessageDTO createWebDeviceRealtimeMessage(HostVehicleRelTimeDTO vehicleRelTimeDTO) {
|
||||||
Integer systemMode) {
|
|
||||||
// todo 状态消息
|
// todo 状态消息
|
||||||
|
|
||||||
WebStatusMessageDTO webStatusMessageDTO = new WebStatusMessageDTO();
|
WebStatusMessageDTO webStatusMessageDTO = new WebStatusMessageDTO();
|
||||||
@@ -474,7 +473,7 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|||||||
|
|
||||||
DeviceStatusDetail system_mode = new DeviceStatusDetail();
|
DeviceStatusDetail system_mode = new DeviceStatusDetail();
|
||||||
system_mode.setName("systemMode");
|
system_mode.setName("systemMode");
|
||||||
system_mode.setValue(String.valueOf(systemMode));
|
system_mode.setValue(String.valueOf(vehicleRelTimeDTO.getData().getSystem_mode()));
|
||||||
system_mode.setUnit("");
|
system_mode.setUnit("");
|
||||||
transferData.add(system_mode);
|
transferData.add(system_mode);
|
||||||
|
|
||||||
@@ -493,35 +492,38 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|||||||
if (vehicleRelTimeDTO != null) {
|
if (vehicleRelTimeDTO != null) {
|
||||||
// todo 更新里程数 里程数 * 割幅0.8
|
// todo 更新里程数 里程数 * 割幅0.8
|
||||||
NettyDevice nettyDevice = deviceSessionManager.getDevice(deviceId);
|
NettyDevice nettyDevice = deviceSessionManager.getDevice(deviceId);
|
||||||
Integer systemMode = null;
|
boolean localControlChange = false; // 切换到本地遥控提示
|
||||||
|
boolean modeNotMatch = false; //
|
||||||
if (nettyDevice != null) {
|
if (nettyDevice != null) {
|
||||||
Long orgId = nettyDevice.getDevice().getOrgId();
|
Long orgId = nettyDevice.getDevice().getOrgId();
|
||||||
Long siteId = nettyDevice.getDevice().getSiteId();
|
Long siteId = nettyDevice.getDevice().getSiteId();
|
||||||
SiteMemory siteMemory = GlobalMemory.getSiteMemory(orgId, siteId);
|
SiteMemory siteMemory = GlobalMemory.getSiteMemory(orgId, siteId);
|
||||||
if (siteMemory != null) {
|
if (siteMemory != null) {
|
||||||
// DeviceRunStatistics deviceRunStatistics =
|
|
||||||
// siteMemory.getRunStatistics(deviceId);
|
// siteMemory.saveVehicleMessage(deviceId, vehicleRelTimeDTO.getData());
|
||||||
// if (deviceRunStatistics == null) {
|
|
||||||
// deviceRunStatistics = new DeviceRunStatistics();
|
// systemMode = siteMemory.getVehicleMessage(deviceId).getSystemMode();
|
||||||
|
// Integer oldSystemMode =
|
||||||
|
// siteMemory.getVehicleMessage(deviceId).getControl_mode();
|
||||||
|
// Integer controlMode = vehicleRelTimeDTO.getData().getControl_mode();
|
||||||
|
|
||||||
|
// if (Objects.equals(oldSystemMode, 0) && !Objects.equals(controlMode, 0)) {
|
||||||
|
|
||||||
|
// // 清除 systemcode;
|
||||||
|
// siteMemory.saveVehicleSystemMode(deviceId, null);
|
||||||
// }
|
// }
|
||||||
// deviceRunStatistics.setDeviceId(deviceId);
|
|
||||||
// deviceRunStatistics.setDistance(vehicleRelTimeDTO.getData().getTotal_work_distance());
|
|
||||||
// deviceRunStatistics.setWorkArea(vehicleRelTimeDTO.getData().getTotal_work_distance()
|
|
||||||
// * 0.8);
|
|
||||||
// siteMemory.saveRunStatistics(deviceRunStatistics);
|
|
||||||
|
|
||||||
siteMemory.saveVehicleMessage(deviceId, vehicleRelTimeDTO.getData());
|
Integer oldControlMode = siteMemory.getVehicleMessage(deviceId).getControl_mode();
|
||||||
|
|
||||||
systemMode = siteMemory.getVehicleMessage(deviceId).getSystemMode();
|
|
||||||
Integer oldSystemMode = siteMemory.getVehicleMessage(deviceId).getControl_mode();
|
|
||||||
Integer controlMode = vehicleRelTimeDTO.getData().getControl_mode();
|
Integer controlMode = vehicleRelTimeDTO.getData().getControl_mode();
|
||||||
|
|
||||||
if (Objects.equals(oldSystemMode, 0) && !Objects.equals(controlMode, 0)) {
|
if (Objects.equals(oldControlMode, 0) && Objects.equals(controlMode, 1)) {
|
||||||
|
// 提示切换到遥控器
|
||||||
// 清除 systemcode;
|
localControlChange = true;
|
||||||
siteMemory.saveVehicleSystemMode(deviceId, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
siteMemory.saveVehicleMessage(deviceId, vehicleRelTimeDTO.getData());
|
||||||
|
|
||||||
// 故障处理
|
// 故障处理
|
||||||
Long errorCode = vehicleRelTimeDTO.getData().getError_code();
|
Long errorCode = vehicleRelTimeDTO.getData().getError_code();
|
||||||
if (errorCode != null && errorCode != 0) {
|
if (errorCode != null && errorCode != 0) {
|
||||||
@@ -534,7 +536,7 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WebStatusMessageDTO dto = createWebDeviceRealtimeMessage(vehicleRelTimeDTO, systemMode);
|
WebStatusMessageDTO dto = createWebDeviceRealtimeMessage(vehicleRelTimeDTO, boolean localControlChange, boolean modeNotMatch);
|
||||||
List<NettyDevice> controlMasters = deviceSessionManager
|
List<NettyDevice> controlMasters = deviceSessionManager
|
||||||
.getAllSlaveControl(deviceId);
|
.getAllSlaveControl(deviceId);
|
||||||
if (!CollectionUtils.isEmpty(controlMasters)) {
|
if (!CollectionUtils.isEmpty(controlMasters)) {
|
||||||
@@ -997,18 +999,18 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|||||||
log.debug("【模式切换回复】deviceId={}, payload={}", deviceId, payload);
|
log.debug("【模式切换回复】deviceId={}, payload={}", deviceId, payload);
|
||||||
|
|
||||||
HostModeChangeReplyDTO data = JsonUtils.parseObject(payload, HostModeChangeReplyDTO.class);
|
HostModeChangeReplyDTO data = JsonUtils.parseObject(payload, HostModeChangeReplyDTO.class);
|
||||||
if (data != null && data.getAccepted() != null && data.getAccepted()) {
|
// if (data != null && data.getAccepted() != null && data.getAccepted()) {
|
||||||
|
|
||||||
NettyDevice nettyDevice = deviceSessionManager.getDevice(deviceId);
|
// NettyDevice nettyDevice = deviceSessionManager.getDevice(deviceId);
|
||||||
if (nettyDevice != null && nettyDevice.getDevice() != null) {
|
// if (nettyDevice != null && nettyDevice.getDevice() != null) {
|
||||||
Long siteId = nettyDevice.getDevice().getSiteId();
|
// Long siteId = nettyDevice.getDevice().getSiteId();
|
||||||
Long orgId = nettyDevice.getDevice().getOrgId();
|
// Long orgId = nettyDevice.getDevice().getOrgId();
|
||||||
SiteMemory siteMemory = GlobalMemory.getSiteMemory(orgId, siteId);
|
// SiteMemory siteMemory = GlobalMemory.getSiteMemory(orgId, siteId);
|
||||||
if (siteMemory != null) {
|
// if (siteMemory != null) {
|
||||||
siteMemory.saveVehicleSystemMode(deviceId, data.getMode());
|
// siteMemory.saveVehicleSystemMode(deviceId, data.getMode());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
CompletableFuture<Boolean> future = GlobalMemory.modeFutureMap.get(deviceId);
|
CompletableFuture<Boolean> future = GlobalMemory.modeFutureMap.get(deviceId);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.maibu.utils;
|
package com.maibu.utils;
|
||||||
|
|
||||||
import io.minio.*;
|
import io.minio.*;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@@ -12,11 +14,10 @@ public class MinioUtil {
|
|||||||
@Resource
|
@Resource
|
||||||
private MinioClient minioClient;
|
private MinioClient minioClient;
|
||||||
|
|
||||||
|
|
||||||
private String defaultBucket = "mbzn";
|
private String defaultBucket = "mbzn";
|
||||||
|
|
||||||
|
@Value("${minio.endpoint}")
|
||||||
private String endpoint = "https://oss.satabot.com"; // http://ip:port
|
private String endpoint;
|
||||||
|
|
||||||
// 上传文件
|
// 上传文件
|
||||||
public void uploadFile(String objectName, InputStream stream, String contentType) throws Exception {
|
public void uploadFile(String objectName, InputStream stream, String contentType) throws Exception {
|
||||||
@@ -32,8 +33,7 @@ public class MinioUtil {
|
|||||||
.object(objectName)
|
.object(objectName)
|
||||||
.stream(stream, -1, 10485760)
|
.stream(stream, -1, 10485760)
|
||||||
.contentType(contentType)
|
.contentType(contentType)
|
||||||
.build()
|
.build());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回 public URL
|
// 返回 public URL
|
||||||
@@ -47,10 +47,6 @@ public class MinioUtil {
|
|||||||
RemoveObjectArgs.builder()
|
RemoveObjectArgs.builder()
|
||||||
.bucket(defaultBucket)
|
.bucket(defaultBucket)
|
||||||
.object(objectName)
|
.object(objectName)
|
||||||
.build()
|
.build());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,32 @@
|
|||||||
package com.maibu.uav.service;
|
package com.maibu.uav.service;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.security.InvalidKeyException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
@@ -9,35 +36,36 @@ import com.maibu.core.domain.entity.SysRole;
|
|||||||
import com.maibu.core.redis.RedisCache;
|
import com.maibu.core.redis.RedisCache;
|
||||||
import com.maibu.mapper.UAVDeviceMapper;
|
import com.maibu.mapper.UAVDeviceMapper;
|
||||||
import com.maibu.service.ISysRoleService;
|
import com.maibu.service.ISysRoleService;
|
||||||
import com.maibu.uav.common.UAVConstant;
|
import com.maibu.uav.dto.CameraLiveParamDTO;
|
||||||
import com.maibu.uav.dto.*;
|
import com.maibu.uav.dto.CameraLiveResultDTO;
|
||||||
|
import com.maibu.uav.dto.CameraLiveStreamDTO;
|
||||||
|
import com.maibu.uav.dto.CameraLiveStreamResultDTO;
|
||||||
|
import com.maibu.uav.dto.FlightTaskCommandDTO;
|
||||||
|
import com.maibu.uav.dto.FlightTaskDTO;
|
||||||
|
import com.maibu.uav.dto.SK2ResultDTO;
|
||||||
|
import com.maibu.uav.dto.UavBindDTO;
|
||||||
|
import com.maibu.uav.dto.UavDeviceStateDTO;
|
||||||
|
import com.maibu.uav.dto.UavDeviceStateResponseDTO;
|
||||||
|
import com.maibu.uav.dto.UavDeviceStateResponseDetailDTO;
|
||||||
|
import com.maibu.uav.dto.UavProjectDeviceDTO;
|
||||||
|
import com.maibu.uav.dto.UavStsTokenDTO;
|
||||||
|
import com.maibu.uav.dto.UavUnBindDTO;
|
||||||
import com.maibu.uav.entity.UavDevice;
|
import com.maibu.uav.entity.UavDevice;
|
||||||
import com.maibu.uav.entity.UavDeviceState;
|
import com.maibu.uav.entity.UavDeviceState;
|
||||||
import com.maibu.uav.utils.UavHttpUtils;
|
import com.maibu.uav.utils.UavHttpUtils;
|
||||||
import com.maibu.utils.StringUtils;
|
import com.maibu.utils.StringUtils;
|
||||||
import com.maibu.utils.json.JsonUtils;
|
import com.maibu.utils.json.JsonUtils;
|
||||||
|
|
||||||
import io.minio.MinioClient;
|
import io.minio.MinioClient;
|
||||||
import io.minio.PutObjectArgs;
|
import io.minio.PutObjectArgs;
|
||||||
import io.minio.credentials.StaticProvider;
|
import io.minio.credentials.StaticProvider;
|
||||||
import io.minio.errors.*;
|
import io.minio.errors.ErrorResponseException;
|
||||||
|
import io.minio.errors.InsufficientDataException;
|
||||||
|
import io.minio.errors.InternalException;
|
||||||
|
import io.minio.errors.InvalidResponseException;
|
||||||
|
import io.minio.errors.ServerException;
|
||||||
|
import io.minio.errors.XmlParserException;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.util.CollectionUtils;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import javax.annotation.PreDestroy;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.security.InvalidKeyException;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.*;
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
|||||||
@@ -821,7 +821,7 @@ public class DeviceTaskService {
|
|||||||
boolean result = true;
|
boolean result = true;
|
||||||
|
|
||||||
Integer controlMode = vehicleMessage.getControl_mode();
|
Integer controlMode = vehicleMessage.getControl_mode();
|
||||||
Integer systemCode = vehicleMessage.getSystemMode();
|
Integer systemCode = vehicleMessage.getSystem_mode();
|
||||||
// 控制模式不为0 同时不为2 不能操作 直接返回false
|
// 控制模式不为0 同时不为2 不能操作 直接返回false
|
||||||
if (controlMode != 0) {
|
if (controlMode != 0) {
|
||||||
if (controlMode != 2) {
|
if (controlMode != 2) {
|
||||||
|
|||||||
Reference in New Issue
Block a user