TASK: 系统模特高宽调整;全局异常优化;
This commit is contained in:
@@ -509,7 +509,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
} else if (designDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
|
||||
SysFileVO byId = sysFileService.getById(designDTO.getTemplateId());
|
||||
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), designDTO.getModelType());
|
||||
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, 680, 200, byId.getUrl()));
|
||||
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, 1050, 500, byId.getUrl()));
|
||||
}
|
||||
elementVO.setModelSex(designDTO.getModelSex());
|
||||
return elementVO;
|
||||
|
||||
@@ -62,9 +62,7 @@ public class CollectionServiceImpl extends ServiceImpl<CollectionMapper, Collect
|
||||
|
||||
@Override
|
||||
public Collection findById(Long id) {
|
||||
QueryWrapper<Collection> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("id", id);
|
||||
return collectionMapper.selectOne(queryWrapper);
|
||||
return collectionMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.ai.da.python.vo.*;
|
||||
import com.ai.da.service.*;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@@ -28,6 +29,7 @@ import com.google.common.collect.Lists;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.*;
|
||||
import org.checkerframework.checker.units.qual.C;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -592,10 +594,13 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public DesignCollectionVO reDesignCollection(ReDesignCollectionDTO reDesignDTO) {
|
||||
//校验collection
|
||||
Collection collection = collectionService.findById(reDesignDTO.getCollectionId());
|
||||
Assert.notNull(collection, "Collection does not exist!");
|
||||
Collection collection = collectionService.getById(reDesignDTO.getCollectionId());
|
||||
if (Objects.isNull(collection)) {
|
||||
throw new BusinessException("collection.not.find");
|
||||
}
|
||||
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
||||
//查询用户 sketch library
|
||||
List<LibraryVo> libraryVos = libraryService.selectByAccountIdAnd1TypeList(userInfo.getId(),
|
||||
@@ -633,8 +638,10 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
|
||||
@Override
|
||||
public DesignCollectionVO designItemList(Long designId) {
|
||||
Design design = getById(designId);
|
||||
Assert.notNull(design, "design does not exist!");
|
||||
Design design = baseMapper.selectById(designId);
|
||||
if (Objects.isNull(design)) {
|
||||
throw new BusinessException("design.not.find");
|
||||
}
|
||||
List<DesignItem> designItems = designItemService.getByDesignId(designId);
|
||||
if (CollectionUtils.isEmpty(designItems)) {
|
||||
return new DesignCollectionVO(designId, design.getCollectionId(), null, null);
|
||||
@@ -651,27 +658,34 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public DesignLikeVO like(DesignLikeDTO designLikeDTO) {
|
||||
Long userGroupId = null;
|
||||
Long groupDetailId = null;
|
||||
Long userGroupId = designLikeDTO.getUserGroupId();;
|
||||
Long groupDetailId;
|
||||
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
||||
DesignItem designItem = designItemService.getById(designLikeDTO.getDesignItemId());
|
||||
Assert.notNull(designItem, "designItem does not exist!");
|
||||
if (Objects.isNull(designItem)) {
|
||||
throw new BusinessException("designItem.not.find");
|
||||
}
|
||||
String pictureName = null;
|
||||
UserLike userLike = null;
|
||||
if (Objects.nonNull(designLikeDTO.getUserGroupId())) {
|
||||
userGroupId = designLikeDTO.getUserGroupId();
|
||||
|
||||
UserLikeGroup userLikeGroup = userLikeGroupService.getById(designLikeDTO.getUserGroupId());
|
||||
Assert.notNull(userLikeGroup, "History does not exist!");
|
||||
UserLike userLike;
|
||||
if (Objects.nonNull(userGroupId)) {
|
||||
UserLikeGroup userLikeGroup = userLikeGroupService.getById(userGroupId);
|
||||
if (Objects.isNull(userLikeGroup)) {
|
||||
throw new BusinessException("userLikeGroup.not.find");
|
||||
}
|
||||
// if(designItem.getCollectionId().equals(userLikeGroup.getCollectionId())){
|
||||
// //相同collection直接跳过 不需要往element加元素
|
||||
// return new DesignLikeVO();
|
||||
// }
|
||||
List<CollectionElement> oldElements = collectionElementService.getByCollectionId(userLikeGroup.getCollectionId());
|
||||
Assert.notEmpty(oldElements, "old elements does not exist!");
|
||||
if (CollectionUtil.isEmpty(oldElements)) {
|
||||
throw new BusinessException("old.elements.not.find");
|
||||
}
|
||||
List<DesignItemDetail> designItemDetails = designItemDetailService.selectByDesignItemId(designLikeDTO.getDesignItemId());
|
||||
Assert.notEmpty(designItemDetails, "new designItemDetails does not exist!");
|
||||
if (CollectionUtil.isEmpty(designItemDetails)) {
|
||||
throw new BusinessException("new.designItemDetails.not.find");
|
||||
}
|
||||
//判断老的element合并到新的是否满足 数量不超过15
|
||||
List<Long> newElementIds = validateMergeElement(oldElements, designItemDetails);
|
||||
//合并,关联新的element到collection
|
||||
@@ -685,7 +699,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
if (CollectionUtils.isEmpty(tDesignPythonOutfits)) {
|
||||
throw new BusinessException("DesignItemId not found elements for ax elements to like! [" + designLikeDTO.getDesignItemId());
|
||||
}
|
||||
userLike = resolveUserLike(designLikeDTO.getUserGroupId(), designItem.getDesignId(),
|
||||
userLike = resolveUserLike(userGroupId, designItem.getDesignId(),
|
||||
designLikeDTO.getDesignItemId(), designLikeDTO.getDesignPythonOutfitId(), tDesignPythonOutfits.get(0).getDesignUrl(), designLikeDTO.getTimeZone());
|
||||
|
||||
} else {
|
||||
@@ -893,29 +907,28 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
.url("http://18.167.251.121:9991/api/get_progress")
|
||||
// .url(accessPythonIp + ":10200/aifda/api/v1.0/generate")
|
||||
.method("POST", body)
|
||||
// .addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
|
||||
.addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = null;
|
||||
Response response;
|
||||
try {
|
||||
response = client.newCall(request).execute();
|
||||
} catch (IOException ioException) {
|
||||
log.error("PythonService##design进度条异常###{}", ExceptionUtil.getThrowableList(ioException));
|
||||
}
|
||||
//去除限流
|
||||
// AccessLimitUtils.validateOut("design");
|
||||
if (Objects.isNull(response)) {
|
||||
log.error("PythonService##design进度条异常###{}", "response or body is empty!");
|
||||
throw new BusinessException("system error!");
|
||||
} catch (IOException e) {
|
||||
log.error("PythonService##design进度条异常###{}", ExceptionUtil.getThrowableList(e));
|
||||
return 0;
|
||||
}
|
||||
if (response.isSuccessful()) {
|
||||
try {
|
||||
String responseBody = response.body().string();
|
||||
JSONObject responseObject = JSON.parseObject(responseBody);
|
||||
String num = responseObject.getString("data");
|
||||
return Integer.valueOf(num);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
if (Objects.nonNull(response.body())) {
|
||||
String responseBody = response.body().string();
|
||||
JSONObject responseObject = JSON.parseObject(responseBody);
|
||||
String num = responseObject.getString("data");
|
||||
return Integer.valueOf(num);
|
||||
}
|
||||
return 0;
|
||||
} catch (IOException | JSONException e) {
|
||||
log.error("PythonService##design进度条异常###{}", ExceptionUtil.getThrowableList(e));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user