0707 - 增加消息推送

koumen
tianxinlei 2026-07-07 09:34:21 +08:00
parent 7667276c30
commit 5df6cb909b
4 changed files with 88 additions and 15 deletions

View File

@ -63,6 +63,14 @@ openapi:
apiCode: test:01 apiCode: test:01
#多个可以逗号隔开,可以为空 #多个可以逗号隔开,可以为空
tenantIds: 1838408702262321152 tenantIds: 1838408702262321152
archives:
async:
pool:
maxPoolSize: 2
corePoolSize: 1
queueCapacity: 60
namePrefix: async-task-
keepAliveSeconds: 60
# 大华平台配置 # 大华平台配置
dahua: dahua:
oauth: oauth:

View File

@ -38,6 +38,9 @@
<version>1.12.23</version> <version>1.12.23</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rocketmq</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -0,0 +1,76 @@
package com.zcloud.primeport.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
/**
* @author zhangyue
* @date 2026/2/2 17:24
*/
@Configuration
public class ThreadPoolAsyncConfig {
public static Integer maxPoolSize;
public static Integer corePoolSize;
public static Integer queueCapacity;
public static String namePrefix;
public static Integer keepAliveSeconds;
@Value("${archives.async.pool.maxPoolSize}")
public void setMaxPoolSize(Integer maxPoolSizeProperties) {
maxPoolSize = maxPoolSizeProperties;
}
@Value("${archives.async.pool.corePoolSize}")
public void setCorePoolSize(Integer corePoolSizeProperties) {
corePoolSize = corePoolSizeProperties;
}
@Value("${archives.async.pool.queueCapacity}")
public void setQueueCapacity(Integer queueCapacityProperties) {
queueCapacity = queueCapacityProperties;
}
@Value("${archives.async.pool.namePrefix}")
public void setNamePrefix(String namePrefixProperties) {
namePrefix = namePrefixProperties;
}
@Value("${archives.async.pool.keepAliveSeconds}")
public void setKeepAliveSeconds(Integer keepAliveSecondsProperties) {
keepAliveSeconds = keepAliveSecondsProperties;
}
@Bean()
public Executor asyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
//最大线程数
executor.setMaxPoolSize(maxPoolSize);
//核心线程数
executor.setCorePoolSize(corePoolSize);
//任务队列的大小
executor.setQueueCapacity(queueCapacity);
//线程前缀名
executor.setThreadNamePrefix(namePrefix);
//线程存活时间
executor.setKeepAliveSeconds(keepAliveSeconds);
/**
*
* CallerRunsPolicy()线 main 线
* AbortPolicy()
* DiscardPolicy()
* DiscardOldestPolicy()
*/
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
// 初始化
executor.initialize();
return executor;
}
}

View File

@ -46,19 +46,5 @@ public class VehicleAuditE extends BaseE {
//变更前信息 //变更前信息
private String changeBefore; private String changeBefore;
public TodoListAddEvent getSendEventObj() {
// 发送待办
TodoListAddEvent event = new TodoListAddEvent();
event.setTitle("测试消息");
event.setContent("测试消息内容");
event.setForeignKey(this.id); // 业务表ID
event.setForeignSubsidiaryKey(this.id); // 业务附表ID 没有附表时为foreignKey的值
event.setReceiveUser(getAuditUserId());// user表ID
event.setPcFlag(1); // 是否PC端待办 1是 0否
event.setAppFlag(1); // 是否APP端待办 1是 0否
event.setOtherParams(new JSONObject());
return event;
}
} }