Browse Source

fix:choose类型函数解析逻辑变更

zhongwei
haungxing 6 months ago
parent
commit
305b8098b1
  1. 2
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java
  2. 2
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/FaultSelectionVO.java
  3. 13
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteSelectionVO.java
  4. 2
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ScadaSelectionVO.java
  5. 15
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java
  6. 109
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java
  7. 27
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java
  8. 2
      pom.xml

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

@ -38,6 +38,6 @@ public class ExtraVO implements Serializable {
private boolean isSpecial; private boolean isSpecial;
@ApiModelProperty("选项") @ApiModelProperty("选项")
private List<? extends SelectionVO> selection; private List selection;
} }

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

@ -13,4 +13,6 @@ import java.io.Serializable;
@EqualsAndHashCode @EqualsAndHashCode
public class FaultSelectionVO extends SelectionVO implements Serializable { public class FaultSelectionVO extends SelectionVO implements Serializable {
private Object item;
} }

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

@ -0,0 +1,13 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/05/31 09:15
*/
public class RemoteSelectionVO extends SelectionVO implements Serializable {
private Object item;
}

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

@ -13,4 +13,6 @@ import java.io.Serializable;
@EqualsAndHashCode @EqualsAndHashCode
public class ScadaSelectionVO extends SelectionVO implements Serializable { public class ScadaSelectionVO extends SelectionVO implements Serializable {
private Object item;
} }

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

@ -12,13 +12,14 @@ import java.util.Optional;
*/ */
@AllArgsConstructor @AllArgsConstructor
public enum FuncRouteEnum { public enum FuncRouteEnum {
OPEN_CANVAS("open_canvas","打开实时画面",null), OPEN_CANVAS("open_canvas","打开实时画面",FunctionConstants.TypeEnum.JUMP),
OPEN_VIDEO("open_video","打开视频监控",null), OPEN_VIDEO("open_video","打开视频监控",FunctionConstants.TypeEnum.PARAMS),
DIAGNOSE("diagnose","智能诊断",null), DIAGNOSE("diagnose","智能诊断",FunctionConstants.TypeEnum.PARAMS),
CHOOSE_STATION("choose_station","选择站点",null), CHOOSE_STATION("choose_station","选择站点",FunctionConstants.TypeEnum.CHOOSE),
CHOOSE_VIDEO("choose_video","选择视频",null), CHOOSE_VIDEO("choose_video","选择视频",FunctionConstants.TypeEnum.CHOOSE),
CHOOSE_CANVAS("choose_canvas","选择画面",null), CHOOSE_CANVAS("choose_canvas","选择画面",FunctionConstants.TypeEnum.CHOOSE),
CHOOSE_FAULT("choose_fault","选择故障",null), CHOOSE_FAULT("choose_fault","选择故障",FunctionConstants.TypeEnum.CHOOSE),
CHOOSE_YK("choose_yk","选择遥控",FunctionConstants.TypeEnum.CHOOSE),
CONFIRM_YK("confirm_yk","遥控确认", FunctionConstants.TypeEnum.PARAMS), CONFIRM_YK("confirm_yk","遥控确认", FunctionConstants.TypeEnum.PARAMS),
SHOW_PARAM("show_param","设备参数查询", FunctionConstants.TypeEnum.PARAMS), SHOW_PARAM("show_param","设备参数查询", FunctionConstants.TypeEnum.PARAMS),
CHOOSE_YC("choose_yc","选择遥测数据",FunctionConstants.TypeEnum.CHOOSE), CHOOSE_YC("choose_yc","选择遥测数据",FunctionConstants.TypeEnum.CHOOSE),

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

@ -63,20 +63,17 @@ public class ExtraResolveStrategyService {
switch (funcRouteEnum) { switch (funcRouteEnum) {
case DIAGNOSE: case DIAGNOSE:
return this.resolveDiagnose(extra); return this.resolveDiagnose(extra);
case CHOOSE_STATION:
return this.resolveChooseStation(extra);
case CHOOSE_VIDEO: case CHOOSE_VIDEO:
return this.resolveChooseVideo(extra);
case CHOOSE_CANVAS: case CHOOSE_CANVAS:
return this.resolveChooseScada(extra); case CHOOSE_STATION:
case CHOOSE_FAULT: case CHOOSE_FAULT:
return this.resolveChooseFault(extra); case CHOOSE_YC:
case CHOOSE_YK:
return this.resolveChooseSelection(extra,funcRouteEnum);
case CONFIRM_YK: case CONFIRM_YK:
return this.resolveConfirmRemote(extra); return this.resolveConfirmRemote(extra);
case SHOW_PARAM: case SHOW_PARAM:
return this.resolveShowParam(extra); return this.resolveShowParam(extra);
case CHOOSE_YC:
return this.resolveChooseYc(extra);
default: default:
break; break;
} }
@ -88,19 +85,31 @@ public class ExtraResolveStrategyService {
return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class); return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class);
} }
private ExtraVO resolveChooseYc(JSONObject extra) { private ExtraVO resolveChooseSelection(JSONObject extra,FuncRouteEnum funcRouteEnum) {
ExtraVO result = new ExtraVO(); ExtraVO result = new ExtraVO();
JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); JSONArray selections = JSONArray.parseArray(JSON.toJSONString(extra.get("data")));
if(data.containsKey("ycs")) { result.setFuncCode(funcRouteEnum.getFuncCode());
List<AttrSelectionVO> attrs = JSONArray.parseArray(JSON.toJSONString(data.get("ycs")), AttrSelectionVO.class);
result.setSelection(attrs);
}
result.setFuncCode(FuncRouteEnum.CHOOSE_YC.getFuncCode());
result.setSpecial(true); result.setSpecial(true);
result.setType(FuncRouteEnum.CHOOSE_YC.getType().getType()); result.setSelection(selections);
result.setType(funcRouteEnum.getType().getType());
return result; return result;
} }
// private ExtraVO resolveChooseYc(JSONObject extra) {
// ExtraVO result = new ExtraVO();
// JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")));
// if(data.containsKey("yks")) {
//
//
// List<AttrSelectionVO> attrs = JSONArray.parseArray(JSON.toJSONString(data.get("yks")), AttrSelectionVO.class);
// result.setSelection(attrs);
// }
// result.setFuncCode(FuncRouteEnum.CHOOSE_YC.getFuncCode());
// result.setSpecial(true);
// result.setType(FuncRouteEnum.CHOOSE_YC.getType().getType());
// return result;
// }
private ExtraVO resolveShowParam(Map<String,Object> extra) { private ExtraVO resolveShowParam(Map<String,Object> extra) {
DataVO data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")),DataVO.class); DataVO data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")),DataVO.class);
if(Func.isNotEmpty(data)) { if(Func.isNotEmpty(data)) {
@ -143,7 +152,7 @@ public class ExtraResolveStrategyService {
result.setType(FuncRouteEnum.CONFIRM_YK.getType().getType()); result.setType(FuncRouteEnum.CONFIRM_YK.getType().getType());
R<DeviceInstanceFuncVO> funcVOR = deviceClient.getFuncById(remoteParam.getFuncId()); R<DeviceInstanceFuncVO> funcVOR = deviceClient.getFuncById(remoteParam.getFuncId());
if(funcVOR.isSuccess()) { if(funcVOR.isSuccess()) {
Map<String,Object> param = new HashMap(1); Map<String,Object> param = new HashMap();
param.put("control",funcVOR.getData()); param.put("control",funcVOR.getData());
param.put("deviceName",remoteParam.getDeviceName()); param.put("deviceName",remoteParam.getDeviceName());
param.put("projectName",remoteParam.getProjectName()); param.put("projectName",remoteParam.getProjectName());
@ -154,18 +163,18 @@ public class ExtraResolveStrategyService {
return result; return result;
} }
private ExtraVO resolveChooseFault(Map<String,Object> extra) { // private ExtraVO resolveChooseFault(Map<String,Object> extra) {
ExtraVO result = new ExtraVO(); // ExtraVO result = new ExtraVO();
JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); // JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")));
if(data.containsKey("faults")) { // if(data.containsKey("faults")) {
List<FaultSelectionVO> faults = JSONArray.parseArray(JSON.toJSONString(data.get("faults")), FaultSelectionVO.class); // List<FaultSelectionVO> faults = JSONArray.parseArray(JSON.toJSONString(data.get("faults")), FaultSelectionVO.class);
result.setSelection(faults); // result.setSelection(faults);
} // }
result.setFuncCode(FuncRouteEnum.CHOOSE_FAULT.getFuncCode()); // result.setFuncCode(FuncRouteEnum.CHOOSE_FAULT.getFuncCode());
result.setSpecial(true); // result.setSpecial(true);
result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); // result.setType(FunctionConstants.TypeEnum.CHOOSE.getType());
return result; // return result;
} // }
private ExtraVO resolveDiagnose(Map<String,Object> extra) { private ExtraVO resolveDiagnose(Map<String,Object> extra) {
ExtraVO result = new ExtraVO(); ExtraVO result = new ExtraVO();
@ -187,28 +196,28 @@ public class ExtraResolveStrategyService {
* @param extra * @param extra
* @return * @return
*/ */
private ExtraVO resolveChooseStation(Map<String,Object> extra) { // private ExtraVO resolveChooseStation(Map<String,Object> extra) {
ExtraVO result = new ExtraVO(); // ExtraVO result = new ExtraVO();
JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); // JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")));
if(data.containsKey("stations")) { // if(data.containsKey("stations")) {
List<String> stations = JSONArray.parseArray(JSON.toJSONString(data.get("stations")), String.class); // List<String> stations = JSONArray.parseArray(JSON.toJSONString(data.get("stations")), String.class);
List<StationSelectionVO> selectionList = stations.stream().map(stationId -> { // List<StationSelectionVO> selectionList = stations.stream().map(stationId -> {
StationSelectionVO selectionVO = new StationSelectionVO(); // StationSelectionVO selectionVO = new StationSelectionVO();
R<StationEntity> stationR = stationClient.getStationByCode(stationId); // R<StationEntity> stationR = stationClient.getStationByCode(stationId);
if (stationR.isSuccess() && Func.isNotEmpty(stationR.getData())) { // if (stationR.isSuccess() && Func.isNotEmpty(stationR.getData())) {
selectionVO.setId(stationId); // selectionVO.setId(stationId);
selectionVO.setName(stationR.getData().getName()); // selectionVO.setName(stationR.getData().getName());
} // }
return selectionVO; // return selectionVO;
}).collect(Collectors.toList()); // }).collect(Collectors.toList());
result.setSelection(selectionList); // result.setSelection(selectionList);
result.setFuncCode(FuncRouteEnum.CHOOSE_STATION.getFuncCode()); // result.setFuncCode(FuncRouteEnum.CHOOSE_STATION.getFuncCode());
result.setSpecial(true); // result.setSpecial(true);
result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); // result.setType(FunctionConstants.TypeEnum.CHOOSE.getType());
} // }
result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); // result.setType(FunctionConstants.TypeEnum.CHOOSE.getType());
return result; // return result;
} // }
private ExtraVO resolveChooseVideo(Map<String,Object> extra) { private ExtraVO resolveChooseVideo(Map<String,Object> extra) {
ExtraVO result = new ExtraVO(); ExtraVO result = new ExtraVO();

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

@ -108,6 +108,7 @@ public class InteractiveHandler extends TextWebSocketHandler {
case CHOOSE_STATION: case CHOOSE_STATION:
case CHOOSE_YC: case CHOOSE_YC:
case CHOOSE_FAULT: case CHOOSE_FAULT:
case CHOOSE_YK:
this.handleDefaultChoose(messageContext,sessionId); this.handleDefaultChoose(messageContext,sessionId);
break; break;
case CHOOSE_VIDEO: case CHOOSE_VIDEO:
@ -126,10 +127,6 @@ public class InteractiveHandler extends TextWebSocketHandler {
IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class); IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class);
String userId = messageContext.getString("userId"); String userId = messageContext.getString("userId");
String funcCode = messageContext.getString("funcCode"); String funcCode = messageContext.getString("funcCode");
StationSelectionVO selectionVO = messageContext.getObject("selection",StationSelectionVO.class);
JSONObject data = new JSONObject();
data.put("station_id",selectionVO.getId());
data.put("station_name",selectionVO.getName());
Map<String, Object> extra = new HashMap<>(2); Map<String, Object> extra = new HashMap<>(2);
extra.put("func",funcCode); extra.put("func",funcCode);
extra.put("data",messageContext.getObject("selection", JSONObject.class)); extra.put("data",messageContext.getObject("selection", JSONObject.class));
@ -195,26 +192,4 @@ public class InteractiveHandler extends TextWebSocketHandler {
} }
} }
private void handleFaultChoose(JSONObject messageContext,String sessionId) {
IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class);
String userId = messageContext.getString("userId");
String funcCode = messageContext.getString("funcCode");
FaultSelectionVO selectionVO = messageContext.getObject("selection",FaultSelectionVO.class);
Map<String, Object> extra = new HashMap<>(2);
extra.put("func",funcCode);
extra.put("data",selectionVO);
interactiveService.specialAsk(sessionId,userId,extra);
}
private void handleDataChoose(JSONObject messageContext,String sessionId) {
IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class);
String userId = messageContext.getString("userId");
String funcCode = messageContext.getString("funcCode");
FaultSelectionVO selectionVO = messageContext.getObject("selection",FaultSelectionVO.class);
Map<String, Object> extra = new HashMap<>(2);
extra.put("func",funcCode);
extra.put("data",selectionVO);
interactiveService.specialAsk(sessionId,userId,extra);
}
} }

2
pom.xml

@ -76,7 +76,7 @@
<groupId>com.hnac.hzinfo.data</groupId> <groupId>com.hnac.hzinfo.data</groupId>
<artifactId>hzinfo-data-sdk</artifactId> <artifactId>hzinfo-data-sdk</artifactId>
<!-- <version>${bladex.project.version}</version>--> <!-- <version>${bladex.project.version}</version>-->
<version>5.1.1.RELEASE.fix.4</version> <version>5.1.1.RELEASE.fix.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.xuxueli</groupId> <groupId>com.xuxueli</groupId>

Loading…
Cancel
Save