TASK:workspace、design模块代码;

This commit is contained in:
shahaibo
2023-09-21 11:35:58 +08:00
parent 49b62d3733
commit 1870996244
6 changed files with 55 additions and 21 deletions

View File

@@ -76,11 +76,11 @@ public class WorkspaceController {
/** /**
* 删除 * 删除
*/ */
@PostMapping("/remove") @DeleteMapping("/remove")
@ApiOperationSupport(order = 4) @ApiOperationSupport(order = 4)
@ApiOperation(value = "删除", notes = "传入id") @ApiOperation(value = "删除", notes = "传入id")
public Response remove(@ApiParam(value = "主键集合", required = true) @RequestParam Long id) { public Response remove(@Valid @RequestBody List<Workspace> workspaceList) {
return Response.success(workspaceService.removeById(id)); return Response.success(workspaceService.removeBatchByIds(workspaceList));
} }
@GetMapping("/enumValues") @GetMapping("/enumValues")

View File

@@ -432,7 +432,7 @@ public class PythonService {
pythonItem.setBody_path(designLibraryModelPoint.getTemplateUrl()); pythonItem.setBody_path(designLibraryModelPoint.getTemplateUrl());
} else { } else {
// pythonItem.setBody_path("/workspace/python_code/Multi-layer-Virtual-Try-on/dataset_for_test/Img_model.png"); // pythonItem.setBody_path("/workspace/python_code/Multi-layer-Virtual-Try-on/dataset_for_test/Img_model.png");
pythonItem.setBody_path("aida-mannequins/model_1693218345.2714431.png"); pythonItem.setBody_path("aida-mannequins/model_1693218345.2714432.png");
} }
} else { } else {
SysFileVO sysFileVO = getRandomSysFileByLevel2Type(type, Lists.newArrayList()); SysFileVO sysFileVO = getRandomSysFileByLevel2Type(type, Lists.newArrayList());
@@ -1354,7 +1354,7 @@ public class PythonService {
bodyPath = designLibraryModelPoint.getTemplateUrl(); bodyPath = designLibraryModelPoint.getTemplateUrl();
} else { } else {
// bodyPath = "/workspace/python_code/Multi-layer-Virtual-Try-on/dataset_for_test/Img_model.png"; // bodyPath = "/workspace/python_code/Multi-layer-Virtual-Try-on/dataset_for_test/Img_model.png";
bodyPath = "aida-mannequins/model_1693218345.2714431.png"; bodyPath = "aida-mannequins/model_1693218345.2714432.png";
} }
response.add(new DesignPythonItem(SysFileLevel2TypeEnum.BODY.getRealName(),bodyPath,pythonTAllInfoService.getImageIdByPath(bodyPath))); response.add(new DesignPythonItem(SysFileLevel2TypeEnum.BODY.getRealName(),bodyPath,pythonTAllInfoService.getImageIdByPath(bodyPath)));
return response; return response;

View File

@@ -109,6 +109,7 @@ public interface CollectionElementService extends IService<CollectionElement> {
List<CollectionElement> getByOnlyCollectionId(Long collectionId); List<CollectionElement> getByOnlyCollectionId(Long collectionId);
DesignLibraryModelPointVO calculateTemplatePoint(LibraryModelPoint modelPoint, Integer high, Integer width, String templateUrl); DesignLibraryModelPointVO calculateTemplatePoint(LibraryModelPoint modelPoint, Integer high, Integer width, String templateUrl);
DesignLibraryModelPointVO calculateTemplatePointTemplate(LibraryModelPoint modelPoint, Integer high, Integer width, String templateUrl);
/** /**
* 刷新历史数据 * 刷新历史数据

View File

@@ -415,13 +415,14 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
Assert.notNull(switchCategory, "unknown parameter switchCategory!"); Assert.notNull(switchCategory, "unknown parameter switchCategory!");
} }
//校验template //校验template
if(Objects.nonNull(designDTO.getTemplateId())){ // if(Objects.nonNull(designDTO.getTemplateId())){
LibraryModelPoint modelPoint = libraryModelPointService.getById(designDTO.getTemplateId()); // LibraryModelPoint modelPoint = libraryModelPointService.getById(designDTO.getTemplateId());
Assert.notNull(modelPoint, "template cannot by empty!"); // Assert.notNull(modelPoint, "template cannot by empty!");
Library library = libraryService.getById(modelPoint.getLibraryId()); // Library library = libraryService.getById(modelPoint.getLibraryId());
Assert.notNull(library, "template library cannot by empty!"); // Assert.notNull(library, "template library cannot by empty!");
elementVO.setDesignLibraryModelPoint(calculateTemplatePoint(modelPoint,library.getHigh(),library.getWidth(),library.getUrl())); // elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint,library.getHigh(),library.getWidth(),library.getUrl()));
} // }
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(null,null,null,null));
return elementVO; return elementVO;
} }
@Override @Override
@@ -436,6 +437,27 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
libraryModelPoint.setTemplateUrl(templateUrl); libraryModelPoint.setTemplateUrl(templateUrl);
return libraryModelPoint; return libraryModelPoint;
} }
@Override
public DesignLibraryModelPointVO calculateTemplatePointTemplate(LibraryModelPoint modelPoint, Integer high, Integer width,String templateUrl){
DesignLibraryModelPointVO libraryModelPoint = new DesignLibraryModelPointVO();
LibraryModelPoint template = libraryModelPointService.getById(96L);
libraryModelPoint.setHandLeft(calculateTemplatePointOne(template.getHandLeft(),752,564));
libraryModelPoint.setHandRight(calculateTemplatePointOne(template.getHandRight(),752,564));
libraryModelPoint.setShoulderLeft(calculateTemplatePointOne(template.getShoulderLeft(),752,564));
libraryModelPoint.setShoulderRight(calculateTemplatePointOne(template.getShoulderRight(),752,564));
libraryModelPoint.setWaistbandLeft(calculateTemplatePointOne(template.getWaistbandLeft(),752,564));
libraryModelPoint.setWaistbandRight(calculateTemplatePointOne(template.getWaistbandRight(),752,564));
libraryModelPoint.setTemplateUrl("aida-mannequins/model_1693218345.2714432.png");
// libraryModelPoint.setHandLeft(calculateTemplatePointOne(modelPoint.getHandLeft(),high,width));
// libraryModelPoint.setHandRight(calculateTemplatePointOne(modelPoint.getHandRight(),high,width));
// libraryModelPoint.setShoulderLeft(calculateTemplatePointOne(modelPoint.getShoulderLeft(),high,width));
// libraryModelPoint.setShoulderRight(calculateTemplatePointOne(modelPoint.getShoulderRight(),high,width));
// libraryModelPoint.setWaistbandLeft(calculateTemplatePointOne(modelPoint.getWaistbandLeft(),high,width));
// libraryModelPoint.setWaistbandRight(calculateTemplatePointOne(modelPoint.getWaistbandRight(),high,width));
// libraryModelPoint.setTemplateUrl(templateUrl);
return libraryModelPoint;
}
private List<BigDecimal> calculateTemplatePointOne(String template,Integer high,Integer width){ private List<BigDecimal> calculateTemplatePointOne(String template,Integer high,Integer width){
List<BigDecimal> originRatioList = JSON.parseObject(template,List.class); List<BigDecimal> originRatioList = JSON.parseObject(template,List.class);
originRatioList.set(0,originRatioList.get(0).multiply(BigDecimal.valueOf(width))); originRatioList.set(0,originRatioList.get(0).multiply(BigDecimal.valueOf(width)));

View File

@@ -438,6 +438,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
designPythonOutfit.setUserId(userInfo.getId()); designPythonOutfit.setUserId(userInfo.getId());
designPythonOutfit.setDesignId(designId); designPythonOutfit.setDesignId(designId);
designPythonOutfit.setCollectionId(collectionId); designPythonOutfit.setCollectionId(collectionId);
designPythonOutfit.setDesignUrl(outfit.getString("synthesis_url")); designPythonOutfit.setDesignUrl(outfit.getString("synthesis_url"));
designPythonOutfitService.save(designPythonOutfit); designPythonOutfitService.save(designPythonOutfit);
JSONArray layers = outfit.getJSONArray("layers"); JSONArray layers = outfit.getJSONArray("layers");

View File

@@ -58,13 +58,20 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
public IPage<WorkspaceVO> selectWorkspacePage(IPage<WorkspaceVO> page, WorkspaceVO workspace) { public IPage<WorkspaceVO> selectWorkspacePage(IPage<WorkspaceVO> page, WorkspaceVO workspace) {
return page.setRecords(baseMapper.selectWorkspacePage(page, workspace)); return page.setRecords(baseMapper.selectWorkspacePage(page, workspace));
} }
private final static String WORKSPACE_NAME = "默认workspace名称";
private final static Integer SYSTEM_DESIGNER_PERCENTAGE = 30;
@Override @Override
public boolean saveOrUpdate(Workspace workspace) { public boolean saveOrUpdate(Workspace workspace) {
AuthPrincipalVo userInfo = UserContext.getUserHolder(); AuthPrincipalVo userInfo = UserContext.getUserHolder();
workspace.setUserName(userInfo.getUsername()); workspace.setUserName(userInfo.getUsername());
workspace.setIsLastIndex(0);
if (null == workspace.getId()) { if (null == workspace.getId()) {
workspace.setIsLastIndex(0);
workspace.setMannequinUrl("aida-mannequins/model_1693218345.2714432.png");
workspace.setMannequinType(MannequinType.SYSTEM.getValue());
workspace.setSex(Sex.MALE.getValue());
workspace.setPosition(Position.OVERALL.getValue());
workspace.setSystemDesignerPercentage(SYSTEM_DESIGNER_PERCENTAGE);
int insert = workspaceMapper.insert(workspace); int insert = workspaceMapper.insert(workspace);
if (insert <= 0) { if (insert <= 0) {
throw new BusinessException("insert workspace failed"); throw new BusinessException("insert workspace failed");
@@ -79,9 +86,6 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
} }
} }
private final static String WORKSPACE_NAME = "默认workspace名称";
private final static Integer SYSTEM_DESIGNER_PERCENTAGE = 30;
@Override @Override
public WorkspaceVO getPage(WorkspaceDTO query) { public WorkspaceVO getPage(WorkspaceDTO query) {
WorkspaceVO vo = new WorkspaceVO(); WorkspaceVO vo = new WorkspaceVO();
@@ -98,7 +102,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
workspace.setPosition(Position.OVERALL.getValue()); workspace.setPosition(Position.OVERALL.getValue());
workspace.setUserName(userName); workspace.setUserName(userName);
workspace.setMannequinId(null); workspace.setMannequinId(null);
workspace.setMannequinUrl("aida-mannequins/model_1693218345.2714431.png"); workspace.setMannequinUrl("aida-mannequins/model_1693218345.2714432.png");
workspace.setMannequinType(MannequinType.SYSTEM.getValue()); workspace.setMannequinType(MannequinType.SYSTEM.getValue());
workspace.setIsLastIndex(1); workspace.setIsLastIndex(1);
int insert = workspaceMapper.insert(workspace); int insert = workspaceMapper.insert(workspace);
@@ -107,14 +111,20 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
} }
page = workspaceMapper.selectPage(new Page<>(query.getPage(), query.getSize()), qw); page = workspaceMapper.selectPage(new Page<>(query.getPage(), query.getSize()), qw);
page.getRecords().forEach(o -> { page.getRecords().forEach(o -> {
o.setMannequinUrl(minioUtil.getPresignedUrl(o.getMannequinUrl(), 10)); String url = o.getMannequinUrl();
if (url.startsWith("aida-")) {
o.setMannequinUrl(minioUtil.getPresignedUrl(o.getMannequinUrl(), 10));
}
}); });
vo.setPage(PageBaseResponse.success(page)); vo.setPage(PageBaseResponse.success(page));
vo.setId(workspace.getId()); vo.setId(workspace.getId());
return vo; return vo;
} }
page.getRecords().forEach(o -> { page.getRecords().forEach(o -> {
o.setMannequinUrl(minioUtil.getPresignedUrl(o.getMannequinUrl(), 10)); String url = o.getMannequinUrl();
if (url.startsWith("aida-")) {
o.setMannequinUrl(minioUtil.getPresignedUrl(o.getMannequinUrl(), 10));
}
}); });
vo.setPage(PageBaseResponse.success(page)); vo.setPage(PageBaseResponse.success(page));
QueryWrapper<Workspace> qwIsLastIndex = new QueryWrapper<>(); QueryWrapper<Workspace> qwIsLastIndex = new QueryWrapper<>();
@@ -169,7 +179,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
ModelVO modelVO = new ModelVO(); ModelVO modelVO = new ModelVO();
modelVO.setId(library.getId()); modelVO.setId(library.getId());
modelVO.setUrl(library.getUrl()); modelVO.setUrl(library.getUrl());
if (library.getUrl().contains("aida-")) { if (library.getUrl().startsWith("aida-")) {
modelVO.setPresignedUrl(minioUtil.getPresignedUrl(library.getUrl(), 10)); modelVO.setPresignedUrl(minioUtil.getPresignedUrl(library.getUrl(), 10));
}else { }else {
modelVO.setPresignedUrl(library.getUrl()); modelVO.setPresignedUrl(library.getUrl());
@@ -191,7 +201,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
ModelVO modelVO = new ModelVO(); ModelVO modelVO = new ModelVO();
modelVO.setId(sysFile.getId()); modelVO.setId(sysFile.getId());
modelVO.setUrl(sysFile.getUrl()); modelVO.setUrl(sysFile.getUrl());
if (sysFile.getUrl().contains("aida-")) { if (sysFile.getUrl().startsWith("aida-")) {
modelVO.setPresignedUrl(minioUtil.getPresignedUrl(sysFile.getUrl(), 10)); modelVO.setPresignedUrl(minioUtil.getPresignedUrl(sysFile.getUrl(), 10));
}else { }else {
modelVO.setPresignedUrl(sysFile.getUrl()); modelVO.setPresignedUrl(sysFile.getUrl());