|
|
|
@ -2,11 +2,14 @@ package com.hnac.hzims.bigmodel.websocket.handler;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; |
|
|
|
|
import com.hnac.hzims.bigmodel.interactive.constants.StationSelectionVO; |
|
|
|
|
import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; |
|
|
|
|
import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
|
import org.springblade.core.tool.utils.SpringUtil; |
|
|
|
|
import org.springframework.util.Assert; |
|
|
|
|
import org.springframework.web.socket.CloseStatus; |
|
|
|
@ -57,12 +60,35 @@ public class InteractiveHandler extends TextWebSocketHandler {
|
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
} |
|
|
|
|
}else { |
|
|
|
|
// 发送问题
|
|
|
|
|
String context = messageJSON.getString("context"); |
|
|
|
|
String userId = messageJSON.getString("userId"); |
|
|
|
|
String sessionId = InteractiveSessionManager.getEntryBySession(session).getKey(); |
|
|
|
|
this.handleMessage(messageJSON,sessionId); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void handleMessage(JSONObject messageContext,String sessionId) { |
|
|
|
|
Boolean isSpecial = messageContext.getBoolean("isSpecial"); |
|
|
|
|
String context = messageContext.getString("context"); |
|
|
|
|
String userId = messageContext.getString("userId"); |
|
|
|
|
if(Func.isEmpty(isSpecial) || !isSpecial) { |
|
|
|
|
IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class); |
|
|
|
|
R askResult = interactiveService.ask(context, InteractiveSessionManager.getEntryBySession(session).getKey(), userId); |
|
|
|
|
R askResult = interactiveService.ask(context, sessionId, userId); |
|
|
|
|
log.info("返回结果为:"+ JSON.toJSONString(askResult)); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
String funcCode = messageContext.getString("func"); |
|
|
|
|
FuncRouteEnum funcEnum = FuncRouteEnum.getEnumByFuncCode(funcCode); |
|
|
|
|
switch (funcEnum) { |
|
|
|
|
case CHOOSE_STATION: |
|
|
|
|
this.handleChooseStation(messageContext); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void handleChooseStation(JSONObject messageContext) { |
|
|
|
|
StationSelectionVO selectionVO = messageContext.getObject("selection",StationSelectionVO.class); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|