逻辑修改
This commit is contained in:
parent
445c0bbf75
commit
f86025bf47
@ -1,9 +1,11 @@
|
||||
package com.ycwl.basic.controller.pc;
|
||||
|
||||
import com.ycwl.basic.model.jwt.JwtInfo;
|
||||
import com.ycwl.basic.model.pc.source.entity.SourceEntity;
|
||||
import com.ycwl.basic.model.pc.source.req.SourceReqQuery;
|
||||
import com.ycwl.basic.service.pc.SourceService;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
import com.ycwl.basic.utils.JwtTokenUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -34,7 +36,8 @@ public class SourceController {
|
||||
@ApiOperation("查询视频源详情")
|
||||
@GetMapping("getDetail/{id}")
|
||||
public ApiResponse getById(@PathVariable Long id) {
|
||||
return sourceService.getById(id);
|
||||
JwtInfo worker = JwtTokenUtil.getWorker();
|
||||
return sourceService.getById(id, worker.getUserId());
|
||||
}
|
||||
@ApiOperation("添加视频源")
|
||||
@PostMapping("/add")
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.ycwl.basic.mapper;
|
||||
|
||||
import com.ycwl.basic.model.pc.source.entity.MemberSourceEntity;
|
||||
import com.ycwl.basic.model.pc.source.entity.SourceEntity;
|
||||
import com.ycwl.basic.model.pc.source.req.SourceReqQuery;
|
||||
import com.ycwl.basic.model.pc.source.resp.SourceRespVO;
|
||||
@ -17,6 +18,7 @@ public interface SourceMapper {
|
||||
List<SourceRespVO> list(SourceReqQuery sourceReqQuery);
|
||||
|
||||
SourceRespVO getById(Long id);
|
||||
SourceRespVO userGetById(Long id, Long userId);
|
||||
|
||||
List<SourceEntity> listBySampleIds(List<Long> sourceIds);
|
||||
|
||||
@ -43,4 +45,8 @@ public interface SourceMapper {
|
||||
List<SourceEntity> listVideoBySampleIds(List<Long> sampleId);
|
||||
|
||||
SourceEntity findBySampleId(Long faceSampleId);
|
||||
|
||||
int addRelation(MemberSourceEntity source);
|
||||
|
||||
List<SourceRespVO> listUser(SourceReqQuery sourceReqQuery);
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
package com.ycwl.basic.model.pc.source.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("member_source")
|
||||
public class MemberSourceEntity {
|
||||
private Long id;
|
||||
private Long memberId;
|
||||
private Integer type;
|
||||
private Long sourceId;
|
||||
private Integer isBuy;
|
||||
}
|
@ -104,7 +104,7 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
sourceReqQuery.setIsBuy(query.getIsBuy());
|
||||
sourceReqQuery.setMemberId(query.getMemberId());
|
||||
sourceReqQuery.setType(sourceType);
|
||||
List<SourceRespVO> list = sourceMapper.list(sourceReqQuery);
|
||||
List<SourceRespVO> list = sourceMapper.listUser(sourceReqQuery);
|
||||
List<GoodsDetailVO> goodsDetailVOList = new ArrayList<>();
|
||||
|
||||
String goodsNamePrefix = "";
|
||||
|
@ -37,8 +37,8 @@ public class SourceServiceImpl implements SourceService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResponse<SourceRespVO> getById(Long id) {
|
||||
return ApiResponse.success(sourceMapper.getById(id));
|
||||
public ApiResponse<SourceRespVO> getById(Long id, Long userId) {
|
||||
return ApiResponse.success(sourceMapper.userGetById(id, userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,7 +15,7 @@ import java.util.List;
|
||||
public interface SourceService {
|
||||
ApiResponse<PageInfo<SourceRespVO>> pageQuery(SourceReqQuery sourceReqQuery);
|
||||
ApiResponse<List<SourceRespVO>> list(SourceReqQuery sourceReqQuery);
|
||||
ApiResponse<SourceRespVO> getById(Long id);
|
||||
ApiResponse<SourceRespVO> getById(Long id, Long userId);
|
||||
ApiResponse<Integer> add(SourceEntity source);
|
||||
ApiResponse<Integer> deleteById(Long id);
|
||||
ApiResponse<Integer> update(SourceEntity source);
|
||||
|
@ -9,6 +9,7 @@ import com.ycwl.basic.mapper.SourceMapper;
|
||||
import com.ycwl.basic.model.pc.device.entity.DeviceConfigEntity;
|
||||
import com.ycwl.basic.model.pc.device.entity.DeviceEntity;
|
||||
import com.ycwl.basic.model.pc.faceSample.resp.FaceSampleRespVO;
|
||||
import com.ycwl.basic.model.pc.source.entity.MemberSourceEntity;
|
||||
import com.ycwl.basic.model.pc.source.entity.SourceEntity;
|
||||
import com.ycwl.basic.storage.StorageFactory;
|
||||
import com.ycwl.basic.storage.adapters.IStorageAdapter;
|
||||
@ -110,7 +111,11 @@ public class VideoPieceGetter {
|
||||
new Date(task.getCreateTime().getTime() - cutPre.multiply(BigDecimal.valueOf(1000)).longValue()),
|
||||
new Date(task.getCreateTime().getTime() + cutPost.multiply(BigDecimal.valueOf(1000)).longValue())
|
||||
);
|
||||
long offset = task.getCreateTime().getTime() - listByDtRange.get(0).getCreateTime().getTime();
|
||||
if (listByDtRange.isEmpty()) {
|
||||
log.warn("没有可用的文件");
|
||||
return;
|
||||
}
|
||||
long offset = task.getCreateTime().getTime() - listByDtRange.get(0).getCreateTime().getTime() - cutPre.multiply(BigDecimal.valueOf(1000)).longValue();
|
||||
FfmpegTask ffmpegTask = new FfmpegTask();
|
||||
ffmpegTask.setFileList(listByDtRange);
|
||||
ffmpegTask.setDuration(duration);
|
||||
@ -128,10 +133,19 @@ public class VideoPieceGetter {
|
||||
SourceEntity imgSource = sourceMapper.findBySampleId(faceSample.getId());
|
||||
SourceEntity sourceEntity = new SourceEntity();
|
||||
sourceEntity.setId(SnowFlakeUtil.getLongId());
|
||||
MemberSourceEntity videoSource = new MemberSourceEntity();
|
||||
MemberSourceEntity imageSource = new MemberSourceEntity();
|
||||
videoSource.setMemberId(task.getMemberId());
|
||||
videoSource.setType(1);
|
||||
videoSource.setIsBuy(0);
|
||||
videoSource.setSourceId(sourceEntity.getId());
|
||||
imageSource.setMemberId(task.getMemberId());
|
||||
imageSource.setType(2);
|
||||
imageSource.setIsBuy(0);
|
||||
if (imgSource != null) {
|
||||
imageSource.setSourceId(imgSource.getId());
|
||||
sourceEntity.setUrl(imgSource.getUrl());
|
||||
sourceEntity.setPosJson(imgSource.getPosJson());
|
||||
sourceEntity.setMemberId(imgSource.getMemberId());
|
||||
}
|
||||
sourceEntity.setVideoUrl(url);
|
||||
sourceEntity.setFaceSampleId(faceSample.getId());
|
||||
@ -140,6 +154,10 @@ public class VideoPieceGetter {
|
||||
sourceEntity.setDeviceId(faceSample.getDeviceId());
|
||||
sourceEntity.setType(1);
|
||||
sourceMapper.add(sourceEntity);
|
||||
sourceMapper.addRelation(videoSource);
|
||||
if (imgSource != null) {
|
||||
sourceMapper.addRelation(imageSource);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean startFfmpegTask(FfmpegTask task) {
|
||||
@ -319,7 +337,7 @@ public class VideoPieceGetter {
|
||||
ffmpegCmd.add("-filter_complex");
|
||||
ffmpegCmd.add(
|
||||
IntStream.range(0, inputFiles.size()).mapToObj(i -> "[" + i + ":v]").collect(Collectors.joining("")) +
|
||||
"concat=n=2:v=1[v]"
|
||||
"concat=n="+inputFiles.size()+":v=1[v]"
|
||||
);
|
||||
ffmpegCmd.add("-map");
|
||||
ffmpegCmd.add("[v]");
|
||||
|
@ -2,15 +2,18 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ycwl.basic.mapper.SourceMapper">
|
||||
<insert id="add">
|
||||
insert into source(id, scenic_id, device_id, member_id, url, video_url, `type`, face_sample_id, pos_json)
|
||||
values (#{id}, #{scenicId}, #{deviceId}, #{memberId}, #{url}, #{videoUrl}, #{type}, #{faceSampleId}, #{posJson})
|
||||
insert into source(id, scenic_id, device_id, url, video_url, `type`, face_sample_id, pos_json)
|
||||
values (#{id}, #{scenicId}, #{deviceId}, #{url}, #{videoUrl}, #{type}, #{faceSampleId}, #{posJson})
|
||||
</insert>
|
||||
<insert id="addRelation">
|
||||
insert member_source(member_id, source_id, is_buy, type)
|
||||
values (#{memberId}, #{sourceId}, #{isBuy}, #{type})
|
||||
</insert>
|
||||
<update id="update">
|
||||
update source
|
||||
<set>
|
||||
<if test="scenicId!= null">scenic_id = #{scenicId}, </if>
|
||||
<if test="deviceId!= null">device_id = #{deviceId}, </if>
|
||||
<if test="memberId!= null">member_id = #{memberId}, </if>
|
||||
<if test="url!= null">url = #{url}, </if>
|
||||
<if test="videoUrl!= null">video_url = #{videoUrl}, </if>
|
||||
<if test="isBuy!=null">is_buy = #{isBuy}, </if>
|
||||
@ -31,7 +34,6 @@
|
||||
<where>
|
||||
<if test="scenicId!= null">and scenic_id = #{scenicId} </if>
|
||||
<if test="deviceId!= null">and device_id = #{deviceId} </if>
|
||||
<if test="memberId!= null">and member_id = #{memberId} </if>
|
||||
<if test="url!= null">and url = #{url} </if>
|
||||
<if test="isBuy!=null">
|
||||
and is_buy = #{isBuy}
|
||||
@ -43,27 +45,33 @@
|
||||
</where>
|
||||
order by so.create_time desc
|
||||
</select>
|
||||
<select id="userGetById" resultType="com.ycwl.basic.model.pc.source.resp.SourceRespVO">
|
||||
select so.id, scenic_id, device_id, ms.member_id, 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
|
||||
where so.id = #{id} and ms.member_id = #{userId}
|
||||
</select>
|
||||
<select id="getById" resultType="com.ycwl.basic.model.pc.source.resp.SourceRespVO">
|
||||
select so.id, scenic_id, device_id, member_id, url, so.create_time, so.update_time,sc.`name` as scenicName
|
||||
select so.id, scenic_id, device_id, url, so.create_time, so.update_time,sc.`name` as scenicName
|
||||
from source so
|
||||
left join scenic sc on sc.id = so.scenic_id
|
||||
where so.id = #{id}
|
||||
</select>
|
||||
<select id="listGroupByType" resultType="com.ycwl.basic.model.pc.source.resp.SourceRespVO">
|
||||
select so.id, scenic_id,sc.name scenicName, sc.longitude ,sc.latitude,so.type,so.is_buy
|
||||
from source so
|
||||
from member_source ms
|
||||
left join source so on ms.source_id = so.id
|
||||
left join scenic sc on sc.id = so.scenic_id
|
||||
<where>
|
||||
<if test="scenicId!= null">and scenic_id = #{scenicId} </if>
|
||||
<if test="memberId!= null">and member_id = #{memberId} </if>
|
||||
<if test="isBuy!=null">
|
||||
and is_buy = #{isBuy}
|
||||
</if>
|
||||
<if test="scenicId!= null">and so.scenic_id = #{scenicId} </if>
|
||||
<if test="memberId!= null">and ms.member_id = #{memberId} </if>
|
||||
<if test="isBuy!=null">and ms.is_buy = #{isBuy}</if>
|
||||
</where>
|
||||
group by so.type
|
||||
</select>
|
||||
<select id="countByMemberId" resultType="java.lang.Integer">
|
||||
select count(1) from source where member_id = #{userId}
|
||||
select count(1) from member_source where member_id = #{userId}
|
||||
</select>
|
||||
<select id="listBySampleIds" resultType="com.ycwl.basic.model.pc.source.entity.SourceEntity">
|
||||
select *
|
||||
@ -88,4 +96,18 @@
|
||||
where type = 2 and face_sample_id = #{faceSampleId}
|
||||
limit 1
|
||||
</select>
|
||||
<select id="listUser" resultType="com.ycwl.basic.model.pc.source.resp.SourceRespVO">
|
||||
select so.id, scenic_id, device_id, 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
|
||||
where
|
||||
ms.member_id = #{memberId}
|
||||
<if test="scenicId!= null">and so.scenic_id = #{scenicId} </if>
|
||||
<if test="deviceId!= null">and so.device_id = #{deviceId} </if>
|
||||
<if test="isBuy!=null">and ms.is_buy = #{isBuy}</if>
|
||||
<if test="type!=null">and ms.type = #{type} </if>
|
||||
<if test="faceId!=null">and FIND_IN_SET(so.face_sample_id, (select face.match_sample_ids from face where id = #{faceId})) </if>
|
||||
order by so.create_time desc
|
||||
</select>
|
||||
</mapper>
|
||||
|
Loading…
x
Reference in New Issue
Block a user