添加hiking服务远程调用接口 修改当前datacenter为调用远程服务
This commit is contained in:
parent
4f0d793cd4
commit
c1b453b487
@ -12,6 +12,7 @@ import cn.iocoder.yudao.module.datacenter.service.region.RegionService;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -31,8 +32,9 @@ public class CameraApi {
|
||||
@Resource
|
||||
private CameraService cameraService;
|
||||
|
||||
@Resource
|
||||
private RegionService regionService;
|
||||
@Autowired
|
||||
private CameraClientApi cameraClientApi;
|
||||
|
||||
|
||||
@GetMapping("/selectCameraByPageAndCondition")
|
||||
@Operation(summary = "分页条件查询监控点信息")
|
||||
@ -58,53 +60,53 @@ public class CameraApi {
|
||||
return result;
|
||||
}
|
||||
|
||||
@GetMapping("/selectPreviewUrlByCameraIndexCode")
|
||||
@Operation(summary = "获取监控点预览流URL")
|
||||
public Map<String, Object> selectPreviewUrlByCameraIndexCode(String cameraIndexCode, Integer streamType, String protocol, Integer transmode, String expand, String streamform) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
String previewUrl = cameraService.getPreviewUrl(cameraIndexCode, streamType, protocol, transmode, expand, streamform);
|
||||
result.put("previewUrl", previewUrl);
|
||||
// result.put("previewUrl", "");
|
||||
// result.put("传入的参数", "cameraIndexCode:" + cameraIndexCode + " streamType:" + streamType + " protocol:" + protocol + " transmode:" + transmode + " expand:" + expand + " streamform:" + streamform);
|
||||
// result.put("status", "success");
|
||||
return result;
|
||||
}
|
||||
|
||||
@GetMapping("/selectPlayBackUrlByCameraIndexCode")
|
||||
@Operation(summary = "获取监控点回放流URL")
|
||||
public Map<String, Object> selectPlayBackUrlByCameraIndexCode(String cameraIndexCode, Integer recordLocation, String protocol, Integer transmode, String beginTime, String endTime, String uuid, String expand, String streamform, Integer lockType) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
String playBack = cameraService.getPlayBackUrl(cameraIndexCode,recordLocation, protocol, transmode, beginTime, endTime, uuid, expand, streamform,lockType);
|
||||
result.put("previewUrl", playBack);
|
||||
// result.put("playBackUrl", "");
|
||||
// result.put("传入的参数", "cameraIndexCode:" + cameraIndexCode + " recordLocation:" + recordLocation + " protocol:" + protocol + " transmode:" + transmode + " beginTime:" + beginTime + " endTime:" + endTime + " uuid:" + uuid + " expand:" + expand + " streamform:" + streamform + " lockType:" + lockType);
|
||||
// result.put("status", "success");
|
||||
return result;
|
||||
}
|
||||
|
||||
@GetMapping("/selZoom")
|
||||
@Operation(summary = "监控点3D缩放")
|
||||
public Map<String, Object> selZoom(String cameraIndexCode, Integer startX, Integer startY, Integer endX, Integer endY) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
String selZoomResult = cameraService.selZoom(cameraIndexCode, startX, startY, endX, endY);
|
||||
result.put("selZoomResult", selZoomResult);
|
||||
// result.put("selZoomResult", "");
|
||||
result.put("传入的参数", "cameraIndexCode:" + cameraIndexCode + " startX:" + startX + " startY:" + startY + " endX:" + endX + " endY:" + endY);
|
||||
result.put("status", "success");
|
||||
return result;
|
||||
}
|
||||
|
||||
@GetMapping("/controlling")
|
||||
@Operation(summary = "云台控制")
|
||||
public Map<String, Object> controlling(String cameraIndexCode, Integer action, String command, Integer speed, Integer presetIndex) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
String controllingResult = cameraService.controlling(cameraIndexCode,action, command, speed, presetIndex);
|
||||
result.put("selZoomResult", controllingResult);
|
||||
// result.put("controllingResult", "");
|
||||
// result.put("传入的参数", "cameraIndexCode:" + cameraIndexCode + " action:" + action + " command:" + command + " speed:" + speed + " presetIndex:" + presetIndex);
|
||||
// result.put("status", "success");
|
||||
return result;
|
||||
}
|
||||
// @GetMapping("/selectPreviewUrlByCameraIndexCode")
|
||||
// @Operation(summary = "获取监控点预览流URL")
|
||||
// public Map<String, Object> selectPreviewUrlByCameraIndexCode(String cameraIndexCode, Integer streamType, String protocol, Integer transmode, String expand, String streamform) {
|
||||
// Map<String, Object> result = new HashMap<>();
|
||||
// String previewUrl = cameraService.getPreviewUrl(cameraIndexCode, streamType, protocol, transmode, expand, streamform);
|
||||
// result.put("previewUrl", previewUrl);
|
||||
//// result.put("previewUrl", "");
|
||||
//// result.put("传入的参数", "cameraIndexCode:" + cameraIndexCode + " streamType:" + streamType + " protocol:" + protocol + " transmode:" + transmode + " expand:" + expand + " streamform:" + streamform);
|
||||
//// result.put("status", "success");
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/selectPlayBackUrlByCameraIndexCode")
|
||||
// @Operation(summary = "获取监控点回放流URL")
|
||||
// public Map<String, Object> selectPlayBackUrlByCameraIndexCode(String cameraIndexCode, Integer recordLocation, String protocol, Integer transmode, String beginTime, String endTime, String uuid, String expand, String streamform, Integer lockType) {
|
||||
// Map<String, Object> result = new HashMap<>();
|
||||
// String playBack = cameraService.getPlayBackUrl(cameraIndexCode, recordLocation, protocol, transmode, beginTime, endTime, uuid, expand, streamform, lockType);
|
||||
// result.put("previewUrl", playBack);
|
||||
//// result.put("playBackUrl", "");
|
||||
//// result.put("传入的参数", "cameraIndexCode:" + cameraIndexCode + " recordLocation:" + recordLocation + " protocol:" + protocol + " transmode:" + transmode + " beginTime:" + beginTime + " endTime:" + endTime + " uuid:" + uuid + " expand:" + expand + " streamform:" + streamform + " lockType:" + lockType);
|
||||
//// result.put("status", "success");
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/selZoom")
|
||||
// @Operation(summary = "监控点3D缩放")
|
||||
// public Map<String, Object> selZoom(String cameraIndexCode, Integer startX, Integer startY, Integer endX, Integer endY) {
|
||||
// Map<String, Object> result = new HashMap<>();
|
||||
// String selZoomResult = cameraService.selZoom(cameraIndexCode, startX, startY, endX, endY);
|
||||
// result.put("selZoomResult", selZoomResult);
|
||||
//// result.put("selZoomResult", "");
|
||||
//// result.put("传入的参数", "cameraIndexCode:" + cameraIndexCode + " startX:" + startX + " startY:" + startY + " endX:" + endX + " endY:" + endY);
|
||||
//// result.put("status", "success");
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/controlling")
|
||||
// @Operation(summary = "云台控制")
|
||||
// public Map<String, Object> controlling(String cameraIndexCode, Integer action, String command, Integer speed, Integer presetIndex) {
|
||||
// Map<String, Object> result = new HashMap<>();
|
||||
// String controllingResult = cameraService.controlling(cameraIndexCode, action, command, speed, presetIndex);
|
||||
// result.put("selZoomResult", controllingResult);
|
||||
//// result.put("controllingResult", "");
|
||||
//// result.put("传入的参数", "cameraIndexCode:" + cameraIndexCode + " action:" + action + " command:" + command + " speed:" + speed + " presetIndex:" + presetIndex);
|
||||
//// result.put("status", "success");
|
||||
// return result;
|
||||
// }
|
||||
|
||||
@GetMapping("/selectCameraByRegionIndexCode")
|
||||
@Operation(summary = "根据区域编码获取监控点信息")
|
||||
@ -127,4 +129,43 @@ public class CameraApi {
|
||||
result.put("cameraIndexCode", cameraIndexCode);
|
||||
return result;
|
||||
}
|
||||
|
||||
// =================远程调用版本===============
|
||||
@GetMapping("/selectPreviewUrlByCameraIndexCode")
|
||||
@Operation(summary = "获取监控点预览流URL")
|
||||
public CommonResult<String> selectPreviewUrlByCameraIndexCodeRPC(String cameraIndexCode, Integer streamType, String protocol, Integer transmode, String expand, String streamform) {
|
||||
// Map<String, Object> result = new HashMap<>();
|
||||
// result.put("previewUrl", "");
|
||||
// result.put("传入的参数", "cameraIndexCode:" + cameraIndexCode + " streamType:" + streamType + " protocol:" + protocol + " transmode:" + transmode + " expand:" + expand + " streamform:" + streamform);
|
||||
// result.put("status", "success");
|
||||
return cameraService.getPreviewUrlRPC(cameraIndexCode, streamType, protocol, transmode, expand, streamform);
|
||||
}
|
||||
|
||||
@GetMapping("/selectPlayBackUrlByCameraIndexCode")
|
||||
@Operation(summary = "获取监控点回放流URL")
|
||||
public CommonResult<String> selectPlayBackUrlByCameraIndexCodeRPC(String cameraIndexCode, Integer recordLocation, String protocol, Integer transmode, String beginTime, String endTime, String uuid, String expand, String streamform, Integer lockType) {
|
||||
// Map<String, Object> result = new HashMap<>();
|
||||
// result.put("previewUrl", playBack);
|
||||
// result.put("playBackUrl", "");
|
||||
// result.put("传入的参数", "cameraIndexCode:" + cameraIndexCode + " recordLocation:" + recordLocation + " protocol:" + protocol + " transmode:" + transmode + " beginTime:" + beginTime + " endTime:" + endTime + " uuid:" + uuid + " expand:" + expand + " streamform:" + streamform + " lockType:" + lockType);
|
||||
// result.put("status", "success");
|
||||
return cameraService.getPlayBackUrlRPC(cameraIndexCode, recordLocation, protocol, transmode, beginTime, endTime, uuid, expand, streamform, lockType);
|
||||
}
|
||||
|
||||
@GetMapping("/selZoom")
|
||||
@Operation(summary = "监控点3D缩放")
|
||||
public CommonResult<String> selZoomRPC(String cameraIndexCode, Integer startX, Integer startY, Integer endX, Integer endY) {
|
||||
// Map<String, Object> result = new HashMap<>();
|
||||
// result.put("selZoomResult", selZoomResult);
|
||||
// result.put("selZoomResult", "");
|
||||
// result.put("传入的参数", "cameraIndexCode:" + cameraIndexCode + " startX:" + startX + " startY:" + startY + " endX:" + endX + " endY:" + endY);
|
||||
// result.put("status", "success");
|
||||
return cameraService.selZoomRPC(cameraIndexCode, startX, startY, endX, endY);
|
||||
}
|
||||
|
||||
@GetMapping("/controlling")
|
||||
@Operation(summary = "云台控制")
|
||||
public CommonResult<String> controllingRPC(String cameraIndexCode, Integer action, String command, Integer speed, Integer presetIndex) {
|
||||
return cameraService.controllingRPC(cameraIndexCode, action, command, speed, presetIndex);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,49 @@
|
||||
package cn.iocoder.yudao.module.datacenter.controller.app.camera;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.camera.vo.CameraDO;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.camera.vo.CameraDTO;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.camera.vo.CameraPageReqVO;
|
||||
import cn.iocoder.yudao.module.datacenter.service.camera.CameraService;
|
||||
import cn.iocoder.yudao.module.datacenter.service.region.RegionService;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@FeignClient("hiking-server")
|
||||
public interface CameraClientApi {
|
||||
@GetMapping("/rpc-api/hiking/camera/selectPreviewUrlByCameraIndexCode")
|
||||
@Operation(summary = "获取监控点预览流URL")
|
||||
CommonResult<String> selectPreviewUrlByCameraIndexCode(@RequestParam("cameraIndexCode") String cameraIndexCode, @RequestParam("streamType") Integer streamType,
|
||||
@RequestParam("protocol") String protocol, @RequestParam("transmode") Integer transmode,
|
||||
@RequestParam("expand") String expand, @RequestParam("streamform") String streamform);
|
||||
|
||||
@GetMapping("/rpc-api/hiking/camera/selectPlayBackUrlByCameraIndexCode")
|
||||
@Operation(summary = "获取监控点回放流URL")
|
||||
CommonResult<String> selectPlayBackUrlByCameraIndexCode(@RequestParam("cameraIndexCode") String cameraIndexCode, @RequestParam("recordLocation") Integer recordLocation,
|
||||
@RequestParam("protocol") String protocol, @RequestParam("transmode") Integer transmode,
|
||||
@RequestParam("beginTime") String beginTime, @RequestParam("endTime") String endTime,
|
||||
@RequestParam("uuid") String uuid, @RequestParam("expand") String expand,
|
||||
@RequestParam("streamform") String streamform ,@RequestParam("lockType") Integer lockType);
|
||||
|
||||
@GetMapping("/rpc-api/hiking/camera/selZoom")
|
||||
@Operation(summary = "监控点3D缩放")
|
||||
CommonResult<String> selZoom(@RequestParam("cameraIndexCode") String cameraIndexCode,
|
||||
@RequestParam("startX") Integer startX, @RequestParam("startY") Integer startY,
|
||||
@RequestParam("endX") Integer endX, @RequestParam("endY") Integer endY);
|
||||
@GetMapping("/rpc-api/hiking/camera/controlling")
|
||||
@Operation(summary = "云台控制")
|
||||
CommonResult<String> controlling(@RequestParam("cameraIndexCode") String cameraIndexCode, @RequestParam("action") Integer action,
|
||||
@RequestParam("command") String command, @RequestParam("speed") Integer speed,
|
||||
@RequestParam("presetIndex") Integer presetIndex);
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.datacenter.controller.app.region;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.camera.vo.CameraDTO;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.camera.vo.RegionCameraListDTO;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.region.vo.RegionDTO;
|
||||
@ -25,7 +26,7 @@ public class RegionApi {
|
||||
|
||||
@GetMapping("/list")
|
||||
@DS("hiking")
|
||||
public List<RegionCameraListDTO> list() {
|
||||
return regionService.getRegionList();
|
||||
public CommonResult<List<RegionCameraListDTO>> list(Integer pageNum, Integer pageSize) {
|
||||
return regionService.getRegionList(pageNum, pageSize);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
package cn.iocoder.yudao.module.datacenter.controller.app.region;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.camera.vo.RegionCameraListDTO;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient("hiking-server")
|
||||
public interface RegionClientApi {
|
||||
@GetMapping("/rpc-api/hiking/region/list/testFeign")
|
||||
CommonResult<List<RegionCameraListDTO>> list(@RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize);
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.datacenter.service.camera;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.camera.vo.CameraDO;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.camera.vo.CameraDTO;
|
||||
@ -8,6 +9,7 @@ import cn.iocoder.yudao.module.datacenter.controller.app.camera.vo.CameraSaveReq
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 资源 Service 接口
|
||||
@ -55,10 +57,15 @@ public interface CameraService {
|
||||
PageResult<CameraDO> getCameraPage(CameraPageReqVO pageReqVO);
|
||||
|
||||
String getPreviewUrl(String cameraIndexCode, Integer streamType, String protocol, Integer transmode, String expand, String streamform);
|
||||
CommonResult<String> getPreviewUrlRPC(String cameraIndexCode, Integer streamType, String protocol, Integer transmode, String expand, String streamform);
|
||||
|
||||
String getPlayBackUrl(String cameraIndexCode, Integer recordLocation, String protocol, Integer transmode, String beginTime, String endTime, String uuid, String expand, String streamform, Integer lockType);
|
||||
CommonResult<String> getPlayBackUrlRPC(String cameraIndexCode, Integer recordLocation, String protocol, Integer transmode, String beginTime, String endTime, String uuid, String expand, String streamform, Integer lockType);
|
||||
|
||||
String selZoom(String cameraIndexCode,int startX,int startY,int endX,int endY);
|
||||
CommonResult<String> selZoomRPC(String cameraIndexCode,int startX,int startY,int endX,int endY);
|
||||
String controlling(String cameraIndexCode, Integer action, String command, Integer speed, Integer presetIndex);
|
||||
CommonResult<String> controllingRPC(String cameraIndexCode, Integer action, String command, Integer speed, Integer presetIndex);
|
||||
|
||||
List<CameraDTO> selectCameraByRegionIndexCode(String regionIndexCode);
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.datacenter.service.region;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.camera.vo.RegionCameraListDTO;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.region.vo.RegionDO;
|
||||
@ -54,7 +55,7 @@ public interface RegionService {
|
||||
* @return 区域分页
|
||||
*/
|
||||
PageResult<RegionDO> getRegionPage(RegionPageReqVO pageReqVO);
|
||||
List<RegionCameraListDTO> getRegionList();
|
||||
CommonResult<List<RegionCameraListDTO>> getRegionList(Integer pageNum, Integer pageSize);
|
||||
RegionDO selectByIndexCode(String indexCode);
|
||||
RegionDO selectByRegionName(String regionName);
|
||||
}
|
@ -1,16 +1,19 @@
|
||||
package cn.iocoder.yudao.module.datacenter.service.region;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.camera.vo.CameraDTO;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.camera.vo.RegionCameraListDTO;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.region.RegionClientApi;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.region.vo.RegionDO;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.region.vo.RegionDTO;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.region.vo.RegionPageReqVO;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.region.vo.RegionSaveReqVO;
|
||||
import cn.iocoder.yudao.module.datacenter.dal.mysql.camera.CameraMapper;
|
||||
import cn.iocoder.yudao.module.datacenter.dal.mysql.region.RegionMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@ -36,6 +39,9 @@ public class RegionServiceImpl implements RegionService {
|
||||
@Resource
|
||||
private CameraMapper cameraMapper;
|
||||
|
||||
@Autowired
|
||||
private RegionClientApi regionClientApi;
|
||||
|
||||
@Override
|
||||
public Long createRegion(RegionSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
@ -79,52 +85,59 @@ public class RegionServiceImpl implements RegionService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RegionCameraListDTO> getRegionList() {
|
||||
List<RegionDO> regionDOListResult = regionMapper.selectList();
|
||||
List<RegionCameraListDTO> regions = new ArrayList<>();
|
||||
Map<String, RegionCameraListDTO> regionMap = new HashMap<>();
|
||||
for (RegionDO regionDO : regionDOListResult) {
|
||||
RegionCameraListDTO temp = new RegionCameraListDTO();
|
||||
temp.setRegionIndexCode(regionDO.getIndexCode());
|
||||
temp.setRegionName(regionDO.getName());
|
||||
temp.setParentIndexCode(regionDO.getParentIndexCode());
|
||||
temp.setLeaf(regionDO.getLeaf());
|
||||
System.out.println("regionDO.getLeaf(): " + regionDO.getLeaf() + " temp.getLeaf(): " + temp.getLeaf());
|
||||
if(temp.getLeaf() == 1) {
|
||||
cameraMapper.selectCameraByRegionIndexCode(temp.getRegionIndexCode()).forEach(cameraDO -> {
|
||||
temp.getCameraList().add(BeanUtils.toBean(cameraDO, CameraDTO.class));
|
||||
});
|
||||
}
|
||||
regions.add(temp);
|
||||
regionMap.put(regionDO.getIndexCode(), temp);
|
||||
}
|
||||
|
||||
System.out.println("regionMap:"+regionMap);
|
||||
|
||||
// 用于存储已经添加到 parent 的子区域,避免重复添加
|
||||
Set<RegionCameraListDTO> addedChildren = new HashSet<>();
|
||||
|
||||
for (RegionCameraListDTO regionDTO : regions) {
|
||||
if(regionDTO.getParentIndexCode() != null && !"-1".equals(regionDTO.getParentIndexCode())) {
|
||||
System.out.println("regionchild:"+regionDTO);
|
||||
RegionCameraListDTO parentRegion = regionMap.get(regionDTO.getParentIndexCode());
|
||||
if (parentRegion != null) {
|
||||
parentRegion.getChildren().add(regionDTO);
|
||||
addedChildren.add(regionDTO); // 记录该子节点已经被添加到父区域
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<RegionCameraListDTO> result = new ArrayList<>();
|
||||
for (RegionCameraListDTO region : regions) {
|
||||
// 只保留根节点
|
||||
if ("-1".equals(region.getParentIndexCode())) {
|
||||
result.add(buildTree(region, regionMap));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
public CommonResult<List<RegionCameraListDTO>> getRegionList(Integer pageNum, Integer pageSize) {
|
||||
System.out.println("调用hiking--server的接口");
|
||||
return regionClientApi.list(pageNum, pageSize);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public List<RegionCameraListDTO> getRegionList(Integer pageNum, Integer pageSize) {
|
||||
// Integer start = (pageNum - 1) * pageSize;
|
||||
// List<RegionDO> regionDOListResult = regionMapper.selectList();
|
||||
// List<RegionCameraListDTO> regions = new ArrayList<>();
|
||||
// Map<String, RegionCameraListDTO> regionMap = new HashMap<>();
|
||||
// for (RegionDO regionDO : regionDOListResult) {
|
||||
// RegionCameraListDTO temp = new RegionCameraListDTO();
|
||||
// temp.setRegionIndexCode(regionDO.getIndexCode());
|
||||
// temp.setRegionName(regionDO.getName());
|
||||
// temp.setParentIndexCode(regionDO.getParentIndexCode());
|
||||
// temp.setLeaf(regionDO.getLeaf());
|
||||
// System.out.println("regionDO.getLeaf(): " + regionDO.getLeaf() + " temp.getLeaf(): " + temp.getLeaf());
|
||||
// if(temp.getLeaf() == 1) {
|
||||
// cameraMapper.selectCameraByRegionIndexCodePage(temp.getRegionIndexCode(), start, pageSize).forEach(cameraDO -> {
|
||||
// temp.getCameraList().add(BeanUtils.toBean(cameraDO, CameraDTO.class));
|
||||
// });
|
||||
// }
|
||||
// regions.add(temp);
|
||||
// regionMap.put(regionDO.getIndexCode(), temp);
|
||||
// }
|
||||
//
|
||||
// System.out.println("regionMap:"+regionMap);
|
||||
//
|
||||
// // 用于存储已经添加到 parent 的子区域,避免重复添加
|
||||
// Set<RegionCameraListDTO> addedChildren = new HashSet<>();
|
||||
//
|
||||
// for (RegionCameraListDTO regionDTO : regions) {
|
||||
// if(regionDTO.getParentIndexCode() != null && !"-1".equals(regionDTO.getParentIndexCode())) {
|
||||
// System.out.println("regionchild:"+regionDTO);
|
||||
// RegionCameraListDTO parentRegion = regionMap.get(regionDTO.getParentIndexCode());
|
||||
// if (parentRegion != null) {
|
||||
// parentRegion.getChildren().add(regionDTO);
|
||||
// addedChildren.add(regionDTO); // 记录该子节点已经被添加到父区域
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// List<RegionCameraListDTO> result = new ArrayList<>();
|
||||
// for (RegionCameraListDTO region : regions) {
|
||||
// // 只保留根节点
|
||||
// if ("-1".equals(region.getParentIndexCode())) {
|
||||
// result.add(buildTree(region, regionMap));
|
||||
// }
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
|
||||
private RegionCameraListDTO buildTree(RegionCameraListDTO region, Map<String, RegionCameraListDTO> regionMap) {
|
||||
// 递归子节点
|
||||
for (RegionCameraListDTO child : region.getChildren()) {
|
||||
|
@ -30,4 +30,12 @@ public interface CameraApi {
|
||||
@GetMapping(PREFIX + "/selectPlayBackUrlByCameraIndexCode")
|
||||
@Operation(summary = "获取监控点回放流URL")
|
||||
public CommonResult<String> selectPlayBackUrlByCameraIndexCode(@RequestParam String cameraIndexCode, Integer recordLocation, String protocol, Integer transmode, String beginTime, String endTime, String uuid, String expand, String streamform, Integer lockType);
|
||||
|
||||
@GetMapping(PREFIX + "/selZoom")
|
||||
@Operation(summary = "监控点3D缩放")
|
||||
CommonResult<String> selZoom(String cameraIndexCode, Integer startX, Integer startY, Integer endX, Integer endY);
|
||||
@GetMapping(PREFIX + "/controlling")
|
||||
@Operation(summary = "云台控制")
|
||||
CommonResult<String> controlling(String cameraIndexCode, Integer action, String command, Integer speed, Integer presetIndex);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package cn.iocoder.yudao.module.hiking.api.region;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.hiking.api.region.dto.RegionCameraListDTO;
|
||||
import cn.iocoder.yudao.module.hiking.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME)
|
||||
@Tag(name = "区域")
|
||||
public interface RegionApi {
|
||||
String PREFIX = ApiConstants.PREFIX + "/region";
|
||||
@GetMapping(PREFIX + "/list/testFeign")
|
||||
@Operation(summary = "获取区域树状列表")
|
||||
CommonResult<List<RegionCameraListDTO>> getRegionCameraList(@RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize);
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package cn.iocoder.yudao.module.hiking.api.region.dto;
|
||||
|
||||
import cn.iocoder.yudao.module.hiking.api.camera.dto.CameraDTO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "区域 Response DTO")
|
||||
@Data
|
||||
public class RegionCameraListDTO {
|
||||
@Schema(description = "区域唯一编码")
|
||||
private String regionIndexCode;
|
||||
@Schema(description = "区域名称")
|
||||
private String regionName;
|
||||
@Schema(description = "父区域唯一编码")
|
||||
private String parentIndexCode;
|
||||
@Schema(description = "是否为叶子节点")
|
||||
private Integer leaf;
|
||||
@Schema(description = "子区域")
|
||||
private List<RegionCameraListDTO> children = new ArrayList<>();
|
||||
@Schema(description = "摄像头列表")
|
||||
private List<CameraDTO> cameraList = new ArrayList<>();
|
||||
}
|
@ -2,11 +2,9 @@ package cn.iocoder.yudao.module.hiking.api;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.hiking.IntegrationURL;
|
||||
import cn.iocoder.yudao.module.hiking.api.camera.CameraApi;
|
||||
import cn.iocoder.yudao.module.hiking.api.camera.dto.CameraDTO;
|
||||
import cn.iocoder.yudao.module.hiking.controller.admin.camera.vo.CameraPageReqVO;
|
||||
import cn.iocoder.yudao.module.hiking.dal.dataobject.camera.CameraConvert;
|
||||
import cn.iocoder.yudao.module.hiking.dal.dataobject.camera.CameraDO;
|
||||
import cn.iocoder.yudao.module.hiking.service.camera.CameraService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -15,12 +13,13 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
||||
@Validated
|
||||
public class HikingCameraApiImpl implements CameraApi {
|
||||
public class CameraApiImpl implements CameraApi {
|
||||
@Resource
|
||||
private CameraService cameraService;
|
||||
|
||||
@ -51,4 +50,14 @@ public class HikingCameraApiImpl implements CameraApi {
|
||||
public CommonResult<String> selectPlayBackUrlByCameraIndexCode(String cameraIndexCode, Integer recordLocation, String protocol, Integer transmode, String beginTime, String endTime, String uuid, String expand, String streamform, Integer lockType) {
|
||||
return success(cameraService.getPlayBackUrl(cameraIndexCode, recordLocation,protocol,transmode,beginTime,endTime, uuid, expand, streamform, lockType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<String> selZoom(String cameraIndexCode, Integer startX, Integer startY, Integer endX, Integer endY) {
|
||||
return success(cameraService.selZoom(cameraIndexCode, startX, startY, endX, endY));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<String> controlling(String cameraIndexCode, Integer action, String command, Integer speed, Integer presetIndex) {
|
||||
return success(cameraService.controlling(cameraIndexCode, action, command, speed, presetIndex));
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package cn.iocoder.yudao.module.hiking.api;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.hiking.api.region.RegionApi;
|
||||
import cn.iocoder.yudao.module.hiking.api.region.dto.RegionCameraListDTO;
|
||||
import cn.iocoder.yudao.module.hiking.service.region.RegionService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
||||
@Validated
|
||||
public class RegionApiImpl implements RegionApi {
|
||||
@Resource
|
||||
private RegionService regionService;
|
||||
|
||||
@Override
|
||||
public CommonResult<List<RegionCameraListDTO>> getRegionCameraList(Integer pageNum, Integer pageSize) {
|
||||
System.out.println("收到打datacenter的请求");
|
||||
return regionService.getRegionList(pageNum, pageSize);
|
||||
}
|
||||
}
|
@ -39,4 +39,8 @@ public interface CameraMapper extends BaseMapperX<CameraDO> {
|
||||
default int updateByCameraIndexCode(CameraDO updateObj) {
|
||||
return update(updateObj, new LambdaQueryWrapperX<CameraDO>().eq(CameraDO::getCameraIndexCode, updateObj.getCameraIndexCode()));
|
||||
}
|
||||
|
||||
default List<CameraDO> selectCameraByRegionIndexCodePage(String regionIndexCode, Integer start, Integer end) {
|
||||
return selectList(new LambdaQueryWrapperX<CameraDO>().eq(CameraDO::getRegionIndexCode, regionIndexCode).last("limit " + start + "," + end));
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package cn.iocoder.yudao.module.hiking.service.camera;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.module.hiking.api.camera.dto.CameraDTO;
|
||||
import cn.iocoder.yudao.module.hiking.controller.admin.camera.vo.*;
|
||||
import cn.iocoder.yudao.module.hiking.dal.dataobject.camera.CameraDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
@ -58,6 +60,8 @@ public interface CameraService {
|
||||
String getPreviewUrl(String cameraIndexCode, Integer streamType, String protocol, Integer transmode, String expand, String streamform);
|
||||
String getPlayBackUrl(String cameraIndexCode, Integer recordLocation, String protocol, Integer transmode, String beginTime, String endTime, String uuid, String expand, String streamform, Integer lockType);
|
||||
|
||||
String selZoom(String cameraIndexCode,int startX,int startY,int endX,int endY);
|
||||
String controlling(String cameraIndexCode, Integer action, String command, Integer speed, Integer presetIndex);
|
||||
void updateCameraCheckByCameraIndexCode(@Valid CameraSaveReqVO cameraSaveReqVO);
|
||||
|
||||
}
|
@ -1,10 +1,12 @@
|
||||
package cn.iocoder.yudao.module.hiking.service.region;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.hiking.api.region.dto.RegionCameraListDTO;
|
||||
import cn.iocoder.yudao.module.hiking.controller.admin.region.vo.*;
|
||||
import cn.iocoder.yudao.module.hiking.dal.dataobject.region.RegionDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
@ -56,4 +58,5 @@ public interface RegionService {
|
||||
RegionDO selectByRegionName(String regionName);
|
||||
|
||||
public void updateRegionCheckByCameraIndexCode(RegionSaveReqVO updateReqVO);
|
||||
CommonResult<List<RegionCameraListDTO>> getRegionList(Integer pageNum, Integer pageSize);
|
||||
}
|
@ -1,16 +1,16 @@
|
||||
package cn.iocoder.yudao.module.hiking.service.region;
|
||||
|
||||
import cn.iocoder.yudao.module.hiking.controller.admin.camera.vo.CameraSaveReqVO;
|
||||
import cn.iocoder.yudao.module.hiking.dal.dataobject.camera.CameraDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.hiking.api.camera.dto.CameraDTO;
|
||||
import cn.iocoder.yudao.module.hiking.api.region.dto.RegionCameraListDTO;
|
||||
import cn.iocoder.yudao.module.hiking.dal.mysql.camera.CameraMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.hiking.controller.admin.region.vo.*;
|
||||
import cn.iocoder.yudao.module.hiking.dal.dataobject.region.RegionDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.hiking.dal.mysql.region.RegionMapper;
|
||||
@ -32,6 +32,9 @@ public class RegionServiceImpl implements RegionService {
|
||||
@Resource
|
||||
private RegionMapper regionMapper;
|
||||
|
||||
@Resource
|
||||
private CameraMapper cameraMapper;
|
||||
|
||||
@Override
|
||||
public Long createRegion(RegionSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
@ -98,4 +101,70 @@ public class RegionServiceImpl implements RegionService {
|
||||
RegionDO updateObj = BeanUtils.toBean(updateReqVO, RegionDO.class);
|
||||
regionMapper.updateByRegionIndexCode(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<List<RegionCameraListDTO>> getRegionList(Integer pageNum, Integer pageSize) {
|
||||
Integer start = (pageNum - 1) * pageSize;
|
||||
List<RegionDO> regionDOListResult = regionMapper.selectList();
|
||||
List<RegionCameraListDTO> regions = new ArrayList<>();
|
||||
Map<String, RegionCameraListDTO> regionMap = new HashMap<>();
|
||||
for (RegionDO regionDO : regionDOListResult) {
|
||||
RegionCameraListDTO temp = new RegionCameraListDTO();
|
||||
temp.setRegionIndexCode(regionDO.getIndexCode());
|
||||
temp.setRegionName(regionDO.getName());
|
||||
temp.setParentIndexCode(regionDO.getParentIndexCode());
|
||||
temp.setLeaf(regionDO.getLeaf());
|
||||
System.out.println("regionDO.getLeaf(): " + regionDO.getLeaf() + " temp.getLeaf(): " + temp.getLeaf());
|
||||
if(temp.getLeaf() == 1) {
|
||||
cameraMapper.selectCameraByRegionIndexCodePage(temp.getRegionIndexCode(), start, pageSize).forEach(cameraDO -> {
|
||||
temp.getCameraList().add(BeanUtils.toBean(cameraDO, CameraDTO.class));
|
||||
});
|
||||
}
|
||||
regions.add(temp);
|
||||
regionMap.put(regionDO.getIndexCode(), temp);
|
||||
}
|
||||
|
||||
System.out.println("regionMap:"+regionMap);
|
||||
|
||||
// 用于存储已经添加到 parent 的子区域,避免重复添加
|
||||
Set<RegionCameraListDTO> addedChildren = new HashSet<>();
|
||||
|
||||
for (RegionCameraListDTO regionDTO : regions) {
|
||||
if(regionDTO.getParentIndexCode() != null && !"-1".equals(regionDTO.getParentIndexCode())) {
|
||||
System.out.println("regionchild:"+regionDTO);
|
||||
RegionCameraListDTO parentRegion = regionMap.get(regionDTO.getParentIndexCode());
|
||||
if (parentRegion != null) {
|
||||
parentRegion.getChildren().add(regionDTO);
|
||||
addedChildren.add(regionDTO); // 记录该子节点已经被添加到父区域
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<RegionCameraListDTO> resultData = new ArrayList<>();
|
||||
for (RegionCameraListDTO region : regions) {
|
||||
// 只保留根节点
|
||||
if ("-1".equals(region.getParentIndexCode())) {
|
||||
resultData.add(buildTree(region, regionMap));
|
||||
}
|
||||
}
|
||||
|
||||
CommonResult<List<RegionCameraListDTO>> result = new CommonResult<>();
|
||||
if(!resultData.isEmpty()) {
|
||||
result.setCode(200);
|
||||
result.setData(resultData);
|
||||
result.setMsg("success");
|
||||
} else {
|
||||
result.setCode(500);
|
||||
result.setMsg("数据查询失败");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private RegionCameraListDTO buildTree(RegionCameraListDTO region, Map<String, RegionCameraListDTO> regionMap) {
|
||||
// 递归子节点
|
||||
for (RegionCameraListDTO child : region.getChildren()) {
|
||||
buildTree(child, regionMap); // 递归构建子树
|
||||
}
|
||||
return region;
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@ import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
|
||||
@ -13,8 +12,9 @@ import cn.iocoder.yudao.module.hiking.dal.dataobject.camera.CameraDO;
|
||||
import cn.iocoder.yudao.module.hiking.dal.mysql.camera.CameraMapper;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@ -115,7 +115,7 @@ public class CameraServiceImplTest extends BaseDbUnitTest {
|
||||
o.setChannelTypeName(null);
|
||||
o.setTransTypeName(null);
|
||||
o.setTreatyTypeName(null);
|
||||
o.setName(null);
|
||||
o.setCameraName(null);
|
||||
o.setInstallLocation(null);
|
||||
o.setCreateTime(null);
|
||||
o.setUpdateTime(null);
|
||||
@ -132,7 +132,7 @@ public class CameraServiceImplTest extends BaseDbUnitTest {
|
||||
// 测试 treatyTypeName 不匹配
|
||||
cameraMapper.insert(cloneIgnoreId(dbCamera, o -> o.setTreatyTypeName(null)));
|
||||
// 测试 name 不匹配
|
||||
cameraMapper.insert(cloneIgnoreId(dbCamera, o -> o.setName(null)));
|
||||
cameraMapper.insert(cloneIgnoreId(dbCamera, o -> o.setCameraName(null)));
|
||||
// 测试 installLocation 不匹配
|
||||
cameraMapper.insert(cloneIgnoreId(dbCamera, o -> o.setInstallLocation(null)));
|
||||
// 测试 createTime 不匹配
|
||||
@ -146,10 +146,10 @@ public class CameraServiceImplTest extends BaseDbUnitTest {
|
||||
reqVO.setChannelTypeName(null);
|
||||
reqVO.setTransTypeName(null);
|
||||
reqVO.setTreatyTypeName(null);
|
||||
reqVO.setName(null);
|
||||
reqVO.setCameraName(null);
|
||||
reqVO.setInstallLocation(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setUpdateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
// reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
// reqVO.setUpdateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
|
||||
// 调用
|
||||
PageResult<CameraDO> pageResult = cameraService.getCameraPage(reqVO);
|
||||
|
Loading…
Reference in New Issue
Block a user