From 5ad63934bee434fe8866461f9ffc16964e10cd2f Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Tue, 21 May 2024 11:51:23 +0800 Subject: [PATCH] =?UTF-8?q?add:=E9=81=A5=E6=8E=A7=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interactive/constants/FunctionConstants.java | 5 ++- hzims-service-api/pom.xml | 1 - .../interactive/constants/FuncRouteEnum.java | 17 ++++++---- .../service/impl/ExtraResolveStrategyService.java | 25 ++++++++++++++ .../bigmodel/interactive/vo/RemoteParamVO.java | 39 ++++++++++++++++++++++ .../bigmodel/interactive/vo/SessionContentVO.java | 19 +++++++++++ .../websocket/constants/RedisKeyConstants.java | 13 ++++++++ .../websocket/handler/InteractiveHandler.java | 9 +++++ .../controller/StationVideoTypeController.java | 6 ++++ .../station/service/IStationVideoTypeService.java | 3 ++ .../station/service/impl/StationServiceImpl.java | 8 +++++ .../service/impl/StationVideoTypeServiceImpl.java | 8 +++++ hzims-service/pom.xml | 1 - pom.xml | 2 +- 14 files changed, 145 insertions(+), 11 deletions(-) create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SessionContentVO.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/constants/RedisKeyConstants.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 7114de1..6a2d62d 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 @@ -20,7 +20,10 @@ public interface FunctionConstants { LINK("2"), /**参数**/ PARAMS("3"), - CHOOSE("4") + /**选项**/ + CHOOSE("4"), + /**确认**/ + CONFIRM("5") ; @Getter private String type; diff --git a/hzims-service-api/pom.xml b/hzims-service-api/pom.xml index 59661cf..e19eb31 100644 --- a/hzims-service-api/pom.xml +++ b/hzims-service-api/pom.xml @@ -29,7 +29,6 @@ middle-api alarm-api big-model-api - suichang-api 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 3dd1caf..174df24 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,18 +12,21 @@ import java.util.Optional; */ @AllArgsConstructor public enum FuncRouteEnum { - 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","选择故障"), + OPEN_CANVAS("open_canvas","打开实时画面",null), + OPEN_VIDEO("open_video","打开视频监控",null), + DIAGNOSE("diagnose","智能诊断",null), + CHOOSE_STATION("choose_station","选择站点",null), + CHOOSE_VIDEO("choose_video","选择视频",null), + CHOOSE_CANVAS("choose_canvas","选择画面",null), + CHOOSE_FAULT("choose_fault","选择故障",null), + CONFIRM_YK("confirm_yk","遥控确认", FunctionConstants.TypeEnum.CONFIRM), ; @Getter private String funcCode; @Getter private String funcName; + @Getter + private FunctionConstants.TypeEnum type; public static FuncRouteEnum getEnumByFuncCode(String funcCode) { Optional FuncRoute = Arrays.stream(FuncRouteEnum.class.getEnumConstants()).filter(e -> funcCode.equals(e.getFuncCode())).findFirst(); 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 c1895b9..c464e05 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 @@ -6,16 +6,22 @@ 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.*; +import com.hnac.hzims.bigmodel.websocket.constants.RedisKeyConstants; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; import com.hnac.hzims.operational.station.feign.IStationClient; import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; +import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceFuncVO; import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.log.XxlJobLogger; import lombok.AllArgsConstructor; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; +import org.springblade.system.dto.ControlDTO; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import java.util.HashMap; @@ -35,6 +41,8 @@ public class ExtraResolveStrategyService { private final IStationClient stationClient; private final IStationVideoTypeClient videoTypeClient; private final JumpRouteJoinStrategy jumpRouteJoinStrategy; + private final DeviceClient deviceClient; + private final RedisTemplate redisTemplate; /** * 解析DFP返回extra @@ -59,6 +67,8 @@ public class ExtraResolveStrategyService { return this.resolveChooseScada(extra); case CHOOSE_FAULT: return this.resolveChooseFault(extra); + case CONFIRM_YK: + return this.resolveConfirmRemote(extra); default: break; } @@ -67,6 +77,21 @@ public class ExtraResolveStrategyService { return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class); } + private ExtraVO resolveConfirmRemote(Map extra) { + ExtraVO result = new ExtraVO(); + RemoteParamVO remoteParam = JSONObject.parseObject(JSON.toJSONString(extra.get("data")), RemoteParamVO.class); + result.setFuncCode(FuncRouteEnum.CONFIRM_YK.getFuncCode()); + result.setType(FunctionConstants.TypeEnum.CONFIRM.getType()); + R funcVOR = deviceClient.getFuncById(remoteParam.getFuncId()); + if(funcVOR.isSuccess()) { + Map param = new HashMap(1); + param.put("control",funcVOR.getData()); + param.put("value",remoteParam.getValue()); + result.setParams(param); + } + return result; + } + private ExtraVO resolveChooseFault(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/vo/RemoteParamVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java new file mode 100644 index 0000000..3bcf351 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java @@ -0,0 +1,39 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/20 14:46 + */ +@Data +@EqualsAndHashCode +public class RemoteParamVO implements Serializable { + + @JSONField(name = "id") + private String funcId; + + @JSONField(name = "yk_name") + private String remoteName; + + @JSONField(name = "device_id") + private String deviceCode; + + @JSONField(name = "device_name") + private String deviceName; + + @JSONField(name = "station_id") + private String projectId; + + @JSONField(name = "station_name") + private String projectName; + + private String signage; + + private String value; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SessionContentVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SessionContentVO.java new file mode 100644 index 0000000..1de0532 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SessionContentVO.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/20 19:31 + */ +@Data +@EqualsAndHashCode +public class SessionContentVO implements Serializable { + + /**机器码**/ + private String machineCode; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/constants/RedisKeyConstants.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/constants/RedisKeyConstants.java new file mode 100644 index 0000000..3cd0e30 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/constants/RedisKeyConstants.java @@ -0,0 +1,13 @@ +package com.hnac.hzims.bigmodel.websocket.constants; + +import com.hnac.hzims.common.constant.CommonConstant; + +/** + * @Author: huangxing + * @Date: 2024/05/20 19:11 + */ +public interface RedisKeyConstants { + + String SESSION_CONTENT_KEY = CommonConstant.TENANT_ID + ":hzims:bigModel:session:content"; + +} 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 96dfc4e..c1b9976 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 @@ -9,12 +9,14 @@ import com.hnac.hzims.bigmodel.interactive.service.impl.JumpRouteJoinStrategy; import com.hnac.hzims.bigmodel.interactive.service.impl.ParamStrategy; import com.hnac.hzims.bigmodel.interactive.vo.*; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; +import com.hnac.hzims.bigmodel.websocket.constants.RedisKeyConstants; import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.SpringUtil; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.web.socket.CloseStatus; import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.WebSocketSession; @@ -23,6 +25,7 @@ import org.springframework.web.socket.handler.TextWebSocketHandler; import java.io.IOException; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.TimeUnit; import java.util.function.Function; /** @@ -64,6 +67,12 @@ public class InteractiveHandler extends TextWebSocketHandler { } }else { String sessionId = InteractiveSessionManager.getEntryBySession(session).getKey(); + if(Func.isNotEmpty(messageJSON.containsKey("content"))) { + // 将发送参数存入redis + RedisTemplate redisTemplate = SpringUtil.getBean(RedisTemplate.class); + redisTemplate.expire(RedisKeyConstants.SESSION_CONTENT_KEY,30, TimeUnit.MINUTES); + redisTemplate.opsForHash().put(RedisKeyConstants.SESSION_CONTENT_KEY,sessionId,messageJSON.getObject("content", SessionContentVO.class)); + } this.handleMessage(messageJSON,sessionId); } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java index 3639cb9..f69936d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java @@ -354,4 +354,10 @@ public class StationVideoTypeController extends BladeController { return R.data(false); } + @GetMapping ("/getVideoByPointCodes") + @ApiOperationSupport(order = 190) + @ApiOperation(value = "通过视频编号获取视频") + public R> getVideoByPointCodes(@RequestParam @ApiParam("视频设备编号") String pointCodes) { + return R.data(stationVideoTypeService.getVideoByPointCodes(pointCodes)); + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java index f008b57..bd5a5b1 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java @@ -10,6 +10,7 @@ import com.hnac.hzims.operational.station.response.HikMonitorResp; import com.hnac.hzims.operational.station.vo.HikVideoAreaTreeVO; import com.hnac.hzims.operational.station.vo.StationVideoTypeVO; import com.hnac.hzims.operational.station.vo.VideoMonitorVO; +import io.swagger.annotations.ApiParam; import org.apache.ibatis.annotations.Param; import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.support.Query; @@ -83,4 +84,6 @@ public interface IStationVideoTypeService extends BaseService getVideoByPointCodes(String pointCodes); + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java index 7976d98..aa58a0f 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java @@ -690,6 +690,14 @@ public class StationServiceImpl extends BaseServiceImpl wq = Wrappers.lambdaQuery().eq(StationEntity::getCode, entity.getCode()); + List stations = this.getBaseMapper().listWithOutAuth(wq); + Assert.isTrue(CollectionUtil.isEmpty(stations),() -> { + throw new ServiceException("站点编号平台已存在,请检查后重新填入!"); + }); + } Integer maxSort = this.baseMapper.getMaxSort(); entity.setSort(Optional.ofNullable(maxSort).map(sort -> sort + 1).orElse(1)); // 创建站点机构 diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java index 94e544a..671e71f 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java @@ -279,6 +279,14 @@ public class StationVideoTypeServiceImpl extends BaseServiceImpl getVideoByPointCodes(String pointCodes) { + List pointCodeList = Func.toStrList(",", pointCodes); + LambdaQueryWrapper qw = Wrappers.lambdaQuery().in(StationVideoTypeEntity::getPointCode, pointCodeList); + List videoList = this.list(qw); + return videoList; + } + private HikVideoAreaTreeVO generateAreaTree(Map> videoAreaMapByParent,HikVideoAreaVO area) { HikVideoAreaTreeVO parentTree = BeanUtil.copy(area,HikVideoAreaTreeVO.class); if(CollectionUtil.isNotEmpty(videoAreaMapByParent.get(area.getIndexCode()))) { diff --git a/hzims-service/pom.xml b/hzims-service/pom.xml index 8c59a54..8812762 100644 --- a/hzims-service/pom.xml +++ b/hzims-service/pom.xml @@ -29,7 +29,6 @@ hzims-alarm hzims-basic hzims-big-model - suichang hzims-simulate diff --git a/pom.xml b/pom.xml index 47b1aaa..e3c6ea9 100644 --- a/pom.xml +++ b/pom.xml @@ -77,7 +77,7 @@ com.hnac.hzinfo.data hzinfo-data-sdk - 5.1.1.RELEASE.fix.4 + 5.1.1.RELEASE.fix.5 com.xuxueli