TASK: attribute_retrieval;
This commit is contained in:
@@ -1554,9 +1554,10 @@ public class PythonService {
|
||||
* 生成 attribute_retrieval
|
||||
*
|
||||
* @param sketchUrlList
|
||||
* @param modelSex
|
||||
* @return
|
||||
*/
|
||||
public DesignAttributeRetrievalDTO generateAttributeRetrieval(List<String> sketchUrlList, Long userId) {
|
||||
public DesignAttributeRetrievalDTO generateAttributeRetrieval(List<String> sketchUrlList, Long userId, String modelSex) {
|
||||
//限流校验
|
||||
AccessLimitUtils.validate("generateAttributeRetrieval",4);
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
@@ -1568,6 +1569,7 @@ public class PythonService {
|
||||
Map<String, Object> content = Maps.newHashMap();
|
||||
content.put("sketch_upload_img_path", sketchUrlList);
|
||||
content.put("userid", userId);
|
||||
content.put("colony", modelSex);
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content));
|
||||
Request request = new Request.Builder()
|
||||
@@ -1604,19 +1606,23 @@ public class PythonService {
|
||||
private static DesignAttributeRetrievalDTO resolveDesignAttributeRetrievalDTO(String bodyStr){
|
||||
DesignAttributeRetrievalDTO response = new DesignAttributeRetrievalDTO();
|
||||
JSONObject jsonObject = JSON.parseObject(bodyStr);
|
||||
JSONObject jsonObjectSys = jsonObject.getJSONObject("sys_lib_dict");
|
||||
if(null == jsonObjectSys || jsonObjectSys.size() == 0){
|
||||
log.error("generateAttributeRetrieval异常###{}", "jsonObjectSys is empty!");
|
||||
throw new BusinessException("system error!");
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
if (data != null) {
|
||||
JSONObject jsonObjectSys = data.getJSONObject("sys_lib_dict");
|
||||
if(null == jsonObjectSys || jsonObjectSys.size() == 0){
|
||||
log.error("generateAttributeRetrieval异常###{}", "jsonObjectSys is empty!");
|
||||
throw new BusinessException("system error!");
|
||||
}
|
||||
setUrls(jsonObjectSys,response.getSysFileUrlS());
|
||||
JSONObject jsonObjectLibrary = data.getJSONObject("user_lib_dict");
|
||||
if(null == jsonObjectLibrary || jsonObjectLibrary.size() == 0){
|
||||
log.error("generateAttributeRetrieval异常###{}", "jsonObjectLibrary is empty!");
|
||||
throw new BusinessException("system error!");
|
||||
}
|
||||
setUrls(jsonObjectLibrary,response.getLibraryUrls());
|
||||
return response;
|
||||
}
|
||||
setUrls(jsonObjectSys,response.getSysFileUrlS());
|
||||
JSONObject jsonObjectLibrary = jsonObject.getJSONObject("user_lib_dict");
|
||||
if(null == jsonObjectLibrary || jsonObjectLibrary.size() == 0){
|
||||
log.error("generateAttributeRetrieval异常###{}", "jsonObjectLibrary is empty!");
|
||||
throw new BusinessException("system error!");
|
||||
}
|
||||
setUrls(jsonObjectLibrary,response.getLibraryUrls());
|
||||
return response;
|
||||
throw new BusinessException("AttributeRetrieval response data is null");
|
||||
}
|
||||
|
||||
private static void setUrls(JSONObject jsonObjectSys,List<String> urls){
|
||||
|
||||
@@ -110,26 +110,24 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
private void calculateLibraryAndSysFile(DesignCollectionDTO designDTO, ValidateElementVO elementVO, AuthPrincipalVo userInfo) {
|
||||
//查询用户 sketch library
|
||||
List<LibraryVo> libraryVos;
|
||||
// if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) {
|
||||
// List<String> sketchUrlList = elementVO.getSketchBoardElements()
|
||||
// .stream()
|
||||
// .map(CollectionElement::getUrl)
|
||||
// .collect(Collectors.toList());
|
||||
// DesignAttributeRetrievalDTO designAttributeRetrievalDTO =
|
||||
// pythonService.generateAttributeRetrieval(sketchUrlList, userInfo.getId());
|
||||
// if (CollectionUtils.isEmpty(designAttributeRetrievalDTO.getLibraryUrls())) {
|
||||
// libraryVos = null;
|
||||
// } else {
|
||||
// libraryVos = libraryService.getByUrlList(designAttributeRetrievalDTO.getLibraryUrls(), userInfo.getId());
|
||||
// }
|
||||
// List<SysFileVO> sysFileVOS = sysFileService.getByUrlList(designAttributeRetrievalDTO.getSysFileUrlS());
|
||||
// elementVO.setSysFileVo(sysFileVOS);
|
||||
// } else {
|
||||
// libraryVos = libraryService.selectByAccountIdAnd1TypeList(userInfo.getId(),
|
||||
// Collections.singletonList(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName()));
|
||||
// }
|
||||
libraryVos = libraryService.selectByAccountIdAnd1TypeList(userInfo.getId(),
|
||||
Collections.singletonList(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName()));
|
||||
if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) {
|
||||
List<String> sketchUrlList = elementVO.getSketchBoardElements()
|
||||
.stream()
|
||||
.map(CollectionElement::getUrl)
|
||||
.collect(Collectors.toList());
|
||||
DesignAttributeRetrievalDTO designAttributeRetrievalDTO =
|
||||
pythonService.generateAttributeRetrieval(sketchUrlList, userInfo.getId(), elementVO.getModelSex());
|
||||
if (CollectionUtils.isEmpty(designAttributeRetrievalDTO.getLibraryUrls())) {
|
||||
libraryVos = null;
|
||||
} else {
|
||||
libraryVos = libraryService.getByUrlList(designAttributeRetrievalDTO.getLibraryUrls(), userInfo.getId());
|
||||
}
|
||||
List<SysFileVO> sysFileVOS = sysFileService.getByUrlList(designAttributeRetrievalDTO.getSysFileUrlS());
|
||||
elementVO.setSysFileVo(sysFileVOS);
|
||||
} else {
|
||||
libraryVos = libraryService.selectByAccountIdAnd1TypeList(userInfo.getId(),
|
||||
Collections.singletonList(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName()));
|
||||
}
|
||||
elementVO.setLibraryVos(libraryVos);
|
||||
//校验比列
|
||||
validateRatio(designDTO, libraryVos);
|
||||
|
||||
Reference in New Issue
Block a user