清理删除逻辑优化

This commit is contained in:
2025-05-28 10:34:18 +08:00
parent 06a07514cc
commit a41b87713f
5 changed files with 17 additions and 1 deletions

View File

@ -79,4 +79,6 @@ public interface SourceMapper {
List<SourceWatermarkEntity> listSourceWatermark(List<Long> sourceIds, Long faceId, String watermarkType);
void addSourceWatermark(Long sourceId, Long faceId, String type, String url);
int deleteUselessSource();
}

View File

@ -54,4 +54,6 @@ public interface VideoMapper {
int deleteNotBuyRelations(Long scenicId, Date endDate);
int deleteNotBuyFaceRelations(Long userId, Long faceId);
int deleteUselessVideo();
}

View File

@ -163,7 +163,8 @@ public class FaceCleaner {
int expireDay = scenicConfig.getVideoStoreDay();
Date endDate = DateUtil.offsetDay(DateUtil.beginOfDay(new Date()), -expireDay);
int deleteCount = videoMapper.deleteNotBuyRelations(scenic.getId(), endDate);
log.info("当前景区{}删除VLOG{}个", scenic.getName(), deleteCount);
int deleteVideoCount = videoMapper.deleteUselessVideo();
log.info("当前景区{}删除VLOG关系{}个删除VLOG记录{}个", scenic.getName(), deleteCount, deleteVideoCount);
});
}
@ -203,6 +204,8 @@ public class FaceCleaner {
Date endDate2 = DateUtil.offsetDay(DateUtil.beginOfDay(new Date()), -imageSourceExpireDay);
int deleteImageSourceCount = sourceMapper.deleteNotRelateSource(2, endDate2);
log.info("当前景区{},删除原始图片素材{}个", scenic.getName(), deleteImageSourceCount);
int deleteSourceCount = sourceMapper.deleteUselessSource();
log.info("当前景区{},删除无用素材{}个", scenic.getName(), deleteSourceCount);
});
}

View File

@ -59,6 +59,9 @@
delete from member_source
where member_id = #{userId} and face_id = #{faceId} and is_buy = 0
</delete>
<delete id="deleteUselessSource">
delete from source where id not in (select source_id from member_source where source_id is not null)
</delete>
<select id="list" resultType="com.ycwl.basic.model.pc.source.resp.SourceRespVO">
select so.id, so.scenic_id, de.name as deviceName, device_id, url, so.create_time, so.update_time,sc.`name` as scenicName, so.video_url, so.`type`, so.face_sample_id

View File

@ -61,6 +61,12 @@
delete from member_video
where member_id = #{userId} and face_id = #{faceId} and is_buy = 0
</delete>
<delete id="deleteUselessVideo">
delete from video
where id not in (
select video_id from member_video where video_id is not null
)
</delete>
<select id="list" resultType="com.ycwl.basic.model.pc.video.resp.VideoRespVO">
select v.id, v.scenic_id, template_id, task_id, worker_id, video_url, v.create_time, v.update_time,
s.name scenicName, s.latitude, s.longitude, t.name templateName, t.price templatePrice,t.cover_url templateCoverUrl