From 27e18383a6c57c4ef8ed2b455ee134e85f0cbe39 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 15 May 2024 15:28:22 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:open=5Fscada=E4=BF=AE=E6=94=B9=E4=B8=BA?= =?UTF-8?q?open=5Fcanvas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java | 2 +- .../bigmodel/interactive/controller/InteractiveController.java | 4 ++-- .../hzims/bigmodel/interactive/service/IInteractiveService.java | 2 +- .../bigmodel/interactive/service/impl/InteractiveServiceImpl.java | 8 ++++---- .../bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java | 4 ++-- .../com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java | 5 ++--- .../hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java | 2 +- 7 files changed, 13 insertions(+), 14 deletions(-) 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 a78b0e9..aca3fab 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 @@ -12,7 +12,7 @@ import java.util.Optional; */ @AllArgsConstructor public enum FuncRouteEnum { - OPEN_SCADA("open_scada","打开实时画面"), + OPEN_CANVAS("open_canvas","打开实时画面"), OPEN_VIDEO("open_video","打开视频监控"), DIAGNOSE("diagnose","智能诊断"), CHOOSE_STATION("choose_station","选择站点"), diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java index 7739800..90102a3 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java @@ -48,8 +48,8 @@ public class InteractiveController { @RequestMapping(value = "/authentication",method = {RequestMethod.GET,RequestMethod.POST}) public R authentication(@RequestParam(required = false) @ApiParam("站点编号") String stationId, @RequestParam @ApiParam("用户ID") String userId, - @RequestParam(required = false) @ApiParam("菜单ID") String funcCode) { - return R.status(interactiveService.authentication(stationId,userId,funcCode)); + @RequestParam(required = false) @ApiParam("菜单ID") String func) { + return R.status(interactiveService.authentication(stationId,userId,func)); } @ApiOperation("获取问答sessionId") diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java index b85ad2f..40b06ea 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java @@ -30,7 +30,7 @@ public interface IInteractiveService { List getAnswerBySessionIds(String sessionIds); - Boolean authentication(String stationId, String userId, String funcCode); + Boolean authentication(String stationId, String userId, String func); Boolean removeSessionId(String sessionId); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java index f59aefb..1c09556 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java @@ -194,7 +194,7 @@ public class InteractiveServiceImpl implements IInteractiveService { } @Override - public Boolean authentication(String stationId, String userId, String funcCode) { + public Boolean authentication(String stationId, String userId, String func) { // 站点鉴权 if(StringUtil.isNotBlank(stationId)) { List stations = this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId) @@ -204,9 +204,9 @@ public class InteractiveServiceImpl implements IInteractiveService { }); } // 菜单鉴权 - if(StringUtil.isNotBlank(funcCode) && StringUtil.isNotBlank(userId)) { - FunctionEntity function = functionService.getFunctionByCode(funcCode); - if(Func.isNotEmpty(function.getRoute()) && StringUtil.isNotBlank(function.getRoute())) { + if(StringUtil.isNotBlank(func) && StringUtil.isNotBlank(userId)) { + FunctionEntity function = functionService.getFunctionByCode(func); + if(Func.isNotEmpty(function) && Func.isNotEmpty(function.getRoute()) && StringUtil.isNotBlank(function.getRoute())) { R authenticationR = userClient.permissionMenuById(Long.valueOf(userId), function.getRoute()); Assert.isTrue(authenticationR.isSuccess() && authenticationR.getData(), () -> { throw new ServiceException("人员菜单鉴权失败!"); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java index 2ad7ae3..6c320a3 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java @@ -40,7 +40,7 @@ public class JumpRouteJoinStrategy { FuncRouteEnum routeEnum = FuncRouteEnum.getEnumByFuncCode(function.getCode()); if(Func.isNotEmpty(routeEnum)) { switch(routeEnum) { - case OPEN_SCADA: + case OPEN_CANVAS: return this.getScadaExtra(args,function); default: break; @@ -53,7 +53,7 @@ public class JumpRouteJoinStrategy { // 跳转页面逻辑 ExtraVO extraVO = new ExtraVO(); extraVO.setImmediatelyJump(true); - extraVO.setFuncCode(FuncRouteEnum.OPEN_SCADA.getFuncCode()); + extraVO.setFuncCode(FuncRouteEnum.OPEN_CANVAS.getFuncCode()); Map params = this.scadaResolve(args); // 根据hz3000画面版本获取path Integer picResource = Integer.valueOf(params.get("picResource")); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java index 629d287..85affae 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java @@ -193,9 +193,8 @@ public class InteractiveSchedule { return ReturnT.SUCCESS; } - //@XxlJob(SYNCHRONOUS_FAULT_INSTRUCT) String params - @Scheduled(cron = "0/10 * * * * ?") - public ReturnT synchronousFaultInstruct() { + @XxlJob(SYNCHRONOUS_FAULT_INSTRUCT) + public ReturnT synchronousFaultInstruct(String params) { Map request = new HashMap<>(2); // 获取站点列表 R> stationsR = stationClient.list(new StationEntity()); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java index 700e44b..bc475f7 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java @@ -147,7 +147,7 @@ public class InteractiveHandler extends TextWebSocketHandler { Map param = new HashMap<>(1); param.put("canvas_id",selection.getId()); IFunctionService functionService = SpringUtil.getBean(IFunctionService.class); - FunctionEntity function = functionService.getFunctionByCode("open_scada"); + FunctionEntity function = functionService.getFunctionByCode(FuncRouteEnum.OPEN_CANVAS.getFuncCode()); ExtraVO scadaExtra = strategy.getScadaExtra(param, function); AnswerVO answerVO = new AnswerVO(); answerVO.setSessionId(sessionId); From 4f85176c37666eeb24b1d417d423486769658b93 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 15 May 2024 17:01:38 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:open=5Fscada=E4=BF=AE=E6=94=B9=E4=B8=BA?= =?UTF-8?q?open=5Fcanvas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interactive/constants/FuncRouteEnum.java | 2 +- .../service/impl/ExtraResolveStrategyService.java | 24 ++++++++++++---------- .../service/impl/InteractiveServiceImpl.java | 3 +++ 3 files changed, 17 insertions(+), 12 deletions(-) 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 aca3fab..c4fc85e 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 @@ -26,7 +26,7 @@ public enum FuncRouteEnum { public static FuncRouteEnum getEnumByFuncCode(String funcCode) { Optional FuncRoute = Arrays.stream(FuncRouteEnum.class.getEnumConstants()).filter(e -> funcCode.equals(e.getFuncCode())).findFirst(); - return FuncRoute.get(); + return FuncRoute.orElse(null); } } 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 3e5f6c6..a9c590b 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 @@ -50,17 +50,19 @@ public class ExtraResolveStrategyService { if(StringUtil.isNotBlank(functionCode)) { XxlJobLogger.log("函数编号为:" + functionCode); FuncRouteEnum funcRouteEnum = FuncRouteEnum.getEnumByFuncCode(functionCode); - switch (funcRouteEnum) { - case DIAGNOSE: - return this.resolveDiagnose(extra); - case CHOOSE_STATION: - return this.resolveChooseStation(extra); - case CHOOSE_VIDEO: - return this.resolveChooseVideo(extra); - case CHOOSE_CANVAS: - return this.resolveChooseScada(extra); - default: - break; + if(Func.isNotEmpty(funcRouteEnum)) { + switch (funcRouteEnum) { + case DIAGNOSE: + return this.resolveDiagnose(extra); + case CHOOSE_STATION: + return this.resolveChooseStation(extra); + case CHOOSE_VIDEO: + return this.resolveChooseVideo(extra); + case CHOOSE_CANVAS: + return this.resolveChooseScada(extra); + default: + break; + } } } return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java index 1c09556..4e835a0 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java @@ -73,6 +73,9 @@ public class InteractiveServiceImpl implements IInteractiveService { logger.info("interactive:resolve","开始解析大模型函数,函数内容为:" + JSON.toJSONString(req)); FunctionEntity function = functionService.getFunctionByCode(req.getFunctionName()); TypeEnum typeEnum = TypeEnum.getTypeEnumByType(function.getType()); + if(Func.isEmpty(typeEnum)) { + throw new ServiceException("函数解析失败!"); + } switch (typeEnum) { // 页面跳转 case JUMP: From 75384cd9504b5a0c3be385fb8f070fce85ce9094 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 15 May 2024 17:32:29 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=E5=AE=9E=E6=97=B6=E7=94=BB=E9=9D=A2?= =?UTF-8?q?=E7=94=BB=E9=9D=A2=E7=B1=BB=E5=9E=8B=E8=BF=94=E5=9B=9E=E5=89=8D?= =?UTF-8?q?=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java index 6c320a3..ddb6f69 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java @@ -60,6 +60,9 @@ public class JumpRouteJoinStrategy { JSONObject pathObject = JSONObject.parseObject(function.getPath()); R stationR = stationClient.getStationByCode(params.get("projectId")); extraVO.setLabel(Optional.ofNullable(stationR).filter(r -> r.isSuccess()).map(R::getData).map(StationEntity::getName).orElse("") + "_" + params.get("name")); + Map extraParams = new HashMap<>(1); + extraParams.put("picResource",picResource); + extraVO.setParams(extraParams); // 云组态 if(picResource == 0) { String scada = pathObject.getString("scada"); From bdb19c110e3be05e59bfca4f4326fcd8bc2c78c3 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Thu, 16 May 2024 15:36:17 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix:=E9=80=89=E6=8B=A9=E6=95=85=E9=9A=9C?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigmodel/interactive/vo/FaultSelectionVO.java | 16 ++++++++++++++++ .../interactive/constants/FuncRouteEnum.java | 1 + .../service/impl/ExtraResolveStrategyService.java | 20 ++++++++++++++++---- .../websocket/handler/InteractiveHandler.java | 17 +++++++++++++++++ 4 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/FaultSelectionVO.java diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/FaultSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/FaultSelectionVO.java new file mode 100644 index 0000000..00aa21e --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/FaultSelectionVO.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/16 15:10 + */ +@Data +@EqualsAndHashCode +public class FaultSelectionVO extends SelectionVO implements Serializable { + +} 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 c4fc85e..3dd1caf 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 @@ -18,6 +18,7 @@ public enum FuncRouteEnum { CHOOSE_STATION("choose_station","选择站点"), CHOOSE_VIDEO("choose_video","选择视频"), CHOOSE_CANVAS("choose_canvas","选择画面"), + CHOOSE_FAULT("choose_fault","选择故障"), ; @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 a9c590b..c1895b9 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 @@ -5,10 +5,7 @@ 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.vo.ScadaSelectionVO; -import com.hnac.hzims.bigmodel.interactive.vo.StationSelectionVO; -import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import com.hnac.hzims.bigmodel.interactive.vo.VideoSelectionVO; +import com.hnac.hzims.bigmodel.interactive.vo.*; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; import com.hnac.hzims.operational.station.feign.IStationClient; @@ -60,6 +57,8 @@ public class ExtraResolveStrategyService { return this.resolveChooseVideo(extra); case CHOOSE_CANVAS: return this.resolveChooseScada(extra); + case CHOOSE_FAULT: + return this.resolveChooseFault(extra); default: break; } @@ -68,6 +67,19 @@ public class ExtraResolveStrategyService { return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class); } + private ExtraVO resolveChooseFault(Map extra) { + ExtraVO result = new ExtraVO(); + JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); + if(data.containsKey("faults")) { + List faults = JSONArray.parseArray(JSON.toJSONString(data.get("faults")), FaultSelectionVO.class); + result.setSelection(faults); + } + result.setFuncCode(FuncRouteEnum.CHOOSE_FAULT.getFuncCode()); + result.setSpecial(true); + result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); + return result; + } + private ExtraVO resolveDiagnose(Map extra) { ExtraVO result = new ExtraVO(); JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java index bc475f7..96dfc4e 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java @@ -90,6 +90,9 @@ public class InteractiveHandler extends TextWebSocketHandler { case CHOOSE_CANVAS: this.handleScadaChoose(messageContext,sessionId); break; + case CHOOSE_FAULT: + this.handleFaultChoose(messageContext,sessionId); + break; default: break; } @@ -168,4 +171,18 @@ public class InteractiveHandler extends TextWebSocketHandler { wsService.sendMessage(sessionId,textMessage); } } + + 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); + JSONObject data = new JSONObject(); + data.put("id",selectionVO.getId()); + data.put("name",selectionVO.getName()); + Map extra = new HashMap<>(2); + extra.put("func",funcCode); + extra.put("data",data); + interactiveService.specialAsk(sessionId,userId,extra); + } }