You've already forked FrameTour-BE
Compare commits
3 Commits
39c955b55c
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 47ae60b203 | |||
| 703a5baf13 | |||
| 7454111615 |
@@ -2,6 +2,7 @@ package com.ycwl.basic.face.pipeline.helper;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2DTO;
|
||||
import com.ycwl.basic.mapper.SourceMapper;
|
||||
import com.ycwl.basic.puzzle.dto.PuzzleGenerateRequest;
|
||||
import com.ycwl.basic.puzzle.dto.PuzzleGenerateResponse;
|
||||
import com.ycwl.basic.puzzle.dto.PuzzleTemplateDTO;
|
||||
@@ -44,6 +45,9 @@ public class PuzzleGenerationOrchestrator {
|
||||
@Autowired
|
||||
private ScenicRepository scenicRepository;
|
||||
|
||||
@Autowired
|
||||
private SourceMapper sourceMapper;
|
||||
|
||||
/**
|
||||
* 异步生成景区所有启用的拼图模板
|
||||
*
|
||||
@@ -74,6 +78,11 @@ public class PuzzleGenerationOrchestrator {
|
||||
// 3. 准备公共动态数据
|
||||
Map<String, String> baseDynamicData = buildBaseDynamicData(faceId, faceUrl, scenicBasic);
|
||||
|
||||
// 4. 设置dateStr为图片素材的最大创建时间
|
||||
Date maxCreateTime = sourceMapper.getMaxCreateTimeByFaceId(faceId);
|
||||
baseDynamicData.put("dateStr", DateUtil.format(
|
||||
maxCreateTime != null ? maxCreateTime : new Date(), "yyyy.MM.dd"));
|
||||
|
||||
// 4. 使用虚拟线程池并行生成所有模板
|
||||
java.util.concurrent.atomic.AtomicInteger successCount = new java.util.concurrent.atomic.AtomicInteger(0);
|
||||
java.util.concurrent.atomic.AtomicInteger failCount = new java.util.concurrent.atomic.AtomicInteger(0);
|
||||
@@ -121,7 +130,6 @@ public class PuzzleGenerationOrchestrator {
|
||||
baseDynamicData.put("faceId", String.valueOf(faceId));
|
||||
baseDynamicData.put("scenicName", scenicBasic.getName());
|
||||
baseDynamicData.put("scenicText", scenicBasic.getName());
|
||||
baseDynamicData.put("dateStr", DateUtil.format(new Date(), "yyyy.MM.dd"));
|
||||
|
||||
return baseDynamicData;
|
||||
}
|
||||
|
||||
@@ -143,6 +143,13 @@ public interface SourceMapper {
|
||||
*/
|
||||
List<Long> getDeviceIdsByFaceId(Long faceId);
|
||||
|
||||
/**
|
||||
* 获取faceId关联的图片素材的最大创建时间
|
||||
* @param faceId 人脸ID
|
||||
* @return 最大创建时间,无记录时返回null
|
||||
*/
|
||||
Date getMaxCreateTimeByFaceId(Long faceId);
|
||||
|
||||
/**
|
||||
* 根据faceId和设备ID获取source
|
||||
* @param faceId 人脸ID
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.stream.Collectors;
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class PuzzleDuplicationDetector {
|
||||
private final Set<String> skippedElementKeys = Set.of("dateStr");
|
||||
private final Set<String> skippedElementKeys = Set.of();
|
||||
private final PuzzleGenerationRecordMapper recordMapper;
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,7 +40,7 @@ public class SourceRepository {
|
||||
Runtime.getRuntime().availableProcessors(),
|
||||
runnable -> {
|
||||
Thread thread = new Thread(runnable);
|
||||
thread.setName("ai-cam-image-processor-" + thread.getId());
|
||||
thread.setName("ai-cam-image-processor-" + thread.threadId());
|
||||
thread.setDaemon(true);
|
||||
return thread;
|
||||
}
|
||||
|
||||
@@ -405,7 +405,9 @@ public class FaceMatchingOrchestrator {
|
||||
baseDynamicData.put("faceId", String.valueOf(faceId));
|
||||
baseDynamicData.put("scenicName", scenicBasic.getName());
|
||||
baseDynamicData.put("scenicText", scenicBasic.getName());
|
||||
baseDynamicData.put("dateStr", DateUtil.format(new Date(), "yyyy.MM.dd"));
|
||||
Date maxCreateTime = sourceMapper.getMaxCreateTimeByFaceId(faceId);
|
||||
baseDynamicData.put("dateStr", DateUtil.format(
|
||||
maxCreateTime != null ? maxCreateTime : new Date(), "yyyy.MM.dd"));
|
||||
|
||||
templateList
|
||||
.forEach(template -> {
|
||||
|
||||
@@ -85,7 +85,7 @@ public class DownloadNotificationTasker {
|
||||
}
|
||||
variables.put("videoDeviceCount", videoTaskRepository.getTaskDeviceNum(item.getTaskId()));
|
||||
variables.put("videoLensCount", videoTaskRepository.getTaskLensNum(item.getTaskId()));
|
||||
variables.put("videoShotTime", DateUtil.format(videoTaskRepository.getTaskShotDate(item.getTaskId()), "yyyy-MM-dd"));
|
||||
variables.put("videoShotTime", DateUtil.format(videoTaskRepository.getTaskShotDate(item.getTaskId()), "yyyy-MM-dd HH:mm"));
|
||||
WechatSubscribeNotifyTriggerRequest request = WechatSubscribeNotifyTriggerRequest.builder()
|
||||
.scenicId(item.getScenicId())
|
||||
.memberId(item.getMemberId())
|
||||
@@ -137,7 +137,7 @@ public class DownloadNotificationTasker {
|
||||
} else {
|
||||
variables.put("videoResultPage", "videoSynthesis");
|
||||
}
|
||||
variables.put("expireDate", DateUtil.format(expireDate, "yyyy-MM-dd"));
|
||||
variables.put("expireDate", DateUtil.format(expireDate, "yyyy-MM-dd HH:mm"));
|
||||
variables.put("videoDeviceCount", videoTaskRepository.getTaskDeviceNum(item.getTaskId()));
|
||||
variables.put("videoLensCount", videoTaskRepository.getTaskLensNum(item.getTaskId()));
|
||||
variables.put("videoShotTime", DateUtil.format(videoTaskRepository.getTaskShotDate(item.getTaskId()), "yyyy-MM-dd HH:mm"));
|
||||
@@ -191,7 +191,7 @@ public class DownloadNotificationTasker {
|
||||
} else {
|
||||
variables.put("videoResultPage", "videoSynthesis");
|
||||
}
|
||||
variables.put("expireDate", DateUtil.format(expireDate, "yyyy-MM-dd"));
|
||||
variables.put("expireDate", DateUtil.format(expireDate, "yyyy-MM-dd HH:mm"));
|
||||
variables.put("videoDeviceCount", videoTaskRepository.getTaskDeviceNum(item.getTaskId()));
|
||||
variables.put("videoLensCount", videoTaskRepository.getTaskLensNum(item.getTaskId()));
|
||||
variables.put("videoShotTime", DateUtil.format(videoTaskRepository.getTaskShotDate(item.getTaskId()), "yyyy-MM-dd HH:mm"));
|
||||
|
||||
@@ -64,10 +64,10 @@ public class SourceNotificationTasker {
|
||||
variables.put("faceId", item.getId());
|
||||
List<MemberSourceEntity> sourceVideoList = memberRelationRepository.listSourceByFaceRelation(item.getId(), 1);
|
||||
variables.put("sourceVideoCount", sourceVideoList.size());
|
||||
variables.put("sourceVideoCreateTime", DateUtil.format(item.getCreateAt(), "yyyy-MM-dd"));
|
||||
variables.put("sourceVideoCreateTime", DateUtil.format(item.getCreateAt(), "yyyy-MM-dd HH:mm"));
|
||||
List<MemberSourceEntity> sourcePhotoList = memberRelationRepository.listSourceByFaceRelation(item.getId(), 2);
|
||||
variables.put("sourcePhotoCount", sourcePhotoList.size());
|
||||
variables.put("sourcePhotoCreateTime", DateUtil.format(item.getCreateAt(), "yyyy-MM-dd"));
|
||||
variables.put("sourcePhotoCreateTime", DateUtil.format(item.getCreateAt(), "yyyy-MM-dd HH:mm"));
|
||||
|
||||
WechatSubscribeNotifyTriggerRequest request = WechatSubscribeNotifyTriggerRequest.builder()
|
||||
.scenicId(item.getScenicId())
|
||||
|
||||
@@ -342,7 +342,7 @@ public class VideoPieceGetter {
|
||||
ffmpegTask.setDuration(duration);
|
||||
ffmpegTask.setOffsetStart(BigDecimal.valueOf(offset, 3));
|
||||
// 使用时间戳和线程ID确保输出文件名唯一性,避免并发冲突
|
||||
String uniqueSuffix = System.currentTimeMillis() + "_" + Thread.currentThread().getId();
|
||||
String uniqueSuffix = System.currentTimeMillis() + "_" + Thread.currentThread().threadId();
|
||||
File outFile = new File(deviceId.toString() + "_" + faceSampleId + "_" + uniqueSuffix + ".mp4");
|
||||
ffmpegTask.setOutputFile(outFile.getAbsolutePath());
|
||||
boolean result = startFfmpegTask(ffmpegTask);
|
||||
|
||||
@@ -464,6 +464,15 @@
|
||||
ORDER BY s.device_id ASC
|
||||
</select>
|
||||
|
||||
<select id="getMaxCreateTimeByFaceId" resultType="java.util.Date">
|
||||
SELECT MAX(s.create_time)
|
||||
FROM member_source ms
|
||||
INNER JOIN source s ON ms.source_id = s.id
|
||||
WHERE ms.face_id = #{faceId}
|
||||
AND s.type = 2
|
||||
AND ms.deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="getSourceByFaceAndDeviceId" resultType="com.ycwl.basic.model.pc.source.entity.SourceEntity">
|
||||
SELECT s.*
|
||||
FROM source s
|
||||
|
||||
Reference in New Issue
Block a user