1
This commit is contained in:
parent
bbcbdd2839
commit
937e1c1ff5
@ -2,6 +2,8 @@ package com.ycwl.basic.service.impl.pc;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ycwl.basic.model.pc.device.entity.DeviceEntity;
|
||||
import com.ycwl.basic.model.wvp.WvpSyncReqVo;
|
||||
import com.ycwl.basic.repository.DeviceRepository;
|
||||
import com.ycwl.basic.mapper.DeviceMapper;
|
||||
import com.ycwl.basic.model.pc.device.entity.DeviceConfigEntity;
|
||||
@ -91,4 +93,22 @@ public class DeviceServiceImpl implements DeviceService {
|
||||
deviceMapper.updateConfig(config);
|
||||
deviceRepository.clearDeviceCache(config.getDeviceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDevices(Long scenicId, WvpSyncReqVo reqVo) {
|
||||
if (reqVo == null) {
|
||||
return;
|
||||
}
|
||||
if (reqVo.getDevices() != null && !reqVo.getDevices().isEmpty()) {
|
||||
for (WvpSyncReqVo.DeviceItem deviceItem : reqVo.getDevices()) {
|
||||
DeviceEntity device = deviceMapper.getByDeviceNo(deviceItem.getDeviceNo());
|
||||
if (device != null) {
|
||||
device.setOnline(deviceItem.getOnline());
|
||||
device.setKeepaliveAt(deviceItem.getKeepaliveAt());
|
||||
deviceMapper.updateEntity(device);
|
||||
deviceRepository.clearDeviceCache(device.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -139,17 +139,17 @@ public class FaceServiceImpl implements FaceService {
|
||||
FaceEntity faceEntity = new FaceEntity();
|
||||
faceEntity.setScore(scenicDbSearchResult.getScore());
|
||||
faceEntity.setMatchResult(scenicDbSearchResult.getSearchResultJson());
|
||||
SearchFaceRespVo userDbSearchResult = faceService.searchFace(USER_FACE_DB_NAME, faceUrl);
|
||||
SearchFaceRespVo userDbSearchResult = faceService.searchFace(USER_FACE_DB_NAME+scenicId, faceUrl);
|
||||
float strictScore = 0.6F;
|
||||
if (userDbSearchResult == null) {
|
||||
// 都是null了,那得是新的
|
||||
faceService.addFaceSample(USER_FACE_DB_NAME, newFaceId.toString(), faceUrl, newFaceId.toString());
|
||||
faceService.addFaceSample(USER_FACE_DB_NAME+scenicId, newFaceId.toString(), faceUrl, newFaceId.toString());
|
||||
} else if (userDbSearchResult.getSampleListIds() == null || userDbSearchResult.getSampleListIds().isEmpty()) {
|
||||
// 没有匹配到过,也得是新的
|
||||
faceService.addFaceSample(USER_FACE_DB_NAME, newFaceId.toString(), faceUrl, newFaceId.toString());
|
||||
faceService.addFaceSample(USER_FACE_DB_NAME+scenicId, newFaceId.toString(), faceUrl, newFaceId.toString());
|
||||
} else if (userDbSearchResult.getFirstMatchRate() < strictScore) {
|
||||
// 有匹配结果,但是不匹配旧的
|
||||
faceService.addFaceSample(USER_FACE_DB_NAME, newFaceId.toString(), faceUrl, newFaceId.toString());
|
||||
faceService.addFaceSample(USER_FACE_DB_NAME+scenicId, newFaceId.toString(), faceUrl, newFaceId.toString());
|
||||
} else {
|
||||
// 有匹配结果,且能匹配旧的数据
|
||||
Optional<Long> faceAny = userDbSearchResult.getSampleListIds().stream().filter(oldFaceId -> {
|
||||
@ -163,7 +163,8 @@ public class FaceServiceImpl implements FaceService {
|
||||
Long oldFaceId = faceAny.get();
|
||||
FaceRespVO oldFace = faceMapper.getById(oldFaceId);
|
||||
if (oldFace == null) {
|
||||
faceService.deleteFaceSample(USER_FACE_DB_NAME, oldFaceId.toString());
|
||||
faceService.deleteFaceSample(USER_FACE_DB_NAME+scenicId, oldFaceId.toString());
|
||||
faceService.addFaceSample(USER_FACE_DB_NAME+scenicId, newFaceId.toString(), faceUrl, newFaceId.toString());
|
||||
} else {
|
||||
faceEntity.setId(oldFaceId);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.ycwl.basic.model.pc.device.entity.DeviceConfigEntity;
|
||||
import com.ycwl.basic.model.pc.device.req.DeviceAddOrUpdateReq;
|
||||
import com.ycwl.basic.model.pc.device.req.DeviceReqQuery;
|
||||
import com.ycwl.basic.model.pc.device.resp.DeviceRespVO;
|
||||
import com.ycwl.basic.model.wvp.WvpSyncReqVo;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
|
||||
import java.util.List;
|
||||
@ -24,4 +25,6 @@ public interface DeviceService {
|
||||
|
||||
DeviceConfigEntity getConfig(Long id);
|
||||
void saveConfig(Long configId, DeviceConfigEntity config);
|
||||
|
||||
void updateDevices(Long scenicId, WvpSyncReqVo reqVo);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.ycwl.basic.service.task;
|
||||
|
||||
import com.ycwl.basic.model.task.resp.AddFaceSampleRespVo;
|
||||
import com.ycwl.basic.model.task.resp.SearchFaceRespVo;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
public interface TaskFaceService {
|
||||
|
@ -42,6 +42,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.aliyuncs.DefaultAcsClient;
|
||||
import com.aliyuncs.IAcsClient;
|
||||
@ -177,6 +178,7 @@ public class TaskFaceServiceImpl implements TaskFaceService {
|
||||
|
||||
@Override
|
||||
public AddFaceSampleRespVo addFaceSample(String dbName, String entityId, String faceUrl, String extData) {
|
||||
assureFaceDB(dbName);
|
||||
AddFaceEntityRequest request = new AddFaceEntityRequest();
|
||||
request.setDbName(dbName);
|
||||
request.setEntityId(entityId);
|
||||
|
@ -504,12 +504,13 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
MpConfigEntity scenicMp = scenicRepository.getScenicMpConfig(member.getScenicId());
|
||||
if (StringUtils.isNotBlank(openId) && scenicMp != null) {
|
||||
String templateId = scenicRepository.getVideoGeneratedTemplateId(item.getScenicId());
|
||||
TemplateRespVO template = templateRepository.getTemplate(item.getTemplateId());
|
||||
if (StringUtils.isBlank(templateId)) {
|
||||
log.warn("未配置视频生成通知模板");
|
||||
return;
|
||||
}
|
||||
ScenicEntity scenic = scenicRepository.getScenic(item.getScenicId());
|
||||
String title = "您在【" + scenic.getName() + "】的专属影像";
|
||||
String title = "您在【" + template.getName() + "】的专属影像";
|
||||
String page = "pages/videoSynthesis/buy?scenicId=" + item.getScenicId() + "&faceId=" + item.getFaceId() + "&id=" + item.getVideoId();
|
||||
/**
|
||||
* 视频名称 {{thing1.DATA}}
|
||||
@ -519,7 +520,6 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
Map<String, Object> dataParam = new HashMap<>();
|
||||
Map<String, String> videoMap = new HashMap<>();
|
||||
TemplateRespVO template = templateRepository.getTemplate(item.getTemplateId());
|
||||
videoMap.put("value", template.getName());
|
||||
dataParam.put("thing1", videoMap);
|
||||
Map<String, String> timeMap2 = new HashMap<>();
|
||||
|
@ -7,6 +7,7 @@ import com.ycwl.basic.model.pc.member.resp.MemberRespVO;
|
||||
import com.ycwl.basic.model.pc.mp.MpConfigEntity;
|
||||
import com.ycwl.basic.model.pc.scenic.entity.ScenicConfigEntity;
|
||||
import com.ycwl.basic.model.pc.scenic.entity.ScenicEntity;
|
||||
import com.ycwl.basic.model.pc.template.resp.TemplateRespVO;
|
||||
import com.ycwl.basic.notify.NotifyFactory;
|
||||
import com.ycwl.basic.notify.adapters.INotifyAdapter;
|
||||
import com.ycwl.basic.notify.entity.NotifyContent;
|
||||
@ -34,6 +35,8 @@ public class DownloadNotificationTasker {
|
||||
private VideoMapper videoMapper;
|
||||
@Autowired
|
||||
private MemberMapper memberMapper;
|
||||
@Autowired
|
||||
private TemplateRepository templateRepository;
|
||||
|
||||
@Scheduled(cron = "0 0 21 * * *")
|
||||
public void sendDownloadNotification() {
|
||||
@ -45,6 +48,7 @@ public class DownloadNotificationTasker {
|
||||
}
|
||||
MemberRespVO member = memberMapper.getById(item.getMemberId());
|
||||
MpConfigEntity scenicMp = scenicRepository.getScenicMpConfig(member.getScenicId());
|
||||
TemplateRespVO template = templateRepository.getTemplate(item.getTemplateId());
|
||||
// 发送模板消息
|
||||
String templateId = scenicRepository.getVideoDownloadTemplateId(item.getScenicId());
|
||||
if (StringUtils.isBlank(templateId)) {
|
||||
@ -53,7 +57,7 @@ public class DownloadNotificationTasker {
|
||||
}
|
||||
log.info("发送模板消息");
|
||||
ScenicEntity scenic = scenicRepository.getScenic(item.getScenicId());
|
||||
String title = "您在【" + scenic.getName() + "】的专属影像";
|
||||
String title = "您在【" + template.getName() + "】的专属影像";
|
||||
String page = "pages/videoSynthesis/buy?scenicId=" + item.getScenicId() + "&faceId=" + item.getFaceId() + "&id=" + item.getVideoId();
|
||||
/**
|
||||
* 景区 {{thing1.DATA}}
|
||||
@ -90,13 +94,14 @@ public class DownloadNotificationTasker {
|
||||
Integer videoStoreDay = scenicConfig.getVideoStoreDay();
|
||||
// 发送模板消息
|
||||
String templateId = scenicRepository.getVideoPreExpireTemplateId(item.getScenicId());
|
||||
TemplateRespVO template = templateRepository.getTemplate(item.getTemplateId());
|
||||
if (StringUtils.isBlank(templateId)) {
|
||||
log.info("模板消息为空");
|
||||
return;
|
||||
}
|
||||
log.info("发送模板消息");
|
||||
ScenicEntity scenic = scenicRepository.getScenic(item.getScenicId());
|
||||
String title = "您在【" + scenic.getName() + "】的专属影像";
|
||||
String title = "您在【" + template.getName() + "】的专属影像";
|
||||
String page = "pages/videoSynthesis/buy?scenicId=" + item.getScenicId() + "&faceId=" + item.getFaceId() + "&id=" + item.getVideoId();
|
||||
/**
|
||||
* 影像名称 {{thing1.DATA}}
|
||||
|
@ -155,11 +155,11 @@ public class DynamicTaskGenerator {
|
||||
public static void addTask(Long faceSampleId) {
|
||||
Date createTime = new Date();
|
||||
// 两分钟后
|
||||
createTime.setTime(createTime.getTime() + 120000L);
|
||||
createTime.setTime(createTime.getTime() + 80000L);
|
||||
queue.add(new Task(faceSampleId, createTime));
|
||||
}
|
||||
|
||||
@Scheduled(fixedRate = 30000L)
|
||||
@Scheduled(fixedRate = 10000L)
|
||||
public void doTask() {
|
||||
Task task = queue.poll();
|
||||
if (task == null) {
|
||||
@ -181,7 +181,7 @@ public class DynamicTaskGenerator {
|
||||
log.info("当前景区{}未启用预约流程,跳过", faceSample.getScenicId());
|
||||
return;
|
||||
}
|
||||
SearchFaceRespVo userDbSearchResult = faceService.searchFace(USER_FACE_DB_NAME, faceSample.getFaceUrl());
|
||||
SearchFaceRespVo userDbSearchResult = faceService.searchFace(USER_FACE_DB_NAME+faceSample.getScenicId(), faceSample.getFaceUrl());
|
||||
// 如果人脸样本ID在人脸样本库中,则创建任务
|
||||
if (!userDbSearchResult.getSampleListIds().isEmpty()) {
|
||||
log.info("人脸样本ID在人脸样本库中,创建任务:{}", task);
|
||||
@ -197,11 +197,10 @@ public class DynamicTaskGenerator {
|
||||
log.info("本景区人脸样本ID不在人脸样本库中,忽略任务:{}", task);
|
||||
return;
|
||||
}
|
||||
List<TemplateRespVO> templateList = templateRepository.getTemplateListByScenicId(faceSample.getScenicId());
|
||||
if (templateList == null || templateList.isEmpty()) {
|
||||
log.info("当前景区{},无模板配置", faceSample.getScenicId());
|
||||
return;
|
||||
}
|
||||
faceIdList.forEach(faceId -> {
|
||||
// 每一个都重新匹配
|
||||
faceService.searchFace(faceId);
|
||||
});
|
||||
faceIdList.forEach(faceId -> {
|
||||
log.info("自动下发任务,人脸ID:{}", faceId);
|
||||
taskService.autoCreateTaskByFaceId(faceId);
|
||||
|
@ -141,6 +141,16 @@ storage:
|
||||
prefix: "user-assets/"
|
||||
url: "https://oss.zhentuai.com"
|
||||
region: "cn-shanghai"
|
||||
- name: "assets-ext"
|
||||
type: "ALI_OSS"
|
||||
config:
|
||||
endpoint: "https://oss-cn-shanghai.aliyuncs.com"
|
||||
accessKeyId: "LTAI5tCa641QdNHH9Ybg9u7V"
|
||||
accessKeySecret: "RRVIgekoqx96Fgm2Gs7eQshMShcEpk"
|
||||
bucketName: "frametour-assets"
|
||||
prefix: "user-assets/"
|
||||
url: "https://oss.zhentuai.com"
|
||||
region: "cn-shanghai"
|
||||
- name: "video"
|
||||
type: "ALI_OSS"
|
||||
config:
|
||||
|
Loading…
x
Reference in New Issue
Block a user