| | |
| | | import com.ruoyi.common.annotation.SdkOperate; |
| | | import com.ruoyi.common.utils.file.FileUtils; |
| | | import com.ruoyi.device.camera.domain.CameraCmd; |
| | | import com.ruoyi.device.camera.mapper.ArdCamerasMapper; |
| | | import com.ruoyi.device.camera.service.IArdCamerasService; |
| | | import com.ruoyi.device.hiksdk.common.GlobalVariable; |
| | | import com.ruoyi.device.camera.domain.ArdCameras; |
| | | import com.ruoyi.device.hiksdk.config.MinioClientSingleton; |
| | |
| | | import com.sun.jna.ptr.IntByReference; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import sun.misc.BASE64Encoder; |
| | | import java.util.Base64; |
| | | import javax.annotation.Resource; |
| | | import java.io.*; |
| | | import java.math.BigDecimal; |
| | |
| | | public class HikClientServiceImpl implements IHikClientService { |
| | | |
| | | @Resource |
| | | ArdCamerasMapper ardCamerasMapper; |
| | | IArdCamerasService ardCamerasService; |
| | | |
| | | private static HCNetSDK hCNetSDK; |
| | | |
| | |
| | | } |
| | | //打印海康sdk日志 |
| | | if (Platform.isWindows()) { |
| | | |
| | | String WIN_PATH = System.getProperty("user.dir") + File.separator + "ardLog" + File.separator + "logs" + File.separator; |
| | | hCNetSDK.NET_DVR_SetLogToFile(3, WIN_PATH, true); |
| | | } else { |
| | |
| | | public void loginAll() { |
| | | try { |
| | | log.debug("加载lib完成!"); |
| | | List<ArdCameras> ardCameras = ardCamerasMapper.selectArdCamerasListNoDataScope(new ArdCameras()); |
| | | List<ArdCameras> ardCameras = ardCamerasService.selectArdCamerasListNoDataScope(new ArdCameras()); |
| | | for (ArdCameras camera : ardCameras) { |
| | | Thread.sleep(500); |
| | | login(camera); |
| | |
| | | NET_DVR_PTZPOS m_ptzPosCurrent = new NET_DVR_PTZPOS(); |
| | | m_ptzPosCurrent.wAction = 1; |
| | | try { |
| | | ArdCameras cameras = ardCamerasMapper.selectArdCamerasById(cameraId); |
| | | ArdCameras cameras = ardCamerasService.selectArdCamerasById(cameraId); |
| | | double[] cameraPositon = new double[]{cameras.getLongitude(), cameras.getLatitude(), cameras.getAltitude()}; |
| | | double[] targetPositions = cmd.getTargetPosition(); |
| | | double[] cameraPTZ = GisUtil.getCameraPTZ(cameraPositon, targetPositions, 20, 150); |
| | |
| | | @SdkOperate |
| | | public boolean controlLock(CameraCmd cmd) { |
| | | String cameraId = cmd.getCameraId();//申请锁的相机 |
| | | ArdCameras ardCameras = ardCamerasMapper.selectArdCamerasById(cameraId); |
| | | ArdCameras ardCameras = ardCamerasService.selectArdCamerasById(cameraId); |
| | | Date now = new Date(); |
| | | now.setTime(now.getTime() + cmd.getExpired() * 1000); |
| | | ardCameras.setOperatorExpired(now);//设置当前过期时间 |
| | | ardCamerasMapper.updateArdCameras(ardCameras); |
| | | ardCamerasService.updateArdCameras(ardCameras); |
| | | return true; |
| | | } |
| | | |
| | |
| | | public boolean controlUnLock(CameraCmd cmd) { |
| | | String cameraId = cmd.getCameraId();//申请解锁的相机 |
| | | String operator = cmd.getOperator();//申请者 |
| | | ArdCameras ardCameras = ardCamerasMapper.selectArdCamerasById(cameraId); |
| | | ArdCameras ardCameras = ardCamerasService.selectArdCamerasById(cameraId); |
| | | if (ardCameras.getOperatorId().equals(operator)) { |
| | | //如果解锁相机的当前用户是申请者,则清空该相机的过期时间 |
| | | ardCameras.setOperatorExpired(null); |
| | | int i = ardCamerasMapper.updateArdCameras(ardCameras); |
| | | int i = ardCamerasService.updateArdCameras(ardCameras); |
| | | if (i > 0) { |
| | | log.debug(cameraId + "--解锁成功"); |
| | | } |
| | |
| | | boolean is = hCNetSDK.NET_DVR_CaptureJPEGPicture_NEW(userId, channelNum, jpeg, jpegBuffer, 1024 * 1024, a); |
| | | log.info("-----------这里开始图片存入内存----------" + is); |
| | | |
| | | BASE64Encoder encoder = new BASE64Encoder(); |
| | | String png_base64 = encoder.encodeBuffer(jpegBuffer);//转换成base64串 |
| | | Base64.Encoder decoder = Base64.getEncoder(); |
| | | // BASE64Encoder encoder = new BASE64Encoder(); |
| | | String png_base64 = decoder.encodeToString(jpegBuffer.array());//转换成base64串 |
| | | png_base64 = png_base64.replaceAll("\n", "").replaceAll("\r", "");//删除 \r\n |
| | | log.info("-----------处理完成截图数据----------"); |
| | | return png_base64; |