diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/constants/HikApiConstants.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/constants/HikApiConstants.java index eeef631..7517885 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/constants/HikApiConstants.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/constants/HikApiConstants.java @@ -9,6 +9,8 @@ public interface HikApiConstants { /**根据区域获取下级编码设备列表**/ String SUB_RESOURCES = "/api/resource/v1/encodeDevice/subResources"; + String GET_DEVICE_SINGLE = "/api/resource/v1/encodeDevice/single/get"; + /**根据区域编号获取下级监控点列表**/ String CAMERAS = "/api/resource/v1/regions/regionIndexCode/cameras"; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IHikVideoService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IHikVideoService.java index 8956ae3..48d874b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IHikVideoService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IHikVideoService.java @@ -1,5 +1,6 @@ package com.hnac.hzims.operational.station.service; +import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.operational.station.vo.HikVideoAreaVO; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -18,6 +19,8 @@ public interface IHikVideoService { List subResources(String regionIndexCode); + JSONObject getDeviceSingle(String resourceIndexCode); + List cameras(String regionIndexCode); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java index e61092a..3c8795f 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java @@ -86,6 +86,18 @@ public class HikVideoServiceImpl implements IHikVideoService { } @Override + public JSONObject getDeviceSingle(String resourceIndexCode) { + init(); + Map path = new HashMap<>(); + path.put("https://", ARTEMIS_PATH + GET_DEVICE_SINGLE); + HashMap body = new HashMap() {{ + put("resourceIndexCode", resourceIndexCode); + }}; + String result = doPostStringArtemis(path, JSON.toJSONString(body)); + return JSONObject.parseObject(result); + } + + @Override public List cameras(String regionIndexCode) { init(); Map path = new HashMap<>(); 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 b50cb95..3d9dc25 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 @@ -40,6 +40,7 @@ import org.springframework.util.Assert; import javax.servlet.http.HttpServletResponse; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -244,8 +245,9 @@ public class StationVideoTypeServiceImpl extends BaseServiceImpl queryWrapper = Wrappers.lambdaQuery().select(StationVideoTypeEntity::getPointCode).eq(StationVideoTypeEntity::getDeptId, refDept); - List pointCodes = this.listObjs(queryWrapper, String::valueOf); + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery().select(StationVideoTypeEntity::getPointCode,StationVideoTypeEntity::getCreateDept).eq(StationVideoTypeEntity::getDeptId, refDept); + List> pointCodeList = this.listMaps(queryWrapper); + List pointCodes = pointCodeList.stream().map(m -> m.get("point_code")).map(String::valueOf).collect(Collectors.toList()); List cameras = hikVideoService.cameras(regionCode); cameras.stream().forEach(camera -> { if(pointCodes.contains(camera.getString("cameraIndexCode"))) { @@ -255,7 +257,13 @@ public class StationVideoTypeServiceImpl extends BaseServiceImpl c.getString("cameraName"))); + List devIndexCodes = cameras.stream().map(obj -> obj.get("encodeDevIndexCode")).map(String::valueOf).distinct().collect(Collectors.toList()); + Map deviceMap = new HashMap<>(); + devIndexCodes.forEach(devIndexCode -> { + String deviceName = Optional.ofNullable(hikVideoService.getDeviceSingle(devIndexCode)).map(o -> o.getString("name")).orElse(null); + deviceMap.put(devIndexCode,deviceName); + }); + return cameras.stream().collect(Collectors.groupingBy(c -> deviceMap.get(c.getString("encodeDevIndexCode")))); } private HikVideoAreaTreeVO generateAreaTree(Map> videoAreaMapByParent,HikVideoAreaVO area) {