Browse Source

add:遥控函数添加

zhongwei
haungxing 6 months ago
parent
commit
8a172849be
  1. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java
  2. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java
  3. 13
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java

@ -19,7 +19,7 @@ public enum FuncRouteEnum {
CHOOSE_VIDEO("choose_video","选择视频",null), CHOOSE_VIDEO("choose_video","选择视频",null),
CHOOSE_CANVAS("choose_canvas","选择画面",null), CHOOSE_CANVAS("choose_canvas","选择画面",null),
CHOOSE_FAULT("choose_fault","选择故障",null), CHOOSE_FAULT("choose_fault","选择故障",null),
CONFIRM_YK("confirm_yk","遥控确认", FunctionConstants.TypeEnum.CONFIRM), CONFIRM_YK("confirm_yk","遥控确认", FunctionConstants.TypeEnum.PARAMS),
; ;
@Getter @Getter
private String funcCode; private String funcCode;

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java

@ -81,7 +81,7 @@ public class ExtraResolveStrategyService {
ExtraVO result = new ExtraVO(); ExtraVO result = new ExtraVO();
RemoteParamVO remoteParam = JSONObject.parseObject(JSON.toJSONString(extra.get("data")), RemoteParamVO.class); RemoteParamVO remoteParam = JSONObject.parseObject(JSON.toJSONString(extra.get("data")), RemoteParamVO.class);
result.setFuncCode(FuncRouteEnum.CONFIRM_YK.getFuncCode()); result.setFuncCode(FuncRouteEnum.CONFIRM_YK.getFuncCode());
result.setType(FunctionConstants.TypeEnum.CONFIRM.getType()); result.setType(FuncRouteEnum.CONFIRM_YK.getType().getType());
R<DeviceInstanceFuncVO> funcVOR = deviceClient.getFuncById(remoteParam.getFuncId()); R<DeviceInstanceFuncVO> funcVOR = deviceClient.getFuncById(remoteParam.getFuncId());
if(funcVOR.isSuccess()) { if(funcVOR.isSuccess()) {
Map<String,Object> param = new HashMap(1); Map<String,Object> param = new HashMap(1);

13
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java

@ -12,11 +12,16 @@ import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService;
import com.hnac.hzims.bigmodel.websocket.constants.RedisKeyConstants; import com.hnac.hzims.bigmodel.websocket.constants.RedisKeyConstants;
import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService;
import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.SpringUtil; import org.springblade.core.tool.utils.SpringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.CloseStatus; import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession; import org.springframework.web.socket.WebSocketSession;
@ -33,7 +38,12 @@ import java.util.function.Function;
* @Date: 2024/04/28 13:45 * @Date: 2024/04/28 13:45
*/ */
@Slf4j @Slf4j
@Component
public class InteractiveHandler extends TextWebSocketHandler { public class InteractiveHandler extends TextWebSocketHandler {
@Autowired
private RedisTemplate redisTemplate;
@Override @Override
public void afterConnectionEstablished(WebSocketSession session) { public void afterConnectionEstablished(WebSocketSession session) {
String[] split = session.getUri().toString().split("/"); String[] split = session.getUri().toString().split("/");
@ -67,9 +77,8 @@ public class InteractiveHandler extends TextWebSocketHandler {
} }
} else { } else {
String sessionId = InteractiveSessionManager.getEntryBySession(session).getKey(); String sessionId = InteractiveSessionManager.getEntryBySession(session).getKey();
if(Func.isNotEmpty(messageJSON.containsKey("content"))) { if(messageJSON.containsKey("content")) {
// 将发送参数存入redis // 将发送参数存入redis
RedisTemplate redisTemplate = SpringUtil.getBean(RedisTemplate.class);
redisTemplate.expire(RedisKeyConstants.SESSION_CONTENT_KEY,30, TimeUnit.MINUTES); redisTemplate.expire(RedisKeyConstants.SESSION_CONTENT_KEY,30, TimeUnit.MINUTES);
redisTemplate.opsForHash().put(RedisKeyConstants.SESSION_CONTENT_KEY,sessionId,messageJSON.getObject("content", SessionContentVO.class)); redisTemplate.opsForHash().put(RedisKeyConstants.SESSION_CONTENT_KEY,sessionId,messageJSON.getObject("content", SessionContentVO.class));
} }

Loading…
Cancel
Save