FIX FLUX2
This commit is contained in:
@@ -22,7 +22,8 @@ public class CommonConstant {
|
|||||||
public static final Integer NUMBER_10080 = 10080;
|
public static final Integer NUMBER_10080 = 10080;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String GENERATE_PATH = "/api/generate_image_flux2_klein";
|
public static final String GENERATE_PATH = "api/generate_image";
|
||||||
|
public static final String GENERATE_PATH_FLUX2_KLEIN = "/api/generate_image_flux2_klein";
|
||||||
|
|
||||||
public static final String GENERATE_SINGLE_LOGO = "/api/generate_single_logo";
|
public static final String GENERATE_SINGLE_LOGO = "/api/generate_single_logo";
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -3405,7 +3405,7 @@ public class PythonService {
|
|||||||
if (result && jsonObject.get("code").equals(200)) {
|
if (result && jsonObject.get("code").equals(200)) {
|
||||||
log.info("Generate##responseObject###{}", jsonObject);
|
log.info("Generate##responseObject###{}", jsonObject);
|
||||||
// return setGenerateImageList(jsonObject.getJSONObject("data"));
|
// return setGenerateImageList(jsonObject.getJSONObject("data"));
|
||||||
if (servicePath== CommonConstant.GENERATE_PATH){
|
if (servicePath== CommonConstant.GENERATE_PATH_FLUX2_KLEIN){
|
||||||
//放入结果到mq
|
//放入结果到mq
|
||||||
JSONObject data = jsonObject.getJSONObject("data");
|
JSONObject data = jsonObject.getJSONObject("data");
|
||||||
String outputPath = data.getString("output_path");
|
String outputPath = data.getString("output_path");
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import okhttp3.*;
|
import okhttp3.*;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.springframework.transaction.support.TransactionSynchronization;
|
||||||
|
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||||
import org.apache.http.HttpHost;
|
import org.apache.http.HttpHost;
|
||||||
import org.apache.http.client.config.RequestConfig;
|
import org.apache.http.client.config.RequestConfig;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
@@ -241,16 +243,12 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
jsonString = JSON.toJSONString(params, SerializerFeature.WriteMapNullValue);
|
jsonString = JSON.toJSONString(params, SerializerFeature.WriteMapNullValue);
|
||||||
break;
|
break;
|
||||||
case "Pattern":
|
case "Pattern":
|
||||||
// 构建object_name: {userId}/{category}/{uuid}.png
|
GenerateToPythonDTO generateToPythonDTO = new GenerateToPythonDTO(generateThroughImageTextDTO.getUniqueId(), text, Objects.isNull(collectionElement) ? "" : collectionElement.getUrl(),
|
||||||
String objectName = generateThroughImageTextDTO.getUserId() + "/" + category + "/" + UUID.randomUUID() + ".png";
|
mode, category, generateThroughImageTextDTO.getGender(), version);
|
||||||
|
jsonString = JSON.toJSONString(generateToPythonDTO, SerializerFeature.WriteMapNullValue);
|
||||||
ImageProcessRequest imageProcessRequest = ImageProcessRequest.builder()
|
|
||||||
.object_name(objectName)
|
|
||||||
.bucket_name(userBucket)
|
|
||||||
.prompt(text).build();
|
|
||||||
jsonString = JSON.toJSONString(imageProcessRequest);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
path = CommonConstant.GENERATE_PATH_FLUX2_KLEIN;
|
||||||
// 构建object_name: {userId}/{category}/{uuid}.png
|
// 构建object_name: {userId}/{category}/{uuid}.png
|
||||||
String objectName = generateThroughImageTextDTO.getUserId() + "/" + category + "/" + UUID.randomUUID() + ".png";
|
String objectName = generateThroughImageTextDTO.getUserId() + "/" + category + "/" + UUID.randomUUID() + ".png";
|
||||||
|
|
||||||
@@ -278,9 +276,16 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
}
|
}
|
||||||
public void saveGenerateImmediately(Generate generate) {
|
public void saveGenerateImmediately(Generate generate) {
|
||||||
save(generate);
|
save(generate);
|
||||||
// 写入完成后设锁,通知 MQ 消费者可以安全读取
|
// 使用 TransactionSynchronizationManager 在事务真正提交后再设锁
|
||||||
String lockKey = "generate:lock:" + generate.getUniqueId();
|
// 否则 save() 完成后事务尚未 commit,MQ 消费者立即读到 null
|
||||||
redisUtil.addToString(lockKey, "1", 60L);
|
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
|
||||||
|
@Override
|
||||||
|
public void afterCommit() {
|
||||||
|
String lockKey = "generate:lock:" + generate.getUniqueId();
|
||||||
|
redisUtil.addToString(lockKey, "1", 60L);
|
||||||
|
log.debug("Save lock set after commit for uniqueId: {}", generate.getUniqueId());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void waitForSaveLock(String uniqueId) {
|
private void waitForSaveLock(String uniqueId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user