1、完善超分功能
2、完善积分系统 3、新增任务列表
This commit is contained in:
@@ -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
|
||||
@@ -837,6 +840,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)) {
|
||||
@@ -1993,10 +1997,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;
|
||||
}
|
||||
}
|
||||
@@ -2006,10 +2010,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;
|
||||
}
|
||||
}
|
||||
@@ -2032,8 +2036,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)) {
|
||||
@@ -2060,7 +2064,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());
|
||||
}
|
||||
}
|
||||
@@ -3065,7 +3069,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();
|
||||
@@ -3073,8 +3077,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;
|
||||
}
|
||||
@@ -3082,7 +3088,7 @@ public class PythonService {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
public String superResolution(SuperResolutionDTO superResolutionDTO){
|
||||
public Boolean superResolution(SuperResolutionDTO superResolutionDTO) throws BusinessException {
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
|
||||
@@ -3092,54 +3098,35 @@ public class PythonService {
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
|
||||
HashMap<String, String> content = new HashMap<>();
|
||||
content.put("image_url", superResolutionDTO.getImages());
|
||||
content.put("sr_image_url", superResolutionDTO.getImages());
|
||||
content.put("sr_xn", superResolutionDTO.getScale().toString());
|
||||
content.put("task_id", superResolutionDTO.getUniqueId());
|
||||
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(accessPythonIp + ":" + 9991 + "/super-resolution/")
|
||||
.url(srPythonPort + "/api/super_resolution")
|
||||
.method("POST", body)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = null;
|
||||
String bodyString;
|
||||
try {
|
||||
log.info("superResolution请求入参content###{}", JSON.toJSONString(superResolutionDTO, SerializerFeature.WriteMapNullValue));
|
||||
log.info("superResolution请求入参content###{}", jsonString);
|
||||
response = client.newCall(request).execute();
|
||||
} catch (IOException ioException) {
|
||||
log.error("PythonService##superResolution异常###{}", ExceptionUtil.getThrowableList(ioException));
|
||||
throw new BusinessException(ioException.getMessage());
|
||||
return null;
|
||||
}
|
||||
int responseCode = response.code();
|
||||
response.close();
|
||||
|
||||
// 判断是否生成失败
|
||||
if (Objects.isNull(response.body())) {
|
||||
log.error("PythonService##superResolution异常###{}", "response or body is empty!");
|
||||
throw new BusinessException("PythonService##superResolution异常###: response or body is empty!");
|
||||
} else if (response.code() != HttpURLConnection.HTTP_OK) {
|
||||
log.error("PythonService##superResolution异常###{}", "Response error!Response code ## " + response.code() + " ##");
|
||||
throw new BusinessException("PythonService##superResolution异常### Response error!Response code ## " + response.code() + " ##");
|
||||
} else {
|
||||
try {
|
||||
bodyString = response.body().string();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage());
|
||||
throw new BusinessException(e.getMessage());
|
||||
}
|
||||
if (responseCode != HttpURLConnection.HTTP_OK) {
|
||||
// 基本不会有除200以外的code
|
||||
log.info("superResolution 请求超分操作失败。 Response code " + response.code());
|
||||
throw new BusinessException("superResolution 请求超分操作失败。 Response code " + response.code());
|
||||
}
|
||||
JSONObject jsonObject = JSON.parseObject(bodyString);
|
||||
Boolean result = JSON.parseObject(JSON.toJSONString(response)).getBoolean("successful");
|
||||
|
||||
// todo 返回数据的结构没对接好
|
||||
if (result && jsonObject.get("code").equals(200)) {
|
||||
log.info("superResolution##responseObject###{}", jsonObject);
|
||||
return jsonObject.getJSONObject("data").get("image").toString();
|
||||
}
|
||||
log.info("superResolution失败###{}", jsonObject);
|
||||
log.info("superResolution Exception! Code : " + jsonObject.get("code"));
|
||||
//生成失败
|
||||
throw new BusinessException("sr.interface.error");
|
||||
log.info("superResolution 请求超分操作成功");
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user