‘liusuyi’
2023-06-06 3a0f24e5517b574a203cec8088fdd3d9165862aa
ard-work/src/main/java/com/ruoyi/device/hiksdk/service/impl/HikClientServiceImpl.java
@@ -5,6 +5,7 @@
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.constant.sdkPriority;
import com.ruoyi.device.camera.domain.CameraCmd;
import com.ruoyi.device.camera.mapper.ArdCamerasMapper;
@@ -1302,15 +1303,13 @@
                return;
            }
            Integer userId = GlobalVariable.loginMap.get(cameraId);
            String path = "";
            //强制I帧结构体对象
            HCNetSDK.NET_DVR_I_FRAME netDvrIFrame = new HCNetSDK.NET_DVR_I_FRAME();   //新建结构体对象
            netDvrIFrame.read();
            netDvrIFrame.dwChannel = channelNum;          //因为上文代码中设置了通道号,按照上文中的设置
            netDvrIFrame.dwChannel = channelNum;//因为上文代码中设置了通道号,按照上文中的设置
            netDvrIFrame.byStreamType = 0;
            netDvrIFrame.dwSize = netDvrIFrame.size();
            netDvrIFrame.write();
            if(!hCNetSDK.NET_DVR_RemoteControl(userId,3402,netDvrIFrame.getPointer(),netDvrIFrame.dwSize)){
                log.error("强制I帧 错误码为:  " + hCNetSDK.NET_DVR_GetLastError());
            }
@@ -1333,15 +1332,8 @@
                        return;
                    }
                    log.info("取流成功");
                    File file = new File("D:/recordTemp/" + cameraId + ".mp4");
                    if (!file.exists()) {
                        File fileParent = file.getParentFile();
                        if (!fileParent.exists()) {
                            fileParent.mkdirs();
                        }
                        file.createNewFile();
                    }
                    path = file.getCanonicalPath();
                    String path= FileUtils.createFile("D:/recordTemp/" + cameraId + ".mp4");
                    recordInfo info = new recordInfo();
                    info.setLRealHandle(lRealHandle);
                    info.setRecordPath(path);
@@ -1360,15 +1352,17 @@
                }
                hCNetSDK.NET_DVR_StopRealPlay(info.getLRealHandle());
                log.info("录像停止");
                //存入minio
                String BucketName = cmd.getRecordBucketName();
                String ObjectName = cmd.getRecordObjectName();
                String ContentType = "video/MP4";
                FileInputStream stream = new FileInputStream(info.getRecordPath());
                boolean b = MinioUtils.uploadObject(BucketName, ObjectName, stream, stream.available(), ContentType);
                if (b) {
                    log.info("上传文件成功!" + MinioClientSingleton.domainUrl + "/"+ BucketName + "/" + ObjectName);
                    GlobalVariable.user_real_Map.remove(userId);
                if(cmd.isUploadMinio()) {
                    //存入minio
                    String BucketName = cmd.getRecordBucketName();
                    String ObjectName = cmd.getRecordObjectName();
                    String ContentType = "video/MP4";
                    FileInputStream stream = new FileInputStream(info.getRecordPath());
                    boolean b = MinioUtils.uploadObject(BucketName, ObjectName, stream, stream.available(), ContentType);
                    if (b) {
                        log.info("上传文件成功!" + MinioClientSingleton.domainUrl + "/" + BucketName + "/" + ObjectName);
                        GlobalVariable.user_real_Map.remove(userId);
                    }
                }
            }
        } catch (Exception ex) {