| | |
| | | import com.ard.common.core.exception.ServiceException; |
| | | import com.ard.common.core.exception.device.CameraSDKException; |
| | | import com.ard.common.core.utils.StringUtils; |
| | | import com.ard.common.core.utils.file.FileMultipartFile; |
| | | import com.ard.common.core.utils.file.FileUtils; |
| | | import com.ard.common.core.utils.file.MimeTypeUtils; |
| | | import com.ard.common.redis.service.RedisService; |
| | |
| | | import com.ard.work.sdk.model.PtzScope; |
| | | import com.ard.work.sdk.service.CameraSDK; |
| | | import com.ard.work.utils.FFmpegUtils; |
| | | import com.ard.work.utils.file.MultipartFileUtil; |
| | | import com.ard.work.utils.gis.GisUtil; |
| | | import com.sun.jna.Native; |
| | | import com.sun.jna.Pointer; |
| | |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.InputStream; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public PtzDto getPtzHigh(CameraCmd cmd) { |
| | | return getPtz(cmd); |
| | | } |
| | | |
| | | @Override |
| | | public PtzScope getPtzScope(CameraCmd cmd) { |
| | | NetSDKLib.LLong loginId = new LLong(cmd.getLoginId()); |
| | | NET_PRODUCTION_DEFNITION productionDefinition = new NET_PRODUCTION_DEFNITION(); |
| | |
| | | ptzScope.setTMax((float) productionDefinition.nPtzVerticalAngleMax); |
| | | ptzScope.setTMin((float) productionDefinition.nPtzVerticalAngleMin); |
| | | return ptzScope; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Boolean setPtzHigh(CameraCmd cmd) { |
| | | return setPtz(cmd); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean setPtzHighT(CameraCmd cmd) { |
| | | return setPtz(cmd); |
| | | } |
| | | |
| | | //设置ptz信息 |
| | |
| | | log.warn("转码耗时:{}", watchStop.getTotalTimeMillis()); |
| | | //存入minio |
| | | String bucketName = "record"; |
| | | String objectName = cameraId + "_" + chanNo; |
| | | String fileName = cameraId + "_" + chanNo; |
| | | String type = cmd.getType(); |
| | | MultipartFile multipartFile = MultipartFileUtil.filePathToMultipartFile(newpath, objectName, |
| | | MimeTypeUtils.VIDEO_MP4); |
| | | // MultipartFile multipartFile = MultipartFileUtil.filePathToMultipartFile(newpath, objectName, |
| | | // MimeTypeUtils.VIDEO_MP4); |
| | | File tempFile = new File(newpath); |
| | | MultipartFile multipartFile = new FileMultipartFile(tempFile, fileName, MimeTypeUtils.VIDEO_MP4); |
| | | R<SysFile> sysFileR = remoteFileService.upload(multipartFile, bucketName, type); |
| | | if (sysFileR.getCode() == R.SUCCESS) { |
| | | url = sysFileR.getData().getUrl(); |
| | |
| | | public void invoke(LLong lLoginID, Pointer pBuf, int RevLen, int EncodeType, int CmdSerial, Pointer dwUser) { |
| | | if (pBuf != null && RevLen > 0) { |
| | | byte[] buf = pBuf.getByteArray(0, RevLen); |
| | | //存储到minio |
| | | InputStream inputStream = new ByteArrayInputStream(buf); |
| | | MultipartFile multipartFile = MultipartFileUtil.inputStreamToMultipartFile(inputStream, objectName, |
| | | MimeTypeUtils.IMAGE_JPEG); |
| | | R<SysFile> sysFileR = remoteFileService.upload(multipartFile, bucketName, type); |
| | | if (sysFileR.getCode() == R.SUCCESS) { |
| | | String url = sysFileR.getData().getUrl(); |
| | | log.info("上传文件成功:{}", url); |
| | | // 在回调中完成 CompletableFuture |
| | | urlFuture.complete(url); |
| | | |
| | | // 定义文件信息 |
| | | String fileName = objectName; |
| | | String tempDir = System.getProperty("java.io.tmpdir") + "/snap_temp/"; |
| | | File tempDirFile = new File(tempDir); |
| | | if (!tempDirFile.exists()) { |
| | | tempDirFile.mkdirs(); |
| | | } |
| | | File tempFile = new File(tempDir + fileName); |
| | | |
| | | try { |
| | | // 写入临时文件 |
| | | try (FileOutputStream fos = new FileOutputStream(tempFile)) { |
| | | fos.write(buf); |
| | | fos.flush(); |
| | | } |
| | | |
| | | // 使用 FileMultipartFile 转换 |
| | | MultipartFile multipartFile = new FileMultipartFile(tempFile, fileName, MimeTypeUtils.IMAGE_JPEG); |
| | | |
| | | // 上传到 MinIO |
| | | R<SysFile> sysFileR = remoteFileService.upload(multipartFile, bucketName, type); |
| | | |
| | | if (sysFileR.getCode() == R.SUCCESS) { |
| | | String url = sysFileR.getData().getUrl(); |
| | | log.info("上传文件成功:{}", url); |
| | | urlFuture.complete(url); |
| | | } else { |
| | | log.error("上传文件失败: {}", sysFileR.getMsg()); |
| | | urlFuture.completeExceptionally(new RuntimeException("上传失败: " + sysFileR.getMsg())); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | log.error("处理截图失败", e); |
| | | urlFuture.completeExceptionally(e); |
| | | } finally { |
| | | // 清理临时文件 |
| | | if (tempFile.exists()) { |
| | | tempFile.delete(); |
| | | } |
| | | } |
| | | } else { |
| | | urlFuture.completeExceptionally(new RuntimeException("截图数据为空")); |
| | | } |
| | | } |
| | | } |