diff --git a/src/main/java/com/dji/sample/component/mqtt/config/InboundMessageRouter.java b/src/main/java/com/dji/sample/component/mqtt/config/InboundMessageRouter.java deleted file mode 100644 index 1b2bdf2..0000000 --- a/src/main/java/com/dji/sample/component/mqtt/config/InboundMessageRouter.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.dji.sample.component.mqtt.config; - -import com.dji.sample.component.mqtt.model.ChannelName; -import lombok.extern.slf4j.Slf4j; -import org.springframework.integration.annotation.Router; -import org.springframework.integration.mqtt.support.MqttHeaders; -import org.springframework.integration.router.AbstractMessageRouter; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.MessageHeaders; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.Collections; -import java.util.regex.Pattern; - -import static com.dji.sample.component.mqtt.model.TopicConst.*; - -/** - * - * @author sean.zhou - * @date 2021/11/10 - * @version 0.1 - */ -@Component -@Slf4j -public class InboundMessageRouter extends AbstractMessageRouter { - - @Resource(name = ChannelName.INBOUND) - private MessageChannel inboundChannel; - - @Resource(name = ChannelName.INBOUND_STATUS) - private MessageChannel statusChannel; - - @Resource(name = ChannelName.INBOUND_STATE) - private MessageChannel stateChannel; - - @Resource(name = ChannelName.DEFAULT) - private MessageChannel defaultChannel; - - @Resource(name = ChannelName.INBOUND_SERVICE_REPLY) - private MessageChannel serviceReplyChannel; - - @Resource(name = ChannelName.INBOUND_OSD) - private MessageChannel osdChannel; - - private static final Pattern PATTERN_TOPIC_STATUS = - Pattern.compile("^" + BASIC_PRE + PRODUCT + REGEX_SN + STATUS_SUF + "$"); - - private static final Pattern PATTERN_TOPIC_STATE = - Pattern.compile("^" + THING_MODEL_PRE + PRODUCT + REGEX_SN + STATE_SUF + "$"); - - private static final Pattern PATTERN_TOPIC_SERVICE_REPLY = - Pattern.compile("^" + THING_MODEL_PRE + PRODUCT + REGEX_SN + SERVICES_SUF + _REPLY_SUF + "$"); - - private static final Pattern PATTERN_TOPIC_OSD = - Pattern.compile("^" + THING_MODEL_PRE + PRODUCT + REGEX_SN + OSD_SUF); - - /** - * All mqtt broker messages will arrive here before distributing them to different channels. - * @param message message from mqtt broker - * @return channel - */ - @Override - @Router(inputChannel = ChannelName.INBOUND) - protected Collection determineTargetChannels(Message message) { - MessageHeaders headers = message.getHeaders(); - String topic = headers.get(MqttHeaders.RECEIVED_TOPIC).toString(); - byte[] payload = (byte[])message.getPayload(); - - // osd - if (PATTERN_TOPIC_OSD.matcher(topic).matches()) { - return Collections.singleton(osdChannel); - } - - log.debug("received topic :{} \t payload :{}", topic, new String(payload)); - - // status - if (PATTERN_TOPIC_STATUS.matcher(topic).matches()) { - return Collections.singleton(statusChannel); - } - - // state - if (PATTERN_TOPIC_STATE.matcher(topic).matches()) { - return Collections.singleton(stateChannel); - } - - // services_reply - if (PATTERN_TOPIC_SERVICE_REPLY.matcher(topic).matches()) { - return Collections.singleton(serviceReplyChannel); - } - return Collections.singleton(defaultChannel); - } -} diff --git a/src/main/java/com/dji/sample/component/mqtt/model/TopicStateReceiver.java b/src/main/java/com/dji/sample/component/mqtt/model/TopicStateReceiver.java deleted file mode 100644 index 522a4f8..0000000 --- a/src/main/java/com/dji/sample/component/mqtt/model/TopicStateReceiver.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.dji.sample.component.mqtt.model; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import lombok.Data; - -/** - * The data format of the state topic. - * @author sean.zhou - * @date 2021/11/17 - * @version 0.1 - */ -@Data -@JsonIgnoreProperties(ignoreUnknown = true) -public class TopicStateReceiver { - - private String tid; - - private String bid; - - private Long timestamp; - - /** - * The sn of the gateway device. - */ - private String gateway; - - private T data; - -} \ No newline at end of file diff --git a/src/main/java/com/dji/sample/component/oss/model/AliyunOSSConfiguration.java b/src/main/java/com/dji/sample/component/oss/model/AliyunOSSConfiguration.java deleted file mode 100644 index 98b5b0d..0000000 --- a/src/main/java/com/dji/sample/component/oss/model/AliyunOSSConfiguration.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.dji.sample.component.oss.model; - -import com.aliyun.oss.OSS; -import com.aliyun.oss.OSSClientBuilder; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Lazy; - -/** - * @author sean - * @version 0.2 - * @date 2021/12/9 - */ -@Configuration -public class AliyunOSSConfiguration { - - /** - * default - */ - public static final String PROVIDER = "ali"; - - /** - * Whether to use the current storage service. - */ - public static boolean enable; - - /** - * The protocol needs to be included at the beginning of the address. - */ - public static String endpoint; - - public static String accessKey; - - public static String secretKey; - - public static String region; - - public static Long expire; - - public static String roleSessionName; - - public static String roleArn; - - public static String bucket; - - public static String objectDirPrefix; - - @Value("${aliyun.oss.endpoint}") - private void setEndpoint(String endpoint) { - AliyunOSSConfiguration.endpoint = endpoint; - } - - @Value("${aliyun.oss.access-key}") - private void setAccessKey(String accessKey) { - AliyunOSSConfiguration.accessKey = accessKey; - } - - @Value("${aliyun.oss.secret-key}") - private void setSecretKey(String secretKey) { - AliyunOSSConfiguration.secretKey = secretKey; - } - - @Value("${aliyun.oss.region}") - private void setRegion(String region) { - AliyunOSSConfiguration.region = region; - } - - @Value("${aliyun.oss.expire: 3600}") - private void setExpire(Long expire) { - AliyunOSSConfiguration.expire = expire; - } - - @Value("${aliyun.oss.enable: false}") - private void setEnable(boolean enable) { - AliyunOSSConfiguration.enable = enable; - } - - @Value("${aliyun.oss.role-session-name}") - private void setRoleSessionName(String roleSessionName) { - AliyunOSSConfiguration.roleSessionName = roleSessionName; - } - - @Value("${aliyun.oss.role-arn}") - private void setRoleArn(String roleArn) { - AliyunOSSConfiguration.roleArn = roleArn; - } - - @Value("${aliyun.oss.bucket}") - private void setBucket(String bucket) { - AliyunOSSConfiguration.bucket = bucket; - } - - @Value("${aliyun.oss.object-dir-prefix: wayline}") - private void setObjectDir(String objectDirPrefix) { - AliyunOSSConfiguration.objectDirPrefix = objectDirPrefix; - } - - @Bean - @Lazy - public OSS ossClient() { - if (!enable) { - return null; - } - return new OSSClientBuilder().build(endpoint, accessKey, secretKey); - } -} diff --git a/src/main/java/com/dji/sample/component/oss/model/MinIOConfiguration.java b/src/main/java/com/dji/sample/component/oss/model/MinIOConfiguration.java deleted file mode 100644 index 1902320..0000000 --- a/src/main/java/com/dji/sample/component/oss/model/MinIOConfiguration.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.dji.sample.component.oss.model; - -import io.minio.MinioClient; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Lazy; -import org.springframework.util.StringUtils; - -/** - * @author sean - * @version 0.2 - * @date 2021/12/7 - */ -@Configuration -public class MinIOConfiguration { - - /** - * default - */ - public static final String PROVIDER = "aws"; - - /** - * Whether to use the current storage service. - */ - public static boolean enable; - - public static String endpoint; - - public static String accessKey; - - public static String secretKey; - - public static String region; - - public static String bucket; - - public static Integer expire; - - public static String objectDirPrefix; - - @Value("${minio.endpoint: http://localhost:9000/}") - private void setEndpoint(String endpoint) { - MinIOConfiguration.endpoint = endpoint; - } - - @Value("${minio.access-key: minioadmin}") - private void setAccessKey(String accessKey) { - MinIOConfiguration.accessKey = accessKey; - } - - @Value("${minio.secret-key: minioadmin}") - private void setSecretKey(String secretKey) { - MinIOConfiguration.secretKey = secretKey; - } - - @Value("${minio.region: }") - private void setRegion(String region) { - MinIOConfiguration.region = region; - } - - @Value("${minio.bucket: test}") - private void setBucket(String bucket) { - MinIOConfiguration.bucket = bucket; - } - - @Value("${minio.expire: 3600}") - private void setExpire(Integer expire) { - MinIOConfiguration.expire = expire; - } - - @Value("${minio.enable: false}") - private void setEnable(boolean enable) { - MinIOConfiguration.enable = enable; - } - - @Value("${minio.object-dir-prefix: wayline}") - private void setObjectDir(String objectDirPrefix) { - MinIOConfiguration.objectDirPrefix = objectDirPrefix; - } - - @Bean - @Lazy - public MinioClient minioClient() { - if (!enable) { - return null; - } - MinioClient.Builder builder = MinioClient.builder() - .endpoint(endpoint) - .credentials(accessKey, secretKey); - if (StringUtils.hasText(region)) { - builder.region(MinIOConfiguration.region); - } - return builder.build(); - } -} diff --git a/src/main/java/com/dji/sample/component/oss/model/enums/OssTypeEnum.java b/src/main/java/com/dji/sample/component/oss/model/enums/OssTypeEnum.java index 58e608c..4d69737 100644 --- a/src/main/java/com/dji/sample/component/oss/model/enums/OssTypeEnum.java +++ b/src/main/java/com/dji/sample/component/oss/model/enums/OssTypeEnum.java @@ -11,7 +11,7 @@ public enum OssTypeEnum { AWS("aws"), - /* + /* * MinIO is temporarily unavailable. */ MINIO("minio"); diff --git a/src/main/java/com/dji/sample/component/websocket/model/WebSocketManager.java b/src/main/java/com/dji/sample/component/websocket/model/WebSocketManager.java deleted file mode 100644 index da48ae1..0000000 --- a/src/main/java/com/dji/sample/component/websocket/model/WebSocketManager.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.dji.sample.component.websocket.model; - -import com.dji.sample.component.websocket.config.ConcurrentWebSocketSession; -import com.dji.sample.manage.model.enums.UserTypeEnum; -import lombok.extern.slf4j.Slf4j; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -/** - * Manage all WebSocket connection objects. - * @author sean.zhou - * @date 2021/11/16 - * @version 0.1 - */ -@Slf4j -public class WebSocketManager { - - private static final ConcurrentHashMap>> MANAGER = new ConcurrentHashMap<>(16); - - /** - * WebSocket connection from the pilot. - */ - private static final Set PILOT_SESSION = ConcurrentHashMap.newKeySet(16); - - /** - * WebSocket connection from the web. - */ - private static final Set WEB_SESSION = ConcurrentHashMap.newKeySet(16); - - public static void put(String key, ConcurrentWebSocketSession val) { - - String[] name = key.split("/"); - if (name.length != 3) { - log.debug("The key is out of format. [{workspaceId}/{userType}/{userId}]"); - return; - } - - ConcurrentHashMap> workspaceSessions = - MANAGER.getOrDefault(name[0], new ConcurrentHashMap<>(16)); - - ConcurrentHashMap userSessions = workspaceSessions.getOrDefault( - name[2], new ConcurrentHashMap<>(16)); - userSessions.put(val.getId(), val); - workspaceSessions.put(name[2], userSessions); - MANAGER.put(name[0], workspaceSessions); - - getSetByUserType(Integer.valueOf(name[1])).add(val); - - } - - public static void remove(String key, String sessionId) { - String[] name = key.split("/"); - if (name.length != 3) { - log.debug("The key is out of format. [{workspaceId}/{userType}/{userId}]"); - return; - } - ConcurrentHashMap userSession = MANAGER.get(name[0]).get(name[2]); - - Set typeSession = getSetByUserType(Integer.valueOf(name[1])); - - ConcurrentWebSocketSession session = userSession.get(sessionId); - typeSession.remove(session); - userSession.remove(sessionId); - } - - public static int getConnectedCount() { - return PILOT_SESSION.size() + WEB_SESSION.size(); - } - - public static Collection getValueWithWorkspace(String workspaceId) { - Set sessions = ConcurrentHashMap.newKeySet(); - - MANAGER.get(workspaceId) - .forEach((userId, userSessions) -> { - sessions.addAll(userSessions.values()); - }); - return sessions; - } - - public static Collection getValueWithWorkspaceAndUserType(String workspaceId, Integer userType) { - Set sessions = ConcurrentHashMap.newKeySet(); - Set typeSessions = getSetByUserType(userType); - - MANAGER.getOrDefault(workspaceId, new ConcurrentHashMap<>()) - .forEach((userId, userSessions) -> { - Collection sessionList = userSessions.values(); - if (!sessionList.isEmpty()) { - ConcurrentWebSocketSession session = sessionList.iterator().next(); - if (typeSessions.contains(session)) { - sessions.addAll(sessionList); - } - } - }); - return sessions; - } - - private static Set getSetByUserType(Integer userType) { - if (UserTypeEnum.PILOT.getVal() == userType) { - return PILOT_SESSION; - } - - if (UserTypeEnum.WEB.getVal() == userType) { - return WEB_SESSION; - } - return new HashSet<>(); - } -} \ No newline at end of file diff --git a/src/main/java/com/dji/sample/manage/dao/ICameraVideoMapper.java b/src/main/java/com/dji/sample/manage/dao/ICameraVideoMapper.java deleted file mode 100644 index 0784954..0000000 --- a/src/main/java/com/dji/sample/manage/dao/ICameraVideoMapper.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.dji.sample.manage.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.dji.sample.manage.model.entity.CameraVideoEntity; - -/** - * @author sean.zhou - * @version 0.1 - * @date 2021/11/19 - */ -public interface ICameraVideoMapper extends BaseMapper { -} diff --git a/src/main/java/com/dji/sample/manage/dao/ICapacityCameraMapper.java b/src/main/java/com/dji/sample/manage/dao/ICapacityCameraMapper.java deleted file mode 100644 index 777d6d0..0000000 --- a/src/main/java/com/dji/sample/manage/dao/ICapacityCameraMapper.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.dji.sample.manage.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.dji.sample.manage.model.entity.CapacityCameraEntity; - -/** - * @author sean.zhou - * @date 2021/11/19 - * @version 0.1 - */ -public interface ICapacityCameraMapper extends BaseMapper { -} diff --git a/src/main/java/com/dji/sample/manage/handler/AbstractStateTopicHandler.java b/src/main/java/com/dji/sample/manage/handler/AbstractStateTopicHandler.java deleted file mode 100644 index 5c51c42..0000000 --- a/src/main/java/com/dji/sample/manage/handler/AbstractStateTopicHandler.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.dji.sample.manage.handler; - -import com.dji.sample.component.mqtt.model.TopicStateReceiver; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.PropertyNamingStrategy; - -/** - * @author sean - * @version 0.3 - * @date 2022/2/21 - */ -public abstract class AbstractStateTopicHandler { - - protected AbstractStateTopicHandler handler; - protected static ObjectMapper mapper = new ObjectMapper();; - - protected AbstractStateTopicHandler(AbstractStateTopicHandler handler){ - this.handler = handler; - mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - } - - /** - * Passing dataNode data, using different processing methods depending on the data selection. - * @param dataNode - * @param stateReceiver - * @param sn - * @return - * @throws JsonProcessingException - */ - public abstract TopicStateReceiver handleState(JsonNode dataNode, TopicStateReceiver stateReceiver, String sn) throws JsonProcessingException; -} diff --git a/src/main/java/com/dji/sample/manage/handler/StateDefaultHandler.java b/src/main/java/com/dji/sample/manage/handler/StateDefaultHandler.java deleted file mode 100644 index 42140b6..0000000 --- a/src/main/java/com/dji/sample/manage/handler/StateDefaultHandler.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.dji.sample.manage.handler; - -import com.dji.sample.component.mqtt.model.TopicStateReceiver; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import org.springframework.stereotype.Service; - -/** - * @author sean - * @version 0.3 - * @date 2022/3/21 - */ -@Service -public class StateDefaultHandler extends AbstractStateTopicHandler { - - protected StateDefaultHandler() { - super(null); - } - - @Override - public TopicStateReceiver handleState(JsonNode dataNode, TopicStateReceiver stateReceiver, String sn) throws JsonProcessingException { - // If no suitable handler is found for the data, it is not processed. - return stateReceiver; - } -} diff --git a/src/main/java/com/dji/sample/manage/handler/StateDeviceBasicHandler.java b/src/main/java/com/dji/sample/manage/handler/StateDeviceBasicHandler.java deleted file mode 100644 index cb773eb..0000000 --- a/src/main/java/com/dji/sample/manage/handler/StateDeviceBasicHandler.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.dji.sample.manage.handler; - -import com.dji.sample.component.mqtt.model.TopicStateReceiver; -import com.dji.sample.manage.model.receiver.DeviceBasicReceiver; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -/** - * @author sean - * @version 0.3 - * @date 2022/2/21 - */ -@Service -public class StateDeviceBasicHandler extends AbstractStateTopicHandler { - - public StateDeviceBasicHandler(@Autowired @Qualifier("statePayloadHandler") AbstractStateTopicHandler handler) { - super(handler); - } - - @Override - public TopicStateReceiver handleState(JsonNode dataNode, TopicStateReceiver stateReceiver, String sn) throws JsonProcessingException { - // handle device basic data - if (dataNode.size() != 1) { - DeviceBasicReceiver data = mapper.treeToValue(dataNode, DeviceBasicReceiver.class); - data.setDeviceSn(sn); - stateReceiver.setData(data); - return stateReceiver; - } - return handler.handleState(dataNode, stateReceiver, sn); - } -} diff --git a/src/main/java/com/dji/sample/manage/handler/StateLiveCapacityHandler.java b/src/main/java/com/dji/sample/manage/handler/StateLiveCapacityHandler.java deleted file mode 100644 index 9e79d6d..0000000 --- a/src/main/java/com/dji/sample/manage/handler/StateLiveCapacityHandler.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.dji.sample.manage.handler; - -import com.dji.sample.component.mqtt.model.TopicStateReceiver; -import com.dji.sample.manage.model.enums.StateDataEnum; -import com.dji.sample.manage.model.receiver.CapacityDeviceReceiver; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -/** - * @author sean - * @version 0.3 - * @date 2022/2/21 - */ -@Service -public class StateLiveCapacityHandler extends AbstractStateTopicHandler { - - private static final String DEVICE_LIST = "device_list"; - - protected StateLiveCapacityHandler(@Autowired @Qualifier("stateDefaultHandler") AbstractStateTopicHandler handler) { - super(handler); - } - - @Override - public TopicStateReceiver handleState(JsonNode dataNode, TopicStateReceiver stateReceiver, String sn) throws JsonProcessingException { - String name = dataNode.fieldNames().next(); - JsonNode childNode = dataNode.findPath(name); - // Determine if it is live capacity data based on name. - if (name.equals(StateDataEnum.LIVE_CAPACITY.getDesc())) { - JsonNode deviceNode = childNode.findPath(DEVICE_LIST); - stateReceiver.setData( - mapper.treeToValue(deviceNode.get(0), CapacityDeviceReceiver.class)); - return stateReceiver; - } - return handler.handleState(dataNode, stateReceiver, sn); - } -} diff --git a/src/main/java/com/dji/sample/manage/handler/StatePayloadHandler.java b/src/main/java/com/dji/sample/manage/handler/StatePayloadHandler.java deleted file mode 100644 index a14e0d0..0000000 --- a/src/main/java/com/dji/sample/manage/handler/StatePayloadHandler.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.dji.sample.manage.handler; - -import com.dji.sample.component.mqtt.model.TopicStateReceiver; -import com.dji.sample.manage.model.enums.StateDataEnum; -import com.dji.sample.manage.model.receiver.DevicePayloadReceiver; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * @author sean - * @version 0.3 - * @date 2022/2/21 - */ -@Service -public class StatePayloadHandler extends AbstractStateTopicHandler { - - protected StatePayloadHandler(@Autowired @Qualifier("stateLiveCapacityHandler") AbstractStateTopicHandler handler) { - super(handler); - } - - @Override - public TopicStateReceiver handleState(JsonNode dataNode, TopicStateReceiver stateReceiver, String sn) throws JsonProcessingException { - String name = dataNode.fieldNames().next(); - JsonNode childNode = dataNode.findPath(name); - // Determine if it is payload data based on name. - if (name.equals(StateDataEnum.PAYLOADS.getDesc())) { - List payloadsList = new ArrayList<>(); - - Iterator payloadsNode = childNode.elements(); - while (payloadsNode.hasNext()) { - DevicePayloadReceiver payloadReceiver = mapper.treeToValue( - payloadsNode.next(), DevicePayloadReceiver.class); - payloadReceiver.setDeviceSn(sn); - payloadsList.add(payloadReceiver); - } - - if (payloadsList.isEmpty()) { - DevicePayloadReceiver payloadReceiver = new DevicePayloadReceiver(); - payloadReceiver.setDeviceSn(sn); - payloadsList.add(payloadReceiver); - } - - stateReceiver.setData(payloadsList); - return stateReceiver; - } - return handler.handleState(dataNode, stateReceiver, sn); - } -} diff --git a/src/main/java/com/dji/sample/manage/handler/StateRouter.java b/src/main/java/com/dji/sample/manage/handler/StateRouter.java deleted file mode 100644 index 3fe3404..0000000 --- a/src/main/java/com/dji/sample/manage/handler/StateRouter.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.dji.sample.manage.handler; - -import com.dji.sample.component.mqtt.model.ChannelName; -import com.dji.sample.component.mqtt.model.TopicStateReceiver; -import com.dji.sample.manage.model.receiver.CapacityDeviceReceiver; -import com.dji.sample.manage.model.receiver.DeviceBasicReceiver; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.integration.annotation.MessageEndpoint; -import org.springframework.integration.annotation.Router; -import org.springframework.integration.annotation.ServiceActivator; -import org.springframework.integration.mqtt.support.MqttHeaders; -import org.springframework.integration.router.MessageRouter; -import org.springframework.integration.router.PayloadTypeRouter; -import org.springframework.messaging.Message; - -import javax.annotation.Resource; -import java.io.IOException; -import java.util.List; -import java.util.Map; - -import static com.dji.sample.component.mqtt.model.TopicConst.*; - -/** - * - * @author sean.zhou - * @date 2021/11/17 - * @version 0.1 - */ -@MessageEndpoint -@Slf4j -@Configuration -public class StateRouter { - - @Resource(name = "stateDeviceBasicHandler") - private AbstractStateTopicHandler handler; - - /** - * Handles the routing of state topic messages. Depending on the data, it is assigned to different channels for handling. - * @param message - * @return - * @throws IOException - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE, outputChannel = ChannelName.INBOUND_STATE_SPLITTER) - public TopicStateReceiver resolveStateData(Message message) throws IOException { - byte[] payload = (byte[])message.getPayload(); - String topic = message.getHeaders().get(MqttHeaders.RECEIVED_TOPIC).toString(); - - ObjectMapper mapper = new ObjectMapper(); - mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - TopicStateReceiver stateReceiver = mapper.readValue(payload, TopicStateReceiver.class); - // Get the sn of the topic source. - String from = topic.substring((THING_MODEL_PRE + PRODUCT).length(), - topic.indexOf(STATE_SUF)); - - try { - JsonNode dataNode = mapper.readTree(payload).findPath("data"); - return handler.handleState(dataNode, stateReceiver, from); - - } catch (UnrecognizedPropertyException e) { - log.info("The {} data is not processed.", e.getPropertyName()); - } - return stateReceiver; - } - - @Bean - @Router(inputChannel = ChannelName.INBOUND_STATE_ROUTER) - public MessageRouter resolveStateRouter() { - PayloadTypeRouter router = new PayloadTypeRouter(); - // // Channel mapping for basic data. - router.setChannelMapping(DeviceBasicReceiver.class.getName(), - ChannelName.INBOUND_STATE_BASIC); - // Channel mapping for live streaming capabilities. - router.setChannelMapping(CapacityDeviceReceiver.class.getName(), - ChannelName.INBOUND_STATE_CAPACITY); - // Channel mapping for payload data. - router.setChannelMapping(List.class.getName(), - ChannelName.INBOUND_STATE_PAYLOAD); - router.setChannelMapping(Map.class.getName(), - ChannelName.DEFAULT); - return router; - } - -} \ No newline at end of file diff --git a/src/main/java/com/dji/sample/manage/handler/StateSplitter.java b/src/main/java/com/dji/sample/manage/handler/StateSplitter.java deleted file mode 100644 index e47fd53..0000000 --- a/src/main/java/com/dji/sample/manage/handler/StateSplitter.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.dji.sample.manage.handler; - -import com.dji.sample.component.mqtt.model.ChannelName; -import com.dji.sample.component.mqtt.model.TopicStateReceiver; -import com.dji.sample.manage.model.receiver.DevicePayloadReceiver; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.integration.annotation.MessageEndpoint; -import org.springframework.integration.annotation.Splitter; -import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; - -import java.util.ArrayList; -import java.util.Collection; - -/** - * - * @author sean.zhou - * @date 2021/11/17 - * @version 0.1 - */ -@MessageEndpoint -@Configuration -public class StateSplitter { - - /** - * Split the state message data to different channels for handling according to their different types. - * @param receiver state message - * @return - */ - @Splitter(inputChannel = ChannelName.INBOUND_STATE_SPLITTER, outputChannel = ChannelName.INBOUND_STATE_ROUTER) - public Collection splitState(TopicStateReceiver receiver) { - ArrayList type = new ArrayList<>(); - type.add(receiver.getData()); - return type; - } - - /** - * Split according to the different types in the list. - * @return - */ - @Bean - public IntegrationFlow splitList() { - return IntegrationFlows - .from(ChannelName.INBOUND_STATE_LIST) - .split() - . route(dataType -> { - Class clazz = dataType.getClass(); - if (DevicePayloadReceiver.class.isAssignableFrom(clazz)) { - return ChannelName.INBOUND_STATE_PAYLOAD; - } - return null; - }, mapping -> { - mapping.channelMapping(ChannelName.INBOUND_STATE_PAYLOAD, - ChannelName.INBOUND_STATE_PAYLOAD); - }) - .get(); - } -} \ No newline at end of file diff --git a/src/main/java/com/dji/sample/manage/handler/StatusRouter.java b/src/main/java/com/dji/sample/manage/handler/StatusRouter.java deleted file mode 100644 index 3fa6bc8..0000000 --- a/src/main/java/com/dji/sample/manage/handler/StatusRouter.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.dji.sample.manage.handler; - -import com.dji.sample.component.mqtt.model.ChannelName; -import com.dji.sample.component.mqtt.model.CommonTopicReceiver; -import com.dji.sample.manage.model.enums.DeviceDomainEnum; -import com.dji.sample.manage.model.receiver.StatusGatewayReceiver; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import org.springframework.integration.annotation.MessageEndpoint; -import org.springframework.integration.annotation.Router; -import org.springframework.integration.annotation.ServiceActivator; -import org.springframework.integration.mqtt.support.MqttHeaders; -import org.springframework.messaging.Message; -import org.springframework.util.CollectionUtils; - -import static com.dji.sample.component.mqtt.model.TopicConst.*; - -/** - * - * @author sean.zhou - * @date 2021/11/12 - * @version 0.1 - */ -@MessageEndpoint -public class StatusRouter { - - /** - * Converts the status data sent by the gateway device into an object. - * @param message - * @return - */ - @ServiceActivator(inputChannel = ChannelName.INBOUND_STATUS, outputChannel = ChannelName.INBOUND_STATUS_ROUTER) - public CommonTopicReceiver resolveStatus(Message message) { - - CommonTopicReceiver statusReceiver = new CommonTopicReceiver<>(); - ObjectMapper mapper = new ObjectMapper(); - mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE); - try { - statusReceiver = mapper.readValue( - (byte[])message.getPayload(), - new TypeReference>() {}); - - String topic = message.getHeaders().get(MqttHeaders.RECEIVED_TOPIC).toString(); - - // set gateway's domain - statusReceiver.getData().setDomain(DeviceDomainEnum.GATEWAY.getVal()); - // set gateway's sn - statusReceiver.getData().setSn( - topic.substring((BASIC_PRE + PRODUCT).length(), - topic.indexOf(STATUS_SUF))); - } catch (Exception e) { - e.printStackTrace(); - } - return statusReceiver; - } - - /** - * Handles the routing of status topic messages. Depending on the data, it is assigned to different channels for handling. - * @param receiver - * @return - */ - @Router(inputChannel = ChannelName.INBOUND_STATUS_ROUTER) - public String resolveStatusRouter(CommonTopicReceiver receiver) { - // Determine whether the drone is online or offline according to whether the data of the sub-device is empty. - return CollectionUtils.isEmpty(receiver.getData().getSubDevices()) ? - ChannelName.INBOUND_STATUS_OFFLINE : ChannelName.INBOUND_STATUS_ONLINE; - } - -} \ No newline at end of file diff --git a/src/main/java/com/dji/sample/manage/model/Chan.java b/src/main/java/com/dji/sample/manage/model/Chan.java deleted file mode 100644 index 5aa7961..0000000 --- a/src/main/java/com/dji/sample/manage/model/Chan.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.dji.sample.manage.model; - -import java.util.concurrent.locks.LockSupport; - -/** - * The demo is only for functional closure, which is not recommended. - * @author sean.zhou - * @date 2021/11/22 - * @version 0.1 - */ -public class Chan { - - private static final long THREAD_WAIT_TIME = 1000_000 * 500; - - private volatile T data; - - private volatile Thread t; - - private Chan () { - - } - - public static Chan getInstance() { - return ChanSingleton.INSTANCE; - } - - public T get(Object blocker) { - this.t = Thread.currentThread(); - LockSupport.parkNanos(blocker, THREAD_WAIT_TIME); - this.t = null; - return data; - } - - public void put(T data) { - this.data = data; - if (t == null) { - return; - } - LockSupport.unpark(t); - } - - private static class ChanSingleton { - private static final Chan INSTANCE = new Chan<>(); - } -} \ No newline at end of file diff --git a/src/main/java/com/dji/sample/manage/model/DeviceStatusManager.java b/src/main/java/com/dji/sample/manage/model/DeviceStatusManager.java deleted file mode 100644 index 2bc6960..0000000 --- a/src/main/java/com/dji/sample/manage/model/DeviceStatusManager.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.dji.sample.manage.model; - -import java.time.LocalDateTime; -import java.util.concurrent.ConcurrentHashMap; - -/** - * The demo is only for functional closure, which is not recommended, - * and it is recommended to use caching for handling. - * @author sean.zhou - * @version 0.1 - * @date 2021/11/25 - */ -public class DeviceStatusManager { - - public static final ConcurrentHashMap STATUS_MANAGER = - new ConcurrentHashMap<>(16); - - public static final Integer DEFAULT_ALIVE_SECOND = 30; - -} \ No newline at end of file diff --git a/src/main/java/com/dji/sample/manage/model/entity/CameraVideoEntity.java b/src/main/java/com/dji/sample/manage/model/entity/CameraVideoEntity.java deleted file mode 100644 index a2e7269..0000000 --- a/src/main/java/com/dji/sample/manage/model/entity/CameraVideoEntity.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.dji.sample.manage.model.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.io.Serializable; - -/** - * @author sean.zhou - * @date 2021/11/19 - * @version 0.1 - */ -@TableName(value = "manage_camera_video") -@Data -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class CameraVideoEntity implements Serializable { - - @TableId(type = IdType.AUTO) - private Integer id; - - @TableField(value = "camera_id") - private Integer cameraId; - - @TableField(value = "video_index") - private String videoIndex; - - @TableField(value = "video_type") - private String videoType; -} \ No newline at end of file diff --git a/src/main/java/com/dji/sample/manage/model/entity/CapacityCameraEntity.java b/src/main/java/com/dji/sample/manage/model/entity/CapacityCameraEntity.java deleted file mode 100644 index c57f496..0000000 --- a/src/main/java/com/dji/sample/manage/model/entity/CapacityCameraEntity.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.dji.sample.manage.model.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.io.Serializable; - -/** - * @author sean.zhou - * @date 2021/11/19 - * @version 0.1 - */ -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor -@TableName(value = "manage_capacity_camera") -public class CapacityCameraEntity implements Serializable { - - @TableId(type = IdType.AUTO) - private Integer id; - - @TableField(value = "device_sn") - private String deviceSn; - - @TableField(value = "name") - private String name; - - @TableField(value = "description") - private String description; - - @TableField(value = "camera_index") - private String cameraIndex; - - @TableField(value = "coexist_video_number_max") - private Integer coexistVideoNumberMax; - - @TableField(value = "available_video_number") - private Integer availableVideoNumber; -} \ No newline at end of file diff --git a/src/main/java/com/dji/sample/manage/model/enums/LiveMethodEnum.java b/src/main/java/com/dji/sample/manage/model/enums/LiveMethodEnum.java deleted file mode 100644 index eebe35c..0000000 --- a/src/main/java/com/dji/sample/manage/model/enums/LiveMethodEnum.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.dji.sample.manage.model.enums; - -/** - * @author sean.zhou - * @date 2021/11/22 - * @version 0.1 - */ -public enum LiveMethodEnum { - - LIVE_START_PUSH("live_start_push"), - - LIVE_STOP_PUSH("live_stop_push"), - - LIVE_SET_QUALITY("live_set_quality"), - - UNKNOWN("unknown"); - - private String method; - - LiveMethodEnum(String method) { - this.method = method; - } - - public String getMethod() { - return method; - } -} \ No newline at end of file diff --git a/src/main/java/com/dji/sample/manage/model/enums/StateDataEnum.java b/src/main/java/com/dji/sample/manage/model/enums/StateDataEnum.java deleted file mode 100644 index 5a93cf3..0000000 --- a/src/main/java/com/dji/sample/manage/model/enums/StateDataEnum.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.dji.sample.manage.model.enums; - -/** - * - * @author sean.zhou - * @date 2021/11/18 - * @version 0.1 - */ -public enum StateDataEnum { - - BATTERIES("batteries"), - - LIVE_CAPACITY("live_capacity"), - - PAYLOADS("payloads"); - - private String desc; - - StateDataEnum(String desc) { - this.desc = desc; - } - - public String getDesc() { - return this.desc; - } -} diff --git a/src/main/java/com/dji/sample/manage/model/receiver/RTKStateReceiver.java b/src/main/java/com/dji/sample/manage/model/receiver/RTKStateReceiver.java deleted file mode 100644 index c877c0c..0000000 --- a/src/main/java/com/dji/sample/manage/model/receiver/RTKStateReceiver.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.dji.sample.manage.model.receiver; - -import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import com.fasterxml.jackson.databind.annotation.JsonNaming; -import lombok.Data; - -/** - * @author sean.zhou - * @version 0.1 - * @date 2021/11/24 - */ -@Data -@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) -public class RTKStateReceiver { - - private Integer bdsNumber; - - private Integer galNumber; - - private Integer gloNumber; - - private Integer gpsNumber; - - private Boolean isFixed; - - private Integer quality; - -} \ No newline at end of file diff --git a/src/main/java/com/dji/sample/manage/model/receiver/ServiceReplyReceiver.java b/src/main/java/com/dji/sample/manage/model/receiver/ServiceReplyReceiver.java deleted file mode 100644 index ece269f..0000000 --- a/src/main/java/com/dji/sample/manage/model/receiver/ServiceReplyReceiver.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.dji.sample.manage.model.receiver; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import lombok.Data; - -/** - * @author sean.zhou - * @version 0.1 - * @date 2021/11/22 - */ -@Data -@JsonIgnoreProperties(ignoreUnknown = true) -public class ServiceReplyReceiver { - - private Integer result; - - private String info; -} \ No newline at end of file diff --git a/src/main/java/com/dji/sample/storage/service/impl/AliyunStorageServiceImpl.java b/src/main/java/com/dji/sample/storage/service/impl/AliyunStorageServiceImpl.java deleted file mode 100644 index 46366a5..0000000 --- a/src/main/java/com/dji/sample/storage/service/impl/AliyunStorageServiceImpl.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.dji.sample.storage.service.impl; - -import com.dji.sample.component.oss.model.AliyunOSSConfiguration; -import com.dji.sample.component.oss.service.impl.AliyunOssServiceImpl; -import com.dji.sample.media.model.StsCredentialsDTO; -import com.dji.sample.storage.service.IStorageService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -/** - * @author sean - * @version 0.3 - * @date 2022/3/9 - */ -@Service -public class AliyunStorageServiceImpl implements IStorageService { - - @Autowired - private AliyunOssServiceImpl ossService; - - @Override - public StsCredentialsDTO getSTSCredentials() { - return StsCredentialsDTO.builder() - .endpoint(AliyunOSSConfiguration.endpoint) - .bucket(AliyunOSSConfiguration.bucket) - .credentials(ossService.getCredentials()) - .provider(AliyunOSSConfiguration.PROVIDER) - .objectKeyPrefix(AliyunOSSConfiguration.objectDirPrefix) - .region(AliyunOSSConfiguration.region) - .build(); - } -} diff --git a/src/main/java/com/dji/sample/storage/service/impl/MinIOStorageServiceImpl.java b/src/main/java/com/dji/sample/storage/service/impl/MinIOStorageServiceImpl.java deleted file mode 100644 index b03e856..0000000 --- a/src/main/java/com/dji/sample/storage/service/impl/MinIOStorageServiceImpl.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.dji.sample.storage.service.impl; - -import com.dji.sample.component.oss.model.MinIOConfiguration; -import com.dji.sample.component.oss.service.impl.MinIOServiceImpl; -import com.dji.sample.media.model.StsCredentialsDTO; -import com.dji.sample.storage.service.IStorageService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -/** - * @author sean - * @version 0.3 - * @date 2021/12/31 - */ -@Service -public class MinIOStorageServiceImpl implements IStorageService { - - @Autowired - private MinIOServiceImpl ossService; - - @Override - public StsCredentialsDTO getSTSCredentials() { - return StsCredentialsDTO.builder() - .endpoint(MinIOConfiguration.endpoint) - .bucket(MinIOConfiguration.bucket) - .credentials(ossService.getCredentials()) - .provider(MinIOConfiguration.PROVIDER) - .objectKeyPrefix(MinIOConfiguration.objectDirPrefix) - .region(MinIOConfiguration.region) - .build(); - } - - -} diff --git a/src/main/java/com/dji/sample/wayline/model/WaylineFileDTO.java b/src/main/java/com/dji/sample/wayline/model/WaylineFileDTO.java deleted file mode 100644 index 9b044db..0000000 --- a/src/main/java/com/dji/sample/wayline/model/WaylineFileDTO.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.dji.sample.wayline.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.List; - -/** - * @author sean - * @version 0.3 - * @date 2021/12/22 - */ -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class WaylineFileDTO { - - private String name; - - @JsonProperty("id") - private String waylineId; - - private String droneModelKey; - - private List payloadModelKeys; - - private Boolean favorited; - - private List templateTypes; - - private String objectKey; - - @JsonProperty("user_name") - private String username; - - private Long updateTime; -} diff --git a/src/main/java/com/dji/sample/wayline/model/WaylineFileEntity.java b/src/main/java/com/dji/sample/wayline/model/WaylineFileEntity.java deleted file mode 100644 index 34295b3..0000000 --- a/src/main/java/com/dji/sample/wayline/model/WaylineFileEntity.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.dji.sample.wayline.model; - -import com.baomidou.mybatisplus.annotation.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * @author sean - * @version 0.3 - * @date 2021/12/22 - */ -@Data -@TableName("wayline_file") -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class WaylineFileEntity { - - @TableId(type = IdType.AUTO) - private Integer id; - - @TableField("name") - private String name; - - @TableField("wayline_id") - private String waylineId; - - @TableField("drone_model_key") - private String droneModelKey; - - @TableField("payload_model_keys") - private String payloadModelKeys; - - @TableField("workspace_id") - private String workspaceId; - - @TableField("favorited") - private Boolean favorited; - - @TableField("template_types") - private String templateTypes; - - @TableField("object_key") - private String objectKey; - - @TableField("user_name") - private String username; - - @TableField(value = "create_time", fill = FieldFill.INSERT) - private Long createTime; - - @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) - private Long updateTime; - -} diff --git a/src/main/java/com/dji/sample/wayline/model/WaylineFileUploadDTO.java b/src/main/java/com/dji/sample/wayline/model/WaylineFileUploadDTO.java deleted file mode 100644 index 53b7996..0000000 --- a/src/main/java/com/dji/sample/wayline/model/WaylineFileUploadDTO.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.dji.sample.wayline.model; - -import lombok.Data; - -/** - * @author sean - * @version 0.3 - * @date 2021/12/23 - */ -@Data -public class WaylineFileUploadDTO { - - private String objectKey; - - private String name; - - private WaylineFileDTO metadata; -} diff --git a/src/main/java/com/dji/sample/wayline/model/WaylineQueryParam.java b/src/main/java/com/dji/sample/wayline/model/WaylineQueryParam.java deleted file mode 100644 index 21db9fe..0000000 --- a/src/main/java/com/dji/sample/wayline/model/WaylineQueryParam.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.dji.sample.wayline.model; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * @author sean - * @version 0.3 - * @date 2021/12/22 - */ -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class WaylineQueryParam { - - private boolean favorited; - - @Builder.Default - private int page = 1; - - @Builder.Default - private int pageSize = 10; - - private String orderBy; - - private Integer[] templateType; -}