修改
This commit is contained in:
parent
38c4b553bc
commit
1aa1ae5e2b
@ -11,6 +11,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:longbinbin
|
* @Author:longbinbin
|
||||||
* @Date:2024/12/4 17:03
|
* @Date:2024/12/4 17:03
|
||||||
@ -39,8 +41,22 @@ AppFaceController {
|
|||||||
return faceService.faceUpload(file,scenicId);
|
return faceService.faceUpload(file,scenicId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/scenic/{scenicId}/list")
|
||||||
|
public ApiResponse<List<FaceRespVO>> list(@PathVariable("scenicId") String scenicId) {
|
||||||
|
JwtInfo worker = JwtTokenUtil.getWorker();
|
||||||
|
Long userId = worker.getUserId();
|
||||||
|
List<FaceRespVO> list = faceService.listByUser(userId, scenicId);
|
||||||
|
return ApiResponse.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/{faceId}")
|
@GetMapping("/{faceId}")
|
||||||
public ApiResponse<FaceRespVO> getById(@PathVariable("faceId") Long faceId) {
|
public ApiResponse<FaceRespVO> getById(@PathVariable("faceId") Long faceId) {
|
||||||
return faceService.getById(faceId);
|
return faceService.getById(faceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/{faceId}/match")
|
||||||
|
public ApiResponse match(@PathVariable("faceId") Long faceId) {
|
||||||
|
faceService.matchFaceId(faceId);
|
||||||
|
return ApiResponse.success("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,10 @@ public class SourceController {
|
|||||||
JwtInfo worker = JwtTokenUtil.getWorker();
|
JwtInfo worker = JwtTokenUtil.getWorker();
|
||||||
return sourceService.getById(id, worker.getUserId());
|
return sourceService.getById(id, worker.getUserId());
|
||||||
}
|
}
|
||||||
|
@PostMapping("/{id}/cutVideo")
|
||||||
|
public ApiResponse cutVideo(@PathVariable("id") Long id) {
|
||||||
|
return sourceService.cutVideo(id);
|
||||||
|
}
|
||||||
@ApiOperation("添加视频源")
|
@ApiOperation("添加视频源")
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
public ApiResponse add(@RequestBody SourceEntity source) {
|
public ApiResponse add(@RequestBody SourceEntity source) {
|
||||||
|
@ -78,21 +78,22 @@ public class ViidController {
|
|||||||
DeviceIdObject deviceIdObject = req.getRegisterObject();
|
DeviceIdObject deviceIdObject = req.getRegisterObject();
|
||||||
log.info("注册的设备信息:{}", deviceIdObject);
|
log.info("注册的设备信息:{}", deviceIdObject);
|
||||||
// 保存设备注册时间
|
// 保存设备注册时间
|
||||||
DeviceEntity device = deviceRepository.getDeviceByDeviceNo(deviceIdObject.getDeviceId());
|
String deviceId = deviceIdObject.getDeviceId();
|
||||||
|
DeviceEntity device = deviceRepository.getDeviceByDeviceNo(deviceId);
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
device = new DeviceEntity();
|
device = new DeviceEntity();
|
||||||
device.setName("未配置设备");
|
device.setName("未配置设备");
|
||||||
device.setNo(deviceIdObject.getDeviceId());
|
device.setNo(deviceId);
|
||||||
device.setOnline(1);
|
device.setOnline(1);
|
||||||
}
|
}
|
||||||
device.setKeepaliveAt(new Date());
|
device.setKeepaliveAt(new Date());
|
||||||
device.setIpAddr(IpUtils.getIpAddr(request));
|
device.setIpAddr(IpUtils.getIpAddr(request));
|
||||||
if (device.getId() != null) {
|
if (device.getId() != null) {
|
||||||
deviceMapper.updateEntity(device);
|
deviceMapper.updateEntity(device);
|
||||||
deviceRepository.clearDeviceCache(device.getId());
|
|
||||||
} else {
|
} else {
|
||||||
device.setId(SnowFlakeUtil.getLongId());
|
device.setId(SnowFlakeUtil.getLongId());
|
||||||
deviceMapper.addEntity(device);
|
deviceMapper.addEntity(device);
|
||||||
|
deviceRepository.clearDeviceCache(deviceId);
|
||||||
}
|
}
|
||||||
return new VIIDBaseResp(
|
return new VIIDBaseResp(
|
||||||
new ResponseStatusObject(serverId, "/VIID/System/Register", "0", "注册成功", sdfTime.format(new Date()))
|
new ResponseStatusObject(serverId, "/VIID/System/Register", "0", "注册成功", sdfTime.format(new Date()))
|
||||||
@ -126,6 +127,7 @@ public class ViidController {
|
|||||||
device.setIpAddr(IpUtils.getIpAddr(request));
|
device.setIpAddr(IpUtils.getIpAddr(request));
|
||||||
device.setId(SnowFlakeUtil.getLongId());
|
device.setId(SnowFlakeUtil.getLongId());
|
||||||
deviceMapper.addEntity(device);
|
deviceMapper.addEntity(device);
|
||||||
|
deviceRepository.clearDeviceCache(deviceId);
|
||||||
} else {
|
} else {
|
||||||
deviceRepository.updateOnlineStatus(device.getId(), IpUtils.getIpAddr(request), 1, new Date());
|
deviceRepository.updateOnlineStatus(device.getId(), IpUtils.getIpAddr(request), 1, new Date());
|
||||||
}
|
}
|
||||||
|
@ -29,4 +29,6 @@ public interface FaceMapper {
|
|||||||
int finishedJourney(Long faceId);
|
int finishedJourney(Long faceId);
|
||||||
|
|
||||||
FaceRespVO findLastFaceByUserId(String userId);
|
FaceRespVO findLastFaceByUserId(String userId);
|
||||||
|
|
||||||
|
List<FaceRespVO> listByScenicAndUserId(String scenicId, Long userId);
|
||||||
}
|
}
|
||||||
|
@ -65,4 +65,6 @@ public interface SourceMapper {
|
|||||||
List<SourceEntity> listVideoByFaceRelation(Long memberId, Long faceId);
|
List<SourceEntity> listVideoByFaceRelation(Long memberId, Long faceId);
|
||||||
|
|
||||||
List<SourceEntity> listImageByFaceRelation(Long memberId, Long faceId);
|
List<SourceEntity> listImageByFaceRelation(Long memberId, Long faceId);
|
||||||
|
|
||||||
|
SourceEntity getEntity(Long id);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ public class WvpSyncReqVo {
|
|||||||
public static class DeviceItem {
|
public static class DeviceItem {
|
||||||
String deviceNo;
|
String deviceNo;
|
||||||
String channelNo;
|
String channelNo;
|
||||||
|
String ip;
|
||||||
Integer online;
|
Integer online;
|
||||||
Date keepaliveAt;
|
Date keepaliveAt;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public class DeviceRepository {
|
|||||||
if (null != device) {
|
if (null != device) {
|
||||||
redisTemplate.opsForValue().set(String.format(DEVICE_CACHE_KEY, deviceNo), JSONObject.toJSONString(device));
|
redisTemplate.opsForValue().set(String.format(DEVICE_CACHE_KEY, deviceNo), JSONObject.toJSONString(device));
|
||||||
} else {
|
} else {
|
||||||
redisTemplate.opsForValue().set(String.format(DEVICE_CACHE_KEY, deviceNo), "null", 60 * 60L, TimeUnit.SECONDS);
|
redisTemplate.opsForValue().set(String.format(DEVICE_CACHE_KEY, deviceNo), "null", 60L, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
@ -64,6 +64,18 @@ public class DeviceRepository {
|
|||||||
return deviceConfig;
|
return deviceConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean clearDeviceCache(String deviceNo) {
|
||||||
|
if (deviceNo == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (redisTemplate.hasKey(String.format(DEVICE_CACHE_KEY, deviceNo))) {
|
||||||
|
DeviceEntity device = getDeviceByDeviceNo(deviceNo);
|
||||||
|
redisTemplate.delete(String.format(DEVICE_CACHE_KEY, device.getNo()));
|
||||||
|
clearDeviceCache(device.getId());
|
||||||
|
}
|
||||||
|
redisTemplate.delete(String.format(DEVICE_CACHE_KEY, deviceNo));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
public boolean clearDeviceCache(Long deviceId) {
|
public boolean clearDeviceCache(Long deviceId) {
|
||||||
if (redisTemplate.hasKey(String.format(DEVICE_CACHE_KEY, deviceId))) {
|
if (redisTemplate.hasKey(String.format(DEVICE_CACHE_KEY, deviceId))) {
|
||||||
DeviceEntity device = getDevice(deviceId);
|
DeviceEntity device = getDevice(deviceId);
|
||||||
|
@ -52,4 +52,8 @@ public class SourceRepository {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SourceEntity getSource(Long id) {
|
||||||
|
return sourceMapper.getEntity(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ public class DeviceServiceImpl implements DeviceService {
|
|||||||
if (device != null) {
|
if (device != null) {
|
||||||
device.setOnline(deviceItem.getOnline());
|
device.setOnline(deviceItem.getOnline());
|
||||||
device.setKeepaliveAt(deviceItem.getKeepaliveAt());
|
device.setKeepaliveAt(deviceItem.getKeepaliveAt());
|
||||||
deviceRepository.updateOnlineStatus(device.getId(), null, 1, deviceItem.getKeepaliveAt());
|
deviceRepository.updateOnlineStatus(device.getId(), deviceItem.getIp(), 1, deviceItem.getKeepaliveAt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import com.github.pagehelper.PageHelper;
|
|||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.ycwl.basic.biz.OrderBiz;
|
import com.ycwl.basic.biz.OrderBiz;
|
||||||
import com.ycwl.basic.enums.StatisticEnum;
|
import com.ycwl.basic.enums.StatisticEnum;
|
||||||
import com.ycwl.basic.exception.BaseException;
|
|
||||||
import com.ycwl.basic.mapper.FaceSampleMapper;
|
import com.ycwl.basic.mapper.FaceSampleMapper;
|
||||||
import com.ycwl.basic.mapper.SourceMapper;
|
import com.ycwl.basic.mapper.SourceMapper;
|
||||||
import com.ycwl.basic.mapper.StatisticsMapper;
|
import com.ycwl.basic.mapper.StatisticsMapper;
|
||||||
@ -30,7 +29,6 @@ import com.ycwl.basic.task.VideoPieceGetter;
|
|||||||
import com.ycwl.basic.utils.*;
|
import com.ycwl.basic.utils.*;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@ -129,16 +127,8 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
String suffix = originalFilename.split("\\.", 2)[1];
|
String suffix = originalFilename.split("\\.", 2)[1];
|
||||||
String fileName = UUID.randomUUID().toString() + "." + suffix;
|
String fileName = UUID.randomUUID().toString() + "." + suffix;
|
||||||
String faceUrl = adapter.uploadFile(file, filePath, fileName);
|
String faceUrl = adapter.uploadFile(file, filePath, fileName);
|
||||||
SearchFaceRespVo scenicDbSearchResult = faceService.searchFace(scenicId, faceUrl);
|
|
||||||
if (scenicDbSearchResult == null) {
|
|
||||||
adapter.deleteFile(filePath, fileName);
|
|
||||||
throw new BaseException("人脸照片校验失败,请重新上传");
|
|
||||||
}
|
|
||||||
// 2、通过人脸查找用户库
|
|
||||||
Long newFaceId = SnowFlakeUtil.getLongId();
|
Long newFaceId = SnowFlakeUtil.getLongId();
|
||||||
FaceEntity faceEntity = new FaceEntity();
|
Long oldFaceId = null;
|
||||||
faceEntity.setScore(scenicDbSearchResult.getScore());
|
|
||||||
faceEntity.setMatchResult(scenicDbSearchResult.getSearchResultJson());
|
|
||||||
SearchFaceRespVo userDbSearchResult = faceService.searchFace(USER_FACE_DB_NAME+scenicId, faceUrl);
|
SearchFaceRespVo userDbSearchResult = faceService.searchFace(USER_FACE_DB_NAME+scenicId, faceUrl);
|
||||||
float strictScore = 0.6F;
|
float strictScore = 0.6F;
|
||||||
if (userDbSearchResult == null) {
|
if (userDbSearchResult == null) {
|
||||||
@ -152,24 +142,63 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
faceService.addFaceSample(USER_FACE_DB_NAME+scenicId, newFaceId.toString(), faceUrl, newFaceId.toString());
|
faceService.addFaceSample(USER_FACE_DB_NAME+scenicId, newFaceId.toString(), faceUrl, newFaceId.toString());
|
||||||
} else {
|
} else {
|
||||||
// 有匹配结果,且能匹配旧的数据
|
// 有匹配结果,且能匹配旧的数据
|
||||||
Optional<Long> faceAny = userDbSearchResult.getSampleListIds().stream().filter(oldFaceId -> {
|
Optional<Long> faceAny = userDbSearchResult.getSampleListIds().stream().filter(_faceId -> {
|
||||||
FaceEntity face = faceRepository.getFace(oldFaceId);
|
FaceEntity face = faceRepository.getFace(_faceId);
|
||||||
if (face == null) {
|
if (face == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return face.getScenicId().equals(scenicId);
|
return face.getScenicId().equals(scenicId);
|
||||||
}).findAny();
|
}).findAny();
|
||||||
if (faceAny.isPresent()) {
|
if (faceAny.isPresent()) {
|
||||||
Long oldFaceId = faceAny.get();
|
oldFaceId = faceAny.get();
|
||||||
FaceRespVO oldFace = faceMapper.getById(oldFaceId);
|
FaceRespVO oldFace = faceMapper.getById(oldFaceId);
|
||||||
if (oldFace == null) {
|
if (oldFace == null) {
|
||||||
faceService.deleteFaceSample(USER_FACE_DB_NAME+scenicId, oldFaceId.toString());
|
faceService.deleteFaceSample(USER_FACE_DB_NAME+scenicId, oldFaceId.toString());
|
||||||
faceService.addFaceSample(USER_FACE_DB_NAME+scenicId, newFaceId.toString(), faceUrl, newFaceId.toString());
|
faceService.addFaceSample(USER_FACE_DB_NAME+scenicId, newFaceId.toString(), faceUrl, newFaceId.toString());
|
||||||
|
oldFaceId = null;
|
||||||
} else {
|
} else {
|
||||||
faceEntity.setId(oldFaceId);
|
newFaceId = oldFaceId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (oldFaceId==null) {
|
||||||
|
//新增人脸
|
||||||
|
FaceEntity faceEntity = new FaceEntity();
|
||||||
|
faceEntity.setCreateAt(new Date());
|
||||||
|
faceEntity.setScenicId(scenicId);
|
||||||
|
faceEntity.setMemberId(userId);
|
||||||
|
faceEntity.setFaceUrl(faceUrl);
|
||||||
|
faceEntity.setId(newFaceId);
|
||||||
|
faceMapper.add(faceEntity);
|
||||||
|
}
|
||||||
|
StatisticsRecordAddReq statisticsRecordAddReq = new StatisticsRecordAddReq();
|
||||||
|
statisticsRecordAddReq.setMemberId(userId);
|
||||||
|
statisticsRecordAddReq.setType(StatisticEnum.UPLOAD_FACE.code);
|
||||||
|
statisticsRecordAddReq.setScenicId(scenicId);
|
||||||
|
statisticsRecordAddReq.setMorphId(newFaceId);
|
||||||
|
statisticsMapper.addStatisticsRecord(statisticsRecordAddReq);
|
||||||
|
FaceRecognizeResp resp = new FaceRecognizeResp();
|
||||||
|
resp.setUrl(faceUrl);
|
||||||
|
resp.setFaceId(newFaceId);
|
||||||
|
matchFaceId(newFaceId);
|
||||||
|
return ApiResponse.success(resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<FaceRespVO> listByUser(Long userId, String scenicId) {
|
||||||
|
return faceMapper.listByScenicAndUserId(scenicId, userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SearchFaceRespVo matchFaceId(Long faceId) {
|
||||||
|
FaceEntity face = faceRepository.getFace(faceId);
|
||||||
|
if (face == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
SearchFaceRespVo scenicDbSearchResult = faceService.searchFace(face.getScenicId(), face.getFaceUrl());
|
||||||
|
FaceEntity faceEntity = new FaceEntity();
|
||||||
|
faceEntity.setScore(scenicDbSearchResult.getScore());
|
||||||
|
faceEntity.setMatchResult(scenicDbSearchResult.getSearchResultJson());
|
||||||
if (scenicDbSearchResult.getFirstMatchRate() != null) {
|
if (scenicDbSearchResult.getFirstMatchRate() != null) {
|
||||||
faceEntity.setFirstMatchRate(BigDecimal.valueOf(scenicDbSearchResult.getFirstMatchRate()));
|
faceEntity.setFirstMatchRate(BigDecimal.valueOf(scenicDbSearchResult.getFirstMatchRate()));
|
||||||
}
|
}
|
||||||
@ -177,38 +206,20 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
faceEntity.setMatchSampleIds(scenicDbSearchResult.getSampleListIds().stream().map(String::valueOf).collect(Collectors.joining(",")));
|
faceEntity.setMatchSampleIds(scenicDbSearchResult.getSampleListIds().stream().map(String::valueOf).collect(Collectors.joining(",")));
|
||||||
}
|
}
|
||||||
faceEntity.setCreateAt(new Date());
|
faceEntity.setCreateAt(new Date());
|
||||||
faceEntity.setScenicId(scenicId);
|
faceEntity.setScenicId(face.getScenicId());
|
||||||
faceEntity.setMemberId(userId);
|
faceEntity.setMemberId(face.getMemberId());
|
||||||
faceEntity.setFaceUrl(faceUrl);
|
faceEntity.setFaceUrl(face.getFaceUrl());
|
||||||
List<Long> sampleListIds = scenicDbSearchResult.getSampleListIds();
|
List<Long> sampleListIds = scenicDbSearchResult.getSampleListIds();
|
||||||
if (faceEntity.getId()==null) {
|
|
||||||
//新增人脸
|
|
||||||
faceEntity.setId(newFaceId);
|
|
||||||
faceMapper.add(faceEntity);
|
|
||||||
} else {
|
|
||||||
//2、更新人脸
|
|
||||||
faceMapper.update(faceEntity);
|
|
||||||
faceRepository.clearFaceCache(faceEntity.getId());
|
|
||||||
}
|
|
||||||
StatisticsRecordAddReq statisticsRecordAddReq = new StatisticsRecordAddReq();
|
|
||||||
statisticsRecordAddReq.setMemberId(userId);
|
|
||||||
statisticsRecordAddReq.setType(StatisticEnum.UPLOAD_FACE.code);
|
|
||||||
statisticsRecordAddReq.setScenicId(scenicId);
|
|
||||||
statisticsRecordAddReq.setMorphId(faceEntity.getId());
|
|
||||||
statisticsMapper.addStatisticsRecord(statisticsRecordAddReq);
|
|
||||||
FaceRecognizeResp resp = new FaceRecognizeResp();
|
|
||||||
resp.setUrl(faceUrl);
|
|
||||||
resp.setFaceId(faceEntity.getId());
|
|
||||||
if (sampleListIds != null && !sampleListIds.isEmpty()) {// 匹配原片:照片
|
if (sampleListIds != null && !sampleListIds.isEmpty()) {// 匹配原片:照片
|
||||||
List<SourceEntity> sourceEntities = sourceMapper.listBySampleIds(sampleListIds);
|
List<SourceEntity> sourceEntities = sourceMapper.listBySampleIds(sampleListIds);
|
||||||
List<MemberSourceEntity> memberSourceEntityList = sourceEntities.stream().map(sourceEntity -> {
|
List<MemberSourceEntity> memberSourceEntityList = sourceEntities.stream().map(sourceEntity -> {
|
||||||
MemberSourceEntity memberSourceEntity = new MemberSourceEntity();
|
MemberSourceEntity memberSourceEntity = new MemberSourceEntity();
|
||||||
memberSourceEntity.setScenicId(scenicId);
|
memberSourceEntity.setScenicId(face.getScenicId());
|
||||||
memberSourceEntity.setFaceId(faceEntity.getId());
|
memberSourceEntity.setFaceId(face.getId());
|
||||||
memberSourceEntity.setMemberId(userId);
|
memberSourceEntity.setMemberId(face.getMemberId());
|
||||||
memberSourceEntity.setSourceId(sourceEntity.getId());
|
memberSourceEntity.setSourceId(sourceEntity.getId());
|
||||||
memberSourceEntity.setType(sourceEntity.getType());
|
memberSourceEntity.setType(sourceEntity.getType());
|
||||||
IsBuyRespVO isBuy = orderBiz.isBuy(userId, scenicId, sourceEntity.getType(), sourceEntity.getId());
|
IsBuyRespVO isBuy = orderBiz.isBuy(face.getMemberId(), face.getScenicId(), sourceEntity.getType(), sourceEntity.getId());
|
||||||
if (isBuy.isBuy()) { // 如果用户买过
|
if (isBuy.isBuy()) { // 如果用户买过
|
||||||
memberSourceEntity.setIsBuy(1);
|
memberSourceEntity.setIsBuy(1);
|
||||||
} else if (isBuy.isFree()) { // 全免费逻辑
|
} else if (isBuy.isFree()) { // 全免费逻辑
|
||||||
@ -224,11 +235,13 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
VideoPieceGetter.Task task = new VideoPieceGetter.Task();
|
VideoPieceGetter.Task task = new VideoPieceGetter.Task();
|
||||||
task.faceId = faceEntity.getId();
|
task.faceId = faceEntity.getId();
|
||||||
task.faceSampleIds = sampleListIds;
|
task.faceSampleIds = sampleListIds;
|
||||||
task.memberId = userId;
|
task.memberId = face.getMemberId();
|
||||||
VideoPieceGetter.addTask(task);
|
VideoPieceGetter.addTask(task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ApiResponse.success(resp);
|
faceMapper.update(faceEntity);
|
||||||
|
faceRepository.clearFaceCache(faceEntity.getId());
|
||||||
|
return scenicDbSearchResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,15 @@ import com.ycwl.basic.mapper.SourceMapper;
|
|||||||
import com.ycwl.basic.model.pc.source.entity.SourceEntity;
|
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.req.SourceReqQuery;
|
||||||
import com.ycwl.basic.model.pc.source.resp.SourceRespVO;
|
import com.ycwl.basic.model.pc.source.resp.SourceRespVO;
|
||||||
|
import com.ycwl.basic.repository.SourceRepository;
|
||||||
import com.ycwl.basic.service.pc.SourceService;
|
import com.ycwl.basic.service.pc.SourceService;
|
||||||
|
import com.ycwl.basic.task.VideoPieceGetter;
|
||||||
import com.ycwl.basic.utils.ApiResponse;
|
import com.ycwl.basic.utils.ApiResponse;
|
||||||
import com.ycwl.basic.utils.SnowFlakeUtil;
|
import com.ycwl.basic.utils.SnowFlakeUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,6 +25,8 @@ import java.util.List;
|
|||||||
public class SourceServiceImpl implements SourceService {
|
public class SourceServiceImpl implements SourceService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SourceMapper sourceMapper;
|
private SourceMapper sourceMapper;
|
||||||
|
@Autowired
|
||||||
|
private SourceRepository sourceRepository;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApiResponse<PageInfo<SourceRespVO>> pageQuery(SourceReqQuery sourceReqQuery) {
|
public ApiResponse<PageInfo<SourceRespVO>> pageQuery(SourceReqQuery sourceReqQuery) {
|
||||||
@ -71,4 +76,16 @@ public class SourceServiceImpl implements SourceService {
|
|||||||
return ApiResponse.fail("修改失败");
|
return ApiResponse.fail("修改失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApiResponse cutVideo(Long id) {
|
||||||
|
SourceEntity source = sourceRepository.getSource(id);
|
||||||
|
if (Integer.valueOf(2).equals(source.getType())) {
|
||||||
|
// 下载切片
|
||||||
|
VideoPieceGetter.Task task = new VideoPieceGetter.Task();
|
||||||
|
task.faceSampleIds = Collections.singletonList(source.getFaceSampleId());
|
||||||
|
VideoPieceGetter.addTask(task);
|
||||||
|
}
|
||||||
|
return ApiResponse.success("任务已下发");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo;
|
|||||||
import com.ycwl.basic.model.pc.face.entity.FaceEntity;
|
import com.ycwl.basic.model.pc.face.entity.FaceEntity;
|
||||||
import com.ycwl.basic.model.pc.face.req.FaceReqQuery;
|
import com.ycwl.basic.model.pc.face.req.FaceReqQuery;
|
||||||
import com.ycwl.basic.model.pc.face.resp.FaceRespVO;
|
import com.ycwl.basic.model.pc.face.resp.FaceRespVO;
|
||||||
|
import com.ycwl.basic.model.task.resp.SearchFaceRespVo;
|
||||||
import com.ycwl.basic.utils.ApiResponse;
|
import com.ycwl.basic.utils.ApiResponse;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@ -22,4 +23,8 @@ public interface FaceService {
|
|||||||
ApiResponse<Integer> deleteByIds(List<Long> ids);
|
ApiResponse<Integer> deleteByIds(List<Long> ids);
|
||||||
|
|
||||||
ApiResponse faceUpload(MultipartFile file, Long scrnicId);
|
ApiResponse faceUpload(MultipartFile file, Long scrnicId);
|
||||||
|
|
||||||
|
List<FaceRespVO> listByUser(Long userId, String scenicId);
|
||||||
|
SearchFaceRespVo matchFaceId(Long faceId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,4 +20,5 @@ public interface SourceService {
|
|||||||
ApiResponse<Integer> deleteById(Long id);
|
ApiResponse<Integer> deleteById(Long id);
|
||||||
ApiResponse<Integer> update(SourceEntity source);
|
ApiResponse<Integer> update(SourceEntity source);
|
||||||
|
|
||||||
|
ApiResponse cutVideo(Long id);
|
||||||
}
|
}
|
||||||
|
@ -265,9 +265,7 @@ public class TaskFaceServiceImpl implements TaskFaceService {
|
|||||||
sampleStoreDay = 3;
|
sampleStoreDay = 3;
|
||||||
}
|
}
|
||||||
Date thatDay = DateUtil.offsetDay(new Date(), -sampleStoreDay);
|
Date thatDay = DateUtil.offsetDay(new Date(), -sampleStoreDay);
|
||||||
Date dayStart = DateUtil.beginOfDay(thatDay);
|
|
||||||
Date dayEnd = DateUtil.endOfDay(thatDay);
|
Date dayEnd = DateUtil.endOfDay(thatDay);
|
||||||
query.setStartTime(dayStart);
|
|
||||||
query.setEndTime(dayEnd);
|
query.setEndTime(dayEnd);
|
||||||
IAcsClient client = getClient();
|
IAcsClient client = getClient();
|
||||||
faceSampleMapper.list(query).forEach(faceSampleEntity -> {
|
faceSampleMapper.list(query).forEach(faceSampleEntity -> {
|
||||||
@ -279,6 +277,8 @@ public class TaskFaceServiceImpl implements TaskFaceService {
|
|||||||
client.getAcsResponse(request);
|
client.getAcsResponse(request);
|
||||||
} catch (ClientException e) {
|
} catch (ClientException e) {
|
||||||
return;
|
return;
|
||||||
|
} finally {
|
||||||
|
faceSampleMapper.deleteById(faceSampleEntity.getId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,6 @@ public class DownloadNotificationTasker {
|
|||||||
}
|
}
|
||||||
MemberRespVO member = memberMapper.getById(item.getMemberId());
|
MemberRespVO member = memberMapper.getById(item.getMemberId());
|
||||||
MpConfigEntity scenicMp = scenicRepository.getScenicMpConfig(member.getScenicId());
|
MpConfigEntity scenicMp = scenicRepository.getScenicMpConfig(member.getScenicId());
|
||||||
TemplateRespVO template = templateRepository.getTemplate(item.getTemplateId());
|
|
||||||
// 发送模板消息
|
// 发送模板消息
|
||||||
String templateId = scenicRepository.getVideoDownloadTemplateId(item.getScenicId());
|
String templateId = scenicRepository.getVideoDownloadTemplateId(item.getScenicId());
|
||||||
if (StringUtils.isBlank(templateId)) {
|
if (StringUtils.isBlank(templateId)) {
|
||||||
@ -57,7 +56,7 @@ public class DownloadNotificationTasker {
|
|||||||
}
|
}
|
||||||
log.info("发送模板消息");
|
log.info("发送模板消息");
|
||||||
ScenicEntity scenic = scenicRepository.getScenic(item.getScenicId());
|
ScenicEntity scenic = scenicRepository.getScenic(item.getScenicId());
|
||||||
String title = "您在【" + template.getName() + "】的专属影像";
|
String title = "您在【" + scenic.getName() + "】的专属影像";
|
||||||
String page = "pages/videoSynthesis/buy?scenicId=" + item.getScenicId() + "&faceId=" + item.getFaceId() + "&id=" + item.getVideoId();
|
String page = "pages/videoSynthesis/buy?scenicId=" + item.getScenicId() + "&faceId=" + item.getFaceId() + "&id=" + item.getVideoId();
|
||||||
/**
|
/**
|
||||||
* 景区 {{thing1.DATA}}
|
* 景区 {{thing1.DATA}}
|
||||||
|
@ -118,7 +118,7 @@ public class VideoPieceGetter {
|
|||||||
DeviceConfigEntity config = deviceRepository.getDeviceConfig(faceSample.getDeviceId());
|
DeviceConfigEntity config = deviceRepository.getDeviceConfig(faceSample.getDeviceId());
|
||||||
|
|
||||||
SourceEntity source = sourceMapper.querySameVideo(faceSample.getId(), device.getId());
|
SourceEntity source = sourceMapper.querySameVideo(faceSample.getId(), device.getId());
|
||||||
IsBuyRespVO isBuy = orderBiz.isBuy(task.getMemberId(), faceSample.getScenicId(), 1, task.getFaceId());
|
|
||||||
if (source == null) {
|
if (source == null) {
|
||||||
BigDecimal cutPre = BigDecimal.valueOf(5L);
|
BigDecimal cutPre = BigDecimal.valueOf(5L);
|
||||||
BigDecimal cutPost = BigDecimal.valueOf(4L);
|
BigDecimal cutPost = BigDecimal.valueOf(4L);
|
||||||
@ -177,12 +177,6 @@ public class VideoPieceGetter {
|
|||||||
SourceEntity sourceEntity = new SourceEntity();
|
SourceEntity sourceEntity = new SourceEntity();
|
||||||
sourceEntity.setId(SnowFlakeUtil.getLongId());
|
sourceEntity.setId(SnowFlakeUtil.getLongId());
|
||||||
sourceEntity.setCreateTime(faceSample.getCreateAt());
|
sourceEntity.setCreateTime(faceSample.getCreateAt());
|
||||||
MemberSourceEntity videoSource = new MemberSourceEntity();
|
|
||||||
videoSource.setMemberId(task.getMemberId());
|
|
||||||
videoSource.setType(1);
|
|
||||||
videoSource.setFaceId(task.getFaceId());
|
|
||||||
videoSource.setScenicId(faceSample.getScenicId());
|
|
||||||
videoSource.setSourceId(sourceEntity.getId());
|
|
||||||
if (imgSource != null) {
|
if (imgSource != null) {
|
||||||
sourceEntity.setUrl(imgSource.getUrl());
|
sourceEntity.setUrl(imgSource.getUrl());
|
||||||
sourceEntity.setPosJson(imgSource.getPosJson());
|
sourceEntity.setPosJson(imgSource.getPosJson());
|
||||||
@ -192,26 +186,14 @@ public class VideoPieceGetter {
|
|||||||
sourceEntity.setScenicId(faceSample.getScenicId());
|
sourceEntity.setScenicId(faceSample.getScenicId());
|
||||||
sourceEntity.setDeviceId(faceSample.getDeviceId());
|
sourceEntity.setDeviceId(faceSample.getDeviceId());
|
||||||
sourceEntity.setType(1);
|
sourceEntity.setType(1);
|
||||||
if (isBuy.isBuy()) { // 如果用户买过
|
if (task.memberId != null && task.faceId != null) {
|
||||||
videoSource.setIsBuy(1);
|
|
||||||
} else if (isBuy.isFree()) { // 全免费逻辑
|
|
||||||
videoSource.setIsBuy(1);
|
|
||||||
} else {
|
|
||||||
videoSource.setIsBuy(0);
|
|
||||||
}
|
|
||||||
sourceMapper.add(sourceEntity);
|
|
||||||
sourceMapper.addRelation(videoSource);
|
|
||||||
} else {
|
|
||||||
// 有原视频
|
|
||||||
int count = sourceMapper.hasRelationTo(task.getMemberId(), source.getId(), 1);
|
|
||||||
if (count <= 0) {
|
|
||||||
// 没有关联
|
|
||||||
MemberSourceEntity videoSource = new MemberSourceEntity();
|
MemberSourceEntity videoSource = new MemberSourceEntity();
|
||||||
videoSource.setId(SnowFlakeUtil.getLongId());
|
|
||||||
videoSource.setScenicId(faceSample.getScenicId());
|
|
||||||
videoSource.setFaceId(task.getFaceId());
|
|
||||||
videoSource.setMemberId(task.getMemberId());
|
videoSource.setMemberId(task.getMemberId());
|
||||||
videoSource.setType(1);
|
videoSource.setType(1);
|
||||||
|
videoSource.setFaceId(task.getFaceId());
|
||||||
|
videoSource.setScenicId(faceSample.getScenicId());
|
||||||
|
videoSource.setSourceId(sourceEntity.getId());
|
||||||
|
IsBuyRespVO isBuy = orderBiz.isBuy(task.getMemberId(), faceSample.getScenicId(), 1, task.getFaceId());
|
||||||
if (isBuy.isBuy()) { // 如果用户买过
|
if (isBuy.isBuy()) { // 如果用户买过
|
||||||
videoSource.setIsBuy(1);
|
videoSource.setIsBuy(1);
|
||||||
} else if (isBuy.isFree()) { // 全免费逻辑
|
} else if (isBuy.isFree()) { // 全免费逻辑
|
||||||
@ -219,9 +201,33 @@ public class VideoPieceGetter {
|
|||||||
} else {
|
} else {
|
||||||
videoSource.setIsBuy(0);
|
videoSource.setIsBuy(0);
|
||||||
}
|
}
|
||||||
videoSource.setSourceId(source.getId());
|
|
||||||
sourceMapper.addRelation(videoSource);
|
sourceMapper.addRelation(videoSource);
|
||||||
}
|
}
|
||||||
|
sourceMapper.add(sourceEntity);
|
||||||
|
} else {
|
||||||
|
// 有原视频
|
||||||
|
if (task.memberId != null && task.faceId != null) {
|
||||||
|
int count = sourceMapper.hasRelationTo(task.getMemberId(), source.getId(), 1);
|
||||||
|
if (count <= 0) {
|
||||||
|
// 没有关联
|
||||||
|
IsBuyRespVO isBuy = orderBiz.isBuy(task.getMemberId(), faceSample.getScenicId(), 1, task.getFaceId());
|
||||||
|
MemberSourceEntity videoSource = new MemberSourceEntity();
|
||||||
|
videoSource.setId(SnowFlakeUtil.getLongId());
|
||||||
|
videoSource.setScenicId(faceSample.getScenicId());
|
||||||
|
videoSource.setFaceId(task.getFaceId());
|
||||||
|
videoSource.setMemberId(task.getMemberId());
|
||||||
|
videoSource.setType(1);
|
||||||
|
if (isBuy.isBuy()) { // 如果用户买过
|
||||||
|
videoSource.setIsBuy(1);
|
||||||
|
} else if (isBuy.isFree()) { // 全免费逻辑
|
||||||
|
videoSource.setIsBuy(1);
|
||||||
|
} else {
|
||||||
|
videoSource.setIsBuy(0);
|
||||||
|
}
|
||||||
|
videoSource.setSourceId(source.getId());
|
||||||
|
sourceMapper.addRelation(videoSource);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (templatePlaceholder != null) {
|
if (templatePlaceholder != null) {
|
||||||
if (templatePlaceholder.contains(faceSample.getDeviceId().toString())) {
|
if (templatePlaceholder.contains(faceSample.getDeviceId().toString())) {
|
||||||
|
@ -94,4 +94,10 @@
|
|||||||
from face
|
from face
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="listByScenicAndUserId" resultType="com.ycwl.basic.model.pc.face.resp.FaceRespVO">
|
||||||
|
select id, face_url, create_at, update_at
|
||||||
|
from face
|
||||||
|
where member_id = #{userId} and scenic_id = #{scenicId}
|
||||||
|
order by update_at desc
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -176,4 +176,9 @@
|
|||||||
left join source s on ms.source_id = s.id
|
left join source s on ms.source_id = s.id
|
||||||
where ms.face_id = #{faceId} and ms.member_id = #{memberId} and ms.type = 2
|
where ms.face_id = #{faceId} and ms.member_id = #{memberId} and ms.type = 2
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getEntity" resultType="com.ycwl.basic.model.pc.source.entity.SourceEntity">
|
||||||
|
select *
|
||||||
|
from source
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user