Merge branch 'dev/dev_xp' into dev/dev

This commit is contained in:
2024-03-26 15:02:12 +08:00
72 changed files with 2968 additions and 232 deletions

View File

@@ -65,6 +65,8 @@ public class PythonService {
private String accessPythonIp;
@Value("${access.python.port:''}")
private String accessPythonPort;
@Value("${access.python.sr}")
private String srPythonPort;
@Resource
private PythonTAllInfoService pythonTAllInfoService;
@@ -290,7 +292,7 @@ public class PythonService {
List<CollectionElement> pinData = getPinData(elementVO);
if (CollectionUtil.isNotEmpty(pinData)) {
return CurrentDesignPictureTypeEnum.PIN;
}else {
} else {
if (sysSketchNum == 0 && noPinSketchNum == 0) {
sysSketchNum = systemScale.multiply(BigDecimal.valueOf(8 - pinSketchNum)).setScale(0, BigDecimal.ROUND_HALF_UP).intValue();
noPinSketchNum = 8 - pinSketchNum - sysSketchNum;
@@ -605,6 +607,7 @@ public class PythonService {
@Resource
private AttributeRetrievalMapper attributeRetrievalMapper;
private List<CollectionElement> getSystemSketchPool(JSONObject attributeRecognition, String styleCategory, String modelSex, int poolNum) {
/**
* female trousers->female_pants
@@ -847,6 +850,7 @@ public class PythonService {
private CollocationMapper collocationMapper;
@Resource
private DressingMapper dressingMapper;
private List<String> getOtherSketchCategoryList(String modelSex, DesignPythonItem designPythonItem) {
List<Collocation> collocationList = collocationMapper.getCollocationListBySketch(modelSex, designPythonItem.getType());
if (CollectionUtil.isNotEmpty(collocationList)) {
@@ -2003,10 +2007,10 @@ public class PythonService {
if (elementVO.getSingleOverall().equals(SingleOverallEnum.SINGLE.getRealName())) {
if (!CollectionUtils.isEmpty(pinData)) {
return pinData.stream().filter(o -> o.getLevel2Type().equals(elementVO.getSwitchCategory())).collect(Collectors.toList());
}else {
} else {
return pinData;
}
}else {
} else {
return pinData;
}
}
@@ -2016,10 +2020,10 @@ public class PythonService {
if (elementVO.getSingleOverall().equals(SingleOverallEnum.SINGLE.getRealName())) {
if (!CollectionUtils.isEmpty(pinData)) {
return pinData.stream().filter(o -> o.getLevel2Type().equals(elementVO.getSwitchCategory())).collect(Collectors.toList());
}else {
} else {
return pinData;
}
}else {
} else {
return pinData;
}
}
@@ -2042,8 +2046,8 @@ public class PythonService {
return sketchBoardPins;
}
public final static List<String> FEMALE_CATEGORY = Arrays.asList("Dress","Blouse","Skirt","Trousers","Outwear");
public final static List<String> MALE_CATEGORY = Arrays.asList("Tops","Bottoms","Outwear");
public final static List<String> FEMALE_CATEGORY = Arrays.asList("Dress", "Blouse", "Skirt", "Trousers", "Outwear");
public final static List<String> MALE_CATEGORY = Arrays.asList("Tops", "Bottoms", "Outwear");
private List<CollectionElement> getPinData(List<CollectionElement> sketchBoardElements, List<String> hasUseMd5List, String modelSex) {
if (CollectionUtils.isEmpty(sketchBoardElements)) {
@@ -2070,7 +2074,7 @@ public class PythonService {
return null;
}
return noPinData.stream().filter(o -> o.getLevel2Type().equals(elementVO.getSwitchCategory())).collect(Collectors.toList());
}else {
} else {
return getNoPinData(elementVO.getSketchBoardElements(), elementVO.getModelSex());
}
}
@@ -2929,6 +2933,7 @@ public class PythonService {
Boolean result = JSON.parseObject(JSON.toJSONString(response)).getBoolean("successful");
if (result && jsonObject.get("code").equals(200)) {
log.info("Generate##responseObject###{}", jsonObject);
return setGenerateImageList(jsonObject.getJSONObject("data"));
}
log.info("generateSketchOrPrintPrint失败###{}", jsonObject);
@@ -3074,7 +3079,7 @@ public class PythonService {
// .addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
// .addHeader("Content-Type", "application/json")
.build();
Response response;
Response response = null;
try {
log.info("cancelGenerateTask请求入参content###{}", taskId);
response = client.newCall(request).execute();
@@ -3082,8 +3087,10 @@ public class PythonService {
log.error("PythonService##cancelGenerateTask异常###{}", ExceptionUtil.getThrowableList(ioException));
return null;
}
int responseCode = response.code();
response.close();
if (response.code() != HttpURLConnection.HTTP_OK) {
if (responseCode != HttpURLConnection.HTTP_OK) {
log.info("generate-python 取消请求失败");
return Boolean.FALSE;
}
@@ -3091,4 +3098,45 @@ public class PythonService {
return Boolean.TRUE;
}
public Boolean superResolution(SuperResolutionDTO superResolutionDTO) throws BusinessException {
OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(30, TimeUnit.SECONDS)
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
.readTimeout(60, TimeUnit.SECONDS)//读取超时(单位:秒)
.writeTimeout(60, TimeUnit.SECONDS)//写入超时(单位:秒)
.build();
MediaType mediaType = MediaType.parse("application/json");
HashMap<String, String> content = new HashMap<>();
content.put("sr_image_url", superResolutionDTO.getImages());
content.put("sr_xn", superResolutionDTO.getScale().toString());
content.put("sr_tasks_id", superResolutionDTO.getUniqueId());
String jsonString = JSON.toJSONString(content, SerializerFeature.WriteNullStringAsEmpty);
RequestBody body = RequestBody.create(mediaType, jsonString);
Request request = new Request.Builder()
.url(srPythonPort + "/api/super_resolution")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = null;
try {
log.info("superResolution请求入参content###{}", jsonString);
response = client.newCall(request).execute();
} catch (IOException ioException) {
log.error("PythonService##superResolution异常###{}", ExceptionUtil.getThrowableList(ioException));
return null;
}
int responseCode = response.code();
response.close();
if (responseCode != HttpURLConnection.HTTP_OK) {
// 基本不会有除200以外的code
log.info("superResolution 请求超分操作失败。 Response code " + response.code());
throw new BusinessException("superResolution 请求超分操作失败。 Response code " + response.code());
}
log.info("superResolution 请求超分操作成功");
return Boolean.TRUE;
}
}