Browse Source

add:智能诊断页面跳转逻辑

zhongwei
haungxing 9 months ago
parent
commit
9873e843d5
  1. 2
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java
  2. 20
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ExtraTypeEnum.java
  3. 1
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java
  4. 51
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java
  5. 9
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java
  6. 1
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java

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

@ -14,7 +14,7 @@ import java.io.Serializable;
@ApiModel("响应内容")
public class ExtraVO implements Serializable {
@ApiModelProperty("交互类型")
@ApiModelProperty("交互类型 1:打开页面,2:打开链接")
private String type;
@ApiModelProperty("若为弹窗,则返回路由")

20
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ExtraTypeEnum.java

@ -0,0 +1,20 @@
package com.hnac.hzims.bigmodel.interactive.constants;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @Author: huangxing
* @Date: 2024/05/08 16:49
*/
@AllArgsConstructor
public enum ExtraTypeEnum {
/**打开页面**/
OPEN_PAGE("1"),
/**链接**/
LINK("2")
;
@Getter
private final String type;
}

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

@ -14,6 +14,7 @@ import java.util.Optional;
public enum FuncRouteEnum {
OPEN_SCADA("open_scada","打开实时画面"),
OPEN_VIDEO("open_video","打开视频监控"),
DIAGNOSE("diagnose","智能诊断")
;
@Getter
private String funcCode;

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

@ -0,0 +1,51 @@
package com.hnac.hzims.bigmodel.interactive.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.bigmodel.interactive.constants.ExtraTypeEnum;
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.Optional;
/**
* @Author: huangxing
* @Date: 2024/05/08 16:19
*/
@Service
public class ExtraResolveStrategyService {
/**
* 解析DFP返回extra
* @param extraStr DFP返回extra
* @return 与前端交互extra
*/
public ExtraVO resolve(String extraStr) {
JSONObject extra = JSONObject.parseObject(extraStr);
String functionCode = Optional.ofNullable(extra.get("func")).map(String::valueOf).orElse("");
if(StringUtil.isNotBlank(functionCode)) {
FuncRouteEnum funcRouteEnum = FuncRouteEnum.getEnumByFuncCode(functionCode);
switch (funcRouteEnum) {
case DIAGNOSE:
return this.resolveDiagnose(extra);
default:
break;
}
}
return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class);
}
private ExtraVO resolveDiagnose(Map<String,Object> extra) {
ExtraVO result = new ExtraVO();
JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")));
String faultId = data.getString("fault_id");
String faultName = data.getString("fault_name");
result.setLabel(faultName);
// TODO 拼接诊断链接
result.setType(ExtraTypeEnum.LINK.getType());
return result;
}
}

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

@ -12,6 +12,7 @@ import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService;
import com.hnac.hzims.bigmodel.interactive.service.IJumpPageService;
import com.hnac.hzims.bigmodel.function.service.IFunctionService;
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -19,6 +20,7 @@ import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil;
@ -64,6 +66,8 @@ public class InteractiveServiceImpl implements IInteractiveService {
private final RedisTemplate redisTemplate;
private final ExtraResolveStrategyService extraResolveStrategyService;
@Value("${fdp.host}")
private String fdpHost;
@ -125,6 +129,11 @@ public class InteractiveServiceImpl implements IInteractiveService {
Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> {
throw new ServiceException("远程调用大模型【获取问题答案】接口失败!");
});
JSONArray.parseArray(response.body(),AnswerVO.class).forEach(answerVO -> {
String[] extras = answerVO.getExtra();
List<String> extraList = Arrays.stream(extras).map(extra -> extraResolveStrategyService.resolve(extra)).map(JSON::toJSONString).collect(Collectors.toList());
answerVO.setExtra(extraList.toArray(new String[extraList.size()]));
});
return JSONArray.parseArray(response.body(),AnswerVO.class);
}

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

@ -48,6 +48,7 @@ public class JumpRouteJoinStrategy {
private ExtraVO getScadaExtra(Map<String,String> args,FunctionEntity function) {
// 跳转页面逻辑
ExtraVO extraVO = new ExtraVO();
Map<String, String> params = this.scadaResolve(args);
// 根据hz3000画面版本获取path
Integer picResource = Integer.valueOf(params.get("picResource"));

Loading…
Cancel
Save