From 615355d72bacbdd7fdc9ec56b3bae897c493f461 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Thu, 9 May 2024 17:13:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=AE=8C=E5=96=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E9=80=89=E9=A1=B9=E9=97=AE=E9=A2=98=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interactive/constants/FunctionConstants.java | 3 +- .../interactive/constants/SelectionVO.java | 20 +++++++++++ .../interactive/constants/StationSelectionVO.java | 12 +++++++ .../hzims/bigmodel/interactive/vo/ExtraVO.java | 10 +++++- .../interactive/constants/FuncRouteEnum.java | 3 +- .../service/impl/ExtraResolveStrategyService.java | 42 ++++++++++++++++++++++ 6 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SelectionVO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/StationSelectionVO.java diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java index 5a509dc..7114de1 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java +++ b/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; diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SelectionVO.java new file mode 100644 index 0000000..a7a271f --- /dev/null +++ b/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; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/StationSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/StationSelectionVO.java new file mode 100644 index 0000000..d67a829 --- /dev/null +++ b/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 { + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java index 92174e8..dbf1a86 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java +++ b/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 params; + @ApiModelProperty("是否为特殊函数") + private boolean isSpecial; + + @ApiModelProperty("选项") + private List selection; } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java index 7419128..724f97e 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java +++ b/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; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index 9affdac..c16cdb6 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/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 extra) { + ExtraVO result = new ExtraVO(); + JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); + if(data.containsKey("stations")) { + List stations = JSONArray.parseArray(JSON.toJSONString(data.get("stations")), String.class); + List selectionList = stations.stream().map(stationId -> { + StationSelectionVO selectionVO = new StationSelectionVO(); + R 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; + } }