|
|
|
|
@ -12,7 +12,6 @@ import com.leaper.web.lib.CameraControlModule;
|
|
|
|
|
import com.leaper.web.lib.hik.HikCameraControlModuleImpl;
|
|
|
|
|
import com.leaper.web.mapper.CameraRecordDuojiMapper;
|
|
|
|
|
import com.leaper.web.pojo.street.StreetSearch;
|
|
|
|
|
import com.leaper.web.task.S3Utils;
|
|
|
|
|
import com.zhehekeji.core.pojo.Result;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
@ -42,76 +41,73 @@ public class CameraRecord {
|
|
|
|
|
@Resource
|
|
|
|
|
ConfigProperties configProperties;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
S3Utils s3Utils;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/record")
|
|
|
|
|
@ApiOperation(value = "回放列表 ")
|
|
|
|
|
@LicenseHandler
|
|
|
|
|
public Result<Record> record(@RequestBody Record record) {
|
|
|
|
|
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-M-d");
|
|
|
|
|
|
|
|
|
|
LocalDate today = LocalDate.parse(record.getDate(), formatter);
|
|
|
|
|
|
|
|
|
|
LocalDateTime startOfDay = LocalDateTime.of(today, LocalTime.MIN);
|
|
|
|
|
LocalDateTime endOfDay = LocalDateTime.of(today, LocalTime.MAX);
|
|
|
|
|
List<CameraRecordDuoji> cameraRecordDuoji = cameraRecordDuojiMapper.selectList(new QueryWrapper<CameraRecordDuoji>()
|
|
|
|
|
.eq("camera_Id", record.getCameraId())
|
|
|
|
|
.ge("start_Time", startOfDay)
|
|
|
|
|
.le("end_Time", endOfDay)
|
|
|
|
|
.orderByAsc("start_Time"));
|
|
|
|
|
record.setStartTimeLong(0L);
|
|
|
|
|
record.setEndTimeLong(24L * 60 * 60);
|
|
|
|
|
List<Record> urls = cameraRecordDuoji.stream()
|
|
|
|
|
.map(cameraRecordDuoji1 -> {
|
|
|
|
|
Record r = new Record();
|
|
|
|
|
r.setUrl( "/"+configProperties.getS3Config().getBucketName() +"/"+cameraRecordDuoji1.getPath() +".mp4");
|
|
|
|
|
r.setStartTimeLong(toSecondsSinceMidnight(cameraRecordDuoji1.getStartTime()));
|
|
|
|
|
r.setEndTimeLong(toSecondsSinceMidnight(cameraRecordDuoji1.getEndTime()));
|
|
|
|
|
return r;
|
|
|
|
|
})
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
record.setUrls(urls);
|
|
|
|
|
|
|
|
|
|
return new Result<>(record);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/convetor")
|
|
|
|
|
@ApiOperation(value = "视频转换 ")
|
|
|
|
|
@LicenseHandler
|
|
|
|
|
public Result<Boolean> convetor(@RequestBody Record record) {
|
|
|
|
|
String url = record.getUrl().replace(".mp4","").replace("/"+configProperties.getS3Config().getBucketName() ,"").substring(1);
|
|
|
|
|
// 文件或目录的路径
|
|
|
|
|
String filePath =configProperties.getS3Config().getUrlCache() +url+".mp4";
|
|
|
|
|
// 创建一个File对象
|
|
|
|
|
File file = new File(filePath);
|
|
|
|
|
if(file.exists()){
|
|
|
|
|
return new Result<>(true);
|
|
|
|
|
}else {
|
|
|
|
|
s3Utils.downloadFile(configProperties.getS3Config().getBucketName(), url, configProperties.getS3Config().getUrlCache() + url);
|
|
|
|
|
HikCameraControlModuleImpl.convetor(configProperties.getS3Config().getUrlCache() + url, filePath);
|
|
|
|
|
return new Result<>(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@PostMapping("/1")
|
|
|
|
|
@ApiOperation(value = "视频转换 ")
|
|
|
|
|
@LicenseHandler
|
|
|
|
|
public Result<Boolean> booleanResult(@RequestBody Record record) {
|
|
|
|
|
return new Result<>(true);
|
|
|
|
|
}
|
|
|
|
|
private static long toSecondsSinceMidnight(LocalDateTime dateTime) {
|
|
|
|
|
LocalDateTime midnight = dateTime.toLocalDate().atStartOfDay();
|
|
|
|
|
Duration duration = Duration.between(midnight, dateTime);
|
|
|
|
|
return duration.getSeconds();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-M-dd");
|
|
|
|
|
|
|
|
|
|
LocalDate today = LocalDate.parse("2024-8-6", formatter);
|
|
|
|
|
System.out.printf(today.toString());
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
// @PostMapping("/record")
|
|
|
|
|
// @ApiOperation(value = "回放列表 ")
|
|
|
|
|
// @LicenseHandler
|
|
|
|
|
// public Result<Record> record(@RequestBody Record record) {
|
|
|
|
|
//
|
|
|
|
|
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-M-d");
|
|
|
|
|
//
|
|
|
|
|
// LocalDate today = LocalDate.parse(record.getDate(), formatter);
|
|
|
|
|
//
|
|
|
|
|
// LocalDateTime startOfDay = LocalDateTime.of(today, LocalTime.MIN);
|
|
|
|
|
// LocalDateTime endOfDay = LocalDateTime.of(today, LocalTime.MAX);
|
|
|
|
|
// List<CameraRecordDuoji> cameraRecordDuoji = cameraRecordDuojiMapper.selectList(new QueryWrapper<CameraRecordDuoji>()
|
|
|
|
|
// .eq("camera_Id", record.getCameraId())
|
|
|
|
|
// .ge("start_Time", startOfDay)
|
|
|
|
|
// .le("end_Time", endOfDay)
|
|
|
|
|
// .orderByAsc("start_Time"));
|
|
|
|
|
// record.setStartTimeLong(0L);
|
|
|
|
|
// record.setEndTimeLong(24L * 60 * 60);
|
|
|
|
|
// List<Record> urls = cameraRecordDuoji.stream()
|
|
|
|
|
// .map(cameraRecordDuoji1 -> {
|
|
|
|
|
// Record r = new Record();
|
|
|
|
|
// r.setUrl( "/"+configProperties.getS3Config().getBucketName() +"/"+cameraRecordDuoji1.getPath() +".mp4");
|
|
|
|
|
// r.setStartTimeLong(toSecondsSinceMidnight(cameraRecordDuoji1.getStartTime()));
|
|
|
|
|
// r.setEndTimeLong(toSecondsSinceMidnight(cameraRecordDuoji1.getEndTime()));
|
|
|
|
|
// return r;
|
|
|
|
|
// })
|
|
|
|
|
// .collect(Collectors.toList());
|
|
|
|
|
// record.setUrls(urls);
|
|
|
|
|
//
|
|
|
|
|
// return new Result<>(record);
|
|
|
|
|
// }
|
|
|
|
|
////
|
|
|
|
|
//// @PostMapping("/convetor")
|
|
|
|
|
//// @ApiOperation(value = "视频转换 ")
|
|
|
|
|
//// @LicenseHandler
|
|
|
|
|
//// public Result<Boolean> convetor(@RequestBody Record record) {
|
|
|
|
|
//// String url = record.getUrl().replace(".mp4","").replace("/"+configProperties.getS3Config().getBucketName() ,"").substring(1);
|
|
|
|
|
//// // 文件或目录的路径
|
|
|
|
|
//// String filePath =configProperties.getS3Config().getUrlCache() +url+".mp4";
|
|
|
|
|
//// // 创建一个File对象
|
|
|
|
|
//// File file = new File(filePath);
|
|
|
|
|
//// if(file.exists()){
|
|
|
|
|
//// return new Result<>(true);
|
|
|
|
|
//// }else {
|
|
|
|
|
//// s3Utils.downloadFile(configProperties.getS3Config().getBucketName(), url, configProperties.getS3Config().getUrlCache() + url);
|
|
|
|
|
//// HikCameraControlModuleImpl.convetor(configProperties.getS3Config().getUrlCache() + url, filePath);
|
|
|
|
|
//// return new Result<>(true);
|
|
|
|
|
//// }
|
|
|
|
|
//// }
|
|
|
|
|
// @PostMapping("/1")
|
|
|
|
|
// @ApiOperation(value = "视频转换 ")
|
|
|
|
|
// @LicenseHandler
|
|
|
|
|
// public Result<Boolean> booleanResult(@RequestBody Record record) {
|
|
|
|
|
// return new Result<>(true);
|
|
|
|
|
// }
|
|
|
|
|
// private static long toSecondsSinceMidnight(LocalDateTime dateTime) {
|
|
|
|
|
// LocalDateTime midnight = dateTime.toLocalDate().atStartOfDay();
|
|
|
|
|
// Duration duration = Duration.between(midnight, dateTime);
|
|
|
|
|
// return duration.getSeconds();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// public static void main(String[] args) {
|
|
|
|
|
//
|
|
|
|
|
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-M-dd");
|
|
|
|
|
//
|
|
|
|
|
// LocalDate today = LocalDate.parse("2024-8-6", formatter);
|
|
|
|
|
// System.out.printf(today.toString());
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|