Browse Source

# 视频点位选择优化

zhongwei
haungxing 10 months ago
parent
commit
824b0e8336
  1. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/constants/HikApiConstants.java
  2. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IHikVideoService.java
  3. 12
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java
  4. 14
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java

2
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";

3
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);
}

12
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<String, String> path = new HashMap<>();
path.put("https://", ARTEMIS_PATH + GET_DEVICE_SINGLE);
HashMap<String, Object> body = new HashMap<String, Object>() {{
put("resourceIndexCode", resourceIndexCode);
}};
String result = doPostStringArtemis(path, JSON.toJSONString(body));
return JSONObject.parseObject(result);
}
@Override
public List cameras(String regionIndexCode) {
init();
Map<String, String> path = new HashMap<>();

14
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<StationVideoTyp
@Override
public Map getVideoPointByRegion(Long refDept, String regionCode) {
LambdaQueryWrapper<StationVideoTypeEntity> queryWrapper = Wrappers.<StationVideoTypeEntity>lambdaQuery().select(StationVideoTypeEntity::getPointCode).eq(StationVideoTypeEntity::getDeptId, refDept);
List<String> pointCodes = this.listObjs(queryWrapper, String::valueOf);
LambdaQueryWrapper<StationVideoTypeEntity> queryWrapper = Wrappers.<StationVideoTypeEntity>lambdaQuery().select(StationVideoTypeEntity::getPointCode,StationVideoTypeEntity::getCreateDept).eq(StationVideoTypeEntity::getDeptId, refDept);
List<Map<String, Object>> pointCodeList = this.listMaps(queryWrapper);
List<String> pointCodes = pointCodeList.stream().map(m -> m.get("point_code")).map(String::valueOf).collect(Collectors.toList());
List<JSONObject> cameras = hikVideoService.cameras(regionCode);
cameras.stream().forEach(camera -> {
if(pointCodes.contains(camera.getString("cameraIndexCode"))) {
@ -255,7 +257,13 @@ public class StationVideoTypeServiceImpl extends BaseServiceImpl<StationVideoTyp
camera.put("disabled",false);
}
});
return cameras.stream().collect(Collectors.groupingBy(c -> c.getString("cameraName")));
List<String> devIndexCodes = cameras.stream().map(obj -> obj.get("encodeDevIndexCode")).map(String::valueOf).distinct().collect(Collectors.toList());
Map<String,String> 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<String, List<HikVideoAreaVO>> videoAreaMapByParent,HikVideoAreaVO area) {

Loading…
Cancel
Save