|
@@ -6,12 +6,11 @@ import cn.hutool.json.JSONArray;
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
import com.backendsys.modules.common.Filter.WebClientFilter;
|
|
import com.backendsys.modules.common.Filter.WebClientFilter;
|
|
-import com.backendsys.modules.sdk.comfyui.entity.ComfyuiQueueItem;
|
|
|
|
-import com.backendsys.modules.sdk.comfyui.entity.ComfyuiRequest;
|
|
|
|
-import com.backendsys.modules.sdk.comfyui.entity.ComfyuiResponse;
|
|
|
|
-import com.backendsys.modules.sdk.comfyui.entity.ComfyuiQueue;
|
|
|
|
|
|
+import com.backendsys.modules.sdk.comfyui.dao.ComfyuiTaskDao;
|
|
|
|
+import com.backendsys.modules.sdk.comfyui.entity.*;
|
|
import com.backendsys.modules.sdk.comfyui.service.ComfyuiService;
|
|
import com.backendsys.modules.sdk.comfyui.service.ComfyuiService;
|
|
import com.backendsys.modules.sdk.comfyui.service.ComfyuiSocketService;
|
|
import com.backendsys.modules.sdk.comfyui.service.ComfyuiSocketService;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.HttpHeaders;
|
|
@@ -32,12 +31,13 @@ public class ComfyuiServiceImpl implements ComfyuiService {
|
|
private String COMFYUI_TOKEN;
|
|
private String COMFYUI_TOKEN;
|
|
@Value("${comfyui.ports}")
|
|
@Value("${comfyui.ports}")
|
|
private String COMFYUI_PORTS_STR;
|
|
private String COMFYUI_PORTS_STR;
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private ComfyuiSocketService comfyuiSocketService;
|
|
|
|
@Value("${comfyui.is-save}")
|
|
@Value("${comfyui.is-save}")
|
|
private Boolean IS_SAVE;
|
|
private Boolean IS_SAVE;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ComfyuiTaskDao comfyuiTaskDao;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ComfyuiSocketService comfyuiSocketService;
|
|
|
|
|
|
private WebClient webClient;
|
|
private WebClient webClient;
|
|
public WebClient getWebClient() {
|
|
public WebClient getWebClient() {
|
|
@@ -178,10 +178,25 @@ public class ComfyuiServiceImpl implements ComfyuiService {
|
|
.accept(MediaType.APPLICATION_JSON)
|
|
.accept(MediaType.APPLICATION_JSON)
|
|
.bodyValue(bodyValue)
|
|
.bodyValue(bodyValue)
|
|
.exchangeToMono(response -> response.bodyToMono(ComfyuiResponse.class))
|
|
.exchangeToMono(response -> response.bodyToMono(ComfyuiResponse.class))
|
|
|
|
+ .map(r -> {
|
|
|
|
+ r.setUrl(url);
|
|
|
|
+ r.setUrl_port(port);
|
|
|
|
+ return r;
|
|
|
|
+ })
|
|
.onErrorResume(e -> {
|
|
.onErrorResume(e -> {
|
|
// 捕获所有异常(包括上面抛出的 RuntimeException)
|
|
// 捕获所有异常(包括上面抛出的 RuntimeException)
|
|
ComfyuiResponse response = new ComfyuiResponse();
|
|
ComfyuiResponse response = new ComfyuiResponse();
|
|
response.setNode_errors(e.getMessage());
|
|
response.setNode_errors(e.getMessage());
|
|
|
|
+
|
|
|
|
+ // -- [DB] 更新任务错误信息 --------------------------------------------------
|
|
|
|
+ ComfyuiTask entity = new ComfyuiTask();
|
|
|
|
+ entity.setReason(e.getMessage());
|
|
|
|
+ entity.setExecute_status(3);
|
|
|
|
+ LambdaQueryWrapper<ComfyuiTask> wrapperTask = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapperTask.eq(ComfyuiTask::getClient_id, client_id);
|
|
|
|
+ comfyuiTaskDao.update(entity, wrapperTask);
|
|
|
|
+ // ------------------------------------------------------------------------
|
|
|
|
+
|
|
return Mono.just(response);
|
|
return Mono.just(response);
|
|
});
|
|
});
|
|
|
|
|