diff --git a/zlt-business/cloud-api-center/pom.xml b/zlt-business/cloud-api-center/pom.xml
deleted file mode 100644
index 61b4ff71..00000000
--- a/zlt-business/cloud-api-center/pom.xml
+++ /dev/null
@@ -1,163 +0,0 @@
-
-
- 4.0.0
-
- com.zlt
- zlt-business
- 6.0.0
-
-
- cloud-api-center
-
-
-
- com.dji
- cloud-sdk
- ${dji-cloud-sdk.version}
-
-
- com.zlt
- zlt-config
-
-
- com.zlt
- zlt-log-spring-boot-starter
-
-
- com.zlt
- zlt-common-spring-boot-starter
-
-
- com.zlt
- zlt-db-spring-boot-starter
-
-
-
- com.zlt
- zlt-loadbalancer-spring-boot-starter
-
-
- com.zlt
- zlt-sentinel-spring-boot-starter
-
-
-
- com.github.xiaoymin
- knife4j-openapi3-jakarta-spring-boot-starter
-
-
- com.alibaba.cloud
- spring-cloud-starter-alibaba-nacos-discovery
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- org.springframework.boot
- spring-boot-starter-actuator
-
-
- commons-io
- commons-io
-
-
- mysql
- mysql-connector-java
-
-
- org.projectlombok
- lombok
- true
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
- org.apache.velocity
- velocity
-
-
- org.apache.commons
- commons-configuration2
-
-
-
- io.micrometer
- micrometer-registry-prometheus
-
-
- commons-configuration
- commons-configuration
-
-
-
- com.squareup.okhttp3
- okhttp
- ${okhttp3.version}
-
-
-
- javax.xml.bind
- jaxb-api
- ${javax-jaxb.version}
-
-
-
-
- org.glassfish.jaxb
- jaxb-runtime
- ${glassfish-jaxb.version}
-
-
-
- org.springframework.boot
- spring-boot-starter-data-redis
-
-
- org.apache.commons
- commons-pool2
-
-
-
- com.amazonaws
- aws-java-sdk-s3
- 1.12.261
-
-
- com.amazonaws
- aws-java-sdk-sts
- 1.12.261
-
-
-
- org.dom4j
- dom4j
- 2.1.3
-
-
-
- jaxen
- jaxen
-
-
-
- org.bouncycastle
- bcpkix-jdk15on
- 1.69
-
-
-
- org.apache.tomcat.embed
- tomcat-embed-core
- 9.0.75
- provided
-
-
-
-
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/CloudApiSampleApplication.java b/zlt-business/cloud-api-center/src/main/java/com/central/CloudApiSampleApplication.java
deleted file mode 100644
index 93acc04b..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/CloudApiSampleApplication.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.central;
-
-import org.mybatis.spring.annotation.MapperScan;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.scheduling.annotation.EnableScheduling;
-
-@MapperScan("com.central.cloud.*.dao")
-@SpringBootApplication
-@EnableScheduling
-@ComponentScan("com.dji")
-public class CloudApiSampleApplication {
-
- public static void main(String[] args) {
- SpringApplication.run(CloudApiSampleApplication.class, args);
- }
-
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/Main.java b/zlt-business/cloud-api-center/src/main/java/com/central/Main.java
deleted file mode 100644
index 85ca400f..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/Main.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.central;
-
-//TIP To Run code, press or
-// click the icon in the gutter.
-public class Main {
- public static void main(String[] args) {
- //TIP Press with your caret at the highlighted text
- // to see how IntelliJ IDEA suggests fixing it.
- System.out.printf("Hello and welcome!");
-
- for (int i = 1; i <= 5; i++) {
- //TIP Press to start debugging your code. We have set one breakpoint
- // for you, but you can always add more by pressing .
- System.out.println("i = " + i);
- }
- }
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/common/error/CommonErrorEnum.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/common/error/CommonErrorEnum.java
deleted file mode 100644
index 66fe8942..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/common/error/CommonErrorEnum.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.central.cloud.common.error;
-
-import com.dji.sdk.common.IErrorInfo;
-
-/**
- * @author sean.zhou
- * @version 0.1
- * @date 2021/11/25
- */
-public enum CommonErrorEnum implements IErrorInfo {
-
- ILLEGAL_ARGUMENT(200001, "illegal argument"),
-
- REDIS_DATA_NOT_FOUND(201404, "Redis data does not exist."),
-
- DEVICE_OFFLINE(212015, "Device is offline."),
-
- GET_ORGANIZATION_FAILED(210230, "Failed to get organization."),
-
- DEVICE_BINDING_FAILED(210231, "Failed to bind device."),
-
- NON_REPEATABLE_BINDING(210232, "The device has been bound to another organization and can't be bound repeatedly."),
-
- GET_DEVICE_BINDING_STATUS_FAILED(210233, "Failed to get device binding status."),
-
- SYSTEM_ERROR(600500, "system error"),
-
- SECRET_INVALID(600100, "secret invalid"),
-
- NO_TOKEN(600101, "token is null"),
-
- TOKEN_EXPIRED(600102, "token is expired"),
-
- TOKEN_INVALID(600103, "token invalid"),
-
- SIGN_INVALID(600104, "sign invalid");
-
- private String msg;
-
- private int code;
-
- CommonErrorEnum(int code, String msg) {
- this.code = code;
- this.msg = msg;
- }
-
- @Override
- public String getMessage() {
- return this.msg;
- }
-
- @Override
- public Integer getCode() {
- return this.code;
- }
-
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/common/model/CustomClaim.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/common/model/CustomClaim.java
deleted file mode 100644
index f61dc301..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/common/model/CustomClaim.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package com.central.cloud.common.model;
-
-import com.auth0.jwt.interfaces.Claim;
-import com.fasterxml.jackson.annotation.JsonAlias;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-
-import java.lang.reflect.Field;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * A custom claim for storing custom information in the token.
- * @author sean.zhou
- * @date 2021/11/16
- * @version 0.1
- */
-@AllArgsConstructor
-@NoArgsConstructor
-@Data
-@Slf4j
-public class CustomClaim {
-
- /**
- * The id of the account.
- */
- private String id;
-
- private String username;
-
- @JsonAlias("user_type")
- private Integer userType;
-
- @JsonAlias("workspace_id")
- private String workspaceId;
-
- /**
- * Convert the custom claim data type to the Map type.
- * @return map
- */
- public ConcurrentHashMap convertToMap() {
- ConcurrentHashMap map = new ConcurrentHashMap<>(4);
- try {
- Field[] declaredFields = this.getClass().getDeclaredFields();
- for (Field field : declaredFields) {
- JsonAlias annotation = field.getAnnotation(JsonAlias.class);
- field.setAccessible(true);
- // The value of key is named underscore.
- map.put(annotation != null ? annotation.value()[0] : field.getName(),
- field.get(this).toString());
- }
- } catch (IllegalAccessException e) {
- log.info("CustomClaim converts failed. {}", this.toString());
- e.printStackTrace();
- }
- return map;
- }
-
- /**
- * Convert the data in Map into a custom claim object.
- * @param claimMap
- */
- public CustomClaim (Map claimMap) {
- Field[] declaredFields = this.getClass().getDeclaredFields();
- for (Field field : declaredFields) {
- field.setAccessible(true);
- JsonAlias annotation = field.getAnnotation(JsonAlias.class);
-
- Claim value = claimMap.get(annotation == null ? field.getName() : annotation.value()[0]);
- try {
- Class> type = field.getType();
- if (Integer.class.equals(type)) {
- field.set(this, Integer.valueOf(value.asString()));
- continue;
- }
- if (String.class.equals(type)) {
- field.set(this, value.asString());
- continue;
- }
- } catch (IllegalAccessException e) {
- log.info("Claim parses failed. {}", claimMap.toString());
- e.printStackTrace();
- }
- }
- }
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/common/util/JwtUtil.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/common/util/JwtUtil.java
deleted file mode 100644
index b84f8e59..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/common/util/JwtUtil.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package com.central.cloud.common.util;
-
-import com.auth0.jwt.JWT;
-import com.auth0.jwt.JWTCreator;
-import com.auth0.jwt.algorithms.Algorithm;
-import com.auth0.jwt.exceptions.TokenExpiredException;
-import com.auth0.jwt.interfaces.DecodedJWT;
-import com.central.cloud.common.model.CustomClaim;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-import org.springframework.util.StringUtils;
-
-import java.util.*;
-
-@Slf4j
-@Component
-public class JwtUtil {
-
- private static String issuer;
-
- private static String subject;
-
- private static long age;
-
- private static String secret;
-
- public static Algorithm algorithm;
-
- @Value("${jwt.issuer: DJI}")
- private void setIssuer(String issuer) {
- JwtUtil.issuer = issuer;
- }
-
- @Value("${jwt.subject: CloudApiSample}")
- private void setSubject(String subject) {
- JwtUtil.subject = subject;
- }
-
- @Value("${jwt.age: 86400}")
- private void setAge(long age) {
- JwtUtil.age = age * 1000;
- }
-
- @Value("${jwt.secret: CloudApiSample}")
- private void setSecret(String secret) {
- JwtUtil.secret = secret;
- setAlgorithm();
- }
-
- private void setAlgorithm() {
- JwtUtil.algorithm = Algorithm.HMAC256(secret);
- }
-
- private JwtUtil() {
-
- }
-
- /**
- * Create a token based on custom information.
- * @param claims custom information
- * @return token
- */
- public static String createToken(Map claims) {
- return JwtUtil.createToken(claims, age, algorithm, subject, issuer);
- }
-
- /**
- *
- * @param claims
- * @param age unit: s
- * @param algorithm
- * @param subject
- * @param issuer
- * @return
- */
- public static String createToken(Map claims, Long age, Algorithm algorithm, String subject, String issuer) {
- if (Objects.isNull(algorithm)) {
- throw new IllegalArgumentException();
- }
-
- Date now = new Date();
- JWTCreator.Builder builder = JWT.create();
- // Add custom information to the token's payload segment.
- claims.forEach((k, v) -> {
- if (Objects.nonNull(v.getClass().getClassLoader())) {
- log.error("claim can't be set to a custom object.");
- return;
- }
- if (v instanceof Map) {
- builder.withClaim(k, (Map) v);
- } else if (v instanceof List) {
- builder.withClaim(k, (List) v);
- } else {
- builder.withClaim(k, String.valueOf(v));
- }
- });
-
- if (StringUtils.hasText(subject)) {
- builder.withSubject(subject);
- }
-
- if (StringUtils.hasText(issuer)) {
- builder.withIssuer(issuer);
- }
-
- if (Objects.nonNull(age)) {
- builder.withExpiresAt(new Date(now.getTime() + age));
- }
-
- String token = builder
- .withIssuedAt(now)
- .withNotBefore(now)
- .sign(algorithm);
- log.debug("token created. " + token);
- return token;
- }
-
- /**
- * Verify that the token is valid.
- * @param token
- * @return
- * @throws TokenExpiredException
- */
- public static DecodedJWT verifyToken(String token) {
- return JWT.require(algorithm).build().verify(token);
- }
-
- /**
- * Parses the custom information in the token into a CustomClaim object.
- * @param token
- * @return custom claim
- */
- public static Optional parseToken(String token) {
- DecodedJWT jwt;
- try {
- jwt = verifyToken(token);
- } catch (Exception e) {
- e.printStackTrace();
- return Optional.empty();
- }
- return Optional.of(new CustomClaim(jwt.getClaims()));
- }
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/common/util/SpringBeanUtilsTest.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/common/util/SpringBeanUtilsTest.java
deleted file mode 100644
index cc241e73..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/common/util/SpringBeanUtilsTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.central.cloud.common.util;
-
-import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.stereotype.Component;
-
-/**
- * @author sean
- * @version 1.3
- * @date 2022/11/10
- */
-@Component
-public class SpringBeanUtilsTest implements ApplicationContextAware {
-
- private static ApplicationContext applicationContext;
-
- @Override
- public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
- SpringBeanUtilsTest.applicationContext = applicationContext;
- }
-
- public static T getBean(Class clazz) {
- return applicationContext.getBean(clazz);
- }
-
- public static Object getBean(String beanName) {
- return applicationContext.getBean(beanName);
- }
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/ApplicationBootInitial.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/ApplicationBootInitial.java
deleted file mode 100644
index 50dfd18a..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/ApplicationBootInitial.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.central.cloud.component;
-
-import com.central.cloud.component.redis.RedisConst;
-import com.central.cloud.component.redis.RedisOpsUtils;
-import com.central.cloud.manage.model.dto.DeviceDTO;
-import com.central.cloud.manage.service.IDeviceRedisService;
-import com.central.cloud.manage.service.IDeviceService;
-import com.dji.sdk.cloudapi.device.DeviceDomainEnum;
-import com.dji.sdk.common.SDKManager;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.CommandLineRunner;
-import org.springframework.stereotype.Component;
-
-import java.util.Optional;
-
-/**
- * @author sean.zhou
- * @date 2021/11/24
- * @version 0.1
- */
-@Component
-public class ApplicationBootInitial implements CommandLineRunner {
-
- @Autowired
- private IDeviceService deviceService;
-
- @Autowired
- private IDeviceRedisService deviceRedisService;
-
- /**
- * Subscribe to the devices that exist in the redis when the program starts,
- * to prevent the data from being different from the pilot side due to program interruptions.
- * @param args
- * @throws Exception
- */
- @Override
- public void run(String... args) throws Exception {
- int start = RedisConst.DEVICE_ONLINE_PREFIX.length();
-
- RedisOpsUtils.getAllKeys(RedisConst.DEVICE_ONLINE_PREFIX + "*")
- .stream()
- .map(key -> key.substring(start))
- .map(deviceRedisService::getDeviceOnline)
- .map(Optional::get)
- .filter(device -> DeviceDomainEnum.DRONE != device.getDomain())
- .forEach(device -> deviceService.subDeviceOnlineSubscribeTopic(
- SDKManager.registerDevice(device.getDeviceSn(), device.getChildDeviceSn(), device.getDomain(),
- device.getType(), device.getSubType(), device.getThingVersion(),
- deviceRedisService.getDeviceOnline(device.getChildDeviceSn()).map(DeviceDTO::getThingVersion).orElse(null))));
-
- }
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/AuthInterceptor.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/AuthInterceptor.java
deleted file mode 100644
index cbf1baf1..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/AuthInterceptor.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package com.central.cloud.component;
-
-import com.central.cloud.common.error.CommonErrorEnum;
-import com.central.cloud.common.model.CustomClaim;
-import com.central.cloud.common.util.JwtUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.stereotype.Component;
-import org.springframework.util.StringUtils;
-import org.springframework.web.servlet.HandlerInterceptor;
-import org.springframework.web.servlet.ModelAndView;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.util.Optional;
-
-@Slf4j
-@Component
-public class AuthInterceptor implements HandlerInterceptor {
-
- public static final String PARAM_TOKEN = "x-auth-token";
-
- public static final String TOKEN_CLAIM = "customClaim";
-
- public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
- String uri = request.getRequestURI();
- log.debug("request uri: {}, IP: {}", uri, request.getRemoteAddr());
- // The options method is passed directly.
- if (HttpMethod.OPTIONS.matches(request.getMethod())) {
- response.setStatus(HttpStatus.OK.value());
- return false;
- }
- String token = request.getHeader(PARAM_TOKEN);
- // Check if the token exists.
- if (!StringUtils.hasText(token)) {
- response.setStatus(HttpStatus.UNAUTHORIZED.value());
- log.error(CommonErrorEnum.NO_TOKEN.getMessage());
- return false;
- }
-
- // Check if the current token is valid.
- Optional customClaimOpt = JwtUtil.parseToken(token);
- if (customClaimOpt.isEmpty()) {
- response.setStatus(HttpStatus.UNAUTHORIZED.value());
- return false;
- }
-
- // Put the custom data from the token into the request.
- request.setAttribute(TOKEN_CLAIM, customClaimOpt.get());
- return true;
- }
-
- public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
- // Delete the custom data in the request after the request ends.
- request.removeAttribute(TOKEN_CLAIM);
- }
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/CorsFilter.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/CorsFilter.java
deleted file mode 100644
index 19243cef..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/CorsFilter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.central.cloud.component;
-
-import org.springframework.stereotype.Component;
-
-import javax.servlet.*;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-import static com.central.cloud.component.AuthInterceptor.PARAM_TOKEN;
-
-/**
- * @author sean.zhou
- * @version 0.1
- * @date 2021/11/22
- */
-@Component
-public class CorsFilter implements Filter {
-
- @Override
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
- HttpServletResponse res = (HttpServletResponse) response;
- res.addHeader("Access-Control-Allow-Credentials", "true");
- res.addHeader("Access-Control-Allow-Origin", "*");
- res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
- res.addHeader("Access-Control-Allow-Headers", "Access-Control-Allow-Headers," +
- "Authorization, Content-Length, X-CSRF-Token, Token,session,X_Requested_With,Accept, "+
- "Origin, Host, Connection, Accept-Encoding, Accept-Language,DNT, X-CustomHeader, Keep-Alive," +
- " User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Pragma," + PARAM_TOKEN);
- if (((HttpServletRequest) request).getMethod().equals("OPTIONS")) {
- return;
- }
- filterChain.doFilter(request, response);
- }
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/GlobalExceptionHandler.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/GlobalExceptionHandler.java
deleted file mode 100644
index f1547235..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/GlobalExceptionHandler.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.central.cloud.component;
-
-import com.dji.sdk.common.HttpResultResponse;
-import org.springframework.validation.BindException;
-import org.springframework.web.bind.MethodArgumentNotValidException;
-import org.springframework.web.bind.annotation.ControllerAdvice;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-/**
- * @author sean
- * @version 0.2
- * @date 2021/12/1
- */
-@ControllerAdvice
-@ResponseBody
-public class GlobalExceptionHandler {
-
- /**
- * Please do not return directly like this, there is a risk.
- * @param e
- * @return
- */
- @ExceptionHandler(Exception.class)
- public HttpResultResponse exceptionHandler(Exception e) {
- e.printStackTrace();
- return HttpResultResponse.error(e.getLocalizedMessage());
- }
-
- @ExceptionHandler(NullPointerException.class)
- public HttpResultResponse nullPointerExceptionHandler(NullPointerException e) {
- e.printStackTrace();
- return HttpResultResponse.error("A null object appeared.");
- }
-
- @ExceptionHandler({MethodArgumentNotValidException.class, BindException.class})
- public HttpResultResponse methodArgumentNotValidExceptionHandler(BindException e) {
- e.printStackTrace();
- return HttpResultResponse.error(e.getFieldError().getField() + e.getFieldError().getDefaultMessage());
- }
-
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/GlobalScheduleService.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/GlobalScheduleService.java
deleted file mode 100644
index 7f01f896..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/GlobalScheduleService.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package com.central.cloud.component;
-
-import com.central.cloud.component.redis.RedisConst;
-import com.central.cloud.component.redis.RedisOpsUtils;
-import com.central.cloud.manage.model.dto.DeviceDTO;
-import com.central.cloud.manage.service.IDeviceService;
-import com.dji.sdk.cloudapi.device.DeviceDomainEnum;
-import com.dji.sdk.mqtt.IMqttTopicService;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-
-import java.util.Arrays;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @author sean.zhou
- * @date 2021/11/24
- * @version 0.1
- */
-@Component
-@Slf4j
-public class GlobalScheduleService {
-
- @Autowired
- private IDeviceService deviceService;
-
- @Autowired
- private IMqttTopicService topicService;
-
- @Autowired
- private ObjectMapper mapper;
- /**
- * Check the status of the devices every 30 seconds. It is recommended to use cache.
- */
- @Scheduled(initialDelay = 10, fixedRate = 30, timeUnit = TimeUnit.SECONDS)
- private void deviceStatusListen() {
- int start = RedisConst.DEVICE_ONLINE_PREFIX.length();
-
- RedisOpsUtils.getAllKeys(RedisConst.DEVICE_ONLINE_PREFIX + "*").forEach(key -> {
- long expire = RedisOpsUtils.getExpire(key);
- if (expire <= 30) {
- DeviceDTO device = (DeviceDTO) RedisOpsUtils.get(key);
- if (null == device) {
- return;
- }
- if (DeviceDomainEnum.DRONE == device.getDomain()) {
- deviceService.subDeviceOffline(key.substring(start));
- } else {
- deviceService.gatewayOffline(key.substring(start));
- }
- RedisOpsUtils.del(key);
- }
- });
-
- log.info("Subscriptions: {}", Arrays.toString(topicService.getSubscribedTopic()));
- }
-
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mqtt/config/MqttMessageChannel.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mqtt/config/MqttMessageChannel.java
deleted file mode 100644
index 75590ee4..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mqtt/config/MqttMessageChannel.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package com.central.cloud.component.mqtt.config;
-
-import com.dji.sdk.mqtt.ChannelName;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.integration.channel.DirectChannel;
-import org.springframework.integration.channel.ExecutorChannel;
-import org.springframework.messaging.MessageChannel;
-
-import java.util.concurrent.Executor;
-
-/**
- * Definition classes for all channels
- * @author sean.zhou
- * @date 2021/11/10
- * @version 0.1
- */
-@Configuration
-public class MqttMessageChannel {
-
- @Autowired
- private Executor threadPool;
-
- @Bean(name = ChannelName.INBOUND)
- public MessageChannel inboundChannel() {
- return new ExecutorChannel(threadPool);
- }
-
- @Bean(name = ChannelName.DEFAULT)
- public MessageChannel defaultChannel() {
- return new DirectChannel();
- }
-
- @Bean(name = ChannelName.INBOUND_STATUS)
- public MessageChannel statusChannel() {
- return new DirectChannel();
- }
-
- @Bean(name = ChannelName.INBOUND_STATE)
- public MessageChannel stateChannel() {
- return new DirectChannel();
- }
-
- @Bean(name = ChannelName.INBOUND_SERVICES_REPLY)
- public MessageChannel serviceReplyChannel() {
- return new DirectChannel();
- }
-
- @Bean(name = ChannelName.INBOUND_OSD)
- public MessageChannel osdChannel() {
- return new ExecutorChannel(threadPool);
- }
-
- @Bean(name = ChannelName.INBOUND_REQUESTS)
- public MessageChannel requestsChannel() {
- return new DirectChannel();
- }
-
- @Bean(name = ChannelName.INBOUND_EVENTS)
- public MessageChannel eventsChannel() {
- return new DirectChannel();
- }
-
- @Bean(name = ChannelName.INBOUND_PROPERTY_SET_REPLY)
- public MessageChannel propertySetReply() {
- return new DirectChannel();
- }
-
- @Bean(name = ChannelName.INBOUND_DRC_UP)
- public MessageChannel drcUp() {
- return new DirectChannel();
- }
-
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mqtt/config/MqttPropertyConfiguration.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mqtt/config/MqttPropertyConfiguration.java
deleted file mode 100644
index b86a2660..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mqtt/config/MqttPropertyConfiguration.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package com.central.cloud.component.mqtt.config;
-
-import com.auth0.jwt.algorithms.Algorithm;
-import com.central.cloud.common.util.JwtUtil;
-import com.central.cloud.component.mqtt.model.MqttClientOptions;
-import com.central.cloud.component.mqtt.model.MqttProtocolEnum;
-import com.central.cloud.component.mqtt.model.MqttUseEnum;
-import com.dji.sdk.cloudapi.control.DrcModeMqttBroker;
-import lombok.Data;
-import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory;
-import org.springframework.integration.mqtt.core.MqttPahoClientFactory;
-import org.springframework.util.StringUtils;
-
-import java.util.Map;
-
-/**
- *
- * @author sean.zhou
- * @date 2021/11/10
- * @version 0.1
- */
-@Configuration
-@Data
-@ConfigurationProperties
-public class MqttPropertyConfiguration {
-
- private static Map mqtt;
-
- public void setMqtt(Map mqtt) {
- MqttPropertyConfiguration.mqtt = mqtt;
- }
-
- /**
- * Get the configuration options of the basic link of the mqtt client.
- * @return
- */
- static MqttClientOptions getBasicClientOptions() {
- if (!mqtt.containsKey(MqttUseEnum.BASIC)) {
- throw new Error("Please configure the basic mqtt connection parameters first, otherwise application cannot be started.");
- }
- return mqtt.get(MqttUseEnum.BASIC);
- }
-
- /**
- * Get the mqtt address of the basic link.
- * @return
- */
- public static String getBasicMqttAddress() {
- return getMqttAddress(getBasicClientOptions());
- }
-
- /**
- * Splice the mqtt address according to the parameters of different clients.
- * @param options
- * @return
- */
- private static String getMqttAddress(MqttClientOptions options) {
- StringBuilder addr = new StringBuilder()
- .append(options.getProtocol().getProtocolAddr())
- .append(options.getHost().trim())
- .append(":")
- .append(options.getPort());
- if ((options.getProtocol() == MqttProtocolEnum.WS || options.getProtocol() == MqttProtocolEnum.WSS)
- && StringUtils.hasText(options.getPath())) {
- addr.append(options.getPath());
- }
- return addr.toString();
- }
-
- /**
- * Get the connection parameters of the mqtt client of the drc link.
- * @param clientId
- * @param username
- * @param age The validity period of the token. unit: s
- * @param map Custom data added in token.
- * @return
- */
- public static DrcModeMqttBroker getMqttBrokerWithDrc(String clientId, String username, Long age, Map map) {
- if (!mqtt.containsKey(MqttUseEnum.DRC)) {
- throw new RuntimeException("Please configure the drc link parameters of mqtt in the backend configuration file first.");
- }
- Algorithm algorithm = JwtUtil.algorithm;
-
- String token = JwtUtil.createToken(map, age, algorithm, null, null);
-
- return new DrcModeMqttBroker()
- .setAddress(getMqttAddress(mqtt.get(MqttUseEnum.DRC)))
- .setUsername(username)
- .setClientId(clientId)
- .setExpireTime(System.currentTimeMillis() / 1000 + age)
- .setPassword(token)
- .setEnableTls(false);
- }
-
-
- @Bean
- public MqttConnectOptions mqttConnectOptions() {
- MqttClientOptions customizeOptions = getBasicClientOptions();
- MqttConnectOptions mqttConnectOptions = new MqttConnectOptions();
- mqttConnectOptions.setServerURIs(new String[]{ getBasicMqttAddress() });
- mqttConnectOptions.setUserName(customizeOptions.getUsername());
- mqttConnectOptions.setPassword(StringUtils.hasText(customizeOptions.getPassword()) ?
- customizeOptions.getPassword().toCharArray() : new char[0]);
- mqttConnectOptions.setAutomaticReconnect(true);
- mqttConnectOptions.setKeepAliveInterval(10);
- return mqttConnectOptions;
- }
-
- @Bean
- public MqttPahoClientFactory mqttClientFactory() {
- DefaultMqttPahoClientFactory factory = new DefaultMqttPahoClientFactory();
- factory.setConnectionOptions(mqttConnectOptions());
- return factory;
- }
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mqtt/model/EventsReceiver.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mqtt/model/EventsReceiver.java
deleted file mode 100644
index 91b0a885..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mqtt/model/EventsReceiver.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package com.central.cloud.component.mqtt.model;
-
-import com.dji.sdk.mqtt.events.EventsDataRequest;
-import com.dji.sdk.mqtt.events.EventsErrorCode;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import lombok.*;
-
-/**
- * @author sean
- * @version 1.1
- * @date 2022/6/9
- */
-@EqualsAndHashCode(callSuper = true)
-@Data
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Builder
-@NoArgsConstructor
-@AllArgsConstructor
-public class EventsReceiver extends EventsDataRequest {
-
- private String bid;
-
- private String sn;
-
- @Override
- public EventsErrorCode getResult() {
- return super.getResult();
- }
-
- @Override
- public EventsReceiver setResult(EventsErrorCode result) {
- super.setResult(result);
- return this;
- }
-
- @Override
- public T getOutput() {
- return super.getOutput();
- }
-
- @Override
- public EventsReceiver setOutput(T output) {
- super.setOutput(output);
- return this;
- }
-
- public String getBid() {
- return bid;
- }
-
- public EventsReceiver setBid(String bid) {
- this.bid = bid;
- return this;
- }
-
- public String getSn() {
- return sn;
- }
-
- public EventsReceiver setSn(String sn) {
- this.sn = sn;
- return this;
- }
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mqtt/model/MapKeyConst.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mqtt/model/MapKeyConst.java
deleted file mode 100644
index dafb033a..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mqtt/model/MapKeyConst.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.central.cloud.component.mqtt.model;
-
-/**
- * @author sean
- * @version 1.1
- * @date 2022/6/14
- */
-public final class MapKeyConst {
-
- private MapKeyConst(){
-
- }
-
- public static final String ACL = "acl";
-
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mqtt/model/MqttClientOptions.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mqtt/model/MqttClientOptions.java
deleted file mode 100644
index b9234cfd..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mqtt/model/MqttClientOptions.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.central.cloud.component.mqtt.model;
-
-import lombok.Data;
-
-/**
- * @author sean
- * @version 1.3
- * @date 2023/1/18
- */
-@Data
-public class MqttClientOptions {
-
- private MqttProtocolEnum protocol;
-
- private String host;
-
- private Integer port;
-
- private String username;
-
- private String password;
-
- private String clientId;
-
- private String path;
-
- /**
- * The topic to subscribe to immediately when client connects. Only required for basic link.
- */
- private String inboundTopic;
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mqtt/model/MqttProtocolEnum.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mqtt/model/MqttProtocolEnum.java
deleted file mode 100644
index 4883ee7e..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mqtt/model/MqttProtocolEnum.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.central.cloud.component.mqtt.model;
-
-import lombok.Getter;
-
-/**
- * @author sean
- * @version 1.3
- * @date 2023/1/18
- */
-@Getter
-public enum MqttProtocolEnum {
-
- MQTT("tcp"),
-
- MQTTS("ssl"),
-
- WS("ws"),
-
- WSS("wss");
-
- String protocol;
-
- MqttProtocolEnum(String protocol) {
- this.protocol = protocol;
- }
-
- public String getProtocolAddr() {
- return protocol + "://";
- }
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mqtt/model/MqttUseEnum.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mqtt/model/MqttUseEnum.java
deleted file mode 100644
index 88af53f4..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mqtt/model/MqttUseEnum.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.central.cloud.component.mqtt.model;
-
-/**
- * @author sean
- * @version 1.3
- * @date 2023/1/18
- */
-public enum MqttUseEnum {
-
- /**
- * The broker is used for basic link.
- */
- BASIC,
-
- /**
- * This broker is used for the drc link.
- */
- DRC
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mybatis/MybatisPlusConfiguration.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mybatis/MybatisPlusConfiguration.java
deleted file mode 100644
index f787e5a9..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mybatis/MybatisPlusConfiguration.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.central.cloud.component.mybatis;
-
-import com.baomidou.mybatisplus.annotation.DbType;
-import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
-import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * @author sean
- * @version 0.3
- * @date 2021/12/22
- */
-@Configuration
-public class MybatisPlusConfiguration {
-
- @Bean
- public MybatisPlusInterceptor mybatisPlusInterceptor() {
- MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
- // select database
- interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
- return interceptor;
- }
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mybatis/MybatisPlusMetaObjectHandler.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mybatis/MybatisPlusMetaObjectHandler.java
deleted file mode 100644
index 0ccd1f6d..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/mybatis/MybatisPlusMetaObjectHandler.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.central.cloud.component.mybatis;
-
-import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
-import org.apache.ibatis.reflection.MetaObject;
-import org.springframework.stereotype.Component;
-
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-
-/**
- * Automatic filling for set values
- */
-@Component
-public class MybatisPlusMetaObjectHandler implements MetaObjectHandler {
-
- /**
- * Automatic filling when inserting into the database.
- * @param metaObject
- */
- @Override
- public void insertFill(MetaObject metaObject) {
- this.strictInsertFill(metaObject, "createTime", Long.class,
- LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
- this.strictInsertFill(metaObject, "updateTime", Long.class,
- LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
- }
-
- /**
- * Automatic filling when updating the data.
- * @param metaObject
- */
- @Override
- public void updateFill(MetaObject metaObject) {
- this.strictUpdateFill(metaObject, "updateTime", Long.class,
- LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
- }
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/oss/model/OssConfiguration.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/oss/model/OssConfiguration.java
deleted file mode 100644
index bfa39c83..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/oss/model/OssConfiguration.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package com.central.cloud.component.oss.model;
-
-import com.dji.sdk.cloudapi.storage.OssTypeEnum;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.stereotype.Component;
-
-/**
- * @author sean
- * @version 0.2
- * @date 2021/12/9
- */
-@ConfigurationProperties(prefix = "oss")
-@Component
-public class OssConfiguration {
-
- /**
- * @see OssTypeEnum
- */
- public static OssTypeEnum provider;
-
- /**
- * Whether to use the object 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;
-
- public void setProvider(OssTypeEnum provider) {
- OssConfiguration.provider = provider;
- }
-
- public void setEnable(boolean enable) {
- OssConfiguration.enable = enable;
- }
-
- public void setEndpoint(String endpoint) {
- OssConfiguration.endpoint = endpoint;
- }
-
- public void setAccessKey(String accessKey) {
- OssConfiguration.accessKey = accessKey;
- }
-
- public void setSecretKey(String secretKey) {
- OssConfiguration.secretKey = secretKey;
- }
-
- public void setRegion(String region) {
- OssConfiguration.region = region;
- }
-
- public void setExpire(Long expire) {
- OssConfiguration.expire = expire;
- }
-
- public void setRoleSessionName(String roleSessionName) {
- OssConfiguration.roleSessionName = roleSessionName;
- }
-
- public void setRoleArn(String roleArn) {
- OssConfiguration.roleArn = roleArn;
- }
-
- public void setBucket(String bucket) {
- OssConfiguration.bucket = bucket;
- }
-
- public void setObjectDirPrefix(String objectDirPrefix) {
- OssConfiguration.objectDirPrefix = objectDirPrefix;
- }
-}
-
-
-
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/oss/service/IOssService.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/oss/service/IOssService.java
deleted file mode 100644
index 567aae7b..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/oss/service/IOssService.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.central.cloud.component.oss.service;
-
-import com.dji.sdk.cloudapi.storage.CredentialsToken;
-import com.dji.sdk.cloudapi.storage.OssTypeEnum;
-
-import java.io.InputStream;
-import java.net.URL;
-
-/**
- * @author sean
- * @version 0.3
- * @date 2021/12/23
- */
-public interface IOssService {
-
- OssTypeEnum getOssType();
-
- /**
- * Get temporary credentials.
- * @return
- */
- CredentialsToken getCredentials();
-
- /**
- * Get the address of the object based on the bucket name and the object name.
- * @param bucket bucket name
- * @param objectKey object name
- * @return download link
- */
- URL getObjectUrl(String bucket, String objectKey);
-
- /**
- * Deletes the object in the storage bucket.
- * @param bucket
- * @param objectKey
- * @return
- */
- Boolean deleteObject(String bucket, String objectKey);
-
- /**
- * Get the contents of an object.
- * @param bucket
- * @param objectKey
- * @return
- */
- InputStream getObject(String bucket, String objectKey);
-
- void putObject(String bucket, String objectKey, InputStream input);
-
- void createClient();
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/oss/service/impl/AliyunOssServiceImpl.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/oss/service/impl/AliyunOssServiceImpl.java
deleted file mode 100644
index 3515b618..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/oss/service/impl/AliyunOssServiceImpl.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package com.central.cloud.component.oss.service.impl;
-
-import com.aliyun.oss.OSS;
-import com.aliyun.oss.OSSClientBuilder;
-import com.aliyun.oss.OSSException;
-import com.aliyun.oss.model.ObjectMetadata;
-import com.aliyun.oss.model.PutObjectRequest;
-import com.aliyun.oss.model.PutObjectResult;
-import com.aliyuncs.DefaultAcsClient;
-import com.aliyuncs.IAcsClient;
-import com.aliyuncs.exceptions.ClientException;
-import com.aliyuncs.profile.DefaultProfile;
-import com.aliyuncs.sts.model.v20150401.AssumeRoleRequest;
-import com.aliyuncs.sts.model.v20150401.AssumeRoleResponse;
-import com.central.cloud.component.oss.model.OssConfiguration;
-import com.central.cloud.component.oss.service.IOssService;
-import com.dji.sdk.cloudapi.storage.CredentialsToken;
-import com.dji.sdk.cloudapi.storage.OssTypeEnum;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Date;
-import java.util.Objects;
-
-/**
- * @author sean
- * @version 0.3
- * @date 2021/12/23
- */
-@Service
-@Slf4j
-public class AliyunOssServiceImpl implements IOssService {
-
- private OSS ossClient;
-
- @Override
- public OssTypeEnum getOssType() {
- return OssTypeEnum.ALIYUN;
- }
-
- @Override
- public CredentialsToken getCredentials() {
-
- try {
- DefaultProfile profile = DefaultProfile.getProfile(
- OssConfiguration.region, OssConfiguration.accessKey, OssConfiguration.secretKey);
- IAcsClient client = new DefaultAcsClient(profile);
-
- AssumeRoleRequest request = new AssumeRoleRequest();
- request.setDurationSeconds(OssConfiguration.expire);
- request.setRoleArn(OssConfiguration.roleArn);
- request.setRoleSessionName(OssConfiguration.roleSessionName);
-
- AssumeRoleResponse.Credentials response = client.getAcsResponse(request).getCredentials();
- return new CredentialsToken(response.getAccessKeyId(), response.getAccessKeySecret(), response.getSecurityToken(), OssConfiguration.expire);
-
- } catch (ClientException e) {
- log.debug("Failed to obtain sts.");
- e.printStackTrace();
- }
- return null;
- }
-
- @Override
- public URL getObjectUrl(String bucket, String objectKey) {
- // First check if the object can be fetched.
- boolean isExist = ossClient.doesObjectExist(bucket, objectKey);
- if (!isExist) {
- throw new OSSException("The object does not exist.");
- }
-
- return ossClient.generatePresignedUrl(bucket, objectKey,
- new Date(System.currentTimeMillis() + OssConfiguration.expire * 1000));
- }
-
- @Override
- public Boolean deleteObject(String bucket, String objectKey) {
- if (!ossClient.doesObjectExist(bucket, objectKey)) {
- return true;
- }
- ossClient.deleteObject(bucket, objectKey);
- return true;
- }
-
- @Override
- public InputStream getObject(String bucket, String objectKey) {
- return ossClient.getObject(bucket, objectKey).getObjectContent();
- }
-
- @Override
- public void putObject(String bucket, String objectKey, InputStream input) {
- if (ossClient.doesObjectExist(bucket, objectKey)) {
- throw new RuntimeException("The filename already exists.");
- }
- PutObjectResult objectResult = ossClient.putObject(new PutObjectRequest(bucket, objectKey, input, new ObjectMetadata()));
- log.info("Upload FlighttaskCreateFile: {}", objectResult.getETag());
- }
-
- public void createClient() {
- if (Objects.nonNull(this.ossClient)) {
- return;
- }
- this.ossClient = new OSSClientBuilder()
- .build(OssConfiguration.endpoint, OssConfiguration.accessKey, OssConfiguration.secretKey);
- }
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/oss/service/impl/AmazonS3ServiceImpl.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/oss/service/impl/AmazonS3ServiceImpl.java
deleted file mode 100644
index 182e1a2e..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/oss/service/impl/AmazonS3ServiceImpl.java
+++ /dev/null
@@ -1,126 +0,0 @@
-package com.central.cloud.component.oss.service.impl;
-
-import com.amazonaws.HttpMethod;
-import com.amazonaws.auth.AWSStaticCredentialsProvider;
-import com.amazonaws.auth.BasicAWSCredentials;
-import com.amazonaws.services.s3.AmazonS3;
-import com.amazonaws.services.s3.AmazonS3ClientBuilder;
-import com.amazonaws.services.s3.model.*;
-import com.amazonaws.services.securitytoken.AWSSecurityTokenService;
-import com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClientBuilder;
-import com.amazonaws.services.securitytoken.model.AssumeRoleRequest;
-import com.amazonaws.services.securitytoken.model.AssumeRoleResult;
-import com.amazonaws.services.securitytoken.model.Credentials;
-import com.central.cloud.component.AuthInterceptor;
-import com.central.cloud.component.oss.model.OssConfiguration;
-import com.central.cloud.component.oss.service.IOssService;
-import com.dji.sdk.cloudapi.storage.CredentialsToken;
-import com.dji.sdk.cloudapi.storage.OssTypeEnum;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.PostConstruct;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
-
-/**
- * @author sean
- * @version 1.0
- * @date 2022/4/27
- */
-@Slf4j
-@Service
-public class AmazonS3ServiceImpl implements IOssService {
-
- private AmazonS3 client;
-
- @Override
- public OssTypeEnum getOssType() {
- return OssTypeEnum.AWS;
- }
-
- @Override
- public CredentialsToken getCredentials() {
- AWSSecurityTokenService stsClient = AWSSecurityTokenServiceClientBuilder.standard()
- .withCredentials(new AWSStaticCredentialsProvider(
- new BasicAWSCredentials(OssConfiguration.accessKey, OssConfiguration.secretKey)))
- .withRegion(OssConfiguration.region).build();
-
- AssumeRoleRequest request = new AssumeRoleRequest()
- .withRoleArn(OssConfiguration.roleArn)
- .withRoleSessionName(OssConfiguration.roleSessionName)
- .withDurationSeconds(Math.toIntExact(OssConfiguration.expire));
- AssumeRoleResult result = stsClient.assumeRole(request);
- Credentials credentials = result.getCredentials();
- return new CredentialsToken(credentials.getAccessKeyId(), credentials.getSecretAccessKey(),
- credentials.getSessionToken(), (credentials.getExpiration().getTime() - System.currentTimeMillis()) / 1000);
- }
-
- @Override
- public URL getObjectUrl(String bucket, String objectKey) {
- return client.generatePresignedUrl(bucket, objectKey,
- new Date(System.currentTimeMillis() + OssConfiguration.expire * 1000), HttpMethod.GET);
- }
-
- @Override
- public Boolean deleteObject(String bucket, String objectKey) {
- if (!client.doesObjectExist(bucket, objectKey)) {
- return true;
- }
- client.deleteObject(bucket, objectKey);
- return true;
- }
-
- public InputStream getObject(String bucket, String objectKey) {
- return client.getObject(bucket, objectKey).getObjectContent().getDelegateStream();
- }
-
- @Override
- public void putObject(String bucket, String objectKey, InputStream input) {
- if (client.doesObjectExist(bucket, objectKey)) {
- throw new RuntimeException("The filename already exists.");
- }
- PutObjectResult objectResult = client.putObject(new PutObjectRequest(bucket, objectKey, input, new ObjectMetadata()));
- log.info("Upload FlighttaskCreateFile: {}", objectResult.toString());
- }
-
- public void createClient() {
- if (Objects.nonNull(this.client)) {
- return;
- }
- this.client = AmazonS3ClientBuilder.standard()
- .withCredentials(
- new AWSStaticCredentialsProvider(
- new BasicAWSCredentials(OssConfiguration.accessKey, OssConfiguration.secretKey)))
- .withRegion(OssConfiguration.region)
- .build();
- }
-
- /**
- * Configuring cross-origin resource sharing
- */
- @PostConstruct
- private void configCORS() {
- if (!OssConfiguration.enable || !OssTypeEnum.AWS.getType().equals(OssConfiguration.provider)) {
- return;
- }
- List allowedMethods = new ArrayList<>();
- allowedMethods.add(CORSRule.AllowedMethods.GET);
- allowedMethods.add(CORSRule.AllowedMethods.POST);
- allowedMethods.add(CORSRule.AllowedMethods.DELETE);
-
- CORSRule rule = new CORSRule()
- .withId("CORSAccessRule")
- .withAllowedOrigins(List.of("*"))
- .withAllowedHeaders(List.of(AuthInterceptor.PARAM_TOKEN))
- .withAllowedMethods(allowedMethods);
-
- client.setBucketCrossOriginConfiguration(OssConfiguration.bucket,
- new BucketCrossOriginConfiguration().withRules(rule));
-
- }
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/oss/service/impl/MinIOServiceImpl.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/oss/service/impl/MinIOServiceImpl.java
deleted file mode 100644
index aed6f0c4..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/oss/service/impl/MinIOServiceImpl.java
+++ /dev/null
@@ -1,123 +0,0 @@
-package com.central.cloud.component.oss.service.impl;
-
-import com.central.cloud.component.oss.model.OssConfiguration;
-import com.central.cloud.component.oss.service.IOssService;
-import com.dji.sdk.cloudapi.storage.CredentialsToken;
-import com.dji.sdk.cloudapi.storage.OssTypeEnum;
-import io.minio.*;
-import io.minio.credentials.AssumeRoleProvider;
-import io.minio.credentials.Credentials;
-import io.minio.errors.*;
-import io.minio.http.Method;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.util.Objects;
-
-/**
- * @author sean
- * @version 0.3
- * @date 2021/12/23
- */
-@Service
-@Slf4j
-public class MinIOServiceImpl implements IOssService {
-
- private MinioClient client;
-
- @Override
- public OssTypeEnum getOssType() {
- return OssTypeEnum.MINIO;
- }
-
- @Override
- public CredentialsToken getCredentials() {
- try {
- AssumeRoleProvider provider = new AssumeRoleProvider(OssConfiguration.endpoint, OssConfiguration.accessKey,
- OssConfiguration.secretKey, Math.toIntExact(OssConfiguration.expire),
- null, OssConfiguration.region, null, null, null, null);
- Credentials credential = provider.fetch();
- return new CredentialsToken(credential.accessKey(), credential.secretKey(), credential.sessionToken(), OssConfiguration.expire);
- } catch (NoSuchAlgorithmException e) {
- log.debug("Failed to obtain sts.");
- e.printStackTrace();
- }
- return null;
- }
-
- @Override
- public URL getObjectUrl(String bucket, String objectKey) {
- try {
- return new URL(
- client.getPresignedObjectUrl(
- GetPresignedObjectUrlArgs.builder()
- .method(Method.GET)
- .bucket(bucket)
- .object(objectKey)
- .expiry(Math.toIntExact(OssConfiguration.expire))
- .build()));
- } catch (ErrorResponseException | InsufficientDataException | InternalException |
- InvalidKeyException | InvalidResponseException | IOException |
- NoSuchAlgorithmException | XmlParserException | ServerException e) {
- throw new RuntimeException("The file does not exist on the OssConfiguration.");
- }
- }
-
- @Override
- public Boolean deleteObject(String bucket, String objectKey) {
- try {
- client.removeObject(RemoveObjectArgs.builder().bucket(bucket).object(objectKey).build());
- } catch (MinioException | NoSuchAlgorithmException | IOException | InvalidKeyException e) {
- log.error("Failed to delete file.");
- e.printStackTrace();
- return false;
- }
- return true;
- }
-
- @Override
- public InputStream getObject(String bucket, String objectKey) {
- try {
- GetObjectResponse object = client.getObject(GetObjectArgs.builder().bucket(bucket).object(objectKey).build());
- return new ByteArrayInputStream(object.readAllBytes());
- } catch (ErrorResponseException | InsufficientDataException | InternalException | InvalidKeyException | InvalidResponseException | IOException | NoSuchAlgorithmException | ServerException | XmlParserException e) {
- e.printStackTrace();
- }
- return InputStream.nullInputStream();
- }
-
- @Override
- public void putObject(String bucket, String objectKey, InputStream input) {
- try {
- client.statObject(StatObjectArgs.builder().bucket(bucket).object(objectKey).build());
- throw new RuntimeException("The filename already exists.");
- } catch (MinioException | InvalidKeyException | IOException | NoSuchAlgorithmException e) {
- log.info("The file does not exist, start uploading.");
- try {
- ObjectWriteResponse response = client.putObject(
- PutObjectArgs.builder().bucket(bucket).object(objectKey).stream(input, input.available(), 0).build());
- log.info("Upload FlighttaskCreateFile: {}", response.etag());
- } catch (MinioException | IOException | InvalidKeyException | NoSuchAlgorithmException ex) {
- log.error("Failed to upload FlighttaskCreateFile {}.", objectKey);
- ex.printStackTrace();
- }
- }
- }
-
- public void createClient() {
- if (Objects.nonNull(this.client)) {
- return;
- }
- this.client = MinioClient.builder()
- .endpoint(OssConfiguration.endpoint)
- .credentials(OssConfiguration.accessKey, OssConfiguration.secretKey)
- .region(OssConfiguration.region)
- .build();
- }
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/oss/service/impl/OssAspectHandler.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/oss/service/impl/OssAspectHandler.java
deleted file mode 100644
index 32ea4a79..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/oss/service/impl/OssAspectHandler.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.central.cloud.component.oss.service.impl;
-
-import com.central.cloud.component.oss.model.OssConfiguration;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Before;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * @author sean
- * @version 1.1
- * @date 2022/6/20
- */
-@Component
-@Aspect
-public class OssAspectHandler {
-
- @Autowired
- private OssServiceContext ossServiceContext;
-
- @Before("execution(public * com.central.cloud.component.oss.service.impl.OssServiceContext.*(..))")
- public void before() {
- if (!OssConfiguration.enable) {
- throw new IllegalArgumentException("Please enable OssConfiguration.");
- }
- if (this.ossServiceContext.getOssService() == null) {
- throw new IllegalArgumentException("Please check the OssConfiguration configuration.");
- }
- this.ossServiceContext.createClient();
- }
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/oss/service/impl/OssServiceContext.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/oss/service/impl/OssServiceContext.java
deleted file mode 100644
index c0530625..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/oss/service/impl/OssServiceContext.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package com.central.cloud.component.oss.service.impl;
-
-import com.central.cloud.component.oss.model.OssConfiguration;
-import com.central.cloud.component.oss.service.IOssService;
-import com.dji.sdk.cloudapi.storage.CredentialsToken;
-import com.dji.sdk.cloudapi.storage.OssTypeEnum;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.util.StringUtils;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * @author sean
- * @version 1.0
- * @date 2022/5/30
- */
-@Service
-public class OssServiceContext {
-
- private IOssService ossService;
-
- @Autowired
- public OssServiceContext(List ossServices, OssConfiguration configuration) {
- if (!OssConfiguration.enable) {
- return;
- }
- this.ossService = ossServices.stream()
- .filter(ossService -> ossService.getOssType() == OssConfiguration.provider)
- .findFirst()
- .orElseThrow(() -> new IllegalArgumentException("Oss provider is illegal. Optional: " +
- Arrays.toString(Arrays.stream(OssTypeEnum.values()).map(OssTypeEnum::getType).toArray())));
- }
-
- IOssService getOssService() {
- return this.ossService;
- }
-
- public CredentialsToken getCredentials() {
- return this.ossService.getCredentials();
- }
-
- public URL getObjectUrl(String bucket, String objectKey) {
- if (!StringUtils.hasText(bucket) || !StringUtils.hasText(objectKey)) {
- throw new IllegalArgumentException();
- }
- return this.ossService.getObjectUrl(bucket, objectKey);
- }
-
- public Boolean deleteObject(String bucket, String objectKey) {
- return this.ossService.deleteObject(bucket, objectKey);
- }
-
- public InputStream getObject(String bucket, String objectKey) {
- return this.ossService.getObject(bucket, objectKey);
- }
-
- public void putObject(String bucket, String objectKey, InputStream stream) {
- this.ossService.putObject(bucket, objectKey, stream);
- }
-
- void createClient() {
- this.ossService.createClient();
- }
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/redis/RedisConfiguration.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/redis/RedisConfiguration.java
deleted file mode 100644
index 0f3ebbef..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/redis/RedisConfiguration.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.central.cloud.component.redis;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
-import com.fasterxml.jackson.databind.MapperFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.PropertyNamingStrategy;
-import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
-import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
-import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.data.redis.connection.RedisConnectionFactory;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
-import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
-import org.springframework.data.redis.serializer.StringRedisSerializer;
-
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-
-/**
- * @author sean
- * @version 1.0
- * @date 2022/4/19
- */
-@Configuration
-@EnableRedisRepositories
-public class RedisConfiguration {
-
- @Bean
- public RedisTemplate redisTemplate(RedisConnectionFactory factory) {
- RedisTemplate redisTemplate = new RedisTemplate<>();
- redisTemplate.setConnectionFactory(factory);
-
- ObjectMapper objectMapper = new ObjectMapper();
- JavaTimeModule timeModule = new JavaTimeModule();
- timeModule.addDeserializer(LocalDateTime.class,
- new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
- timeModule.addSerializer(LocalDateTime.class,
- new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
- objectMapper.disable(MapperFeature.IGNORE_DUPLICATE_MODULE_REGISTRATIONS);
- objectMapper.registerModules(timeModule);
- objectMapper.activateDefaultTyping(objectMapper.getPolymorphicTypeValidator(),
- ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
-
- objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
- objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
- objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
-
-
- StringRedisSerializer serializer = new StringRedisSerializer();
- redisTemplate.setKeySerializer(serializer);
- redisTemplate.setHashKeySerializer(serializer);
-
- GenericJackson2JsonRedisSerializer jsonRedisSerializer = new GenericJackson2JsonRedisSerializer(objectMapper);
- redisTemplate.setValueSerializer(jsonRedisSerializer);
- redisTemplate.setHashValueSerializer(jsonRedisSerializer);
- redisTemplate.afterPropertiesSet();
- return redisTemplate;
-
- }
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/redis/RedisConst.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/redis/RedisConst.java
deleted file mode 100644
index a616dd50..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/redis/RedisConst.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package com.central.cloud.component.redis;
-
-/**
- * @author sean
- * @version 1.0
- * @date 2022/4/21
- */
-public final class RedisConst {
-
- public static final int WAYLINE_JOB_BLOCK_TIME = 600;
-
- private RedisConst() {
-
- }
-
- public static final String DELIMITER = ":";
-
- public static final Integer DEVICE_ALIVE_SECOND = 60;
-
- public static final Integer WEBSOCKET_ALIVE_SECOND = 60 * 60 * 24;
-
- public static final String DEVICE_ONLINE_PREFIX = "online" + DELIMITER;
-
- public static final String WEBSOCKET_PREFIX = "webSocket" + DELIMITER;
-
- public static final String WEBSOCKET_ALL = WEBSOCKET_PREFIX + "all";
-
- public static final String HMS_PREFIX = "hms" + DELIMITER;
-
- public static final String FIRMWARE_UPGRADING_PREFIX = "upgrading" + DELIMITER;
-
- public static final String STATE_PAYLOAD_PREFIX = "payload" + DELIMITER;
-
- public static final String LOGS_FILE_PREFIX = "logs_file" + DELIMITER;
-
- public static final String WAYLINE_JOB_TIMED_EXECUTE = "wayline_job_timed_execute";
-
- public static final String WAYLINE_JOB_CONDITION_PREPARE = "wayline_job_condition_prepare";
-
- public static final String WAYLINE_JOB_CONDITION_PREFIX = WAYLINE_JOB_CONDITION_PREPARE + DELIMITER;
-
- public static final String WAYLINE_JOB_BLOCK_PREFIX = "wayline_job_block" + DELIMITER;
-
- public static final String WAYLINE_JOB_RUNNING_PREFIX = "wayline_job_running" + DELIMITER;
-
- public static final String WAYLINE_JOB_PAUSED_PREFIX = "wayline_job_paused" + DELIMITER;
-
- public static final String OSD_PREFIX = "osd" + DELIMITER;
-
- public static final String MEDIA_FILE_PREFIX = "media_file" + DELIMITER;
-
- public static final String MEDIA_HIGHEST_PRIORITY_PREFIX = "media_highest_priority" + DELIMITER;
-
- public static final String LIVE_CAPACITY = "live_capacity";
-
- public static final String DRC_PREFIX = "drc" + DELIMITER;
-
- public static final Integer DRC_MODE_ALIVE_SECOND = 3600;
-
- public static final String MQTT_ACL_PREFIX = "mqtt_acl" + DELIMITER;
-
- public static final String FILE_UPLOADING_PREFIX = "file_uploading" + DELIMITER;
-
- public static final String DRONE_CONTROL_PREFiX = "control_source" + DELIMITER;
-}
diff --git a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/redis/RedisOpsUtils.java b/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/redis/RedisOpsUtils.java
deleted file mode 100644
index fd8d3c33..00000000
--- a/zlt-business/cloud-api-center/src/main/java/com/central/cloud/component/redis/RedisOpsUtils.java
+++ /dev/null
@@ -1,263 +0,0 @@
-package com.central.cloud.component.redis;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.stereotype.Component;
-import org.springframework.util.CollectionUtils;
-
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @author sean
- * @version 1.0
- * @date 2022/4/19
- */
-@Component
-public class RedisOpsUtils {
-
- private static RedisTemplate redisTemplate;
-
- @Autowired
- public void setRedisTemplate(RedisTemplate redisTemplate) {
- RedisOpsUtils.redisTemplate = redisTemplate;
- }
-
- /**
- * HSET
- * @param key
- * @param field
- * @param value
- */
- public static void hashSet(String key, String field, Object value) {
- redisTemplate.opsForHash().put(key, field, value);
- }
-
- /**
- * HGET
- * @param key
- * @param field
- * @return
- */
- public static Object hashGet(String key, String field) {
- return redisTemplate.opsForHash().get(key, field);
- }
-
- /**
- * HKEYS
- * @param key
- * @return
- */
- public static Set