Browse Source

fix:完善问题选项问题解析

zhongwei
haungxing 9 months ago
parent
commit
2499c3bbcd
  1. 2
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java
  2. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java
  3. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java
  4. 22
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java
  5. 18
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java
  6. 34
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java

2
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java

@ -28,7 +28,7 @@ public class ExtraVO implements Serializable {
private String label;
@ApiModelProperty("是否立即跳转")
private boolean isImmediatelyJump = true;
private boolean isImmediatelyJump = false;
@ApiModelProperty("附带参数")
private Map<String,Object> params;

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java

@ -15,6 +15,8 @@ public class BigModelInvokeUrl {
private String assistantAsk;
private String assistantSpecialAsk;
private String assistantStatus;
private String askAbort;

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

@ -20,6 +20,8 @@ public interface IInteractiveService {
R ask(String question,String sessionId,String userId);
R specialAsk(String sessionId,String userId,Map<String,Object> extra);
void updateVideo(Map<String,Object> request);
Boolean updateCanvas(Map<String,Object> request);

22
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java

@ -103,6 +103,11 @@ public class InteractiveServiceImpl implements IInteractiveService {
log.error("远程调用大模型【发起问答】接口失败!");
return R.fail("远程调用大模型【发起问答】接口失败!");
}
this.addQuestionSessionId(sessionId);
return R.success("消息发送成功");
}
private void addQuestionSessionId(String sessionId) {
// 添加redis问题会话
Object json = redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY);
if(ObjectUtil.isEmpty(json)){
@ -115,6 +120,23 @@ public class InteractiveServiceImpl implements IInteractiveService {
}
redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY,JSONObject.toJSONString(asks));
}
}
@Override
public R specialAsk(String sessionId, String userId, Map<String, Object> extra) {
Map<String,Object> params = new HashMap<>();
params.put("id",sessionId);
params.put("userid", userId);
params.put("extra",extra);
params.put("stationids",this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId).filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).toArray());
params.put("projectids",this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getDeptId).filter(Func::isNotEmpty).map(String::valueOf).toArray());
HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantSpecialAsk())
.body(JSON.toJSONString(params)).execute();
if(response.getStatus() != HttpServletResponse.SC_OK) {
log.error("远程调用大模型【发起特殊问答】接口失败!");
return R.fail("远程调用大模型【发起特殊问答】接口失败!");
}
this.addQuestionSessionId(sessionId);
return R.success("消息发送成功");
}

18
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java

@ -46,7 +46,7 @@ public class JumpRouteJoinStrategy {
private ExtraVO getScadaExtra(Map<String,String> args,FunctionEntity function) {
// 跳转页面逻辑
ExtraVO extraVO = new ExtraVO();
extraVO.setImmediatelyJump(true);
Map<String, String> params = this.scadaResolve(args);
// 根据hz3000画面版本获取path
Integer picResource = Integer.valueOf(params.get("picResource"));
@ -79,15 +79,6 @@ public class JumpRouteJoinStrategy {
return extraVO;
}
private ExtraVO getVideoExtra(Map<String,String> args,FunctionEntity function) {
// 跳转页面逻辑
ExtraVO extraVO = new ExtraVO();
Map<String, String> params = this.videoResolve(args);
String path = this.replacePath(function.getPath(), params);
extraVO.setRoute(path);
return extraVO;
}
/**
* 解析实时画面参数
* @param args 大模型解析参数
@ -100,13 +91,6 @@ public class JumpRouteJoinStrategy {
return this.resolve(params,keys);
}
private Map<String,String> videoResolve(Map<String,String> args) {
String params = args.get("canvas_id");
// 参数格式为:id^name^stationCode^pointCode^host^appKey^appSecret
String[] keys = new String[]{"id","name","stationCode","pointCode","host","appKey","appSecret"};
return this.resolve(params,keys);
}
private Map<String,String> resolve(String paramsStr,String... keys) {
Map<String,String> result = new HashMap<>();
List<String> params = Func.toStrList("\\^", paramsStr);

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

@ -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);
}
}

Loading…
Cancel
Save