1.优化获取config配置接口

2.优化回调保存接口
3.优化文件保存信息的完善
This commit is contained in:
wangqiong
2024-03-15 16:02:12 +08:00
parent c593e47adc
commit 88052b6986
10 changed files with 166 additions and 35 deletions
@@ -3,6 +3,8 @@ package com.oo.demo.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.oo.demo.dao.OnFileMapper;
import com.oo.demo.entity.OnFile;
import com.oo.demo.entity.WebsocketResult;
import com.oo.onlyoffice.api.OnlyServiceAPI;
@@ -31,10 +33,18 @@ public class FileService {
private OnlyServiceAPI onlyServiceAPI;
@Autowired
private DemoService demoService;
@Autowired
private OnFileService onFileService;
/**
* 文档服务器 保存文件回调
* Defines the status of the document. Can have the following values:
* 1 - document is being edited,
* 2 - document is ready for saving,
* 3 - document saving error has occurred,
* 4 - document is closed with no changes,
* 6 - document is being edited, but the current document state is saved,
* 7 - error has occurred while force saving the document.
*
* @param jsonObject
*/
@@ -61,6 +71,11 @@ public class FileService {
//文件id
String fileId = onlyServiceAPI.getFileId(key);
log.info("fileId:" + JSON.toJSONString(fileId));
if (fileId != null && !"".equals(fileId)) {
//查询之前FileId对应的文件信息
OnFile onfile = onFileService.getFileById(fileId);
jsonObject.put("caseId", onfile.getCaseId());
}
//判断是否是最后一人进行保存
int users = onlyServiceAPI.getUserNum(key);
// if (users > 1) {
@@ -77,6 +92,8 @@ public class FileService {
}
//处理文件的保存
OnFile file = onlyServiceAPI.handlerStatus(jsonObject);
//查询相同案件最新版本的文件信息
file = getNewFileInofoByCaseId(file.getCaseId());
result = WebsocketResult.builder().onFile(file).userId(SecurityUtils.getUserSession().getId()).build();
log.info("处理文件的保存:" + JSON.toJSONString(jsonObject));
log.info("保存文件结束");
@@ -107,5 +124,25 @@ public class FileService {
return result;
}
@Autowired
OnFileMapper onFileMapper;
/**
* 查询相同案件最新版本的文件信息
*
* @param caseId
* @return
*/
private OnFile getNewFileInofoByCaseId(String caseId) {
OnFile file = new OnFile();
QueryWrapper<OnFile> fileQueryWrapper = new QueryWrapper<>();
fileQueryWrapper.eq("case_id", caseId);
fileQueryWrapper.orderByDesc("created_time");
List<OnFile> onFiles = onFileMapper.selectList(fileQueryWrapper);
if (onFiles != null && onFiles.size() > 0) {
file = onFiles.get(0);
}
log.info("caseId:" + caseId + ":fileinfo:" + JSON.toJSONString(file));
return file;
}
}