BUGFIX: format;

This commit is contained in:
shahaibo
2023-10-20 14:47:18 +08:00
parent f18c27fe02
commit 9fa605f83e
134 changed files with 1345 additions and 1203 deletions

View File

@@ -22,7 +22,7 @@ public interface AccountLoginLogService extends IService<AccountLoginLog> {
* @param accountId
* @return
*/
Boolean saveLoginLog(String ip ,Long accountId);
Boolean saveLoginLog(String ip, Long accountId);
/**
* 根据账户查询

View File

@@ -20,18 +20,23 @@ public interface AccountService extends IService<Account> {
/**
* 账户预先登入
*
* @param accountDTO
* @return
*/
AccountPreLoginVO preLogin(AccountPreLoginDTO accountDTO);
/**
* 账户登入
*
* @param accountLoginDTO
* @return
*/
AccountLoginVO login(AccountLoginDTO accountLoginDTO, HttpServletRequest request);
/**
* 绑定邮箱
*
* @param accountBindEmailDTO
* @return
*/
@@ -39,38 +44,49 @@ public interface AccountService extends IService<Account> {
/**
* 忘记密码
*
* @param accountDTO
* @return
*/
Boolean forgetPwd(AccountRegisterDTO accountDTO);
/**
* 发送邮件
*
* @param emailSendDTO
* @return
*/
Boolean sendEmail(EmailSendDTO emailSendDTO);
/**
* 登出
*
* @param accountLogoutDTO
* @return
*/
Boolean logout(AccountLogoutDTO accountLogoutDTO);
/**
* 判断是否登出 Boolean为登入
*
* @param accountLogoutDTO
* @return
*/
Boolean isLogin(AccountLogoutDTO accountLogoutDTO);
/**
* 添加用户信息
*
* @param accountAddDTO
* @return
*/
Boolean addUser(AccountAddDTO accountAddDTO);
/**
* 编辑用户信息
*
* @param accountEditDTO
* @return
*/
Boolean editUser(AccountEditDTO accountEditDTO) ;
Boolean editUser(AccountEditDTO accountEditDTO);
}

View File

@@ -31,6 +31,7 @@ public interface CollectionElementService extends IService<CollectionElement> {
* @return
*/
void delete(Long id);
/**
* 删除元素图片
*
@@ -38,6 +39,7 @@ public interface CollectionElementService extends IService<CollectionElement> {
* @return
*/
void batchDelete(List<Long> ids);
/**
* 生产印花图片
*
@@ -45,6 +47,7 @@ public interface CollectionElementService extends IService<CollectionElement> {
* @return
*/
CollectionGeneratePrintVO generatePrint(CollectionGeneratePrintDTO generatePrintDTO);
/**
* 保存印花图片
*
@@ -52,14 +55,17 @@ public interface CollectionElementService extends IService<CollectionElement> {
* @return
*/
Boolean savePrint(CollectionSavePrintDTO savePrintDTO);
/**
* 通过element保存library
*
* @param elements
* @return
*/
Boolean saveLibraryByCollectionElement(List<CollectionElement> elements,String timeZone);
Boolean saveLibraryByCollectionElement(List<CollectionElement> elements,String timeZone, String modelSex);
Boolean saveLibraryByCollectionElement(List<CollectionElement> elements, String timeZone);
Boolean saveLibraryByCollectionElement(List<CollectionElement> elements, String timeZone, String modelSex);
/**
* 校验element
*
@@ -67,6 +73,7 @@ public interface CollectionElementService extends IService<CollectionElement> {
* @return
*/
ValidateElementVO validateElement(DesignCollectionDTO designDTO);
/**
* 编辑
*
@@ -74,6 +81,7 @@ public interface CollectionElementService extends IService<CollectionElement> {
* @return
*/
void editSketchBoardsElement(ValidateElementVO elementVO, List<CollectionSketchDTO> sketchBoards);
/**
* 编辑
*
@@ -81,6 +89,7 @@ public interface CollectionElementService extends IService<CollectionElement> {
* @return
*/
void editPrintBoardsElement(ValidateElementVO elementVO, List<DesignCollectionPrintElementDTO> printBoards);
/**
* 关联element和collection
*
@@ -88,7 +97,7 @@ public interface CollectionElementService extends IService<CollectionElement> {
* @param collectionId
* @return
*/
void relationCollection(List<Long> elementIds,Long collectionId);
void relationCollection(List<Long> elementIds, Long collectionId);
/**
* 保存颜色板
@@ -107,22 +116,24 @@ public interface CollectionElementService extends IService<CollectionElement> {
*/
List<CollectionElement> getByCollectionId(Long collectionId);
List<CollectionElement> getByOnlyCollectionId(Long collectionId);
List<CollectionElement> getByOnlyCollectionId(Long collectionId);
DesignLibraryModelPointVO calculateTemplatePoint(LibraryModelPoint modelPoint, Integer high, Integer width, String templateUrl);
DesignLibraryModelPointVO calculateTemplatePointTemplate(LibraryModelPoint modelPoint, Integer high, Integer width, String templateUrl);
/**
* 刷新历史数据
*/
void refreshHistoryData() ;
void refreshHistoryData();
/**
* 当level2Type发生改变时修改levelType
*
* @param elementId
* @param level2Type
* @return
*/
CollectionElement editLevel2Type(Long elementId,String level2Type);
CollectionElement editLevel2Type(Long elementId, String level2Type);
}

View File

@@ -22,11 +22,13 @@ public interface CollectionService extends IService<Collection> {
/**
* 保存collection
*/
Long saveCollection(Long accountId,String timeZone,String moodTemplateId);
Long saveCollection(Long accountId, String timeZone, String moodTemplateId);
/**
* 根据主键查询
*/
Collection findById(Long id);
/**
* 查询choose关联的collection
*/

View File

@@ -28,6 +28,6 @@ public interface ColorLoopUpTableService extends IService<ColorLookupTable> {
* @param colorValues
* @return
*/
List<ColorLookupTable> getByColorValueList(List<Integer> colorValues);
List<ColorLookupTable> getByColorValueList(List<Integer> colorValues);
}

View File

@@ -23,12 +23,13 @@ public interface DesignItemService extends IService<DesignItem> {
List<DesignItem> getByDesignId(Long designId);
void updateLikeStatus(Long designItemId,Byte hasLike);
void updateLikeStatus(Long designItemId, Byte hasLike);
void updateDesignHighUrl(Long designItemId,String highUrl,String timeZone);
void updateDesignHighUrl(Long designItemId, String highUrl, String timeZone);
/**
* 切换系统elemnt
*
* @param id
* @param type
*/
@@ -36,12 +37,14 @@ public interface DesignItemService extends IService<DesignItem> {
/**
* 单个design
*
* @param designSingleDTO
*/
DesignCollectionItemVO designSingle(DesignSingleDTO designSingleDTO);
/**
* print打点
*
* @param designSingleDTO
*/
String printDot(DesignSingleDTO designSingleDTO);

View File

@@ -20,6 +20,7 @@ import java.math.BigDecimal;
public interface DesignService extends IService<Design> {
/**
* design
*
* @param designDTO
* @return
*/
@@ -27,12 +28,15 @@ public interface DesignService extends IService<Design> {
/**
* redesign
*
* @param reDesignDTO
* @return
*/
DesignCollectionVO reDesignCollection(ReDesignCollectionDTO reDesignDTO);
/**
* redesign
*
* @param designId
* @return
*/
@@ -45,6 +49,7 @@ public interface DesignService extends IService<Design> {
/**
* like
*
* @param designLikeDTO
* @return
*/
@@ -52,6 +57,7 @@ public interface DesignService extends IService<Design> {
/**
* dislike
*
* @param disDesignLikeDTO
* @return
*/
@@ -59,6 +65,7 @@ public interface DesignService extends IService<Design> {
/**
* generateHighDesign
*
* @param generateHighDesignDTO
* @return
*/
@@ -66,6 +73,7 @@ public interface DesignService extends IService<Design> {
/**
* deleteHighDesign
*
* @param generateHighDesignDTO
* @return
*/
@@ -73,10 +81,11 @@ public interface DesignService extends IService<Design> {
/**
* detail
*
* @param designItemId
* @return
*/
DesignItemDetailVO detail(Long designPythonOutfitId,Long designItemId);
DesignItemDetailVO detail(Long designPythonOutfitId, Long designItemId);
Integer designProcess(String processId);

View File

@@ -17,5 +17,5 @@ public interface GenerateService extends IService<Generate> {
GenerateLikeVO generateLike(GenerateLikeDTO generateLikeDTO);
Boolean generateDislike(Long generateDetailId,String timeZone);
Boolean generateDislike(Long generateDetailId, String timeZone);
}

View File

@@ -17,24 +17,25 @@ import java.util.List;
*/
public interface ITDesignPythonOutfitDetailService extends IService<TDesignPythonOutfitDetail> {
/**
* 自定义分页
*
* @param page
* @param tDesignPythonOutfitDetail
* @return
*/
IPage<TDesignPythonOutfitDetailVO> selectTDesignPythonOutfitDetailPage(IPage<TDesignPythonOutfitDetailVO> page, TDesignPythonOutfitDetailVO tDesignPythonOutfitDetail);
/**
* 自定义分页
*
* @param page
* @param tDesignPythonOutfitDetail
* @return
*/
IPage<TDesignPythonOutfitDetailVO> selectTDesignPythonOutfitDetailPage(IPage<TDesignPythonOutfitDetailVO> page, TDesignPythonOutfitDetailVO tDesignPythonOutfitDetail);
/**
* 通过DesignPythonOutfitId获取designPythonOutfitDetail
* @param designPythonOutfitId
* @return
*/
List<TDesignPythonOutfitDetail> getDetailByDesignPythonOutfitId(Long designPythonOutfitId);
/**
* 通过DesignPythonOutfitId获取designPythonOutfitDetail
*
* @param designPythonOutfitId
* @return
*/
List<TDesignPythonOutfitDetail> getDetailByDesignPythonOutfitId(Long designPythonOutfitId);
DesignPythonOutfitVO convertToDesignPythonOutfitVO(TDesignPythonOutfitDetail detail,List<Long> offset);
DesignPythonOutfitVO convertToDesignPythonOutfitVO(TDesignPythonOutfitDetail detail, List<Long> offset);
void deleteByDesignPythonOutfitId(Long designPythonOutfitId);
void deleteByDesignPythonOutfitId(Long designPythonOutfitId);
}

View File

@@ -13,14 +13,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
*/
public interface ITDesignPythonOutfitService extends IService<TDesignPythonOutfit> {
/**
* 自定义分页
*
* @param page
* @param tDesignPythonOutfit
* @return
*/
IPage<TDesignPythonOutfitVO> selectTDesignPythonOutfitPage(IPage<TDesignPythonOutfitVO> page, TDesignPythonOutfitVO tDesignPythonOutfit);
/**
* 自定义分页
*
* @param page
* @param tDesignPythonOutfit
* @return
*/
IPage<TDesignPythonOutfitVO> selectTDesignPythonOutfitPage(IPage<TDesignPythonOutfitVO> page, TDesignPythonOutfitVO tDesignPythonOutfit);
TDesignPythonOutfit getByDesignItemId(Long designItemId);
TDesignPythonOutfit getByDesignItemId(Long designItemId);
}

View File

@@ -19,17 +19,18 @@ import java.util.List;
*/
public interface LibraryModelPointService extends IService<LibraryModelPoint> {
LibraryModelPointVO saveOrEditTemplatePoint (LibraryModelPointDTO libraryModelPoint);
LibraryModelPointVO saveOrEditTemplatePoint(LibraryModelPointDTO libraryModelPoint);
List<LibraryModelPointVO> selectByLibraryIds (List<Long> libraryIds);
List<LibraryModelPointVO> selectByLibraryIds(List<Long> libraryIds);
/**
* 模特打点
*
* @param modelsDotDTO
* @return
*/
String modelsDot( ModelsDotDTO modelsDotDTO );
String modelsDot(ModelsDotDTO modelsDotDTO);
LibraryModelPoint getByRelationId(Long relationId,String modelType);
LibraryModelPoint getByRelationId(Long relationId, String modelType);
}

View File

@@ -23,6 +23,7 @@ import java.util.List;
public interface LibraryService extends IService<Library> {
/**
* 根据用户id和一等级查询
*
* @param accountId
* @param level1Types
* @return
@@ -31,6 +32,7 @@ public interface LibraryService extends IService<Library> {
/**
* 分页查询library
*
* @param query
* @return
*/
@@ -46,27 +48,31 @@ public interface LibraryService extends IService<Library> {
/**
* 编辑library 文件名
*
* @param libraryUpdateDTO
*/
void updateLibraryName(LibraryUpdateDTO libraryUpdateDTO);
/**
* 跟进ids批量查询
*
* @param ids
*/
List<Library> getByIds(List<Long> ids);
/**
* 根据md5集合查询
*
* @param md5List
*/
List<Library> getByMD5List(List<String> md5List);
/**
* 根据集合url查询
*
* @param urlList
*/
List<LibraryVo> getByUrlList(List<String> urlList,Long userId);
List<LibraryVo> getByUrlList(List<String> urlList, Long userId);
Boolean updateLibraryLevel2Type(LibraryLevel2TypeUpdateDTO libraryLevel2TypeUpdateDTO);

View File

@@ -25,6 +25,7 @@ public interface PanToneService extends IService<PanTone> {
* @return
*/
PantoneVO getByHSV(Integer h, Integer s, Integer v);
/**
* 根据TCX值查询
*
@@ -35,22 +36,24 @@ public interface PanToneService extends IService<PanTone> {
/**
* 根据TRGB值查询
*
* @param r
* @param g
* @param b
* @return
*/
PantoneVO getByRGB(Integer r,Integer g,Integer b);
PantoneVO getByRGB(Integer r, Integer g, Integer b);
Map<String,PantoneVO> getPantoneByRgbBatch(List<String> colors);
Map<String, PantoneVO> getPantoneByRgbBatch(List<String> colors);
PantoneVO getPantoneByRgb(String color);
/**
* 根据hsv批量查询
*
* @param rgbByHsvBatch
* @return
*/
List<PantoneVO> getRgbByHsvBatch(List<GetRgbByHsvBatchDTO> rgbByHsvBatch);
List<PantoneVO> getRgbByHsvBatch(List<GetRgbByHsvBatchDTO> rgbByHsvBatch);
}

View File

@@ -1,7 +1,6 @@
package com.ai.da.service;
import com.ai.da.mapper.entity.PythonTAllInfo;
import com.baomidou.mybatisplus.extension.service.IService;

View File

@@ -38,18 +38,23 @@ public interface SysFileService extends IService<SysFile> {
/**
* 根据id获取系统文件
*
* @param id
* @return
*/
SysFileVO getById(Long id);
/**
* 根据level1Type获取系统文件
*
* @param level2Type
* @return
*/
List<SysFileVO> getByLevel2Type(String level2Type);
/**
* 根据集合url查询
*
* @param urlList
*/
List<SysFileVO> getByUrlList(List<String> urlList);

View File

@@ -16,5 +16,6 @@ import java.util.List;
*/
public interface TCollectionElementRelationService extends IService<TCollectionElementRelation> {
void deleteByCollectionId(Long collectionId);
List<Long> getByCollectionId(Long collectionId);
List<Long> getByCollectionId(Long collectionId);
}

View File

@@ -22,10 +22,11 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
HistoryUpdateVO updateUserGroupName(Long userGroupId, String userGroupName, String timeZone);
Long insertUserGroup(Long userId,Long collectionId,String timeZone);
Long insertUserGroup(Long userId, Long collectionId, String timeZone);
/**
* choose
*
* @param userGroupId
* @return
*/

View File

@@ -14,37 +14,37 @@ import java.io.FileNotFoundException;
import java.util.List;
/**
* 服务类
* 服务类
*
* @author SHAHAIBO
* @since 2023-08-01
*/
public interface WorkspaceService extends IService<Workspace> {
/**
* 自定义分页
*
* @param page
* @param workspace
* @return
*/
IPage<WorkspaceVO> selectWorkspacePage(IPage<WorkspaceVO> page, WorkspaceVO workspace);
/**
* 自定义分页
*
* @param page
* @param workspace
* @return
*/
IPage<WorkspaceVO> selectWorkspacePage(IPage<WorkspaceVO> page, WorkspaceVO workspace);
boolean saveOrUpdate(Workspace workspace);
boolean saveOrUpdate(Workspace workspace);
WorkspaceVO getPage(WorkspaceDTO query);
WorkspaceVO getPage(WorkspaceDTO query);
List<BizJson> getEnumValues(String enumName);
List<BizJson> getEnumValues(String enumName);
Workspace getByIdNew(Long id);
Workspace getByIdNew(Long id);
List<ModelsVO> getMannequins(String sex);
List<ModelsVO> getMannequins(String sex);
void systemFileCopy();
void systemFileCopy();
void moveFile();
void moveFile();
void maleDataInsert() throws FileNotFoundException;
void maleDataInsert() throws FileNotFoundException;
List<Long> delete(List<Workspace> workspaceList);
List<Long> delete(List<Workspace> workspaceList);
}

View File

@@ -28,12 +28,12 @@ public class AccountLoginLogServiceImpl extends ServiceImpl<AccountLoginLogMappe
AccountLoginLogMapper accountLoginLogMapper;
@Override
public Boolean saveLoginLog(String ip ,Long accountId) {
public Boolean saveLoginLog(String ip, Long accountId) {
AccountLoginLog accountLoginLog = new AccountLoginLog();
accountLoginLog.setAccountId(accountId);
accountLoginLog.setIp(ip);
accountLoginLog.setCreateDate(new Date());
return accountLoginLogMapper.insert(accountLoginLog) >0;
return accountLoginLogMapper.insert(accountLoginLog) > 0;
}
@Override

View File

@@ -167,7 +167,7 @@ public class ChatRobotServiceImpl implements ChatRobotService {
if (response.isSuccessful()) {
try {
String responseBody = response.body().string();
JSONObject responseObject = JSON.parseObject(responseBody);
JSONObject responseObject = JSON.parseObject(responseBody);
JSONObject data = responseObject.getJSONObject("data");
if (null != data) {
ChatRobot chatRobot = new ChatRobot();
@@ -180,7 +180,7 @@ public class ChatRobotServiceImpl implements ChatRobotService {
chatRobot.setSessionId(data.getString("session_id"));
BigDecimal totalCost = data.getBigDecimal("total_cost");
// 校验本次余额够不够
checkBalance(totalCost,chatSendDTO.getUser_id());
checkBalance(totalCost, chatSendDTO.getUser_id());
chatRobot.setTotalCost(totalCost);
chatRobot.setTotalTokens(data.getLong("total_tokens"));
chatRobot.setUserId(chatSendDTO.getUser_id());
@@ -194,7 +194,7 @@ public class ChatRobotServiceImpl implements ChatRobotService {
chatRobot.setSuccessful(0);
chatRobotMapper.insert(chatRobot);
chatRobotVO.setOutput("I'm sorry, but I can't process your current request. Please rephrase it differently.");
}else {
} else {
chatRobot.setSuccessful(1);
chatRobotMapper.insert(chatRobot);
for (int i = 0; i < array.size(); i++) {
@@ -219,19 +219,19 @@ public class ChatRobotServiceImpl implements ChatRobotService {
}
chatRobotVO.setChatRobotLibraryList(chatRobotLibraryVOList);
}
}else {
} else {
chatRobot.setSuccessful(0);
chatRobotMapper.insert(chatRobot);
chatRobotVO.setOutput("I'm sorry, but I can't process your current request. Please rephrase it differently.");
}
}else {
} else {
chatRobot.setSuccessful(1);
chatRobotMapper.insert(chatRobot);
}
return chatRobotVO;
}
throw new BusinessException("ChatRobot response data is null!");
}catch (IOException e) {
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@@ -245,9 +245,9 @@ public class ChatRobotServiceImpl implements ChatRobotService {
queryWrapper.select("user_id", "SUM(total_cost) as total_cost");
queryWrapper.groupBy("user_id");
List<ChatRobot> chatRobots = chatRobotMapper.selectList(queryWrapper);
if(!CollectionUtils.isEmpty(chatRobots)) {
if (!CollectionUtils.isEmpty(chatRobots)) {
BigDecimal totalCostUsed = chatRobots.get(0).getTotalCost();
if(totalCostUsed.add(totalCost).compareTo(BigDecimal.valueOf(5)) > 0) {
if (totalCostUsed.add(totalCost).compareTo(BigDecimal.valueOf(5)) > 0) {
throw new BusinessException("Your balance is insufficient");
}
}
@@ -279,10 +279,10 @@ public class ChatRobotServiceImpl implements ChatRobotService {
String name = split[4];
if (name.contains(".")) {
library.setName(name.split("\\.")[0]);
}else {
} else {
library.setName(name);
}
}else {
} else {
throw new BusinessException("error url");
}
@@ -296,7 +296,7 @@ public class ChatRobotServiceImpl implements ChatRobotService {
library.setCreateDate(new Date());
libraryMapper.insert(library);
return library;
}else {
} else {
libraryMapper.deleteById(chatRobotLibraryDTO.getId());
return null;
}
@@ -310,9 +310,9 @@ public class ChatRobotServiceImpl implements ChatRobotService {
queryWrapper.select("user_id", "SUM(total_cost) as total_cost");
queryWrapper.groupBy("user_id");
List<ChatRobot> chatRobots = chatRobotMapper.selectList(queryWrapper);
if(CollectionUtils.isEmpty(chatRobots)) {
if (CollectionUtils.isEmpty(chatRobots)) {
return BigDecimal.ONE;
}else {
} else {
BigDecimal totalCost = BigDecimal.valueOf(5).subtract(chatRobots.get(0).getTotalCost());
BigDecimal result = totalCost.divide(BigDecimal.valueOf(5), 4, RoundingMode.HALF_UP);
return result;

View File

@@ -113,7 +113,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
//获取图片后缀
String suffix = pictureCollectonName.substring(pictureCollectonName.lastIndexOf("."));
//获取图片前缀
String prefix = pictureCollectonName.substring(0,pictureCollectonName.lastIndexOf("."));
String prefix = pictureCollectonName.substring(0, pictureCollectonName.lastIndexOf("."));
element.setName(DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD));
element.setUrl(file.getAbsolutePath());
//按时区计算
@@ -162,14 +162,14 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
@Override
public void batchDelete(List<Long> ids) {
if(CollectionUtils.isEmpty(ids)){
if (CollectionUtils.isEmpty(ids)) {
return;
}
QueryWrapper<CollectionElement> queryWrapper = new QueryWrapper<>();
queryWrapper.in("id",ids);
queryWrapper.in("id", ids);
CollectionElement collectionElement = new CollectionElement();
collectionElement.setCollectionId(0L);
collectionElementMapper.update(collectionElement,queryWrapper);
collectionElementMapper.update(collectionElement, queryWrapper);
}
@Override
@@ -177,19 +177,19 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
String url1 = null;
String url2 = null;
CollectionElement element1 = selectById(generatePrintDTO.getSelect1Id());
if (Objects.isNull(element1)){
if (Objects.isNull(element1)) {
Library library1 = libraryService.getById(generatePrintDTO.getSelect1Id());
Assert.notNull(library1, "select1 file does not exist!");
url1 = library1.getUrl();
}else {
} else {
url1 = element1.getUrl();
}
CollectionElement element2 = selectById(generatePrintDTO.getSelect2Id());
if (Objects.isNull(element2)){
if (Objects.isNull(element2)) {
Library library2 = libraryService.getById(generatePrintDTO.getSelect2Id());
Assert.notNull(library2, "select2 file does not exist!");
url2 = library2.getUrl();
}else{
} else {
url2 = element2.getUrl();
}
List<String> printPath = Arrays.asList(url1, url2);
@@ -198,11 +198,11 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
Assert.isTrue(!StringUtils.isEmpty(generateUrl), "generate print exception!");
//用户信息
AuthPrincipalVo userInfo = UserContext.getUserHolder();
CollectionElement element = resolveData(generateUrl,generatePrintDTO.getTimeZone(), userInfo);
CollectionElement element = resolveData(generateUrl, generatePrintDTO.getTimeZone(), userInfo);
if (!this.save(element)) {
throw new BusinessException("generate print failed !");
}
CollectionGeneratePrintVO collectionGeneratePrint= CopyUtil.copyObject(element,CollectionGeneratePrintVO.class);
CollectionGeneratePrintVO collectionGeneratePrint = CopyUtil.copyObject(element, CollectionGeneratePrintVO.class);
collectionGeneratePrint.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
return collectionGeneratePrint;
}
@@ -211,29 +211,29 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
public Boolean savePrint(CollectionSavePrintDTO savePrintDTO) {
//用户信息
List<CollectionElement> elements = listByIds(savePrintDTO.getPrintId());
Assert.notEmpty(elements,"print file does not exist!");
return saveLibraryByCollectionElement(elements,savePrintDTO.getTimeZone());
Assert.notEmpty(elements, "print file does not exist!");
return saveLibraryByCollectionElement(elements, savePrintDTO.getTimeZone());
}
@Override
public Boolean saveLibraryByCollectionElement(List<CollectionElement> elements,String timeZone){
if(CollectionUtils.isEmpty(elements)){
public Boolean saveLibraryByCollectionElement(List<CollectionElement> elements, String timeZone) {
if (CollectionUtils.isEmpty(elements)) {
return Boolean.TRUE;
}
//获取已存在相同的library
List<String> md5List = elements.stream().map(CollectionElement::getMd5).collect(Collectors.toList());
List<Library> existsLibrarys = libraryService.getByMD5List(md5List);
if(!CollectionUtils.isEmpty(existsLibrarys)){
if (!CollectionUtils.isEmpty(existsLibrarys)) {
//去重
List<String> existsMd5Lists = existsLibrarys.stream().map(Library::getMd5).collect(Collectors.toList());
elements = elements.stream().filter(element ->!existsMd5Lists.contains(element.getMd5())).collect(Collectors.toList());
elements = elements.stream().filter(element -> !existsMd5Lists.contains(element.getMd5())).collect(Collectors.toList());
}
if(CollectionUtils.isEmpty(elements)){
if (CollectionUtils.isEmpty(elements)) {
//都是重复的
return Boolean.TRUE;
}
String name = DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD);
List<Library> libraryList = CopyUtil.copyList(elements, Library.class,(o,d) ->{
String name = DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD);
List<Library> libraryList = CopyUtil.copyList(elements, Library.class, (o, d) -> {
d.setCreateDate(DateUtil.getByTimeZone(timeZone));
d.setName(name);
d.setId(null);
@@ -245,24 +245,24 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
}
@Override
public Boolean saveLibraryByCollectionElement(List<CollectionElement> elements,String timeZone, String modelSex){
if(CollectionUtils.isEmpty(elements)){
public Boolean saveLibraryByCollectionElement(List<CollectionElement> elements, String timeZone, String modelSex) {
if (CollectionUtils.isEmpty(elements)) {
return Boolean.TRUE;
}
//获取已存在相同的library
List<String> md5List = elements.stream().map(CollectionElement::getMd5).collect(Collectors.toList());
List<Library> existsLibrarys = libraryService.getByMD5List(md5List);
if(!CollectionUtils.isEmpty(existsLibrarys)){
if (!CollectionUtils.isEmpty(existsLibrarys)) {
//去重
List<String> existsMd5Lists = existsLibrarys.stream().map(Library::getMd5).collect(Collectors.toList());
elements = elements.stream().filter(element ->!existsMd5Lists.contains(element.getMd5())).collect(Collectors.toList());
elements = elements.stream().filter(element -> !existsMd5Lists.contains(element.getMd5())).collect(Collectors.toList());
}
if(CollectionUtils.isEmpty(elements)){
if (CollectionUtils.isEmpty(elements)) {
//都是重复的
return Boolean.TRUE;
}
String name = DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD);
List<Library> libraryList = CopyUtil.copyList(elements, Library.class,(o,d) ->{
String name = DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD);
List<Library> libraryList = CopyUtil.copyList(elements, Library.class, (o, d) -> {
if (d.getLevel1Type().equals(LibraryLevel1TypeEnum.SKETCH_BOARD.getRealName())) {
d.setLevel3Type(modelSex);
}
@@ -276,7 +276,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
return Boolean.TRUE;
}
private CollectionElement resolveData(String path, String timeZone,AuthPrincipalVo userInfo) {
private CollectionElement resolveData(String path, String timeZone, AuthPrincipalVo userInfo) {
File file = new File(path);
CollectionElement element = new CollectionElement();
element.setAccountId(userInfo.getId());
@@ -296,17 +296,17 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
ValidateElementVO elementVO = CopyUtil.copyObject(designDTO, ValidateElementVO.class);
List<Long> usedElementIds = elementVO.getUsedElementIds();
List<CollectionElement> libraryCollectionElements = elementVO.getLibraryCollectionElements();
List<CollectionElement> generateCollectionElements = elementVO.getGenerateCollectionElements();
List<CollectionElement> libraryCollectionElements = elementVO.getLibraryCollectionElements();
List<CollectionElement> generateCollectionElements = elementVO.getGenerateCollectionElements();
//校验moodboard
if (CollectionUtil.isNotEmpty(designDTO.getMoodBoards())) {
//校验designType
validateDesignType(designDTO.getMoodBoards(),"moodBoards");
validateDesignType(designDTO.getMoodBoards(), "moodBoards");
List<Long> moodBoardIds = designDTO.getMoodBoards().stream()
.filter(f ->f.getDesignType().equals(DesignTypeEnum.COLLECTION.getRealName()))
.filter(f -> f.getDesignType().equals(DesignTypeEnum.COLLECTION.getRealName()))
.map(DesignCollectionElementDTO::getId)
.collect(Collectors.toList());
if(!CollectionUtils.isEmpty(moodBoardIds)){
if (!CollectionUtils.isEmpty(moodBoardIds)) {
List<CollectionElement> MoodBoardElements = collectionElementMapper.selectBatchIds(moodBoardIds);
Assert.isTrue(CollectionUtil.isNotEmpty(MoodBoardElements)
&& MoodBoardElements.size() == moodBoardIds.size(), "get moodboard data is mismatch");
@@ -315,14 +315,14 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
}
//library
List<Long> libraryIds = designDTO.getMoodBoards().stream()
.filter(f ->f.getDesignType().equals(DesignTypeEnum.LIBRARY.getRealName()))
.filter(f -> f.getDesignType().equals(DesignTypeEnum.LIBRARY.getRealName()))
.map(DesignCollectionElementDTO::getId)
.collect(Collectors.toList());
if(!CollectionUtils.isEmpty(libraryIds)){
if (!CollectionUtils.isEmpty(libraryIds)) {
List<Library> librarys = libraryService.getByIds(libraryIds);
//不校验了防止用户在library删除 对应不上
if(CollectionUtil.isNotEmpty(librarys)){
libraryCollectionElements.addAll(covertLibrarysToCollections(librarys,null));
if (CollectionUtil.isNotEmpty(librarys)) {
libraryCollectionElements.addAll(covertLibrarysToCollections(librarys, null));
}
}
// generate
@@ -330,21 +330,21 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
.filter(o -> o.getDesignType().equals((DesignTypeEnum.GENERATE.getRealName())))
.map(DesignCollectionElementDTO::getId)
.collect((Collectors.toList()));
if(CollectionUtil.isNotEmpty(generateIds)) {
if (CollectionUtil.isNotEmpty(generateIds)) {
List<Generate> generateList = generateService.listByIds(generateIds);
if(CollectionUtil.isNotEmpty(generateList)){
generateCollectionElements.addAll(covertGeneratesToCollections(generateList,null));
if (CollectionUtil.isNotEmpty(generateList)) {
generateCollectionElements.addAll(covertGeneratesToCollections(generateList, null));
}
}
}
if (CollectionUtil.isNotEmpty(designDTO.getPrintBoards())) {
//校验designType
validateDesignType(CopyUtil.copyList(designDTO.getPrintBoards(),DesignCollectionElementDTO.class),"printBoards");
validateDesignType(CopyUtil.copyList(designDTO.getPrintBoards(), DesignCollectionElementDTO.class), "printBoards");
List<Long> printBoardIds = designDTO.getPrintBoards().stream()
.filter(f ->f.getDesignType().equals(DesignTypeEnum.COLLECTION.getRealName()))
.filter(f -> f.getDesignType().equals(DesignTypeEnum.COLLECTION.getRealName()))
.map(DesignCollectionPrintElementDTO::getId)
.collect(Collectors.toList());
if(!CollectionUtils.isEmpty(printBoardIds)){
if (!CollectionUtils.isEmpty(printBoardIds)) {
//校验printboard
List<CollectionElement> printBoardElements = collectionElementMapper.selectBatchIds(printBoardIds);
Assert.isTrue(CollectionUtil.isNotEmpty(printBoardElements)
@@ -354,17 +354,17 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
}
//library
List<Long> libraryIds = designDTO.getPrintBoards().stream()
.filter(f ->f.getDesignType().equals(DesignTypeEnum.LIBRARY.getRealName()))
.filter(f -> f.getDesignType().equals(DesignTypeEnum.LIBRARY.getRealName()))
.map(DesignCollectionPrintElementDTO::getId)
.collect(Collectors.toList());
if(!CollectionUtils.isEmpty(libraryIds)){
if (!CollectionUtils.isEmpty(libraryIds)) {
List<Library> librarys = libraryService.getByIds(libraryIds);
//不校验了防止用户在library删除 对应不上
if(CollectionUtil.isNotEmpty(librarys)){
Map<Long,DesignCollectionPrintElementDTO> idToMap = designDTO.getPrintBoards()
if (CollectionUtil.isNotEmpty(librarys)) {
Map<Long, DesignCollectionPrintElementDTO> idToMap = designDTO.getPrintBoards()
.stream()
.collect(Collectors.toMap(DesignCollectionPrintElementDTO::getId,v ->v));
libraryCollectionElements.addAll(covertLibrarysToPrintCollections(librarys,idToMap));
.collect(Collectors.toMap(DesignCollectionPrintElementDTO::getId, v -> v));
libraryCollectionElements.addAll(covertLibrarysToPrintCollections(librarys, idToMap));
}
}
// generate
@@ -372,39 +372,39 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
.filter(o -> o.getDesignType().equals((DesignTypeEnum.GENERATE.getRealName())))
.map(DesignCollectionPrintElementDTO::getId)
.collect((Collectors.toList()));
if(CollectionUtil.isNotEmpty(generateIds)) {
if (CollectionUtil.isNotEmpty(generateIds)) {
List<Generate> generateList = generateService.listByIds(generateIds);
if(CollectionUtil.isNotEmpty(generateList)){
Map<Long,DesignCollectionPrintElementDTO> idToMap = designDTO.getPrintBoards()
if (CollectionUtil.isNotEmpty(generateList)) {
Map<Long, DesignCollectionPrintElementDTO> idToMap = designDTO.getPrintBoards()
.stream()
.collect(Collectors.toMap(DesignCollectionPrintElementDTO::getId,v ->v));
generateCollectionElements.addAll(covertGeneratesToPrintCollections(generateList,idToMap));
.collect(Collectors.toMap(DesignCollectionPrintElementDTO::getId, v -> v));
generateCollectionElements.addAll(covertGeneratesToPrintCollections(generateList, idToMap));
}
}
}
if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) {
//校验PIN是否满足 上衣或者下衣必须不超过8
long topNum= designDTO.getSketchBoards().stream()
.filter(skecth ->skecth.getIsPin() ==1
long topNum = designDTO.getSketchBoards().stream()
.filter(skecth -> skecth.getIsPin() == 1
&& DesignPythonItem.OUTWEAR_DRESS_BLOUSE.contains(skecth.getLevel2Type())).count();
Assert.isTrue(topNum<=8,"The number of PIN sketch cannot be greater than 8!");
long bottomNum= designDTO.getSketchBoards().stream()
.filter(skecth ->skecth.getIsPin() ==1
Assert.isTrue(topNum <= 8, "The number of PIN sketch cannot be greater than 8!");
long bottomNum = designDTO.getSketchBoards().stream()
.filter(skecth -> skecth.getIsPin() == 1
&& DesignPythonItem.SKIRT_TROUSERS.contains(skecth.getLevel2Type())).count();
Assert.isTrue(bottomNum<=8,"The number of PIN sketch cannot be greater than 8!");
Assert.isTrue(bottomNum <= 8, "The number of PIN sketch cannot be greater than 8!");
//校验designType
Boolean result = designDTO.getSketchBoards().stream()
.filter(mood ->StringUtils.isEmpty(mood.getDesignType()))
.filter(mood -> StringUtils.isEmpty(mood.getDesignType()))
.findFirst().isPresent();
if(result){
if (result) {
throw new BusinessException("sketchBoards designType cannot be empty!");
}
List<Long> sketchBoardIds = designDTO.getSketchBoards().stream()
.filter(f ->f.getDesignType().equals(DesignTypeEnum.COLLECTION.getRealName()))
.filter(f -> f.getDesignType().equals(DesignTypeEnum.COLLECTION.getRealName()))
.map(CollectionSketchDTO::getSketchBoardId)
.collect(Collectors.toList());
if(!CollectionUtils.isEmpty(sketchBoardIds)){
if (!CollectionUtils.isEmpty(sketchBoardIds)) {
//校验sketchBoard
List<CollectionElement> sketchBoardElements = collectionElementMapper.selectBatchIds(sketchBoardIds);
Assert.isTrue(CollectionUtil.isNotEmpty(sketchBoardElements)
@@ -414,17 +414,17 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
}
//library
List<Long> libraryIds = designDTO.getSketchBoards().stream()
.filter(f ->f.getDesignType().equals(DesignTypeEnum.LIBRARY.getRealName()))
.filter(f -> f.getDesignType().equals(DesignTypeEnum.LIBRARY.getRealName()))
.map(CollectionSketchDTO::getSketchBoardId)
.collect(Collectors.toList());
if(!CollectionUtils.isEmpty(libraryIds)){
if (!CollectionUtils.isEmpty(libraryIds)) {
List<Library> librarys = libraryService.getByIds(libraryIds);
//不校验了防止用户在library删除 对应不上
if(CollectionUtil.isNotEmpty(librarys)){
Map<Long,CollectionSketchDTO> idToMap = designDTO.getSketchBoards()
if (CollectionUtil.isNotEmpty(librarys)) {
Map<Long, CollectionSketchDTO> idToMap = designDTO.getSketchBoards()
.stream()
.collect(Collectors.toMap(CollectionSketchDTO::getSketchBoardId,v ->v));
libraryCollectionElements.addAll(covertLibrarysToCollections(librarys,idToMap));
.collect(Collectors.toMap(CollectionSketchDTO::getSketchBoardId, v -> v));
libraryCollectionElements.addAll(covertLibrarysToCollections(librarys, idToMap));
}
}
// generate
@@ -432,13 +432,13 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
.filter(o -> o.getDesignType().equals((DesignTypeEnum.GENERATE.getRealName())))
.map(CollectionSketchDTO::getSketchBoardId)
.collect((Collectors.toList()));
if(CollectionUtil.isNotEmpty(generateIds)) {
if (CollectionUtil.isNotEmpty(generateIds)) {
List<Generate> generateList = generateService.listByIds(generateIds);
if(CollectionUtil.isNotEmpty(generateList)){
Map<Long,CollectionSketchDTO> idToMap = designDTO.getSketchBoards()
if (CollectionUtil.isNotEmpty(generateList)) {
Map<Long, CollectionSketchDTO> idToMap = designDTO.getSketchBoards()
.stream()
.collect(Collectors.toMap(CollectionSketchDTO::getSketchBoardId,v ->v));
generateCollectionElements.addAll(covertGeneratesToCollections(generateList,idToMap));
.collect(Collectors.toMap(CollectionSketchDTO::getSketchBoardId, v -> v));
generateCollectionElements.addAll(covertGeneratesToCollections(generateList, idToMap));
}
}
}
@@ -479,7 +479,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
Assert.notNull(switchCategory, "unknown parameter switchCategory!");
}
//校验template
if(Objects.nonNull(designDTO.getTemplateId())){
if (Objects.nonNull(designDTO.getTemplateId())) {
// LibraryModelPoint modelPoint = libraryModelPointService.getById(designDTO.getTemplateId());
// Assert.notNull(modelPoint, "template cannot by empty!");
// Library library = libraryService.getById(modelPoint.getLibraryId());
@@ -493,8 +493,8 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
if (Objects.isNull(modelPoint)) {
throw new BusinessException("error modelPoint get");
}
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint,byId.getHigh(),byId.getWidth(),byId.getUrl()));
}else if (designDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, byId.getHigh(), byId.getWidth(), byId.getUrl()));
} else if (designDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
SysFileVO byId = sysFileService.getById(designDTO.getTemplateId());
QueryWrapper<LibraryModelPoint> qw = new QueryWrapper<>();
qw.lambda().eq(LibraryModelPoint::getModelType, ModelType.SYSTEM.getValue());
@@ -503,9 +503,9 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
if (Objects.isNull(modelPoint)) {
throw new BusinessException("error modelPoint get");
}
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint,1050,500,byId.getUrl()));
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, 1050, 500, byId.getUrl()));
}
}else {
} else {
throw new BusinessException("templateId or modelType can't be null");
}
if (StringUtils.isEmpty(designDTO.getModelSex())) {
@@ -514,21 +514,22 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
elementVO.setModelSex(designDTO.getModelSex());
return elementVO;
}
@Override
public DesignLibraryModelPointVO calculateTemplatePoint(LibraryModelPoint modelPoint, Integer high, Integer width,String templateUrl){
public DesignLibraryModelPointVO calculateTemplatePoint(LibraryModelPoint modelPoint, Integer high, Integer width, String templateUrl) {
DesignLibraryModelPointVO libraryModelPoint = new DesignLibraryModelPointVO();
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.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;
}
@Override
public DesignLibraryModelPointVO calculateTemplatePointTemplate(LibraryModelPoint modelPoint, Integer high, Integer width,String templateUrl){
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));
@@ -538,25 +539,26 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
// 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.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){
List<BigDecimal> originRatioList = JSON.parseObject(template,List.class);
originRatioList.set(0,originRatioList.get(0).multiply(BigDecimal.valueOf(width)));
originRatioList.set(1,originRatioList.get(1).multiply(BigDecimal.valueOf(high)));
private List<BigDecimal> calculateTemplatePointOne(String template, Integer high, Integer width) {
List<BigDecimal> originRatioList = JSON.parseObject(template, List.class);
originRatioList.set(0, originRatioList.get(0).multiply(BigDecimal.valueOf(width)));
originRatioList.set(1, originRatioList.get(1).multiply(BigDecimal.valueOf(high)));
return originRatioList;
}
private List<CollectionElement> covertLibrarysToCollections(List<Library> libraries, Map<Long,CollectionSketchDTO> idToMap){
return CopyUtil.copyList(libraries,CollectionElement.class,(o,d) ->{
if(null != idToMap){
private List<CollectionElement> covertLibrarysToCollections(List<Library> libraries, Map<Long, CollectionSketchDTO> idToMap) {
return CopyUtil.copyList(libraries, CollectionElement.class, (o, d) -> {
if (null != idToMap) {
CollectionSketchDTO sketchDTO = idToMap.get(o.getId());
d.setLevel2Type(sketchDTO.getLevel2Type());
d.setHasPin(sketchDTO.getIsPin());
@@ -564,9 +566,9 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
});
}
private List<CollectionElement> covertGeneratesToCollections(List<Generate> generates, Map<Long,CollectionSketchDTO> idToMap){
return CopyUtil.copyList(generates,CollectionElement.class,(o,d) ->{
if(null != idToMap){
private List<CollectionElement> covertGeneratesToCollections(List<Generate> generates, Map<Long, CollectionSketchDTO> idToMap) {
return CopyUtil.copyList(generates, CollectionElement.class, (o, d) -> {
if (null != idToMap) {
CollectionSketchDTO sketchDTO = idToMap.get(o.getId());
d.setLevel2Type(sketchDTO.getLevel2Type());
d.setHasPin(sketchDTO.getIsPin());
@@ -574,35 +576,36 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
});
}
private List<CollectionElement> covertLibrarysToPrintCollections(List<Library> libraries, Map<Long,DesignCollectionPrintElementDTO> idToMap){
return CopyUtil.copyList(libraries,CollectionElement.class,(o,d) ->{
if(null != idToMap){
private List<CollectionElement> covertLibrarysToPrintCollections(List<Library> libraries, Map<Long, DesignCollectionPrintElementDTO> idToMap) {
return CopyUtil.copyList(libraries, CollectionElement.class, (o, d) -> {
if (null != idToMap) {
DesignCollectionPrintElementDTO printDTO = idToMap.get(o.getId());
d.setHasPin(printDTO.getIsPin());
}
});
}
private List<CollectionElement> covertGeneratesToPrintCollections(List<Generate> generates, Map<Long,DesignCollectionPrintElementDTO> idToMap){
return CopyUtil.copyList(generates,CollectionElement.class,(o,d) ->{
if(null != idToMap){
private List<CollectionElement> covertGeneratesToPrintCollections(List<Generate> generates, Map<Long, DesignCollectionPrintElementDTO> idToMap) {
return CopyUtil.copyList(generates, CollectionElement.class, (o, d) -> {
if (null != idToMap) {
DesignCollectionPrintElementDTO printDTO = idToMap.get(o.getId());
d.setHasPin(printDTO.getIsPin());
}
});
}
private void validateDesignType(List<DesignCollectionElementDTO> collectionElements,String msg){
Boolean result = collectionElements.stream().filter(mood ->StringUtils.isEmpty(mood.getDesignType())).findFirst().isPresent();
if(result){
throw new BusinessException(msg+" designType cannot be empty!");
private void validateDesignType(List<DesignCollectionElementDTO> collectionElements, String msg) {
Boolean result = collectionElements.stream().filter(mood -> StringUtils.isEmpty(mood.getDesignType())).findFirst().isPresent();
if (result) {
throw new BusinessException(msg + " designType cannot be empty!");
}
}
@Override
public void editSketchBoardsElement(ValidateElementVO elementVO, List<CollectionSketchDTO> sketchBoards) {
if(CollectionUtil.isNotEmpty(sketchBoards)){
sketchBoards.forEach(sketchBoard ->{
CollectionElement collectionElement = CopyUtil.copyObject(sketchBoard,CollectionElement.class);
if (CollectionUtil.isNotEmpty(sketchBoards)) {
sketchBoards.forEach(sketchBoard -> {
CollectionElement collectionElement = CopyUtil.copyObject(sketchBoard, CollectionElement.class);
collectionElement.setHasPin(sketchBoard.getIsPin());
collectionElement.setId(sketchBoard.getSketchBoardId());
collectionElementMapper.updateById(collectionElement);
@@ -612,12 +615,13 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
elementVO.setSketchBoardElements(sketchBoardElements);
}
}
@Override
public void editPrintBoardsElement(ValidateElementVO elementVO, List<DesignCollectionPrintElementDTO> printBoards) {
if(CollectionUtil.isNotEmpty(printBoards)){
printBoards.forEach(printBoard ->{
CollectionElement collectionElement = CopyUtil.copyObject(printBoard,CollectionElement.class);
collectionElement.setHasPin(Objects.isNull(printBoard.getIsPin()) ? 0 :printBoard.getIsPin());
if (CollectionUtil.isNotEmpty(printBoards)) {
printBoards.forEach(printBoard -> {
CollectionElement collectionElement = CopyUtil.copyObject(printBoard, CollectionElement.class);
collectionElement.setHasPin(Objects.isNull(printBoard.getIsPin()) ? 0 : printBoard.getIsPin());
collectionElement.setId(printBoard.getId());
collectionElementMapper.updateById(collectionElement);
});
@@ -630,7 +634,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
@Transactional
@Override
public void relationCollection(List<Long> elementIds, Long collectionId) {
if (CollectionUtils.isEmpty(elementIds) || null == collectionId){
if (CollectionUtils.isEmpty(elementIds) || null == collectionId) {
return;
}
QueryWrapper<CollectionElement> queryWrapper = new QueryWrapper<>();
@@ -652,34 +656,35 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
}
return CopyUtil.copyList(colorElements, CollectionElementVO.class);
}
@Override
public void refreshHistoryData() {
//幂等
if(!CollectionUtils.isEmpty(tCollectionElementRelationService.getByCollectionId(1083L))){
if (!CollectionUtils.isEmpty(tCollectionElementRelationService.getByCollectionId(1083L))) {
return;
}
// 分页数据
QueryWrapper<CollectionElement> queryWrapper = new QueryWrapper<>();
queryWrapper.orderByAsc("id");
PageQueryBaseVo pageQuery = new PageQueryBaseVo();
PageQueryBaseVo pageQuery = new PageQueryBaseVo();
pageQuery.setPage(1);
pageQuery.setSize(200);
while(true){
while (true) {
IPage<CollectionElement> page = getBaseMapper().selectPage(
new Page<>(pageQuery.getPage(), pageQuery.getSize()), queryWrapper);
List<CollectionElement> list = page.getRecords();
if(CollectionUtils.isEmpty(list)){
if (CollectionUtils.isEmpty(list)) {
break;
}
//保存
List<TCollectionElementRelation> relations = list.stream().map(element->
TCollectionElementRelation.builder().elementId(element.getId())
.collectionId(element.getCollectionId()).createDate(new Date()).build())
List<TCollectionElementRelation> relations = list.stream().map(element ->
TCollectionElementRelation.builder().elementId(element.getId())
.collectionId(element.getCollectionId()).createDate(new Date()).build())
.collect(Collectors.toList());
tCollectionElementRelationService.saveBatch(relations);
pageQuery.setPage(pageQuery.getPage()+1);
log.info("refreshHistoryData###process###page###"+pageQuery.getPage());
pageQuery.setPage(pageQuery.getPage() + 1);
log.info("refreshHistoryData###process###page###" + pageQuery.getPage());
}
}
@@ -694,7 +699,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
if (StringUtils.isEmpty(color.getName())) {
element.setName(null);
} else {
element.setName(color.getId()+"_"+color.getName()+"_"+color.getTcx());
element.setName(color.getId() + "_" + color.getName() + "_" + color.getTcx());
}
element.setLevel1Type(CollectionLevel1TypeEnum.COLOR_BOARD.getRealName());
element.setHasPin((byte) 0);
@@ -711,13 +716,14 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
@Override
public List<CollectionElement> getByCollectionId(Long collectionId) {
List<Long> elementIds = tCollectionElementRelationService.getByCollectionId(collectionId);
if (CollectionUtils.isEmpty(elementIds)){
if (CollectionUtils.isEmpty(elementIds)) {
return null;
}
QueryWrapper<CollectionElement> queryWrapper = new QueryWrapper<>();
queryWrapper.in("id", elementIds);
return collectionElementMapper.selectList(queryWrapper);
}
@Override
public List<CollectionElement> getByOnlyCollectionId(Long collectionId) {
QueryWrapper<CollectionElement> queryWrapper = new QueryWrapper<>();
@@ -745,11 +751,11 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
}
@Override
public CollectionElement editLevel2Type(Long elementId, String level2Type){
public CollectionElement editLevel2Type(Long elementId, String level2Type) {
CollectionElement collectionElement = null;
if(!Objects.isNull(elementId)){
if (!Objects.isNull(elementId)) {
collectionElement = collectionElementMapper.selectById(elementId);
if (StringUtil.isNullOrEmpty(collectionElement.getLevel2Type()) || !(collectionElement.getLevel2Type()).equals(level2Type)){
if (StringUtil.isNullOrEmpty(collectionElement.getLevel2Type()) || !(collectionElement.getLevel2Type()).equals(level2Type)) {
collectionElement.setLevel2Type(level2Type);
updateById(collectionElement);
}

View File

@@ -49,7 +49,7 @@ public class CollectionServiceImpl extends ServiceImpl<CollectionMapper, Collect
@Transactional
@Override
public Long saveCollection(Long accountId,String timeZone,String moodTemplateId ) {
public Long saveCollection(Long accountId, String timeZone, String moodTemplateId) {
Collection collection = new Collection();
collection.setAccountId(accountId);
collection.setCreateDate(DateUtil.getByTimeZone(timeZone));
@@ -71,9 +71,9 @@ public class CollectionServiceImpl extends ServiceImpl<CollectionMapper, Collect
public UserLikeCollectionVO chooseCollection(Long id) {
UserLikeCollectionVO response = new UserLikeCollectionVO();
Collection collection = getById(id);
Assert.notNull(collection,"collection does not exist!");
Assert.notNull(collection, "collection does not exist!");
List<CollectionElement> collectionElements = collectionElementService.getByCollectionId(id);
Assert.notEmpty(collectionElements,"collection element does not exist!");
Assert.notEmpty(collectionElements, "collection element does not exist!");
response.setCollectionId(id);
response.setMoodTemplateId(collection.getMoodTemplateId());
if (collection.getMoodTemplateId() != null) {
@@ -83,28 +83,28 @@ public class CollectionServiceImpl extends ServiceImpl<CollectionMapper, Collect
response.setMoodTemplateUrl(minioUtil.getPresignedUrl(byId.getUrl(), 24 * 60));
}
}
Map<String,List<CollectionElement>> maps = collectionElements
Map<String, List<CollectionElement>> maps = collectionElements
.stream()
.collect(Collectors.groupingBy(CollectionElement::getLevel1Type));
maps.forEach((k,v)->{
maps.forEach((k, v) -> {
CollectionLevel1TypeEnum level1TypeEnum = CollectionLevel1TypeEnum.uploadOf(k);
Assert.notNull(level1TypeEnum,"unknown level1TypeEnum!");
switch (level1TypeEnum){
Assert.notNull(level1TypeEnum, "unknown level1TypeEnum!");
switch (level1TypeEnum) {
case MOOD_BOARD:
response.setMoodBoards(CopyUtil.copyList(v,CollectionElementVO.class,(o,d)->{
response.setMoodBoards(CopyUtil.copyList(v, CollectionElementVO.class, (o, d) -> {
d.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
d.setUrl(minioUtil.getPresignedUrl(o.getUrl(), 24 * 60));
}));
break;
case PRINT_BOARD:
response.setPrintBoards(CopyUtil.copyList(v,CollectionElementVO.class,(o,d)->{
response.setPrintBoards(CopyUtil.copyList(v, CollectionElementVO.class, (o, d) -> {
d.setIsPin(o.getHasPin());
d.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
d.setUrl(minioUtil.getPresignedUrl(o.getUrl(), 24 * 60));
}));
break;
case SKETCH_BOARD:
response.setSketchBoards(CopyUtil.copyList(v,CollectionElementVO.class,(o,d) ->{
response.setSketchBoards(CopyUtil.copyList(v, CollectionElementVO.class, (o, d) -> {
d.setIsPin(o.getHasPin());
d.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
d.setUrl(minioUtil.getPresignedUrl(o.getUrl(), 24 * 60));
@@ -114,7 +114,7 @@ public class CollectionServiceImpl extends ServiceImpl<CollectionMapper, Collect
response.setColorBoards(resolveColorBoard(v));
break;
case MARKETING_SKETCH:
response.setMarketingSketchs(CopyUtil.copyList(v,CollectionElementVO.class,(o,d)->{
response.setMarketingSketchs(CopyUtil.copyList(v, CollectionElementVO.class, (o, d) -> {
d.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
}));
break;
@@ -123,15 +123,16 @@ public class CollectionServiceImpl extends ServiceImpl<CollectionMapper, Collect
});
return response;
}
private List<CollectionColorVO> resolveColorBoard(List<CollectionElement> collectionElements){
return CopyUtil.copyList(collectionElements,CollectionColorVO.class,(o,d) ->{
private List<CollectionColorVO> resolveColorBoard(List<CollectionElement> collectionElements) {
return CopyUtil.copyList(collectionElements, CollectionColorVO.class, (o, d) -> {
String name = o.getName();
if (StringUtils.isBlank(name)){
if (StringUtils.isBlank(name)) {
d.setId(null);
d.setName(null);
}else {
} else {
String[] idName = name.split("_");
if (idName.length >1){
if (idName.length > 1) {
d.setId(StringUtil.isNullOrEmpty(idName[0]) ? null : Integer.valueOf(idName[0]));
d.setName(idName[1]);
d.setTcx(idName[2]);

View File

@@ -16,20 +16,20 @@ public class DesignItemDetailPrintServiceImpl extends ServiceImpl<DesignItemDeta
@Override
public List<DesignItemDetailPrint> getByDesignItemDetailId(Long designItemDetailId){
public List<DesignItemDetailPrint> getByDesignItemDetailId(Long designItemDetailId) {
QueryWrapper<DesignItemDetailPrint> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("design_item_detail_id",designItemDetailId);
queryWrapper.eq("design_item_detail_id", designItemDetailId);
return baseMapper.selectList(queryWrapper);
}
@Override
public void deleteByDesignItemDetailId(Long designItemDetailId){
public void deleteByDesignItemDetailId(Long designItemDetailId) {
UpdateWrapper<DesignItemDetailPrint> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("design_item_detail_id", designItemDetailId);
updateWrapper.set("is_deleted",(byte)1);
updateWrapper.set("is_deleted", (byte) 1);
baseMapper.update(null,updateWrapper);
baseMapper.update(null, updateWrapper);
}
}

View File

@@ -47,8 +47,8 @@ public class DesignItemDetailServiceImpl extends ServiceImpl<DesignItemDetailMap
UpdateWrapper<DesignItemDetail> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("design_item_id", designItemId);
updateWrapper.set("is_deleted",(byte)1);
return designItemDetailMapper.update(null,updateWrapper);
updateWrapper.set("is_deleted", (byte) 1);
return designItemDetailMapper.update(null, updateWrapper);
}
@Override

View File

@@ -72,7 +72,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
@Override
public Long saveOne(DesignItem designItem) {
if(designItemMapper.insertDesignItem(designItem) <= 0){
if (designItemMapper.insertDesignItem(designItem) <= 0) {
throw new BusinessException("save designItem failed!");
}
return designItem.getId();
@@ -85,153 +85,155 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
DesignItem designItem = new DesignItem();
designItem.setCollectionId(0L);
return designItemMapper.update(designItem,queryWrapper);
return designItemMapper.update(designItem, queryWrapper);
}
@Override
public List<DesignItem> getByDesignId(Long designId) {
QueryWrapper<DesignItem> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("design_id", designId);
queryWrapper.eq("is_like", (byte)0);
queryWrapper.eq("is_like", (byte) 0);
return designItemMapper.selectList(queryWrapper);
}
@Override
public void updateLikeStatus(Long designItemId,Byte hasLike) {
public void updateLikeStatus(Long designItemId, Byte hasLike) {
QueryWrapper<DesignItem> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id", designItemId);
DesignItem designItem =new DesignItem();
DesignItem designItem = new DesignItem();
designItem.setHasLike(hasLike);
designItemMapper.update(designItem,queryWrapper);
designItemMapper.update(designItem, queryWrapper);
}
@Override
public void updateDesignHighUrl(Long designItemId, String highUrl,String timeZone) {
public void updateDesignHighUrl(Long designItemId, String highUrl, String timeZone) {
QueryWrapper<DesignItem> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id", designItemId);
DesignItem designItem =new DesignItem();
DesignItem designItem = new DesignItem();
designItem.setHighDesignUrl(highUrl);
designItem.setUpdateDate(DateUtil.getByTimeZone(timeZone));
designItemMapper.update(designItem,queryWrapper);
designItemMapper.update(designItem, queryWrapper);
}
@Override
public GetNextSysElementVO getNextSysElement(Long id, String level2Type, String operateType) {
//校验
if(! DesignPythonItem.SYS_HAIRSTYLE_SHOES_BODY.contains(level2Type)){
if (!DesignPythonItem.SYS_HAIRSTYLE_SHOES_BODY.contains(level2Type)) {
throw new BusinessException("unknown type! ");
}
List<String> operateTypes = Arrays.asList("PREV","NEXT");
if(! operateTypes.contains(operateType)){
List<String> operateTypes = Arrays.asList("PREV", "NEXT");
if (!operateTypes.contains(operateType)) {
throw new BusinessException("unknown operateType! ");
}
Assert.notNull(id,"id cannot be empty!");
Assert.notNull(id, "id cannot be empty!");
Long maxId = sysFileService.getMaxIdByLevel2Type(level2Type, null);
Long minId = sysFileService.getMinIdByLevel2Type(level2Type, null);
if(id > maxId || id <minId){
if (id > maxId || id < minId) {
throw new BusinessException("The id value is out of range!");
}
Long idValue = null;
if("PREV".equals(operateType)){
if(minId.equals(id)){
if ("PREV".equals(operateType)) {
if (minId.equals(id)) {
idValue = minId;
}else{
idValue = id -1;
} else {
idValue = id - 1;
}
}
if("NEXT".equals(operateType)){
if(maxId.equals(id)){
if ("NEXT".equals(operateType)) {
if (maxId.equals(id)) {
idValue = maxId;
}else{
idValue = id +1;
} else {
idValue = id + 1;
}
}
SysFileVO sysFileVO = sysFileService.getById(idValue);
return new GetNextSysElementVO(sysFileVO.getId(),level2Type,sysFileVO.getUrl());
return new GetNextSysElementVO(sysFileVO.getId(), level2Type, sysFileVO.getUrl());
}
@Override
public DesignCollectionItemVO designSingle(DesignSingleDTO designSingleDTO) {
AuthPrincipalVo userInfo = UserContext.getUserHolder();
DesignItem designItem = selectById(designSingleDTO.getDesignItemId());
Assert.notNull(designItem,"design item does not exists!");
Assert.notNull(designItem, "design item does not exists!");
Design design = designService.getById(designItem.getDesignId());
Assert.notNull(design,"design does not exists!");
Assert.notNull(design, "design does not exists!");
DesignLibraryModelPointVO designLibraryModelPointVO = null;
if (Objects.nonNull(design.getTemplateId())){
if (Objects.nonNull(design.getTemplateId())) {
LibraryModelPoint modelPoint = libraryModelPointService.getById(design.getTemplateId());
Assert.notNull(modelPoint,"template does not exists!");
Assert.notNull(modelPoint, "template does not exists!");
Library library = libraryService.getById(modelPoint.getRelationId());
// ??和上面重复
Assert.notNull(modelPoint,"template does not exists!");
designLibraryModelPointVO = collectionElementService.calculateTemplatePoint(modelPoint,library.getHigh(),library.getWidth(),library.getUrl());
Assert.notNull(modelPoint, "template does not exists!");
designLibraryModelPointVO = collectionElementService.calculateTemplatePoint(modelPoint, library.getHigh(), library.getWidth(), library.getUrl());
}
Set<String> newTypes = designSingleDTO.getClothes().stream().map(DesignSingleItemDTO::getType).collect(Collectors.toSet());
//校验category
validateCategory(newTypes,design.getSingleOverall(),design.getSwitchCategory());
DesignPythonObjects objects =pythonService.covertDesignSingleParam(
designSingleDTO,design.getSingleOverall(),design.getSwitchCategory(),designLibraryModelPointVO);
validateCategory(newTypes, design.getSingleOverall(), design.getSwitchCategory());
DesignPythonObjects objects = pythonService.covertDesignSingleParam(
designSingleDTO, design.getSingleOverall(), design.getSwitchCategory(), designLibraryModelPointVO);
pythonService.design(objects);
//designSingle
DesignCollectionItemVO response = saveSingleDesignItemAndDetail(objects,design.getId(),designSingleDTO.getDesignItemId(),
design.getCollectionId(),userInfo,designSingleDTO.getTimeZone());
DesignCollectionItemVO response = saveSingleDesignItemAndDetail(objects, design.getId(), designSingleDTO.getDesignItemId(),
design.getCollectionId(), userInfo, designSingleDTO.getTimeZone());
// ??
designItem.setDesignUrl(response.getDesignItemUrl());
return response;
}
private LibraryModelPointVO resloveVoByModelPoint(LibraryModelPoint modelPoint,Library library){
LibraryModelPointVO libraryModelPointVO = CopyUtil.copyObject(modelPoint,LibraryModelPointVO.class);
private LibraryModelPointVO resloveVoByModelPoint(LibraryModelPoint modelPoint, Library library) {
LibraryModelPointVO libraryModelPointVO = CopyUtil.copyObject(modelPoint, LibraryModelPointVO.class);
libraryModelPointVO.setTemplateId(modelPoint.getId());
libraryModelPointVO.setHandLeft(JSON.parseObject(modelPoint.getHandLeft(),List.class));
libraryModelPointVO.setHandRight(JSON.parseObject(modelPoint.getHandRight(),List.class));
libraryModelPointVO.setShoulderRight(JSON.parseObject(modelPoint.getShoulderRight(),List.class));
libraryModelPointVO.setShoulderLeft(JSON.parseObject(modelPoint.getShoulderLeft(),List.class));
libraryModelPointVO.setWaistbandRight(JSON.parseObject(modelPoint.getWaistbandRight(),List.class));
libraryModelPointVO.setWaistbandLeft(JSON.parseObject(modelPoint.getWaistbandLeft(),List.class));
libraryModelPointVO.setHandLeft(JSON.parseObject(modelPoint.getHandLeft(), List.class));
libraryModelPointVO.setHandRight(JSON.parseObject(modelPoint.getHandRight(), List.class));
libraryModelPointVO.setShoulderRight(JSON.parseObject(modelPoint.getShoulderRight(), List.class));
libraryModelPointVO.setShoulderLeft(JSON.parseObject(modelPoint.getShoulderLeft(), List.class));
libraryModelPointVO.setWaistbandRight(JSON.parseObject(modelPoint.getWaistbandRight(), List.class));
libraryModelPointVO.setWaistbandLeft(JSON.parseObject(modelPoint.getWaistbandLeft(), List.class));
return libraryModelPointVO;
}
@Override
public String printDot(DesignSingleDTO designSingleDTO) {
DesignItem designItem = selectById(designSingleDTO.getDesignItemId());
Assert.notNull(designItem,"design item does not exists!");
Assert.notNull(designItem, "design item does not exists!");
Design design = designService.getById(designItem.getDesignId());
Assert.notNull(design,"design does not exists!");
Assert.notNull(design, "design does not exists!");
DesignLibraryModelPointVO designLibraryModelPointVO = null;
if (Objects.nonNull(design.getTemplateId())){
if (Objects.nonNull(design.getTemplateId())) {
LibraryModelPoint modelPoint = libraryModelPointService.getById(design.getTemplateId());
Assert.notNull(modelPoint,"template does not exists!");
Assert.notNull(modelPoint, "template does not exists!");
Library library = libraryService.getById(modelPoint.getRelationId());
Assert.notNull(modelPoint,"template does not exists!");
designLibraryModelPointVO = collectionElementService.calculateTemplatePoint(modelPoint,library.getHigh(),library.getWidth(),library.getUrl());
Assert.notNull(modelPoint, "template does not exists!");
designLibraryModelPointVO = collectionElementService.calculateTemplatePoint(modelPoint, library.getHigh(), library.getWidth(), library.getUrl());
}
Set<String> newTypes = designSingleDTO.getClothes().stream().map(DesignSingleItemDTO::getType).collect(Collectors.toSet());
//校验category
validateCategory(newTypes,design.getSingleOverall(),design.getSwitchCategory());
DesignPythonObjects objects =pythonService.covertDesignSingleParam(
designSingleDTO,design.getSingleOverall(),design.getSwitchCategory(),designLibraryModelPointVO);
validateCategory(newTypes, design.getSingleOverall(), design.getSwitchCategory());
DesignPythonObjects objects = pythonService.covertDesignSingleParam(
designSingleDTO, design.getSingleOverall(), design.getSwitchCategory(), designLibraryModelPointVO);
pythonService.design(objects);
return objects.getObjects().get(0).getBasic().getSave_name();
}
private void validateCategory(Set<String> newTypes, String singleOverall, String switchCategory) {
if(SingleOverallEnum.SINGLE.getRealName().equals(singleOverall) ){
if(newTypes.size() >1){
if (SingleOverallEnum.SINGLE.getRealName().equals(singleOverall)) {
if (newTypes.size() > 1) {
throw new BusinessException("Wrong clothes type !");
}
//一个的时候
if(!switchCategory.equals(CollectionUtil.newArrayList(newTypes).get(0))){
if (!switchCategory.equals(CollectionUtil.newArrayList(newTypes).get(0))) {
throw new BusinessException("Wrong clothes type !");
}
}
}
private DesignCollectionItemVO saveSingleDesignItemAndDetail(DesignPythonObjects pythonObjects
, Long designId,Long designItemId, Long collectionId, AuthPrincipalVo userInfo, String timeZone){
, Long designId, Long designItemId, Long collectionId, AuthPrincipalVo userInfo, String timeZone) {
DesignCollectionItemVO response = new DesignCollectionItemVO();
response.setDesignItemId(designItemId);
@@ -247,40 +249,40 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
designItemDetailService.deleteByDesignItemId(designItemId);
List<DesignItemDetail> designItemDetails = Lists.newArrayList();
pythonObjects.getObjects().get(0).getItems().forEach(detail ->{
if(null == detail){
pythonObjects.getObjects().get(0).getItems().forEach(detail -> {
if (null == detail) {
return;
}
DesignItemDetail designItemDetail = CopyUtil.copyObject(detail,DesignItemDetail.class);
DesignItemDetail designItemDetail = CopyUtil.copyObject(detail, DesignItemDetail.class);
designItemDetail.setAccountId(userInfo.getId());
designItemDetail.setDesignId(designId);
designItemDetail.setDesignItemId(designItemId);
designItemDetail.setCollectionElementId(detail.getElementId());
designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone));
if(SysFileLevel2TypeEnum.BODY.getRealName().equals(detail.getType())){
if (SysFileLevel2TypeEnum.BODY.getRealName().equals(detail.getType())) {
designItemDetail.setPath(detail.getBody_path());
//BODY不关联businessId
designItemDetail.setBusinessId(0L);
}
designItemDetail.setIconPath(detail.getIcon());
DesignPythonItemPrint printObject = detail.getPrint();
designItemDetail.setPrintPath(Objects.isNull(printObject)? "" :printObject.getPath());
designItemDetail.setPrintPath(Objects.isNull(printObject) ? "" : printObject.getPath());
designItemDetail.setPrintJson(JSON.toJSONString(printObject));
designItemDetails.add(designItemDetail);
});
designItemDetailService.saveBatch(designItemDetails);
//封装item信息
List<DesignCollectionItemVO> designCollectionItems = CopyUtil.copyList(getByDesignId(designId)
,DesignCollectionItemVO.class,(o,d) ->{
d.setDesignItemId(o.getId());
d.setDesignItemUrl(o.getDesignUrl());
, DesignCollectionItemVO.class, (o, d) -> {
d.setDesignItemId(o.getId());
d.setDesignItemUrl(o.getDesignUrl());
});
return response;
}
private List<TDesignPythonOutfitDetail> saveDesignSingleItemDetailAndLayers(DesignPythonObjects pythonObjects
, Long designId,Long designItemId, AuthPrincipalVo userInfo
, JSONObject outfit, String timeZone,List<DesignSingleItemDTO> designSingleItemDTOList){
, Long designId, Long designItemId, AuthPrincipalVo userInfo
, JSONObject outfit, String timeZone, List<DesignSingleItemDTO> designSingleItemDTOList) {
DesignItem designItem = new DesignItem();
// String url = pythonObjects.getObjects().get(0).getBasic().getSave_name();
@@ -293,24 +295,24 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
designItemDetailService.deleteByDesignItemId(designItemId);
List<DesignItemDetail> designItemDetails = Lists.newArrayList();
// 3、保存新的designItemDetail
pythonObjects.getObjects().get(0).getItems().forEach(detail ->{
if(null == detail){
pythonObjects.getObjects().get(0).getItems().forEach(detail -> {
if (null == detail) {
return;
}
DesignItemDetail designItemDetail = CopyUtil.copyObject(detail,DesignItemDetail.class);
DesignItemDetail designItemDetail = CopyUtil.copyObject(detail, DesignItemDetail.class);
designItemDetail.setAccountId(userInfo.getId());
designItemDetail.setDesignId(designId);
designItemDetail.setDesignItemId(designItemId);
designItemDetail.setCollectionElementId(detail.getElementId());
designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone));
if(SysFileLevel2TypeEnum.BODY.getRealName().equals(detail.getType())){
if (SysFileLevel2TypeEnum.BODY.getRealName().equals(detail.getType())) {
designItemDetail.setPath(detail.getBody_path());
//BODY不关联businessId
designItemDetail.setBusinessId(0L);
}
designItemDetail.setIconPath(detail.getIcon());
DesignPythonItemPrint printObject = detail.getPrint();
designItemDetail.setPrintPath(Objects.isNull(printObject)? "" :printObject.getPath());
designItemDetail.setPrintPath(Objects.isNull(printObject) ? "" : printObject.getPath());
// 当有多个印花后返回的printObject太长导致存储到数据库时报错
// designItemDetail.setPrintJson(JSON.toJSONString(printObject));
designItemDetails.add(designItemDetail);
@@ -337,7 +339,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
// 需要将request中的offset也存入数据库通过type与image_category将sketch与layers关联
Map<String, List<Long>> typeOffset = designSingleItemDTOList.stream()
.collect(Collectors.toMap(d -> d.getType().toLowerCase(), DesignSingleItemDTO::getOffset));
List<TDesignPythonOutfitDetail> list = setTDesignPythonOutfitDetailList(layers, designId, designPythonOutfit.getId(), userInfo.getId(),typeOffset);
List<TDesignPythonOutfitDetail> list = setTDesignPythonOutfitDetailList(layers, designId, designPythonOutfit.getId(), userInfo.getId(), typeOffset);
designPythonOutfitDetailService.saveBatch(list);
@@ -346,7 +348,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
public List<TDesignPythonOutfitDetail> setTDesignPythonOutfitDetailList(JSONArray layers, Long designId,
Long designPythonOutfitId, Long userId,
Map<String, List<Long>> typeOffset){
Map<String, List<Long>> typeOffset) {
// 设置图层信息;
List<TDesignPythonOutfitDetail> list = new ArrayList<>();
for (int i = 0; i < layers.size(); i++) {
@@ -383,13 +385,13 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
public DesignSingleVO designSingleIncludeLayers(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO) {
AuthPrincipalVo userInfo = UserContext.getUserHolder();
DesignItem designItem = selectById(designSingleIncludeLayersDTO.getDesignItemId());
Assert.notNull(designItem,"design item does not exists!");
Assert.notNull(designItem, "design item does not exists!");
Design design = designService.getById(designItem.getDesignId());
Assert.notNull(design,"design does not exists!");
Assert.notNull(design, "design does not exists!");
DesignLibraryModelPointVO designLibraryModelPointVO = null;
// 设置模特
if (Objects.nonNull(design.getTemplateId())){
if (Objects.nonNull(design.getTemplateId())) {
// LibraryModelPoint modelPoint = libraryModelPointService.getById(design.getTemplateId());
// Assert.notNull(modelPoint,"template does not exists!");
// Library library = libraryService.getById(modelPoint.getRelationId());
@@ -397,28 +399,28 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
String modelUrl;
Integer high;
Integer width;
if (design.getModelType().equals(ModelType.SYSTEM.getValue())){
if (design.getModelType().equals(ModelType.SYSTEM.getValue())) {
SysFileVO sysFile = sysFileService.getById(design.getTemplateId());
Assert.notNull(sysFile,"model does not exists!");
Assert.notNull(sysFile, "model does not exists!");
modelUrl = sysFile.getUrl();
high = 1050;
width = 500;
}else{
} else {
Library libFile = libraryService.getById(design.getTemplateId());
Assert.notNull(libFile,"model does not exists!");
Assert.notNull(libFile, "model does not exists!");
modelUrl = libFile.getUrl();
high = libFile.getHigh();
width = libFile.getWidth();
}
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(design.getTemplateId(),design.getModelType());
Assert.notNull(modelPoint,"The model has not been tagged");
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(design.getTemplateId(), design.getModelType());
Assert.notNull(modelPoint, "The model has not been tagged");
designLibraryModelPointVO = collectionElementService.calculateTemplatePoint(modelPoint,high,width,modelUrl);
designLibraryModelPointVO = collectionElementService.calculateTemplatePoint(modelPoint, high, width, modelUrl);
}
// 组装入参
DesignPythonObjects objects =pythonService.covertDesignSingleParam(
designSingleIncludeLayersDTO,design.getSingleOverall(),design.getSwitchCategory(),designLibraryModelPointVO);
DesignPythonObjects objects = pythonService.covertDesignSingleParam(
designSingleIncludeLayersDTO, design.getSingleOverall(), design.getSwitchCategory(), designLibraryModelPointVO);
// design
JSONObject jsonObject = pythonService.designNew(objects);
// preview -> 不存数据库 submit -> 存数据库
@@ -431,27 +433,27 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
// 通过type将offset关联到layers
Map<String, List<Long>> typeOffset = designSingleIncludeLayersDTO.getDesignSingleItemDTOList().stream()
.collect(Collectors.toMap(d -> d.getType().toLowerCase(), DesignSingleItemDTO::getOffset));
if (!designSingleIncludeLayersDTO.getIsPreview()){
if (!designSingleIncludeLayersDTO.getIsPreview()) {
// 更新及保存图层信息
tDesignPythonOutfitDetails = saveDesignSingleItemDetailAndLayers(objects, design.getId(), designSingleIncludeLayersDTO.getDesignItemId(),
userInfo, outfit, designSingleIncludeLayersDTO.getTimeZone(),designSingleIncludeLayersDTO.getDesignSingleItemDTOList());
}else {
userInfo, outfit, designSingleIncludeLayersDTO.getTimeZone(), designSingleIncludeLayersDTO.getDesignSingleItemDTOList());
} else {
JSONArray layers = outfit.getJSONArray("layers");
tDesignPythonOutfitDetails = setTDesignPythonOutfitDetailList(layers,designItem.getDesignId(),null,userInfo.getId(),typeOffset);
tDesignPythonOutfitDetails = setTDesignPythonOutfitDetailList(layers, designItem.getDesignId(), null, userInfo.getId(), typeOffset);
}
List<DesignPythonOutfitVO> detailsVO = new ArrayList<>();
tDesignPythonOutfitDetails.forEach(detail -> {
String type = detail.getImageCategory().split("_")[0];
detailsVO.add(designPythonOutfitDetailService.convertToDesignPythonOutfitVO(detail,typeOffset.get(type)));
detailsVO.add(designPythonOutfitDetailService.convertToDesignPythonOutfitVO(detail, typeOffset.get(type)));
});
TDesignPythonOutfit designPythonOutfit = designPythonOutfitService.getByDesignItemId(designSingleIncludeLayersDTO.getDesignItemId());
Assert.notNull(designItem,"design item detail layers does not exists!");
Assert.notNull(designItem, "design item detail layers does not exists!");
return assembleDesignSingleResponse(designItem.getId(),
minioUtil.getPresignedUrl(designPythonOutfit.getDesignUrl(),24 * 60),
minioUtil.getPresignedUrl(designPythonOutfit.getDesignUrl(), 24 * 60),
outfit.getString("synthesis_url"),
designSingleIncludeLayersDTO.getDesignSingleItemDTOList(),
detailsVO);
@@ -462,14 +464,14 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
ComposeLayersVO designItemLayer = positionAndScaleVO.getLayers();
// 1、校验designItem是是否存在
DesignItem designItem = selectById(designItemLayer.getDesignItemId());
Assert.notNull(designItem,"designItem does not exists!");
Assert.notNull(designItem, "designItem does not exists!");
TDesignPythonOutfit designPythonOutfit = designPythonOutfitService.getByDesignItemId(designItemLayer.getDesignItemId());
Assert.notNull(designPythonOutfit,"layers does not exists!");
Assert.notNull(designPythonOutfit, "layers does not exists!");
// 2、校验layers是否存在
designItemLayer.getLayers().forEach(layer -> {
TDesignPythonOutfitDetail detail = designPythonOutfitDetailService.getById(layer.getId());
Assert.notNull(detail,layer.getImageCategory() + " layer does not exists!");
Assert.notNull(detail, layer.getImageCategory() + " layer does not exists!");
/*layer.setImageUrl(detail.getImageUrl());
layer.setMaskUrl(detail.getMaskUrl());*/
@@ -480,7 +482,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
// 4、合成图层
String synthesisUrl = pythonService.composeLayers(outfitDetailPythonItems);
designItemLayer.setDesignItemUrl(minioUtil.getPresignedUrl(synthesisUrl,24 * 60));
designItemLayer.setDesignItemUrl(minioUtil.getPresignedUrl(synthesisUrl, 24 * 60));
// 5、更新数据库根据designItemId更新designItemUrl
designItem.setUpdateDate(DateUtil.getByTimeZone(positionAndScaleVO.getTimeZone()));
@@ -514,20 +516,20 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
imageSize.add((long) (layer.getImageSize().get(i) * layer.getScale()));
}
layer.setImageSize(imageSize);
if (!StringUtil.isNullOrEmpty(layer.getImageUrl())){
layer.setImageUrl(minioUtil.getPresignedUrl(layer.getImageUrl(),24 * 60));
if (!StringUtil.isNullOrEmpty(layer.getImageUrl())) {
layer.setImageUrl(minioUtil.getPresignedUrl(layer.getImageUrl(), 24 * 60));
}
if (!StringUtil.isNullOrEmpty(layer.getMaskUrl())){
layer.setMaskUrl(minioUtil.getPresignedUrl(layer.getMaskUrl(),24 * 60));
if (!StringUtil.isNullOrEmpty(layer.getMaskUrl())) {
layer.setMaskUrl(minioUtil.getPresignedUrl(layer.getMaskUrl(), 24 * 60));
}
});
return designItemLayer;
}
private DesignSingleVO assembleDesignSingleResponse(Long designItemId,String designItemUrl,
private DesignSingleVO assembleDesignSingleResponse(Long designItemId, String designItemUrl,
String currentFullBodyView,
List<DesignSingleItemDTO> designSingleItemDTOList,
List<DesignPythonOutfitVO> layersObject){
List<DesignPythonOutfitVO> layersObject) {
DesignSingleVO designSingleVO = new DesignSingleVO();
ArrayList<DesignItemClothesDetailVO> clothes = new ArrayList<>();
@@ -536,14 +538,15 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
// 图片用于修改前后的一键对比
designSingleVO.setDesignItemUrl(designItemUrl);
// 当前全身图
designSingleVO.setCurrentFullBodyView(minioUtil.getPresignedUrl(currentFullBodyView,24 * 60));;
designSingleVO.setCurrentFullBodyView(minioUtil.getPresignedUrl(currentFullBodyView, 24 * 60));
;
designSingleVO.setClothes(clothes);
designSingleItemDTOList.forEach(singleItem -> {
DesignItemClothesDetailVO designItemClothesDetailVO = new DesignItemClothesDetailVO();
designItemClothesDetailVO.setId(singleItem.getId());
designItemClothesDetailVO.setType(singleItem.getType());
designItemClothesDetailVO.setPath(minioUtil.getPresignedUrl(singleItem.getPath(),24 * 60));
designItemClothesDetailVO.setPath(minioUtil.getPresignedUrl(singleItem.getPath(), 24 * 60));
designItemClothesDetailVO.setMinIOPath(singleItem.getPath());
designItemClothesDetailVO.setColor(panToneService.getPantoneByRgb(singleItem.getColor()));
// designItemClothesDetailVO.setPrintObject(new DesignPythonItemPrint(singleItem.getPrintObject().getPath()));
@@ -562,7 +565,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
private List<DesignItemDetailPrint> setDesignItemDetailPrintList(List<DesignItemDetail> designItemDetails,
List<DesignSingleItemDTO> designSingleItemDTOList,
String timeZone){
String timeZone) {
Map<String, Long> designItemDetailTypeIdMap = designItemDetails.stream().collect(Collectors.toMap(DesignItemDetail::getType, DesignItemDetail::getId));
ArrayList<DesignItemDetailPrint> designItemDetailPrints = new ArrayList<>();
@@ -571,14 +574,14 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
// 1、判断有无印花无印花则跳过
DesignSinglePrintDTO printObject = designSingleItem.getPrintObject();
if (printObject.getIfSingle().equals(Boolean.FALSE)
&& CollectionUtil.isEmpty(printObject.getPrints()) ){
&& CollectionUtil.isEmpty(printObject.getPrints())) {
return;
}else {
} else {
// 2、有印花添加到list
printObject.getPrints().forEach(print -> {
// 2.1 判断是否第一次添加印花,是:直接添加
List<DesignItemDetailPrint> designItemDetailPrintList = designItemDetailPrintService.getByDesignItemDetailId(designItemDetailTypeIdMap.get(designSingleItem.getType()));
if (!designItemDetailPrintList.isEmpty()){
if (!designItemDetailPrintList.isEmpty()) {
// 2.2 否:先删除原始印花,再添加新印花信息
designItemDetailPrintService.deleteByDesignItemDetailId(designItemDetailTypeIdMap.get(designSingleItem.getType()));
}
@@ -599,10 +602,10 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
return designItemDetailPrints;
}
private List<OutfitDetailPythonItem> convertToOutfitDetailPythonItemList(List<DesignPythonOutfitVO> layers){
private List<OutfitDetailPythonItem> convertToOutfitDetailPythonItemList(List<DesignPythonOutfitVO> layers) {
List<OutfitDetailPythonItem> composeLayerPythonItem = Arrays.asList(new OutfitDetailPythonItem[layers.size()]);
layers.forEach(layer -> {
composeLayerPythonItem.set(layer.getPriority() - 1,new OutfitDetailPythonItem(layer.getImageCategory(),
composeLayerPythonItem.set(layer.getPriority() - 1, new OutfitDetailPythonItem(layer.getImageCategory(),
layer.getPosition(),
layer.getImageSize(),
layer.getScale(),

View File

@@ -457,7 +457,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
String synthesisUrl = outfit.getString("synthesis_url");
if (!StringUtils.isEmpty(synthesisUrl)) {
designPythonOutfit.setDesignUrl(synthesisUrl);
}else {
} else {
throw new BusinessException("design python response synthesis_url is null");
}
designPythonOutfitService.save(designPythonOutfit);
@@ -487,7 +487,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
String designUrl = designPythonOutfit.getDesignUrl();
if (!StringUtils.isEmpty(designUrl) && designUrl.contains("/")) {
int firstIndex = designUrl.indexOf("/");
designCollectionItemVO.setDesignOutfitUrl(minIoUtil.getPresignedUrl(designUrl.substring(0,firstIndex) + "/" + designUrl.substring(firstIndex+1), 24 * 60));
designCollectionItemVO.setDesignOutfitUrl(minIoUtil.getPresignedUrl(designUrl.substring(0, firstIndex) + "/" + designUrl.substring(firstIndex + 1), 24 * 60));
}
//response
designCollectionItems.add(designCollectionItemVO);
@@ -688,7 +688,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
qw.lambda().eq(TDesignPythonOutfit::getDesignItemId, designLikeDTO.getDesignItemId());
List<TDesignPythonOutfit> tDesignPythonOutfits = designPythonOutfitMapper.selectList(qw);
if (CollectionUtils.isEmpty(tDesignPythonOutfits)) {
throw new BusinessException("DesignItemId not found elements for ax elements to like! ["+designLikeDTO.getDesignItemId());
throw new BusinessException("DesignItemId not found elements for ax elements to like! [" + designLikeDTO.getDesignItemId());
}
userLike = resolveUserLike(designLikeDTO.getUserGroupId(), designItem.getDesignId(),
designLikeDTO.getDesignItemId(), designLikeDTO.getDesignPythonOutfitId(), tDesignPythonOutfits.get(0).getDesignUrl(), designLikeDTO.getTimeZone());
@@ -700,7 +700,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
qw.lambda().eq(TDesignPythonOutfit::getDesignItemId, designLikeDTO.getDesignItemId());
List<TDesignPythonOutfit> tDesignPythonOutfits = designPythonOutfitMapper.selectList(qw);
if (CollectionUtils.isEmpty(tDesignPythonOutfits)) {
throw new BusinessException("DesignItemId not found elements for ax elements to like! ["+designLikeDTO.getDesignItemId());
throw new BusinessException("DesignItemId not found elements for ax elements to like! [" + designLikeDTO.getDesignItemId());
}
userLike = resolveUserLike(userGroupId,
designItem.getDesignId(), designLikeDTO.getDesignItemId(), designLikeDTO.getDesignPythonOutfitId(), tDesignPythonOutfits.get(0).getDesignUrl(), designLikeDTO.getTimeZone());
@@ -843,15 +843,15 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
.filter(f -> OUTWEAR_DRESS_BLOUSE.contains(f.getType()) || SKIRT_TROUSERS.contains(f.getType())
|| TOPS.contains(f.getType()) || BOTTOMS.contains(f.getType()))
.collect(Collectors.toList());
response.setClothes(CopyUtil.copyList(filterDetail,DesignItemClothesDetailVO.class,(o,d)->{
response.setClothes(CopyUtil.copyList(filterDetail, DesignItemClothesDetailVO.class, (o, d) -> {
d.setId(o.getId());
d.setPath(minIoUtil.getPresignedUrl(o.getPath(),24 * 60));
d.setPath(minIoUtil.getPresignedUrl(o.getPath(), 24 * 60));
d.setMinIOPath(o.getPath());
d.setLevel1Type(converTypeToLevel1(o.getType()));
// 根据designItemDetailId获取印花
List<DesignItemDetailPrint> prints = designItemDetailPrintService.getByDesignItemDetailId(o.getId());
// 判断有无印花
if (CollectionUtil.isNotEmpty(prints)){
if (CollectionUtil.isNotEmpty(prints)) {
// 有印花
d.setPrintObject(convertToDesignSinglePrintDTO(prints));
}
@@ -870,13 +870,13 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
.collect(Collectors.toList());
response.setOthers(CopyUtil.copyList(filterDetail2, DesignItemOthersDetailVO.class, (o, d) -> {
d.setId(o.getBusinessId());
d.setPath(minIoUtil.getPresignedUrl(o.getPath(),24 * 60));
d.setPath(minIoUtil.getPresignedUrl(o.getPath(), 24 * 60));
d.setMinIOPath(o.getPath());
d.setPrintObject(new DesignPythonItemPrint());
}));
return editDesignItemLayer(flag,designPythonOutfit,
minIoUtil.getPresignedUrl(designPythonOutfit.getDesignUrl(),24 * 60),
editResponseColor(designItemDetails,response));
return editDesignItemLayer(flag, designPythonOutfit,
minIoUtil.getPresignedUrl(designPythonOutfit.getDesignUrl(), 24 * 60),
editResponseColor(designItemDetails, response));
}
@Override
@@ -916,10 +916,10 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
if (response.isSuccessful()) {
try {
String responseBody = response.body().string();
JSONObject responseObject = JSON.parseObject(responseBody);
JSONObject responseObject = JSON.parseObject(responseBody);
String num = responseObject.getString("data");
return Integer.valueOf(num);
}catch (IOException e) {
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@@ -967,6 +967,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
/**
* 避免多次连接数据所这里一次查多条颜色并利用designItemDetailId保持颜色与vo的对应关系
*
* @param designItemDetails
* @param designItemDetailVO
* @return
@@ -1004,16 +1005,16 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
Assert.notEmpty(details, "Some errors occurred, please restart the design");
details.forEach(detail -> {
List<Long> offset = new ArrayList<>();
if (StringUtil.isNullOrEmpty(detail.getOffset()) || detail.getOffset().equals("null")){
offset = Arrays.asList(0L,0L);
}else {
if (StringUtil.isNullOrEmpty(detail.getOffset()) || detail.getOffset().equals("null")) {
offset = Arrays.asList(0L, 0L);
} else {
offset = Arrays.stream(detail.getOffset().replaceAll("\\[|\\]", "").split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
}
detailsVO.add(designPythonOutfitDetailService.convertToDesignPythonOutfitVO(detail,offset));
detailsVO.add(designPythonOutfitDetailService.convertToDesignPythonOutfitVO(detail, offset));
});
// 2、将查询出的图层信息填充到designItemDetailVO中
designItemDetailVO.setDesignItemUrl(minIoUtil.getPresignedUrl(designPythonOutfit.getDesignUrl(),24 * 60));
designItemDetailVO.setDesignItemUrl(minIoUtil.getPresignedUrl(designPythonOutfit.getDesignUrl(), 24 * 60));
// 2.1 填充clothes
designItemDetailVO.getClothes().forEach(c -> {
String type = c.getType().toLowerCase();
@@ -1039,31 +1040,31 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
return designItemDetailVO;
}
private DesignSinglePrintDTO convertToDesignSinglePrintDTO(List<DesignItemDetailPrint> designItemDetailPrints){
private DesignSinglePrintDTO convertToDesignSinglePrintDTO(List<DesignItemDetailPrint> designItemDetailPrints) {
DesignSinglePrintDTO designSinglePrintDTO = new DesignSinglePrintDTO();
List<DesignSinglePrint> prints = new ArrayList<>();
// 只有一个印花
if (designItemDetailPrints.size() == 1){
if (designItemDetailPrints.size() == 1) {
DesignItemDetailPrint detailPrint = designItemDetailPrints.get(0);
DesignSinglePrint designSinglePrint = new DesignSinglePrint();
designSinglePrintDTO.setIfSingle(detailPrint.getSingleOrOverall().equals("single") ? Boolean.TRUE : Boolean.FALSE);
designSinglePrint.setLocation(JSONArray.parseArray(detailPrint.getPosition(),Double.class));
designSinglePrint.setLocation(JSONArray.parseArray(detailPrint.getPosition(), Double.class));
designSinglePrint.setAngle(detailPrint.getAngle());
designSinglePrint.setPriority(detailPrint.getPriority());
designSinglePrint.setPath(minIoUtil.getPresignedUrl(detailPrint.getPath(),24 * 60));
designSinglePrint.setPath(minIoUtil.getPresignedUrl(detailPrint.getPath(), 24 * 60));
designSinglePrint.setMinIOPath(detailPrint.getPath());
designSinglePrint.setScale(detailPrint.getScale());
prints.add(designSinglePrint);
}else {
} else {
// single模式下多个印花
designSinglePrintDTO.setIfSingle(Boolean.TRUE);
designItemDetailPrints.forEach(print -> {
if (print.getSingleOrOverall().equals("single")){
if (print.getSingleOrOverall().equals("single")) {
prints.add(new DesignSinglePrint(
minIoUtil.getPresignedUrl(print.getPath(),24 * 60),
minIoUtil.getPresignedUrl(print.getPath(), 24 * 60),
print.getPath(),
JSONArray.parseArray(print.getPosition(),Double.class),
JSONArray.parseArray(print.getPosition(), Double.class),
print.getScale(),
print.getAngle(),
print.getPriority()));

View File

@@ -31,7 +31,7 @@ import java.io.IOException;
import java.util.*;
@Service
public class GenerateServiceImpl extends ServiceImpl<GenerateMapper,Generate> implements GenerateService {
public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> implements GenerateService {
@Resource
private CollectionElementMapper collectionElementMapper;
@@ -54,9 +54,9 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper,Generate> im
@Override
public GenerateCaptionVO generateCaption(Long sketchElementId) {
CollectionElement collectionElement = collectionElementMapper.selectById(sketchElementId);
Assert.notNull(collectionElement,"System error!Please reselect the sketch");
Assert.notNull(collectionElement, "System error!Please reselect the sketch");
Assert.isTrue("Sketchboard".equals(collectionElement.getLevel1Type()) && !StringUtil.isNullOrEmpty(collectionElement.getUrl())
,"System error!Please reselect the sketch");
, "System error!Please reselect the sketch");
String url = collectionElement.getUrl();
// String caption = pythonService.generateSketchCaption(url);
GenerateCaptionVO recognized_caption = new GenerateCaptionVO("recognized caption");
@@ -80,7 +80,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper,Generate> im
String text = generateThroughImageTextDTO.getText();
Long elementId = generateThroughImageTextDTO.getCollectionElementId();
validateGeneraType(generate,text,elementId);
validateGeneraType(generate, text, elementId);
// 3、将请求信息落库
// 3.1 sketch或print在t_collection_element表中的信息是否需要更新 如 level2Type
@@ -93,8 +93,8 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper,Generate> im
int mode = GenerateModeEnum.TEXT.getValue().equals(generate.getGenerateType()) ? GenerateModeEnum.TEXT.getCode() : GenerateModeEnum.TEXT_IMAGE.getCode();
String category = generateThroughImageTextDTO.getLevel1Type().equals(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName()) ? "sketch" :
generateThroughImageTextDTO.getLevel1Type().equals(CollectionLevel1TypeEnum.PRINT_BOARD.getRealName()) ? "print" : "moodboard";
List<String> generatedSketchUrl = pythonService.generateSketchOrPrint(accountId,Objects.isNull(elementId) ? null : collectionElement.getUrl(),
category,text,mode,generateThroughImageTextDTO.getVersion());
List<String> generatedSketchUrl = pythonService.generateSketchOrPrint(accountId, Objects.isNull(elementId) ? null : collectionElement.getUrl(),
category, text, mode, generateThroughImageTextDTO.getVersion());
// List<String> generatedSketchUrl = Arrays.asList("testUrl1","testUrl2","testUrl3","testUrl4");
@@ -110,23 +110,23 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper,Generate> im
GenerateCollectionItemVO generateCollectionItemVO = new GenerateCollectionItemVO();
generateCollectionItemVO.setGenerateItemId(generateDetail.getId());
generateCollectionItemVO.setGenerateItemUrl(minioUtil.getPresignedUrl(item,24 * 60));
generateCollectionItemVO.setGenerateItemUrl(minioUtil.getPresignedUrl(item, 24 * 60));
generatedCollectionItems.add(generateCollectionItemVO);
});
// 6、将模型返回的图片地址返回给前端
Long collectionId = Objects.isNull(collectionElement) ? null : collectionElement.getCollectionId();
return new GenerateCollectionVO(generate.getId(),collectionId,generatedCollectionItems);
return new GenerateCollectionVO(generate.getId(), collectionId, generatedCollectionItems);
}
private void validateGeneraType(Generate generate,String text,Long elementId){
switch(generate.getGenerateType()){
private void validateGeneraType(Generate generate, String text, Long elementId) {
switch (generate.getGenerateType()) {
case "text":
Assert.notNull(text,"Please input the caption");
Assert.notNull(text, "Please input the caption");
generate.setText(text);
break;
case "image":
Assert.notNull(elementId,"Please choose a image");
Assert.notNull(elementId, "Please choose a image");
generate.setCollectionElementId(elementId);
break;
case "text-image":
@@ -142,15 +142,15 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper,Generate> im
public GenerateLikeVO generateLike(GenerateLikeDTO generateLikeDTO) {
// 1、判断参数是否正确
// 1.1 必须参数是否非空
if(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName().equals(generateLikeDTO.getLevel1Type()) ){
Assert.isTrue(!StringUtil.isNullOrEmpty(generateLikeDTO.getLevel2Type()),"level2Type cannot be empty");
if (CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName().equals(generateLikeDTO.getLevel1Type())) {
Assert.isTrue(!StringUtil.isNullOrEmpty(generateLikeDTO.getLevel2Type()), "level2Type cannot be empty");
}
// 1.2 判断参数是否真实有效
Long generateDetailId = generateLikeDTO.getGenerateDetailId();
GenerateDetail generateDetail = generateDetailMapper.selectById(generateDetailId);
Assert.notNull(generateDetail,"generateItem does not exist");
Assert.notNull(generateDetail, "generateItem does not exist");
Generate generate = getById(generateDetail.getGenerateId());
Assert.isTrue(generateLikeDTO.getLevel1Type().equals(generate.getLevel1Type()),"level1Type does not match");
Assert.isTrue(generateLikeDTO.getLevel1Type().equals(generate.getLevel1Type()), "level1Type does not match");
// 2、将like的图片信息存入library
// 2.1、不能重复喜欢
@@ -164,7 +164,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper,Generate> im
libraryService.save(library);
// 3、更新generateDetail表的isLike列和libraryId列
updateLikeStatus(generateLikeDTO.getGenerateDetailId(),(byte)1,library.getId(),generateLikeDTO.getTimeZone());
updateLikeStatus(generateLikeDTO.getGenerateDetailId(), (byte) 1, library.getId(), generateLikeDTO.getTimeZone());
return new GenerateLikeVO(library.getId());
}
@@ -173,14 +173,14 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper,Generate> im
public Boolean generateDislike(Long generateDetailId, String timeZone) {
// 1、确定generateDetail中是否有这条记录
GenerateDetail generateDetail = generateDetailMapper.selectById(generateDetailId);
Assert.notNull(generateDetail,"generateItem does not exist");
Assert.notNull(generateDetail, "generateItem does not exist");
// 2、修改generateDetail表中的isLike、libraryId字段
updateLikeStatus(generateDetailId,(byte)0,0L,timeZone);
updateLikeStatus(generateDetailId, (byte) 0, 0L, timeZone);
// 3、确定library中是否添加该条记录
Library libraryDetail = libraryService.getById(generateDetail.getLibraryId());
if (Objects.isNull(libraryDetail)){
if (Objects.isNull(libraryDetail)) {
return Boolean.TRUE;
}
@@ -191,12 +191,12 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper,Generate> im
return Boolean.TRUE;
}
public Library setLibrary(Long accountId,GenerateLikeDTO generateLikeDTO,String imageUrl){
public Library setLibrary(Long accountId, GenerateLikeDTO generateLikeDTO, String imageUrl) {
Library library = new Library();
library.setAccountId(accountId);
library.setLevel1Type(generateLikeDTO.getLevel1Type());
library.setLevel2Type(StringUtil.isNullOrEmpty(generateLikeDTO.getLevel2Type()) ? null : generateLikeDTO.getLevel2Type());
library.setName(DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD));
library.setName(DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD));
library.setUrl(imageUrl);
try {
library.setMd5(MD5Utils.encryptFile(minioUtil.download(imageUrl)));
@@ -209,7 +209,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper,Generate> im
return library;
}
public void updateLikeStatus(Long generateDetailId,Byte hasLike,Long libraryId,String timeZone){
public void updateLikeStatus(Long generateDetailId, Byte hasLike, Long libraryId, String timeZone) {
QueryWrapper<GenerateDetail> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id", generateDetailId);
@@ -217,6 +217,6 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper,Generate> im
generateDetail.setIsLike(hasLike);
generateDetail.setLibraryId(libraryId);
generateDetail.setUpdateDate(DateUtil.getByTimeZone(timeZone));
generateDetailMapper.update(generateDetail,queryWrapper);
generateDetailMapper.update(generateDetail, queryWrapper);
}
}

View File

@@ -60,17 +60,17 @@ public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointM
public LibraryModelPointVO saveOrEditTemplatePoint(LibraryModelPointDTO libraryModelPointDTO) {
// Library library = libraryService.getById(libraryModelPointDTO.getLibraryId());
// Assert.notNull(library,"library does not exist!");
LibraryModelPointVO libraryModelPointVO =CopyUtil.copyObject(libraryModelPointDTO,LibraryModelPointVO.class);
if(Objects.isNull(libraryModelPointDTO.getTemplateId())){
LibraryModelPointVO libraryModelPointVO = CopyUtil.copyObject(libraryModelPointDTO, LibraryModelPointVO.class);
if (Objects.isNull(libraryModelPointDTO.getTemplateId())) {
//新增
LibraryModelPoint libraryModelPoint = resolvePoint(libraryModelPointDTO);
libraryModelPoint.setCreateDate(DateUtil.getByTimeZone(libraryModelPointDTO.getTimeZone()));
save(libraryModelPoint);
libraryModelPointVO.setTemplateId(libraryModelPoint.getId());
}else {
} else {
//编辑
LibraryModelPoint modelPoint = getById(libraryModelPointDTO.getTemplateId());
Assert.notNull(modelPoint,"Template does not exist!");
Assert.notNull(modelPoint, "Template does not exist!");
modelPoint = resolvePoint(libraryModelPointDTO);
modelPoint.setUpdateDate(DateUtil.getByTimeZone(libraryModelPointDTO.getTimeZone()));
modelPoint.setId(libraryModelPointDTO.getTemplateId());
@@ -79,8 +79,9 @@ public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointM
}
return libraryModelPointVO;
}
private LibraryModelPoint resolvePoint(LibraryModelPointDTO libraryModelPointDTO){
LibraryModelPoint libraryModelPoint = CopyUtil.copyObject(libraryModelPointDTO,LibraryModelPoint.class);
private LibraryModelPoint resolvePoint(LibraryModelPointDTO libraryModelPointDTO) {
LibraryModelPoint libraryModelPoint = CopyUtil.copyObject(libraryModelPointDTO, LibraryModelPoint.class);
libraryModelPoint.setRelationId(libraryModelPointDTO.getLibraryId());
libraryModelPoint.setHandLeft(JSON.toJSONString(libraryModelPointDTO.getHandLeft()));
libraryModelPoint.setHandRight(JSON.toJSONString(libraryModelPointDTO.getHandRight()));
@@ -98,23 +99,24 @@ public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointM
queryWrapper.lambda().eq(LibraryModelPoint::getModelType, ModelType.LIBRARY.getValue());
queryWrapper.in("relation_id", libraryIds);
List<LibraryModelPoint> libraryModelPoints = libraryModelPointMapper.selectList(queryWrapper);
if(CollectionUtils.isEmpty(libraryModelPoints)){
if (CollectionUtils.isEmpty(libraryModelPoints)) {
return null;
}
return CopyUtil.copyList(libraryModelPoints,LibraryModelPointVO.class,(o,d) ->{
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));
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 String modelsDot( ModelsDotDTO modelsDotDTO) {
DesignPythonObjects objects =pythonService.covertModelsDotParam(
modelsDotDTO, SingleOverallEnum.OVERALL.getRealName(),"");
public String modelsDot(ModelsDotDTO modelsDotDTO) {
DesignPythonObjects objects = pythonService.covertModelsDotParam(
modelsDotDTO, SingleOverallEnum.OVERALL.getRealName(), "");
designService.relationImageId(objects);
JSONObject jsonObject = pythonService.designNew(objects);
JSONObject data = jsonObject.getJSONObject("data");
@@ -133,10 +135,10 @@ public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointM
}
@Override
public LibraryModelPoint getByRelationId(Long relationId,String modelType){
public LibraryModelPoint getByRelationId(Long relationId, String modelType) {
QueryWrapper<LibraryModelPoint> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("relation_id", relationId)
.eq("model_type",modelType);
.eq("model_type", modelType);
return baseMapper.selectOne(queryWrapper);
}

View File

@@ -68,7 +68,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
private String sysImage;
private static List<String> top = Arrays.asList(CollectionLevel2TypeEnum.DRESS.getRealName(),
CollectionLevel2TypeEnum.OUTWEAR.getRealName(),CollectionLevel2TypeEnum.BLOUSE.getRealName());
CollectionLevel2TypeEnum.OUTWEAR.getRealName(), CollectionLevel2TypeEnum.BLOUSE.getRealName());
private static List<String> bottom = Arrays.asList(CollectionLevel2TypeEnum.SKIRT.getRealName(),
CollectionLevel2TypeEnum.TROUSERS.getRealName());
@@ -77,7 +77,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
QueryWrapper<Library> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("account_id", accountId);
queryWrapper.in("level1_type", level1Types);
return CopyUtil.copyList(libraryMapper.selectList(queryWrapper),LibraryVo.class);
return CopyUtil.copyList(libraryMapper.selectList(queryWrapper), LibraryVo.class);
}
@Override
@@ -87,66 +87,66 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
QueryWrapper<Library> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("account_id", authPrincipalVo.getId());
if(!StringUtils.isEmpty(query.getLevel1Type())){
if (!StringUtils.isEmpty(query.getLevel1Type())) {
LibraryLevel1TypeEnum level1TypeEnum = LibraryLevel1TypeEnum.uploadOf(query.getLevel1Type());
Assert.notNull(level1TypeEnum,"unknown level1Type " +query.getLevel1Type());
Assert.notNull(level1TypeEnum, "unknown level1Type " + query.getLevel1Type());
queryWrapper.eq("level1_type", query.getLevel1Type());
}
if (!StringUtils.isEmpty(query.getModelSex()) && query.getLevel1Type().equals(LibraryLevel1TypeEnum.SKETCH_BOARD.getRealName())) {
queryWrapper.eq("level3_type", query.getModelSex());
}
if(!StringUtils.isEmpty(query.getLevel2Type())){
if (!StringUtils.isEmpty(query.getLevel2Type())) {
CollectionLevel2TypeEnum level2TypeEnum = CollectionLevel2TypeEnum.of(query.getLevel2Type());
Assert.notNull(level2TypeEnum,"unknown level2Type " +query.getLevel2Type());
Assert.notNull(level2TypeEnum, "unknown level2Type " + query.getLevel2Type());
queryWrapper.eq("level2_type", query.getLevel2Type());
}
if(!StringUtils.isEmpty(query.getType())){
if (!StringUtils.isEmpty(query.getType())) {
LibraryTopTypeEnum libraryTopTypeEnum = LibraryTopTypeEnum.uploadOf(query.getType());
Assert.notNull(libraryTopTypeEnum,"unknown type " +query.getType());
if(libraryTopTypeEnum.equals(LibraryTopTypeEnum.PRINT)){
Assert.notNull(libraryTopTypeEnum, "unknown type " + query.getType());
if (libraryTopTypeEnum.equals(LibraryTopTypeEnum.PRINT)) {
queryWrapper.eq("level1_type", LibraryLevel1TypeEnum.PRINT_BOARD.getRealName());
}else{
} else {
queryWrapper.eq("level1_type", LibraryLevel1TypeEnum.SKETCH_BOARD.getRealName());
if(LibraryTopTypeEnum.TOP.equals(libraryTopTypeEnum)){
if (LibraryTopTypeEnum.TOP.equals(libraryTopTypeEnum)) {
queryWrapper.in("level2_type", top);
}else{
} else {
queryWrapper.in("level2_type", bottom);
}
}
}
if(!StringUtils.isEmpty(query.getPictureName())){
if (!StringUtils.isEmpty(query.getPictureName())) {
queryWrapper.like("name", query.getPictureName());
}
queryWrapper.orderByDesc("id");
IPage<Library> page = getBaseMapper().selectPage(
new Page<>(query.getPage(), query.getSize()), queryWrapper);
if(CollectionUtils.isEmpty(page.getRecords())){
if (CollectionUtils.isEmpty(page.getRecords())) {
return PageBaseResponse.success(new Page<>());
}
Map<Long,LibraryModelPointVO> map = null;
Map<Long, LibraryModelPointVO> map = null;
//封装打点内容
Boolean isExist = page.getRecords().stream()
.anyMatch(library -> library.getLevel1Type().equals(LibraryLevel1TypeEnum.MODELS.getRealName()));
if(isExist){
if (isExist) {
List<Long> libarayIds = page.getRecords().stream()
.filter(library -> library.getLevel1Type().equals(LibraryLevel1TypeEnum.MODELS.getRealName()))
.map(Library::getId)
.collect(Collectors.toList());
List<LibraryModelPointVO> libraryModelPointVOS = libraryModelPointService.selectByLibraryIds(libarayIds);
if(!CollectionUtils.isEmpty(libraryModelPointVOS)){
map = libraryModelPointVOS.stream().collect(Collectors.toMap(LibraryModelPointVO::getRelationId,v ->v));
if (!CollectionUtils.isEmpty(libraryModelPointVOS)) {
map = libraryModelPointVOS.stream().collect(Collectors.toMap(LibraryModelPointVO::getRelationId, v -> v));
}
}
Map<Long, LibraryModelPointVO> finalMap = map;
IPage<QueryLibraryPageVO> convert = page.convert((Function<Library, QueryLibraryPageVO>) library -> {
QueryLibraryPageVO libraryPageVO = CopyUtil.copyObject(library,QueryLibraryPageVO.class);
libraryPageVO.setDesignType(DesignTypeEnum.LIBRARY.getRealName());
libraryPageVO.setMinIOPath(library.getUrl());
libraryPageVO.setUrl(minioUtil.getPresignedUrl(library.getUrl(),24 * 60));
if(finalMap != null && finalMap.containsKey(library.getId())){
libraryPageVO.setLibraryModelPoint(finalMap.get(library.getId()));
}
return libraryPageVO;
QueryLibraryPageVO libraryPageVO = CopyUtil.copyObject(library, QueryLibraryPageVO.class);
libraryPageVO.setDesignType(DesignTypeEnum.LIBRARY.getRealName());
libraryPageVO.setMinIOPath(library.getUrl());
libraryPageVO.setUrl(minioUtil.getPresignedUrl(library.getUrl(), 24 * 60));
if (finalMap != null && finalMap.containsKey(library.getId())) {
libraryPageVO.setLibraryModelPoint(finalMap.get(library.getId()));
}
return libraryPageVO;
});
return PageBaseResponse.success(convert);
}
@@ -157,12 +157,12 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
AuthPrincipalVo userInfo = UserContext.getUserHolder();
LibraryLevel1TypeEnum level1TypeEnum = LibraryLevel1TypeEnum.uploadOf(libraryUploadDTO.getLevel1Type());
Assert.notNull(level1TypeEnum, "unknown parameter level1Type!");
if(!StringUtils.isEmpty(libraryUploadDTO.getLevel2Type())){
if (!StringUtils.isEmpty(libraryUploadDTO.getLevel2Type())) {
CollectionLevel2TypeEnum level2TypeEnum = CollectionLevel2TypeEnum.of(libraryUploadDTO.getLevel2Type());
Assert.notNull(level2TypeEnum, "unknown parameter level2Type!");
}
Assert.isTrue(!( level1TypeEnum.equals(LibraryLevel1TypeEnum.SKETCH_BOARD)
&& StringUtils.isEmpty(libraryUploadDTO.getLevel2Type()) ),"level2Type cannot be empty!");
Assert.isTrue(!(level1TypeEnum.equals(LibraryLevel1TypeEnum.SKETCH_BOARD)
&& StringUtils.isEmpty(libraryUploadDTO.getLevel2Type())), "level2Type cannot be empty!");
String path = calculateFileUrl(level1TypeEnum, libraryUploadDTO.getLevel2Type(), libraryUploadDTO.getModelSex(), userInfo.getId());
String bucketName = null;
switch (level1TypeEnum) {
@@ -188,7 +188,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
libraryUpdateVo.setUrl(minioUtil.getPresignedUrl(newFilePath, 24 * 60));
libraryUpdateVo.setCheckMd5(Boolean.TRUE);
return libraryUpdateVo;
}else if (libraryUploadDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
} else if (libraryUploadDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
bucketName = sysImage;
path = "models/" + libraryUploadDTO.getModelSex().toLowerCase();
String filePath = minioUtil.upload(bucketName, path, libraryUploadDTO.getFile());
@@ -199,10 +199,10 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
libraryUpdateVo.setUrl(minioUtil.getPresignedUrl(newFilePath, 24 * 60));
libraryUpdateVo.setCheckMd5(Boolean.TRUE);
return libraryUpdateVo;
}else {
} else {
throw new BusinessException("unknown modelType");
}
}else {
} else {
String filePath = minioUtil.upload(bucketName, path, libraryUploadDTO.getFile());
//保存element元素
Library library = resolveData(libraryUploadDTO, userInfo, filePath);
@@ -251,10 +251,10 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
if (response.isSuccessful()) {
try {
String responseBody = response.body().string();
JSONObject responseObject = JSON.parseObject(responseBody);
JSONObject responseObject = JSON.parseObject(responseBody);
String newMinioPath = responseObject.getString("data");
return newMinioPath;
}catch (IOException e) {
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@@ -272,7 +272,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
if (level1Type.equals(LibraryLevel1TypeEnum.SKETCH_BOARD)) {
qw.lambda().eq(Library::getLevel2Type, level2Type);
qw.lambda().eq(Library::getLevel3Type, sex);
}else {
} else {
qw.lambda().eq(Library::getLevel2Type, sex);
}
}
@@ -281,7 +281,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
if (!CollectionUtils.isEmpty(libraryList)) {
// throw new BusinessException("Your library already contains the images you uploaded, Are you sure to upload them");
return Boolean.FALSE;
}else {
} else {
return Boolean.TRUE;
}
}
@@ -290,20 +290,20 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
if (StringUtils.isEmpty(uploadDTO.getModelType()) || uploadDTO.getModelType().equals(ModelType.LIBRARY.getValue())) {
Library library = CopyUtil.copyObject(uploadDTO, Library.class);
library.setAccountId(userInfo.getId());
library.setName(DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD));
library.setName(DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD));
library.setUrl(filePath);
//按时区计算
library.setCreateDate(DateUtil.getByTimeZone(uploadDTO.getTimeZone()));
if (uploadDTO.getModelType().equals(ModelType.LIBRARY.getValue())) {
library.setLevel2Type(uploadDTO.getModelSex());
}else {
} else {
library.setLevel3Type(uploadDTO.getModelSex());
}
libraryMapper.insert(library);
return library;
}else if (uploadDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
} else if (uploadDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
SysFile sysFile = new SysFile();
sysFile.setName(DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD));
sysFile.setName(DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD));
sysFile.setLevel1Type("Models");
sysFile.setLevel2Type(uploadDTO.getModelSex());
sysFile.setUrl(filePath);
@@ -314,7 +314,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
library.setId(sysFile.getId());
library.setUrl(sysFile.getUrl());
return library;
}else {
} else {
throw new BusinessException("system error!");
}
}
@@ -322,7 +322,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
private String calculateFileUrl(LibraryLevel1TypeEnum level1TypeEnum, String level2Type, String modelSex, Long userId) {
if (StringUtils.isEmpty(modelSex)) {
return StringUtils.isEmpty(level2Type) ? userId + "/" + level1TypeEnum.getRealName().toLowerCase() : userId + "/" + level1TypeEnum.getRealName().toLowerCase() + "/" + level2Type;
}else {
} else {
return StringUtils.isEmpty(level2Type) ? userId + "/" + level1TypeEnum.getRealName().toLowerCase() + "/" + modelSex.toLowerCase() : userId + "/" + level1TypeEnum.getRealName().toLowerCase() + "/" + modelSex.toLowerCase() + "/" + level2Type;
}
}
@@ -330,13 +330,13 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
@Override
public void updateLibraryName(LibraryUpdateDTO libraryUpdateDTO) {
List<Library> librarys = getByIds(libraryUpdateDTO.getLibraryIds());
Assert.notEmpty(librarys,"Librarys does not exist!");
Assert.notEmpty(librarys, "Librarys does not exist!");
QueryWrapper<Library> queryWrapper = new QueryWrapper<>();
queryWrapper.in("id", libraryUpdateDTO.getLibraryIds());
Library library1= new Library();
Library library1 = new Library();
library1.setName(libraryUpdateDTO.getLibraryName());
library1.setUpdateDate(DateUtil.getByTimeZone(libraryUpdateDTO.getTimeZone()));
libraryMapper.update(library1,queryWrapper);
libraryMapper.update(library1, queryWrapper);
}
@Override
@@ -354,11 +354,11 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
}
@Override
public List<LibraryVo> getByUrlList(List<String> urlList,Long userId) {
public List<LibraryVo> getByUrlList(List<String> urlList, Long userId) {
QueryWrapper<Library> queryWrapper = new QueryWrapper<>();
queryWrapper.in("url", urlList);
queryWrapper.in("account_id", userId);
return CopyUtil.copyList(libraryMapper.selectList(queryWrapper),LibraryVo.class);
return CopyUtil.copyList(libraryMapper.selectList(queryWrapper), LibraryVo.class);
}
@Override

View File

@@ -36,15 +36,15 @@ public class PanToneServiceImpl extends ServiceImpl<PanToneMapper, PanTone> impl
@Override
public PantoneVO getByHSV(Integer h, Integer s, Integer v) {
int value = (h * 101 *101)+ (s*101) +v;
int value = (h * 101 * 101) + (s * 101) + v;
ColorLookupTable colorLookupTable = colorLoopUpTableService.getByColorValue(value);
if(Objects.isNull(colorLookupTable)){
if (Objects.isNull(colorLookupTable)) {
return new PantoneVO();
}
QueryWrapper<PanTone> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("pantone_index", colorLookupTable.getColorIndex());
PanTone panTone = panToneMapper.selectOne(queryWrapper);
if(Objects.isNull(panTone)){
if (Objects.isNull(panTone)) {
throw new BusinessException("Pantone value does not exist !");
}
return coverPanToneToVo(panTone);
@@ -55,14 +55,14 @@ public class PanToneServiceImpl extends ServiceImpl<PanToneMapper, PanTone> impl
QueryWrapper<PanTone> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("tcx", txc);
List<PanTone> panTones = panToneMapper.selectList(queryWrapper);
if(CollectionUtil.isEmpty(panTones)){
if (CollectionUtil.isEmpty(panTones)) {
throw new BusinessException("Pantone value does not exist !");
}
return coverPanToneToVo(panTones.get(0));
}
@Override
public PantoneVO getByRGB(Integer r,Integer g,Integer b) {
public PantoneVO getByRGB(Integer r, Integer g, Integer b) {
QueryWrapper<PanTone> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("r", r);
queryWrapper.eq("g", g);
@@ -72,23 +72,23 @@ public class PanToneServiceImpl extends ServiceImpl<PanToneMapper, PanTone> impl
}
@Override
public Map<String,PantoneVO> getPantoneByRgbBatch(List<String> colors){
public Map<String, PantoneVO> getPantoneByRgbBatch(List<String> colors) {
HashMap<Integer,String> colorValueRgb = new HashMap<>();
HashMap<Integer,String> colorIndexRgb = new HashMap<>();
HashMap<Integer, String> colorValueRgb = new HashMap<>();
HashMap<Integer, String> colorIndexRgb = new HashMap<>();
ArrayList<Integer> values = new ArrayList<>();
colors.forEach(color -> {
int[] rgb = Arrays.stream(color.split("\\s+")).mapToInt(Integer::parseInt).toArray();
int[] hsv = PantoneUtils.rgbToHsv(rgb);
int value = (hsv[0] * 101 *101)+ (hsv[1]*101) +hsv[2];
colorValueRgb.put(value,color);
int value = (hsv[0] * 101 * 101) + (hsv[1] * 101) + hsv[2];
colorValueRgb.put(value, color);
values.add(value);
});
List<ColorLookupTable> colorValueList = colorLoopUpTableService.getByColorValueList(values);
colorValueList.forEach(colorValue ->{
colorValueList.forEach(colorValue -> {
// 不同的colorValue可能会有相同的colorIndex
colorIndexRgb.put(colorValue.getColorIndex(),colorValueRgb.get(colorValue.getColorValue()));
colorIndexRgb.put(colorValue.getColorIndex(), colorValueRgb.get(colorValue.getColorValue()));
});
List<PanTone> panTones = panToneService.listByIds(colorIndexRgb.keySet());
@@ -101,12 +101,12 @@ public class PanToneServiceImpl extends ServiceImpl<PanToneMapper, PanTone> impl
pantoneVOS.forEach(pantoneVO -> {
int colorIndex = pantoneVO.getId();
List<ColorLookupTable> collect = colorValueList.stream().filter(colorValue -> colorValue.getColorIndex().equals(colorIndex)).collect(Collectors.toList());
if (collect.size() > 1){
if (collect.size() > 1) {
for (ColorLookupTable colorLookupTable : collect) {
colorPantoneVO.put(colorValueRgb.get(colorLookupTable.getColorValue()), pantoneVO);
}
}else if (collect.size() == 1){
colorPantoneVO.put(colorIndexRgb.get(pantoneVO.getId()),pantoneVO);
} else if (collect.size() == 1) {
colorPantoneVO.put(colorIndexRgb.get(pantoneVO.getId()), pantoneVO);
}
});
@@ -123,9 +123,9 @@ public class PanToneServiceImpl extends ServiceImpl<PanToneMapper, PanTone> impl
@Override
public PantoneVO getPantoneByRgb(String color){
public PantoneVO getPantoneByRgb(String color) {
GetRgbByHsvBatchDTO getRgbByHsvBatchDTO = new GetRgbByHsvBatchDTO();
if (!StringUtil.isNullOrEmpty(color)){
if (!StringUtil.isNullOrEmpty(color)) {
int[] rgb = Arrays.stream(color.split("\\s+")).mapToInt(Integer::parseInt).toArray();
int[] hsv = PantoneUtils.rgbToHsv(rgb);
@@ -134,79 +134,80 @@ public class PanToneServiceImpl extends ServiceImpl<PanToneMapper, PanTone> impl
getRgbByHsvBatchDTO.setV(hsv[2]);
}
return getByHSV(getRgbByHsvBatchDTO.getH(),getRgbByHsvBatchDTO.getS(),getRgbByHsvBatchDTO.getV());
return getByHSV(getRgbByHsvBatchDTO.getH(), getRgbByHsvBatchDTO.getS(), getRgbByHsvBatchDTO.getV());
}
@Override
public List<PantoneVO> getRgbByHsvBatch(List<GetRgbByHsvBatchDTO> hsvBatch) {
if(hsvBatch.size() >8){
if (hsvBatch.size() > 8) {
throw new BusinessException("hsv value cannot exceed the maximum of 8");
}
List<Integer> colorValues = Lists.newArrayList();
Map<Integer,GetRgbByHsvBatchDTO> valueToHsv = Maps.newHashMap();
hsvBatch.forEach( hsv->{
Map<Integer, GetRgbByHsvBatchDTO> valueToHsv = Maps.newHashMap();
hsvBatch.forEach(hsv -> {
if (Objects.isNull(hsv)) {
return;
}
Integer h = hsv.getH();
Integer s = hsv.getS();
Integer v = hsv.getV();
int value = (h * 101 *101)+ (s*101) +v;
int value = (h * 101 * 101) + (s * 101) + v;
colorValues.add(value);
valueToHsv.put(value,hsv);
valueToHsv.put(value, hsv);
});
List<ColorLookupTable> colorLookupTables = colorLoopUpTableService.getByColorValueList(colorValues);
if(Objects.isNull(colorLookupTables)){
if (Objects.isNull(colorLookupTables)) {
return Lists.newArrayList();
}
Map<Integer,Integer> IndexToValue = colorLookupTables.stream()
.collect(Collectors.toMap(v->v.getColorIndex(),v ->v.getColorValue(),(V1,V2) ->V1));
Map<Integer, Integer> IndexToValue = colorLookupTables.stream()
.collect(Collectors.toMap(v -> v.getColorIndex(), v -> v.getColorValue(), (V1, V2) -> V1));
QueryWrapper<PanTone> queryWrapper = new QueryWrapper<>();
queryWrapper.in("pantone_index", colorLookupTables.stream()
.map(ColorLookupTable::getColorIndex).collect(Collectors.toList()));
return coverPanToneToVoList(panToneMapper.selectList(queryWrapper),IndexToValue,valueToHsv,hsvBatch);
return coverPanToneToVoList(panToneMapper.selectList(queryWrapper), IndexToValue, valueToHsv, hsvBatch);
}
private PantoneVO coverPanToneToVo(PanTone panTone){
if(Objects.isNull(panTone)){
private PantoneVO coverPanToneToVo(PanTone panTone) {
if (Objects.isNull(panTone)) {
return null;
}
PantoneVO pantoneVO = CopyUtil.copyObject(panTone,PantoneVO.class);
PantoneVO pantoneVO = CopyUtil.copyObject(panTone, PantoneVO.class);
// pantoneVO.setR(panTone.getR());
// pantoneVO.setG(panTone.getG());
// pantoneVO.setB(panTone.getB());
pantoneVO.setId(panTone.getPantoneIndex());
return pantoneVO;
}
private List<PantoneVO> coverPanToneToVoList(List<PanTone> panTones
,Map<Integer,Integer> indexToValue, Map<Integer,GetRgbByHsvBatchDTO> valueToHsv,
List<GetRgbByHsvBatchDTO> hsvBatch){
if(Objects.isNull(panTones)){
, Map<Integer, Integer> indexToValue, Map<Integer, GetRgbByHsvBatchDTO> valueToHsv,
List<GetRgbByHsvBatchDTO> hsvBatch) {
if (Objects.isNull(panTones)) {
throw new BusinessException("Pantone value does not exist !");
}
List<PantoneVO> templateResposne = CopyUtil.copyList(panTones,PantoneVO.class,(o,d)->{
List<PantoneVO> templateResposne = CopyUtil.copyList(panTones, PantoneVO.class, (o, d) -> {
d.setId(o.getPantoneIndex());
GetRgbByHsvBatchDTO getRgbByHsvBatchDTO = valueToHsv.get(indexToValue.get(o.getPantoneIndex()));
if(Objects.nonNull(getRgbByHsvBatchDTO)){
GetRgbByHsvBatchDTO getRgbByHsvBatchDTO = valueToHsv.get(indexToValue.get(o.getPantoneIndex()));
if (Objects.nonNull(getRgbByHsvBatchDTO)) {
d.setH(getRgbByHsvBatchDTO.getH());
d.setS(getRgbByHsvBatchDTO.getS());
d.setV(getRgbByHsvBatchDTO.getV());
}
});
Map<Integer,PantoneVO> valueToPantoneVo = templateResposne.stream().collect(Collectors.toMap(
v -> (v.getH() * 101 *101)+ (v.getS()*101) +v.getV(), Function.identity(),(value1,value2)-> value1
Map<Integer, PantoneVO> valueToPantoneVo = templateResposne.stream().collect(Collectors.toMap(
v -> (v.getH() * 101 * 101) + (v.getS() * 101) + v.getV(), Function.identity(), (value1, value2) -> value1
));
List<PantoneVO> response =Lists.newArrayList();
List<PantoneVO> response = Lists.newArrayList();
//排序给前端
hsvBatch.forEach( hsv->{
hsvBatch.forEach(hsv -> {
if (Objects.isNull(hsv)) {
return;
}
int value = (hsv.getH() * 101 *101)+ (hsv.getS()*101) +hsv.getV();
int value = (hsv.getH() * 101 * 101) + (hsv.getS() * 101) + hsv.getV();
PantoneVO pantoneVO = valueToPantoneVo.get(value);
if(Objects.isNull(pantoneVO)){
response.add(new PantoneVO("None","11-1111"));
}else{
if (Objects.isNull(pantoneVO)) {
response.add(new PantoneVO("None", "11-1111"));
} else {
response.add(pantoneVO);
}
});

View File

@@ -52,144 +52,151 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
//删除缓存
clearCacheSysFileData();
//读取linux环境系统图片地址
List<File> allFile= FileUtil.getAllFile("/workspace/home/aida/file/sys");
if(CollectionUtils.isEmpty(allFile)){
List<File> allFile = FileUtil.getAllFile("/workspace/home/aida/file/sys");
if (CollectionUtils.isEmpty(allFile)) {
return;
}
Map<String ,Long> idMap = initIdValueByLevel2Type();
if (allFile.size() >500){
Map<String, Long> idMap = initIdValueByLevel2Type();
if (allFile.size() > 500) {
AtomicInteger process = new AtomicInteger();
//批量保存mysql 500条一次
List<List<File>> fileList = Lists.partition(allFile,500);
fileList.forEach(list ->{
log.info("初始化系统文件进度###次数###{}",process.getAndAdd(1));
if(saveMany(initSysFile(list,idMap))){
List<List<File>> fileList = Lists.partition(allFile, 500);
fileList.forEach(list -> {
log.info("初始化系统文件进度###次数###{}", process.getAndAdd(1));
if (saveMany(initSysFile(list, idMap))) {
return;
}
});
return;
}
saveMany(initSysFile(allFile,idMap));
saveMany(initSysFile(allFile, idMap));
}
private void clearCacheSysFileData(){
private void clearCacheSysFileData() {
LocalCacheUtils.clearAllMaxMinValueCache();
LocalCacheUtils.clearAllSysFileCache();
LocalCacheUtils.clearAllSysFileCacheByLevel2Type();
log.info("初始化系统文件删除删除系统文件缓存完毕#####");
}
private void deleteAllSysFileData(){
private void deleteAllSysFileData() {
AtomicInteger process = new AtomicInteger();
while(true){
while (true) {
// 分页数据
QueryWrapper<SysFile> queryWrapper = new QueryWrapper<>();
IPage<SysFile> page = this.getBaseMapper().selectPage(
new Page<>(1, 500), queryWrapper);
if(CollectionUtils.isEmpty(page.getRecords())){
break ;
}else{
if (CollectionUtils.isEmpty(page.getRecords())) {
break;
} else {
List<Long> ids = page.getRecords().stream().map(SysFile::getId).collect(Collectors.toList());
this.removeByIds(ids);
log.info("初始化系统文件删除mysql数据进度###次数###{}",process.getAndAdd(1));
log.info("初始化系统文件删除mysql数据进度###次数###{}", process.getAndAdd(1));
}
}
}
private List<SysFile> initSysFile(List<File> files,Map<String ,Long> idMap){
List<SysFile> sysFiles =Lists.newArrayList();
private List<SysFile> initSysFile(List<File> files, Map<String, Long> idMap) {
List<SysFile> sysFiles = Lists.newArrayList();
files.forEach(file -> {
SysFile sysFile = new SysFile();
sysFile.setCreateDate(new Date());
String filePath = file.getAbsolutePath();
sysFile.setLevel1Type(calculateLevel1Type(filePath));
sysFile.setLevel2Type(calculateLevel2Type(filePath));
sysFile.setId(getIdByLevel2Type(sysFile.getLevel2Type(),idMap));
sysFile.setId(getIdByLevel2Type(sysFile.getLevel2Type(), idMap));
sysFile.setName(file.getName());
try{
try {
FileInputStream inputStream = new FileInputStream(file);
sysFile.setMd5(MD5Utils.encryptFile(inputStream));
}catch(IOException ioException){
} catch (IOException ioException) {
log.info("initSysFile 文件异常###{}", ExceptionUtil.getThrowableList(ioException));
throw new BusinessException("initSysFile ioException");
}
String linuxDomain = fileProperties.getLinuxDomain();
if(!StringUtils.isEmpty(linuxDomain)){
if (!StringUtils.isEmpty(linuxDomain)) {
//linux 系统
String oldPath = fileProperties.getSys().getPath();
sysFile.setUrl(filePath.replace(oldPath,linuxDomain));
sysFile.setUrl(filePath.replace(oldPath, linuxDomain));
}
sysFiles.add(sysFile);
});
return sysFiles;
}
private String calculateLevel1Type(String filePath){
private String calculateLevel1Type(String filePath) {
String[] split = filePath.split("/");
//一级目录
SysFileLevel1TypeEnum sysFileLevel1Type = SysFileLevel1TypeEnum.uploadOf(split[split.length-3]);
if(Objects.nonNull(sysFileLevel1Type)){
SysFileLevel1TypeEnum sysFileLevel1Type = SysFileLevel1TypeEnum.uploadOf(split[split.length - 3]);
if (Objects.nonNull(sysFileLevel1Type)) {
return sysFileLevel1Type.getRealName();
}
return "";
}
private String calculateLevel2Type(String filePath){
private String calculateLevel2Type(String filePath) {
String[] split = filePath.split("/");
//一级目录
SysFileLevel2TypeEnum sysFileLevel2Type = SysFileLevel2TypeEnum.uploadOf(split[split.length-2]);
if(Objects.nonNull(sysFileLevel2Type)){
SysFileLevel2TypeEnum sysFileLevel2Type = SysFileLevel2TypeEnum.uploadOf(split[split.length - 2]);
if (Objects.nonNull(sysFileLevel2Type)) {
return sysFileLevel2Type.getRealName();
}
return "";
}
private Long getIdByLevel2Type(String level2Type ,Map<String, Long> IdMp){
private Long getIdByLevel2Type(String level2Type, Map<String, Long> IdMp) {
Long id = IdMp.get(level2Type);
Long newId = id +1;
IdMp.put(level2Type,newId);
Long newId = id + 1;
IdMp.put(level2Type, newId);
return newId;
}
private Map<String ,Long> initIdValueByLevel2Type(){
private Map<String, Long> initIdValueByLevel2Type() {
//每个类型分配100000 十万个位置
Map<String ,Long> idMap = Maps.newHashMap();
Map<String, Long> idMap = Maps.newHashMap();
// 0 到 100000
idMap.put(SysFileLevel2TypeEnum.EARRINGS.getRealName(),0L);
idMap.put(SysFileLevel2TypeEnum.EARRINGS.getRealName(), 0L);
// 100001 到 200000
idMap.put(SysFileLevel2TypeEnum.HAIRSTYLE.getRealName(),100000L);
idMap.put(SysFileLevel2TypeEnum.HAIRSTYLE.getRealName(), 100000L);
// 200001 到 300000
idMap.put(SysFileLevel2TypeEnum.SHOES.getRealName(),200000L);
idMap.put(SysFileLevel2TypeEnum.SHOES.getRealName(), 200000L);
// 300001 到 400000
idMap.put(SysFileLevel2TypeEnum.BLOUSE.getRealName(),300000L);
idMap.put(SysFileLevel2TypeEnum.BLOUSE.getRealName(), 300000L);
// 400001 到 500000
idMap.put(SysFileLevel2TypeEnum.DRESS.getRealName(),400000L);
idMap.put(SysFileLevel2TypeEnum.DRESS.getRealName(), 400000L);
// 500001 到 600000
idMap.put(SysFileLevel2TypeEnum.OUTWEAR.getRealName(),500000L);
idMap.put(SysFileLevel2TypeEnum.OUTWEAR.getRealName(), 500000L);
// 600001 到 700000
idMap.put(SysFileLevel2TypeEnum.SKIRT.getRealName(),600000L);
idMap.put(SysFileLevel2TypeEnum.SKIRT.getRealName(), 600000L);
// 700001 到 800000
idMap.put(SysFileLevel2TypeEnum.TROUSERS.getRealName(),700000L);
idMap.put(SysFileLevel2TypeEnum.TROUSERS.getRealName(), 700000L);
// 800001 到 900000
idMap.put(SysFileLevel2TypeEnum.ICON.getRealName(),800000L);
idMap.put(SysFileLevel2TypeEnum.ICON.getRealName(), 800000L);
// 900001 到 1000000
idMap.put(SysFileLevel2TypeEnum.BAG.getRealName(),900000L);
idMap.put(SysFileLevel2TypeEnum.BAG.getRealName(), 900000L);
// 1000001 到 1100000
idMap.put(SysFileLevel2TypeEnum.BODY.getRealName(),1000000L);
idMap.put(SysFileLevel2TypeEnum.BODY.getRealName(), 1000000L);
return idMap;
}
@Override
public Long getMaxIdByLevel2Type(String level2Type, String modelSex) {
String key = "MAX_"+level2Type;
String key = "MAX_" + level2Type;
Long maxId = LocalCacheUtils.getFileMaxMinValueCache(key);
if(null == maxId){
maxId =maxId(level2Type, modelSex);
LocalCacheUtils.setFileMaxMinValueCache(key,maxId);
if (null == maxId) {
maxId = maxId(level2Type, modelSex);
LocalCacheUtils.setFileMaxMinValueCache(key, maxId);
}
return maxId;
}
@Override
public Long getMinIdByLevel2Type(String level2Type, String modelSex) {
String key = "MIN_"+level2Type;
String key = "MIN_" + level2Type;
Long minId = LocalCacheUtils.getFileMaxMinValueCache(key);
if(null == minId || minId == 0L){
if (null == minId || minId == 0L) {
minId = minId(level2Type, modelSex);
LocalCacheUtils.setFileMaxMinValueCache(key,minId);
LocalCacheUtils.setFileMaxMinValueCache(key, minId);
}
return minId;
}
@@ -197,9 +204,9 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
@Override
public SysFileVO getById(Long id) {
SysFileVO sysFile = LocalCacheUtils.getSysFileCache(id);
if(Objects.isNull(sysFile) || Objects.isNull(sysFile.getId())){
sysFile = CopyUtil.copyObject(sysFileMapper.selectById(id),SysFileVO.class);
LocalCacheUtils.setSysFileCache(id,sysFile);
if (Objects.isNull(sysFile) || Objects.isNull(sysFile.getId())) {
sysFile = CopyUtil.copyObject(sysFileMapper.selectById(id), SysFileVO.class);
LocalCacheUtils.setSysFileCache(id, sysFile);
}
return sysFile;
}
@@ -212,32 +219,34 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
// throw new BusinessException("unknown level2Type "+level2Type);
// }
List<SysFileVO> cacheSysFileList = LocalCacheUtils.getSysFileCacheByLevel2Type(level2Type);
if(CollectionUtils.isEmpty(cacheSysFileList)){
if (CollectionUtils.isEmpty(cacheSysFileList)) {
QueryWrapper<SysFile> queryWrapper = new QueryWrapper<>();
queryWrapper.in("level2_type", SysFileLevel2TypeEnum.ofPython());
List<SysFileVO> sysFiles = CopyUtil.copyList(sysFileMapper.selectList(queryWrapper),SysFileVO.class);
LocalCacheUtils.setSysFileCacheByLevel2Type(level2Type,sysFiles);
List<SysFileVO> sysFiles = CopyUtil.copyList(sysFileMapper.selectList(queryWrapper), SysFileVO.class);
LocalCacheUtils.setSysFileCacheByLevel2Type(level2Type, sysFiles);
return sysFiles;
}
return cacheSysFileList;
}
private Long maxId(String level2Type, String modelSex){
private Long maxId(String level2Type, String modelSex) {
QueryWrapper<SysFile> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("level2_type", level2Type);
queryWrapper.eq(!StringUtils.isEmpty(modelSex), "level3_type", modelSex);
queryWrapper.select("max(id) as id " );
queryWrapper.select("max(id) as id ");
SysFile sysFile = sysFileMapper.selectOne(queryWrapper);
return sysFile.getId();
}
private Long minId(String level2Type, String modelSex){
private Long minId(String level2Type, String modelSex) {
QueryWrapper<SysFile> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("level2_type", level2Type);
queryWrapper.eq(!StringUtils.isEmpty(modelSex), "level3_type", modelSex);
queryWrapper.select("min(id) as id " );
queryWrapper.select("min(id) as id ");
SysFile sysFile = sysFileMapper.selectOne(queryWrapper);
return sysFile.getId();
}
private boolean saveMany(List<SysFile> sysFiles) {
if (!this.saveBatch(sysFiles)) {
throw new BusinessException("save system file failed!");
@@ -249,6 +258,6 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
public List<SysFileVO> getByUrlList(List<String> urlList) {
QueryWrapper<SysFile> queryWrapper = new QueryWrapper<>();
queryWrapper.in("url", urlList);
return CopyUtil.copyList(sysFileMapper.selectList(queryWrapper),SysFileVO.class);
return CopyUtil.copyList(sysFileMapper.selectList(queryWrapper), SysFileVO.class);
}
}

View File

@@ -37,7 +37,7 @@ public class TCollectionElementRelationServiceImpl extends ServiceImpl<TCollecti
public List<Long> getByCollectionId(Long collectionId) {
QueryWrapper<TCollectionElementRelation> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("collection_id", collectionId);
List<TCollectionElementRelation> tCollectionElementRelations = tCollectionElementRelationMapper.selectList(queryWrapper);
List<TCollectionElementRelation> tCollectionElementRelations = tCollectionElementRelationMapper.selectList(queryWrapper);
return CollectionUtils.isEmpty(tCollectionElementRelations) ? null :
tCollectionElementRelations.stream().map(TCollectionElementRelation::getElementId).collect(Collectors.toList());
}

View File

@@ -30,36 +30,37 @@ import java.util.Objects;
@Service
public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl<TDesignPythonOutfitDetailMapper, TDesignPythonOutfitDetail> implements ITDesignPythonOutfitDetailService {
@Resource
private MinioUtil minIoUtil;
@Override
public IPage<TDesignPythonOutfitDetailVO> selectTDesignPythonOutfitDetailPage(IPage<TDesignPythonOutfitDetailVO> page, TDesignPythonOutfitDetailVO tDesignPythonOutfitDetail) {
return page.setRecords(baseMapper.selectTDesignPythonOutfitDetailPage(page, tDesignPythonOutfitDetail));
}
@Override
public List<TDesignPythonOutfitDetail> getDetailByDesignPythonOutfitId(Long designPythonOutfitId){
QueryWrapper<TDesignPythonOutfitDetail> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("design_python_outfit_id",designPythonOutfitId);
return baseMapper.selectList(queryWrapper);
}
@Resource
private MinioUtil minIoUtil;
@Override
public DesignPythonOutfitVO convertToDesignPythonOutfitVO(TDesignPythonOutfitDetail detail,List<Long> offset){
if (Objects.isNull(detail)) {
return null;
}
public IPage<TDesignPythonOutfitDetailVO> selectTDesignPythonOutfitDetailPage(IPage<TDesignPythonOutfitDetailVO> page, TDesignPythonOutfitDetailVO tDesignPythonOutfitDetail) {
return page.setRecords(baseMapper.selectTDesignPythonOutfitDetailPage(page, tDesignPythonOutfitDetail));
}
DesignPythonOutfitVO designPythonOutfitVO = CopyUtil.copyObject(detail,DesignPythonOutfitVO.class);
designPythonOutfitVO.setPosition(StringUtil.isNullOrEmpty(detail.getPosition()) ? null : (List<Long>) JSON.parse(detail.getPosition()));
designPythonOutfitVO.setImageSize(StringUtil.isNullOrEmpty(detail.getImageSize()) ? null : (List<Long>) JSON.parse(detail.getImageSize()));
designPythonOutfitVO.setImageUrl(StringUtil.isNullOrEmpty(detail.getImageUrl()) ? null : minIoUtil.getPresignedUrl(detail.getImageUrl(),24 * 60));
designPythonOutfitVO.setImageMinioUrl(StringUtil.isNullOrEmpty(detail.getImageUrl()) ? null : detail.getImageUrl());
designPythonOutfitVO.setMaskUrl(StringUtil.isNullOrEmpty(detail.getMaskUrl()) ? null : minIoUtil.getPresignedUrl(detail.getMaskUrl(),24 * 60));
designPythonOutfitVO.setMaskMinioUrl(StringUtil.isNullOrEmpty(detail.getMaskUrl()) ? null : detail.getMaskUrl());
designPythonOutfitVO.setScale(Float.parseFloat(detail.getScale()));
designPythonOutfitVO.setOffset(CollectionUtil.isEmpty(offset) ? Arrays.asList(0L,0L) : offset);
@Override
public List<TDesignPythonOutfitDetail> getDetailByDesignPythonOutfitId(Long designPythonOutfitId) {
QueryWrapper<TDesignPythonOutfitDetail> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("design_python_outfit_id", designPythonOutfitId);
return baseMapper.selectList(queryWrapper);
}
@Override
public DesignPythonOutfitVO convertToDesignPythonOutfitVO(TDesignPythonOutfitDetail detail, List<Long> offset) {
if (Objects.isNull(detail)) {
return null;
}
DesignPythonOutfitVO designPythonOutfitVO = CopyUtil.copyObject(detail, DesignPythonOutfitVO.class);
designPythonOutfitVO.setPosition(StringUtil.isNullOrEmpty(detail.getPosition()) ? null : (List<Long>) JSON.parse(detail.getPosition()));
designPythonOutfitVO.setImageSize(StringUtil.isNullOrEmpty(detail.getImageSize()) ? null : (List<Long>) JSON.parse(detail.getImageSize()));
designPythonOutfitVO.setImageUrl(StringUtil.isNullOrEmpty(detail.getImageUrl()) ? null : minIoUtil.getPresignedUrl(detail.getImageUrl(), 24 * 60));
designPythonOutfitVO.setImageMinioUrl(StringUtil.isNullOrEmpty(detail.getImageUrl()) ? null : detail.getImageUrl());
designPythonOutfitVO.setMaskUrl(StringUtil.isNullOrEmpty(detail.getMaskUrl()) ? null : minIoUtil.getPresignedUrl(detail.getMaskUrl(), 24 * 60));
designPythonOutfitVO.setMaskMinioUrl(StringUtil.isNullOrEmpty(detail.getMaskUrl()) ? null : detail.getMaskUrl());
designPythonOutfitVO.setScale(Float.parseFloat(detail.getScale()));
designPythonOutfitVO.setOffset(CollectionUtil.isEmpty(offset) ? Arrays.asList(0L, 0L) : offset);
/*if (!StringUtil.isNullOrEmpty(detail.getImageSize())){
List<Long> size = Arrays.stream(detail.getImageSize().replaceAll("\\[|\\]", "").split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
@@ -69,20 +70,20 @@ public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl<TDesignPyt
}
designPythonOutfitVO.setImageSize(imageSize);
}*/
return designPythonOutfitVO;
}
return designPythonOutfitVO;
}
@Override
public void deleteByDesignPythonOutfitId(Long designPythonOutfitId){
@Override
public void deleteByDesignPythonOutfitId(Long designPythonOutfitId) {
// QueryWrapper<TDesignPythonOutfitDetail> queryWrapper = new QueryWrapper<>();
// queryWrapper.eq("design_python_outfit_id",designPythonOutfitId);
// TDesignPythonOutfitDetail tDesignPythonOutfitDetail = new TDesignPythonOutfitDetail();
// tDesignPythonOutfitDetail.setIsDeleted(1);
UpdateWrapper<TDesignPythonOutfitDetail> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("design_python_outfit_id", designPythonOutfitId);
updateWrapper.set("is_deleted",(byte)1);
UpdateWrapper<TDesignPythonOutfitDetail> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("design_python_outfit_id", designPythonOutfitId);
updateWrapper.set("is_deleted", (byte) 1);
baseMapper.update(null,updateWrapper);
}
baseMapper.update(null, updateWrapper);
}
}

View File

@@ -18,17 +18,17 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
@Service
public class TDesignPythonOutfitServiceImpl extends ServiceImpl<TDesignPythonOutfitMapper, TDesignPythonOutfit> implements ITDesignPythonOutfitService {
@Override
public IPage<TDesignPythonOutfitVO> selectTDesignPythonOutfitPage(IPage<TDesignPythonOutfitVO> page, TDesignPythonOutfitVO tDesignPythonOutfit) {
return page.setRecords(baseMapper.selectTDesignPythonOutfitPage(page, tDesignPythonOutfit));
}
@Override
public IPage<TDesignPythonOutfitVO> selectTDesignPythonOutfitPage(IPage<TDesignPythonOutfitVO> page, TDesignPythonOutfitVO tDesignPythonOutfit) {
return page.setRecords(baseMapper.selectTDesignPythonOutfitPage(page, tDesignPythonOutfit));
}
@Override
public TDesignPythonOutfit getByDesignItemId(Long designItemId){
QueryWrapper<TDesignPythonOutfit> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("design_item_id",designItemId);
@Override
public TDesignPythonOutfit getByDesignItemId(Long designItemId) {
QueryWrapper<TDesignPythonOutfit> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("design_item_id", designItemId);
return getOne(queryWrapper);
}
return getOne(queryWrapper);
}
}

View File

@@ -53,22 +53,22 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
@Override
public void deleteUserGroup(Long userGroupId) {
UserLikeGroup group = getById(userGroupId);
Assert.notNull(group,"History does not exist!");
Assert.notNull(group, "History does not exist!");
userLikeGroupMapper.deleteById(userGroupId);
}
@Override
public HistoryUpdateVO updateUserGroupName(Long userGroupId, String userGroupName,String timeZone) {
public HistoryUpdateVO updateUserGroupName(Long userGroupId, String userGroupName, String timeZone) {
UserLikeGroup group = getById(userGroupId);
Assert.notNull(group,"History does not exist!");
Assert.notNull(group, "History does not exist!");
QueryWrapper<UserLikeGroup> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id", userGroupId);
UserLikeGroup userLikeGroup = new UserLikeGroup();
userLikeGroup.setName(userGroupName);
userLikeGroup.setUpdateDate(DateUtil.getByTimeZone(timeZone));
log.info("跟新group名字###{}###时间是###{}",userLikeGroup.getUpdateDate(),TimeZone.getDefault());
userLikeGroupMapper.update(userLikeGroup,queryWrapper);
return new HistoryUpdateVO(userLikeGroup.getName(),userLikeGroup.getUpdateDate().getTime());
log.info("跟新group名字###{}###时间是###{}", userLikeGroup.getUpdateDate(), TimeZone.getDefault());
userLikeGroupMapper.update(userLikeGroup, queryWrapper);
return new HistoryUpdateVO(userLikeGroup.getName(), userLikeGroup.getUpdateDate().getTime());
}
// public static void main(String[] args) {
@@ -92,7 +92,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
public Long insertUserGroup(Long userId, Long collectionId, String timeZone) {
UserLikeGroup userLikeGroup = new UserLikeGroup();
//默认当前时间
userLikeGroup.setName(DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD_HH_MM_SS));
userLikeGroup.setName(DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS));
userLikeGroup.setCreateDate(DateUtil.getByTimeZone(timeZone));
userLikeGroup.setUpdateDate(DateUtil.getByTimeZone(timeZone));
userLikeGroup.setAccountId(userId);
@@ -104,7 +104,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
@Override
public UserLikeChooseVO choose(Long userGroupId) {
UserLikeGroup group = getById(userGroupId);
Assert.notNull(group,"History does not exist!");
Assert.notNull(group, "History does not exist!");
List<UserLikeVO> userLikeVOS = userLikeService.getGroupDetail(userGroupId);
userLikeVOS.forEach(o -> {
TDesignPythonOutfit tDesignPythonOutfit1 = designPythonOutfitMapper.selectById(o.getDesignOutfitId());
@@ -123,6 +123,6 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
}
});
UserLikeCollectionVO userLikeCollection = collectionService.chooseCollection(group.getCollectionId());
return new UserLikeChooseVO(userGroupId,userLikeVOS,userLikeCollection);
return new UserLikeChooseVO(userGroupId, userLikeVOS, userLikeCollection);
}
}

View File

@@ -38,10 +38,10 @@ public class UserLikeServiceImpl extends ServiceImpl<UserLikeMapper, UserLike> i
QueryWrapper<UserLike> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("user_like_group_id", userGroupId);
List<UserLike> userLikes = userLikeMapper.selectList(queryWrapper);
if(CollectionUtils.isEmpty(userLikes)){
if (CollectionUtils.isEmpty(userLikes)) {
return Lists.newArrayList();
}
return CopyUtil.copyList(userLikes,UserLikeVO.class);
return CopyUtil.copyList(userLikes, UserLikeVO.class);
// List<Long> designItemIds = userLikes.stream().map(UserLike::getDesignItemId).collect(Collectors.toList());
// List<DesignItem> designItems = designItemService.listByIds(designItemIds);
// Map<Long,String> idToUrlMap = designItems.stream().collect(Collectors.toMap(DesignItem::getId,DesignItem::getDesignUrl));
@@ -54,7 +54,7 @@ public class UserLikeServiceImpl extends ServiceImpl<UserLikeMapper, UserLike> i
public List<UserLikeVO> getGroupDetails(List<Long> userGroupIds) {
QueryWrapper<UserLike> queryWrapper = new QueryWrapper<>();
queryWrapper.in("user_like_group_id", userGroupIds);
return CopyUtil.copyList(userLikeMapper.selectList(queryWrapper),UserLikeVO.class);
return CopyUtil.copyList(userLikeMapper.selectList(queryWrapper), UserLikeVO.class);
}
public void deleteByUserGroupId(Long userGroupId) {

View File

@@ -81,6 +81,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
public IPage<WorkspaceVO> selectWorkspacePage(IPage<WorkspaceVO> page, WorkspaceVO workspace) {
return page.setRecords(baseMapper.selectWorkspacePage(page, workspace));
}
private final static String WORKSPACE_NAME = "Default workspace name";
private final static Integer SYSTEM_DESIGNER_PERCENTAGE = 30;
@@ -180,14 +181,14 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
if (o.getMannequinFemaleId() != null) {
if (o.getMannequinFemaleType().equals(ModelType.SYSTEM.getValue())) {
workspaceVO.setFemalePresignedUrl(minioUtil.getPresignedUrl(sysFileMapper.selectById(o.getMannequinFemaleId()).getUrl(), 24 * 60));
}else if (o.getMannequinFemaleType().equals(ModelType.LIBRARY.getValue())) {
} else if (o.getMannequinFemaleType().equals(ModelType.LIBRARY.getValue())) {
workspaceVO.setFemalePresignedUrl(minioUtil.getPresignedUrl(libraryMapper.selectById(o.getMannequinFemaleId()).getUrl(), 24 * 60));
}
}
if (o.getMannequinMaleId() != null) {
if (o.getMannequinMaleType().equals(ModelType.SYSTEM.getValue())) {
workspaceVO.setMalePresignedUrl(minioUtil.getPresignedUrl(sysFileMapper.selectById(o.getMannequinMaleId()).getUrl(), 24 * 60));
}else if (o.getMannequinMaleType().equals(ModelType.LIBRARY.getValue())) {
} else if (o.getMannequinMaleType().equals(ModelType.LIBRARY.getValue())) {
workspaceVO.setMalePresignedUrl(minioUtil.getPresignedUrl(libraryMapper.selectById(o.getMannequinMaleId()).getUrl(), 24 * 60));
}
}
@@ -204,14 +205,14 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
if (o.getMannequinFemaleId() != null) {
if (o.getMannequinFemaleType().equals(ModelType.SYSTEM.getValue())) {
workspaceVO.setFemalePresignedUrl(minioUtil.getPresignedUrl(sysFileMapper.selectById(o.getMannequinFemaleId()).getUrl(), 24 * 60));
}else if (o.getMannequinFemaleType().equals(ModelType.LIBRARY.getValue())) {
} else if (o.getMannequinFemaleType().equals(ModelType.LIBRARY.getValue())) {
workspaceVO.setFemalePresignedUrl(minioUtil.getPresignedUrl(libraryMapper.selectById(o.getMannequinFemaleId()).getUrl(), 24 * 60));
}
}
if (o.getMannequinMaleId() != null) {
if (o.getMannequinMaleType().equals(ModelType.SYSTEM.getValue())) {
workspaceVO.setMalePresignedUrl(minioUtil.getPresignedUrl(sysFileMapper.selectById(o.getMannequinMaleId()).getUrl(), 24 * 60));
}else if (o.getMannequinMaleType().equals(ModelType.LIBRARY.getValue())) {
} else if (o.getMannequinMaleType().equals(ModelType.LIBRARY.getValue())) {
workspaceVO.setMalePresignedUrl(minioUtil.getPresignedUrl(libraryMapper.selectById(o.getMannequinMaleId()).getUrl(), 24 * 60));
}
}
@@ -352,12 +353,12 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
sb.append(o.getAccountId() + "/").append(o.getLevel1Type().toLowerCase() + "/").append(o.getLevel2Type().toLowerCase() + "/").append(file.getName());
}
String bucketName = users;
boolean b = minioUtil.doesObjectExist(bucketName, sb.toString());
if (!b) {
FileItem a = getMultipartFile(file, file.getName());
MultipartFile multipartFile = new CommonsMultipartFile(a);
minioUtil.upload(bucketName, sb.toString(), multipartFile, "");
}
boolean b = minioUtil.doesObjectExist(bucketName, sb.toString());
if (!b) {
FileItem a = getMultipartFile(file, file.getName());
MultipartFile multipartFile = new CommonsMultipartFile(a);
minioUtil.upload(bucketName, sb.toString(), multipartFile, "");
}
o.setUrl(bucketName + "/" + sb);
libraryMapper.updateById(o);
}
@@ -399,7 +400,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
String newUrl = oldUrls[0] + "/sketchboard/female" + oldUrls[1];
library.setUrl(newUrl);
libraryMapper.updateById(library);
}else if (oldUrl.contains("/images")) {
} else if (oldUrl.contains("/images")) {
String[] oldUrls = oldUrl.split("/images");
String newUrl = oldUrls[0] + "/images/female" + oldUrls[1];
library.setUrl(newUrl);
@@ -437,10 +438,10 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
if (absolutePath.contains("bottom")) {
sysFile.setLevel2Type("Bottoms");
sb.append("/bottoms/");
}else if(absolutePath.contains("top")) {
} else if (absolutePath.contains("top")) {
sysFile.setLevel2Type("Tops");
sb.append("/tops/");
}else if(absolutePath.contains("outer")) {
} else if (absolutePath.contains("outer")) {
sysFile.setLevel2Type("Outwear");
sb.append("/outwear/");
}
@@ -456,7 +457,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
// }
FileItem a = getMultipartFile(pngFile, fileName);
MultipartFile multipartFile = new CommonsMultipartFile(a);
minioUtil.upload(url.substring(0,14), url.substring(15), multipartFile, "");
minioUtil.upload(url.substring(0, 14), url.substring(15), multipartFile, "");
sysFile.setCreateDate(new Date());
sysFileMapper.insert(sysFile);
}
@@ -539,7 +540,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
return pngFiles;
}
private static FileItem getMultipartFile(File file, String fieldName){
private static FileItem getMultipartFile(File file, String fieldName) {
// 使用 DiskFileItemFactory 创建一个 FileItemFactory
FileItemFactory factory = new DiskFileItemFactory(16, null);