| | |
| | | package com.ruoyi.device.camera.controller; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import com.ruoyi.device.camera.domain.ArdCameras; |
| | | import com.ruoyi.device.camera.domain.CameraCmd; |
| | | import com.ruoyi.device.camera.service.IArdCamerasService; |
| | | import com.ruoyi.device.hiksdk.service.impl.HikClientServiceImpl; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.inspect.service.IArdVideoInspectTaskService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 相机设备Controller |
| | | * |
| | | * @author ruoyi |
| | | * @date 2023-01-31 |
| | | */ |
| | | @Slf4j(topic = "hikSdk") |
| | | @RestController |
| | | @RequestMapping("/device/cameras") |
| | | @Api(tags = "相机管理接口") |
| | | public class ArdCamerasController extends BaseController { |
| | | @Resource |
| | | private HikClientServiceImpl sdk; |
| | | @Resource |
| | | private IArdCamerasService ardCamerasService; |
| | | @Resource |
| | | private IArdVideoInspectTaskService ardVideoInspectTaskService; |
| | | |
| | | /** |
| | | * 查询相机设备列表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('device:cameras:list')") |
| | | @GetMapping("/list") |
| | | @ApiOperation("查询相机设备列表") |
| | | public TableDataInfo list(ArdCameras ardCamera) { |
| | | startPage(); |
| | | List<ArdCameras> list = ardCamerasService.selectArdCamerasList(ardCamera); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | /** |
| | | * 导出相机设备列表 |
| | | */ |
| | | @ApiOperation("导出相机设备列表") |
| | | @PreAuthorize("@ss.hasPermi('device:cameras:export')") |
| | | @Log(title = "相机设备", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, ArdCameras ardCamera) { |
| | | List<ArdCameras> list = ardCamerasService.selectArdCamerasList(ardCamera); |
| | | ExcelUtil<ArdCameras> util = new ExcelUtil<>(ArdCameras.class); |
| | | util.exportExcel(response, list, "相机设备数据"); |
| | | } |
| | | |
| | | /** |
| | | * 获取相机设备详细信息 |
| | | */ |
| | | @ApiOperation("获取相机设备详细信息") |
| | | @PreAuthorize("@ss.hasPermi('device:cameras:query')") |
| | | @GetMapping(value = "/{id}") |
| | | public AjaxResult getInfo(@PathVariable("id") String id) { |
| | | return success(ardCamerasService.selectArdCamerasById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 新增相机设备 |
| | | */ |
| | | @ApiOperation("新增相机设备") |
| | | @PreAuthorize("@ss.hasPermi('device:cameras:add')") |
| | | @Log(title = "相机设备", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody ArdCameras camera) { |
| | | //注销 |
| | | sdk.loginOut(camera.getId()); |
| | | //登录 |
| | | sdk.login(camera); |
| | | return toAjax(ardCamerasService.insertArdCameras(camera)); |
| | | } |
| | | |
| | | /** |
| | | * 修改相机设备 |
| | | */ |
| | | @ApiOperation("修改相机设备") |
| | | @PreAuthorize("@ss.hasPermi('device:cameras:edit')") |
| | | @Log(title = "相机设备", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody ArdCameras camera) { |
| | | int i = ardCamerasService.updateArdCameras(camera); |
| | | if (i > 0) { |
| | | ArdCameras cameras = ardCamerasService.selectArdCamerasById(camera.getId()); |
| | | sdk.loginOut(cameras.getId()); |
| | | sdk.login(cameras); |
| | | } |
| | | return toAjax(i); |
| | | } |
| | | |
| | | /** |
| | | * 删除相机设备 |
| | | */ |
| | | @ApiOperation("删除相机设备") |
| | | @PreAuthorize("@ss.hasPermi('device:cameras:remove')") |
| | | @Log(title = "相机设备", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult remove(@PathVariable String[] ids) { |
| | | for (String id : ids) { |
| | | sdk.loginOut(id); |
| | | } |
| | | return toAjax(ardCamerasService.deleteArdCamerasByIds(ids)); |
| | | } |
| | | |
| | | @GetMapping("/options") |
| | | @ApiOperation("选择相机数据") |
| | | public List options(ArdCameras ardCameras) { |
| | | List<ArdCameras> list = ardCamerasService.findOptions(ardCameras); |
| | | List options = new ArrayList(); |
| | | for (ArdCameras item : list) { |
| | | Map option = new HashMap(); |
| | | option.put("value", item.getId()); |
| | | option.put("label", item.getName()); |
| | | option.put("channel", item.getChannel()); |
| | | List timeList = ardVideoInspectTaskService.getCameraIdleTimeList(item.getId()); |
| | | option.put("idleTimeList", timeList);//空闲时间段 |
| | | options.add(option); |
| | | } |
| | | return options; |
| | | } |
| | | @GetMapping("/getDeptAndCamera") |
| | | @ApiOperation("获取部门和相机") |
| | | public AjaxResult getDeptAndCamera() |
| | | { |
| | | Map deptAndCamera = ardCamerasService.getChildDeptAndCamera(false); |
| | | return AjaxResult.success(deptAndCamera); |
| | | } |
| | | @GetMapping("/getDeptAndCameraWithCheckBox") |
| | | @ApiOperation("获取部门和相机(开启复选框)") |
| | | public AjaxResult getDeptAndCameraWithCheckBox() |
| | | { |
| | | Map deptAndCamera = ardCamerasService.getChildDeptAndCamera(true); |
| | | return AjaxResult.success(deptAndCamera); |
| | | } |
| | | @PostMapping("/getNearCamerasBycoordinate") |
| | | @ApiOperation("获取附近的相机") |
| | | @ApiOperationSupport(includeParameters = {"targetPosition"}) |
| | | public AjaxResult getNearCamerasBycoordinate(@RequestBody CameraCmd cmd) |
| | | { |
| | | TreeMap nearCamerasBycoordinate = ardCamerasService.getNearCamerasBycoordinate(cmd); |
| | | return AjaxResult.success(nearCamerasBycoordinate); |
| | | } |
| | | } |
| | | package com.ruoyi.device.camera.controller;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
| | | import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWell;
|
| | | import com.ruoyi.common.constant.CameraConstants;
|
| | | import com.ruoyi.common.utils.SecurityUtils;
|
| | | import com.ruoyi.device.camera.domain.ArdCameras;
|
| | | import com.ruoyi.device.camera.domain.CameraCmd;
|
| | | import com.ruoyi.device.camera.domain.DeptAndCamerasDto;
|
| | | import com.ruoyi.device.camera.service.IArdCamerasService;
|
| | | import com.ruoyi.device.camera.service.ICameraSdkService;
|
| | | import com.ruoyi.common.utils.poi.ExcelUtil;
|
| | | import com.ruoyi.inspect.service.IArdVideoInspectTaskService;
|
| | | import io.swagger.annotations.Api;
|
| | | import io.swagger.annotations.ApiOperation;
|
| | | import lombok.extern.slf4j.Slf4j;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.PostMapping;
|
| | | import org.springframework.web.bind.annotation.PutMapping;
|
| | | import org.springframework.web.bind.annotation.DeleteMapping;
|
| | | import org.springframework.web.bind.annotation.PathVariable;
|
| | | import org.springframework.web.bind.annotation.RequestBody;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.annotation.Log;
|
| | | import com.ruoyi.common.core.controller.BaseController;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.enums.BusinessType;
|
| | | import com.ruoyi.common.core.page.TableDataInfo;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | |
|
| | | import java.util.*;
|
| | |
|
| | | /**
|
| | | * 相机设备Controller
|
| | | *
|
| | | * @author ruoyi
|
| | | * @date 2023-01-31
|
| | | */
|
| | | @Slf4j(topic = "hikSdk")
|
| | | @RestController
|
| | | @RequestMapping("/device/cameras")
|
| | | @Api(tags = "相机管理接口")
|
| | | public class ArdCamerasController extends BaseController {
|
| | | @Resource
|
| | | private ICameraSdkService cameraSdkService;
|
| | | @Resource
|
| | | private IArdCamerasService ardCamerasService;
|
| | | @Resource
|
| | | private IArdVideoInspectTaskService ardVideoInspectTaskService;
|
| | |
|
| | | /**
|
| | | * 查询相机设备列表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('device:cameras:list')")
|
| | | @GetMapping("/list")
|
| | | @ApiOperation("查询相机设备列表")
|
| | | public TableDataInfo list(ArdCameras ardCamera) {
|
| | | startPage();
|
| | | List<ArdCameras> list = ardCamerasService.selectArdCamerasList(ardCamera);
|
| | | return getDataTable(list);
|
| | | }
|
| | | /**
|
| | | * 查询相机设备列表(不校验权限)
|
| | | */
|
| | | @GetMapping("/list/noPerm")
|
| | | @ApiOperation("查询相机设备列表")
|
| | | public TableDataInfo listNoPerm(ArdCameras ardCamera) {
|
| | | startPage();
|
| | | List<ArdCameras> list = ardCamerasService.selectArdCamerasList(ardCamera);
|
| | | return getDataTable(list);
|
| | | }
|
| | | /**
|
| | | * 导出相机设备列表
|
| | | */
|
| | | @ApiOperation("导出相机设备列表")
|
| | | @PreAuthorize("@ss.hasPermi('device:cameras:export')")
|
| | | @Log(title = "相机设备", businessType = BusinessType.EXPORT)
|
| | | @PostMapping("/export")
|
| | | public void export(HttpServletResponse response, ArdCameras ardCamera) {
|
| | | List<ArdCameras> list = ardCamerasService.selectArdCamerasList(ardCamera);
|
| | | ExcelUtil<ArdCameras> util = new ExcelUtil<>(ArdCameras.class);
|
| | | util.exportExcel(response, list, "相机设备数据");
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取相机设备详细信息
|
| | | */
|
| | | @ApiOperation("获取相机设备详细信息")
|
| | | @PreAuthorize("@ss.hasPermi('device:cameras:query')")
|
| | | @GetMapping(value = "/{id}")
|
| | | public AjaxResult getInfo(@PathVariable("id") String id) {
|
| | | return success(ardCamerasService.selectArdCamerasById(id));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 新增相机设备
|
| | | */
|
| | | @ApiOperation("新增相机设备")
|
| | | @PreAuthorize("@ss.hasPermi('device:cameras:add')")
|
| | | @Log(title = "相机设备", businessType = BusinessType.INSERT)
|
| | | @PostMapping
|
| | | public AjaxResult add(@RequestBody ArdCameras camera) {
|
| | | if (CameraConstants.NOT_UNIQUE.equals(ardCamerasService.checkCameraIpAndPortUnique(camera)))
|
| | | {
|
| | | return error("新增相机'" + camera.getIp()+":"+camera.getPort() + "'失败,相机已存在");
|
| | | }
|
| | | int i = ardCamerasService.insertArdCameras(camera);
|
| | | if (i > 0) {
|
| | | cameraSdkService.logout(camera.getId());
|
| | | cameraSdkService.login(camera);
|
| | | }
|
| | | return toAjax(i);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 修改相机设备
|
| | | */
|
| | | @ApiOperation("修改相机设备")
|
| | | @PreAuthorize("@ss.hasPermi('device:cameras:edit')")
|
| | | @Log(title = "相机设备", businessType = BusinessType.UPDATE)
|
| | | @PutMapping
|
| | | public AjaxResult edit(@RequestBody ArdCameras camera) {
|
| | | if (CameraConstants.NOT_UNIQUE.equals(ardCamerasService.checkCameraIpAndPortUnique(camera)))
|
| | | {
|
| | | return error("修改相机'" + camera.getIp()+":"+camera.getPort() + "'失败,相机已存在");
|
| | | }
|
| | | int i = ardCamerasService.updateArdCameras(camera);
|
| | | if (i > 0) {
|
| | | cameraSdkService.logout(camera.getId());
|
| | | cameraSdkService.login(camera);
|
| | | }
|
| | | return toAjax(i);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 删除相机设备
|
| | | */
|
| | | @ApiOperation("删除相机设备")
|
| | | @PreAuthorize("@ss.hasPermi('device:cameras:remove')")
|
| | | @Log(title = "相机设备", businessType = BusinessType.DELETE)
|
| | | @DeleteMapping("/{ids}")
|
| | | public AjaxResult remove(@PathVariable String[] ids) {
|
| | | for (String id : ids) {
|
| | | cameraSdkService.logout(id);
|
| | | }
|
| | | return toAjax(ardCamerasService.deleteArdCamerasByIds(ids));
|
| | | }
|
| | |
|
| | | @Log(title = "导入相机设备", businessType = BusinessType.IMPORT)
|
| | | @PreAuthorize("@ss.hasPermi('device:cameras:import')")
|
| | | @PostMapping("/importData")
|
| | | @ApiOperation("导入相机设备")
|
| | | public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
|
| | | ExcelUtil<ArdCameras> util = new ExcelUtil<ArdCameras>(ArdCameras.class);
|
| | | List<ArdCameras> camerasList = util.importExcel(file.getInputStream());
|
| | | String operName = getUsername();
|
| | | String message = ardCamerasService.importCameras(camerasList, updateSupport, operName);
|
| | | return success(message);
|
| | | }
|
| | |
|
| | | @PostMapping("/importTemplate")
|
| | | @ApiOperation("相机设备导入模板")
|
| | | public void importTemplate(HttpServletResponse response) {
|
| | | ExcelUtil<ArdCameras> util = new ExcelUtil<ArdCameras>(ArdCameras.class);
|
| | | util.importTemplateExcel(response, "相机设备数据");
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | @GetMapping("/options")
|
| | | @ApiOperation("选择相机数据")
|
| | | public List options(ArdCameras ardCameras) {
|
| | | List<ArdCameras> list = ardCamerasService.findOptions(ardCameras);
|
| | | //System.out.println("list:"+list.size());
|
| | | List options = new ArrayList();
|
| | | for (ArdCameras item : list) {
|
| | | Map option = new HashMap();
|
| | | option.put("value", item.getId());
|
| | | option.put("label", item.getName());
|
| | | option.put("channelList", item.getChannelList());
|
| | | List timeList = ardVideoInspectTaskService.getCameraIdleTimeList(item.getId());
|
| | | option.put("idleTimeList", timeList);//空闲时间段
|
| | | options.add(option);
|
| | | }
|
| | | return options;
|
| | | }
|
| | |
|
| | | @GetMapping("/getDeptAndCamera")
|
| | | @ApiOperation("获取部门和相机")
|
| | | public AjaxResult getDeptAndCamera() {
|
| | | Map deptAndCamera = ardCamerasService.getChildDeptAndCamera(true);
|
| | | return AjaxResult.success(deptAndCamera);
|
| | | }
|
| | | @GetMapping("/getDeptAndCameraByRole")
|
| | | @ApiOperation("获取部门和相机按角色")
|
| | | public AjaxResult getDeptAndCameraByRole() {
|
| | | List<DeptAndCamerasDto> deptAndCamera = ardCamerasService.getChildDeptAndCamera();
|
| | | return AjaxResult.success(deptAndCamera);
|
| | | }
|
| | | @GetMapping("/getDeptAndCameraWithCheckBox")
|
| | | @ApiOperation("获取部门和相机(开启复选框)")
|
| | | public AjaxResult getDeptAndCameraWithCheckBox() {
|
| | | Map deptAndCamera = ardCamerasService.getChildDeptAndCamera(false);
|
| | | return AjaxResult.success(deptAndCamera);
|
| | | }
|
| | |
|
| | | @PostMapping("/getNearCamerasBycoordinate")
|
| | | @ApiOperation("获取附近的相机")
|
| | | @ApiOperationSupport(includeParameters = {"targetPosition"})
|
| | | public AjaxResult getNearCamerasBycoordinate(@RequestBody CameraCmd cmd) {
|
| | | TreeMap nearCamerasBycoordinate = ardCamerasService.getNearCamerasBycoordinate(cmd);
|
| | | return AjaxResult.success(nearCamerasBycoordinate);
|
| | | }
|
| | |
|
| | | @GetMapping("/getCamerasByDeptId")
|
| | | @ApiOperation("获取权限及下属权限下的相机")
|
| | | public AjaxResult getCamerasByDeptId() {
|
| | | Long deptId = SecurityUtils.getDeptId();
|
| | | String userId = SecurityUtils.getUserId();
|
| | | List<Map<String,Object>> camerasList = ardCamerasService.getCamerasByDeptId(deptId,userId);
|
| | | return AjaxResult.success(camerasList);
|
| | | }
|
| | |
|
| | | @PostMapping("/getCameraOperationByCameraId")
|
| | | @ApiOperation("查看相机可否操控")
|
| | | public AjaxResult getCameraOperationByCameraId(@RequestBody Map<String,String> map) {
|
| | | String userId = SecurityUtils.getUserId();
|
| | | Boolean flag = ardCamerasService.getCameraOperationByCameraId(map.get("id"),userId);
|
| | | return AjaxResult.success(flag);
|
| | | }
|
| | |
|
| | | @PostMapping("/getChannelByCameraId")
|
| | | @ApiOperation("获取相机通道")
|
| | | public AjaxResult getChannelByCameraId(@RequestBody Map<String,String> map) {
|
| | | Map<String,Object> result = ardCamerasService.getChannelByCameraId(map.get("id"));
|
| | | return AjaxResult.success(result);
|
| | | }
|
| | | }
|