BUGFIX: cloud;

This commit is contained in:
shahaibo
2025-06-13 10:55:55 +08:00
parent a750a91f7b
commit 3eaa0d017c

View File

@@ -1919,10 +1919,11 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
prompt = pythonService.promptTranslate(prompt); prompt = pythonService.promptTranslate(prompt);
} }
Map<ToProductImageVO, Integer> toProductImageVOIntegerMap = allocateElements(toProductImageDTO.getToProductImageVOList(), cloudTaskDTO.getNums()); Map<String, Integer> toProductImageVOIntegerMap = allocateElements(toProductImageDTO.getToProductImageVOList(), cloudTaskDTO.getNums());
for (ToProductImageVO toProductImageVO : toProductImageDTO.getToProductImageVOList()) { for (ToProductImageVO toProductImageVO : toProductImageDTO.getToProductImageVOList()) {
String taskId; String taskId;
String key = toProductImageVO.getElementId() + "_" + toProductImageVO.getElementType();
if (toProductImageVO.getElementType().equals("DesignOutfit")) { if (toProductImageVO.getElementType().equals("DesignOutfit")) {
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageVO.getElementId()); TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageVO.getElementId());
@@ -1954,8 +1955,8 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
// 走模型 // 走模型
List<BatchParamDTO> paramList = new ArrayList<>(); List<BatchParamDTO> paramList = new ArrayList<>();
List<String> promptList = pythonService.getPrompt(sb.toString(), toProductImageVOIntegerMap.get(toProductImageVO)); List<String> promptList = pythonService.getPrompt(sb.toString(), toProductImageVOIntegerMap.get(key));
for (int i1 = 0; i1 < toProductImageVOIntegerMap.get(toProductImageVO); i1++) { for (int i1 = 0; i1 < toProductImageVOIntegerMap.get(key); i1++) {
BatchParamDTO batchParamDTO = new BatchParamDTO(); BatchParamDTO batchParamDTO = new BatchParamDTO();
taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId(); taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
batchParamDTO.setTasks_id(taskId); batchParamDTO.setTasks_id(taskId);
@@ -1997,8 +1998,8 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId()); ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
// 走模型 // 走模型
List<BatchParamDTO> paramList = new ArrayList<>(); List<BatchParamDTO> paramList = new ArrayList<>();
List<String> promptList = pythonService.getPrompt(sb.toString(), toProductImageVOIntegerMap.get(toProductImageVO)); List<String> promptList = pythonService.getPrompt(sb.toString(), toProductImageVOIntegerMap.get(key));
for (int i1 = 0; i1 < toProductImageVOIntegerMap.get(toProductImageVO); i1++) { for (int i1 = 0; i1 < toProductImageVOIntegerMap.get(key); i1++) {
BatchParamDTO batchParamDTO = new BatchParamDTO(); BatchParamDTO batchParamDTO = new BatchParamDTO();
taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId(); taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
batchParamDTO.setTasks_id(taskId); batchParamDTO.setTasks_id(taskId);
@@ -2092,9 +2093,10 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
}else { }else {
s = "Snow moutain, snowy day, natural light"; s = "Snow moutain, snowy day, natural light";
} }
Map<ToProductImageVO, Integer> toProductImageVOIntegerMap = allocateElements(toProductImageDTO.getToProductImageVOList(), cloudTaskDTO.getNums()); Map<String, Integer> toProductImageVOIntegerMap = allocateElements(toProductImageDTO.getToProductImageVOList(), cloudTaskDTO.getNums());
for (ToProductImageVO toProductImageVO : toProductImageDTO.getToProductImageVOList()) { for (ToProductImageVO toProductImageVO : toProductImageDTO.getToProductImageVOList()) {
String taskId; String taskId;
String key = toProductImageVO.getElementId() + "_" + toProductImageVO.getElementType();
if (toProductImageVO.getElementType().equals("ToProductImage")) { if (toProductImageVO.getElementType().equals("ToProductImage")) {
ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageVO.getElementId()); ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageVO.getElementId());
String relightType = "overall"; String relightType = "overall";
@@ -2106,8 +2108,8 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
relightType = "single"; relightType = "single";
} }
List<BatchParamDTO> paramList = new ArrayList<>(); List<BatchParamDTO> paramList = new ArrayList<>();
List<String> promptList = pythonService.getPrompt(s, toProductImageVOIntegerMap.get(toProductImageVO)); List<String> promptList = pythonService.getPrompt(s, toProductImageVOIntegerMap.get(key));
for (int i1 = 0; i1 < toProductImageVOIntegerMap.get(toProductImageVO); i1++) { for (int i1 = 0; i1 < toProductImageVOIntegerMap.get(key); i1++) {
BatchParamDTO batchParamDTO = new BatchParamDTO(); BatchParamDTO batchParamDTO = new BatchParamDTO();
taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId(); taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
batchParamDTO.setTasks_id(taskId); batchParamDTO.setTasks_id(taskId);
@@ -2148,8 +2150,8 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId()); ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
// 走模型 // 走模型
List<BatchParamDTO> paramList = new ArrayList<>(); List<BatchParamDTO> paramList = new ArrayList<>();
List<String> promptList = pythonService.getPrompt(s, toProductImageVOIntegerMap.get(toProductImageVO)); List<String> promptList = pythonService.getPrompt(s, toProductImageVOIntegerMap.get(key));
for (int i1 = 0; i1 < toProductImageVOIntegerMap.get(toProductImageVO); i1++) { for (int i1 = 0; i1 < toProductImageVOIntegerMap.get(key); i1++) {
BatchParamDTO batchParamDTO = new BatchParamDTO(); BatchParamDTO batchParamDTO = new BatchParamDTO();
taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId(); taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
batchParamDTO.setTasks_id(taskId); batchParamDTO.setTasks_id(taskId);
@@ -2246,16 +2248,17 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
return null; return null;
} }
public static Map<ToProductImageVO, Integer> allocateElements(List<ToProductImageVO> voList, int totalResults) { public static Map<String, Integer> allocateElements(List<ToProductImageVO> voList, int totalResults) {
// 计算基础分配值和余数 // 计算基础分配值和余数
int baseAllocation = totalResults / voList.size(); int baseAllocation = totalResults / voList.size();
int remainder = totalResults % voList.size(); int remainder = totalResults % voList.size();
// 初始化分配结果(每个元素先分配基础值) // 初始化分配结果(每个元素先分配基础值)
Map<ToProductImageVO, Integer> allocationMap = new HashMap<>(); Map<String, Integer> allocationMap = new HashMap<>();
for (ToProductImageVO vo : voList) { for (ToProductImageVO vo : voList) {
allocationMap.put(vo, baseAllocation); String key = vo.getElementId() + "_" + vo.getElementType();
allocationMap.put(key, baseAllocation);
} }
// 如果有余数,随机分配额外的一个结果 // 如果有余数,随机分配额外的一个结果
@@ -2267,7 +2270,8 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
// 将前N个元素各增加1N=余数) // 将前N个元素各增加1N=余数)
for (int i = 0; i < remainder; i++) { for (int i = 0; i < remainder; i++) {
ToProductImageVO toProductImageVO = shuffledIds.get(i); ToProductImageVO toProductImageVO = shuffledIds.get(i);
allocationMap.put(toProductImageVO, allocationMap.get(toProductImageVO) + 1); String key = toProductImageVO.getElementId() + "_" + toProductImageVO.getElementType();
allocationMap.put(key, allocationMap.get(key) + 1);
} }
} }