|
@@ -7,6 +7,8 @@ import cn.hutool.core.io.IoUtil;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.file.entity.*;
|
|
|
import com.fjhx.file.mapper.FileInfoMapper;
|
|
@@ -139,7 +141,6 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
* @param obsFileList 文件列表
|
|
|
* @param businessId 业务id
|
|
|
* @param businessType 业务文件类型
|
|
@@ -162,7 +163,6 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
* @param obsFileList 文件列表
|
|
|
* @param businessId 业务id
|
|
|
* @param businessType 业务文件类型
|
|
@@ -216,4 +216,37 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
|
|
|
return new ObsClient(ak, sk, endPoint);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 判断文件是否已经绑定业务 是将文件复制一份并保存
|
|
|
+ *
|
|
|
+ * @param fileList 文件列表
|
|
|
+ * @param businessId 业务id
|
|
|
+ * @param businessType 业务文件类型
|
|
|
+ */
|
|
|
+ @DS(BaseSourceConstant.BASE)
|
|
|
+ @Override
|
|
|
+ public void copyFileAndSave(List<ObsFile> fileList, Long businessId, Integer businessType) {
|
|
|
+ if (ObjectUtils.isEmpty(fileList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<Long> fids = fileList.stream().map(ObsFile::getId).collect(Collectors.toList());
|
|
|
+ Map<Long, FileInfo> fileInfoMap = this.mapKEntity(FileInfo::getId, q -> q.in(FileInfo::getId, fids));
|
|
|
+ List<FileInfo> newFileInfo = new ArrayList<>();
|
|
|
+ for (ObsFile obsFile : fileList) {
|
|
|
+ FileInfo fileInfo = fileInfoMap.get(obsFile.getId());
|
|
|
+ if (ObjectUtils.isEmpty(fileInfo)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //如果文件已经有业务id了 且业务id不是当前业务id 就将文件复制一份
|
|
|
+ if (ObjectUtils.isNotEmpty(fileInfo.getBusinessId()) && !businessId.equals(fileInfo.getBusinessId())) {
|
|
|
+ long id = IdWorker.getId();
|
|
|
+ fileInfo.setId(id);
|
|
|
+ obsFile.setId(id);
|
|
|
+ newFileInfo.add(fileInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.saveBatch(newFileInfo);
|
|
|
+ saveFile(fileList, businessId, businessType);
|
|
|
+ }
|
|
|
+
|
|
|
}
|