修改
This commit is contained in:
parent
ea3ce510d8
commit
a6157ddad8
@ -1,5 +1,6 @@
|
||||
package com.ycwl.basic.controller.mobile.manage;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ycwl.basic.constant.BaseContextHandler;
|
||||
import com.ycwl.basic.mapper.ScenicAccountMapper;
|
||||
import com.ycwl.basic.model.pc.order.req.OrderReqQuery;
|
||||
@ -35,4 +36,15 @@ public class AppScenicOrderController {
|
||||
query.setScenicId(account.getScenicId());
|
||||
return orderService.list(query);
|
||||
}
|
||||
|
||||
@PostMapping("/page")
|
||||
public ApiResponse<PageInfo<OrderRespVO>> page(@RequestBody OrderReqQuery query) {
|
||||
String userId = BaseContextHandler.getUserId();
|
||||
ScenicAccountEntity account = scenicAccountMapper.findAccountById(userId);
|
||||
if (account == null) {
|
||||
return ApiResponse.fail("用户未绑定景区");
|
||||
}
|
||||
query.setScenicId(account.getScenicId());
|
||||
return orderService.pageQuery(query);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.ycwl.basic.model.pc.source.req.SourceReqQuery;
|
||||
import com.ycwl.basic.model.pc.source.resp.SourceRespVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -67,4 +68,8 @@ public interface SourceMapper {
|
||||
List<SourceEntity> listImageByFaceRelation(Long memberId, Long faceId);
|
||||
|
||||
SourceEntity getEntity(Long id);
|
||||
|
||||
int deleteNotRelateSource(int type, Date endDate);
|
||||
|
||||
int deleteNotBuyRelations(Long scenicId, Date endDate);
|
||||
}
|
||||
|
@ -10,6 +10,6 @@ public class VideoTaskStatusVO {
|
||||
private Long templateId;
|
||||
private Long faceId;
|
||||
private Long scenicId;
|
||||
private int count;
|
||||
private int maxCount;
|
||||
private long count;
|
||||
private long maxCount;
|
||||
}
|
||||
|
@ -59,4 +59,5 @@ public class ScenicConfigEntity {
|
||||
private Integer antiScreenRecordType;
|
||||
private Integer videoSourceStoreDay;
|
||||
private Integer imageSourceStoreDay;
|
||||
private Integer userSourceExpireDay;
|
||||
}
|
||||
|
@ -23,9 +23,11 @@ import com.ycwl.basic.model.pc.scenic.req.ScenicReqQuery;
|
||||
import com.ycwl.basic.model.pc.scenic.resp.ScenicRespVO;
|
||||
import com.ycwl.basic.model.pc.source.req.SourceReqQuery;
|
||||
import com.ycwl.basic.model.pc.source.resp.SourceRespVO;
|
||||
import com.ycwl.basic.model.pc.task.entity.TaskEntity;
|
||||
import com.ycwl.basic.model.pc.video.entity.MemberVideoEntity;
|
||||
import com.ycwl.basic.model.pc.video.resp.VideoRespVO;
|
||||
import com.ycwl.basic.repository.ScenicRepository;
|
||||
import com.ycwl.basic.repository.VideoTaskRepository;
|
||||
import com.ycwl.basic.service.mobile.AppScenicService;
|
||||
import com.ycwl.basic.repository.TemplateRepository;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
@ -71,6 +73,8 @@ public class AppScenicServiceImpl implements AppScenicService {
|
||||
private ScenicRepository scenicRepository;
|
||||
@Autowired
|
||||
private TemplateBiz templateBiz;
|
||||
@Autowired
|
||||
private VideoTaskRepository videoTaskRepository;
|
||||
|
||||
@Override
|
||||
public ApiResponse<PageInfo<ScenicAppVO>> pageQuery(ScenicReqQuery scenicReqQuery) {
|
||||
@ -120,7 +124,14 @@ public class AppScenicServiceImpl implements AppScenicService {
|
||||
contentPageVO.setDuration(videoMapperById.getDuration());
|
||||
contentPageVO.setLockType(-1);
|
||||
} else {
|
||||
TaskEntity taskById = videoTaskRepository.getTaskById(memberVideoEntityList.get(0).getTaskId());
|
||||
if (taskById == null) {
|
||||
contentPageVO.setLockType(0);
|
||||
} else if (taskById.getStatus() == 3) {
|
||||
contentPageVO.setLockType(2);
|
||||
} else {
|
||||
contentPageVO.setLockType(0);
|
||||
}
|
||||
contentPageVO.setContentType(0);
|
||||
}
|
||||
} else {
|
||||
|
@ -278,11 +278,19 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
if (taskById == null) {
|
||||
return true;
|
||||
}
|
||||
return taskById.getStatus() != 1;
|
||||
return taskById.getStatus() == 0 || taskById.getStatus() == 2;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
long finishedTask = taskList.stream()
|
||||
.filter(task -> {
|
||||
TaskEntity taskById = videoTaskRepository.getTaskById(task.getTaskId());
|
||||
if (taskById == null) {
|
||||
return false;
|
||||
}
|
||||
return taskById.getStatus() == 1;
|
||||
}).count();
|
||||
response.setCount(finishedTask);
|
||||
if (!notFinishedTasks.isEmpty()) {
|
||||
response.setCount(taskList.size() - notFinishedTasks.size());
|
||||
response.setTemplateId(notFinishedTasks.get(0).getTemplateId());
|
||||
response.setTaskId(notFinishedTasks.get(0).getTaskId());
|
||||
response.setStatus(2);
|
||||
@ -292,7 +300,6 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
response.setTaskId(lastVideo.getTaskId());
|
||||
response.setTemplateId(lastVideo.getTemplateId());
|
||||
response.setVideoId(lastVideo.getVideoId());
|
||||
response.setCount(taskList.size());
|
||||
response.setStatus(1);
|
||||
return response;
|
||||
}
|
||||
@ -321,10 +328,18 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
if (taskById == null) {
|
||||
return true;
|
||||
}
|
||||
return taskById.getStatus() != 1;
|
||||
return taskById.getStatus() == 0 || taskById.getStatus() == 2;
|
||||
}).collect(Collectors.toList());
|
||||
long finishedTask = taskList.stream()
|
||||
.filter(task -> {
|
||||
TaskEntity taskById = videoTaskRepository.getTaskById(task.getTaskId());
|
||||
if (taskById == null) {
|
||||
return false;
|
||||
}
|
||||
return taskById.getStatus() == 1;
|
||||
}).count();
|
||||
response.setCount(finishedTask);
|
||||
if (!notFinishedTasks.isEmpty()) {
|
||||
response.setCount(taskList.size() - notFinishedTasks.size());
|
||||
response.setTemplateId(notFinishedTasks.get(0).getTemplateId());
|
||||
response.setTaskId(notFinishedTasks.get(0).getTaskId());
|
||||
response.setStatus(2);
|
||||
@ -334,12 +349,23 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
response.setTaskId(lastVideo.getTaskId());
|
||||
response.setTemplateId(lastVideo.getTemplateId());
|
||||
response.setVideoId(lastVideo.getVideoId());
|
||||
response.setCount(taskList.size());
|
||||
if (null == lastVideo.getVideoId()) {
|
||||
if (null != lastVideo.getVideoId()) {
|
||||
response.setStatus(1);
|
||||
response.setVideoId(lastVideo.getVideoId());
|
||||
} else {
|
||||
TaskEntity taskById = videoTaskRepository.getTaskById(lastVideo.getTaskId());
|
||||
if (taskById == null) {
|
||||
response.setStatus(1);
|
||||
} else {
|
||||
if (taskById.getStatus() == 1) {
|
||||
response.setStatus(1);
|
||||
response.setVideoId(lastVideo.getVideoId());
|
||||
} else if (taskById.getStatus() == 0 || taskById.getStatus() == 2) {
|
||||
response.setStatus(2);
|
||||
} else {
|
||||
response.setStatus(1);
|
||||
response.setVideoId(lastVideo.getVideoId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.ycwl.basic.service.task.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import com.aliyuncs.facebody.model.v20191230.AddFaceEntityRequest;
|
||||
@ -294,7 +295,7 @@ public class TaskFaceServiceImpl implements TaskFaceService {
|
||||
log.info("当前景区{},人脸样本保存天数未设置,默认7天", scenicId);
|
||||
sampleStoreDay = 7;
|
||||
}
|
||||
Date endDate = DateUtils.addDateDays(new Date(), -(sampleStoreDay + 1));
|
||||
Date endDate = DateUtil.offsetDay(DateUtil.beginOfDay(new Date()), -sampleStoreDay);
|
||||
ListFaceEntitiesRequest listFaceEntitiesRequest = new ListFaceEntitiesRequest();
|
||||
listFaceEntitiesRequest.setDbName(String.valueOf(scenicId));
|
||||
listFaceEntitiesRequest.setOrder("asc");
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.ycwl.basic.task;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.ycwl.basic.mapper.FaceSampleMapper;
|
||||
import com.ycwl.basic.mapper.ScenicMapper;
|
||||
import com.ycwl.basic.mapper.SourceMapper;
|
||||
@ -9,6 +10,8 @@ import com.ycwl.basic.model.pc.faceSample.resp.FaceSampleRespVO;
|
||||
import com.ycwl.basic.model.pc.scenic.entity.ScenicConfigEntity;
|
||||
import com.ycwl.basic.model.pc.scenic.req.ScenicReqQuery;
|
||||
import com.ycwl.basic.model.pc.scenic.resp.ScenicRespVO;
|
||||
import com.ycwl.basic.model.pc.source.req.SourceReqQuery;
|
||||
import com.ycwl.basic.model.pc.source.resp.SourceRespVO;
|
||||
import com.ycwl.basic.model.pc.video.req.VideoReqQuery;
|
||||
import com.ycwl.basic.model.pc.video.resp.VideoRespVO;
|
||||
import com.ycwl.basic.repository.ScenicRepository;
|
||||
@ -22,6 +25,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@ -52,6 +56,27 @@ public class FaceCleaner {
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0 3 * * ?")
|
||||
public void deleteNotBuySource(){
|
||||
ScenicReqQuery scenicQuery = new ScenicReqQuery();
|
||||
List<ScenicRespVO> scenicList = scenicMapper.list(scenicQuery);
|
||||
scenicList.parallelStream().forEach(scenic -> {
|
||||
ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(scenic.getId());
|
||||
if (scenicConfig == null) {
|
||||
log.info("当前景区{},无配置信息", scenic.getName());
|
||||
return;
|
||||
}
|
||||
if (scenicConfig.getUserSourceExpireDay() == null) {
|
||||
log.info("当前景区{},人脸样本过期天数未设置", scenic.getName());
|
||||
return;
|
||||
}
|
||||
int expireDay = scenicConfig.getUserSourceExpireDay();
|
||||
Date endDate = DateUtil.offsetDay(DateUtil.beginOfDay(new Date()), -expireDay);
|
||||
int deleteCount = sourceMapper.deleteNotBuyRelations(scenic.getId(), endDate);
|
||||
log.info("当前景区{},删除关联素材{}个", scenic.getName(), deleteCount);
|
||||
});
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 30 3 * * ?")
|
||||
public void deleteExpiredSource(){
|
||||
ScenicReqQuery scenicQuery = new ScenicReqQuery();
|
||||
List<ScenicRespVO> scenicList = scenicMapper.list(scenicQuery);
|
||||
@ -80,6 +105,13 @@ public class FaceCleaner {
|
||||
return;
|
||||
}
|
||||
log.info("当前景区{},开始删除原始素材", scenic.getName());
|
||||
Date endDate = DateUtil.offsetDay(DateUtil.beginOfDay(new Date()), -videoSourceExpireDay);
|
||||
int deleteVideoSourceCount = sourceMapper.deleteNotRelateSource(1, endDate);
|
||||
log.info("当前景区{},删除原始视频素材{}个", scenic.getName(), deleteVideoSourceCount);
|
||||
log.info("当前景区{},开始删除原始图片素材", scenic.getName());
|
||||
Date endDate2 = DateUtil.offsetDay(DateUtil.beginOfDay(new Date()), -imageSourceExpireDay);
|
||||
int deleteImageSourceCount = sourceMapper.deleteNotRelateSource(2, endDate2);
|
||||
log.info("当前景区{},删除原始图片素材{}个", scenic.getName(), deleteImageSourceCount);
|
||||
});
|
||||
}
|
||||
|
||||
@ -102,6 +134,29 @@ public class FaceCleaner {
|
||||
});
|
||||
}
|
||||
private void cleanSourceOss() {
|
||||
log.info("开始清理源视频素材文件");
|
||||
List<SourceRespVO> list = sourceMapper.list(new SourceReqQuery());
|
||||
IStorageAdapter adapter = StorageFactory.use("assets-ext");
|
||||
List<StorageFileObject> fileObjectList = adapter.listDir("video-source");
|
||||
fileObjectList.parallelStream().forEach(fileObject -> {
|
||||
if (list.parallelStream().noneMatch(videoRespVO -> videoRespVO.getVideoUrl().contains(fileObject.getFullPath()))){
|
||||
log.info("删除视频文件:{}", fileObject);
|
||||
adapter.deleteFile(fileObject.getFullPath());
|
||||
} else {
|
||||
log.info("视频文件存在关系:{},未删除", fileObject);
|
||||
}
|
||||
});
|
||||
log.info("开始清理源图片素材文件");
|
||||
IStorageAdapter imageAdapter = StorageFactory.use("faces");
|
||||
List<StorageFileObject> imageFileObjectList = imageAdapter.listDir("user-photo");
|
||||
imageFileObjectList.parallelStream().forEach(fileObject -> {
|
||||
if (list.parallelStream().noneMatch(videoRespVO -> videoRespVO.getUrl().contains(fileObject.getFullPath()))){
|
||||
log.info("删除图片文件:{}", fileObject);
|
||||
imageAdapter.deleteFile(fileObject.getFullPath());
|
||||
} else {
|
||||
log.info("图片文件存在关系:{},未删除", fileObject);
|
||||
}
|
||||
});
|
||||
}
|
||||
private void cleanVideoOss() {
|
||||
log.info("开始清理视频文件");
|
||||
|
@ -95,6 +95,7 @@
|
||||
disable_source_image=#{disableSourceImage},
|
||||
video_source_store_day=#{videoSourceStoreDay},
|
||||
image_source_store_day=#{imageSourceStoreDay},
|
||||
user_source_expire_day=#{userSourceExpireDay},
|
||||
force_finish_time=#{forceFinishTime}
|
||||
</set>
|
||||
where id = #{id}
|
||||
|
@ -41,6 +41,16 @@
|
||||
<delete id="deleteById">
|
||||
delete from source where id = #{id}
|
||||
</delete>
|
||||
<delete id="deleteNotRelateSource">
|
||||
delete from `source`
|
||||
where id not in (select source_id from member_source)
|
||||
and type = #{type}
|
||||
and create_time <= #{endDate}
|
||||
</delete>
|
||||
<delete id="deleteNotBuyRelations">
|
||||
delete from member_source
|
||||
where member_id = #{memberId} and scenic_id = #{scenicId} and is_buy = 0 and create_time <= #{endDate}
|
||||
</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
|
||||
|
@ -113,6 +113,7 @@
|
||||
select t.id
|
||||
from template t
|
||||
where t.scenic_id = #{scenicId} and t.pid = 0 and t.status = 1
|
||||
order by sort
|
||||
</select>
|
||||
<select id="get" resultType="com.ycwl.basic.model.pc.template.entity.TemplateEntity">
|
||||
select *
|
||||
|
Loading…
x
Reference in New Issue
Block a user