@@ -62,7 +62,7 @@ public class PythonService {
*/
public String generatePrint ( List < String > printPath ) {
//限流校验
AccessLimitUtils . validate ( " generatePrint " , 2 ) ;
AccessLimitUtils . validate ( " generatePrint " , 2 ) ;
OkHttpClient client = new OkHttpClient ( ) . newBuilder ( )
. connectTimeout ( 30 , TimeUnit . SECONDS )
. pingInterval ( 5 , TimeUnit . SECONDS ) //websocket轮训间隔(单位:秒)
@@ -156,7 +156,7 @@ public class PythonService {
String path = calculateFileUrl ( operationType ) ;
for ( MultipartFile file : files ) {
File generateFile = FileUtil . upload2 ( file , path ) ;
Assert . notNull ( generateFile , " An error occurred while processing the file, please try again later " ) ;
Assert . notNull ( generateFile , " An error occurred while processing the file, please try again later " ) ;
String linuxDomain = fileProperties . getLinuxDomain ( ) ;
if ( ! StringUtils . isEmpty ( linuxDomain ) ) {
@@ -409,7 +409,7 @@ public class PythonService {
if ( Objects . nonNull ( skirt ) ) {
items . add ( skirt ) ;
}
} else {
} else {
// 男装逻辑
DesignPythonItem top = calculatePythonItemTop ( pinData , elementVO , designPictureType ) ;
if ( Objects . nonNull ( top ) ) {
@@ -494,7 +494,7 @@ public class PythonService {
}
} else {
//系统获取
SysFileVO sysFileVO = getRandomSysFileMaleBottoms ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
SysFileVO sysFileVO = getRandomSysFileMaleBottoms ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
bottom = coverToDesignPythonItem ( null , sysFileVO . getLevel2Type ( ) , sysFileVO . getUrl ( ) , elementVO ) ;
bottom . setBusinessId ( sysFileVO . getId ( ) ) ;
//添加已使用的md5
@@ -524,7 +524,7 @@ public class PythonService {
DesignPythonItem . BOTTOMS , elementVO . getHasUseMd5List ( ) ) ;
if ( StringUtils . isEmpty ( libraryVo ) ) {
//系统获取
SysFileVO sysFileVO = getRandomSysFileMaleBottoms ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
SysFileVO sysFileVO = getRandomSysFileMaleBottoms ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
bottom = coverToDesignPythonItem ( null , sysFileVO . getLevel2Type ( ) , sysFileVO . getUrl ( ) , elementVO ) ;
bottom . setBusinessId ( sysFileVO . getId ( ) ) ;
//添加已使用的md5
@@ -547,7 +547,7 @@ public class PythonService {
}
} else {
//系统获取
SysFileVO sysFileVO = getRandomSysFileMaleBottoms ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
SysFileVO sysFileVO = getRandomSysFileMaleBottoms ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
bottom = coverToDesignPythonItem ( null , sysFileVO . getLevel2Type ( ) , sysFileVO . getUrl ( ) , elementVO ) ;
bottom . setBusinessId ( sysFileVO . getId ( ) ) ;
//添加已使用的md5
@@ -578,7 +578,7 @@ public class PythonService {
CollectionElement collectionElement = getRandomSketchLibrary ( noPinData , elementVO . getHasUseMd5List ( ) ) ;
if ( Objects . isNull ( collectionElement ) ) {
//系统获取
SysFileVO sysFileVO = getRandomSysFileMaleBottoms ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
SysFileVO sysFileVO = getRandomSysFileMaleBottoms ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
bottom = coverToDesignPythonItem ( null , sysFileVO . getLevel2Type ( ) , sysFileVO . getUrl ( ) , elementVO ) ;
bottom . setBusinessId ( sysFileVO . getId ( ) ) ;
} else {
@@ -661,7 +661,7 @@ public class PythonService {
}
} else {
//系统获取
SysFileVO sysFileVO = getRandomSysFileMaleTops ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
SysFileVO sysFileVO = getRandomSysFileMaleTops ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
top = coverToDesignPythonItem ( null , sysFileVO . getLevel2Type ( ) , sysFileVO . getUrl ( ) , elementVO ) ;
top . setBusinessId ( sysFileVO . getId ( ) ) ;
//添加已使用的md5
@@ -691,7 +691,7 @@ public class PythonService {
DesignPythonItem . TOPS , elementVO . getHasUseMd5List ( ) ) ;
if ( StringUtils . isEmpty ( libraryVo ) ) {
//系统获取
SysFileVO sysFileVO = getRandomSysFileMaleTops ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
SysFileVO sysFileVO = getRandomSysFileMaleTops ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
top = coverToDesignPythonItem ( null , sysFileVO . getLevel2Type ( ) , sysFileVO . getUrl ( ) , elementVO ) ;
top . setBusinessId ( sysFileVO . getId ( ) ) ;
//添加已使用的md5
@@ -714,7 +714,7 @@ public class PythonService {
}
} else {
//系统获取
SysFileVO sysFileVO = getRandomSysFileMaleTops ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
SysFileVO sysFileVO = getRandomSysFileMaleTops ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
top = coverToDesignPythonItem ( null , sysFileVO . getLevel2Type ( ) , sysFileVO . getUrl ( ) , elementVO ) ;
top . setBusinessId ( sysFileVO . getId ( ) ) ;
//添加已使用的md5
@@ -745,7 +745,7 @@ public class PythonService {
CollectionElement collectionElement = getRandomSketchLibrary ( noPinData , elementVO . getHasUseMd5List ( ) ) ;
if ( Objects . isNull ( collectionElement ) ) {
//系统获取
SysFileVO sysFileVO = getRandomSysFileMaleTops ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
SysFileVO sysFileVO = getRandomSysFileMaleTops ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
top = coverToDesignPythonItem ( null , sysFileVO . getLevel2Type ( ) , sysFileVO . getUrl ( ) , elementVO ) ;
top . setBusinessId ( sysFileVO . getId ( ) ) ;
} else {
@@ -864,7 +864,7 @@ public class PythonService {
}
} else {
//系统获取
SysFileVO sysFileVO = getRandomSysFileSkirt ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
SysFileVO sysFileVO = getRandomSysFileSkirt ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
skirt = coverToDesignPythonItem ( null , sysFileVO . getLevel2Type ( ) , sysFileVO . getUrl ( ) , elementVO ) ;
skirt . setBusinessId ( sysFileVO . getId ( ) ) ;
//添加已使用的md5
@@ -894,7 +894,7 @@ public class PythonService {
DesignPythonItem . SKIRT_TROUSERS , elementVO . getHasUseMd5List ( ) ) ;
if ( StringUtils . isEmpty ( libraryVo ) ) {
//系统获取
SysFileVO sysFileVO = getRandomSysFileSkirt ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
SysFileVO sysFileVO = getRandomSysFileSkirt ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
skirt = coverToDesignPythonItem ( null , sysFileVO . getLevel2Type ( ) , sysFileVO . getUrl ( ) , elementVO ) ;
skirt . setBusinessId ( sysFileVO . getId ( ) ) ;
//添加已使用的md5
@@ -917,7 +917,7 @@ public class PythonService {
}
} else {
//系统获取
SysFileVO sysFileVO = getRandomSysFileSkirt ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
SysFileVO sysFileVO = getRandomSysFileSkirt ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
skirt = coverToDesignPythonItem ( null , sysFileVO . getLevel2Type ( ) , sysFileVO . getUrl ( ) , elementVO ) ;
skirt . setBusinessId ( sysFileVO . getId ( ) ) ;
//添加已使用的md5
@@ -948,7 +948,7 @@ public class PythonService {
CollectionElement collectionElement = getRandomSketchLibrary ( noPinData , elementVO . getHasUseMd5List ( ) ) ;
if ( Objects . isNull ( collectionElement ) ) {
//系统获取
SysFileVO sysFileVO = getRandomSysFileSkirt ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
SysFileVO sysFileVO = getRandomSysFileSkirt ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
skirt = coverToDesignPythonItem ( null , sysFileVO . getLevel2Type ( ) , sysFileVO . getUrl ( ) , elementVO ) ;
skirt . setBusinessId ( sysFileVO . getId ( ) ) ;
} else {
@@ -1033,7 +1033,7 @@ public class PythonService {
}
} else {
//系统获取
SysFileVO sysFileVO = getRandomSysFileOutwear ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
SysFileVO sysFileVO = getRandomSysFileOutwear ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
DesignPythonItem item = coverToDesignPythonItem ( null , sysFileVO . getLevel2Type ( ) , sysFileVO . getUrl ( ) , elementVO ) ;
item . setBusinessId ( sysFileVO . getId ( ) ) ;
items . add ( item ) ;
@@ -1065,7 +1065,7 @@ public class PythonService {
DesignPythonItem . OUTWEAR_DRESS_BLOUSE , elementVO . getHasUseMd5List ( ) ) ;
if ( StringUtils . isEmpty ( libraryVo ) ) {
//系统获取
SysFileVO sysFileVO = getRandomSysFileOutwear ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
SysFileVO sysFileVO = getRandomSysFileOutwear ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
DesignPythonItem item = coverToDesignPythonItem ( null , sysFileVO . getLevel2Type ( ) , sysFileVO . getUrl ( ) , elementVO ) ;
item . setBusinessId ( sysFileVO . getId ( ) ) ;
items . add ( item ) ;
@@ -1090,7 +1090,7 @@ public class PythonService {
}
} else {
//系统获取
SysFileVO sysFileVO = getRandomSysFileOutwear ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
SysFileVO sysFileVO = getRandomSysFileOutwear ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
DesignPythonItem item = coverToDesignPythonItem ( null , sysFileVO . getLevel2Type ( ) , sysFileVO . getUrl ( ) , elementVO ) ;
item . setBusinessId ( sysFileVO . getId ( ) ) ;
items . add ( item ) ;
@@ -1122,7 +1122,7 @@ public class PythonService {
CollectionElement collectionElement = getRandomSketchLibrary ( noPinData , elementVO . getHasUseMd5List ( ) ) ;
if ( Objects . isNull ( collectionElement ) ) {
//系统获取
SysFileVO sysFileVO = getRandomSysFileOutwear ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
SysFileVO sysFileVO = getRandomSysFileOutwear ( elementVO . getSysFileVo ( ) , elementVO . getSysFileIds ( ) , elementVO . getModelSex ( ) ) ;
DesignPythonItem item = coverToDesignPythonItem ( null , sysFileVO . getLevel2Type ( ) , sysFileVO . getUrl ( ) , elementVO ) ;
item . setBusinessId ( sysFileVO . getId ( ) ) ;
items . add ( item ) ;
@@ -1194,7 +1194,7 @@ public class PythonService {
Map < String , List < Integer > > body_point = Maps . newHashMap ( ) ;
if ( Objects . nonNull ( designLibraryModelPointOld ) ) {
DesignLibraryModelPointVO designLibraryModelPoint =
CopyUtil . copyObject ( designLibraryModelPointOld , DesignLibraryModelPointVO . class ) ;
CopyUtil . copyObject ( designLibraryModelPointOld , DesignLibraryModelPointVO . class ) ;
//自己的template是6个点
body_point . put ( " shoulder_left " , resolve ( designLibraryModelPoint . getShoulderLeft ( ) ) ) ;
body_point . put ( " shoulder_right " , resolve ( designLibraryModelPoint . getShoulderRight ( ) ) ) ;
@@ -1224,7 +1224,7 @@ public class PythonService {
private List < Integer > resolve ( List < BigDecimal > list ) {
List < Integer > integerList = Lists . newArrayList ( ) ;
list . forEach ( l - > {
list . forEach ( l - > {
integerList . add ( new Integer ( l . intValue ( ) ) ) ;
} ) ;
return integerList ;
@@ -1283,41 +1283,41 @@ public class PythonService {
private SysFileVO getRandomSysFileOutwear ( List < SysFileVO > sysFileVo , List < Long > sysFileIds , String modelSex ) {
Long randomIndex = RandomsUtil . randomSysFile ( 0L , 3L ) ;
if ( CollectionUtils . isEmpty ( sysFileVo ) ) {
if ( CollectionUtils . isEmpty ( sysFileVo ) ) {
return getRandomSysFileByLevel2Type ( DesignPythonItem . OUTWEAR_DRESS_BLOUSE . get ( randomIndex . intValue ( ) ) , sysFileIds , modelSex ) ;
} else {
} else {
//attribute_retrieval 算法,满足blouse + outwear+dress>8,以及 skirt+trousers>8
return getRandomSysFileByAttributeRetrieval ( DesignPythonItem . OUTWEAR_DRESS_BLOUSE , sysFileVo , sysFileIds ) ;
return getRandomSysFileByAttributeRetrieval ( DesignPythonItem . OUTWEAR_DRESS_BLOUSE , sysFileVo , sysFileIds ) ;
}
}
private SysFileVO getRandomSysFileMaleTops ( List < SysFileVO > sysFileVo , List < Long > sysFileIds , String modelSex ) {
Long randomIndex = RandomsUtil . randomSysFile ( 0L , 1L ) ;
if ( CollectionUtils . isEmpty ( sysFileVo ) ) {
if ( CollectionUtils . isEmpty ( sysFileVo ) ) {
return getRandomSysFileByLevel2Type ( DesignPythonItem . TOPS . get ( randomIndex . intValue ( ) ) , sysFileIds , modelSex ) ;
} else {
} else {
//attribute_retrieval 算法,满足blouse + outwear+dress>8,以及 skirt+trousers>8
return getRandomSysFileByAttributeRetrieval ( DesignPythonItem . TOPS , sysFileVo , sysFileIds ) ;
return getRandomSysFileByAttributeRetrieval ( DesignPythonItem . TOPS , sysFileVo , sysFileIds ) ;
}
}
private SysFileVO getRandomSysFileMaleBottoms ( List < SysFileVO > sysFileVo , List < Long > sysFileIds , String modelSex ) {
Long randomIndex = RandomsUtil . randomSysFile ( 0L , 1L ) ;
if ( CollectionUtils . isEmpty ( sysFileVo ) ) {
if ( CollectionUtils . isEmpty ( sysFileVo ) ) {
return getRandomSysFileByLevel2Type ( DesignPythonItem . BOTTOMS . get ( randomIndex . intValue ( ) ) , sysFileIds , modelSex ) ;
} else {
} else {
//attribute_retrieval 算法,满足blouse + outwear+dress>8,以及 skirt+trousers>8
return getRandomSysFileByAttributeRetrieval ( DesignPythonItem . BOTTOMS , sysFileVo , sysFileIds ) ;
return getRandomSysFileByAttributeRetrieval ( DesignPythonItem . BOTTOMS , sysFileVo , sysFileIds ) ;
}
}
private SysFileVO getRandomSysFileSkirt ( List < SysFileVO > sysFileVo , List < Long > sysFileIds , String modelSex ) {
Long randomIndex = RandomsUtil . randomSysFile ( 0L , 2L ) ;
if ( CollectionUtils . isEmpty ( sysFileVo ) ) {
if ( CollectionUtils . isEmpty ( sysFileVo ) ) {
return getRandomSysFileByLevel2Type ( DesignPythonItem . SKIRT_TROUSERS . get ( randomIndex . intValue ( ) ) , sysFileIds , modelSex ) ;
} else {
} else {
//attribute_retrieval 算法,满足blouse + outwear+dress>8,以及 skirt+trousers>8
return getRandomSysFileByAttributeRetrieval ( DesignPythonItem . SKIRT_TROUSERS , sysFileVo , sysFileIds ) ;
return getRandomSysFileByAttributeRetrieval ( DesignPythonItem . SKIRT_TROUSERS , sysFileVo , sysFileIds ) ;
}
}
@@ -1331,9 +1331,10 @@ public class PythonService {
sysFileIds . add ( sysFileId ) ;
return sysFileService . getById ( sysFileId ) ;
}
private SysFileVO getRandomSysFileByAttributeRetrieval ( List < String > level2TypeList , List < SysFileVO > sysFileVo , List < Long > sysFileIds ) {
private SysFileVO getRandomSysFileByAttributeRetrieval ( List < String > level2TypeList , List < SysFileVO > sysFileVo , List < Long > sysFileIds ) {
sysFileVo = sysFileVo . stream ( ) . filter (
f - > level2TypeList . contains ( f . getLevel2Type ( ) ) & & ( ! sysFileIds . contains ( f . getId ( ) ) ) )
f - > level2TypeList . contains ( f . getLevel2Type ( ) ) & & ( ! sysFileIds . contains ( f . getId ( ) ) ) )
. collect ( Collectors . toList ( ) ) ;
Long maxId = ( long ) sysFileVo . size ( ) ;
Long minId = 0L ;
@@ -1456,7 +1457,7 @@ public class PythonService {
*/
public Boolean design ( DesignPythonObjects designPythonObjects ) {
//限流校验
AccessLimitUtils . validate ( " design " , 5 ) ;
AccessLimitUtils . validate ( " design " , 5 ) ;
OkHttpClient client = new OkHttpClient ( ) . newBuilder ( )
. connectTimeout ( 30 , TimeUnit . SECONDS )
. pingInterval ( 5 , TimeUnit . SECONDS ) //websocket轮训间隔(单位:秒)
@@ -1509,7 +1510,7 @@ public class PythonService {
*/
public String generateHighDesign ( String designPath ) {
//限流校验
AccessLimitUtils . validate ( " generateHighDesign " , 2 ) ;
AccessLimitUtils . validate ( " generateHighDesign " , 2 ) ;
OkHttpClient client = new OkHttpClient ( ) . newBuilder ( )
. connectTimeout ( 30 , TimeUnit . SECONDS )
. pingInterval ( 5 , TimeUnit . SECONDS ) //websocket轮训间隔(单位:秒)
@@ -1550,6 +1551,7 @@ public class PythonService {
//生成失败
throw new BusinessException ( " system error! " ) ;
}
/**
* 生成 attribute_retrieval
*
@@ -1557,9 +1559,9 @@ public class PythonService {
* @param modelSex
* @return
*/
public DesignAttributeRetrievalDTO generateAttributeRetrieval ( List < String > sketchUrlList , Long userId , String modelSex ) {
public DesignAttributeRetrievalDTO generateAttributeRetrieval ( List < String > sketchUrlList , Long userId , String modelSex ) {
//限流校验
AccessLimitUtils . validate ( " generateAttributeRetrieval " , 4 ) ;
AccessLimitUtils . validate ( " generateAttributeRetrieval " , 4 ) ;
OkHttpClient client = new OkHttpClient ( ) . newBuilder ( )
. connectTimeout ( 30 , TimeUnit . SECONDS )
. pingInterval ( 5 , TimeUnit . SECONDS ) //websocket轮训间隔(单位:秒)
@@ -1603,34 +1605,35 @@ public class PythonService {
//生成失败
throw new BusinessException ( " system error! " ) ;
}
private static DesignAttributeRetrievalDTO resolveDesignAttributeRetrievalDTO ( String bodyStr ) {
private static DesignAttributeRetrievalDTO resolveDesignAttributeRetrievalDTO ( String bodyStr ) {
DesignAttributeRetrievalDTO response = new DesignAttributeRetrievalDTO ( ) ;
JSONObject jsonObject = JSON . parseObject ( bodyStr ) ;
JSONObject data = jsonObject . getJSONObject ( " data " ) ;
if ( data ! = null ) {
JSONObject jsonObjectSys = data . getJSONObject ( " sys_lib_dict " ) ;
if ( null = = jsonObjectSys | | jsonObjectSys . size ( ) = = 0 ) {
if ( null = = jsonObjectSys | | jsonObjectSys . size ( ) = = 0 ) {
log . error ( " generateAttributeRetrieval异常###{} " , " jsonObjectSys is empty! " ) ;
throw new BusinessException ( " system error! " ) ;
}
setUrls ( jsonObjectSys , response . getSysFileUrlS ( ) ) ;
setUrls ( jsonObjectSys , response . getSysFileUrlS ( ) ) ;
JSONObject jsonObjectLibrary = data . getJSONObject ( " user_lib_dict " ) ;
if ( null = = jsonObjectLibrary | | jsonObjectLibrary . size ( ) = = 0 ) {
if ( null = = jsonObjectLibrary | | jsonObjectLibrary . size ( ) = = 0 ) {
log . error ( " generateAttributeRetrieval异常###{} " , " jsonObjectLibrary is empty! " ) ;
throw new BusinessException ( " system error! " ) ;
}
setUrls ( jsonObjectLibrary , response . getLibraryUrls ( ) ) ;
setUrls ( jsonObjectLibrary , response . getLibraryUrls ( ) ) ;
return response ;
}
throw new BusinessException ( " AttributeRetrieval response data is null " ) ;
}
private static void setUrls ( JSONObject jsonObjectSys , List < String > urls ) {
private static void setUrls ( JSONObject jsonObjectSys , List < String > urls ) {
List < String > finalUrls = urls ;
SysFileLevel2TypeEnum . ofPythonPath ( ) . forEach ( path - > {
SysFileLevel2TypeEnum . ofPythonPath ( ) . forEach ( path - > {
JSONArray array = jsonObjectSys . getJSONArray ( path ) ;
List < String > urlList = JSONObject . parseArray ( JSON . toJSONString ( array ) , String . class ) ;
if ( CollectionUtil . isNotEmpty ( urlList ) ) {
List < String > urlList = JSONObject . parseArray ( JSON . toJSONString ( array ) , String . class ) ;
if ( CollectionUtil . isNotEmpty ( urlList ) ) {
finalUrls . addAll ( urlList ) ;
}
} ) ;
@@ -1658,6 +1661,7 @@ public class PythonService {
/**
* 组装和计算设计包括图层的单品的参数, 不需要priority
*
* @param designSingleDTO
* @param singleOverall
* @param switchCategory
@@ -1702,6 +1706,7 @@ public class PythonService {
/**
* 设计包括图层的单品,每次只针对一个单品
*
* @param designSingleIncludeLayersDTO
* @param designLibraryModelPoint
* @return
@@ -1731,16 +1736,15 @@ public class PythonService {
// bodyPath = "/workspace/python_code/Multi-layer-Virtual-Try-on/dataset_for_test/Img_model.png";
bodyPath = " aida-mannequins/model_1693218345.2714432.png " ;
}
response . add ( new DesignPythonItem ( SysFileLevel2TypeEnum . BODY . getRealName ( ) , bodyPath , pythonTAllInfoService . getImageIdByPath ( bodyPath ) ) ) ;
response . add ( new DesignPythonItem ( SysFileLevel2TypeEnum . BODY . getRealName ( ) , bodyPath , pythonTAllInfoService . getImageIdByPath ( bodyPath ) ) ) ;
return response ;
}
private DesignPythonItemPrint resolveDesignSinglePrint ( DesignSinglePrintDTO printObject , String clothesPath ) {
// 没有印花时的参数设置
if ( printObject . getIfSingle ( ) . equals ( Boolean . FALSE ) & & CollectionUtil . isEmpty ( printObject . getPrints ( ) ) ) {
return new DesignPythonItemPrint ( new ArrayList < > ( ) , false ) ;
return new DesignPythonItemPrint ( new ArrayList < > ( ) , false ) ;
}
DesignPythonItemPrint print = CopyUtil . copyObject ( printObject , DesignPythonItemPrint . class ) ;
// if(StringUtils.isEmpty(printObject.getPath())){
@@ -1769,13 +1773,13 @@ public class PythonService {
// 设置印花的位置、大小、旋转角度
List < DesignSinglePrint > prints = printObject . getPrints ( ) ;
prints . forEach ( p - > {
p . getLocation ( ) . set ( 0 , p . getLocation ( ) . get ( 0 ) ) ;
p . getLocation ( ) . set ( 1 , p . getLocation ( ) . get ( 1 ) ) ;
p . getLocation ( ) . set ( 0 , p . getLocation ( ) . get ( 0 ) ) ;
p . getLocation ( ) . set ( 1 , p . getLocation ( ) . get ( 1 ) ) ;
Integer priority = p . getPriority ( ) ;
location . add ( priority - 1 , p . getLocation ( ) ) ;
scale . add ( priority - 1 , p . getScale ( ) ) ;
angle . add ( priority - 1 , p . getAngle ( ) ) ;
paths . add ( priority - 1 , p . getMinIOPath ( ) ) ;
scale . add ( priority - 1 , p . getScale ( ) ) ;
angle . add ( priority - 1 , p . getAngle ( ) ) ;
paths . add ( priority - 1 , p . getMinIOPath ( ) ) ;
// log.info("本次print打点locations###{}###fileVO{}", p.getLocation(), JSON.toJSONString(fileVO));
} ) ;
print . setLocation ( location ) ;
@@ -1808,6 +1812,7 @@ public class PythonService {
/**
* 设计包括图层的单品, 不用指定save_name和priority
*
* @param singleOverall
* @param switchCategory
* @param designLibraryModelPoint
@@ -1939,7 +1944,7 @@ public class PythonService {
// log.info("PythonService##responseBodyStr###{}", response.body().string());
// log.info("PythonService##responseBodyJson###{}", JSON.toJSONString(response.body()));
String responseBody = response . body ( ) . string ( ) ;
JSONObject responseObject = JSON . parseObject ( responseBody ) ;
JSONObject responseObject = JSON . parseObject ( responseBody ) ;
return responseObject ;
} catch ( IOException ioException ) {
log . error ( " PythonService##design异常###{} " , ExceptionUtil . getThrowableList ( ioException ) ) ;
@@ -1956,9 +1961,9 @@ public class PythonService {
if ( response . isSuccessful ( ) ) {
try {
String responseBody = response . body ( ) . string ( ) ;
JSONObject responseObject = JSON . parseObject ( responseBody ) ;
JSONObject responseObject = JSON . parseObject ( responseBody ) ;
return responseObject ;
} catch ( IOException e ) {
} catch ( IOException e ) {
throw new RuntimeException ( e ) ;
}
}
@@ -1968,10 +1973,9 @@ public class PythonService {
}
public String generateSketchCaption ( String url ) {
public String generateSketchCaption ( String url ) {
//限流校验
AccessLimitUtils . validate ( " generateSketchCaption " , 5 ) ;
AccessLimitUtils . validate ( " generateSketchCaption " , 5 ) ;
OkHttpClient client = new OkHttpClient ( ) . newBuilder ( )
. connectTimeout ( 30 , TimeUnit . SECONDS )
. pingInterval ( 5 , TimeUnit . SECONDS ) //websocket轮训间隔(单位:秒)
@@ -1981,7 +1985,7 @@ public class PythonService {
MediaType mediaType = MediaType . parse ( " application/json " ) ;
RequestBody body = RequestBody . create ( mediaType , url ) ;
Request request = new Request . Builder ( )
. url ( accessPythonIp + " :2828/aida/interrogator " )
. url ( accessPythonIp + " :2828/aida/interrogator " )
. method ( " POST " , body )
. addHeader ( " Authorization " , " Basic YWlkbGFiOjEyMw== " )
. addHeader ( " Content-Type " , " application/json " )
@@ -2011,9 +2015,9 @@ public class PythonService {
throw new BusinessException ( " system error! " ) ;
}
public List < String > generateSketchOrPrint ( Long userId , String url , String category , String text , int mode , String modelName ) {
public List < String > generateSketchOrPrint ( Long userId , String url , String category , String text , int mode , String modelName ) {
//限流校验
AccessLimitUtils . validate ( " generateSketchOrPrint " , 5 ) ;
AccessLimitUtils . validate ( " generateSketchOrPrint " , 5 ) ;
OkHttpClient client = new OkHttpClient ( ) . newBuilder ( )
. connectTimeout ( 30 , TimeUnit . SECONDS )
. pingInterval ( 5 , TimeUnit . SECONDS ) //websocket轮训间隔(单位:秒)
@@ -2025,10 +2029,10 @@ public class PythonService {
content . put ( " user_id " , userId ) ;
content . put ( " image_url " , url ) ;
content . put ( " category " , category ) ;
content . put ( " mode " , mode ) ;
content . put ( " mode " , mode ) ;
content . put ( " str " , text ) ;
content . put ( " version " , modelName ) ;
RequestBody body = RequestBody . create ( mediaType , JSON . toJSONString ( content , SerializerFeature . WriteMapNullValue ) ) ;
content . put ( " version " , modelName ) ;
RequestBody body = RequestBody . create ( mediaType , JSON . toJSONString ( content , SerializerFeature . WriteMapNullValue ) ) ;
Request request = new Request . Builder ( )
// .url(accessPythonIp + ":2828/aida/diffusion")
// .url("http://18.167.251.121:9992")
@@ -2040,7 +2044,7 @@ public class PythonService {
Response response = null ;
String bodyString = null ;
try {
log . info ( " generateSketchOrPrint请求入参content###{} " , JSON . toJSONString ( content , SerializerFeature . WriteMapNullValue ) ) ;
log . info ( " generateSketchOrPrint请求入参content###{} " , JSON . toJSONString ( content , SerializerFeature . WriteMapNullValue ) ) ;
response = client . newCall ( request ) . execute ( ) ;
bodyString = response . body ( ) . string ( ) ;
// bodyString = "{\n" +
@@ -2073,7 +2077,7 @@ public class PythonService {
throw new BusinessException ( " Generate Exception! Code : " + jsonObject . get ( " code " ) ) ;
}
public Response sendPostToModel ( String content , String portAndRoute , String functionName ) {
public Response sendPostToModel ( String content , String portAndRoute , String functionName ) {
OkHttpClient client = new OkHttpClient ( ) . newBuilder ( )
. connectTimeout ( 30 , TimeUnit . SECONDS )
@@ -2096,15 +2100,15 @@ public class PythonService {
response = client . newCall ( request ) . execute ( ) ;
// bodyString = response.body().string();
} catch ( IOException ioException ) {
log . error ( " PythonService## " + functionName + " 异常###{} " , ExceptionUtil . getThrowableList ( ioException ) ) ;
log . error ( " PythonService## " + functionName + " 异常###{} " , ExceptionUtil . getThrowableList ( ioException ) ) ;
}
return response ;
}
private List < String > setGenerateImageList ( JSONObject jsonObject ) {
List < String > imageUrlList = JSONObject . parseArray ( jsonObject . get ( " list " ) . toString ( ) , String . class ) ;
if ( imageUrlList . isEmpty ( ) ) {
log . error ( " PythonService##generateSketchOrPrint异常###{} " , " diffusion response list is null " ) ;
private List < String > setGenerateImageList ( JSONObject jsonObject ) {
List < String > imageUrlList = JSONObject . parseArray ( jsonObject . get ( " list " ) . toString ( ) , String . class ) ;
if ( imageUrlList . isEmpty ( ) ) {
log . error ( " PythonService##generateSketchOrPrint异常###{} " , " diffusion response list is null " ) ;
// todo 如果这里返回为空,是判断出错还是返回给前端空
throw new BusinessException ( " The data returned on the python side is empty " ) ;
}
@@ -2116,7 +2120,7 @@ public class PythonService {
HashMap < String , List < OutfitDetailPythonItem > > layers = new HashMap < > ( ) ;
HashMap < String , HashMap < String , List < OutfitDetailPythonItem > > > content = new HashMap < > ( ) ;
layers . put ( " layers " , layersDetail ) ;
content . put ( " 0 " , layers ) ;
content . put ( " 0 " , layers ) ;
String jsonString = JSON . toJSONString ( content , SerializerFeature . WriteNullStringAsEmpty ) ;
// todo 添加限流
@@ -2128,7 +2132,7 @@ public class PythonService {
if ( Objects . isNull ( response ) | | Objects . isNull ( response . body ( ) ) ) {
log . error ( " PythonService##composeLayers异常###{} " , " response or body is empty! " ) ;
throw new BusinessException ( " generate exception! " ) ;
} else {
} else {
bodyString = response . body ( ) . string ( ) ;
}
JSONObject jsonObject = JSON . parseObject ( bodyString ) ;
@@ -2141,7 +2145,7 @@ public class PythonService {
throw new BusinessException ( " composeLayers Exception! " ) ;
}
private String getCompositeImage ( JSONObject jsonObject ) {
private String getCompositeImage ( JSONObject jsonObject ) {
JSONObject item0 = jsonObject . getJSONObject ( " 0 " ) ;
return item0 . getString ( " synthesis_url " ) ;
}