@@ -81,36 +81,40 @@ public class AsyncLatchUtils {
|
||||
|
||||
System.out.println("主流程开始,准备分发异步任务...");
|
||||
|
||||
System.out.println("主线程id:" + Thread.currentThread().getId());
|
||||
// 2. 提交多个异步任务
|
||||
// 任务一:获取用户信息
|
||||
AsyncLatchUtils.submitTask(executorService, () -> {
|
||||
try {
|
||||
try {
|
||||
System.out.println("任务一子线程id:" + Thread.currentThread().getId());
|
||||
System.out.println("开始获取用户信息...");
|
||||
Thread.sleep(1000); // 模拟耗时
|
||||
System.out.println("获取用户信息成功!");
|
||||
} catch (InterruptedException e) {
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
});
|
||||
|
||||
// 任务二:获取订单信息
|
||||
AsyncLatchUtils.submitTask(executorService, () -> {
|
||||
try {
|
||||
try {
|
||||
System.out.println("任务二子线程id:" + Thread.currentThread().getId());
|
||||
System.out.println("开始获取订单信息...");
|
||||
Thread.sleep(1500); // 模拟耗时
|
||||
System.out.println("获取订单信息成功!");
|
||||
} catch (InterruptedException e) {
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
});
|
||||
|
||||
// 任务三:获取商品信息
|
||||
AsyncLatchUtils.submitTask(executorService, () -> {
|
||||
try {
|
||||
try {
|
||||
System.out.println("任务三子线程id:" + Thread.currentThread().getId());
|
||||
System.out.println("开始获取商品信息...");
|
||||
Thread.sleep(500); // 模拟耗时
|
||||
System.out.println("获取商品信息成功!");
|
||||
} catch (InterruptedException e) {
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
});
|
||||
@@ -118,12 +122,12 @@ public class AsyncLatchUtils {
|
||||
System.out.println("所有异步任务已提交,主线程开始等待...");
|
||||
|
||||
// 3. 等待所有任务完成,最长等待5秒
|
||||
boolean allTasksCompleted = AsyncLatchUtils.waitFor(5, TimeUnit.SECONDS);
|
||||
boolean allTasksCompleted = AsyncLatchUtils.waitFor(5, TimeUnit.SECONDS);
|
||||
|
||||
// 4. 根据等待结果继续主流程
|
||||
if (allTasksCompleted) {
|
||||
System.out.println("所有异步任务执行成功,主流程继续...");
|
||||
} else {
|
||||
} else {
|
||||
System.err.println("有任务执行超时,主流程中断!");
|
||||
}
|
||||
|
||||
|
||||
@@ -40,8 +40,11 @@ public class PortalRespVO {
|
||||
@ExcelProperty("图标类型")
|
||||
private Integer iconType;
|
||||
|
||||
@Schema(description = "图标图片URL(当 iconType=2 时使用)", example = "https://example.com/icon.png")
|
||||
private String iconUrl;
|
||||
@Schema(description = "图标文件ID(当 iconType=2 时使用)", example = "1234567890")
|
||||
private String iconFileId;
|
||||
|
||||
@Schema(description = "图标文件名(当 iconType=2 时使用)", example = "logo.png")
|
||||
private String iconFileName;
|
||||
|
||||
@Schema(description = "门户分类", example = "业务系统")
|
||||
@ExcelProperty("门户分类")
|
||||
|
||||
@@ -41,9 +41,13 @@ public class PortalSaveReqVO {
|
||||
@Max(value = 2, message = "图标类型值不正确")
|
||||
private Integer iconType;
|
||||
|
||||
@Schema(description = "图标图片URL(当 iconType=2 时使用)", example = "https://example.com/icon.png")
|
||||
@Size(max = 500, message = "图标图片URL长度不能超过500个字符")
|
||||
private String iconUrl;
|
||||
@Schema(description = "图标文件ID(当 iconType=2 时使用)", example = "1234567890")
|
||||
@Size(max = 64, message = "图标文件ID长度不能超过64个字符")
|
||||
private String iconFileId;
|
||||
|
||||
@Schema(description = "图标文件名(当 iconType=2 时使用)", example = "logo.png")
|
||||
@Size(max = 255, message = "图标文件名长度不能超过255个字符")
|
||||
private String iconFileName;
|
||||
|
||||
@Schema(description = "门户分类", example = "业务系统")
|
||||
@Size(max = 50, message = "门户分类长度不能超过50个字符")
|
||||
|
||||
@@ -49,14 +49,21 @@ public class PortalDO extends TenantBaseDO {
|
||||
* 图标类型
|
||||
*
|
||||
* 1 - 图标库(使用 icon 字段)
|
||||
* 2 - 自定义图片(使用 iconUrl 字段)
|
||||
* 2 - 自定义图片(使用 iconFileId 字段)
|
||||
*/
|
||||
private Integer iconType;
|
||||
|
||||
/**
|
||||
* 图标图片URL(当 iconType=2 时使用)
|
||||
* 图标文件ID(当 iconType=2 时使用)
|
||||
*
|
||||
* 通过文件ID实时获取访问URL,避免URL过期问题
|
||||
*/
|
||||
private String iconUrl;
|
||||
private String iconFileId;
|
||||
|
||||
/**
|
||||
* 图标文件名(当 iconType=2 时使用)
|
||||
*/
|
||||
private String iconFileName;
|
||||
|
||||
/**
|
||||
* 门户分类
|
||||
|
||||
Reference in New Issue
Block a user