TASK:cloud;
This commit is contained in:
@@ -375,23 +375,23 @@ public class GenerateConsumer {
|
|||||||
log.info("toProductImageBatch response : {}", generateResult);
|
log.info("toProductImageBatch response : {}", generateResult);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
log.info("tasks_id : {} start ", generateResult.get("tasks_id"));
|
log.info("task_id : {} start ", generateResult.get("task_id"));
|
||||||
if (!StringUtils.isEmpty(generateResult.getString("progress"))) {
|
if (!StringUtils.isEmpty(generateResult.getString("progress"))) {
|
||||||
String progress = generateResult.getString("progress");
|
String progress = generateResult.getString("progress");
|
||||||
JSONObject result = generateResult.getJSONObject("result_data");
|
JSONObject result = generateResult.getJSONObject("result");
|
||||||
String url = null;
|
String url = null;
|
||||||
if (!StringUtils.isEmpty(result)) {
|
if (!StringUtils.isEmpty(result)) {
|
||||||
url = result.getString("image_url");
|
url = result.getString("image_url");
|
||||||
String taskId = generateResult.getString("tasks_id");
|
String taskId = generateResult.getString("task_id");
|
||||||
userLikeGroupService.toProductBatch(taskId, url, progress);
|
userLikeGroupService.toProductBatch(taskId, url, progress);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 修改redis中的数据状态为exception
|
// 修改redis中的数据状态为exception
|
||||||
String key = toProductImageResultKey + ":" + generateResult.get("tasks_id");
|
String key = toProductImageResultKey + ":" + generateResult.get("task_id");
|
||||||
redisUtil.addToString(key, new Gson().toJson(new GenerateResultVO(generateResult.getString("tasks_id"), null, null, "Fail")), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
redisUtil.addToString(key, new Gson().toJson(new GenerateResultVO(generateResult.getString("tasks_id"), null, null, "Fail")), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||||
// 将异常信息存到exception中
|
// 将异常信息存到exception中
|
||||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||||
exceptionInfo.put(generateResult.getString("tasks_id"), generateResult.getString("data"));
|
exceptionInfo.put(generateResult.getString("task_id"), generateResult.getString("data"));
|
||||||
// 存redis
|
// 存redis
|
||||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||||
}
|
}
|
||||||
@@ -400,7 +400,7 @@ public class GenerateConsumer {
|
|||||||
try {
|
try {
|
||||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
||||||
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
||||||
redisUtil.removeFromZSet(consumptionOrderKey, generateResult.getString("tasks_id"));
|
redisUtil.removeFromZSet(consumptionOrderKey, generateResult.getString("task_id"));
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
log.error("手动确认,取消返回队列,不再重新消费");
|
log.error("手动确认,取消返回队列,不再重新消费");
|
||||||
}
|
}
|
||||||
@@ -408,13 +408,13 @@ public class GenerateConsumer {
|
|||||||
String exceptionMessage = JSONObject.toJSONString(generateResult) +
|
String exceptionMessage = JSONObject.toJSONString(generateResult) +
|
||||||
" Exception message : " + e.getMessage();
|
" Exception message : " + e.getMessage();
|
||||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||||
exceptionInfo.put(String.valueOf(generateResult.get("tasks_id")), exceptionMessage);
|
exceptionInfo.put(String.valueOf(generateResult.get("task_id")), exceptionMessage);
|
||||||
// 存redis
|
// 存redis
|
||||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
long end = System.currentTimeMillis();
|
long end = System.currentTimeMillis();
|
||||||
log.info("tasks_id : {}, end , message : {}, 执行时长: {} 毫秒", generateResult.get("tasks_id"), generateResult.get("message"), (end - start));
|
log.info("task_id : {}, end , message : {}, 执行时长: {} 毫秒", generateResult.get("task_id"), generateResult.get("message"), (end - start));
|
||||||
log.info("============ProcessToProductImageBatchResult End listening==========");
|
log.info("============ProcessToProductImageBatchResult End listening==========");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,23 +426,23 @@ public class GenerateConsumer {
|
|||||||
log.info("relightBatch response : {}", generateResult);
|
log.info("relightBatch response : {}", generateResult);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
log.info("task_id : {} start ", generateResult.get("tasks_id"));
|
log.info("task_id : {} start ", generateResult.get("task_id"));
|
||||||
if (!StringUtils.isEmpty(generateResult.getString("progress"))) {
|
if (!StringUtils.isEmpty(generateResult.getString("progress"))) {
|
||||||
String progress = generateResult.getString("progress");
|
String progress = generateResult.getString("progress");
|
||||||
JSONObject result = generateResult.getJSONObject("result_data");
|
JSONObject result = generateResult.getJSONObject("result");
|
||||||
String url = null;
|
String url = null;
|
||||||
if (!StringUtils.isEmpty(result)) {
|
if (!StringUtils.isEmpty(result)) {
|
||||||
url = result.getString("image_url");
|
url = result.getString("image_url");
|
||||||
String taskId = generateResult.getString("tasks_id");
|
String taskId = generateResult.getString("task_id");
|
||||||
userLikeGroupService.relightBatch(taskId, url, progress);
|
userLikeGroupService.relightBatch(taskId, url, progress);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 修改redis中的数据状态为exception
|
// 修改redis中的数据状态为exception
|
||||||
String key = relightResultKey + ":" + generateResult.get("tasks_id");
|
String key = relightResultKey + ":" + generateResult.get("task_id");
|
||||||
redisUtil.addToString(key, new Gson().toJson(new GenerateResultVO(generateResult.getString("tasks_id"), null, null, "Fail")), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
redisUtil.addToString(key, new Gson().toJson(new GenerateResultVO(generateResult.getString("tasks_id"), null, null, "Fail")), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||||
// 将异常信息存到exception中
|
// 将异常信息存到exception中
|
||||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||||
exceptionInfo.put(generateResult.getString("tasks_id"), generateResult.getString("data"));
|
exceptionInfo.put(generateResult.getString("task_id"), generateResult.getString("data"));
|
||||||
// 存redis
|
// 存redis
|
||||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||||
}
|
}
|
||||||
@@ -451,7 +451,7 @@ public class GenerateConsumer {
|
|||||||
try {
|
try {
|
||||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
||||||
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
||||||
redisUtil.removeFromZSet(consumptionOrderKey, generateResult.getString("tasks_id"));
|
redisUtil.removeFromZSet(consumptionOrderKey, generateResult.getString("task_id"));
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
log.error("手动确认,取消返回队列,不再重新消费");
|
log.error("手动确认,取消返回队列,不再重新消费");
|
||||||
}
|
}
|
||||||
@@ -459,13 +459,13 @@ public class GenerateConsumer {
|
|||||||
String exceptionMessage = JSONObject.toJSONString(generateResult) +
|
String exceptionMessage = JSONObject.toJSONString(generateResult) +
|
||||||
" Exception message : " + e.getMessage();
|
" Exception message : " + e.getMessage();
|
||||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||||
exceptionInfo.put(String.valueOf(generateResult.get("tasks_id")), exceptionMessage);
|
exceptionInfo.put(String.valueOf(generateResult.get("task_id")), exceptionMessage);
|
||||||
// 存redis
|
// 存redis
|
||||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
long end = System.currentTimeMillis();
|
long end = System.currentTimeMillis();
|
||||||
log.info("task_id : {}, end , message : {}, 执行时长: {} 毫秒", generateResult.get("tasks_id"), generateResult.get("message"), (end - start));
|
log.info("task_id : {}, end , message : {}, 执行时长: {} 毫秒", generateResult.get("task_id"), generateResult.get("message"), (end - start));
|
||||||
log.info("============ProcessRelightBatchResult End listening==========");
|
log.info("============ProcessRelightBatchResult End listening==========");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4288,7 +4288,7 @@ public class PythonService {
|
|||||||
map.put("batch_tasks_id", taskIdBatch);
|
map.put("batch_tasks_id", taskIdBatch);
|
||||||
log.info("toProductImage请求python 参数:####{}", map);
|
log.info("toProductImage请求python 参数:####{}", map);
|
||||||
String param = JSON.toJSONString(map, SerializerFeature.WriteNullStringAsEmpty);
|
String param = JSON.toJSONString(map, SerializerFeature.WriteNullStringAsEmpty);
|
||||||
System.out.println(param);
|
System.out.println(JSONObject.toJSONString(param));
|
||||||
RequestBody body = RequestBody.create(mediaType, param);
|
RequestBody body = RequestBody.create(mediaType, param);
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
// .url(accessPythonIp + ":" + accessPythonPort + "/api/generate_product_image")
|
// .url(accessPythonIp + ":" + accessPythonPort + "/api/generate_product_image")
|
||||||
|
|||||||
Reference in New Issue
Block a user