1.fix:高级工具转产品图不需要也没有ageGroup,会导致报错
2.上传sketch模板代码
This commit is contained in:
@@ -118,11 +118,11 @@ public class WorkspaceController {
|
|||||||
return Response.success(true);
|
return Response.success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("maleDataInsert")
|
@GetMapping("/maleDataInsert")
|
||||||
@ApiOperationSupport(order = 8)
|
@ApiOperationSupport(order = 8)
|
||||||
@ApiOperation(value = "男装数据入库入minio")
|
@ApiOperation(value = "男装数据入库入minio")
|
||||||
public Response<Boolean> maleDataInsert() throws FileNotFoundException {
|
public Response<Boolean> maleDataInsert() throws FileNotFoundException {
|
||||||
workspaceService.maleDataInsert();
|
// workspaceService.maleDataInsert();
|
||||||
return Response.success(true);
|
return Response.success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,4 +34,6 @@ public interface AttributeRetrievalMapper {
|
|||||||
Integer getCountByStyle(String tableName, String style);
|
Integer getCountByStyle(String tableName, String style);
|
||||||
|
|
||||||
String getOneSystemSketchRadom(String tableName, String style, Integer randomNum);
|
String getOneSystemSketchRadom(String tableName, String style, Integer randomNum);
|
||||||
|
|
||||||
|
void insertSketch(AttributeRetrieval attributeRetrievalAttrDict, String tableName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3360,7 +3360,11 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
}
|
}
|
||||||
private String buildAdvancedPrompt(Long projectId, String prompt) {
|
private String buildAdvancedPrompt(Long projectId, String prompt) {
|
||||||
String process = projectService.getById(projectId).getProcess();
|
String process = projectService.getById(projectId).getProcess();
|
||||||
String ageGroup = workspaceService.getWSByProjectId(projectId).getAgeGroup();
|
String ageGroup = null;
|
||||||
|
if (!"TO_PRODUCT_IMAGE".equals(process)) {
|
||||||
|
//高级工具转产品图不需要这个字段
|
||||||
|
ageGroup = workspaceService.getWSByProjectId(projectId).getAgeGroup();
|
||||||
|
}
|
||||||
String suffixCommon = "Pay attention to the size of the garment, the print, and the fabric texture, real photo, 8K, HDR, DOF, soft lighting, high detail, high quality, Do not return the original image.";
|
String suffixCommon = "Pay attention to the size of the garment, the print, and the fabric texture, real photo, 8K, HDR, DOF, soft lighting, high detail, high quality, Do not return the original image.";
|
||||||
String suffixModelAdult = "Transform this image into a real model standing,"+suffixCommon;
|
String suffixModelAdult = "Transform this image into a real model standing,"+suffixCommon;
|
||||||
String suffixModelChild = "Transform this image into a real child model standing,"+suffixCommon;
|
String suffixModelChild = "Transform this image into a real child model standing,"+suffixCommon;
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import com.ai.da.common.response.ResultEnum;
|
|||||||
import com.ai.da.common.utils.*;
|
import com.ai.da.common.utils.*;
|
||||||
import com.ai.da.mapper.primary.*;
|
import com.ai.da.mapper.primary.*;
|
||||||
import com.ai.da.mapper.primary.entity.*;
|
import com.ai.da.mapper.primary.entity.*;
|
||||||
|
import com.ai.da.mapper.secondary.AttributeRetrievalMapper;
|
||||||
|
import com.ai.da.mapper.secondary.entity.AttributeRetrieval;
|
||||||
import com.ai.da.model.dto.ProjectDTO;
|
import com.ai.da.model.dto.ProjectDTO;
|
||||||
import com.ai.da.model.dto.WorkspaceDTO;
|
import com.ai.da.model.dto.WorkspaceDTO;
|
||||||
import com.ai.da.model.dto.WorkspaceSaveDTO;
|
import com.ai.da.model.dto.WorkspaceSaveDTO;
|
||||||
@@ -26,6 +28,7 @@ import io.netty.util.internal.StringUtil;
|
|||||||
import org.apache.commons.fileupload.FileItem;
|
import org.apache.commons.fileupload.FileItem;
|
||||||
import org.apache.commons.fileupload.FileItemFactory;
|
import org.apache.commons.fileupload.FileItemFactory;
|
||||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -37,6 +40,7 @@ import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -610,10 +614,138 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//上传衣服
|
@Autowired
|
||||||
|
private AttributeRetrievalMapper attributeRetrievalMapper;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public void maleDataInsert() throws FileNotFoundException {
|
public void maleDataInsert() throws FileNotFoundException {
|
||||||
String directoryPath = "C:\\workspace\\fileData\\aida_men_library";
|
String directoryPath = "C:\\Users\\39093\\Desktop\\generated_sketch_gemini_updated_regendered\\unisex\\Post_apocalyptic";
|
||||||
|
List<File> pngFiles = getPNGFiles(directoryPath);
|
||||||
|
for (File pngFile : pngFiles) {
|
||||||
|
String category = Paths.get(directoryPath).getFileName().toString();
|
||||||
|
String fileName = category + "_2_" + pngFile.getName();
|
||||||
|
String tableName = null;
|
||||||
|
SysFile sysFile = new SysFile();
|
||||||
|
sysFile.setName(fileName);
|
||||||
|
sysFile.setLevel1Type("Images");
|
||||||
|
|
||||||
|
AttributeRetrieval attributeRetrievalAttrDict = new AttributeRetrieval();
|
||||||
|
|
||||||
|
attributeRetrievalAttrDict.setStyle("POST_APOCALYPTIC");
|
||||||
|
String absolutePath = pngFile.getAbsolutePath();
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("aida-sys-image/images");
|
||||||
|
if (absolutePath.contains("Coat_Jacket") || absolutePath.contains("coat_jacket")) {
|
||||||
|
if (absolutePath.contains("\\male")) {
|
||||||
|
tableName = "male_outwear";
|
||||||
|
sb.append("/male/outwear/");
|
||||||
|
sysFile.setLevel3Type("Male");
|
||||||
|
} else if (absolutePath.contains("\\female")) {
|
||||||
|
tableName = "female_outwear";
|
||||||
|
sb.append("/female/outwear/");
|
||||||
|
sysFile.setLevel3Type("Female");
|
||||||
|
} else if (absolutePath.contains("\\unisex")) {
|
||||||
|
tableName = "female_outwear";
|
||||||
|
sb.append("/female/outwear/");
|
||||||
|
sysFile.setLevel3Type("Female");
|
||||||
|
}
|
||||||
|
sysFile.setLevel2Type("Outwear");
|
||||||
|
attributeRetrievalAttrDict.setImgName("outwear/" + fileName);
|
||||||
|
}
|
||||||
|
if (absolutePath.contains("Pants") || absolutePath.contains("pants")) {
|
||||||
|
if (absolutePath.contains("\\male")) {
|
||||||
|
tableName = "male_bottoms";
|
||||||
|
sb.append("/male/bottoms/");
|
||||||
|
sysFile.setLevel3Type("Male");
|
||||||
|
} else if (absolutePath.contains("\\female")) {
|
||||||
|
tableName = "female_trousers";
|
||||||
|
sb.append("/female/trousers/");
|
||||||
|
sysFile.setLevel3Type("Female");
|
||||||
|
} else if (absolutePath.contains("\\unisex")) {
|
||||||
|
tableName = "female_trousers";
|
||||||
|
sb.append("/female/trousers/");
|
||||||
|
sysFile.setLevel3Type("Female");
|
||||||
|
}
|
||||||
|
sysFile.setLevel2Type("Trousers");
|
||||||
|
attributeRetrievalAttrDict.setImgName("trousers/" + fileName);
|
||||||
|
}
|
||||||
|
if (absolutePath.contains("Top_Shirt") || absolutePath.contains("top_shirt")) {
|
||||||
|
if (absolutePath.contains("\\male")) {
|
||||||
|
tableName = "male_tops";
|
||||||
|
sb.append("/male/tops/");
|
||||||
|
sysFile.setLevel3Type("Male");
|
||||||
|
} else if (absolutePath.contains("\\female")) {
|
||||||
|
tableName = "female_blouse";
|
||||||
|
sb.append("/female/blouse/");
|
||||||
|
sysFile.setLevel3Type("Female");
|
||||||
|
} else if (absolutePath.contains("\\unisex")) {
|
||||||
|
tableName = "female_blouse";
|
||||||
|
sb.append("/female/blouse/");
|
||||||
|
sysFile.setLevel3Type("Female");
|
||||||
|
}
|
||||||
|
sysFile.setLevel2Type("Blouse");
|
||||||
|
attributeRetrievalAttrDict.setImgName("blouse/" + fileName);
|
||||||
|
}
|
||||||
|
if (absolutePath.contains("Dress") || absolutePath.contains("dress")) {
|
||||||
|
tableName = "female_dress";
|
||||||
|
sb.append("/female/dress/");
|
||||||
|
sysFile.setLevel2Type("Dress");
|
||||||
|
sysFile.setLevel3Type("Female");
|
||||||
|
attributeRetrievalAttrDict.setImgName("dress/" + fileName);
|
||||||
|
}
|
||||||
|
if (absolutePath.contains("skirt") || absolutePath.contains("Skirt")) {
|
||||||
|
tableName = "female_skirt";
|
||||||
|
sb.append("/female/skirt/");
|
||||||
|
sysFile.setLevel2Type("Skirt");
|
||||||
|
sysFile.setLevel3Type("Female");
|
||||||
|
attributeRetrievalAttrDict.setImgName("skirt/" + fileName);
|
||||||
|
}
|
||||||
|
sb.append(fileName);
|
||||||
|
String url = sb.toString();
|
||||||
|
sysFile.setUrl(url);
|
||||||
|
sysFile.setMd5(MD5Utils.encryptFile(new FileInputStream(pngFile)));
|
||||||
|
attributeRetrievalMapper.insertSketch(attributeRetrievalAttrDict, tableName);
|
||||||
|
sysFile.setCreateDate(new Date());
|
||||||
|
sysFile.setId(null);
|
||||||
|
sysFileMapper.insert(sysFile);
|
||||||
|
FileItem a = getMultipartFile(pngFile, fileName);
|
||||||
|
MultipartFile multipartFile = new CommonsMultipartFile(a);
|
||||||
|
minioUtil.upload(url.substring(0, 14), url.substring(15), multipartFile, "");
|
||||||
|
System.out.println("上传成功url:" + url);
|
||||||
|
if (absolutePath.contains("unisex")) {
|
||||||
|
if (tableName.equals("female_outwear")) {
|
||||||
|
tableName = "male_outwear";
|
||||||
|
url = url.replace("/female/outwear/", "/male/outwear/");
|
||||||
|
} else if (tableName.equals("female_blouse")) {
|
||||||
|
tableName = "male_tops";
|
||||||
|
attributeRetrievalAttrDict.setImgName("tops/" + fileName);
|
||||||
|
sysFile.setLevel2Type("Tops");
|
||||||
|
url = url.replace("/female/blouse/", "/male/tops/");
|
||||||
|
} else if (tableName.equals("female_trousers")) {
|
||||||
|
tableName = "male_bottoms";
|
||||||
|
attributeRetrievalAttrDict.setImgName("bottoms/" + fileName);
|
||||||
|
sysFile.setLevel2Type("Bottoms");
|
||||||
|
url = url.replace("/female/trousers/", "/male/bottoms/");
|
||||||
|
}
|
||||||
|
minioUtil.upload(url.substring(0, 14), url.substring(15), multipartFile, "");
|
||||||
|
sysFile.setLevel3Type("Male");
|
||||||
|
sysFile.setId(null);
|
||||||
|
sysFile.setUrl(url);
|
||||||
|
sysFileMapper.insert(sysFile);
|
||||||
|
attributeRetrievalMapper.insertSketch(attributeRetrievalAttrDict, tableName);
|
||||||
|
System.out.println("上传成功url:" + url);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
System.out.println("结束");
|
||||||
|
}
|
||||||
|
|
||||||
|
//上传衣服
|
||||||
|
|
||||||
|
public void maleDataInsert1() throws FileNotFoundException {
|
||||||
|
String directoryPath = "C:\\Users\\39093\\Desktop\\generated_sketch_gemini_updated_regendered";
|
||||||
List<File> pngFiles = getPNGFiles(directoryPath);
|
List<File> pngFiles = getPNGFiles(directoryPath);
|
||||||
for (File pngFile : pngFiles) {
|
for (File pngFile : pngFiles) {
|
||||||
SysFile sysFile = new SysFile();
|
SysFile sysFile = new SysFile();
|
||||||
@@ -732,7 +864,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
|||||||
LambdaQueryWrapper<CollectionElement> queryWrapper = new LambdaQueryWrapper<CollectionElement>().eq(CollectionElement::getProjectId, projectId)
|
LambdaQueryWrapper<CollectionElement> queryWrapper = new LambdaQueryWrapper<CollectionElement>().eq(CollectionElement::getProjectId, projectId)
|
||||||
.eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MODEL.getRealName())
|
.eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MODEL.getRealName())
|
||||||
.eq(CollectionElement::getLevel3Type, workspaceNew.getSex());
|
.eq(CollectionElement::getLevel3Type, workspaceNew.getSex());
|
||||||
if (collectionElementMapper.selectCount(queryWrapper) == 0){
|
if (collectionElementMapper.selectCount(queryWrapper) == 0) {
|
||||||
CollectionElement collectionElement = new CollectionElement();
|
CollectionElement collectionElement = new CollectionElement();
|
||||||
collectionElement.setAccountId(userInfo.getId());
|
collectionElement.setAccountId(userInfo.getId());
|
||||||
collectionElement.setProjectId(projectId);
|
collectionElement.setProjectId(projectId);
|
||||||
@@ -793,7 +925,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
|||||||
Project project = CopyUtil.copyObject(projectDTO, Project.class);
|
Project project = CopyUtil.copyObject(projectDTO, Project.class);
|
||||||
project.setAccountId(userInfo.getId());
|
project.setAccountId(userInfo.getId());
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
if (StringUtil.isNullOrEmpty(project.getName())){
|
if (StringUtil.isNullOrEmpty(project.getName())) {
|
||||||
Long seq = redisUtil.increaseCount(UNNAMED_PROJECT_SEQ + userInfo.getId());
|
Long seq = redisUtil.increaseCount(UNNAMED_PROJECT_SEQ + userInfo.getId());
|
||||||
project.setName("Untitled_" + seq);
|
project.setName("Untitled_" + seq);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,10 @@
|
|||||||
<result column="opening_type" property="openingType" />
|
<result column="opening_type" property="openingType" />
|
||||||
<result column="subtype" property="subtype" />
|
<result column="subtype" property="subtype" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
<insert id="insertSketch">
|
||||||
|
INSERT INTO ${tableName} (img_name, style)
|
||||||
|
VALUES (#{attributeRetrievalAttrDict.imgName}, #{attributeRetrievalAttrDict.style})
|
||||||
|
</insert>
|
||||||
|
|
||||||
<select id="getSystemSketchPool" resultMap="BaseResultMap">
|
<select id="getSystemSketchPool" resultMap="BaseResultMap">
|
||||||
SELECT
|
SELECT
|
||||||
|
|||||||
Reference in New Issue
Block a user