|
@@ -1,19 +1,29 @@
|
|
|
package com.fdkankan.scene.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.fdkankan.common.constant.CommonOperStatus;
|
|
|
import com.fdkankan.common.constant.CommonStatus;
|
|
|
+import com.fdkankan.common.constant.SceneAsynFuncType;
|
|
|
+import com.fdkankan.common.constant.SceneAsynModuleType;
|
|
|
+import com.fdkankan.common.constant.SceneAsynOperType;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
import com.fdkankan.scene.entity.SceneAsynOperLog;
|
|
|
import com.fdkankan.scene.mapper.ISceneAsynOperLogMapper;
|
|
|
import com.fdkankan.scene.service.ISceneAsynOperLogService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fdkankan.scene.vo.SceneAsynOperLogParamVO;
|
|
|
import com.fdkankan.web.response.ResultData;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.Calendar;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
/**
|
|
@@ -24,9 +34,14 @@ import org.springframework.stereotype.Service;
|
|
|
* @author
|
|
|
* @since 2022-12-07
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
public class SceneAsynOperLogServiceImpl extends ServiceImpl<ISceneAsynOperLogMapper, SceneAsynOperLog> implements ISceneAsynOperLogService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private FYunFileServiceInterface fYunFileService;
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public ResultData getAsynOperLog(SceneAsynOperLogParamVO param) {
|
|
|
|
|
@@ -62,4 +77,42 @@ public class SceneAsynOperLogServiceImpl extends ServiceImpl<ISceneAsynOperLogMa
|
|
|
|
|
|
return ResultData.ok(list);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void cleanDownloadPanorama() {
|
|
|
+
|
|
|
+ List<SceneAsynOperLog> downloadList = this.list(
|
|
|
+ new LambdaQueryWrapper<SceneAsynOperLog>()
|
|
|
+ .eq(SceneAsynOperLog::getOperType, SceneAsynOperType.DOWNLOAD.code())
|
|
|
+ .eq(SceneAsynOperLog::getModule, SceneAsynModuleType.UPLOAD_DOWNLOAD.code())
|
|
|
+ .eq(SceneAsynOperLog::getFunc, SceneAsynFuncType.PANORAMIC_IMAGE));
|
|
|
+ if(CollUtil.isEmpty(downloadList)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ DateTime preMonth = DateUtil.offsetMonth(Calendar.getInstance().getTime(), -1);
|
|
|
+ List<SceneAsynOperLog> deleteList = downloadList.parallelStream().filter(log -> {
|
|
|
+ if (log.getCreateTime().before(preMonth)) {
|
|
|
+ return Boolean.TRUE;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ if(CollUtil.isEmpty(deleteList)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除数据库记录
|
|
|
+ List<Long> deleteIdList = deleteList.parallelStream().map(item -> item.getId()).collect(Collectors.toList());
|
|
|
+ this.removeByIds(deleteIdList);
|
|
|
+
|
|
|
+ deleteList.parallelStream().forEach(item -> {
|
|
|
+ if(StrUtil.isNotEmpty(item.getUrl())){
|
|
|
+ try {
|
|
|
+ fYunFileService.deleteFile(item.getUrl());
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.warn("删除oss全景图下载压缩包失败,key:{}", item.getUrl());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
}
|