Browse Source

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

zhongwei
haungxing 7 months ago
parent
commit
615355d72b
  1. 3
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java
  2. 20
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SelectionVO.java
  3. 12
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/StationSelectionVO.java
  4. 10
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java
  5. 3
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java
  6. 42
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java

3
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java

@ -19,7 +19,8 @@ public interface FunctionConstants {
/**链接**/
LINK("2"),
/**参数**/
PARAMS("3")
PARAMS("3"),
CHOOSE("4")
;
@Getter
private String type;

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

@ -0,0 +1,20 @@
package com.hnac.hzims.bigmodel.interactive.constants;
import lombok.Data;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/05/09 16:30
*/
@Data
public class SelectionVO implements Serializable {
/**选项ID**/
private String id;
/**选项名称**/
private String name;
}

12
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/StationSelectionVO.java

@ -0,0 +1,12 @@
package com.hnac.hzims.bigmodel.interactive.constants;
import lombok.Data;
/**
* @Author: huangxing
* @Date: 2024/05/09 16:32
*/
@Data
public class StationSelectionVO extends SelectionVO {
}

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

@ -1,10 +1,13 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import com.hnac.hzims.bigmodel.interactive.constants.SelectionVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import net.sf.jsqlparser.statement.select.Select;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
@ -15,7 +18,7 @@ import java.util.Map;
@ApiModel("响应内容")
public class ExtraVO implements Serializable {
@ApiModelProperty("交互类型 1:打开页面,2:打开链接,3:参数传递")
@ApiModelProperty("交互类型 1:打开页面,2:打开链接,3:参数传递,4:完善选项")
private String type;
@ApiModelProperty("若为弹窗,则返回路由")
@ -30,4 +33,9 @@ public class ExtraVO implements Serializable {
@ApiModelProperty("附带参数")
private Map<String,Object> params;
@ApiModelProperty("是否为特殊函数")
private boolean isSpecial;
@ApiModelProperty("选项")
private List<? extends SelectionVO> selection;
}

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

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

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

@ -1,23 +1,36 @@
package com.hnac.hzims.bigmodel.interactive.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum;
import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants;
import com.hnac.hzims.bigmodel.interactive.constants.StationSelectionVO;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @Author: huangxing
* @Date: 2024/05/08 16:19
*/
@Service
@AllArgsConstructor
public class ExtraResolveStrategyService {
private final IStationClient stationClient;
/**
* 解析DFP返回extra
* @param extraStr DFP返回extra
@ -31,6 +44,8 @@ public class ExtraResolveStrategyService {
switch (funcRouteEnum) {
case DIAGNOSE:
return this.resolveDiagnose(extra);
case CHOOSE_STATION:
return this.resolveChooseStation(extra);
default:
break;
}
@ -48,4 +63,31 @@ public class ExtraResolveStrategyService {
result.setType(FunctionConstants.TypeEnum.LINK.getType());
return result;
}
/**
*
* @param extra
* @return
*/
private ExtraVO resolveChooseStation(Map<String,Object> extra) {
ExtraVO result = new ExtraVO();
JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")));
if(data.containsKey("stations")) {
List<String> stations = JSONArray.parseArray(JSON.toJSONString(data.get("stations")), String.class);
List<StationSelectionVO> selectionList = stations.stream().map(stationId -> {
StationSelectionVO selectionVO = new StationSelectionVO();
R<StationEntity> stationR = stationClient.getStationByCode(stationId);
if (stationR.isSuccess() && Func.isNotEmpty(stationR.getData())) {
selectionVO.setId(stationId);
selectionVO.setName(stationR.getData().getName());
}
return selectionVO;
}).collect(Collectors.toList());
result.setSelection(selectionList);
result.setSpecial(true);
result.setType(FunctionConstants.TypeEnum.CHOOSE.getType());
}
result.setType(FunctionConstants.TypeEnum.CHOOSE.getType());
return result;
}
}

Loading…
Cancel
Save