AI ID通用方法
This commit is contained in:
@@ -2,7 +2,6 @@ package com.volvo.ai.analytic.center.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.volvo.common.core.base.BaseEntity;
|
||||
import jdk.nashorn.internal.ir.annotations.Ignore;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@@ -5,7 +5,7 @@ import lombok.Getter;
|
||||
@Getter
|
||||
public enum BusinessTypeEnum {
|
||||
|
||||
COMMUNITYTARGET("COMMUNITYTARGET", "社区舆情分析")
|
||||
COMMUNITYTARGET("CommunityTarget", "社区舆情分析")
|
||||
;
|
||||
|
||||
private String code;
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.volvo.ai.analytic.center.utils;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class AiAnalysisUtils {
|
||||
|
||||
/**
|
||||
* 生成ai分析请求id
|
||||
* @param businessType
|
||||
* @return
|
||||
*/
|
||||
public static String getAiAnalysisRequestId(String businessType) {
|
||||
if (businessType == null || businessType.trim().isEmpty()) {
|
||||
log.error("businessType is null or empty, using default value 'unknown'");
|
||||
businessType = "unknown";
|
||||
}
|
||||
|
||||
try {
|
||||
long snowflakeId = IdUtil.getSnowflakeNextId();
|
||||
if (snowflakeId == 0) {
|
||||
log.error("Failed to generate Snowflake ID");
|
||||
throw new RuntimeException("Failed to generate Snowflake ID");
|
||||
}
|
||||
String aiAnalysisRequestId = businessType + "-" + snowflakeId;
|
||||
log.info("Generated AI analysis request ID: {}", aiAnalysisRequestId);
|
||||
return aiAnalysisRequestId;
|
||||
} catch (Exception e) {
|
||||
log.error("Error generating AI analysis request ID", e);
|
||||
//生成唯一字符串
|
||||
return businessType + "-"+IdUtil.fastSimpleUUID();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user