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 a78b0e9..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 @@ -12,12 +12,13 @@ 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","选择站点"), CHOOSE_VIDEO("choose_video","选择视频"), CHOOSE_CANVAS("choose_canvas","选择画面"), + CHOOSE_FAULT("choose_fault","选择故障"), ; @Getter private String funcCode; @@ -26,7 +27,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/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/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index 3e5f6c6..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; @@ -50,22 +47,39 @@ 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); + case CHOOSE_FAULT: + return this.resolveChooseFault(extra); + default: + break; + } } } 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/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..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: @@ -194,7 +197,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 +207,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..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 @@ -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,13 +53,16 @@ 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")); 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"); 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 df732d1..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 @@ -194,7 +194,6 @@ public class InteractiveSchedule { } @XxlJob(SYNCHRONOUS_FAULT_INSTRUCT) - //@Scheduled(cron = "0/10 * * * * ?") public ReturnT synchronousFaultInstruct(String params) { Map request = new HashMap<>(2); // 获取站点列表 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..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; } @@ -147,7 +150,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); @@ -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); + } } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java index 558bf50..13d8cb0 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java @@ -129,6 +129,7 @@ public class RobotServiceImpl extends BaseServiceImpl Optional attrOptional = paramDeviceAttrR.getData().stream().filter(deviceAttr -> k.getValue().getN().equals(deviceAttr.getName())).findFirst(); data.setModelClassifyId(attrOptional.get().getModelClassifyId()); data.setModelClassifyName(attrOptional.get().getModelClassifyName()); + data.setUnits(attrOptional.get().getUnits()); return data; })).collect(Collectors.toList()); return result.stream().collect(Collectors.groupingBy(RobotRealDataVO::getModelClassifyName)); diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/vo/robot/RobotRealDataVO.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/vo/robot/RobotRealDataVO.java index f3371a7..00e3eda 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/vo/robot/RobotRealDataVO.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/vo/robot/RobotRealDataVO.java @@ -49,4 +49,7 @@ public class RobotRealDataVO implements Serializable { @ApiModelProperty("启停状态") private Integer state; + + @ApiModelProperty("单位") + private String units; } diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/web/MsgWsRecordHistoryController.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/web/MsgWsRecordHistoryController.java index a800d2b..4345391 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/web/MsgWsRecordHistoryController.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/web/MsgWsRecordHistoryController.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.message.controller; +package com.hnac.hzims.message.web; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; @@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.*; * @author xiashandong * @created 2021-06-28 16:45 **/ +@Deprecated @RestController @AllArgsConstructor @RequestMapping("/msg/ws/record/history")