Jelajahi Sumber

Initial commit

wangyunpeng 1 Minggu lalu
melakukan
1812634f6d
65 mengubah file dengan 4724 tambahan dan 0 penghapusan
  1. 37 0
      .gitignore
  2. 20 0
      core/pom.xml
  3. 15 0
      core/src/main/java/com/tzld/rta/annotation/NoRequestLog.java
  4. 361 0
      core/src/main/java/com/tzld/rta/common/LoghubAppender.java
  5. 34 0
      core/src/main/java/com/tzld/rta/common/LoghubAppenderCallback.java
  6. 81 0
      core/src/main/java/com/tzld/rta/common/base/CommonResponse.java
  7. 13 0
      core/src/main/java/com/tzld/rta/common/constant/ResponseConstant.java
  8. 30 0
      core/src/main/java/com/tzld/rta/common/enums/EnumUploadFileType.java
  9. 32 0
      core/src/main/java/com/tzld/rta/common/enums/ExceptionEnum.java
  10. 87 0
      core/src/main/java/com/tzld/rta/common/exception/CommonException.java
  11. 43 0
      core/src/main/java/com/tzld/rta/config/RedisConfig.java
  12. 11 0
      core/src/main/java/com/tzld/rta/config/SchedulingConfig.java
  13. 56 0
      core/src/main/java/com/tzld/rta/config/SwaggerConfig.java
  14. 49 0
      core/src/main/java/com/tzld/rta/config/XxlJobConfig.java
  15. 68 0
      core/src/main/java/com/tzld/rta/config/db/RtaDBConfig.java
  16. 19 0
      core/src/main/java/com/tzld/rta/config/mybatis/RtaMybatisConfig.java
  17. 31 0
      core/src/main/java/com/tzld/rta/dao/generator/MybatisGeneratorMain.java
  18. 73 0
      core/src/main/java/com/tzld/rta/handle/GlobalExceptionHandle.java
  19. 38 0
      core/src/main/java/com/tzld/rta/interceptor/CrosDomainAllowInterceptor.java
  20. 39 0
      core/src/main/java/com/tzld/rta/model/entity/DeepSeekOfficialApiResponse.java
  21. 11 0
      core/src/main/java/com/tzld/rta/model/entity/DeepSeekResult.java
  22. 25 0
      core/src/main/java/com/tzld/rta/model/vo/FileInfo.java
  23. 49 0
      core/src/main/java/com/tzld/rta/model/vo/PolicyDetailVO.java
  24. 13 0
      core/src/main/java/com/tzld/rta/model/vo/SignatureVO.java
  25. 20 0
      core/src/main/java/com/tzld/rta/model/vo/StsTokenVO.java
  26. 139 0
      core/src/main/java/com/tzld/rta/util/BaseUtils.java
  27. 169 0
      core/src/main/java/com/tzld/rta/util/CdnUtil.java
  28. 333 0
      core/src/main/java/com/tzld/rta/util/DateUtils.java
  29. 23 0
      core/src/main/java/com/tzld/rta/util/DistributedIdGenerator.java
  30. 69 0
      core/src/main/java/com/tzld/rta/util/IpUtil.java
  31. 50 0
      core/src/main/java/com/tzld/rta/util/MapBuilder.java
  32. 72 0
      core/src/main/java/com/tzld/rta/util/Md5Util.java
  33. 33 0
      core/src/main/java/com/tzld/rta/util/OdpsUtil.java
  34. 174 0
      core/src/main/java/com/tzld/rta/util/PropertiesUtils.java
  35. 64 0
      core/src/main/java/com/tzld/rta/util/RandomUtil.java
  36. 257 0
      core/src/main/java/com/tzld/rta/util/RedisUtils.java
  37. 55 0
      core/src/main/java/com/tzld/rta/util/TimelineUtils.java
  38. 105 0
      core/src/main/java/com/tzld/rta/util/feishu/FeiShu.java
  39. 190 0
      core/src/main/java/com/tzld/rta/util/feishu/FeishuExcelUtil.java
  40. 152 0
      core/src/main/java/com/tzld/rta/util/feishu/FeishuMessageSender.java
  41. 37 0
      core/src/main/java/com/tzld/rta/util/feishu/model/FeishuChatListResult.java
  42. 62 0
      core/src/main/java/com/tzld/rta/util/feishu/model/FeishuGroup.java
  43. 48 0
      core/src/main/java/com/tzld/rta/util/feishu/model/Message.java
  44. 50 0
      core/src/main/java/com/tzld/rta/util/feishu/model/MessageParams.java
  45. 26 0
      core/src/main/java/com/tzld/rta/util/feishu/model/config/MessageConfig.java
  46. 17 0
      core/src/main/java/com/tzld/rta/util/feishu/model/element/BaseElement.java
  47. 24 0
      core/src/main/java/com/tzld/rta/util/feishu/model/element/DivElement.java
  48. 30 0
      core/src/main/java/com/tzld/rta/util/feishu/model/element/Filed.java
  49. 31 0
      core/src/main/java/com/tzld/rta/util/feishu/model/element/MarkDownText.java
  50. 14 0
      core/src/main/java/com/tzld/rta/util/feishu/model/header/HeadTitle.java
  51. 17 0
      core/src/main/java/com/tzld/rta/util/feishu/model/header/MessageHeader.java
  52. 54 0
      core/src/main/resources/generator/mybatis-rta-generator-config.xml
  53. 295 0
      pom.xml
  54. 51 0
      server/pom.xml
  55. 33 0
      server/src/main/java/com/tzld/rta/Application.java
  56. 171 0
      server/src/main/java/com/tzld/rta/aop/LogRequestAop.java
  57. 21 0
      server/src/main/java/com/tzld/rta/controller/HealthController.java
  58. 40 0
      server/src/main/java/com/tzld/rta/filter/CustomFilter.java
  59. 55 0
      server/src/main/resources/application-dev.yml
  60. 53 0
      server/src/main/resources/application-prod.yml
  61. 53 0
      server/src/main/resources/application-test.yml
  62. 68 0
      server/src/main/resources/application.yml
  63. 166 0
      server/src/main/resources/logback-spring.xml
  64. 42 0
      server/src/test/java/FeishuTest.java
  65. 126 0
      server/src/test/java/GeminiTest.java

+ 37 - 0
.gitignore

@@ -0,0 +1,37 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
+
+*.log

+ 20 - 0
core/pom.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.tzld.piaoquan</groupId>
+        <artifactId>tencent-rta-server</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>core</artifactId>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+</project>

+ 15 - 0
core/src/main/java/com/tzld/rta/annotation/NoRequestLog.java

@@ -0,0 +1,15 @@
+package com.tzld.rta.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * 请求日志排除注解
+ *
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface NoRequestLog {
+}

+ 361 - 0
core/src/main/java/com/tzld/rta/common/LoghubAppender.java

@@ -0,0 +1,361 @@
+package com.tzld.rta.common;
+
+import ch.qos.logback.classic.spi.IThrowableProxy;
+import ch.qos.logback.classic.spi.LoggingEvent;
+import ch.qos.logback.classic.spi.StackTraceElementProxy;
+import ch.qos.logback.classic.spi.ThrowableProxyUtil;
+import ch.qos.logback.core.CoreConstants;
+import ch.qos.logback.core.UnsynchronizedAppenderBase;
+import ch.qos.logback.core.encoder.Encoder;
+import com.aliyun.openservices.aliyun.log.producer.LogProducer;
+import com.aliyun.openservices.aliyun.log.producer.Producer;
+import com.aliyun.openservices.aliyun.log.producer.ProducerConfig;
+import com.aliyun.openservices.aliyun.log.producer.ProjectConfig;
+import com.aliyun.openservices.aliyun.log.producer.errors.ProducerException;
+import com.aliyun.openservices.log.common.LogItem;
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+
+import java.time.Instant;
+import java.time.ZoneId;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Optional;
+
+public class LoghubAppender<E> extends UnsynchronizedAppenderBase<E> {
+    private String project;
+    private String endpoint;
+    private String accessKeyId;
+    private String accessKeySecret;
+    private String userAgent = "logback";
+    protected Encoder<E> encoder;
+    protected ProducerConfig producerConfig = new ProducerConfig();
+    protected ProjectConfig projectConfig;
+    protected Producer producer;
+    protected String logStore;
+    protected String topic = "";
+    protected String source = "";
+    protected String timeZone = "UTC";
+    protected String timeFormat = "yyyy-MM-dd'T'HH:mmZ";
+    protected DateTimeFormatter formatter;
+    protected java.time.format.DateTimeFormatter formatter1;
+    private String mdcFields;
+
+    public LoghubAppender() {
+    }
+
+    public void start() {
+        try {
+            this.doStart();
+        } catch (Exception var2) {
+            this.addError("Failed to start LoghubAppender.", var2);
+        }
+
+    }
+
+    private void doStart() {
+        try {
+            this.formatter = DateTimeFormat.forPattern(this.timeFormat).withZone(DateTimeZone.forID(this.timeZone));
+        } catch (Exception var2) {
+            this.formatter1 = java.time.format.DateTimeFormatter.ofPattern(this.timeFormat).withZone(ZoneId.of(this.timeZone));
+        }
+
+        this.producer = this.createProducer();
+        super.start();
+    }
+
+    public Producer createProducer() {
+        this.projectConfig = this.buildProjectConfig();
+        Producer producer = new LogProducer(this.producerConfig);
+        producer.putProjectConfig(this.projectConfig);
+        return producer;
+    }
+
+    private ProjectConfig buildProjectConfig() {
+        return new ProjectConfig(this.project, this.endpoint, this.accessKeyId, this.accessKeySecret, (String) null, this.userAgent);
+    }
+
+    public void stop() {
+        try {
+            this.doStop();
+        } catch (Exception var2) {
+            this.addError("Failed to stop LoghubAppender.", var2);
+        }
+
+    }
+
+    private void doStop() throws InterruptedException, ProducerException {
+        if (this.isStarted()) {
+            super.stop();
+            this.producer.close();
+        }
+    }
+
+    public void append(E eventObject) {
+        try {
+            this.appendEvent(eventObject);
+        } catch (Exception var3) {
+            this.addError("Failed to append event.", var3);
+        }
+    }
+
+    private void appendEvent(E eventObject) {
+        if (!(eventObject instanceof LoggingEvent)) {
+            return;
+        }
+        LoggingEvent event = (LoggingEvent) eventObject;
+        if (event.getMarker() == null) {
+            appendPlainEvent(eventObject);
+        }
+    }
+
+    private void appendPlainEvent(E eventObject) {
+        LoggingEvent event = (LoggingEvent) eventObject;
+        List<LogItem> logItems = new ArrayList();
+        LogItem item = new LogItem();
+        logItems.add(item);
+        item.SetTime((int) (event.getTimeStamp() / 1000L));
+        if (this.formatter != null) {
+            DateTime dateTime = new DateTime(event.getTimeStamp());
+            item.PushBack("time", dateTime.toString(this.formatter));
+        } else {
+            Instant instant = Instant.ofEpochMilli(event.getTimeStamp());
+            item.PushBack("time", this.formatter1.format(instant));
+        }
+
+        item.PushBack("level", event.getLevel().toString());
+        item.PushBack("thread", event.getThreadName());
+        StackTraceElement[] caller = event.getCallerData();
+        if (caller != null && caller.length > 0) {
+            item.PushBack("location", caller[0].toString());
+        }
+
+        String message = event.getFormattedMessage();
+        item.PushBack("message", message);
+        IThrowableProxy iThrowableProxy = event.getThrowableProxy();
+        if (iThrowableProxy != null) {
+            String throwable = this.getExceptionInfo(iThrowableProxy);
+            throwable = throwable + this.fullDump(event.getThrowableProxy().getStackTraceElementProxyArray());
+            item.PushBack("throwable", throwable);
+        }
+
+        if (this.encoder != null) {
+            item.PushBack("log", new String(this.encoder.encode(eventObject)));
+        }
+
+        Optional.ofNullable(this.mdcFields).ifPresent((f) -> {
+            event.getMDCPropertyMap().entrySet().stream().filter((v) -> {
+                return Arrays.stream(f.split(",")).anyMatch((i) -> {
+                    return i.equals(v.getKey());
+                });
+            }).forEach((map) -> {
+                item.PushBack((String) map.getKey(), (String) map.getValue());
+            });
+        });
+
+        try {
+            this.producer.send(this.projectConfig.getProject(), this.logStore, this.topic, this.source, logItems,
+                    new LoghubAppenderCallback(this, this.projectConfig.getProject(), this.logStore,
+                            this.topic, this.source, logItems));
+        } catch (Exception var9) {
+            this.addError("Failed to send log, project=" + this.project + ", logStore=" + this.logStore + ", topic=" + this.topic + ", source=" + this.source + ", logItem=" + logItems, var9);
+        }
+    }
+
+    public String getTimeFormat() {
+        return this.timeFormat;
+    }
+
+    public void setTimeFormat(String timeFormat) {
+        this.timeFormat = timeFormat;
+    }
+
+    private String getExceptionInfo(IThrowableProxy iThrowableProxy) {
+        String s = iThrowableProxy.getClassName();
+        String message = iThrowableProxy.getMessage();
+        return message != null ? s + ": " + message : s;
+    }
+
+    private String fullDump(StackTraceElementProxy[] stackTraceElementProxyArray) {
+        StringBuilder builder = new StringBuilder();
+        StackTraceElementProxy[] var3 = stackTraceElementProxyArray;
+        int var4 = stackTraceElementProxyArray.length;
+
+        for (int var5 = 0; var5 < var4; ++var5) {
+            StackTraceElementProxy step = var3[var5];
+            builder.append(CoreConstants.LINE_SEPARATOR);
+            String string = step.toString();
+            builder.append('\t').append(string);
+            ThrowableProxyUtil.subjoinPackagingData(builder, step);
+        }
+
+        return builder.toString();
+    }
+
+    public String getLogStore() {
+        return this.logStore;
+    }
+
+    public void setLogStore(String logStore) {
+        this.logStore = logStore;
+    }
+
+    public String getTopic() {
+        return this.topic;
+    }
+
+    public void setTopic(String topic) {
+        this.topic = topic;
+    }
+
+    public String getSource() {
+        return this.source;
+    }
+
+    public void setSource(String source) {
+        this.source = source;
+    }
+
+    public String getTimeZone() {
+        return this.timeZone;
+    }
+
+    public void setTimeZone(String timeZone) {
+        this.timeZone = timeZone;
+    }
+
+    public String getProject() {
+        return this.project;
+    }
+
+    public void setProject(String project) {
+        this.project = project;
+    }
+
+    public String getEndpoint() {
+        return this.endpoint;
+    }
+
+    public void setEndpoint(String endpoint) {
+        this.endpoint = endpoint;
+    }
+
+    public String getAccessKeyId() {
+        return this.accessKeyId;
+    }
+
+    public void setAccessKeyId(String accessKeyId) {
+        this.accessKeyId = accessKeyId;
+    }
+
+    public String getAccessKeySecret() {
+        return this.accessKeySecret;
+    }
+
+    public void setAccessKeySecret(String accessKeySecret) {
+        this.accessKeySecret = accessKeySecret;
+    }
+
+    public String getUserAgent() {
+        return this.userAgent;
+    }
+
+    public void setUserAgent(String userAgent) {
+        this.userAgent = userAgent;
+    }
+
+    public int getTotalSizeInBytes() {
+        return this.producerConfig.getTotalSizeInBytes();
+    }
+
+    public void setTotalSizeInBytes(int totalSizeInBytes) {
+        this.producerConfig.setTotalSizeInBytes(totalSizeInBytes);
+    }
+
+    public long getMaxBlockMs() {
+        return this.producerConfig.getMaxBlockMs();
+    }
+
+    public void setMaxBlockMs(long maxBlockMs) {
+        this.producerConfig.setMaxBlockMs(maxBlockMs);
+    }
+
+    public int getIoThreadCount() {
+        return this.producerConfig.getIoThreadCount();
+    }
+
+    public void setIoThreadCount(int ioThreadCount) {
+        this.producerConfig.setIoThreadCount(ioThreadCount);
+    }
+
+    public int getBatchSizeThresholdInBytes() {
+        return this.producerConfig.getBatchSizeThresholdInBytes();
+    }
+
+    public void setBatchSizeThresholdInBytes(int batchSizeThresholdInBytes) {
+        this.producerConfig.setBatchSizeThresholdInBytes(batchSizeThresholdInBytes);
+    }
+
+    public int getBatchCountThreshold() {
+        return this.producerConfig.getBatchCountThreshold();
+    }
+
+    public void setBatchCountThreshold(int batchCountThreshold) {
+        this.producerConfig.setBatchCountThreshold(batchCountThreshold);
+    }
+
+    public int getLingerMs() {
+        return this.producerConfig.getLingerMs();
+    }
+
+    public void setLingerMs(int lingerMs) {
+        this.producerConfig.setLingerMs(lingerMs);
+    }
+
+    public int getRetries() {
+        return this.producerConfig.getRetries();
+    }
+
+    public void setRetries(int retries) {
+        this.producerConfig.setRetries(retries);
+    }
+
+    public int getMaxReservedAttempts() {
+        return this.producerConfig.getMaxReservedAttempts();
+    }
+
+    public void setMaxReservedAttempts(int maxReservedAttempts) {
+        this.producerConfig.setMaxReservedAttempts(maxReservedAttempts);
+    }
+
+    public long getBaseRetryBackoffMs() {
+        return this.producerConfig.getBaseRetryBackoffMs();
+    }
+
+    public void setBaseRetryBackoffMs(long baseRetryBackoffMs) {
+        this.producerConfig.setBaseRetryBackoffMs(baseRetryBackoffMs);
+    }
+
+    public long getMaxRetryBackoffMs() {
+        return this.producerConfig.getMaxRetryBackoffMs();
+    }
+
+    public void setMaxRetryBackoffMs(long maxRetryBackoffMs) {
+        this.producerConfig.setMaxRetryBackoffMs(maxRetryBackoffMs);
+    }
+
+    public Encoder<E> getEncoder() {
+        return this.encoder;
+    }
+
+    public void setEncoder(Encoder<E> encoder) {
+        this.encoder = encoder;
+    }
+
+    public void setMdcFields(String mdcFields) {
+        this.mdcFields = mdcFields;
+    }
+}

+ 34 - 0
core/src/main/java/com/tzld/rta/common/LoghubAppenderCallback.java

@@ -0,0 +1,34 @@
+package com.tzld.rta.common;
+
+
+import com.aliyun.openservices.aliyun.log.producer.Callback;
+import com.aliyun.openservices.aliyun.log.producer.Result;
+import com.aliyun.openservices.log.common.LogItem;
+
+import java.util.List;
+
+public class LoghubAppenderCallback<E> implements Callback {
+    protected LoghubAppender<E> loghubAppender;
+    protected String project;
+    protected String logstore;
+    protected String topic;
+    protected String source;
+    protected List<LogItem> logItems;
+
+    public LoghubAppenderCallback(LoghubAppender<E> loghubAppender, String project, String logstore,
+                                  String topic, String source, List<LogItem> logItems) {
+        this.loghubAppender = loghubAppender;
+        this.project = project;
+        this.logstore = logstore;
+        this.topic = topic;
+        this.source = source;
+        this.logItems = logItems;
+    }
+
+    public void onCompletion(Result result) {
+        if (!result.isSuccessful()) {
+            this.loghubAppender.addError("Failed to send log, project=" + this.project + ", logStore=" + this.logstore + ", topic=" + this.topic + ", source=" + this.source + ", logItem=" + this.logItems + ", errorCode=" + result.getErrorCode() + ", errorMessage=" + result.getErrorMessage());
+        }
+
+    }
+}

+ 81 - 0
core/src/main/java/com/tzld/rta/common/base/CommonResponse.java

@@ -0,0 +1,81 @@
+package com.tzld.rta.common.base;
+
+import com.tzld.rta.common.enums.ExceptionEnum;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+import static com.tzld.rta.common.constant.ResponseConstant.SUCCESS_CODE;
+import static com.tzld.rta.common.constant.ResponseConstant.SUCCESS_MSG;
+
+
+/**
+ * Common Response
+ *
+ * @author xueyiming
+ */
+@Setter
+@Getter
+@ToString
+public class CommonResponse<T> {
+    /**
+     * 返回状态码,0 表示业务成功
+     */
+    private int code = 0;
+    /**
+     * 返回消息
+     */
+    private String msg = "success";
+    /**
+     * 业务成功时返回数据
+     */
+    private T data;
+
+    public static <T> CommonResponse<T> success() {
+        CommonResponse<T> commonResponse = new CommonResponse<>();
+        commonResponse.setCode(SUCCESS_CODE);
+        commonResponse.setMsg(SUCCESS_MSG);
+        return commonResponse;
+    }
+
+    public static <T> CommonResponse<T> success(T data) {
+        CommonResponse<T> commonResponse = new CommonResponse<>();
+        commonResponse.setCode(SUCCESS_CODE);
+        commonResponse.setMsg(SUCCESS_MSG);
+        commonResponse.setData(data);
+        return commonResponse;
+    }
+
+    public static <T> CommonResponse<T> create() {
+        return create(SUCCESS_CODE, SUCCESS_MSG, null);
+    }
+
+    public static <T> CommonResponse<T> create(T data) {
+        return create(SUCCESS_CODE, SUCCESS_MSG, data);
+    }
+
+    public static <T> CommonResponse<T> create(ExceptionEnum exceptionEnum) {
+        return create(exceptionEnum.getCode(), exceptionEnum.getMsg(), null);
+    }
+
+    public static <T> CommonResponse<T> create(ExceptionEnum exceptionEnum, String msg) {
+        return create(exceptionEnum.getCode(), msg, null);
+    }
+
+    public static <T> CommonResponse<T> create(int code, String msg) {
+        return create(code, msg, null);
+    }
+
+    public static <T> CommonResponse<T> create(int code, String msg, T data) {
+        CommonResponse<T> commonResponse = new CommonResponse<>();
+        commonResponse.setCode(code);
+        commonResponse.setMsg(msg);
+        commonResponse.setData(data);
+        return commonResponse;
+    }
+
+    public boolean isSuccess() {
+        return this.code == SUCCESS_CODE;
+    }
+
+}

+ 13 - 0
core/src/main/java/com/tzld/rta/common/constant/ResponseConstant.java

@@ -0,0 +1,13 @@
+package com.tzld.rta.common.constant;
+
+/**
+ * 响应常量
+ *
+ * @author xueyiming
+ */
+public interface ResponseConstant {
+
+    int SUCCESS_CODE = 0;
+
+    String SUCCESS_MSG = "success";
+}

+ 30 - 0
core/src/main/java/com/tzld/rta/common/enums/EnumUploadFileType.java

@@ -0,0 +1,30 @@
+package com.tzld.rta.common.enums;
+
+public enum EnumUploadFileType {
+	PICTURE(1,"1"),
+	VIDEO(2,"2"),
+	VOICE(3,"3"),
+	FILE(4,"4"),
+	GIF(5,"5"),
+	SUBTITLE(6,"6"),
+	;
+
+	private Integer intType;
+	private String strType;
+	EnumUploadFileType(Integer intType, String strType){
+		this.intType = intType;
+		this.strType = strType;
+	}
+	public Integer getIntType() {
+		return intType;
+	}
+	public void setIntType(Integer intType) {
+		this.intType = intType;
+	}
+	public String getStrType() {
+		return strType;
+	}
+	public void setStrType(String strType) {
+		this.strType = strType;
+	}
+}

+ 32 - 0
core/src/main/java/com/tzld/rta/common/enums/ExceptionEnum.java

@@ -0,0 +1,32 @@
+package com.tzld.rta.common.enums;
+
+/**
+ * 异常枚举
+ * 通用 code三位负整数
+ * 业务 code四位正整数,其中第一位代表功能模块
+ */
+
+public enum ExceptionEnum {
+
+    SYSTEM_ERROR(-101, "系统错误"),
+    DATA_ERROR(-102, "数据异常,请联系管理员"),
+    PARAM_ERROR(-103, "参数异常"),
+
+    ;
+    private int code;
+    private String msg;
+
+    public int getCode() {
+        return code;
+    }
+
+
+    public String getMsg() {
+        return msg;
+    }
+
+    ExceptionEnum(int code, String msg) {
+        this.code = code;
+        this.msg = msg;
+    }
+}

+ 87 - 0
core/src/main/java/com/tzld/rta/common/exception/CommonException.java

@@ -0,0 +1,87 @@
+package com.tzld.rta.common.exception;
+
+import com.tzld.rta.common.enums.ExceptionEnum;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 通用异常
+ */
+public class CommonException extends RuntimeException {
+
+    /**
+     *
+     */
+    private static final long serialVersionUID = 1L;
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(CommonException.class);
+    /**
+     * 异常
+     */
+    private ExceptionEnum exceptionEnum;
+    /**
+     * 错误码
+     */
+    private int code;
+    /**
+     * 异常信息
+     */
+    private String msg;
+
+
+    public int getCode() {
+        return code;
+    }
+
+    public void setCode(int code) {
+        this.code = code;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+
+    public CommonException(Throwable throwable) {
+        super(throwable);
+    }
+
+    public CommonException(int code, String msg) {
+        super(msg);
+        this.code = code;
+        this.msg = msg;
+    }
+
+    public CommonException(ExceptionEnum exceptionEnum) {
+        super(exceptionEnum.getMsg());
+        this.exceptionEnum = exceptionEnum;
+        this.code = exceptionEnum.getCode();
+        this.msg = exceptionEnum.getMsg();
+    }
+
+
+    public CommonException(int code, String msg, Throwable throwable) {
+        super(msg, throwable);
+        this.code = code;
+        this.msg = msg;
+    }
+
+    public CommonException(ExceptionEnum exceptionEnum, Throwable throwable) {
+        super(exceptionEnum.getMsg(), throwable);
+        this.exceptionEnum = exceptionEnum;
+        this.code = exceptionEnum.getCode();
+        this.msg = exceptionEnum.getMsg();
+    }
+
+
+    @Override
+    public void printStackTrace() {
+        if (exceptionEnum != null) {
+            LOGGER.info("exception code = {}, msg = {}", exceptionEnum.getCode(), exceptionEnum.getMsg());
+        }
+        LOGGER.info("exception code = {}, msg = {}", code, msg);
+    }
+}

+ 43 - 0
core/src/main/java/com/tzld/rta/config/RedisConfig.java

@@ -0,0 +1,43 @@
+package com.tzld.rta.config;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
+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.serializer.GenericJackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.RedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+@Configuration
+public class RedisConfig {
+
+    @Bean
+    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory){
+        RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
+        redisTemplate.setConnectionFactory(redisConnectionFactory);
+        //设置value的序列化方式json
+        redisTemplate.setValueSerializer(redisSerializer());
+        //设置key序列化方式String
+        redisTemplate.setKeySerializer(new StringRedisSerializer());
+        //设置hash key序列化方式String
+        redisTemplate.setHashKeySerializer(new StringRedisSerializer());
+        //设置hash value序列化json
+        redisTemplate.setHashValueSerializer(redisSerializer());
+        redisTemplate.afterPropertiesSet();
+        return redisTemplate;
+    }
+
+    public RedisSerializer<Object> redisSerializer() {
+        //创建JSON序列化器
+        ObjectMapper objectMapper = new ObjectMapper();
+        objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
+        //必须设置,否则无法序列化实体类对象
+        objectMapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL);
+        return new GenericJackson2JsonRedisSerializer(objectMapper);
+    }
+
+}

+ 11 - 0
core/src/main/java/com/tzld/rta/config/SchedulingConfig.java

@@ -0,0 +1,11 @@
+package com.tzld.rta.config;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+@Configuration(proxyBeanMethods = false)
+@EnableScheduling
+@Profile("prod")
+public class SchedulingConfig {
+}

+ 56 - 0
core/src/main/java/com/tzld/rta/config/SwaggerConfig.java

@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.tzld.rta.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+/**
+ * swagger2 配置
+ */
+@Configuration
+@Profile({"dev","test","pre"})
+@EnableSwagger2
+public class SwaggerConfig {
+
+    @Bean
+    public Docket createRestApi() {
+        return new Docket(DocumentationType.SWAGGER_2)
+                .apiInfo(apiInfo())
+                .select()
+                .apis(RequestHandlerSelectors.basePackage("com.tzld.rta.controller"))
+                .paths(PathSelectors.any())
+                .build();
+    }
+
+    private ApiInfo apiInfo() {
+        return new ApiInfoBuilder()
+                .title("tencentRta server swagger api")
+                .description("tencentRta server swagger api")
+                .version("1.0")
+                .build();
+    }
+}

+ 49 - 0
core/src/main/java/com/tzld/rta/config/XxlJobConfig.java

@@ -0,0 +1,49 @@
+package com.tzld.rta.config;
+
+import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class XxlJobConfig {
+
+
+    @Value("${xxl.job.admin.addresses}")
+    private String adminAddresses;
+
+    @Value("${xxl.job.accessToken}")
+    private String accessToken;
+
+    @Value("${xxl.job.executor.appname}")
+    private String appName;
+
+    @Value("${xxl.job.executor.address}")
+    private String address;
+
+    @Value("${xxl.job.executor.ip}")
+    private String ip;
+
+    @Value("${xxl.job.executor.port}")
+    private int port;
+
+    @Value("${xxl.job.executor.logpath}")
+    private String logPath;
+
+    @Value("${xxl.job.executor.logretentiondays}")
+    private int logRetentionDays;
+
+    @Bean
+    public XxlJobSpringExecutor xxlJobExecutor() {
+        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
+        xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
+        xxlJobSpringExecutor.setAppname(appName);
+        xxlJobSpringExecutor.setAddress(address);
+        xxlJobSpringExecutor.setIp(ip);
+        xxlJobSpringExecutor.setPort(port);
+        xxlJobSpringExecutor.setAccessToken(accessToken);
+        xxlJobSpringExecutor.setLogPath(logPath);
+        xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
+        return xxlJobSpringExecutor;
+    }
+}

+ 68 - 0
core/src/main/java/com/tzld/rta/config/db/RtaDBConfig.java

@@ -0,0 +1,68 @@
+package com.tzld.rta.config.db;
+
+import com.zaxxer.hikari.HikariDataSource;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.mybatis.spring.SqlSessionFactoryBean;
+import org.mybatis.spring.boot.autoconfigure.MybatisProperties;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+import org.springframework.jdbc.datasource.DataSourceTransactionManager;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+import javax.sql.DataSource;
+
+@Configuration
+@EnableTransactionManagement
+public class RtaDBConfig {
+
+    // 1. 配置 tencentRta 数据源
+    @Primary
+    @Bean(name = "tencentRtaDataSource")
+    @ConfigurationProperties(prefix = "spring.datasource.rta")
+    public DataSource tencentRtaDataSource() {
+        return new HikariDataSource(); // 使用 HikariCP 连接池
+    }
+
+    // 2. 配置 tencentRta 专属 SqlSessionFactory
+    @Primary
+    @Bean(name = "tencentRtaSqlSessionFactory")
+    public SqlSessionFactory tencentRtaSqlSessionFactory(
+            @Qualifier("tencentRtaDataSource") DataSource tencentRtaDataSource,
+            MybatisProperties properties) throws Exception {
+        SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
+        sessionFactory.setDataSource(tencentRtaDataSource); // 关联 tencentRta 数据源
+        
+        // 关键:指定 tencentRta 模块的 mapper 文件路径(隔离其他数据源)
+        // 使用 try-catch 避免空目录报错
+        try {
+            org.springframework.core.io.Resource[] mapperResources = 
+                new PathMatchingResourcePatternResolver().getResources("classpath:mapper/rta/**/*.xml");
+            if (mapperResources != null && mapperResources.length > 0) {
+                sessionFactory.setMapperLocations(mapperResources);
+            }
+        } catch (Exception e) {
+            // 如果目录不存在或为空,不设置 mapper  locations,应用仍可正常启动
+            // 后续添加 mapper 文件后重启即可生效
+        }
+        
+        sessionFactory.setTypeAliasesPackage("com.tzld.rta");
+        sessionFactory.setConfiguration(properties.getConfiguration());
+        return sessionFactory.getObject();
+    }
+
+
+    // 3. 配置 tencentRta 事务管理器
+    @Primary
+    @Bean(name = "tencentRtaTransactionManager")
+    public PlatformTransactionManager tencentRtaTransactionManager(
+            @Qualifier("tencentRtaDataSource") DataSource tencentRtaDataSource) {
+        return new DataSourceTransactionManager(tencentRtaDataSource);
+    }
+
+}
+

+ 19 - 0
core/src/main/java/com/tzld/rta/config/mybatis/RtaMybatisConfig.java

@@ -0,0 +1,19 @@
+package com.tzld.rta.config.mybatis;
+
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.mybatis.spring.SqlSessionTemplate;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@MapperScan(basePackages = "com.tzld.rta.dao.mapper.rta",
+        sqlSessionFactoryRef = "tencentRtaSqlSessionFactory")
+public class RtaMybatisConfig {
+
+    @Bean(name = "tencentRtaSqlSessionTemplate")
+    public SqlSessionTemplate tencentRtaSqlSessionTemplate(@Qualifier("tencentRtaSqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
+        return new SqlSessionTemplate(sqlSessionFactory);
+    }
+}

+ 31 - 0
core/src/main/java/com/tzld/rta/dao/generator/MybatisGeneratorMain.java

@@ -0,0 +1,31 @@
+package com.tzld.rta.dao.generator;
+
+import org.mybatis.generator.api.MyBatisGenerator;
+import org.mybatis.generator.config.Configuration;
+import org.mybatis.generator.config.xml.ConfigurationParser;
+import org.mybatis.generator.exception.InvalidConfigurationException;
+import org.mybatis.generator.exception.XMLParserException;
+import org.mybatis.generator.internal.DefaultShellCallback;
+
+import java.io.File;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class MybatisGeneratorMain {
+
+	public static void main(String[] args)
+			throws SQLException, IOException, InterruptedException, InvalidConfigurationException, XMLParserException {
+		List<String> warnings = new ArrayList<String>();
+		boolean overwrite = true;
+		File configFile = new File(MybatisGeneratorMain.class.getResource("/generator/mybatis-rta-generator-config.xml").getFile());
+
+		ConfigurationParser cp = new ConfigurationParser(warnings);
+		Configuration config = cp.parseConfiguration(configFile);
+		DefaultShellCallback callback = new DefaultShellCallback(overwrite);
+		MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
+		myBatisGenerator.generate(null);
+		System.out.println("generate finish");
+	}
+}

+ 73 - 0
core/src/main/java/com/tzld/rta/handle/GlobalExceptionHandle.java

@@ -0,0 +1,73 @@
+package com.tzld.rta.handle;
+
+import com.tzld.rta.common.base.CommonResponse;
+import com.tzld.rta.common.enums.ExceptionEnum;
+import com.tzld.rta.common.exception.CommonException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.util.CollectionUtils;
+import org.springframework.validation.BindException;
+import org.springframework.validation.ObjectError;
+import org.springframework.web.bind.MethodArgumentNotValidException;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+
+/**
+ * 全局异常处理器
+ */
+
+@RestControllerAdvice
+public class GlobalExceptionHandle {
+
+    private static Logger LOGGER = LoggerFactory.getLogger(GlobalExceptionHandle.class);
+
+    @ExceptionHandler
+    public Object handleException(HttpServletRequest req, Exception exception) throws Exception {
+        String uri = req.getRequestURI();
+        CommonResponse<Object> response = new CommonResponse<Object>();
+        // 业务异常
+        if (exception instanceof CommonException) {
+            CommonException e = (CommonException) exception;
+            response.setCode(e.getCode());
+            response.setMsg(e.getMsg());
+            LOGGER.info("uri:" + uri + "\n" + "CustomException log.", exception);
+        } else if (exception instanceof MethodArgumentNotValidException) {
+            // 参数校验异常
+            MethodArgumentNotValidException e = (MethodArgumentNotValidException) exception;
+            List<ObjectError> errorList = e.getBindingResult().getAllErrors();
+            StringBuilder errorMsg = new StringBuilder();
+            errorMsg.append("|");
+            if (!CollectionUtils.isEmpty(errorList)) {
+                for (ObjectError objectError : errorList) {
+                    errorMsg.append(objectError.getDefaultMessage()).append("|");
+                }
+            }
+            response.setCode(ExceptionEnum.PARAM_ERROR.getCode());
+            response.setMsg(errorMsg.toString());
+            LOGGER.error("uri:" + uri + "\n" + "MethodArgumentNotValidException log.", exception);
+        } else if (exception instanceof BindException) {
+            // 参数绑定异常
+            BindException e = (BindException) exception;
+            List<ObjectError> errorList = e.getBindingResult().getAllErrors();
+            StringBuilder errorMsg = new StringBuilder();
+            errorMsg.append("|");
+            if (!CollectionUtils.isEmpty(errorList)) {
+                for (ObjectError objectError : errorList) {
+                    errorMsg.append(objectError.getDefaultMessage()).append("|");
+                }
+            }
+            response.setCode(ExceptionEnum.PARAM_ERROR.getCode());
+            response.setMsg(errorMsg.toString());
+            LOGGER.error("uri:" + uri + "\n" + "BindException log.", exception);
+        } else {
+            response.setCode(ExceptionEnum.SYSTEM_ERROR.getCode());
+            response.setMsg(ExceptionEnum.SYSTEM_ERROR.getMsg());
+            LOGGER.error("uri:" + uri + "\n" + "unknownException log.", exception);
+        }
+        return response;
+    }
+
+}

+ 38 - 0
core/src/main/java/com/tzld/rta/interceptor/CrosDomainAllowInterceptor.java

@@ -0,0 +1,38 @@
+package com.tzld.rta.interceptor;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.servlet.HandlerInterceptor;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@Component
+public class CrosDomainAllowInterceptor implements HandlerInterceptor {
+
+    @Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
+            throws Exception {
+        response.addHeader("Access-Control-Allow-Origin", "*");
+        response.addHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
+        response.addHeader("Access-Control-Allow-Headers", "*");
+        if (request.getMethod().equals(RequestMethod.OPTIONS.name())) {
+            response.setStatus(HttpStatus.OK.value());
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
+                           ModelAndView modelAndView) throws Exception {
+    }
+
+    @Override
+    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
+            throws Exception {
+    }
+
+}

+ 39 - 0
core/src/main/java/com/tzld/rta/model/entity/DeepSeekOfficialApiResponse.java

@@ -0,0 +1,39 @@
+package com.tzld.rta.model.entity;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class DeepSeekOfficialApiResponse {
+
+    private String id;
+    private String object;
+    private long created;
+    private String model;
+    private List<Choice> choices;
+    private Usage usage;
+
+
+    @Data
+    public static class Choice {
+        private long index;
+        private Message message;
+        private String finishReason;
+    }
+
+
+    @Data
+    public static class Message {
+        private String role;
+        private String content;
+    }
+
+    @Data
+    public static class Usage {
+        private long promptTokens;
+        private long completionTokens;
+        private long totalTokens;
+    }
+
+}

+ 11 - 0
core/src/main/java/com/tzld/rta/model/entity/DeepSeekResult.java

@@ -0,0 +1,11 @@
+package com.tzld.rta.model.entity;
+
+import lombok.Data;
+
+@Data
+public class DeepSeekResult {
+    private boolean success;
+    private DeepSeekOfficialApiResponse response;
+    private String failReason;
+    private String responseStr;
+}

+ 25 - 0
core/src/main/java/com/tzld/rta/model/vo/FileInfo.java

@@ -0,0 +1,25 @@
+package com.tzld.rta.model.vo;
+
+import lombok.Data;
+
+/**
+ * @author sunxy
+ */
+@Data
+public class FileInfo {
+
+    /**
+     * 文件名
+     */
+    private String fileName;
+
+    /**
+     * 文件URL
+     */
+    private String fileUrl;
+
+    /**
+     * 文件Size,单位KB
+     */
+    private Double fileSize;
+}

+ 49 - 0
core/src/main/java/com/tzld/rta/model/vo/PolicyDetailVO.java

@@ -0,0 +1,49 @@
+package com.tzld.rta.model.vo;
+
+import java.util.List;
+
+public class PolicyDetailVO {
+	public List<PolicyVO> Statement;
+	public String Version;
+
+	public List<PolicyVO> getStatement() {
+		return Statement;
+	}
+
+	public void setStatement(List<PolicyVO> statement) {
+		Statement = statement;
+	}
+
+	public String getVersion() {
+		return Version;
+	}
+
+	public void setVersion(String version) {
+		Version = version;
+	}
+
+	public static class PolicyVO {
+		public List<String> Action;
+		public String Effect;
+		public List<String> Resource;
+		public List<String> getAction() {
+			return Action;
+		}
+		public void setAction(List<String> action) {
+			Action = action;
+		}
+		public String getEffect() {
+			return Effect;
+		}
+		public void setEffect(String effect) {
+			Effect = effect;
+		}
+		public List<String> getResource() {
+			return Resource;
+		}
+		public void setResource(List<String> resource) {
+			Resource = resource;
+		}
+		
+	}
+}

+ 13 - 0
core/src/main/java/com/tzld/rta/model/vo/SignatureVO.java

@@ -0,0 +1,13 @@
+package com.tzld.rta.model.vo;
+
+import lombok.Data;
+
+@Data
+public class SignatureVO {
+    private String accessId;
+    private String policy;
+    private String signature;
+    private String fileName;
+    private String host;
+    private String expire;
+}

+ 20 - 0
core/src/main/java/com/tzld/rta/model/vo/StsTokenVO.java

@@ -0,0 +1,20 @@
+package com.tzld.rta.model.vo;
+
+import lombok.Data;
+
+@Data
+public class StsTokenVO {
+    private String Expiration;
+    private String AccessKeyId;
+    private String AccessKeySecret;
+    private String SecurityToken;
+    private String RequestId;
+    private String FileName;
+    private String Host;
+    private String[] Hosts;
+    private String Bucket;
+    private String Region;
+    private Boolean Cname;
+    private Long serverTimestamp;
+
+}

+ 139 - 0
core/src/main/java/com/tzld/rta/util/BaseUtils.java

@@ -0,0 +1,139 @@
+package com.tzld.rta.util;
+
+import org.apache.http.util.TextUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.util.StringUtils;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.Objects;
+import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class BaseUtils {
+
+    public static void copyProperties(Object orig, Object dest) {
+        // spring的BeanUtils性能较好
+        BeanUtils.copyProperties(orig, dest);
+    }
+
+    public static String getUUID() {
+        return UUID.randomUUID().toString();
+    }
+
+    public static String getUUIDStr() {
+        return UUID.randomUUID().toString().replaceAll("-", "");
+    }
+
+    private static String[] chars = new String[]{"a", "b", "c", "d", "e", "f",
+            "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
+            "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5",
+            "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I",
+            "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
+            "W", "X", "Y", "Z"};
+
+    public static String getShortUUIDStr() {
+        StringBuffer shortBuffer = new StringBuffer();
+        String uuid = UUID.randomUUID().toString().replace("-", "");
+        for (int i = 0; i < 8; i++) {
+            String str = uuid.substring(i * 4, i * 4 + 4);
+            int x = Integer.parseInt(str, 16);
+            shortBuffer.append(chars[x % 0x3E]);
+        }
+        return shortBuffer.toString();
+    }
+
+    public static String getShortUUIDStr_6() {
+        StringBuffer shortBuffer = new StringBuffer();
+        String uuid = UUID.randomUUID().toString().replace("-", "");
+        System.out.println("uuid = " + uuid.length() + " , chars = " + chars.length);
+        for (int i = 0; i < 6; i++) {
+            String str = uuid.substring(i * 5, i * 5 + 5);
+            int x = Integer.parseInt(str, 16);
+            shortBuffer.append(chars[x % 0x3E]);
+        }
+        return shortBuffer.toString();
+    }
+
+    /**
+     * 带时间戳的uuid
+     *
+     * @return
+     */
+    public static String getTimestampUUIDStr() {
+        return UUID.randomUUID().toString().replaceAll("-", "") + System.currentTimeMillis();
+    }
+
+    public static boolean isUidAvailable(Long uid) {
+        return Objects.nonNull(uid) && uid >= 0;
+    }
+
+    public static boolean checkEmailAddressAvailable(String email) {
+        String check = "^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$";
+        Pattern regex = Pattern.compile(check);
+        Matcher matcher = regex.matcher(email);
+        return matcher.matches();
+    }
+
+    public static int getInt(String intValue, int defaultValue) {
+        try {
+            return Integer.parseInt(intValue);
+        } catch (NumberFormatException e) {
+            e.printStackTrace();
+        }
+        return defaultValue;
+    }
+
+    public static boolean isContainChinese(String str) {
+        if (TextUtils.isEmpty(str)) {
+            return false;
+        }
+        try {
+            Pattern p = Pattern.compile("[\u4E00-\u9FA5|\\!|\\,|\\。|\\(|\\)|\\《|\\》|\\“|\\”|\\?|\\:|\\;|\\【|\\】]");
+            Matcher m = p.matcher(str);
+            if (m.find()) {
+                return true;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return false;
+    }
+
+    public static String calcRate(Integer a, Integer b) {
+        if (a == null || b == null || b == 0) {
+            return "0";
+        }
+        return new BigDecimal(a).divide(new BigDecimal(b), 2, RoundingMode.HALF_UP).toString();
+    }
+
+    public static boolean isNumberStr(String str){
+        Pattern pattern = Pattern.compile("[0-9]*");
+        return pattern.matcher(str).matches();
+    }
+
+    public static String getFirstGroupPlanExeId(String planExeId) {
+        if (StringUtils.hasText(planExeId) && planExeId.contains("_")) {
+            return planExeId.substring(0, planExeId.indexOf("_"));
+        }
+        return planExeId;
+    }
+
+    public static boolean isFirstGroupPlanExeId(String planExeId) {
+        if (StringUtils.hasText(planExeId) && planExeId.contains("_")) {
+            return false;
+        }
+        return true;
+    }
+
+    public static void main(String[] args) {
+        System.out.println(checkEmailAddressAvailable("a-a_a@q-q.A"));
+        System.out.println(getUUIDStr());
+        System.out.println(getShortUUIDStr());
+        System.out.println(getShortUUIDStr_6());
+        System.out.println(isNumberStr("20240201052729691500183"));
+        System.out.println(getFirstGroupPlanExeId("20240314125002672235936_2"));
+        System.out.println("20240314125002672235936_2".substring("20240314125002672235936_2".indexOf("_") + 1));
+    }
+}

+ 169 - 0
core/src/main/java/com/tzld/rta/util/CdnUtil.java

@@ -0,0 +1,169 @@
+package com.tzld.rta.util;
+
+import cn.hutool.core.net.URLEncodeUtil;
+import com.alibaba.fastjson.JSON;
+import com.aliyuncs.DefaultAcsClient;
+import com.aliyuncs.IAcsClient;
+import com.aliyuncs.cdn.model.v20141111.DescribeDomainBpsDataRequest;
+import com.aliyuncs.cdn.model.v20141111.DescribeDomainBpsDataResponse;
+import com.aliyuncs.exceptions.ClientException;
+import com.aliyuncs.exceptions.ServerException;
+import com.aliyuncs.profile.DefaultProfile;
+import com.stuuudy.commons.external.filestorage.enums.EnumFileType;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Objects;
+
+public class CdnUtil {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(CdnUtil.class);
+
+//    public static final String VIDEO_CDN_URL_HOST = "https://xycdn.yishihui.com/";
+    public static final String VIDEO_CDN_URL_HOST = "http://rescdn.yishihui.com/";
+
+    public static final String PICTURE_CDN_URL_HOST_PICTURE = "http://rescdn.yishihui.com/";
+    public static final String DOWNLOAD_CDN_URL_HOST_PICTURE = "https://rescdn.yishihui.com/";
+
+
+    private static IAcsClient client;
+
+    static {
+        if (Objects.isNull(client)) {
+            DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "LTAInlg8tWvBeiJe", "hDu5v2nrOmdY0AjlqGnZkW57mxCOLO");
+            /** use STS Token
+             DefaultProfile profile = DefaultProfile.getProfile(
+             "<your-region-id>",           // The region ID
+             "<your-access-key-id>",       // The AccessKey ID of the RAM account
+             "<your-access-key-secret>",   // The AccessKey Secret of the RAM account
+             "<your-sts-token>");          // STS Token
+             **/
+            client = new DefaultAcsClient(profile);
+        }
+    }
+
+
+    public static Double getDescribeDomainBpsData() {
+        DescribeDomainBpsDataRequest request = new DescribeDomainBpsDataRequest();
+        //需要时区为GMT
+        LocalDateTime endTime = LocalDateTime.now().plusHours(-8);
+        LocalDateTime startTime = endTime.plusMinutes(-10);
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        String[] starts = startTime.format(df).split(" ");
+        String[] ends = endTime.format(df).split(" ");
+        String start = starts[0] + "T" + starts[1] + "Z";
+        String end = ends[0] + "T" + ends[1] + "Z";
+        request.setStartTime(start);
+        request.setEndTime(end);
+        LOGGER.info("getDescribeDomainBpsData request = {}", JSON.toJSONString(request));
+        try {
+            DescribeDomainBpsDataResponse response = client.getAcsResponse(request);
+            LOGGER.info("getDescribeDomainBpsData response = {}", JSON.toJSONString(response));
+            if (Objects.isNull(response) || Objects.isNull(response.getBpsDataPerInterval())
+                    || response.getBpsDataPerInterval().isEmpty() || response.getBpsDataPerInterval().size() <= 1) {
+                //只有1条可能不准确
+                return null;
+            }
+            DescribeDomainBpsDataResponse.DataModule module1 = response.getBpsDataPerInterval().get(1);
+            if (Objects.nonNull(module1) && Objects.equals("0", module1.getValue())) {
+                return null;
+            }
+            DescribeDomainBpsDataResponse.DataModule module = response.getBpsDataPerInterval().get(0);
+            if (Objects.nonNull(module) && Objects.nonNull(module.getValue())) {
+                return Double.parseDouble(module.getValue()) / 1000 / 1000 / 1000;
+            }
+        } catch (ServerException e) {
+            LOGGER.error("getDescribeDomainBpsData ServerException", e);
+        } catch (ClientException e) {
+            LOGGER.error("getDescribeDomainBpsData ClientException", e);
+        }
+        return null;
+    }
+
+    public static String getCdnUrlHost(EnumFileType fileType) {
+        if (Objects.isNull(fileType)) {
+            return null;
+        }
+        switch (fileType) {
+            case VIDEO:
+                return VIDEO_CDN_URL_HOST;
+            case PICTURE:
+                return PICTURE_CDN_URL_HOST_PICTURE;
+        }
+        return null;
+    }
+
+
+    public static String getOssHttpUrl(String key) {
+        if (StringUtils.isBlank(key)) {
+            return key;
+        }
+        if (org.springframework.util.StringUtils.startsWithIgnoreCase(key, "http")) {
+            return key;
+        } else {
+            String url = DOWNLOAD_CDN_URL_HOST_PICTURE + key;
+            return URLEncodeUtil.encode(url);
+        }
+    }
+
+//    public static void main(String[] args_) throws Exception {
+//        DescribeDomainBpsDataRequest request = new DescribeDomainBpsDataRequest();
+//        //需要时区为GMT
+//        LocalDateTime endTime = LocalDateTime.now().plusHours(-8);
+//        LocalDateTime startTime = endTime.plusMinutes(-10);
+//        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+//        String[] starts = startTime.format(df).split(" ");
+//        String[] ends = endTime.format(df).split(" ");
+//        String start = starts[0] + "T" + starts[1] + "Z";
+//        String end = ends[0] + "T" + ends[1] + "Z";
+//        request.setStartTime(start);
+//        request.setEndTime(end);
+//        System.out.println("---" + JSON.toJSONString(request));
+//        try {
+//            DescribeDomainBpsDataResponse response = client.getAcsResponse(request);
+//
+//            System.out.println("---" + JSON.toJSONString(response));
+//            DescribeDomainBpsDataResponse.DataModule module = response.getBpsDataPerInterval().get(0);
+//
+//            System.out.println("---" + module.getValue());
+//            double d = Double.valueOf(module.getValue()) / 1000 / 1000 / 1000;
+//            System.out.println(d);
+//
+////            System.out.println(new Gson().toJson(response));
+//        } catch (ServerException e) {
+//            e.printStackTrace();
+//        } catch (ClientException e) {
+//            System.out.println("ErrCode:" + e.getErrCode());
+//            System.out.println("ErrMsg:" + e.getErrMsg());
+//            System.out.println("RequestId:" + e.getRequestId());
+//        }
+//
+//    }
+
+    public static String getFileExtensionFromUrl(String uri) {
+        if (StringUtils.isBlank(uri)) {
+            return "";
+        }
+        String fileExtension = "";
+        try {
+            if (uri.contains(".")) {
+                int lastDotIndex = uri.lastIndexOf('.');
+                if (lastDotIndex > 0) {
+                    fileExtension = uri.substring(lastDotIndex + 1);
+                }
+            }
+        } catch (Exception e) {
+            LOGGER.error("getFileExtensionFromURL error", e);
+        }
+        return fileExtension;
+    }
+
+    public static void main(String[] args) {
+        String url = "ad/material_1564536000000.mp4";
+        System.out.println(getFileExtensionFromUrl(url));
+    }
+
+}

+ 333 - 0
core/src/main/java/com/tzld/rta/util/DateUtils.java

@@ -0,0 +1,333 @@
+package com.tzld.rta.util;
+
+import org.springframework.util.StringUtils;
+
+import java.text.SimpleDateFormat;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
+import java.time.temporal.ChronoUnit;
+import java.util.*;
+
+/**
+ * @author dyp
+ */
+public final class DateUtils {
+    public static String getCurrentDateStr(String format) {
+        SimpleDateFormat dateFormat = new SimpleDateFormat(format);
+        Date currentDate = new Date();
+        return dateFormat.format(currentDate);
+    }
+
+    public static int getCurrentHour() {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+        return calendar.get(Calendar.HOUR_OF_DAY);
+    }
+
+    public static String getBeforeDaysDateStr(String format, int d) {
+        SimpleDateFormat dateFormat = new SimpleDateFormat(format);
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+        calendar.setTime(new Date());
+        calendar.add(Calendar.DAY_OF_MONTH, -d);
+        Date previousDate = calendar.getTime();
+        return dateFormat.format(previousDate);
+    }
+
+    public static String getBeforeDaysDateStr(String dateStr, String format, int d) {
+        SimpleDateFormat dateFormat = new SimpleDateFormat(format);
+        Date date = new Date();
+        try {
+            date = dateFormat.parse(dateStr);
+        } catch (Exception ignore) {}
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+        calendar.setTime(date);
+        calendar.add(Calendar.DAY_OF_MONTH, -d);
+        Date previousDate = calendar.getTime();
+        return dateFormat.format(previousDate);
+    }
+
+
+    public static boolean ifTimeRangeInNow(String timeRange) {
+        try {
+
+            String[] split = timeRange.split("-");
+            if (split.length != 2) {
+                return false;
+            }
+            String startTime = split[0];
+            String endTime = split[1];
+            if (startTime.length() != 10 || endTime.length() != 10) {
+                return false;
+            }
+            LocalDateTime now = LocalDateTime.now();
+            LocalDateTime start = LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyyMMddHH"));
+            LocalDateTime end = LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern("yyyyMMddHH"));
+            return now.equals(start) || (now.isAfter(start) && now.isBefore(end));
+        } catch (Exception e) {
+//            e.printStackTrace();
+            return false;
+        }
+    }
+
+    public static long dateStrToTimestamp(String dateStr, String format) {
+        // 定义日期格式
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
+
+        // 解析输入的日期字符串为LocalDate对象
+        LocalDate date = LocalDate.parse(dateStr, formatter);
+
+        // 将LocalDate转换为LocalDateTime,时间部分设为00:00:00
+        LocalDateTime dateTime = date.atStartOfDay();
+
+        // 定义北京时区
+        ZoneId zone = ZoneId.of("Asia/Shanghai");
+
+        // 将LocalDateTime转换为时间戳(秒数),使用北京时区
+        return dateTime.toEpochSecond(zone.getRules().getOffset(dateTime));
+    }
+
+    public static boolean isValidDate(String dateString) {
+        // 定义日期格式
+        DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+
+        try {
+            // 尝试解析日期字符串
+            LocalDate date = LocalDate.parse(dateString, dateFormatter);
+            return true; // 如果解析成功,返回 true
+        } catch (DateTimeParseException e) {
+            return false; // 如果解析失败,返回 false
+        }
+    }
+
+    public static String timestampToYMDStr(Long timestamp, String format) {
+
+        // 定义北京时区
+        ZoneId zone = ZoneId.of("Asia/Shanghai");
+
+        // 将时间戳转换为LocalDateTime
+        LocalDateTime dateTime = LocalDateTime.ofInstant(Instant.ofEpochSecond(timestamp), zone);
+
+        // 定义日期格式为"yyyyMMddHHmmss"
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
+
+        // 将LocalDateTime格式化为字符串
+        return dateTime.format(formatter);
+    }
+
+    public static String findNearestDate(List<String> dateList, String targetDateStr, String format) {
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
+        // 将目标日期字符串转换为 LocalDate
+        LocalDate targetDate = LocalDate.parse(targetDateStr, formatter);
+
+        // 初始化最近的日期和最小的天数差值
+        String nearestDateStr = null;
+        long minDiff = Long.MAX_VALUE;
+
+        // 遍历日期列表,找到最近的日期
+        for (String dateStr : dateList) {
+            LocalDate currentDate = LocalDate.parse(dateStr, formatter);
+            long diff = Math.abs(ChronoUnit.DAYS.between(currentDate, targetDate));  // 计算天数差异
+
+            // 如果找到更小的差异,更新最近的日期
+            if (diff < minDiff) {
+                minDiff = diff;
+                nearestDateStr = dateStr;
+            }
+        }
+
+        return nearestDateStr;  // 返回最近的日期字符串
+    }
+
+    public static List<String> getBeforeDays(String beginDate, String endDate, int days) {
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
+        // 获取今天的日期
+        LocalDate today = LocalDate.now();
+        if (!StringUtils.hasText(beginDate)) {
+            beginDate = today.format(formatter);
+        }
+        if (!StringUtils.hasText(endDate)) {
+            endDate = today.format(formatter);
+        }
+        // 解析输入的日期字符串为LocalDate对象
+        LocalDate date = LocalDate.parse(beginDate, formatter);
+        LocalDate end = LocalDate.parse(endDate, formatter);
+        // 获取从输入日期前三天的日期
+        LocalDate startDate = date.minusDays(days);
+        // 存储所有日期的列表
+        List<String> datesList = new ArrayList<>();
+        // 从startDate到today遍历日期
+        while (startDate.isBefore(today) && !startDate.isAfter(end)) {
+            // 将当前日期格式化为"yyyyMMdd"并添加到列表中
+            datesList.add(startDate.format(formatter));
+            // 日期加1天
+            startDate = startDate.plusDays(1);
+        }
+        return datesList;
+    }
+
+    // 获取每日最小秒数 (当天零点)
+    public static Long getStartOfDay(String dateStr, String formatter) {
+        try {
+            SimpleDateFormat sdf = new SimpleDateFormat(formatter);
+            Date date = sdf.parse(dateStr);
+
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+            calendar.setTime(date);
+            calendar.set(Calendar.HOUR_OF_DAY, 0);
+            calendar.set(Calendar.MINUTE, 0);
+            calendar.set(Calendar.SECOND, 0);
+            calendar.set(Calendar.MILLISECOND, 0);
+
+            return calendar.getTimeInMillis();
+        } catch (Exception e) {
+            Date date = new Date();
+            return date.getTime();
+        }
+    }
+
+    public static Date getStartDateOfDay(Long timestamp) {
+        try {
+            Calendar calendar = Calendar.getInstance();
+            // 设置时区为UTC(你可以根据需要更改时区)
+            calendar.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+            // 将时间戳转换为毫秒并设置时间
+            calendar.setTimeInMillis(timestamp);
+            calendar.set(Calendar.HOUR_OF_DAY, 0);
+            calendar.set(Calendar.MINUTE, 0);
+            calendar.set(Calendar.SECOND, 0);
+            calendar.set(Calendar.MILLISECOND, 0);
+
+            return calendar.getTime();
+        } catch (Exception e) {
+            return new Date();
+        }
+    }
+
+    // 获取每日最大秒数 (当天的23:59:59)
+    public static Long getEndOfDay(String dateStr, String formatter) {
+        try {
+            SimpleDateFormat sdf = new SimpleDateFormat(formatter);
+            Date date = sdf.parse(dateStr);
+
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+            calendar.setTime(date);
+            calendar.set(Calendar.HOUR_OF_DAY, 23);
+            calendar.set(Calendar.MINUTE, 59);
+            calendar.set(Calendar.SECOND, 59);
+            calendar.set(Calendar.MILLISECOND, 999);
+
+            return calendar.getTimeInMillis();
+        } catch (Exception e) {
+            Date date = new Date();
+            return date.getTime();
+        }
+    }
+
+    public static Integer getHourByTimestamp(Long timestamp) {
+        Calendar calendar = Calendar.getInstance();
+        // 设置时区为UTC(你可以根据需要更改时区)
+        calendar.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+        // 将时间戳转换为毫秒并设置时间
+        calendar.setTimeInMillis(timestamp);
+        // 获取小时
+        return calendar.get(Calendar.HOUR_OF_DAY);
+    }
+
+    public static int getMinuteByTimestamp(long timestamp) {
+        Calendar calendar = Calendar.getInstance();
+        // 设置时区为UTC(你可以根据需要更改时区)
+        calendar.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+        // 将时间戳转换为毫秒并设置时间
+        calendar.setTimeInMillis(timestamp);
+        // 获取小时
+        return calendar.get(Calendar.MINUTE);
+    }
+
+
+    public static void main(String[] args) {
+        Calendar calendar = Calendar.getInstance();
+
+        System.out.println((calendar.get(Calendar.DAY_OF_WEEK) + 6) % 7);
+        System.out.println(new SimpleDateFormat("yyyyMMdd").format(calendar.getTime()));
+        System.out.println(new SimpleDateFormat("HH").format(calendar.getTime()));
+
+    }
+
+    public static Long getTodayStart() {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
+        return calendar.getTime().getTime();
+    }
+
+    public static Long getBeforeDayStart(int days) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
+        calendar.add(Calendar.DAY_OF_MONTH, -days);
+        return calendar.getTime().getTime();
+    }
+
+    public static String getBeforeDayStr(String dateStr, String format, int days) {
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
+        LocalDate date = LocalDate.parse(dateStr, formatter);
+        date = date.minusDays(days);
+        return date.format(formatter);
+    }
+
+    public static String getDateString(Long timestamp) {
+        // 创建日期时间格式化器
+        DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyyMMdd");
+        // 将时间戳转换为 LocalDateTime
+        ZoneId zone = ZoneId.of("Asia/Shanghai");
+        LocalDateTime dateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), zone);
+        // 格式化日期时间并返回
+        return dateTime.format(dateFormat);
+    }
+
+    public static String getDateString(Long timestamp, String pattern) {
+        // 创建日期时间格式化器
+        DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern(pattern);
+        // 将时间戳转换为 LocalDateTime
+        ZoneId zone = ZoneId.of("Asia/Shanghai");
+        LocalDateTime dateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), zone);
+        // 格式化日期时间并返回
+        return dateTime.format(dateFormat);
+    }
+
+    public static Date getDate(String dateString) {
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        LocalDate localDate = LocalDate.parse(dateString, formatter);
+        ZoneId zone = ZoneId.of("Asia/Shanghai");
+        return Date.from(localDate.atStartOfDay(zone).toInstant());
+    }
+
+    /**
+     * 日期型转化成字符串类型
+     * @param date
+     * @return
+     */
+    public static String dateToStringyyyyMMdd(Date date) {
+        return new SimpleDateFormat("yyyyMMdd").format(date);
+    }
+
+    public static String formatIso8601Date(Date date) {
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+        df.setTimeZone(new SimpleTimeZone(8, "GMT"));
+        return df.format(date);
+    }
+}

+ 23 - 0
core/src/main/java/com/tzld/rta/util/DistributedIdGenerator.java

@@ -0,0 +1,23 @@
+package com.tzld.rta.util;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Random;
+
+public abstract class DistributedIdGenerator {
+    /**
+     * 生成一个
+     *
+     * @return
+     */
+    public static String generate() {
+        StringBuilder builder = new StringBuilder();
+        builder.append(new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()));
+        builder.append(new Random().nextInt(899999) + 100000);
+        return builder.toString();
+    }
+
+    public static void main(String[] args) {
+        System.out.println(generate());
+    }
+}

+ 69 - 0
core/src/main/java/com/tzld/rta/util/IpUtil.java

@@ -0,0 +1,69 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright © 2021 xrv <xrg@live.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+package com.tzld.rta.util;
+
+import javax.servlet.http.HttpServletRequest;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+/**
+ * @author ehlxr
+ * @since 2021-12-14 15:27.
+ */
+public class IpUtil {
+    public static String getIpAddr(HttpServletRequest request) {
+        String ipAddress;
+        ipAddress = request.getHeader("x-forwarded-for");
+        if (ipAddress == null || ipAddress.length() == 0
+                || "unknown".equalsIgnoreCase(ipAddress)) {
+            ipAddress = request.getHeader("Proxy-Client-IP");
+        }
+        if (ipAddress == null || ipAddress.length() == 0
+                || "unknown".equalsIgnoreCase(ipAddress)) {
+            ipAddress = request.getHeader("WL-Proxy-Client-IP");
+        }
+        if (ipAddress == null || ipAddress.length() == 0
+                || "unknown".equalsIgnoreCase(ipAddress)) {
+            ipAddress = request.getRemoteAddr();
+            if ("127.0.0.1".equals(ipAddress)) {
+                // 根据网卡取本机配置的IP
+                InetAddress inet;
+                try {
+                    inet = InetAddress.getLocalHost();
+                    ipAddress = inet.getHostAddress();
+                } catch (UnknownHostException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        // 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
+        if (ipAddress != null && ipAddress.length() > 15) { // "***.***.***.***".length()
+            if (ipAddress.indexOf(",") > 0) {
+                ipAddress = ipAddress.substring(0, ipAddress.indexOf(","));
+            }
+        }
+        return ipAddress;
+    }
+}

+ 50 - 0
core/src/main/java/com/tzld/rta/util/MapBuilder.java

@@ -0,0 +1,50 @@
+package com.tzld.rta.util;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * @author: TanJingyu
+ * @create:2023-06-12 13:28:18
+ **/
+public class MapBuilder {
+
+    private MapBuilder() {
+    }
+
+    public static <K, V> Builder<K, V> builder() {
+        return new Builder<>(null);
+    }
+
+    public static <K, V> Builder<K, V> builder(Map<K, V> map) {
+        return new Builder<>(map);
+    }
+
+    public static class Builder<K, V> {
+        private Map<K, V> resultMap = new HashMap<>();
+
+        private Builder(Map<K, V> map) {
+            if (Objects.nonNull(map)) {
+                resultMap = map;
+            }
+        }
+
+        public Builder<K, V> put(K k, V v) {
+            resultMap.put(k, v);
+            return this;
+        }
+
+        public Map<K, V> build() {
+            return resultMap;
+        }
+    }
+
+
+    public static void main(String[] args) {
+        Map<String, Object> build = MapBuilder.<String, Object>builder().put("name", "忘记")
+                .put("age", 23)
+                .build();
+        System.out.println(build);
+    }
+}

+ 72 - 0
core/src/main/java/com/tzld/rta/util/Md5Util.java

@@ -0,0 +1,72 @@
+package com.tzld.rta.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.MessageDigest;
+
+public class Md5Util {
+	static char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };  
+	
+	public static final String encoderByMd5(String msg) {
+		try {
+			byte[] strTemp = msg.getBytes();
+            //如果输入“SHA”,就是实现SHA加密。
+			MessageDigest mdTemp = MessageDigest.getInstance("MD5"); 
+			mdTemp.update(strTemp);
+			byte[] md = mdTemp.digest();
+			int j = md.length;
+			char str[] = new char[j * 2];
+			int k = 0;
+			for (int i = 0; i < j; i++) {
+				byte byte0 = md[i];
+				str[k++] = hexDigits[byte0 >>> 4 & 0xf];
+				str[k++] = hexDigits[byte0 & 0xf];
+			}
+			return new String(str);
+		} catch (Exception e) {
+			return null;
+		}
+	}
+
+	public static final String encoderFileByMd5(InputStream is){
+        try {  
+            MessageDigest md = MessageDigest.getInstance("MD5");  
+            byte[] buffer = new byte[2048];  
+            int length = -1;  
+            while ((length = is.read(buffer)) != -1) {  
+                md.update(buffer, 0, length);  
+            }  
+            byte[] b = md.digest();  
+            return byteToHexString(b);  
+        } catch (Exception e) {  
+            e.printStackTrace();  
+            return null;  
+        } finally {  
+            try {  
+                is.close();  
+            } catch (IOException e) {  
+                e.printStackTrace();  
+            }  
+        }  
+	}
+	
+	private static String byteToHexString(byte[] tmp) {  
+        String s;  
+        // 用字节表示就是 16 个字节  
+        // 每个字节用 16 进制表示的话,使用两个字符,所以表示成 16 进制需要 32 个字符  
+        // 比如一个字节为01011011,用十六进制字符来表示就是“5b”  
+        char str[] = new char[16 * 2];  
+        int k = 0; // 表示转换结果中对应的字符位置  
+        for (int i = 0; i < 16; i++) { // 从第一个字节开始,对 MD5 的每一个字节转换成 16 进制字符的转换  
+            byte byte0 = tmp[i]; // 取第 i 个字节  
+            str[k++] = hexDigits[byte0 >>> 4 & 0xf]; // 取字节中高 4 位的数字转换, >>> 为逻辑右移,将符号位一起右移  
+            str[k++] = hexDigits[byte0 & 0xf]; // 取字节中低 4 位的数字转换  
+        }  
+        s = new String(str); // 换后的结果转换为字符串  
+        return s;  
+    }  
+	
+	public static void main(String[] args) {
+		System.out.println(encoderByMd5("test1002"));
+	}
+}

+ 33 - 0
core/src/main/java/com/tzld/rta/util/OdpsUtil.java

@@ -0,0 +1,33 @@
+package com.tzld.rta.util;
+
+import com.aliyun.odps.Instance;
+import com.aliyun.odps.Odps;
+import com.aliyun.odps.OdpsException;
+import com.aliyun.odps.account.Account;
+import com.aliyun.odps.account.AliyunAccount;
+import com.aliyun.odps.data.Record;
+import com.aliyun.odps.task.SQLTask;
+
+import java.util.List;
+
+public class OdpsUtil {
+
+    public static List<Record> getOdpsData(String sql) {
+        String accessId = "LTAI9EBa0bd5PrDa";
+        String accessKey = "vAalxds7YxhfOA2yVv8GziCg3Y87v5";
+        String endpoint = "http://service.odps.aliyun.com/api";
+        Account account = new AliyunAccount(accessId, accessKey);
+        Odps odps = new Odps(account);
+        odps.setEndpoint(endpoint);
+        odps.setDefaultProject("loghubods");
+        Instance i;
+        try {
+            i = SQLTask.run(odps, sql);
+            i.waitForSuccess();
+            return SQLTask.getResult(i);
+        } catch (OdpsException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+}

+ 174 - 0
core/src/main/java/com/tzld/rta/util/PropertiesUtils.java

@@ -0,0 +1,174 @@
+package com.tzld.rta.util;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.Properties;
+
+@Slf4j
+public class PropertiesUtils {
+    public static Properties properties;
+    public static Properties mainProperties;
+
+    static {
+        mainProperties = new Properties();
+        properties = new Properties();
+        try {
+            // 加载主配置文件 application.yml
+            InputStream mainStream = PropertiesUtils.class.getClassLoader().getResourceAsStream("application.yml");
+            if (mainStream == null) {
+                throw new IOException("application.yml 配置文件不存在");
+            }
+            // 解析 YAML 并转换为 Properties 格式(扁平 key-value)
+            Map<String, Object> mainYamlMap = new Yaml().load(mainStream);
+            mainProperties = convertYamlToProperties(mainYamlMap);
+
+            // 获取环境变量(优先取 -Denv,其次取 application.yml 中的 spring.profiles.active)
+            String env = System.getProperty("env");
+            if (StringUtils.isEmpty(env)) {
+                env = mainProperties.getProperty("spring.profiles.active");
+            }
+            if (StringUtils.isEmpty(env)) {
+                log.error("请设置 spring.profiles.active 或启动参数 -Denv");
+                System.exit(1);
+            }
+
+            // 加载环境配置文件 application-{env}.yml
+            InputStream activeStream = PropertiesUtils.class.getClassLoader().getResourceAsStream("application-" + env + ".yml");
+            if (activeStream == null) {
+                throw new IOException("application-" + env + ".yml 配置文件不存在");
+            }
+            Map<String, Object> activeYamlMap = new Yaml().load(activeStream);
+            Properties activeProperties = convertYamlToProperties(activeYamlMap);
+
+            // 合并配置(环境配置覆盖主配置)
+            properties.putAll(mainProperties);
+            properties.putAll(activeProperties);
+            properties.setProperty("spring.profiles.active", env); // 确保环境变量生效
+            log.info("开发环境为: " + env);
+
+        } catch (IOException e) {
+            log.error("配置文件加载失败: " + e.getMessage(), e);
+            System.exit(1);
+        }
+    }
+
+    /**
+     * 将 YAML 解析后的嵌套 Map 转换为扁平的 Properties(键名用点分隔层级)
+     */
+    private static Properties convertYamlToProperties(Map<String, Object> yamlMap) {
+        Properties properties = new Properties();
+        flattenYamlMap(yamlMap, "", properties);
+        return properties;
+    }
+
+    /**
+     * 递归展平 YAML Map
+     */
+    private static void flattenYamlMap(Map<String, Object> yamlMap, String parentKey, Properties properties) {
+        for (Map.Entry<String, Object> entry : yamlMap.entrySet()) {
+            String key = parentKey.isEmpty() ? entry.getKey() : parentKey + "." + entry.getKey();
+            Object value = entry.getValue();
+
+            if (value instanceof Map<?, ?>) {
+                // 递归处理嵌套 Map
+                flattenYamlMap((Map<String, Object>) value, key, properties);
+            } else if (value instanceof Iterable<?>) {
+                // 处理列表(转换为逗号分隔的字符串)
+                StringBuilder sb = new StringBuilder();
+                for (Object item : (Iterable<?>) value) {
+                    if (sb.length() > 0) sb.append(",");
+                    sb.append(item);
+                }
+                properties.setProperty(key, sb.toString());
+            } else {
+                // 基本类型直接设置
+                properties.setProperty(key, value != null ? value.toString() : "");
+            }
+        }
+    }
+
+    public static Properties getProperties() {
+        return properties;
+    }
+
+    public static String getProjectEnv() {
+        return getProperties().getProperty("spring.profiles.active");
+    }
+
+    public static String getValue(String key) {
+        return PropertiesUtils.getProperties().getProperty(key);
+    }
+
+    public static boolean getSwaggerEnabled() {
+        return Boolean.parseBoolean(getProperties().getProperty("swagger.enabled"));
+    }
+
+    public static String getSwaggerBasePath() {
+        return getProperties().getProperty("swagger.basePath");
+    }
+
+    public static String getSwaggerProtocols() {
+        return getProperties().getProperty("swagger.protocols");
+    }
+
+    public static String getDownloadDomain() {
+        return getProperties().getProperty("oss.longvideo.cdnDomain");
+    }
+
+    public static String getTranscodeLocation() {
+        return getProperties().getProperty("oss.longvideo.transcode.location");
+    }
+
+    public static String getTranscodePipelineId() {
+        return getProperties().getProperty("oss.longvideo.transcode.PipelineId");
+    }
+
+    public static String getReadOnlyAccessKeyId() {
+        return getProperties().getProperty("oss.video.readonly.accessKey");
+    }
+
+    public static String getReadOnlyAccessKeySecret() {
+        return getProperties().getProperty("oss.video.readonly.secretKey");
+    }
+
+    public static Properties getMainProperties() {
+        return mainProperties;
+    }
+
+    public static String getMainPropertiesValue(String key) {
+        return getMainProperties().getProperty(key);
+    }
+
+    public static String getVideoBucket() {
+        return getMainProperties().getProperty("oss.video.bucket");
+    }
+
+    public static String getLongvideoStsEndpoint() {
+        return getMainProperties().getProperty("oss.longvideo.video.sts.endpoint");
+    }
+
+    public static String getLongvideoStsAccessKeyId() {
+        return getMainProperties().getProperty("oss.longvideo.video.sts.accessKeyId");
+    }
+
+    public static String getLongvideoStsAccessKeySecret() {
+        return getMainProperties().getProperty("oss.longvideo.video.sts.accessKeySecret");
+    }
+
+    public static String getLongvideoStsRoleArn() {
+        return getMainProperties().getProperty("oss.longvideo.video.sts.roleArn");
+    }
+
+    public static String getLongvideoStsSessionName() {
+        return getMainProperties().getProperty("oss.longvideo.video.sts.roleSessionName");
+    }
+
+    public static String getOssaccelerateUploadDomain() {
+        return getMainProperties().getProperty("oss.accelerate.upload.domain");
+    }
+}

+ 64 - 0
core/src/main/java/com/tzld/rta/util/RandomUtil.java

@@ -0,0 +1,64 @@
+package com.tzld.rta.util;
+
+import java.math.BigDecimal;
+import java.util.Calendar;
+import java.util.Random;
+import java.util.UUID;
+
+public class RandomUtil {
+
+	public static final String ALLNUMBER = "0123456789";  
+	public static final String ALLCHAR = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";  
+	public static final Integer FIXLENG=18;
+    /** 
+     * 返回一个定长的随机字符串(只包含大小写字母、数字)
+     *  随机字符串长度
+     * @return 随机字符串 
+     */  
+    public static String generate18String() {  
+        StringBuffer sb = new StringBuffer();  
+        Random random = new Random();  
+        for (int i = 0; i < FIXLENG; i++) {  
+            sb.append(ALLCHAR.charAt(random.nextInt(ALLCHAR.length())));  
+        }  
+        return sb.toString();  
+    } 
+    
+    public static void main(String[] args) {
+		//System.out.println(generate18String())
+        String proportion="0.01";
+        Long price=150l;
+        Double incomeMoney=price*(Double.valueOf(proportion));
+        System.out.println(incomeMoney);
+
+
+        BigDecimal b = new BigDecimal(incomeMoney);
+        Long t = b.setScale(0,BigDecimal.ROUND_HALF_UP).longValue();
+        System.out.println(t);
+
+    	
+	}
+    
+    public static String generateString(int length) {  
+        StringBuffer sb = new StringBuffer();  
+        Random random = new Random();  
+        for (int i = 0; i < length; i++) {  
+            sb.append(ALLCHAR.charAt(random.nextInt(ALLCHAR.length())));  
+        }  
+        return sb.toString();  
+    }
+    
+    public static String generateNumber(int length) {  
+        StringBuffer sb = new StringBuffer();  
+        Random random = new Random();  
+        for (int i = 0; i < length; i++) {  
+            sb.append(ALLNUMBER.charAt(random.nextInt(ALLNUMBER.length())));  
+        }  
+        return sb.toString();  
+    } 
+    
+    public static String getRandomUUIDStr() {
+		return UUID.randomUUID().toString().replaceAll("-", "")+Calendar.getInstance().getTimeInMillis();
+	}
+
+}

+ 257 - 0
core/src/main/java/com/tzld/rta/util/RedisUtils.java

@@ -0,0 +1,257 @@
+package com.tzld.rta.util;
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisCallback;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.RedisSerializer;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+@Service
+public class RedisUtils {
+
+    private final static Logger log = LoggerFactory.getLogger(RedisUtils.class);
+
+    public final static Long DEFAULT_EXPIRE_TIME = 7L * 24 * 60 * 60; // 默认过期7天,单位秒
+
+    @Autowired
+    private RedisTemplate<String, String> redisTemplate;
+
+
+    public boolean containsKey(String key) {
+        if (StringUtils.isBlank(key)) {
+            log.error("containsKey is empty key:" + key);
+            return Boolean.FALSE;
+        }
+        return Boolean.TRUE.equals(redisTemplate.hasKey(key));
+    }
+
+    public String getString(String key) {
+        Object obj = redisTemplate.opsForValue().get(key);
+        return Objects.isNull(obj) ? null : obj.toString();
+    }
+
+    public Long getLong(String key) {
+        long longVal = 0L;
+        Object obj = redisTemplate.opsForValue().get(key);
+        if (Objects.nonNull(obj)) {
+            try {
+                longVal = Long.parseLong(obj.toString());
+            } catch (Exception e) {
+                e.printStackTrace();
+                return longVal;
+            }
+
+        }
+        return longVal;
+    }
+
+    public void setValueWithExpire(String key, String value, Long expireTime) {
+        redisTemplate.opsForValue().set(key, value, expireTime, TimeUnit.SECONDS);
+    }
+
+    public void setIncrementValue(String key, long value, Date date) {
+        Long expireTime;
+        if (date != null) {
+            expireTime = (date.getTime() - System.currentTimeMillis()) / 1000;
+            if (expireTime < 0) {
+                expireTime = DEFAULT_EXPIRE_TIME;
+            }
+        } else { // date为null
+            expireTime = DEFAULT_EXPIRE_TIME;
+        }
+        // 只在第一次进行设置过期时间
+        if (!containsKey(key)) {
+            redisTemplate.opsForValue().increment(key, value);
+            redisTemplate.expire(key, expireTime, TimeUnit.SECONDS);
+        } else {
+            redisTemplate.opsForValue().increment(key, value);
+        }
+    }
+
+    public void setIncrementValue(String key, Integer value, Long expireTime) {
+        // 只在第一次进行设置过期时间
+        if (!containsKey(key)) {
+            redisTemplate.opsForValue().increment(key, value);
+            redisTemplate.expire(key, expireTime, TimeUnit.SECONDS);
+        } else {
+            redisTemplate.opsForValue().increment(key, value);
+        }
+    }
+
+    public void setDecrementValue(String key, double value) {
+        redisTemplate.opsForValue().increment(key, -value);
+    }
+
+    public void setIncrementValue(String key, double value, Date date) {
+        Long expireTime;
+        if (date != null) {
+            expireTime = (date.getTime() - System.currentTimeMillis()) / 1000;
+            if (expireTime < 0) {
+                expireTime = DEFAULT_EXPIRE_TIME;
+            }
+        } else { // date为null
+            expireTime = DEFAULT_EXPIRE_TIME;
+        }
+        // 只在第一次进行设置过期时间
+        if (!containsKey(key)) {
+            redisTemplate.opsForValue().increment(key, value);
+            redisTemplate.expire(key, expireTime, TimeUnit.SECONDS);
+        } else {
+            redisTemplate.opsForValue().increment(key, value);
+        }
+    }
+
+    public int getInteger(String key) {
+        Object obj = redisTemplate.opsForValue().get(key);
+        if (Objects.isNull(obj)) {
+            return 0;
+        }
+        return Integer.valueOf(obj.toString());
+    }
+
+    public Integer getIntegerO(String key) {
+        Object obj = redisTemplate.opsForValue().get(key);
+        if (Objects.isNull(obj)) {
+            return null;
+        }
+        return Integer.valueOf(obj.toString());
+    }
+
+    public void putDealyQueueMsg(String key, String value) {
+        redisTemplate.opsForZSet().add(key, value, System.currentTimeMillis() + DEFAULT_EXPIRE_TIME);
+    }
+
+    public Set<String> processDelayQueue(String key) {
+        long currentTimeMillis = System.currentTimeMillis();
+        Set<String> values = redisTemplate.opsForZSet().rangeByScore(key, 0, currentTimeMillis);
+        if (!CollectionUtils.isEmpty(values)) {
+            redisTemplate.opsForZSet().removeRangeByScore(key, 0, currentTimeMillis);
+        }
+        return values;
+    }
+
+    public void addVal(String key, String val) {
+        redisTemplate.opsForValue().set(key, val);
+    }
+
+    public Long getKeyExpire(String key) {
+        return redisTemplate.getExpire(key, TimeUnit.SECONDS);
+    }
+
+    public void expire(String key, Long time) {
+        redisTemplate.expire(key, time, TimeUnit.SECONDS);
+    }
+
+    public Long countExistingKeys(List<String> keys) {
+        return redisTemplate.countExistingKeys(keys);
+    }
+
+    public boolean del(String key) {
+        return redisTemplate.delete(key);
+    }
+
+    public boolean set(String key, String value, long time) {
+        try {
+            if (time > 0) {
+                redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
+            } else {
+                redisTemplate.opsForValue().set(key, value);
+            }
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     * Redis 分布式锁
+     *
+     * @param key        锁键
+     * @param value      锁值,可以为随机数或者 UUID 等唯一标识符
+     * @param expireTime 锁过期时间,单位为秒
+     * @return true:获取锁成功,false:获取锁失败
+     */
+    public boolean tryLock(String key, String value, long expireTime) {
+        Boolean result = redisTemplate.opsForValue().setIfAbsent(key, value, expireTime, TimeUnit.SECONDS);
+        if (result != null && result) {
+            // 获取锁成功
+            return true;
+        }
+        return false;
+    }
+
+    public void listLeftPush(String key, String value) {
+        redisTemplate.opsForList().leftPush(key, value);
+
+    }
+
+    public String listRightPop(String key) {
+        return redisTemplate.opsForList().rightPop(key);
+    }
+
+    public Double getDouble(String key) {
+        try {
+            String val = redisTemplate.opsForValue().get(key);
+            if (StringUtils.isNotBlank(val)) {
+                return Double.valueOf(val);
+            }
+        } catch (Exception e) {
+            log.error("getDouble error redis key:" + key + "----" + e);
+        }
+        return null;
+    }
+
+    public String get(String key) {
+        String val = redisTemplate.opsForValue().get(key);
+        if (StringUtils.isNotBlank(val)) {
+            return val;
+        }
+        return null;
+    }
+
+    public void sAdd(String key, String val) {
+        redisTemplate.opsForSet().add(key, val);
+    }
+
+    public Set<String> sMembers(String key) {
+        return redisTemplate.opsForSet().members(key);
+    }
+
+
+    public Boolean sIsMember(String key, String val) {
+        return redisTemplate.opsForSet().isMember(key, val);
+    }
+
+    public void setBit(String key, long val, boolean flag) {
+        redisTemplate.opsForValue().setBit(key, val, flag);
+    }
+
+    public void setBitList(String key, Set<Long> indexs, boolean flag) {
+        RedisSerializer<String> serializer = redisTemplate.getStringSerializer();
+        redisTemplate.executePipelined((RedisCallback<Object>) redisConnection -> {
+            indexs.forEach(x -> {
+                redisConnection.setBit(key.getBytes(), x, flag);
+            });
+            return null;
+        }, serializer);
+    }
+
+    public Boolean getBitMap(String key, long offset) {
+        return redisTemplate.opsForValue().getBit(key, offset);
+    }
+
+    public List<String> mGet(List<String> keys) {
+        return redisTemplate.opsForValue().multiGet(keys);
+    }
+}

+ 55 - 0
core/src/main/java/com/tzld/rta/util/TimelineUtils.java

@@ -0,0 +1,55 @@
+package com.tzld.rta.util;
+
+public class TimelineUtils {
+
+    public static void main(String[] args) {
+        System.out.println(coverSrtTimeToMillis("00:00:00.000", "\\."));
+    }
+
+    // 00:01:57,230 时间格式转成毫秒
+    public static int coverSrtTimeToMillis(String srtTime, String splitMs) {
+        String[] array = srtTime.split(splitMs);
+        String[] hhmmss = array[0].split(":");
+        return Integer.valueOf(hhmmss[0]) * 60 * 60 * 1000 + Integer.valueOf(hhmmss[1]) * 60 * 1000
+                + Integer.valueOf(hhmmss[2]) * 1000 + Integer.valueOf(array[1]);
+    }
+
+    public static String convertMillisToStringTime(int millis, String splitSSS) {
+        String hh = "";
+        int hhInt = 0;
+        String mm = "";
+        int mmInt = 0;
+        String ss = "";
+        int ssInt = millis / 1000;
+        String SSS = millis % 1000 + "";
+        if (ssInt >= 60) {
+            mmInt = ssInt / 60;
+            ss = ssInt % 60 + "";
+        } else {
+            ss = ssInt + "";
+        }
+        if (mmInt >= 60) {
+            hhInt = mmInt / 60;
+            mm = mmInt % 60 + "";
+        } else {
+            mm = mmInt + "";
+        }
+        hh = hhInt + "";
+        // 补0
+        if (SSS.length() == 1) {
+            SSS = "00" + SSS;
+        } else if (SSS.length() == 2) {
+            SSS = "0" + SSS;
+        }
+        if (ss.length() == 1) {
+            ss = "0" + ss;
+        }
+        if (mm.length() == 1) {
+            mm = "0" + mm;
+        }
+        if (hh.length() == 1) {
+            hh = "0" + hh;
+        }
+        return hh + ":" + mm + ":" + ss + splitSSS + SSS;
+    }
+}

+ 105 - 0
core/src/main/java/com/tzld/rta/util/feishu/FeiShu.java

@@ -0,0 +1,105 @@
+package com.tzld.rta.util.feishu;
+
+import com.alibaba.fastjson.JSONObject;
+import com.tzld.rta.util.feishu.model.FeishuChatListResult;
+import com.tzld.rta.util.feishu.model.FeishuGroup;
+import okhttp3.*;
+import org.slf4j.LoggerFactory;
+import org.springframework.data.util.Pair;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+public class FeiShu {
+
+    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(FeiShu.class);
+
+    private static final OkHttpClient client = new OkHttpClient.Builder()
+            .connectTimeout(30, TimeUnit.SECONDS)
+            .readTimeout(30, TimeUnit.SECONDS)
+            .writeTimeout(30, TimeUnit.SECONDS)
+            .build();
+
+    private static final MediaType JSON_MEDIA_TYPE = MediaType.get("application/json; charset=utf-8");
+
+    public static final String URL_FEISHU_ACCESSTOKEN = "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal";
+    public static final String URL_FEISHU_CHAT_LIST = "https://open.feishu.cn/open-apis/chat/v4/list?page_size=200";
+    public static final String URL_FEISHU_SEND_MESSAGE = "https://open.feishu.cn/open-apis/message/v4/send";
+    public static final String URL_FEISHU_GROUP_MEMBERS = "https://open.feishu.cn/open-apis/im/v1/chats/:chat_id/members?member_id_type=open_id";
+    public static final String URL_FEISHU_REPLY_MESSAGE = "https://open.feishu.cn/open-apis/im/v1/messages/:message_id/reply";
+    public static final String URL_FEISHU_CARD_MESSAGE_UPDATE = "https://open.feishu.cn/open-apis/im/v1/messages/:message_id";
+    public static final String APPID = "cli_a51114cf8bf8d00c";
+    public static final String APPSECRET = "cNoTAqMpsAm7mPBcpCAXFfvOzCNL27fe";
+
+    public static Pair<String, Integer> requestAccessToken() {
+        Pair<String, Integer> result = Pair.of("", 0);
+        long startTime = System.currentTimeMillis();
+        int retryCount = 0;
+
+        while (retryCount < 3) {
+            try {
+                FormBody.Builder formBuilder = new FormBody.Builder();
+                formBuilder.add("app_id", APPID);
+                formBuilder.add("app_secret", APPSECRET);
+
+                Request request = new Request.Builder()
+                        .url(URL_FEISHU_ACCESSTOKEN)
+                        .post(formBuilder.build())
+                        .build();
+
+                try (Response response = client.newCall(request).execute()) {
+                    String responseBody = response.body() != null ? response.body().string() : "";
+                    LOGGER.info("feishu accessToken response = {}", responseBody);
+                    JSONObject jsonResponse = JSONObject.parseObject(responseBody);
+                    String accessToken = jsonResponse.getString("tenant_access_token");
+                    int expireSeconds = jsonResponse.getIntValue("expire");
+                    return Pair.of(accessToken, expireSeconds);
+                }
+            } catch (Exception e) {
+                LOGGER.error("requestFeishuAccessToken, error ,retryCount = {}, cost = {}", retryCount, System.currentTimeMillis() - startTime, e);
+            }
+            retryCount++;
+        }
+
+        return result;
+
+    }
+
+    public static void main(String[] args) throws IOException {
+        FormBody.Builder formBuilder = new FormBody.Builder();
+        formBuilder.add("app_id", APPID);
+        formBuilder.add("app_secret", APPSECRET);
+
+        Request tokenRequest = new Request.Builder()
+                .url(URL_FEISHU_ACCESSTOKEN)
+                .post(formBuilder.build())
+                .build();
+
+        try (Response tokenResponse = client.newCall(tokenRequest).execute()) {
+            String tokenBody = tokenResponse.body() != null ? tokenResponse.body().string() : "";
+            System.out.println(tokenBody);
+            JSONObject response = JSONObject.parseObject(tokenBody);
+            String accessToken = response.getString("tenant_access_token");
+
+            //获取群聊ID
+            Request chatRequest = new Request.Builder()
+                    .url(URL_FEISHU_CHAT_LIST)
+                    .get()
+                    .addHeader("Authorization", "Bearer " + accessToken)
+                    .addHeader("Content-Type", "application/json; charset=utf-8")
+                    .build();
+
+            try (Response chatResponse = client.newCall(chatRequest).execute()) {
+                String chatBody = chatResponse.body() != null ? chatResponse.body().string() : "";
+                JSONObject responseJSON = JSONObject.parseObject(chatBody);
+                String chatData = responseJSON.getString("data");
+                System.out.println(chatData);
+                System.out.println("-------------------");
+                FeishuChatListResult feishuChatListResult = JSONObject.parseObject(chatData, FeishuChatListResult.class);
+                for (FeishuGroup group : feishuChatListResult.getGroups()) {
+                    System.out.println(JSONObject.toJSONString(group));
+                }
+            }
+        }
+    }
+}

+ 190 - 0
core/src/main/java/com/tzld/rta/util/feishu/FeishuExcelUtil.java

@@ -0,0 +1,190 @@
+package com.tzld.rta.util.feishu;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.tzld.rta.util.MapBuilder;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.data.util.Pair;
+import org.springframework.http.*;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+@Slf4j
+public class FeishuExcelUtil {
+
+    public static void feishuSheetDelete(String sheetToken,
+                                   String sheetId,
+                                   int rowNum,
+                                   int startRowIndex,
+                                   HttpHeaders httpHeaders,
+                                   RestTemplate restTemplate,
+                                   List<String> dateStrList) {
+        HttpEntity<Object> queryEntity = new HttpEntity<>(httpHeaders);
+        int deleteRowNum = rowNum < 20 ? startRowIndex + dateStrList.size() * rowNum : startRowIndex + (rowNum * 2);
+        ResponseEntity<String> queryResponseEntity = restTemplate.exchange(
+                String.format("https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/%s/values/%s!A"
+                        + startRowIndex + ":A" + deleteRowNum, sheetToken, sheetId),
+                HttpMethod.GET, queryEntity, String.class);
+        JSONArray values = JSON.parseObject(queryResponseEntity.getBody())
+                .getJSONObject("data")
+                .getJSONObject("valueRange")
+                .getJSONArray("values");
+        int count = 0;
+        if (!values.isEmpty() && Objects.nonNull(values.get(0)) && !((JSONArray) values.get(0)).isEmpty()
+                && Objects.nonNull(((JSONArray) values.get(0)).get(0))
+                && dateStrList.contains(((JSONArray) values.get(0)).get(0).toString())) {
+            for (Object value : values) {
+                if (((JSONArray) value).get(0) != null) {
+                    List<String> dates = ((JSONArray) value).stream().map(Object::toString).collect(Collectors.toList());
+                    if (dateStrList.contains(dates.get(0))) {
+                        count++;
+                        continue;
+                    }
+                }
+                break;
+            }
+        }
+        if (count > 0) {
+            int delNum = 0;
+            do {
+                // 删除当前日期已存在的旧数据
+                httpHeaders.setContentType(MediaType.APPLICATION_JSON);
+                HttpEntity<Object> deleteEntity = new HttpEntity<>(
+                        String.format("{\n" +
+                                "    \"dimension\": {\n" +
+                                "        \"sheetId\": \"%s\",\n" +
+                                "        \"majorDimension\": \"ROWS\",\n" +
+                                "        \"startIndex\": %s,\n" +
+                                "        \"endIndex\": %s\n" +
+                                "    }\n" +
+                                "}", sheetId, startRowIndex, Math.min(startRowIndex + 4000, count - delNum + startRowIndex) - 1),
+                        httpHeaders);
+                restTemplate.exchange(String.format("https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/%s/dimension_range", sheetToken),
+                        HttpMethod.DELETE, deleteEntity, String.class);
+                delNum = Math.min(delNum + 4000, count);
+            } while (delNum < count);
+        }
+    }
+
+    public static void feishuSheetInsert(String sheetToken,
+                                   String sheetId,
+                                   Integer startRowIndex,
+                                   HttpHeaders httpHeaders,
+                                   RestTemplate restTemplate,
+                                   List<List<List<Object>>> partitions) {
+        int startRow = startRowIndex;
+        for (List<List<Object>> partition : partitions) {
+            // 插入数据
+            HttpEntity<Object> postEntity = new HttpEntity<>(MapBuilder
+                    .builder()
+                    .put("valueRange", MapBuilder
+                            .builder()
+                            .put("range", String.format("%s!A" + startRow + ":CI", sheetId) + (partition.size() + startRow - 1))
+                            .put("values", partition)
+                            .build())
+                    .build(), httpHeaders);
+            ResponseEntity<String> response = restTemplate.exchange(String.format("https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/%s/values_prepend",
+                            sheetToken),
+                    HttpMethod.POST, postEntity, String.class);
+            JSONObject responseJSON = JSONObject.parseObject(response.getBody());
+            if (0 != responseJSON.getInteger("code")) {
+                log.error("doSendFeishuSheet write error :{}", responseJSON.getString("msg"));
+            }
+            // 设置行高
+            httpHeaders.setContentType(MediaType.APPLICATION_JSON);
+            HttpEntity<Object> putEntity = new HttpEntity<>(
+                    String.format("{\n" +
+                            "    \"dimension\": {\n" +
+                            "        \"sheetId\": \"%s\",\n" +
+                            "        \"majorDimension\": \"ROWS\",\n" +
+                            "        \"startIndex\": %s,\n" +
+                            "        \"endIndex\": %s\n" +
+                            "    },\n" +
+                            "    \"dimensionProperties\":{\n" +
+                            "        \"fixedSize\":27\n" +
+                            "    }\n" +
+                            "}", sheetId, startRow, Math.min(startRow + 4000, startRow + partition.size()) - 1),
+                    httpHeaders);
+            restTemplate.exchange(String.format("https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/%s/dimension_range", sheetToken),
+                    HttpMethod.PUT, putEntity, String.class);
+            startRow += partition.size();
+        }
+    }
+
+    public static void feishuSheetStyle(String sheetToken,
+                                  String sheetId,
+                                  int rowNum,
+                                  Integer startRowIndex,
+                                  HttpHeaders httpHeaders,
+                                  RestTemplate restTemplate,
+                                  List<Pair<String, Map<Object, Object>>> styles) {
+        Integer startRow = startRowIndex;
+        do {
+            for (Pair<String, Map<Object, Object>> style : styles) {
+                HttpEntity<Map<Object, Object>> styleEntity = new HttpEntity<>(MapBuilder
+                        .builder()
+                        .put("appendStyle",
+                                MapBuilder
+                                        .builder()
+                                        .put("range", String.format("%s!%s" + startRow + ":%s", sheetId,
+                                                style.getFirst(), style.getFirst())
+                                                + (Math.min(startRow + 4000, rowNum + startRowIndex) - 1))
+                                        .put("style", style.getSecond())
+                                        .build()
+                        )
+                        .build(), httpHeaders);
+                restTemplate.exchange(
+                        String.format("https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/%s/style",
+                                sheetToken),
+                        HttpMethod.PUT,
+                        styleEntity,
+                        String.class
+                );
+            }
+            startRow += 4000;
+        } while (startRow < rowNum);
+    }
+
+    public static void feishuSheetThanks(String sheetToken,
+                                   String sheetId,
+                                   int rowNum,
+                                   Integer startRowIndex,
+                                   HttpHeaders httpHeaders,
+                                   RestTemplate restTemplate,
+                                   List<Pair<String, List<Pair<String, String>>>> thanks) {
+        Integer startRow = startRowIndex;
+        do {
+            for (Pair<String, List<Pair<String, String>>> thank : thanks) {
+                List<String> keyList = thank.getSecond().stream().map(Pair::getFirst).collect(Collectors.toList());
+                List<String> colorList = thank.getSecond().stream().map(Pair::getSecond).collect(Collectors.toList());
+                HttpEntity<Map<Object, Object>> styleEntity = new HttpEntity<>(MapBuilder
+                        .builder()
+                        .put("range", String.format("%s!%s" + startRow + ":%s", sheetId,
+                                thank.getFirst(), thank.getFirst())
+                                + (Math.min(startRow + 4000, rowNum + startRowIndex) - 1))
+                        .put("dataValidationType", "list")
+                        .put("dataValidation", MapBuilder.builder()
+                                .put("conditionValues", keyList)
+                                .put("options", MapBuilder.builder()
+                                        .put("highlightValidData", true)
+                                        .put("colors", colorList)
+                                        .build()
+                                ).build())
+                        .build(), httpHeaders);
+                restTemplate.exchange(
+                        String.format("https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/%s/dataValidation",
+                                sheetToken),
+                        HttpMethod.POST,
+                        styleEntity,
+                        String.class
+                );
+            }
+            startRow += 4000;
+        } while (startRow < rowNum);
+    }
+}

+ 152 - 0
core/src/main/java/com/tzld/rta/util/feishu/FeishuMessageSender.java

@@ -0,0 +1,152 @@
+package com.tzld.rta.util.feishu;
+
+import com.alibaba.fastjson.JSONObject;
+import com.tzld.rta.util.feishu.model.Message;
+import com.tzld.rta.util.feishu.model.MessageParams;
+import com.tzld.rta.util.feishu.model.config.MessageConfig;
+import com.tzld.rta.util.feishu.model.element.BaseElement;
+import com.tzld.rta.util.feishu.model.element.DivElement;
+import com.tzld.rta.util.feishu.model.element.Filed;
+import com.tzld.rta.util.feishu.model.element.MarkDownText;
+import com.tzld.rta.util.feishu.model.header.HeadTitle;
+import com.tzld.rta.util.feishu.model.header.MessageHeader;
+import lombok.extern.slf4j.Slf4j;
+import okhttp3.*;
+import org.apache.http.util.TextUtils;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.util.Pair;
+import org.springframework.stereotype.Component;
+
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+
+@Component
+@Slf4j
+public class FeishuMessageSender implements InitializingBean {
+
+    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(FeishuMessageSender.class);
+
+    private static final String webHookUrl = "https://open.feishu.cn/open-apis/bot/v2/hook/";
+
+    private static final OkHttpClient client = new OkHttpClient.Builder()
+            .connectTimeout(30, TimeUnit.SECONDS)
+            .readTimeout(30, TimeUnit.SECONDS)
+            .writeTimeout(30, TimeUnit.SECONDS)
+            .build();
+
+    private static final MediaType JSON_MEDIA_TYPE = MediaType.get("application/json; charset=utf-8");
+
+    private static String staticEnv;
+
+    @Value("${spring.profiles.active:prod}")
+    private String env;
+
+    @Override
+    public void afterPropertiesSet() throws Exception {
+        FeishuMessageSender.staticEnv = env;
+    }
+
+    public void sendChat(String chatId, String title, Map<String, String> infos) {
+        sendChat(chatId, null, title, infos);
+    }
+
+    public void sendChat(String chatId, String userOpenId, String title, Map<String, String> infos) {
+        try {
+            Pair<String, Integer> token = FeiShu.requestAccessToken();
+
+            MessageConfig messageConfig = new MessageConfig();
+            MessageHeader messageHeader = new MessageHeader();
+            messageHeader.title = new HeadTitle(title);
+            List<BaseElement> elements = new ArrayList<>();
+            DivElement textElement = new DivElement();
+            for (Map.Entry<String, String> stringStringEntry : infos.entrySet()) {
+                if (TextUtils.isBlank(stringStringEntry.getValue())) {
+                    textElement.fields.add(new Filed(new MarkDownText(String.format("%s", stringStringEntry.getKey()))));
+                } else {
+                    textElement.fields.add(new Filed(new MarkDownText(String.format("**%s**:%s", stringStringEntry.getKey(), stringStringEntry.getValue()))));
+                }
+            }
+            elements.add(textElement);
+            MessageParams messageParams = new MessageParams(chatId, userOpenId, new Message(messageConfig, messageHeader, elements));
+
+            RequestBody body = RequestBody.create(JSON_MEDIA_TYPE, JSONObject.toJSONString(messageParams));
+            Request request = new Request.Builder()
+                    .url(FeiShu.URL_FEISHU_SEND_MESSAGE)
+                    .post(body)
+                    .addHeader("Authorization", "Bearer " + token.getFirst())
+                    .addHeader("Content-Type", "application/json; charset=utf-8")
+                    .build();
+
+            try (Response response = client.newCall(request).execute()) {
+                if (!response.isSuccessful()) {
+                    String errorBody = response.body() != null ? response.body().string() : "无";
+                    LOGGER.error("发送飞书消息失败,HTTP状态码: {}, 错误信息: {}", response.code(), errorBody);
+                }
+            }
+        } catch (Exception e) {
+            LOGGER.error("FeishuMessageSender", e);
+        }
+    }
+
+    public static void sendWebHookMessage(String robotId, String msg) {
+        // 使用自定义群机器人webhook方式,支持外部群
+        if (!"prod".equals(staticEnv)) {
+            return;
+        }
+        JSONObject content = new JSONObject();
+        content.put("text", msg);
+        JSONObject bodyParam = new JSONObject();
+        bodyParam.put("msg_type", "text");
+        bodyParam.put("content", content);
+        String webhookUrl = webHookUrl + robotId;
+        String hrc = request(bodyParam, webhookUrl);
+        if (hrc == null) {
+            // 重试一次
+            hrc = request(bodyParam, webhookUrl);
+        }
+        if (hrc == null) {
+            log.error("sendWebHookMessage,hrc is null");
+        }
+    }
+
+    public static void sendWebHookMessage(String robotId, JSONObject bodyParam) {
+        // 使用自定义群机器人webhook方式,支持外部群
+        if (!"prod".equals(staticEnv)) {
+            return;
+        }
+        String webhookUrl = webHookUrl + robotId;
+        String hrc = request(bodyParam, webhookUrl);
+        if (hrc == null) {
+            // 重试一次
+            hrc = request(bodyParam, webhookUrl);
+        }
+        if (hrc == null) {
+            log.error("sendWebHookMessage,hrc is null");
+        }
+    }
+
+    public static String request(JSONObject bodyParam, String webhookUrl) {
+        long start = System.currentTimeMillis();
+        try {
+            RequestBody body = RequestBody.create(JSON_MEDIA_TYPE, bodyParam.toJSONString());
+            Request request = new Request.Builder()
+                    .url(webhookUrl)
+                    .post(body)
+                    .addHeader("Content-Type", "application/json")
+                    .build();
+
+            try (Response response = client.newCall(request).execute()) {
+                if (response.isSuccessful() && response.body() != null) {
+                    return response.body().string();
+                }
+            }
+        } catch (Exception e) {
+            log.error("request error", e);
+        }
+        log.info("score耗时:{}", System.currentTimeMillis() - start);
+        return null;
+    }
+
+}

+ 37 - 0
core/src/main/java/com/tzld/rta/util/feishu/model/FeishuChatListResult.java

@@ -0,0 +1,37 @@
+package com.tzld.rta.util.feishu.model;
+
+import java.util.List;
+
+/**
+ * Create by nieqi on 2021/7/8
+ */
+public class FeishuChatListResult {
+
+    private boolean has_more;
+    private String page_token;
+    private List<FeishuGroup> groups;
+
+    public boolean isHas_more() {
+        return has_more;
+    }
+
+    public void setHas_more(boolean has_more) {
+        this.has_more = has_more;
+    }
+
+    public String getPage_token() {
+        return page_token;
+    }
+
+    public void setPage_token(String page_token) {
+        this.page_token = page_token;
+    }
+
+    public List<FeishuGroup> getGroups() {
+        return groups;
+    }
+
+    public void setGroups(List<FeishuGroup> groups) {
+        this.groups = groups;
+    }
+}

+ 62 - 0
core/src/main/java/com/tzld/rta/util/feishu/model/FeishuGroup.java

@@ -0,0 +1,62 @@
+package com.tzld.rta.util.feishu.model;
+
+/**
+ * Create by nieqi on 2021/7/8
+ */
+public class FeishuGroup {
+
+    private String avatar;
+    private String description;
+    private String chat_id;
+    private String name;
+    private String owner_open_id;
+    private String owner_user_id;
+
+    public String getAvatar() {
+        return avatar;
+    }
+
+    public void setAvatar(String avatar) {
+        this.avatar = avatar;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String getChat_id() {
+        return chat_id;
+    }
+
+    public void setChat_id(String chat_id) {
+        this.chat_id = chat_id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getOwner_open_id() {
+        return owner_open_id;
+    }
+
+    public void setOwner_open_id(String owner_open_id) {
+        this.owner_open_id = owner_open_id;
+    }
+
+    public String getOwner_user_id() {
+        return owner_user_id;
+    }
+
+    public void setOwner_user_id(String owner_user_id) {
+        this.owner_user_id = owner_user_id;
+    }
+}

+ 48 - 0
core/src/main/java/com/tzld/rta/util/feishu/model/Message.java

@@ -0,0 +1,48 @@
+package com.tzld.rta.util.feishu.model;
+
+
+import com.tzld.rta.util.feishu.model.config.MessageConfig;
+import com.tzld.rta.util.feishu.model.element.BaseElement;
+import com.tzld.rta.util.feishu.model.header.MessageHeader;
+
+import java.util.List;
+
+/**
+ * Create by nieqi on 2021/7/9
+ */
+public class Message {
+
+    private MessageConfig config;
+    private MessageHeader header;
+    private List<BaseElement> elements;
+
+    public Message(MessageConfig config, MessageHeader header, List<BaseElement> elements) {
+        this.config = config;
+        this.header = header;
+        this.elements = elements;
+    }
+
+    public MessageConfig getConfig() {
+        return config;
+    }
+
+    public void setConfig(MessageConfig config) {
+        this.config = config;
+    }
+
+    public MessageHeader getHeader() {
+        return header;
+    }
+
+    public void setHeader(MessageHeader header) {
+        this.header = header;
+    }
+
+    public List<BaseElement> getElements() {
+        return elements;
+    }
+
+    public void setElements(List<BaseElement> elements) {
+        this.elements = elements;
+    }
+}

+ 50 - 0
core/src/main/java/com/tzld/rta/util/feishu/model/MessageParams.java

@@ -0,0 +1,50 @@
+package com.tzld.rta.util.feishu.model;
+
+/**
+ * Create by nieqi on 2021/7/9
+ */
+public class MessageParams {
+
+    private String chat_id;
+    private String open_id;
+    private String msg_type = "interactive";
+    private Message card;
+
+    public MessageParams(String chat_id, String open_id, Message card) {
+        this.chat_id = chat_id;
+        this.open_id = open_id;
+        this.card = card;
+    }
+
+    public String getOpen_id() {
+        return open_id;
+    }
+
+    public void setOpen_id(String open_id) {
+        this.open_id = open_id;
+    }
+
+    public void setChat_id(String chat_id) {
+        this.chat_id = chat_id;
+    }
+
+    public void setMsg_type(String msg_type) {
+        this.msg_type = msg_type;
+    }
+
+    public void setCard(Message card) {
+        this.card = card;
+    }
+
+    public String getChat_id() {
+        return chat_id;
+    }
+
+    public String getMsg_type() {
+        return msg_type;
+    }
+
+    public Message getCard() {
+        return card;
+    }
+}

+ 26 - 0
core/src/main/java/com/tzld/rta/util/feishu/model/config/MessageConfig.java

@@ -0,0 +1,26 @@
+package com.tzld.rta.util.feishu.model.config;
+
+/**
+ * Create by nieqi on 2021/7/9
+ */
+public class MessageConfig {
+
+    boolean wide_screen_mode = true;
+    boolean enable_forward = true;
+
+    public boolean isWide_screen_mode() {
+        return wide_screen_mode;
+    }
+
+    public void setWide_screen_mode(boolean wide_screen_mode) {
+        this.wide_screen_mode = wide_screen_mode;
+    }
+
+    public boolean isEnable_forward() {
+        return enable_forward;
+    }
+
+    public void setEnable_forward(boolean enable_forward) {
+        this.enable_forward = enable_forward;
+    }
+}

+ 17 - 0
core/src/main/java/com/tzld/rta/util/feishu/model/element/BaseElement.java

@@ -0,0 +1,17 @@
+package com.tzld.rta.util.feishu.model.element;
+
+/**
+ * Create by nieqi on 2021/7/9
+ */
+public class BaseElement {
+
+    public String tag = "";
+
+    public String getTag() {
+        return tag;
+    }
+
+    public void setTag(String tag) {
+        this.tag = tag;
+    }
+}

+ 24 - 0
core/src/main/java/com/tzld/rta/util/feishu/model/element/DivElement.java

@@ -0,0 +1,24 @@
+package com.tzld.rta.util.feishu.model.element;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Create by nieqi on 2021/7/9
+ */
+public class DivElement extends BaseElement {
+
+    public DivElement() {
+        this.tag = "div";
+    }
+
+    public List<Filed> fields = new ArrayList<>();
+
+    public List<Filed> getFields() {
+        return fields;
+    }
+
+    public void setFields(List<Filed> fields) {
+        this.fields = fields;
+    }
+}

+ 30 - 0
core/src/main/java/com/tzld/rta/util/feishu/model/element/Filed.java

@@ -0,0 +1,30 @@
+package com.tzld.rta.util.feishu.model.element;
+
+/**
+ * Create by nieqi on 2021/7/9
+ */
+public class Filed {
+
+    boolean is_short = false;
+    MarkDownText text;
+
+    public Filed(MarkDownText text) {
+        this.text = text;
+    }
+
+    public boolean isIs_short() {
+        return is_short;
+    }
+
+    public void setIs_short(boolean is_short) {
+        this.is_short = is_short;
+    }
+
+    public MarkDownText getText() {
+        return text;
+    }
+
+    public void setText(MarkDownText text) {
+        this.text = text;
+    }
+}

+ 31 - 0
core/src/main/java/com/tzld/rta/util/feishu/model/element/MarkDownText.java

@@ -0,0 +1,31 @@
+package com.tzld.rta.util.feishu.model.element;
+
+/**
+ * Create by nieqi on 2021/7/9
+ */
+public class MarkDownText {
+
+    private String tag = "lark_md";
+
+    String content = "";
+
+    public MarkDownText(String content) {
+        this.content = content;
+    }
+
+    public String getTag() {
+        return tag;
+    }
+
+    public void setTag(String tag) {
+        this.tag = tag;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+}

+ 14 - 0
core/src/main/java/com/tzld/rta/util/feishu/model/header/HeadTitle.java

@@ -0,0 +1,14 @@
+package com.tzld.rta.util.feishu.model.header;
+
+/**
+ * Create by nieqi on 2021/7/9
+ */
+public class HeadTitle {
+
+    public String tag = "plain_text";
+    public String content;
+
+    public HeadTitle(String content) {
+        this.content = content;
+    }
+}

+ 17 - 0
core/src/main/java/com/tzld/rta/util/feishu/model/header/MessageHeader.java

@@ -0,0 +1,17 @@
+package com.tzld.rta.util.feishu.model.header;
+
+/**
+ * Create by nieqi on 2021/7/9
+ */
+public class MessageHeader {
+
+    public HeadTitle title;
+
+    public HeadTitle getTitle() {
+        return title;
+    }
+
+    public void setTitle(HeadTitle title) {
+        this.title = title;
+    }
+}

+ 54 - 0
core/src/main/resources/generator/mybatis-rta-generator-config.xml

@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE generatorConfiguration
+        PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
+        "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
+<!-- 配置生成器 -->
+<generatorConfiguration>
+    <context id="mysql" defaultModelType="flat">
+        <property name="autoDelimitKeywords" value="true"/>
+        <!-- 生成的Java文件的编码 -->
+        <property name="javaFileEncoding" value="UTF-8"/>
+        <!-- 格式化java代码 -->
+        <property name="javaFormatter" value="org.mybatis.generator.api.dom.DefaultJavaFormatter"/>
+        <!-- 格式化XML代码 -->
+        <property name="xmlFormatter" value="org.mybatis.generator.api.dom.DefaultXmlFormatter"/>
+        <!-- beginningDelimiter和endingDelimiter:指明数据库的用于标记数据库对象名的符号,比如ORACLE就是双引号,MYSQL默认是`反引号; -->
+        <property name="beginningDelimiter" value="`"/>
+        <property name="endingDelimiter" value="`"/>
+
+        <plugin type="org.mybatis.generator.plugins.ToStringPlugin" />
+        <plugin type="org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin" />
+
+        <commentGenerator>
+            <property name="addRemarkComments" value="true"/>
+        </commentGenerator>
+
+        <jdbcConnection driverClass="com.mysql.jdbc.Driver"
+                        connectionURL="jdbc:mysql://rm-bp17q95335a99272b.mysql.rds.aliyuncs.com:3306/deconstruct-vector?useUnicode=true&amp;characterEncoding=utf-8&amp;zeroDateTimeBehavior=convertToNull&amp;useSSL=false"
+                        userId="crawler" password="crawler123456@">
+        </jdbcConnection>
+
+        <javaTypeResolver type="org.mybatis.generator.internal.types.JavaTypeResolverDefaultImpl">
+            <property name="forceBigDecimals" value="false"/>
+        </javaTypeResolver>
+
+        <javaModelGenerator targetPackage="com.tzld.rta.model.po.rta.deconstruct" targetProject="core/src/main/java">
+            <property name="constructorBased" value="false"/>
+            <property name="enableSubPackages" value="true"/>
+            <property name="immutable" value="false"/>
+        </javaModelGenerator>
+
+        <sqlMapGenerator targetPackage="mapper.rta.deconstruct" targetProject="core/src/main/resources">
+            <property name="enableSubPackages" value="true"/>
+        </sqlMapGenerator>
+
+        <javaClientGenerator targetPackage="com.tzld.rta.dao.mapper.rta.deconstruct" type="XMLMAPPER" targetProject="core/src/main/java">
+            <property name="enableSubPackages" value="true"/>
+        </javaClientGenerator>
+
+        <table tableName="deconstruct_content" domainObjectName="" alias=""/>
+        <table tableName="deconstruct_content_vector" domainObjectName="" alias=""/>
+        <table tableName="deconstruct_vector_config" domainObjectName="" alias=""/>
+    </context>
+
+</generatorConfiguration>

+ 295 - 0
pom.xml

@@ -0,0 +1,295 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>com.tzld.piaoquan</groupId>
+    <artifactId>tencent-rta-server</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>pom</packaging>
+    <modules>
+        <module>core</module>
+        <module>server</module>
+    </modules>
+
+    <parent>
+        <groupId>com.tzld.commons</groupId>
+        <artifactId>supom</artifactId>
+        <version>1.0.6</version>
+    </parent>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.mybatis.spring.boot</groupId>
+            <artifactId>mybatis-spring-boot-starter</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.github.pagehelper</groupId>
+            <artifactId>pagehelper-spring-boot-starter</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-aop</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>io.lettuce</groupId>
+            <artifactId>lettuce-core</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-pool2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-collections4</artifactId>
+            <version>4.1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.mybatis.generator</groupId>
+            <artifactId>mybatis-generator-core</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+        </dependency>
+
+        <!-- druid数据源 -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid</artifactId>
+            <version>1.1.23</version>
+        </dependency>
+        <!--easyexcel-->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>easyexcel</artifactId>
+            <version>3.0.5</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+            <version>3.5.3.2</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.18.12</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.14</version> <!-- 使用最新版本 -->
+        </dependency>
+
+        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpmime -->
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpmime</artifactId>
+            <version>4.5.14</version>
+        </dependency>
+
+        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore -->
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpcore</artifactId>
+            <version>4.4.16</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>31.1-jre</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.aliyun.odps</groupId>
+            <artifactId>odps-sdk-core</artifactId>
+            <version>0.27.2-public</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.aliyun.oss</groupId>
+            <artifactId>aliyun-sdk-oss</artifactId>
+            <version>3.17.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.xuxueli</groupId>
+            <artifactId>xxl-job-core</artifactId>
+        </dependency>
+
+        <!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+            <version>1.17.1</version>
+        </dependency>
+
+        <!--XML 解析包-->
+        <dependency>
+            <groupId>org.jdom</groupId>
+            <artifactId>jdom2</artifactId>
+            <version>2.0.6</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.aliyun.openservices</groupId>
+            <artifactId>ons-client</artifactId>
+            <version>1.8.4.Final</version>
+        </dependency>
+
+        <!-- https://mvnrepository.com/artifact/com.ctrip.framework.apollo/apollo-client -->
+        <dependency>
+            <groupId>com.ctrip.framework.apollo</groupId>
+            <artifactId>apollo-client</artifactId>
+            <version>2.0.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.aliyun.openservices</groupId>
+            <artifactId>aliyun-log-producer</artifactId>
+            <version>0.3.10</version>
+        </dependency>
+        <dependency>
+            <groupId>com.aliyun.openservices</groupId>
+            <artifactId>aliyun-log-logback-appender</artifactId>
+            <version>0.1.18</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>com.google.protobuf</groupId>
+                    <artifactId>protobuf-java</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <!-- 强制使用兼容的 Protobuf 版本 -->
+        <dependency>
+            <groupId>com.google.protobuf</groupId>
+            <artifactId>protobuf-java</artifactId>
+            <version>3.20.1</version> <!-- 使用与阿里云 SDK 兼容的版本 -->
+        </dependency>
+
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.aliyun</groupId>
+            <artifactId>alibabacloud-dysmsapi20170525</artifactId>
+            <version>2.0.23</version>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>com.tzld.commons</groupId>
+            <artifactId>aliyun-log-spring-boot-starter</artifactId>
+            <version>2.0.0</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>aliyun-log</artifactId>
+                    <groupId>com.aliyun.openservices</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>com.stuuudy.commons</groupId>
+            <artifactId>commons-external</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-validation</artifactId>
+        </dependency>
+
+        <!-- Eureka 客户端 -->
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
+        </dependency>
+
+        <!-- Jersey 客户端(Eureka 依赖) -->
+        <dependency>
+            <groupId>com.sun.jersey</groupId>
+            <artifactId>jersey-client</artifactId>
+            <version>1.19.4</version>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.jersey.contribs</groupId>
+            <artifactId>jersey-apache-client4</artifactId>
+            <version>1.19.4</version>
+        </dependency>
+
+        <!-- OpenFeign -->
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-openfeign</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.8.18</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.msgpack</groupId>
+            <artifactId>msgpack-core</artifactId>
+            <version>0.9.9</version>
+        </dependency>
+        <dependency>
+            <groupId>org.msgpack</groupId>
+            <artifactId>jackson-dataformat-msgpack</artifactId>
+            <version>0.9.9</version>
+        </dependency>
+
+
+    </dependencies>
+
+</project>

+ 51 - 0
server/pom.xml

@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.tzld.piaoquan</groupId>
+        <artifactId>tencent-rta-server</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>server</artifactId>
+
+    <properties>
+        <java.version>1.8</java.version>
+        <maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss.SSS</maven.build.timestamp.format>
+        <mavenBuildTime>${maven.build.timestamp}</mavenBuildTime>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.tzld.piaoquan</groupId>
+            <artifactId>core</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <!-- 固定包名 避免随着版本变动 -->
+        <finalName>tencent-rta-server</finalName>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>true</filtering>
+                <includes>
+                    <include>**/*.yml</include>
+                    <include>**/*.yaml</include>
+                    <include>**/*.xml</include>
+                    <include>**/*.properties</include>
+                </includes>
+            </resource>
+        </resources>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+
+    </build>
+</project>

+ 33 - 0
server/src/main/java/com/tzld/rta/Application.java

@@ -0,0 +1,33 @@
+package com.tzld.rta;
+
+import com.tzld.rta.interceptor.CrosDomainAllowInterceptor;
+import org.mybatis.spring.annotation.MapperScan;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.web.servlet.ServletComponentScan;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+@SpringBootApplication
+@MapperScan("com.tzld.rta.dao")
+@ServletComponentScan("com.tzld.rta.controller")
+@EnableDiscoveryClient
+@EnableFeignClients
+public class Application implements WebMvcConfigurer {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(Application.class);
+
+    public static void main(String[] args) {
+        SpringApplication.run(Application.class, args);
+        LOGGER.info("tencent-rta-server Start Success");
+    }
+
+    @Override
+    public void addInterceptors(InterceptorRegistry registry) {
+        registry.addInterceptor(new CrosDomainAllowInterceptor()).addPathPatterns("/**");
+    }
+}

+ 171 - 0
server/src/main/java/com/tzld/rta/aop/LogRequestAop.java

@@ -0,0 +1,171 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright © 2021 xrv <xrg@live.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+package com.tzld.rta.aop;
+
+import com.alibaba.fastjson.JSON;
+import com.google.common.base.Strings;
+import com.tzld.commons.aliyun.log.AliyunLogManager;
+import com.tzld.rta.util.IpUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+/**
+ * 请求日志记录
+ *
+ * @author ehlxr
+ * @since 2021-12-14 14:03.
+ */
+@Aspect
+@Component
+public class LogRequestAop {
+    private static final Logger log = LoggerFactory.getLogger(LogRequestAop.class);
+
+    private final AliyunLogManager aliyunLogManager;
+    /**
+     * aliyun log 配置
+     */
+    @Value("${aliyun.log.project:}")
+    private String projcet;
+    @Value("${aliyun.log.logstore.request:request-log}")
+    private String logStore;
+    @Value("${aliyun.log.topic:}")
+    private String topic;
+
+    public static String LOG_TRACE_ID = "logTraceId";
+    private String REQUEST_START_TIME = "request_start_time";
+
+    @Autowired
+    public LogRequestAop(AliyunLogManager aliyunLogManager) {
+        this.aliyunLogManager = aliyunLogManager;
+    }
+
+    /**
+     * 切入点
+     */
+    @Pointcut("execution(public * com.tzld.rta.controller..*(..)) " +
+            "&& !@annotation(com.tzld.rta.annotation.NoRequestLog)")
+    public void requestLog() {
+    }
+
+    /**
+     * 前置操作
+     */
+    @Before("requestLog()")
+    public void beforeLog() {
+        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+        HttpServletRequest request = Objects.requireNonNull(attributes).getRequest();
+
+        request.setAttribute(REQUEST_START_TIME, System.currentTimeMillis());
+    }
+
+    /**
+     * 后置操作
+     */
+    @AfterReturning(pointcut = "requestLog()", returning = "returnValue")
+    public void afterReturning(JoinPoint point, Object returnValue) {
+        logRecord(point, JSON.toJSONString(returnValue));
+    }
+
+    @AfterThrowing(pointcut = "requestLog()", throwing = "ex")
+    public void afterThrowing(JoinPoint point, Exception ex) {
+        logRecord(point, getStackTraceString(ex));
+    }
+
+    /**
+     * 获取异常的完整堆栈信息
+     */
+    private String getStackTraceString(Exception ex) {
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        ex.printStackTrace(pw);
+        return sw.toString();
+    }
+
+    private void logRecord(JoinPoint point, String message) {
+        try {
+            ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+            HttpServletRequest request = Objects.requireNonNull(attributes).getRequest();
+
+            Long startTime = (Long) request.getAttribute(REQUEST_START_TIME);
+            if (Objects.isNull(startTime)) {
+                return;
+            }
+
+            String query = request.getQueryString();
+            String uri = request.getRequestURI();
+
+            Map<String, Object> logMap = new HashMap<>(8);
+            String url = Strings.isNullOrEmpty(query) ? uri : uri + "?" + query;
+            if (StringUtils.isNotBlank(url) && url.contains("/test")) {
+                return;
+            }
+            logMap.put("url", url);
+            logMap.put("method", request.getMethod());
+            logMap.put("header", getHeaders(request));
+            logMap.put("elapsedTime", String.valueOf(System.currentTimeMillis() - startTime));
+            logMap.put("clientIp", IpUtil.getIpAddr(request));
+            logMap.put("requestBody", getRequestBody(point.getArgs()));
+            logMap.put(LOG_TRACE_ID, Strings.nullToEmpty(MDC.get(LOG_TRACE_ID)));
+            logMap.put("responseBody", message);
+            aliyunLogManager.sendLog(projcet, logStore, topic, logMap);
+        } catch (Exception e) {
+            log.error("log report request error", e);
+        }
+    }
+
+    private Object getRequestBody(Object[] args) {
+        try {
+            return JSON.toJSONString(args[0]);
+        } catch (Exception e) {
+            return args;
+        }
+    }
+
+    private String getHeaders(HttpServletRequest request) {
+        return Collections.list(request.getHeaderNames())
+                .stream()
+                .collect(Collectors.toMap(
+                        name -> name,
+                        request::getHeader)).toString();
+    }
+}

+ 21 - 0
server/src/main/java/com/tzld/rta/controller/HealthController.java

@@ -0,0 +1,21 @@
+package com.tzld.rta.controller;
+
+import com.tzld.rta.annotation.NoRequestLog;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/")
+public class HealthController {
+
+    /**
+     * 探活
+     * @return
+     */
+    @GetMapping("/healthcheck")
+    @NoRequestLog
+    public String healthcheck() {
+        return "ok";
+    }
+}

+ 40 - 0
server/src/main/java/com/tzld/rta/filter/CustomFilter.java

@@ -0,0 +1,40 @@
+package com.tzld.rta.filter;
+
+import com.tzld.rta.aop.LogRequestAop;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.springframework.core.annotation.Order;
+
+import javax.servlet.*;
+import javax.servlet.annotation.WebFilter;
+import java.io.IOException;
+import java.util.UUID;
+
+/**
+ * auth filter
+ *
+ */
+@Order(value = 1)
+@WebFilter(filterName = "customFilter", urlPatterns = {"/*"})
+public class CustomFilter implements Filter {
+    private static final Logger log = LoggerFactory.getLogger(CustomFilter.class);
+
+    @Override
+    public void init(FilterConfig filterConfig) {
+        log.info("customFilter init");
+    }
+
+    @Override
+    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
+            throws IOException, ServletException {
+        MDC.put(LogRequestAop.LOG_TRACE_ID, UUID.randomUUID().toString().replaceAll("-", ""));
+        filterChain.doFilter(servletRequest, servletResponse);
+        MDC.remove(LogRequestAop.LOG_TRACE_ID);
+    }
+
+    @Override
+    public void destroy() {
+        log.info("customFilter destroy");
+    }
+}

+ 55 - 0
server/src/main/resources/application-dev.yml

@@ -0,0 +1,55 @@
+server:
+  port: 8080
+
+spring:
+  datasource:
+    rta:
+      driver-class-name: com.mysql.jdbc.Driver
+      jdbc-url: jdbc:mysql://rm-bp17q95335a99272b.mysql.rds.aliyuncs.com:3306/deconstruct-vector?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false
+      username: crawler
+      password: crawler123456@
+      type: com.zaxxer.hikari.HikariDataSource
+      hikari:
+        minimum-idle: 10
+        maximum-pool-size: 20
+        connection-test-query: SELECT 1
+
+  redis:
+    host: r-bp1zg8fw8db0vxdo2mpd.redis.rds.aliyuncs.com
+    port: 6379
+    username: r-bp1zg8fw8db0vxdo2m
+    password: Wqsd@2026
+
+xxl:
+  job:
+    admin:
+      addresses: http://xxl-job-test-internal.piaoquantv.com/xxl-job-admin
+
+aliyun:
+  log:
+    endpoint: cn-hangzhou.log.aliyuncs.com
+    accessKeyId: LTAIP6x1l3DXfSxm
+    accessKeySecret: KbTaM9ars4OX3PMS6Xm7rtxGr1FLon
+    project: tencent-rta-server-test
+    logstore:
+      info: info-log
+      error: error-log
+      request: request-log
+
+apollo:
+  meta: http://devapolloconfig-internal.piaoquantv.com
+
+feign:
+  client:
+    config:
+      default:  # 默认 Feign 客户端配置
+        logger-level: NONE  # 日志级别(NONE/BASE/HEADERS/FULL)
+        connect-timeout: 20000  # 连接超时时间(毫秒)
+        read-timeout: 20000  # 读取超时时间(毫秒)
+
+eureka:
+  client:
+    service-url:  # Eureka 服务注册中心地址
+      defaultZone: http://deveureka-internal.piaoquantv.com/eureka/  # 注册中心 URL
+
+

+ 53 - 0
server/src/main/resources/application-prod.yml

@@ -0,0 +1,53 @@
+server:
+  port: 8080
+
+spring:
+  datasource:
+    rta:
+      driver-class-name: com.mysql.jdbc.Driver
+      jdbc-url: jdbc:mysql://rm-bp17q95335a99272b.mysql.rds.aliyuncs.com:3306/deconstruct-vector?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false
+      username: crawler
+      password: crawler123456@
+      type: com.zaxxer.hikari.HikariDataSource
+      hikari:
+        minimum-idle: 10
+        maximum-pool-size: 20
+        connection-test-query: SELECT 1
+
+  redis:
+    host: r-bp1zg8fw8db0vxdo2mpd.redis.rds.aliyuncs.com
+    port: 6379
+    username: r-bp1zg8fw8db0vxdo2m
+    password: Wqsd@2026
+
+xxl:
+  job:
+    admin:
+      addresses: http://xxl-job-internal.piaoquantv.com/xxl-job-admin
+
+aliyun:
+  log:
+    endpoint: cn-hangzhou.log.aliyuncs.com
+    accessKeyId: LTAIP6x1l3DXfSxm
+    accessKeySecret: KbTaM9ars4OX3PMS6Xm7rtxGr1FLon
+    project: tencent-rta-server-prod
+    logstore:
+      info: info-log
+      error: error-log
+      request: request-log
+
+apollo:
+  meta: http://apolloconfig-internal.piaoquantv.com
+
+feign:
+  client:
+    config:
+      default:  # 默认 Feign 客户端配置
+        logger-level: NONE  # 日志级别(NONE/BASE/HEADERS/FULL)
+        connect-timeout: 20000  # 连接超时时间(毫秒)
+        read-timeout: 20000  # 读取超时时间(毫秒)
+
+eureka:
+  client:
+    service-url:  # Eureka 服务注册中心地址
+      defaultZone: http://eureka-internal.piaoquantv.com/eureka/  # 注册中心 URL

+ 53 - 0
server/src/main/resources/application-test.yml

@@ -0,0 +1,53 @@
+server:
+  port: 8080
+
+spring:
+  datasource:
+    rta:
+      driver-class-name: com.mysql.jdbc.Driver
+      jdbc-url: jdbc:mysql://rm-bp17q95335a99272b.mysql.rds.aliyuncs.com:3306/deconstruct-vector?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false
+      username: crawler
+      password: crawler123456@
+      type: com.zaxxer.hikari.HikariDataSource
+      hikari:
+        minimum-idle: 10
+        maximum-pool-size: 20
+        connection-test-query: SELECT 1
+
+  redis:
+    host: r-bp1zg8fw8db0vxdo2mpd.redis.rds.aliyuncs.com
+    port: 6379
+    username: r-bp1zg8fw8db0vxdo2m
+    password: Wqsd@2026
+
+xxl:
+  job:
+    admin:
+      addresses: http://xxl-job-test-internal.piaoquantv.com/xxl-job-admin
+
+aliyun:
+  log:
+    endpoint: cn-hangzhou.log.aliyuncs.com
+    accessKeyId: LTAIP6x1l3DXfSxm
+    accessKeySecret: KbTaM9ars4OX3PMS6Xm7rtxGr1FLon
+    project: tencent-rta-server-test
+    logstore:
+      info: info-log
+      error: error-log
+      request: request-log
+
+apollo:
+  meta: http://testapolloconfig-internal.piaoquantv.com
+
+feign:
+  client:
+    config:
+      default:  # 默认 Feign 客户端配置
+        logger-level: NONE  # 日志级别(NONE/BASE/HEADERS/FULL)
+        connect-timeout: 20000  # 连接超时时间(毫秒)
+        read-timeout: 20000  # 读取超时时间(毫秒)
+
+eureka:
+  client:
+    service-url:  # Eureka 服务注册中心地址
+      defaultZone: http://testeureka-internal.piaoquantv.com/eureka/  # 注册中心 URL

+ 68 - 0
server/src/main/resources/application.yml

@@ -0,0 +1,68 @@
+spring:
+  profiles:
+    active: test
+  application:
+    name: tencent-rta-server
+
+server:
+  tomcat:
+    threads:
+      max: 1000
+    uri-encoding: UTF-8
+    accept-count: 1000
+    connection-timeout: 30000
+  servlet:
+    context-path: /tencentRta
+    session:
+      timeout: 60
+pagehelper:
+  helper-dialect: mysql
+
+mybatis:
+  mapper-locations: classpath:mapper/**/*.xml
+  configuration:
+    use-generated-keys: true
+    map-underscore-to-camel-case: true
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl  # 直接输出到控制台(简单调试用)
+
+app:
+  id: tencent-rta-server  # 应用标识
+  build:
+    time: @mavenBuildTime@
+
+xxl:
+  job:
+    accessToken:
+    executor:
+      appname: ${spring.application.name}
+      address:
+      ip:
+      port: 9999
+      logpath: /datalog/weblog/xxl-job/jobhandler
+      logretentiondays: 7
+
+apollo:
+  bootstrap:
+    enabled: true  # 启用 Apollo 配置预加载
+    namespaces: application  # 指定加载的命名空间
+  cacheDir: /datalog/apollo-cache-dir  # Apollo 本地缓存目录
+
+eureka:
+  instance:
+    prefer-ip-address: true  # 优先使用 IP 地址注册
+    instance-id: ${spring.cloud.client.ip-address}:${spring.application.name}:${server.port}  # 实例 ID 格式
+    lease-renewal-interval-in-seconds: 30  # 心跳续约间隔(秒)
+    lease-expiration-duration-in-seconds: 90  # 心跳过期时间(秒)
+  client:
+    registry-fetch-interval-seconds: 5  # 拉取服务注册列表间隔(秒)
+
+logging:
+  level:
+    # 替换为你的 Mapper 接口所在包路径(根据错误日志中的包名调整)
+    com.tzld.rta.dao.mapper: DEBUG  # 输出该包下所有 Mapper 的 SQL 日志
+    # 可选:HikariCP 连接池日志(调试连接问题时开启)
+    com.zaxxer.hikari: INFO  # 连接池基本信息(避免 DEBUG 级别日志过多)
+
+cdn:
+  upload:
+    domain: https://weappupload.piaoquantv.com/

+ 166 - 0
server/src/main/resources/logback-spring.xml

@@ -0,0 +1,166 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 -->
+<!-- scan:当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true -->
+<!-- scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
+<!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
+<configuration scan="true" scanPeriod="10 seconds">
+    <!--<include resource="org/springframework/boot/logging/logback/base.xml"/>-->
+
+    <contextName>logback</contextName>
+    <!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
+    <!-- <property name="LOG_PATH"  value="${logging.file.path}" />-->
+
+    <springProperty name="LOG_PATH" source="logging.file.path"/>
+    <springProperty name="ALIYUN_LOG_ENDPOINT" source="aliyun.log.endpoint"/>
+    <springProperty name="ALIYUN_LOG_ACCESSKEYID" source="aliyun.log.accessKeyId"/>
+    <springProperty name="ALIYUN_LOG_ACCESSKEYSECRET" source="aliyun.log.accessKeySecret"/>
+    <springProperty name="ALIYUN_LOG_PROJECT" source="aliyun.log.project"/>
+    <springProperty name="ALIYUN_LOG_LOGSTORE_INFO" source="aliyun.log.logstore.info"/>
+    <springProperty name="ALIYUN_LOG_LOGSTORE_ERROR" source="aliyun.log.logstore.error"/>
+
+    <!-- 彩色日志 -->
+    <!-- 彩色日志依赖的渲染类 -->
+    <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
+    <conversionRule conversionWord="wex"
+                    converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
+    <conversionRule conversionWord="wEx"
+                    converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
+    <!-- 彩色日志格式 -->
+    <property name="CONSOLE_LOG_PATTERN"
+              value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr([%X{logTraceId}]){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
+    <!--<property name="CONSOLE_LOG_PATTERN"-->
+    <!--          value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr([%X{√logTraceId}]){magenta} %clr(-&#45;&#45;){faint} %clr([%15.15t]){faint} %clr(at %class.%method){cyan} \\(%file:%line\\) %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>-->
+
+    <!--输出到控制台-->
+    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+        <!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
+        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+            <level>debug</level>
+        </filter>
+        <encoder>
+            <Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
+            <!-- 设置字符集 -->
+            <charset>UTF-8</charset>
+        </encoder>
+    </appender>
+
+
+    <appender name="ALIYUN_LOG_INFO" class="com.tzld.rta.common.LoghubAppender">
+        <endpoint>${ALIYUN_LOG_ENDPOINT}</endpoint>
+        <accessKeyId>${ALIYUN_LOG_ACCESSKEYID}</accessKeyId>
+        <accessKeySecret>${ALIYUN_LOG_ACCESSKEYSECRET}</accessKeySecret>
+        <project>${ALIYUN_LOG_PROJECT}</project>
+        <logStore>${ALIYUN_LOG_LOGSTORE_INFO}</logStore>
+
+        <totalSizeInBytes>104857600</totalSizeInBytes>
+        <maxBlockMs>0</maxBlockMs>
+        <ioThreadCount>8</ioThreadCount>
+        <batchSizeThresholdInBytes>524288</batchSizeThresholdInBytes>
+        <batchCountThreshold>4096</batchCountThreshold>
+        <lingerMs>2000</lingerMs>
+        <retries>10</retries>
+        <baseRetryBackoffMs>100</baseRetryBackoffMs>
+        <maxRetryBackoffMs>50000</maxRetryBackoffMs>
+
+        <encoder>
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level [%X{logTraceId}] %logger{50} [%L] - %msg%n</pattern>
+            <charset>UTF-8</charset>
+        </encoder>
+
+        <timeFormat>yyyy-MM-dd'T'HH:mmZ</timeFormat>
+        <timeZone>Asia/Shanghai</timeZone>
+
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>INFO</level>
+        </filter>
+
+        <mdcFields>logTraceId</mdcFields>
+    </appender>
+
+    <appender name="ALIYUN_LOG_ERROR" class="com.tzld.rta.common.LoghubAppender">
+        <endpoint>${ALIYUN_LOG_ENDPOINT}</endpoint>
+        <accessKeyId>${ALIYUN_LOG_ACCESSKEYID}</accessKeyId>
+        <accessKeySecret>${ALIYUN_LOG_ACCESSKEYSECRET}</accessKeySecret>
+        <project>${ALIYUN_LOG_PROJECT}</project>
+        <logStore>${ALIYUN_LOG_LOGSTORE_ERROR}</logStore>
+
+        <totalSizeInBytes>104857600</totalSizeInBytes>
+        <maxBlockMs>0</maxBlockMs>
+        <ioThreadCount>8</ioThreadCount>
+        <batchSizeThresholdInBytes>524288</batchSizeThresholdInBytes>
+        <batchCountThreshold>4096</batchCountThreshold>
+        <lingerMs>2000</lingerMs>
+        <retries>10</retries>
+        <baseRetryBackoffMs>100</baseRetryBackoffMs>
+        <maxRetryBackoffMs>50000</maxRetryBackoffMs>
+
+        <encoder>
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level [%X{logTraceId}] %logger{50} [%L] - %msg%n</pattern>
+            <charset>UTF-8</charset>
+        </encoder>
+
+        <timeFormat>yyyy-MM-dd'T'HH:mmZ</timeFormat>
+        <timeZone>Asia/Shanghai</timeZone>
+
+        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+            <level>ERROR</level>
+        </filter>
+
+        <mdcFields>logTraceId</mdcFields>
+    </appender>
+
+    <!--
+        <logger>用来设置某一个包或者具体的某一个类的日志打印级别、以及指定<appender>。
+        <logger>仅有一个name属性,一个可选的level和一个可选的addtivity属性。
+        name:用来指定受此logger约束的某一个包或者具体的某一个类。
+        level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,
+              还有一个特俗值INHERITED或者同义词NULL,代表强制执行上级的级别。
+              如果未设置此属性,那么当前logger将会继承上级的级别。
+        addtivity:是否向上级logger传递打印信息。默认是true。
+    -->
+    <!--<logger name="org.springframework.web" level="info"/>-->
+    <!--<logger name="org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor" level="INFO"/>-->
+
+    <!--
+        使用mybatis的时候,sql语句是debug下才会打印,而这里我们只配置了info,所以想要查看sql语句的话,有以下两种操作:
+        第一种把<root level="info">改成<root level="DEBUG">这样就会打印sql,不过这样日志那边会出现很多其他消息
+        第二种就是单独给dao下目录配置 <logger> 指定 level 属性为 debug,这样配置sql语句会打印,其他还是正常info级别:
+     -->
+
+    <!--<springProfile name="dev">-->
+    <!--    <logger name="com.tzld.piaoquan.ad" level="debug"/>-->
+    <!--    <logger name="com.ctrip.framework.apollo.internals.RemoteConfigLongPollService" level="error"/>-->
+    <!--</springProfile>-->
+    <!--<springProfile name="test">-->
+    <!--    <logger name="com.tzld.piaoquan.ad" level="info"/>-->
+    <!--</springProfile>-->
+    <!--<springProfile name="pre">-->
+    <!--    <logger name="com.tzld.piaoquan.ad" level="info"/>-->
+    <!--</springProfile>-->
+    <!--<springProfile name="stress">-->
+    <!--    <logger name="com.tzld.piaoquan.ad" level="info"/>-->
+    <!--</springProfile>-->
+    <!--<springProfile name="prod">-->
+    <!--    <logger name="com.tzld.piaoquan.ad" level="info"/>-->
+    <!--</springProfile>-->
+    <!--<logger name="com.netflix.discovery.shared.resolver.aws.ConfigClusterResolver" level="warn"/>-->
+
+    <!-- 可用来获取 StatusManager 中的状态 -->
+    <!--<statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener"/>-->
+    <!-- 解决 aliyun loghub debug模式下循环发送的问题 -->
+    <logger name="org.apache.http.impl.conn.Wire" level="WARN"/>
+    <!--aliyun loghub 为了防止进程退出时,内存中的数据丢失,请加上此选项-->
+    <shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook"/>
+
+    <!--
+        root节点是必选节点,用来指定最基础的日志输出级别,只有一个level属性
+        level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,
+        不能设置为INHERITED或者同义词NULL。默认是DEBUG
+        可以包含零个或多个元素,标识这个appender将会添加到这个logger。
+    -->
+    <root level="info">
+        <appender-ref ref="CONSOLE"/>
+        <appender-ref ref="ALIYUN_LOG_INFO"/>
+        <appender-ref ref="ALIYUN_LOG_ERROR"/>
+    </root>
+</configuration>

+ 42 - 0
server/src/test/java/FeishuTest.java

@@ -0,0 +1,42 @@
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.tzld.rta.Application;
+import com.tzld.rta.util.feishu.FeiShu;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.data.util.Pair;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.client.RestTemplate;
+
+@SpringBootTest(classes = Application.class)
+@Slf4j
+public class FeishuTest {
+
+    @Test
+    public void test() {
+        String sheetToken = "ZSIVw4IQiiuYVwkBrC9c1uMpnKc";
+        String sheetId = "ecec8a";
+        int rowNum = 2;
+        Integer startRowIndex = 2;
+        Pair<String, Integer> token = FeiShu.requestAccessToken();
+        RestTemplate restTemplate = new RestTemplate();
+        HttpHeaders httpHeaders = new HttpHeaders();
+        httpHeaders.add("Authorization", "Bearer " + token.getFirst());
+        HttpEntity<Object> queryEntity = new HttpEntity<>(httpHeaders);
+        int deleteRowNum = rowNum < 20 ? startRowIndex + 20 * rowNum : startRowIndex + (rowNum * 2);
+        ResponseEntity<String> queryResponseEntity = restTemplate.exchange(
+                String.format("https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/%s/values/%s!A"
+                        + startRowIndex + ":A" + deleteRowNum, sheetToken, sheetId),
+                HttpMethod.GET, queryEntity, String.class);
+        JSONArray values = JSON.parseObject(queryResponseEntity.getBody())
+                .getJSONObject("data")
+                .getJSONObject("valueRange")
+                .getJSONArray("values");
+        System.out.println(JSONObject.toJSONString(values));
+    }
+}

+ 126 - 0
server/src/test/java/GeminiTest.java

@@ -0,0 +1,126 @@
+import com.alibaba.fastjson.JSONObject;
+import com.tzld.rta.Application;
+import com.tzld.rta.api.google.GeminiApiService;
+import com.tzld.rta.api.google.ModelEnum;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.io.IOException;
+
+@SpringBootTest(classes = Application.class)
+@Slf4j
+public class GeminiTest {
+    @Autowired
+    private GeminiApiService geminiApiService;
+
+//    @Value("title.analyse.systemprompt:")
+//    private String systemPrompt;
+
+    @Test
+    public void testGemini() {
+        String systemPrompt = "# 角色\n" +
+                "你是一名严格的,为中国50岁以上中老年群体做热点内容筛选的内容专家。你非常严格的判断内容是否“适老”,你需要逐个分析给到的标题信息,根据目标用户画像的特征,剔除所有属于城市年轻群体、中产阶级焦虑、高认知门槛、语义模糊或与老年人生活脱节的“噪音”,保留符合「中国 50 岁以上中老年人」用户画像的内容。\n" +
+                "\n" +
+                "# 一、基础定义(严格遵守,不可修改)\n" +
+                "## 用户画像:中国50岁以上老年人\n" +
+                "1. **认知特点**: 追求“确定性”和“安全感”。偏好简单直白的内容,拒绝烧脑、逻辑复杂或需要推理的内容。拒绝一切“盲盒式”标题(如“这件事千万别做”但没说什么事)。不关注新事物,不关注抽象的宏观经济指标、复杂的金融博弈、枯燥的行政程序\n" +
+                "2. **文化背景**: 成长于上世纪50~70年代,传统观念根深蒂固。对网络梗、亚文化、职场黑话、微短剧逻辑不敏感甚至反感。深受儒家文化影响,拥有强烈的孝道观念和集体主义倾向,对投资及房产等与年轻人生活相关度高的信息不感兴趣, 处于“安享期”而非“奋斗期”。关注“保命”(三高、心脏、防骗)而非“塑形”(减肥、发际线);关注“存量财产安全”而非“增量资产博弈”。更倾向于追求身心安宁及正能量内容,不喜欢高强度、信息量大的娱乐内容。\n" +
+                "3. **情感需求**: “安逸”、“从容”、“被尊重”。倾向于追求身心安宁、正能量、民族自豪感。反感贩卖焦虑、激烈的矛盾冲突、血腥暴力或过于悲惨的负面新闻。偏好娱乐放松、激发民族自豪感的国家大事、与中国相关的重大国际形式、民生生活、弘扬社会正能量、家庭生活、传统文化、时事政务、同龄人出镜的内容,需要被“认同感”及“群体认同感”,偏好接地气、贴近生活、贴近自身的内容,叙事风格\n" +
+                "4. **场景偏好**: 菜市场、公园、家庭、医院、老友聚会等怀旧场景。排斥写字楼、夜店、高端滑雪场、极限运动场所。\n" +
+                "\n" +
+                "## 适老品类库(白名单)\n" +
+                "只有核心内容属于以下分类,才具备“品类适老系数=1”的基础条件:\n" +
+                "*   **国家力量/统一**: 阅兵、基建狂魔、外交胜利、撤侨、领土主权、两岸统一(不含晦涩的地缘政治分析),以非具体正能量人物、非科学、技术为主要内容;反映中国人文、文化、基建、人民生活、国内外对比中强大的内容\n" +
+                "*   **知识科普**:非生活技巧、非科技自然 的 文化、历史、人文、健康等社科知识类科普视\n" +
+                "*   **惠民/民生政策**: 养老金调整、医保报销、现金支付保障、菜篮子物价、天气预警(需具体利民,非枯燥公文)。\n" +
+                "*   **人财诈骗/防骗**: 电诈案例、新型毒品伪装、保健品骗局(极高优先级)。\n" +
+                "*   **老年健康**: 三高管理、心脑血管、养生食疗、长寿知识(**严格剔除**减肥、塑形、医美、脱发焦虑)。\n" +
+                "*   **怀念时光**: 70年代及以前的老照片、老电影切片(非影评)、经典红歌。\n" +
+                "*   **家庭/亲子**: 隔辈亲、孝道故事、家庭邻里互助(**严格剔除**婆媳恶斗、剧烈伦理冲突)。\n" +
+                "*   **传统文化/习俗**: 节气、民俗、戏曲、国学、非遗。\n" +
+                "*   **正能量/社会风气**: 见义勇为、拾金不昧、反腐倡廉、平凡人的善举,以具体中国当代正能量人物为主要描述对象的内容\n" +
+                "*   **惊奇/罕见画面**: 自然奇观、动物趣闻(**严格剔除**血腥、恐怖、猎奇阴暗面)。\n" +
+                "\n" +
+                "# 二、红灯拦截标准(触犯即死,优先级最高)\n" +
+                "**不仅要检查负面词汇,更要检查“逻辑不适老”,凡触犯以下任意一条,分值直接归零,:**\n" +
+                "\n" +
+                "1.  **信源模糊/标题党拦截**:\n" +
+                "    *   标题缺乏具体的**人名、地名、机构名**,无法作为搜索关键词的(如“最爱发钱的老板招工了”、“我看这地儿不错”)。\n" +
+                "    *   主语不明、指代不清的(如“注意!这东西不能吃”、“他竟然这样做”)。\n" +
+                "    *   个人Vlog式、无公共信息价值的感悟(如“如果我在冬天失业了”)。\n" +
+                "2.  **生命阶段错位拦截**:\n" +
+                "    *   **职场焦虑**:涉及“月薪、大厂、内卷、求职(非银发专岗)、降薪、裁员、年终奖”。\n" +
+                "    *   **中年健康焦虑**:涉及“减肥、瘦身、代谢变慢、发际线、抗初老、精力管理”。\n" +
+                "    *   **高危活动**:涉及“滑雪、潜水、马拉松、蹦极、赛车”等不适合老年人生理机能的活动(即使是免费票也要拦截)。\n" +
+                "3.  **低质娱乐/亚文化拦截**:\n" +
+                "    *   **微短剧/网剧**:标题含“微短剧、网剧、霸总、逆袭、重生”等,此类内容多为虚构浮夸且含诱导付费。\n" +
+                "    *   **网络热梗**:含“破防、yyds、绝绝子、CP感、谐音梗营销”,网络热梗段子、恶搞视频、二次元的游戏黑话等\n" +
+                "    *   **专业/小众体育**:NBA交易、欧洲足球战术、球星转会费、网球/斯诺克小众赛事(除非是**国家队/为国争光**)。\n" +
+                "    *   **长辈无关娱乐圈**:年轻流量偶像八卦、饭圈互撕、国外网红动态。\n" +
+                "4.  **金融与商业噪音拦截**:\n" +
+                "    *   涉及“板块、指数、美联储、加息、IPO、资产配置、套利”的金融博弈。\n" +
+                "    *   涉及“金银价格剧烈波动分析”(如“K线、点位、抄底”),只保留单纯的实物金价涨跌。\n" +
+                "    *   明显的商业软文、带货广告、陌生APP公测。\n" +
+                "5.  **负面与恐慌拦截**:\n" +
+                "    *   过于血腥、暴力、违背伦理的案件细节(如“强奸、分尸、虐待”)。\n" +
+                "    *   纯粹贩卖焦虑而无解决方案的内容。\n" +
+                "6.行政公文拦截:没有具体利民事件的,一律不通过。\n" +
+                "7.宏观自豪感拦截: 只有国家领导人会面而无具体实惠或震撼性视觉成果(如大型阅兵、卫星发射成功)的,一律不通过。\n" +
+                "\n" +
+                "# 三、核心评分与计算逻辑\n" +
+                "## 第一步:红灯熔断审查\n" +
+                "检查标题是否触犯【二、红灯拦截标准】。\n" +
+                "*   **若触犯任意一条**:最终综合得分直接为 0.00,判定为“不通过”,reason中明确指出触犯了哪条红灯。\n" +
+                "*   **若未触犯**:进入第二步。\n" +
+                "\n" +
+                "## 第二步:用户画像维度打分(0.00 - 1.00)\n" +
+                "请根据【一、用户画像】对以下四个维度进行最严格的独立打分,如果信息模糊则全部用最低分值判断:\n" +
+                "1.  **S1 认知特点 (权重 20%)**:对应用户画像进行判断(模糊不清/专业术语/黑话=0分)\n" +
+                "2.  **S2 文化背景 (权重 30%)**:对应用户画像进行判断(个人主义/挑战传统/崇洋媚外=0分)\n" +
+                "3.  **S3 情感需求 (权重 30%)**:对应用户画像进行判断(焦虑/恐惧/悲惨/激烈冲突=0分)\n" +
+                "4.  **S4 场景偏好 (权重 20%)**:对应用户画像进行判断(CBD/夜店/极限运动/国外陌生场景=0分)\n" +
+                "\n" +
+                "## 第三步:短板效应与画像分计算\n" +
+                "*   **公式**:\n" +
+                "    IF (S1 < 0.6 OR S2 < 0.6 OR S3 < 0.6):\n" +
+                "        Persona_Score = Min(S1, S2, S3)  (任意核心维度不及格,则整体不及格)\n" +
+                "    ELSE:\n" +
+                "        Persona_Score = (S1 * 0.2) + (S2 * 0.3) + (S3 * 0.3) + (S4 * 0.2)\n" +
+                "\n" +
+                "## 第四步:最终判定\n" +
+                "*   **品类系数 K**:\n" +
+                "    *   内容核心属于白名单品类:K = 1\n" +
+                "    *   内容核心不属于白名单(如科技、游戏、职场、二次元等):K = 0\n" +
+                "*   **最终综合得分** = Persona_Score * K\n" +
+                "\n" +
+                "\n" +
+                "# 四、输出格式\n" +
+                "仅输出 JSON 格式,无多余解释。\n" +
+                "\n" +
+                "{\n" +
+                "  \"标题内容\": \"原标题\",\n" +
+                "  \"最终综合得分\": 0.00,\n" +
+                "  \"画像维度得分\": {\n" +
+                "    \"S1_认知\": 0.00,\n" +
+                "    \"S2_文化\": 0.00,\n" +
+                "    \"S3_情感\": 0.00,\n" +
+                "    \"S4_场景\": 0.00\n" +
+                "  },\n" +
+                "  \"用户画像匹配分(Persona_Score)\": 0.00,\n" +
+                "  \"品类系数(K)\": 1或0,\n" +
+                "  \"匹配品类\": \"最匹配的白名单分类或'无'\",\n" +
+                "  \"reason\": \"简要说明理由,若拦截需指出具体原因(如:信源模糊、生命阶段错位、红灯拦截等)\"\n" +
+                "}";
+        String content = "郑建成:中国现代文学评论中的金岳霖";
+
+        try {
+            JSONObject jsonObject = geminiApiService.callGemini(ModelEnum.GEMINI_3_FLASH_PREVIEW, systemPrompt,content);
+            log.info(jsonObject.toString());
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+
+    }
+}