feat: 边缘系统停止所有设备接口

This commit is contained in:
stream 2025-12-09 09:38:08 +08:00
parent 1dbf35856d
commit 5cc438f84d
13 changed files with 5324 additions and 13 deletions

View File

@ -0,0 +1,26 @@
package com.cmvr.web.controller.api;
import com.cmvr.common.core.controller.BaseController;
import com.cmvr.common.core.domain.AjaxResult;
import com.cmvr.edge.client.service.EdgeSystemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api(tags = "边缘--系统功能")
@RestController
@RequestMapping("/api/system")
@RequiredArgsConstructor
public class EdgeSystemController extends BaseController {
private final EdgeSystemService edgeSystemService;
@ApiOperation("停止所有设备")
@GetMapping("/stopAll")
public AjaxResult stopAll(String terminalId) {
return AjaxResult.ok(edgeSystemService.stopAll(terminalId));
}
}

View File

@ -18,4 +18,6 @@ public interface EdgeSystemService {
public List<DeDeviceRegistration> deviceList(String terminalId); public List<DeDeviceRegistration> deviceList(String terminalId);
public String stopAll(String terminalId);
} }

View File

@ -2,15 +2,16 @@ package com.cmvr.edge.client.service.impl;
import cmvr.api.SystemCommand; import cmvr.api.SystemCommand;
import cmvr.api.SystemServiceGrpc; import cmvr.api.SystemServiceGrpc;
import com.alibaba.fastjson2.JSON;
import com.cmvr.device.domain.DeDeviceRegistration; import com.cmvr.device.domain.DeDeviceRegistration;
import com.cmvr.device.domain.vo.Device;
import com.cmvr.edge.client.manage.GrpcServiceManager; import com.cmvr.edge.client.manage.GrpcServiceManager;
import com.cmvr.edge.client.service.EdgeSystemService; import com.cmvr.edge.client.service.EdgeSystemService;
import io.grpc.ManagedChannel; import com.cmvr.edge.client.utils.EdgeCommonUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -73,6 +74,17 @@ public class EdgeSystemServiceImpl implements EdgeSystemService {
} }
} }
@Override
public String stopAll(String terminalId) {
SystemServiceGrpc.SystemServiceBlockingStub stub = grpcServiceManager.getGrpcClient(
terminalId,
SystemServiceGrpc.SystemServiceBlockingStub.class);
SystemCommand.StopAllCommand.Request build = SystemCommand.StopAllCommand.Request.newBuilder()
.setHeader(EdgeCommonUtil.buildRequest(""))
.build();
SystemCommand.StopAllCommand.Feedback feedback = stub.stopAll(build);
return JSON.toJSONString(feedback.getHeader());
}
/** /**

View File

@ -77,6 +77,68 @@ public final class SystemServiceGrpc {
return getGetSystemStatusMethod; return getGetSystemStatusMethod;
} }
private static volatile io.grpc.MethodDescriptor<cmvr.api.SystemCommand.UpdateParamsCommand.Request,
cmvr.api.SystemCommand.UpdateParamsCommand.Feedback> getUpdateParamsMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "UpdateParams",
requestType = cmvr.api.SystemCommand.UpdateParamsCommand.Request.class,
responseType = cmvr.api.SystemCommand.UpdateParamsCommand.Feedback.class,
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
public static io.grpc.MethodDescriptor<cmvr.api.SystemCommand.UpdateParamsCommand.Request,
cmvr.api.SystemCommand.UpdateParamsCommand.Feedback> getUpdateParamsMethod() {
io.grpc.MethodDescriptor<cmvr.api.SystemCommand.UpdateParamsCommand.Request, cmvr.api.SystemCommand.UpdateParamsCommand.Feedback> getUpdateParamsMethod;
if ((getUpdateParamsMethod = SystemServiceGrpc.getUpdateParamsMethod) == null) {
synchronized (SystemServiceGrpc.class) {
if ((getUpdateParamsMethod = SystemServiceGrpc.getUpdateParamsMethod) == null) {
SystemServiceGrpc.getUpdateParamsMethod = getUpdateParamsMethod =
io.grpc.MethodDescriptor.<cmvr.api.SystemCommand.UpdateParamsCommand.Request, cmvr.api.SystemCommand.UpdateParamsCommand.Feedback>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "UpdateParams"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
cmvr.api.SystemCommand.UpdateParamsCommand.Request.getDefaultInstance()))
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
cmvr.api.SystemCommand.UpdateParamsCommand.Feedback.getDefaultInstance()))
.setSchemaDescriptor(new SystemServiceMethodDescriptorSupplier("UpdateParams"))
.build();
}
}
}
return getUpdateParamsMethod;
}
private static volatile io.grpc.MethodDescriptor<cmvr.api.SystemCommand.StopAllCommand.Request,
cmvr.api.SystemCommand.StopAllCommand.Feedback> getStopAllMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "StopAll",
requestType = cmvr.api.SystemCommand.StopAllCommand.Request.class,
responseType = cmvr.api.SystemCommand.StopAllCommand.Feedback.class,
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
public static io.grpc.MethodDescriptor<cmvr.api.SystemCommand.StopAllCommand.Request,
cmvr.api.SystemCommand.StopAllCommand.Feedback> getStopAllMethod() {
io.grpc.MethodDescriptor<cmvr.api.SystemCommand.StopAllCommand.Request, cmvr.api.SystemCommand.StopAllCommand.Feedback> getStopAllMethod;
if ((getStopAllMethod = SystemServiceGrpc.getStopAllMethod) == null) {
synchronized (SystemServiceGrpc.class) {
if ((getStopAllMethod = SystemServiceGrpc.getStopAllMethod) == null) {
SystemServiceGrpc.getStopAllMethod = getStopAllMethod =
io.grpc.MethodDescriptor.<cmvr.api.SystemCommand.StopAllCommand.Request, cmvr.api.SystemCommand.StopAllCommand.Feedback>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "StopAll"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
cmvr.api.SystemCommand.StopAllCommand.Request.getDefaultInstance()))
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
cmvr.api.SystemCommand.StopAllCommand.Feedback.getDefaultInstance()))
.setSchemaDescriptor(new SystemServiceMethodDescriptorSupplier("StopAll"))
.build();
}
}
}
return getStopAllMethod;
}
/** /**
* Creates a new async stub that supports all call types for the service * Creates a new async stub that supports all call types for the service
*/ */
@ -139,6 +201,20 @@ public final class SystemServiceGrpc {
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetSystemStatusMethod(), responseObserver); io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetSystemStatusMethod(), responseObserver);
} }
/**
*/
public void updateParams(cmvr.api.SystemCommand.UpdateParamsCommand.Request request,
io.grpc.stub.StreamObserver<cmvr.api.SystemCommand.UpdateParamsCommand.Feedback> responseObserver) {
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getUpdateParamsMethod(), responseObserver);
}
/**
*/
public void stopAll(cmvr.api.SystemCommand.StopAllCommand.Request request,
io.grpc.stub.StreamObserver<cmvr.api.SystemCommand.StopAllCommand.Feedback> responseObserver) {
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getStopAllMethod(), responseObserver);
}
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
.addMethod( .addMethod(
@ -155,6 +231,20 @@ public final class SystemServiceGrpc {
cmvr.api.SystemCommand.GetSystemStatusCommand.Request, cmvr.api.SystemCommand.GetSystemStatusCommand.Request,
cmvr.api.SystemCommand.GetSystemStatusCommand.Feedback>( cmvr.api.SystemCommand.GetSystemStatusCommand.Feedback>(
this, METHODID_GET_SYSTEM_STATUS))) this, METHODID_GET_SYSTEM_STATUS)))
.addMethod(
getUpdateParamsMethod(),
io.grpc.stub.ServerCalls.asyncUnaryCall(
new MethodHandlers<
cmvr.api.SystemCommand.UpdateParamsCommand.Request,
cmvr.api.SystemCommand.UpdateParamsCommand.Feedback>(
this, METHODID_UPDATE_PARAMS)))
.addMethod(
getStopAllMethod(),
io.grpc.stub.ServerCalls.asyncUnaryCall(
new MethodHandlers<
cmvr.api.SystemCommand.StopAllCommand.Request,
cmvr.api.SystemCommand.StopAllCommand.Feedback>(
this, METHODID_STOP_ALL)))
.build(); .build();
} }
} }
@ -188,6 +278,22 @@ public final class SystemServiceGrpc {
io.grpc.stub.ClientCalls.asyncUnaryCall( io.grpc.stub.ClientCalls.asyncUnaryCall(
getChannel().newCall(getGetSystemStatusMethod(), getCallOptions()), request, responseObserver); getChannel().newCall(getGetSystemStatusMethod(), getCallOptions()), request, responseObserver);
} }
/**
*/
public void updateParams(cmvr.api.SystemCommand.UpdateParamsCommand.Request request,
io.grpc.stub.StreamObserver<cmvr.api.SystemCommand.UpdateParamsCommand.Feedback> responseObserver) {
io.grpc.stub.ClientCalls.asyncUnaryCall(
getChannel().newCall(getUpdateParamsMethod(), getCallOptions()), request, responseObserver);
}
/**
*/
public void stopAll(cmvr.api.SystemCommand.StopAllCommand.Request request,
io.grpc.stub.StreamObserver<cmvr.api.SystemCommand.StopAllCommand.Feedback> responseObserver) {
io.grpc.stub.ClientCalls.asyncUnaryCall(
getChannel().newCall(getStopAllMethod(), getCallOptions()), request, responseObserver);
}
} }
/** /**
@ -217,6 +323,20 @@ public final class SystemServiceGrpc {
return io.grpc.stub.ClientCalls.blockingUnaryCall( return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getGetSystemStatusMethod(), getCallOptions(), request); getChannel(), getGetSystemStatusMethod(), getCallOptions(), request);
} }
/**
*/
public cmvr.api.SystemCommand.UpdateParamsCommand.Feedback updateParams(cmvr.api.SystemCommand.UpdateParamsCommand.Request request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getUpdateParamsMethod(), getCallOptions(), request);
}
/**
*/
public cmvr.api.SystemCommand.StopAllCommand.Feedback stopAll(cmvr.api.SystemCommand.StopAllCommand.Request request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getStopAllMethod(), getCallOptions(), request);
}
} }
/** /**
@ -248,10 +368,28 @@ public final class SystemServiceGrpc {
return io.grpc.stub.ClientCalls.futureUnaryCall( return io.grpc.stub.ClientCalls.futureUnaryCall(
getChannel().newCall(getGetSystemStatusMethod(), getCallOptions()), request); getChannel().newCall(getGetSystemStatusMethod(), getCallOptions()), request);
} }
/**
*/
public com.google.common.util.concurrent.ListenableFuture<cmvr.api.SystemCommand.UpdateParamsCommand.Feedback> updateParams(
cmvr.api.SystemCommand.UpdateParamsCommand.Request request) {
return io.grpc.stub.ClientCalls.futureUnaryCall(
getChannel().newCall(getUpdateParamsMethod(), getCallOptions()), request);
}
/**
*/
public com.google.common.util.concurrent.ListenableFuture<cmvr.api.SystemCommand.StopAllCommand.Feedback> stopAll(
cmvr.api.SystemCommand.StopAllCommand.Request request) {
return io.grpc.stub.ClientCalls.futureUnaryCall(
getChannel().newCall(getStopAllMethod(), getCallOptions()), request);
}
} }
private static final int METHODID_GET_SYSTEM_INFO = 0; private static final int METHODID_GET_SYSTEM_INFO = 0;
private static final int METHODID_GET_SYSTEM_STATUS = 1; private static final int METHODID_GET_SYSTEM_STATUS = 1;
private static final int METHODID_UPDATE_PARAMS = 2;
private static final int METHODID_STOP_ALL = 3;
private static final class MethodHandlers<Req, Resp> implements private static final class MethodHandlers<Req, Resp> implements
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>, io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
@ -278,6 +416,14 @@ public final class SystemServiceGrpc {
serviceImpl.getSystemStatus((cmvr.api.SystemCommand.GetSystemStatusCommand.Request) request, serviceImpl.getSystemStatus((cmvr.api.SystemCommand.GetSystemStatusCommand.Request) request,
(io.grpc.stub.StreamObserver<cmvr.api.SystemCommand.GetSystemStatusCommand.Feedback>) responseObserver); (io.grpc.stub.StreamObserver<cmvr.api.SystemCommand.GetSystemStatusCommand.Feedback>) responseObserver);
break; break;
case METHODID_UPDATE_PARAMS:
serviceImpl.updateParams((cmvr.api.SystemCommand.UpdateParamsCommand.Request) request,
(io.grpc.stub.StreamObserver<cmvr.api.SystemCommand.UpdateParamsCommand.Feedback>) responseObserver);
break;
case METHODID_STOP_ALL:
serviceImpl.stopAll((cmvr.api.SystemCommand.StopAllCommand.Request) request,
(io.grpc.stub.StreamObserver<cmvr.api.SystemCommand.StopAllCommand.Feedback>) responseObserver);
break;
default: default:
throw new AssertionError(); throw new AssertionError();
} }
@ -341,6 +487,8 @@ public final class SystemServiceGrpc {
.setSchemaDescriptor(new SystemServiceFileDescriptorSupplier()) .setSchemaDescriptor(new SystemServiceFileDescriptorSupplier())
.addMethod(getGetSystemInfoMethod()) .addMethod(getGetSystemInfoMethod())
.addMethod(getGetSystemStatusMethod()) .addMethod(getGetSystemStatusMethod())
.addMethod(getUpdateParamsMethod())
.addMethod(getStopAllMethod())
.build(); .build();
} }
} }

View File

@ -24,13 +24,18 @@ public final class SystemServiceOuterClass {
static { static {
java.lang.String[] descriptorData = { java.lang.String[] descriptorData = {
"\n\035cmvr/api/system_service.proto\022\010cmvr.ap" + "\n\035cmvr/api/system_service.proto\022\010cmvr.ap" +
"i\032\035cmvr/api/system_command.proto2\335\001\n\rSys" + "i\032\035cmvr/api/system_command.proto2\220\003\n\rSys" +
"temService\022b\n\rGetSystemInfo\022&.cmvr.api.G" + "temService\022b\n\rGetSystemInfo\022&.cmvr.api.G" +
"etSystemInfoCommand.Request\032\'.cmvr.api.G" + "etSystemInfoCommand.Request\032\'.cmvr.api.G" +
"etSystemInfoCommand.Feedback\"\000\022h\n\017GetSys" + "etSystemInfoCommand.Feedback\"\000\022h\n\017GetSys" +
"temStatus\022(.cmvr.api.GetSystemStatusComm" + "temStatus\022(.cmvr.api.GetSystemStatusComm" +
"and.Request\032).cmvr.api.GetSystemStatusCo" + "and.Request\032).cmvr.api.GetSystemStatusCo" +
"mmand.Feedback\"\000b\006proto3" "mmand.Feedback\"\000\022_\n\014UpdateParams\022%.cmvr." +
"api.UpdateParamsCommand.Request\032&.cmvr.a" +
"pi.UpdateParamsCommand.Feedback\"\000\022P\n\007Sto" +
"pAll\022 .cmvr.api.StopAllCommand.Request\032!" +
".cmvr.api.StopAllCommand.Feedback\"\000b\006pro" +
"to3"
}; };
descriptor = com.google.protobuf.Descriptors.FileDescriptor descriptor = com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData, .internalBuildGeneratedFileFrom(descriptorData,

View File

@ -28,3 +28,16 @@ message CommandHeader {
google.protobuf.Timestamp timestamp = 3; // google.protobuf.Timestamp timestamp = 3; //
} }
} }
message ConfigParam {
string param_name = 1;
oneof param_value {
int32 int_value = 2; //
double double_value = 3; //
string string_value = 4; //
bool bool_value = 5; //
bytes bytes_value = 6; //
}
}

View File

@ -48,3 +48,25 @@ message GetSystemStatusCommand {
repeated DeviceList device_list = 7; repeated DeviceList device_list = 7;
} }
} }
message UpdateParamsCommand {
message Request {
CommandHeader.Request header = 1;
repeated ConfigParam params = 2;
}
message Feedback {
CommandHeader.Feedback header = 1;
}
}
message StopAllCommand {
message Request {
CommandHeader.Request header = 1;
}
message Feedback {
CommandHeader.Feedback header = 1;
}
}

View File

@ -8,4 +8,8 @@ package cmvr.api;
service SystemService { service SystemService {
rpc GetSystemInfo(GetSystemInfoCommand.Request) returns (GetSystemInfoCommand.Feedback) {} rpc GetSystemInfo(GetSystemInfoCommand.Request) returns (GetSystemInfoCommand.Feedback) {}
rpc GetSystemStatus(GetSystemStatusCommand.Request) returns (GetSystemStatusCommand.Feedback) {} rpc GetSystemStatus(GetSystemStatusCommand.Request) returns (GetSystemStatusCommand.Feedback) {}
rpc UpdateParams(UpdateParamsCommand.Request) returns (UpdateParamsCommand.Feedback) {}
rpc StopAll(StopAllCommand.Request) returns (StopAllCommand.Feedback) {}
} }

View File

@ -3,6 +3,7 @@ package com.cmvr.test.flow.context;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.cmvr.test.enums.TaskStatusEnum; import com.cmvr.test.enums.TaskStatusEnum;
import com.cmvr.test.enums.TerminalStatusEnum; import com.cmvr.test.enums.TerminalStatusEnum;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -20,6 +21,7 @@ public class TaskContextManager {
/** /**
* 实例 ID 任务上下文 * 实例 ID 任务上下文
*/ */
@Getter
private final Map<String, TaskContext> instContextMap = new ConcurrentHashMap<>(); private final Map<String, TaskContext> instContextMap = new ConcurrentHashMap<>();
/** /**

View File

@ -2,6 +2,7 @@ package com.cmvr.test.flow.control;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.cmvr.common.exception.GlobalException; import com.cmvr.common.exception.GlobalException;
import com.cmvr.edge.client.service.EdgeSystemService;
import com.cmvr.test.enums.NodeTypeEnum; import com.cmvr.test.enums.NodeTypeEnum;
import com.cmvr.test.enums.TaskStatusEnum; import com.cmvr.test.enums.TaskStatusEnum;
import com.cmvr.test.enums.TerminalStatusEnum; import com.cmvr.test.enums.TerminalStatusEnum;
@ -39,12 +40,12 @@ public class FlowControlService {
private final ITeNodeInstService nodeInstService; private final ITeNodeInstService nodeInstService;
private final TaskThreadRegistry taskThreadRegistry; private final TaskThreadRegistry taskThreadRegistry;
private final FlowItemExecutor flowItemExecutor; private final FlowItemExecutor flowItemExecutor;
private final EdgeSystemService edgeSystemService;
/** /**
* 终止流程 * 终止流程
*/ */
public void stop(String instId) { public void stop(String instId) {
// todo 调用 edge 暂停接口
TaskContext ctx = taskInstHolder.getContext(instId); TaskContext ctx = taskInstHolder.getContext(instId);
if (ctx == null) { if (ctx == null) {
@ -53,6 +54,7 @@ public class FlowControlService {
if (ctx.isStopped()) { if (ctx.isStopped()) {
throw new GlobalException("任务已终止,无需重复操作"); throw new GlobalException("任务已终止,无需重复操作");
} }
edgeSystemService.stopAll(ctx.getTerminalId());
// 统一记录日志 + 设置上下文状态 + 数据库状态 // 统一记录日志 + 设置上下文状态 + 数据库状态
taskInstHolder.syncStatus(instId, TaskStatusEnum.STOPPED); taskInstHolder.syncStatus(instId, TaskStatusEnum.STOPPED);
@ -69,8 +71,6 @@ public class FlowControlService {
* 暂停任务 * 暂停任务
*/ */
public void pause(String instId) { public void pause(String instId) {
// todo 调用 edge 暂停接口
TaskContext ctx = taskInstHolder.getContext(instId); TaskContext ctx = taskInstHolder.getContext(instId);
if (ctx == null || ctx.isStopped()) { if (ctx == null || ctx.isStopped()) {
throw new GlobalException("任务不存在或已终止,无法暂停"); throw new GlobalException("任务不存在或已终止,无法暂停");
@ -78,6 +78,7 @@ public class FlowControlService {
if (ctx.isPaused()) { if (ctx.isPaused()) {
throw new GlobalException("任务已处于暂停状态"); throw new GlobalException("任务已处于暂停状态");
} }
edgeSystemService.stopAll(ctx.getTerminalId());
ctx.setPaused(true); ctx.setPaused(true);
ctx.setTerminalStatus(TerminalStatusEnum.RUNNING); ctx.setTerminalStatus(TerminalStatusEnum.RUNNING);
ctx.setStatus(TaskStatusEnum.PAUSED); ctx.setStatus(TaskStatusEnum.PAUSED);

View File

@ -7,6 +7,9 @@ import com.cmvr.common.utils.http.CallAPIUtil;
import com.cmvr.common.utils.uuid.IdUtils; import com.cmvr.common.utils.uuid.IdUtils;
import com.cmvr.edge.client.service.EdgeBioHeadService; import com.cmvr.edge.client.service.EdgeBioHeadService;
import com.cmvr.test.enums.FlowiseActionEnum; import com.cmvr.test.enums.FlowiseActionEnum;
import com.cmvr.test.flow.context.TaskContext;
import com.cmvr.test.flow.context.TaskContextManager;
import com.cmvr.test.flow.control.FlowControlService;
import com.cmvr.test.model.vo.FlowiseActionRequestVO; import com.cmvr.test.model.vo.FlowiseActionRequestVO;
import com.cmvr.test.model.vo.FlowiseChatRequestVO; import com.cmvr.test.model.vo.FlowiseChatRequestVO;
import com.cmvr.test.model.vo.FlowiseStartRequestVO; import com.cmvr.test.model.vo.FlowiseStartRequestVO;
@ -26,6 +29,8 @@ import java.util.Map;
public class FlowiseActionService { public class FlowiseActionService {
private final EdgeBioHeadService edgeBioHeadService; private final EdgeBioHeadService edgeBioHeadService;
private final TaskContextManager taskContextManager;
private final FlowControlService flowControlService;
@Value("${flowise.tts}") @Value("${flowise.tts}")
private String flowiseTts; private String flowiseTts;
@ -78,6 +83,10 @@ public class FlowiseActionService {
public String abort() { public String abort() {
CallAPIUtil.doPostJson(flowiseTts + "stop", null, null); CallAPIUtil.doPostJson(flowiseTts + "stop", null, null);
Map<String, TaskContext> instContextMap = taskContextManager.getInstContextMap();
instContextMap.forEach((key, value) -> {
flowControlService.stop(key);
});
synchronized (lock) { synchronized (lock) {
if (chatId == null) { if (chatId == null) {