加点缓存

This commit is contained in:
2025-01-02 17:32:46 +08:00
parent f8d4665c59
commit ade7193e64
9 changed files with 125 additions and 104 deletions

View File

@ -0,0 +1,7 @@
package com.ycwl.basic.face.repository;
import org.springframework.stereotype.Component;
@Component
public class FaceRepository {
}

View File

@ -17,6 +17,7 @@ public class GoodsPageVO {
private String goodsName;
@ApiModelProperty("景区id")
private Long scenicId;
private Long faceId;
@ApiModelProperty("景区名称")
private String scenicName;
@ApiModelProperty("商品类型 1:成片视频 2:源素材")

View File

@ -35,6 +35,7 @@ public class SourceRespVO {
*/
@ApiModelProperty("来源设备id")
private Long deviceId;
private Long faceId;
@ApiModelProperty("原素材类型1视频2图像")
private Integer type;
/**

View File

@ -29,6 +29,7 @@ public class VideoRespVO {
*/
@ApiModelProperty("用户id")
private Long memberId;
private Long faceId;
/**
* 模版id
*/

View File

@ -68,6 +68,7 @@ public class GoodsServiceImpl implements GoodsService {
goodsPageVO.setScenicId(videoRespVO.getScenicId());
goodsPageVO.setScenicName(videoRespVO.getScenicName());
goodsPageVO.setGoodsType(0);
goodsPageVO.setFaceId(videoRespVO.getFaceId());
goodsPageVO.setGoodsId(videoRespVO.getId());
goodsPageVO.setTemplateName(videoRespVO.getTemplateName());
goodsPageVO.setTemplateCoverUrl(videoRespVO.getTemplateCoverUrl());
@ -81,8 +82,13 @@ public class GoodsServiceImpl implements GoodsService {
sourceReqQuery.setMemberId(Long.valueOf(BaseContextHandler.getUserId()));
//查询源素材
List<SourceRespVO> sourceList = sourceMapper.queryByRelation(sourceReqQuery);
sourceList.stream().collect(Collectors.groupingBy(SourceRespVO::getType)).forEach((type, value) -> {
List<GoodsPageVO> sourceGoods = sourceList.stream().collect(Collectors.groupingBy(SourceRespVO::getFaceId)).entrySet().stream().flatMap((faceEntry) -> {
Long faceId = faceEntry.getKey();
List<SourceRespVO> goods = faceEntry.getValue();
return goods.stream().collect(Collectors.groupingBy(SourceRespVO::getType)).entrySet().stream().map((typeEntry) -> {
Integer type = typeEntry.getKey();
GoodsPageVO goodsPageVO = new GoodsPageVO();
goodsPageVO.setFaceId(faceId);
if (type == 1) {
goodsPageVO.setGoodsName("原片集");
goodsPageVO.setGoodsType(1);
@ -91,9 +97,16 @@ public class GoodsServiceImpl implements GoodsService {
goodsPageVO.setGoodsType(2);
}
goodsPageVO.setScenicId(query.getScenicId());
goodsList.add(goodsPageVO);
return goodsPageVO;
});
}).collect(Collectors.toList());
if (!sourceGoods.isEmpty()) {
if (goodsList.size() > 2) {
goodsList.addAll(2, sourceGoods);
} else {
goodsList.addAll(sourceGoods);
}
}
return ApiResponse.success(goodsList);
}

View File

@ -78,17 +78,14 @@ public class VideoPieceGetter {
queue.add(task);
}
@Scheduled(fixedDelay = 1000L)
@Scheduled(fixedRate = 2000L)
public void doTask() {
Task task = queue.poll();
if (task == null) {
return;
}
log.info("poll task: {}", task);
if (!task.getType().equalsIgnoreCase("normal")) {
task.getCallback().onInvoke();
return;
}
if (task.getType().equalsIgnoreCase("normal")) {
task.getFaceSampleId().parallelStream().forEach(faceSampleId -> {
FaceSampleRespVO faceSample = faceSampleMapper.getById(faceSampleId);
DeviceEntity device = deviceRepository.getDevice(faceSample.getDeviceId());
@ -177,7 +174,10 @@ public class VideoPieceGetter {
sourceMapper.add(sourceEntity);
sourceMapper.addRelation(videoSource);
});
}
if (null != task.getCallback()) {
task.getCallback().onInvoke();
}
}
public boolean startFfmpegTask(FfmpegTask task) {

View File

@ -55,8 +55,6 @@ mybatis-plus:
# 开启驼峰命名法
map-underscore-to-camel-case: true
use-generated-keys: true
# 这个配置会将执行的sql打印出来在开发或测试的时候可以用
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# 指定使用的日志配置文件
logging:
config: classpath:logback-spring.xml

View File

@ -124,7 +124,7 @@
order by so.create_time desc
</select>
<select id="queryByRelation" resultType="com.ycwl.basic.model.pc.source.resp.SourceRespVO">
select so.id, ms.scenic_id, ms.type, so.url, so.create_time, so.update_time,sc.`name` as scenicName
select so.id, ms.face_id, ms.scenic_id, ms.type, so.url, so.create_time, so.update_time,sc.`name` as scenicName
from member_source ms
left join source so on ms.source_id = so.id
left join scenic sc on sc.id = so.scenic_id

View File

@ -85,7 +85,7 @@
select * from video where task_id = #{taskId} limit 1
</select>
<select id="queryByRelation" resultType="com.ycwl.basic.model.pc.video.resp.VideoRespVO">
select v.id, mv.scenic_id, v.template_id, mv.task_id, worker_id, video_url, v.create_time, v.update_time,
select v.id, mv.scenic_id, v.template_id, mv.task_id, mv.face_id, worker_id, video_url, v.create_time, v.update_time,
s.name scenicName, t.name templateName, t.price templatePrice,t.cover_url templateCoverUrl,mv.is_buy
from member_video mv
left join video v on mv.video_id = v.id