| | |
| | | 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.dhsdk.service.IDhClientService; |
| | | import com.ruoyi.device.hiksdk.service.IHikClientService; |
| | | import com.ruoyi.device.hiksdk.service.impl.HikClientServiceImpl; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | @Api(tags = "相机管理接口") |
| | | public class ArdCamerasController extends BaseController { |
| | | @Resource |
| | | private IHikClientService sdk; |
| | | private IHikClientService hikSdk; |
| | | @Resource |
| | | private IDhClientService dhSdk; |
| | | @Resource |
| | | private IArdCamerasService ardCamerasService; |
| | | @Resource |
| | |
| | | public AjaxResult add(@RequestBody ArdCameras camera) { |
| | | int i = ardCamerasService.insertArdCameras(camera); |
| | | if(i>0) { |
| | | if (camera.getFactory().equals("1")) { |
| | | //注销 |
| | | sdk.loginOut(camera.getId()); |
| | | hikSdk.logout(camera.getId()); |
| | | //异步登录 |
| | | sdk.asyncLogin(camera); |
| | | hikSdk.asyncLogin(camera); |
| | | } |
| | | else if(camera.getFactory().equals("2")) |
| | | { |
| | | dhSdk.logout(camera.getId()); |
| | | dhSdk.login(camera); |
| | | } |
| | | } |
| | | return toAjax(i); |
| | | } |
| | |
| | | @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.asyncLogin(cameras); |
| | | if (i > 0) { |
| | | camera= ardCamerasService.selectArdCamerasById(camera.getId()); |
| | | if(camera.getFactory().equals("1")) { |
| | | hikSdk.logout(camera.getId()); |
| | | hikSdk.asyncLogin(camera); |
| | | } |
| | | else if(camera.getFactory().equals("2")) { |
| | | dhSdk.logout(camera.getId()); |
| | | dhSdk.login(camera); |
| | | } |
| | | } |
| | | return toAjax(i); |
| | | } |
| | |
| | | @Log(title = "相机设备", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult remove(@PathVariable String[] ids) { |
| | | for(String id :ids) |
| | | { |
| | | sdk.loginOut(id); |
| | | for (String id : ids) { |
| | | hikSdk.logout(id); |
| | | dhSdk.logout(id); |
| | | } |
| | | return toAjax(ardCamerasService.deleteArdCamerasByIds(ids)); |
| | | } |
| | |
| | | } |
| | | return options; |
| | | } |
| | | |
| | | @GetMapping("/getDeptAndCamera") |
| | | @ApiOperation("获取部门和相机") |
| | | public AjaxResult getDeptAndCamera() |
| | | { |
| | | public AjaxResult getDeptAndCamera() { |
| | | Map deptAndCamera = ardCamerasService.getChildDeptAndCamera(true); |
| | | return AjaxResult.success(deptAndCamera); |
| | | } |
| | | |
| | | @GetMapping("/getDeptAndCameraWithCheckBox") |
| | | @ApiOperation("获取部门和相机(开启复选框)") |
| | | public AjaxResult getDeptAndCameraWithCheckBox() |
| | | { |
| | | public AjaxResult getDeptAndCameraWithCheckBox() { |
| | | Map deptAndCamera = ardCamerasService.getChildDeptAndCamera(false); |
| | | return AjaxResult.success(deptAndCamera); |
| | | } |
| | | |
| | | @PostMapping("/getNearCamerasBycoordinate") |
| | | @ApiOperation("获取附近的相机") |
| | | @ApiOperationSupport(includeParameters = {"targetPosition"}) |
| | | public AjaxResult getNearCamerasBycoordinate(@RequestBody CameraCmd cmd) |
| | | { |
| | | public AjaxResult getNearCamerasBycoordinate(@RequestBody CameraCmd cmd) { |
| | | TreeMap nearCamerasBycoordinate = ardCamerasService.getNearCamerasBycoordinate(cmd); |
| | | return AjaxResult.success(nearCamerasBycoordinate); |
| | | } |