|
|
@ -62,21 +62,27 @@ public class InteractiveHandler extends TextWebSocketHandler { |
|
|
|
} catch (IOException e) { |
|
|
|
} catch (IOException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
String sessionId = InteractiveSessionManager.getEntryBySession(session).getKey(); |
|
|
|
String sessionId = InteractiveSessionManager.getEntryBySession(session).getKey(); |
|
|
|
this.handleMessage(messageJSON,sessionId); |
|
|
|
this.handleMessage(messageJSON, sessionId); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void handleMessage(JSONObject messageContext,String sessionId) { |
|
|
|
private void handleMessage(JSONObject messageContext, String sessionId) { |
|
|
|
Boolean isSpecial = messageContext.getBoolean("isSpecial"); |
|
|
|
Boolean isSpecial = messageContext.getBoolean("isSpecial"); |
|
|
|
if(Func.isEmpty(isSpecial) || !isSpecial) { |
|
|
|
if (Func.isEmpty(isSpecial) || !isSpecial) { |
|
|
|
String context = messageContext.getString("context"); |
|
|
|
String context = messageContext.getString("context"); |
|
|
|
String userId = messageContext.getString("userId"); |
|
|
|
String userId = messageContext.getString("userId"); |
|
|
|
|
|
|
|
String knowledge = messageContext.getString("knowledge"); |
|
|
|
IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class); |
|
|
|
IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class); |
|
|
|
|
|
|
|
if (knowledge != null) { |
|
|
|
|
|
|
|
R askResult = interactiveService.knowledgeAsk(context, sessionId, userId, knowledge); |
|
|
|
|
|
|
|
log.info("知识库问答返回结果:" + JSON.toJSONString(askResult)); |
|
|
|
|
|
|
|
} else { |
|
|
|
R askResult = interactiveService.ask(context, sessionId, userId); |
|
|
|
R askResult = interactiveService.ask(context, sessionId, userId); |
|
|
|
log.info("返回结果为:"+ JSON.toJSONString(askResult)); |
|
|
|
log.info("返回结果为:"+ JSON.toJSONString(askResult)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
String funcCode = messageContext.getString("funcCode"); |
|
|
|
String funcCode = messageContext.getString("funcCode"); |
|
|
|
FuncRouteEnum funcEnum = FuncRouteEnum.getEnumByFuncCode(funcCode); |
|
|
|
FuncRouteEnum funcEnum = FuncRouteEnum.getEnumByFuncCode(funcCode); |
|
|
|