Merge branch 'dev/dev_xp' into dev/3.1_release_merge
# Conflicts: # src/main/java/com/ai/da/python/PythonService.java # src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java
This commit is contained in:
@@ -41,4 +41,6 @@ public interface AffiliateService extends IService<Affiliate> {
|
||||
void calcCouponsCommission();
|
||||
|
||||
List<Map<String, Object>> getAllAffiliateUsername();
|
||||
|
||||
void modifyAffiliateStatus(Long affiliateId, String operationType);
|
||||
}
|
||||
|
||||
@@ -25,4 +25,6 @@ public interface DesignItemDetailService extends IService<DesignItemDetail> {
|
||||
void saveDesignItemDetailCanvas(Long designItemDetailId, Long exportFileId);
|
||||
|
||||
DesignItemDetailCanvas getDIDCByDesignItemDetailId(Long designItemDetailId);
|
||||
|
||||
void updateDetailPathById(Long id, String path);
|
||||
}
|
||||
|
||||
@@ -98,4 +98,6 @@ public interface LibraryService extends IService<Library> {
|
||||
PageBaseResponse<Library> getPublicLib(String order, long page, long size);
|
||||
|
||||
PageBaseResponse<Library> getAllSubAccLib(String order, long page, long size);
|
||||
|
||||
String addSysSketchToLibrary(Long clothId, String path);
|
||||
}
|
||||
|
||||
@@ -554,5 +554,23 @@ public class AffiliateServiceImpl extends ServiceImpl<AffiliateMapper, Affiliate
|
||||
coupon.setUnpaidCommission(unpaidCommission);
|
||||
}
|
||||
|
||||
// operationType Active -> 激活 | Inactive -> 关闭 | Delete -> 删除
|
||||
@Override
|
||||
public void modifyAffiliateStatus(Long affiliateId, String operationType) {
|
||||
Affiliate affiliate = baseMapper.selectById(affiliateId);
|
||||
if (Objects.isNull(affiliate)) {
|
||||
throw new BusinessException("unknow.affiliate");
|
||||
}
|
||||
|
||||
if (operationType.equals("Delete")) {
|
||||
affiliate.setIsDeleted(1);
|
||||
} else if (operationType.equals("Active") || operationType.equals("Inactive")) {
|
||||
affiliate.setStatus(operationType);
|
||||
} else {
|
||||
throw new BusinessException("unknown.operationType");
|
||||
}
|
||||
|
||||
updateById(affiliate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -130,4 +131,16 @@ public class DesignItemDetailServiceImpl extends ServiceImpl<DesignItemDetailMap
|
||||
|
||||
return designItemDetailCanvasMapper.selectOne(qw);
|
||||
}
|
||||
|
||||
public void updateDetailPathById(Long id, String path) {
|
||||
if (Objects.nonNull(id)) {
|
||||
DesignItemDetail designItemDetail = baseMapper.selectById(id);
|
||||
if (Objects.nonNull(designItemDetail)) {
|
||||
designItemDetail.setPath(path);
|
||||
designItemDetail.setUpdateDate(new Date());
|
||||
|
||||
baseMapper.updateById(designItemDetail);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1462,6 +1462,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
d.setId(o.getId());
|
||||
d.setPath(minioUtil.getPreSignedUrl(o.getPath(), 24 * 60, true));
|
||||
d.setMinIOPath(o.getPath());
|
||||
d.setScope(o.getPath().startsWith("aida-sys-image") ? "sys" : "user");
|
||||
d.setLevel1Type(converTypeToLevel1(o.getType()));
|
||||
d.setGradient(JSONObject.parseObject(o.getGradientString(), Gradient.class));
|
||||
if (!StringUtil.isNullOrEmpty(o.getUndividedLayer())){
|
||||
|
||||
@@ -2499,17 +2499,23 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
} else {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
taskId = uuid + "-" + accountId;
|
||||
isRequestSuccess = pythonService.poseTransformation(productImage, poseId, taskId);
|
||||
|
||||
com.alibaba.fastjson.JSONObject params = createParamsForMotion(poseTransformDTO, taskId);
|
||||
String api = params.getString("api");
|
||||
params.remove("api");
|
||||
isRequestSuccess = pythonService.poseTransformation(params, api);
|
||||
}
|
||||
|
||||
poseTransformation.setProjectId(projectId);
|
||||
poseTransformation.setAccountId(accountId);
|
||||
poseTransformation.setUniqueId(taskId);
|
||||
poseTransformation.setProductImage(productImage);
|
||||
poseTransformation.setLastFrameProductImage(poseTransformDTO.getLastFrameProductImage());
|
||||
poseTransformation.setPoseId(poseId);
|
||||
poseTransformation.setIsLiked((byte) 0);
|
||||
String taskStatus = isRequestSuccess ? "Executing" : "Fail";
|
||||
poseTransformation.setTaskStatus(taskStatus);
|
||||
poseTransformation.setPrompt(poseTransformDTO.getPrompt());
|
||||
poseTransformation.setCreateTime(LocalDateTime.now());
|
||||
poseTransformationMapper.insert(poseTransformation);
|
||||
// 当需要默认like
|
||||
@@ -2996,7 +3002,8 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
public List<Map<String, String>> getAllPose() {
|
||||
List<Map<String, String>> propertyList = PoseEnum.getPropertyList();
|
||||
propertyList.forEach(item -> {
|
||||
item.put("gif", minioUtil.getPreSignedUrl(item.get("gif"), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
// item.put("gif", minioUtil.getPreSignedUrl(item.get("gif"), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
item.put("video", minioUtil.getPreSignedUrl(item.get("video"), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
item.put("firstFrame", minioUtil.getPreSignedUrl(item.get("firstFrame"), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
});
|
||||
return propertyList;
|
||||
@@ -4083,11 +4090,11 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
// 处理不同状态
|
||||
switch (statusEnum) {
|
||||
case TASK_NOT_FOUND:
|
||||
// 审核没过
|
||||
// 审核没过
|
||||
case REQUEST_MODERATED:
|
||||
// 审核没过
|
||||
// 审核没过
|
||||
case CONTENT_MODERATED:
|
||||
// 出错
|
||||
// 出错
|
||||
case ERROR:
|
||||
return "Fail";
|
||||
case PENDING_F:
|
||||
@@ -4198,6 +4205,34 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
com.alibaba.fastjson.JSONObject createParamsForMotion(PoseTransformDTO poseTransformDTO, String taskId) {
|
||||
|
||||
com.alibaba.fastjson.JSONObject params = new com.alibaba.fastjson.JSONObject();
|
||||
params.put("tasks_id", taskId);
|
||||
// 判断当前使用的哪种生成模式
|
||||
MotionModeEnum motionModeEnum = MotionModeEnum.of(poseTransformDTO.getMode());
|
||||
switch (motionModeEnum){
|
||||
case POSE_TO_VIDEO:
|
||||
params.put("pose_id", poseTransformDTO.getPoseId());
|
||||
params.put("image_url", poseTransformDTO.getProductImage());
|
||||
break;
|
||||
case PROMPT_TO_VIDEO:
|
||||
params.put("image_url", poseTransformDTO.getProductImage());
|
||||
params.put("prompt", poseTransformDTO.getPrompt());
|
||||
break;
|
||||
case FIRST_LAST_FRAME_TO_VIDEO:
|
||||
params.put("start_image_url", poseTransformDTO.getProductImage());
|
||||
params.put("end_image_url", poseTransformDTO.getLastFrameProductImage());
|
||||
params.put("prompt", poseTransformDTO.getPrompt());
|
||||
break;
|
||||
default:
|
||||
throw new BusinessException("unknown.mode");
|
||||
}
|
||||
params.put("api", motionModeEnum.getUrl());
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据豆包错误码和详细信息返回用户友好的错误信息
|
||||
*
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.fileupload.FileItem;
|
||||
@@ -54,6 +55,8 @@ import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.ai.da.common.enums.CollectionLevel2TypeEnum.OUTWEAR;
|
||||
|
||||
/**
|
||||
* 服务实现类
|
||||
*
|
||||
@@ -62,39 +65,25 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> implements LibraryService {
|
||||
@Resource
|
||||
private LibraryMapper libraryMapper;
|
||||
@Resource
|
||||
private SysFileMapper sysFileMapper;
|
||||
@Resource
|
||||
private SysFileExtraMapper sysFileExtraMapper;
|
||||
@Resource
|
||||
private FileProperties fileProperties;
|
||||
@Resource
|
||||
private LibraryModelPointService libraryModelPointService;
|
||||
@Resource
|
||||
private WorkspaceService workspaceService;
|
||||
@Resource
|
||||
private ClassificationService classificationService;
|
||||
@Resource
|
||||
private MinioUtil minioUtil;
|
||||
@Resource
|
||||
private AccountMapper accountMapper;
|
||||
@Resource
|
||||
private EductionLibraryMapper eductionLibraryMapper;
|
||||
@Resource
|
||||
private EnterpriseLibraryMapper enterpriseLibraryMapper;
|
||||
@Resource
|
||||
private LibraryCopyMapper libraryCopyMapper;
|
||||
@Resource
|
||||
private LibraryModelPointCopyMapper libraryModelPointCopyMapper;
|
||||
@Resource
|
||||
private PythonTAllInfoService pythonTAllInfoService;
|
||||
@Resource
|
||||
private BrandRelLibraryMapper brandRelLibraryMapper;
|
||||
@Resource
|
||||
private GenerateDetailMapper generateDetailMapper;
|
||||
private final AccountMapper accountMapper;
|
||||
private final BrandRelLibraryMapper brandRelLibraryMapper;
|
||||
private final ClassificationService classificationService;
|
||||
private final DesignItemDetailService designItemDetailService;
|
||||
private final EductionLibraryMapper eductionLibraryMapper;
|
||||
private final EnterpriseLibraryMapper enterpriseLibraryMapper;
|
||||
private final FileProperties fileProperties;
|
||||
private final GenerateDetailMapper generateDetailMapper;
|
||||
private final MinioUtil minioUtil;
|
||||
private final LibraryMapper libraryMapper;
|
||||
private final LibraryCopyMapper libraryCopyMapper;
|
||||
private final LibraryModelPointMapper libraryModelPointMapper;
|
||||
private final LibraryModelPointCopyMapper libraryModelPointCopyMapper;
|
||||
private final PythonTAllInfoService pythonTAllInfoService;
|
||||
private final SysFileMapper sysFileMapper;
|
||||
private final SysFileExtraMapper sysFileExtraMapper;
|
||||
private final WorkspaceService workspaceService;
|
||||
|
||||
@Value("${minio.bucketName.users}")
|
||||
private String users;
|
||||
@@ -110,7 +99,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
private String fastApiPythonAddress;
|
||||
|
||||
private static List<String> top = Arrays.asList(CollectionLevel2TypeEnum.DRESS.getRealName(),
|
||||
CollectionLevel2TypeEnum.OUTWEAR.getRealName(), CollectionLevel2TypeEnum.BLOUSE.getRealName());
|
||||
OUTWEAR.getRealName(), CollectionLevel2TypeEnum.BLOUSE.getRealName());
|
||||
private static List<String> bottom = Arrays.asList(CollectionLevel2TypeEnum.SKIRT.getRealName(),
|
||||
CollectionLevel2TypeEnum.TROUSERS.getRealName());
|
||||
|
||||
@@ -233,7 +222,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
.filter(library -> library.getLevel1Type().equals(LibraryLevel1TypeEnum.MODELS.getRealName()))
|
||||
.map(Library::getId)
|
||||
.collect(Collectors.toList());
|
||||
List<LibraryModelPointVO> libraryModelPointVOS = libraryModelPointService.selectByLibraryIds(libraryIds);
|
||||
List<LibraryModelPointVO> libraryModelPointVOS = selectByLibraryIds(libraryIds);
|
||||
if (!CollectionUtils.isEmpty(libraryModelPointVOS)) {
|
||||
map = libraryModelPointVOS.stream()
|
||||
.collect(Collectors.toMap(LibraryModelPointVO::getRelationId, v -> v));
|
||||
@@ -307,6 +296,25 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
return PageBaseResponse.success(pageResult);
|
||||
}
|
||||
|
||||
public List<LibraryModelPointVO> selectByLibraryIds(List<Long> libraryIds) {
|
||||
QueryWrapper<LibraryModelPoint> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(LibraryModelPoint::getModelType, ModelType.LIBRARY.getValue());
|
||||
queryWrapper.in("relation_id", libraryIds);
|
||||
List<LibraryModelPoint> libraryModelPoints = libraryModelPointMapper.selectList(queryWrapper);
|
||||
if (CollectionUtils.isEmpty(libraryModelPoints)) {
|
||||
return null;
|
||||
}
|
||||
return CopyUtil.copyList(libraryModelPoints, LibraryModelPointVO.class, (o, d) -> {
|
||||
d.setTemplateId(o.getId());
|
||||
d.setHandLeft(JSON.parseObject(o.getHandLeft(), List.class));
|
||||
d.setHandRight(JSON.parseObject(o.getHandRight(), List.class));
|
||||
d.setShoulderRight(JSON.parseObject(o.getShoulderRight(), List.class));
|
||||
d.setShoulderLeft(JSON.parseObject(o.getShoulderLeft(), List.class));
|
||||
d.setWaistbandRight(JSON.parseObject(o.getWaistbandRight(), List.class));
|
||||
d.setWaistbandLeft(JSON.parseObject(o.getWaistbandLeft(), List.class));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public LibraryUpdateVo upload(LibraryUploadDTO libraryUploadDTO) {
|
||||
//用户信息
|
||||
@@ -659,7 +667,8 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
|
||||
libraryModelPoint.setRelationId(newInsert.getId());
|
||||
libraryModelPoint.setId(null);
|
||||
libraryModelPointService.saveOrUpdate(libraryModelPoint);
|
||||
// libraryModelPointService.saveOrUpdate(libraryModelPoint);
|
||||
libraryModelPointMapper.insert(libraryModelPoint);
|
||||
continue;
|
||||
}
|
||||
if (libraryCopy.getLevel1Type().equals("Sketchboard")) {
|
||||
@@ -913,12 +922,12 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
libraryMapper.insert(library);
|
||||
|
||||
// 添加点位信息到library
|
||||
LibraryModelPoint sysModelPoint = libraryModelPointService.getByRelationId(sysModelId, "System");
|
||||
LibraryModelPoint sysModelPoint = getByRelationId(sysModelId, "System");
|
||||
sysModelPoint.setId(null);
|
||||
sysModelPoint.setModelType("Library");
|
||||
sysModelPoint.setRelationId(library.getId());
|
||||
sysModelPoint.setCreateDate(new Date());
|
||||
libraryModelPointService.save(sysModelPoint);
|
||||
libraryModelPointMapper.insert(sysModelPoint);
|
||||
|
||||
Map<String, String> resp = new HashMap<>();
|
||||
resp.put("id", library.getId().toString());
|
||||
@@ -926,6 +935,19 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
return resp;
|
||||
}
|
||||
|
||||
public LibraryModelPoint getByRelationId(Long relationId, String modelType) {
|
||||
QueryWrapper<LibraryModelPoint> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(LibraryModelPoint::getRelationId, relationId)
|
||||
.eq(LibraryModelPoint::getModelType, modelType)
|
||||
.last("limit 1");
|
||||
List<LibraryModelPoint> libraryModelPoints = libraryModelPointMapper.selectList(queryWrapper);
|
||||
if (CollectionUtil.isEmpty(libraryModelPoints)) {
|
||||
throw new BusinessException("modelPoint.not.found");
|
||||
}
|
||||
return libraryModelPoints.get(0);
|
||||
}
|
||||
|
||||
|
||||
public boolean saveToOrganizationLibrary(Long libraryId){
|
||||
// 1、判断该用户是否属于某个组织
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
@@ -1030,4 +1052,53 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将系统sketch添加到个人library
|
||||
*/
|
||||
public String addSysSketchToLibrary(Long clothId, String path) {
|
||||
// 1. 判断当前路径是不是系统sketch
|
||||
if (!path.startsWith("aida-sys-image/images")) {
|
||||
throw new BusinessException("Non-system Sketch file cannot be added to personal library.", ResultEnum.PROMPT.getCode());
|
||||
}
|
||||
|
||||
// 2. 是。获取当前用户id,随机生成4位数
|
||||
String sourceObject = path.substring(path.indexOf("/") + 1);
|
||||
String subPath = sourceObject.substring(sourceObject.indexOf("images/") + 1, sourceObject.lastIndexOf("."));
|
||||
String gender = subPath.substring(0, subPath.indexOf("/")).equals("female") ? "female" : "male";
|
||||
String category = subPath.substring(subPath.indexOf("/") + 1, subPath.lastIndexOf("/"));
|
||||
CollectionLevel2TypeEnum collectionLevel2TypeEnum = CollectionLevel2TypeEnum.ofWithLoweCase(category);
|
||||
if (Objects.nonNull(collectionLevel2TypeEnum)){
|
||||
category = collectionLevel2TypeEnum.getRealName();
|
||||
} else {
|
||||
category = OUTWEAR.getRealName();
|
||||
}
|
||||
String suffix = sourceObject.substring(sourceObject.lastIndexOf(".") + 1);
|
||||
Long userId = UserContext.getUserHolder().getId();
|
||||
String name = subPath.substring(subPath.lastIndexOf("/") + 1) + "_" + RandomsUtil.generateVerifyCode(1000L, 9999L);
|
||||
String targetObject = userId + "/sketchboard/" + gender + "/" + category + "/" +
|
||||
name + "." + suffix;
|
||||
|
||||
// 3. 复制图片到用户个人图片文件夹下
|
||||
minioUtil.copyObject(sysImage, sourceObject, users, targetObject);
|
||||
|
||||
// 4. 存储到数据库中
|
||||
String targetPath = users + "/" + targetObject;
|
||||
String md5 = MD5Utils.encryptFile(minioUtil.getPreSignedUrl(targetPath, CommonConstant.MINIO_IMAGE_EXPIRE_TIME), false);
|
||||
Library library = new Library(userId, CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName(),
|
||||
category, gender, "Adult", name, targetPath, md5, new Date());
|
||||
saveOne(library);
|
||||
|
||||
// 5. 更新designItemDetail中的图片路径
|
||||
if (Objects.nonNull(clothId)) {
|
||||
designItemDetailService.updateDetailPathById(clothId, targetPath);
|
||||
}
|
||||
return minioUtil.getPreSignedUrl(targetPath, CommonConstant.MINIO_IMAGE_EXPIRE_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* todo 低分辨率下载
|
||||
*/
|
||||
public void downloadSysSketchWithWatermark() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user