From 6a26b1d539576a556d0f8682af7ae4317de78c7a Mon Sep 17 00:00:00 2001 From: ‘liusuyi’ <1951119284@qq.com> Date: 星期二, 02 四月 2024 13:35:35 +0800 Subject: [PATCH] 修复相机密码脱敏导致的bug --- ard-work/src/main/java/com/ruoyi/device/camera/controller/ArdCamerasController.java | 56 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 42 insertions(+), 14 deletions(-) diff --git a/ard-work/src/main/java/com/ruoyi/device/camera/controller/ArdCamerasController.java b/ard-work/src/main/java/com/ruoyi/device/camera/controller/ArdCamerasController.java index 1f5b15d..b5727f2 100644 --- a/ard-work/src/main/java/com/ruoyi/device/camera/controller/ArdCamerasController.java +++ b/ard-work/src/main/java/com/ruoyi/device/camera/controller/ArdCamerasController.java @@ -2,10 +2,12 @@ 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.common.utils.StringUtils; import com.ruoyi.device.camera.domain.ArdCameras; import com.ruoyi.device.camera.domain.CameraCmd; import com.ruoyi.device.camera.domain.DeptAndCamerasDto; @@ -13,10 +15,12 @@ import com.ruoyi.device.camera.service.ICameraSdkService; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.inspect.service.IArdVideoInspectTaskService; +import com.ruoyi.utils.tools.ArdTool; 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.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; @@ -63,6 +67,7 @@ List<ArdCameras> list = ardCamerasService.selectArdCamerasList(ardCamera); return getDataTable(list); } + /** * 鏌ヨ鐩告満璁惧鍒楄〃锛堜笉鏍¢獙鏉冮檺锛� */ @@ -73,6 +78,7 @@ List<ArdCameras> list = ardCamerasService.selectArdCamerasList(ardCamera); return getDataTable(list); } + /** * 瀵煎嚭鐩告満璁惧鍒楄〃 */ @@ -104,16 +110,17 @@ @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() + "'澶辫触锛岀浉鏈哄凡瀛樺湪"); + if (CameraConstants.NOT_UNIQUE.equals(ardCamerasService.checkCameraIpAndPortUnique(camera))) { + return error("鏂板鐩告満'" + camera.getIp() + ":" + camera.getPort() + "'澶辫触锛岀浉鏈哄凡瀛樺湪"); } + camera.setState("0"); int i = ardCamerasService.insertArdCameras(camera); if (i > 0) { - cameraSdkService.logout(camera.getId()); - cameraSdkService.login(camera); + AjaxResult result = cameraSdkService.login(camera); + return success(result.get("msg")); + } else { + return error("鏂板鐩告満璁惧澶辫触"); } - return toAjax(i); } /** @@ -124,16 +131,20 @@ @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() + "'澶辫触锛岀浉鏈哄凡瀛樺湪"); + if (CameraConstants.NOT_UNIQUE.equals(ardCamerasService.checkCameraIpAndPortUnique(camera))) { + return error("淇敼鐩告満'" + camera.getIp() + ":" + camera.getPort() + "'澶辫触锛岀浉鏈哄凡瀛樺湪"); } + ArdCameras cameraOld = ardCamerasService.selectArdCamerasById(camera.getId()); + ArdTool.fillNullFields(cameraOld, camera); + + camera.setState("0"); int i = ardCamerasService.updateArdCameras(camera); if (i > 0) { - cameraSdkService.logout(camera.getId()); - cameraSdkService.login(camera); + AjaxResult result = cameraSdkService.login(camera); + return success(result.get("msg")); + } else { + return error("淇敼鐩告満璁惧澶辫触"); } - return toAjax(i); } /** @@ -170,7 +181,6 @@ } - @GetMapping("/options") @ApiOperation("閫夋嫨鐩告満鏁版嵁") public List options(ArdCameras ardCameras) { @@ -195,12 +205,14 @@ 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() { @@ -220,7 +232,23 @@ @ApiOperation("鑾峰彇鏉冮檺鍙婁笅灞炴潈闄愪笅鐨勭浉鏈�") public AjaxResult getCamerasByDeptId() { Long deptId = SecurityUtils.getDeptId(); - List<Map<String,Object>> camerasList = ardCamerasService.getCamerasByDeptId(deptId); + 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); + } } -- Gitblit v1.9.3