This commit is contained in:
2026-11-20 08:50:59 +08:00
parent 21b3dbaddb
commit ed2d856f2f
7 changed files with 104 additions and 75 deletions

View File

@@ -1,18 +1,21 @@
package com.maibu.config;
import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class MinioConfig {
@Value("${minio.endpoint}")
private String endpoint;
@Bean
public MinioClient minioClient() {
return MinioClient.builder()
.endpoint("https://oss.satabot.com")
.endpoint(endpoint)
.build();
}
}

View File

@@ -54,10 +54,10 @@ public class VehicleMessage {
private double linear_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 Long error_code; // 暂时用于上报错误
private Long error_code; // 暂时用于上报错误
}

View File

@@ -76,7 +76,7 @@ public class SiteMemory {
public final ConcurrentHashMap<String, DeviceMapPushDTO> deviceMapPushMap = new ConcurrentHashMap<>();
public ConcurrentHashMap<String, VehicleMessage> vehicleMessageMap = new ConcurrentHashMap<>();
public ConcurrentHashMap<String, VehicleMessage> vehicleMessageMap = new ConcurrentHashMap<>();
public final ConcurrentHashMap<RuleType, List<IotAutoRule>> iotAutoRuleMap = new ConcurrentHashMap<>();
@@ -209,15 +209,15 @@ public class SiteMemory {
public synchronized void saveVehicleSystemMode(String deviceId, Integer systemMode) {
VehicleMessage vehicleMessage = getVehicleMessage(deviceId);
if (vehicleMessage != null) {
vehicleMessage.setSystemMode(systemMode);
vehicleMessage.setSystem_mode(systemMode);
}
}
public synchronized void saveVehicleMessage(String deviceId, VehicleMessage vehicleMessage) {
VehicleMessage oldVehicle = getVehicleMessage(deviceId);
if (oldVehicle != null) {
vehicleMessage.setSystemMode(oldVehicle.getSystemMode());
}
// VehicleMessage oldVehicle = getVehicleMessage(deviceId);
// if (oldVehicle != null) {
// vehicleMessage.setSystemMode(oldVehicle.getSystemMode());
// }
vehicleMessage.setDeviceId(deviceId);
vehicleMessageMap.put(deviceId, vehicleMessage);
}

View File

@@ -291,7 +291,7 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
dto.setCm(vehicleMessage.getControl_mode());
dto.setMs(vehicleMessage.getMotion());
dto.setB(vehicleMessage.getBattery_percentage());
dto.setSm(vehicleMessage.getSystemMode());
dto.setSm(vehicleMessage.getSystem_mode());
dto.setE(vehicleMessage.getEmergency_stop());
}
dto.setWk(nettyDevice.getTask() != null ? nettyDevice.getTask().getWorkName() : "");
@@ -303,8 +303,7 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
return webStatusMessageDTO;
}
public WebStatusMessageDTO createWebDeviceRealtimeMessage(HostVehicleRelTimeDTO vehicleRelTimeDTO,
Integer systemMode) {
public WebStatusMessageDTO createWebDeviceRealtimeMessage(HostVehicleRelTimeDTO vehicleRelTimeDTO) {
// todo 状态消息
WebStatusMessageDTO webStatusMessageDTO = new WebStatusMessageDTO();
@@ -474,7 +473,7 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
DeviceStatusDetail system_mode = new DeviceStatusDetail();
system_mode.setName("systemMode");
system_mode.setValue(String.valueOf(systemMode));
system_mode.setValue(String.valueOf(vehicleRelTimeDTO.getData().getSystem_mode()));
system_mode.setUnit("");
transferData.add(system_mode);
@@ -493,35 +492,38 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
if (vehicleRelTimeDTO != null) {
// todo 更新里程数 里程数 * 割幅0.8
NettyDevice nettyDevice = deviceSessionManager.getDevice(deviceId);
Integer systemMode = null;
boolean localControlChange = false; // 切换到本地遥控提示
boolean modeNotMatch = false; //
if (nettyDevice != null) {
Long orgId = nettyDevice.getDevice().getOrgId();
Long siteId = nettyDevice.getDevice().getSiteId();
SiteMemory siteMemory = GlobalMemory.getSiteMemory(orgId, siteId);
if (siteMemory != null) {
// DeviceRunStatistics deviceRunStatistics =
// siteMemory.getRunStatistics(deviceId);
// if (deviceRunStatistics == null) {
// deviceRunStatistics = new DeviceRunStatistics();
// siteMemory.saveVehicleMessage(deviceId, vehicleRelTimeDTO.getData());
// 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();
if (Objects.equals(oldSystemMode, 0) && !Objects.equals(controlMode, 0)) {
// 清除 systemcode;
siteMemory.saveVehicleSystemMode(deviceId, null);
if (Objects.equals(oldControlMode, 0) && Objects.equals(controlMode, 1)) {
// 提示切换到遥控器
localControlChange = true;
}
siteMemory.saveVehicleMessage(deviceId, vehicleRelTimeDTO.getData());
// 故障处理
Long errorCode = vehicleRelTimeDTO.getData().getError_code();
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
.getAllSlaveControl(deviceId);
if (!CollectionUtils.isEmpty(controlMasters)) {
@@ -997,18 +999,18 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
log.debug("【模式切换回复】deviceId={}, payload={}", deviceId, payload);
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);
if (nettyDevice != null && nettyDevice.getDevice() != null) {
Long siteId = nettyDevice.getDevice().getSiteId();
Long orgId = nettyDevice.getDevice().getOrgId();
SiteMemory siteMemory = GlobalMemory.getSiteMemory(orgId, siteId);
if (siteMemory != null) {
siteMemory.saveVehicleSystemMode(deviceId, data.getMode());
}
}
}
// NettyDevice nettyDevice = deviceSessionManager.getDevice(deviceId);
// if (nettyDevice != null && nettyDevice.getDevice() != null) {
// Long siteId = nettyDevice.getDevice().getSiteId();
// Long orgId = nettyDevice.getDevice().getOrgId();
// SiteMemory siteMemory = GlobalMemory.getSiteMemory(orgId, siteId);
// if (siteMemory != null) {
// siteMemory.saveVehicleSystemMode(deviceId, data.getMode());
// }
// }
// }
CompletableFuture<Boolean> future = GlobalMemory.modeFutureMap.get(deviceId);

View File

@@ -1,6 +1,8 @@
package com.maibu.utils;
import io.minio.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -12,11 +14,10 @@ public class MinioUtil {
@Resource
private MinioClient minioClient;
private String defaultBucket = "mbzn";
private String endpoint = "https://oss.satabot.com"; // http://ip:port
@Value("${minio.endpoint}")
private String endpoint;
// 上传文件
public void uploadFile(String objectName, InputStream stream, String contentType) throws Exception {
@@ -32,8 +33,7 @@ public class MinioUtil {
.object(objectName)
.stream(stream, -1, 10485760)
.contentType(contentType)
.build()
);
.build());
}
// 返回 public URL
@@ -47,10 +47,6 @@ public class MinioUtil {
RemoveObjectArgs.builder()
.bucket(defaultBucket)
.object(objectName)
.build()
);
.build());
}
}

View File

@@ -1,5 +1,32 @@
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.fasterxml.jackson.core.type.TypeReference;
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.mapper.UAVDeviceMapper;
import com.maibu.service.ISysRoleService;
import com.maibu.uav.common.UAVConstant;
import com.maibu.uav.dto.*;
import com.maibu.uav.dto.CameraLiveParamDTO;
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.UavDeviceState;
import com.maibu.uav.utils.UavHttpUtils;
import com.maibu.utils.StringUtils;
import com.maibu.utils.json.JsonUtils;
import io.minio.MinioClient;
import io.minio.PutObjectArgs;
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 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
@Slf4j

View File

@@ -821,7 +821,7 @@ public class DeviceTaskService {
boolean result = true;
Integer controlMode = vehicleMessage.getControl_mode();
Integer systemCode = vehicleMessage.getSystemMode();
Integer systemCode = vehicleMessage.getSystem_mode();
// 控制模式不为0 同时不为2 不能操作 直接返回false
if (controlMode != 0) {
if (controlMode != 2) {