feat: 企标更改流程在线编辑已有文件获取在线编辑文件接口
This commit is contained in:
+6
@@ -316,6 +316,12 @@ public class OnlyOfficeController {
|
||||
return Result.OK(busProcessModelHisService.saveEditFile(model));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "传入ossFileId获取在线编辑文件相关信息")
|
||||
@GetMapping("/saveEditFileWithOss")
|
||||
public Result<BusProcessModelHis> saveEditFileWithOss(String ossFileId) {
|
||||
return Result.OK(busProcessModelHisService.saveEditFileWithOss(ossFileId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "根据路径下载文件")
|
||||
@GetMapping("/downLoadFile")
|
||||
public void downLoadFile(@RequestParam(name = "path") String path, HttpServletResponse response) {
|
||||
|
||||
+2
@@ -29,6 +29,8 @@ public interface IBusProcessModelHisService extends IService<BusProcessModelHis>
|
||||
|
||||
BusProcessModelHis saveEditFile(String model);
|
||||
|
||||
BusProcessModelHis saveEditFileWithOss(String ossFileId);
|
||||
|
||||
List<BusProcessModelHis> modelHisList(String pid);
|
||||
|
||||
OnlineFileLog selectOnlineFile(String onlineFileId);
|
||||
|
||||
+63
@@ -14,6 +14,7 @@ import com.jero.modules.onlyoffice.mapper.OnlineFileLogDao;
|
||||
import com.jero.modules.onlyoffice.service.IBusProcessModelHisService;
|
||||
import com.jero.modules.oss.entity.OSSFile;
|
||||
import com.jero.modules.oss.service.IOSSFileService;
|
||||
import com.jero.modules.sys.controller.SysCommonController;
|
||||
import io.minio.errors.*;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -113,6 +114,68 @@ public class BusProcessModelHisServiceImpl extends ServiceImpl<BusProcessModelHi
|
||||
return modelHis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BusProcessModelHis saveEditFileWithOss(String ossFileId) {
|
||||
OSSFile ossFile = ossFileService.getById(ossFileId);
|
||||
BusProcessModelHis modelHis = new BusProcessModelHis();
|
||||
|
||||
try {
|
||||
String taskId = generateTaskId();
|
||||
String topId = generateTopId();
|
||||
String builderModel = "model" + "/";
|
||||
String targetPath = builderModel + taskId + "/" + taskId + "_" + topId + "_node.docx";
|
||||
|
||||
createDirectoryIfNotExists(filePath + builderModel);
|
||||
createDirectoryIfNotExists(filePath + builderModel + taskId + "/");
|
||||
|
||||
String fileUrl = ossFile.getUrl();
|
||||
String minioUrl = MinioUtil.getMinioUrl() + MinioUtil.getBucketName() + "/";
|
||||
String url = fileUrl.replace(minioUrl, "");
|
||||
|
||||
InputStream minioFile = MinioUtil.getMinioFile(MinioUtil.getBucketName(), url);
|
||||
|
||||
File targetFile = new File(filePath + targetPath);
|
||||
|
||||
try (OutputStream outputStream = new FileOutputStream(targetFile)) {
|
||||
byte[] buffer = new byte[1024];
|
||||
int bytesRead;
|
||||
while ((bytesRead = minioFile.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("文件写入失败:" + e.getMessage());
|
||||
}
|
||||
|
||||
modelHis.setFileName(ossFile.getFileName());
|
||||
modelHis.setTaskId(taskId);
|
||||
modelHis.setPId(topId);
|
||||
modelHis.setEditFilePath(targetPath);
|
||||
modelHis.setDownLoadUrl(downloadUrl + targetPath);
|
||||
this.baseMapper.insert(modelHis);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
|
||||
return modelHis;
|
||||
}
|
||||
|
||||
private String generateTaskId() {
|
||||
String preUuid2 = UUID.randomUUID().toString();
|
||||
return "task_" + preUuid2.substring(0, 8);
|
||||
}
|
||||
|
||||
private String generateTopId() {
|
||||
String preUuid2 = UUID.randomUUID().toString();
|
||||
return "top_" + preUuid2.substring(0, 8);
|
||||
}
|
||||
|
||||
private void createDirectoryIfNotExists(String directoryPath) {
|
||||
File dir = new File(directoryPath);
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public OnlineFileLog selectOnlineFile(String onlineFileId) {
|
||||
BusProcessModelHis busProcessModelHis = baseMapper.selectById(onlineFileId);
|
||||
|
||||
Reference in New Issue
Block a user