优化回调保存接口(若传递文件id则每次保存只更新文件)
This commit is contained in:
@@ -52,6 +52,7 @@ public class FileService {
|
||||
public WebsocketResult documentSave(JSONObject jsonObject) {
|
||||
WebsocketResult result = new WebsocketResult();
|
||||
String key = "";
|
||||
String fileId = jsonObject.getString("fileId");
|
||||
try {
|
||||
int status = jsonObject.getIntValue("status");
|
||||
log.info("status[{}]", status);
|
||||
@@ -69,7 +70,13 @@ public class FileService {
|
||||
key = jsonObject.getString("key");
|
||||
log.info("key:" + JSON.toJSONString(key));
|
||||
//文件id
|
||||
String fileId = onlyServiceAPI.getFileId(key);
|
||||
Boolean isexistid = false;
|
||||
if (fileId != null && !"".equals(fileId)) {
|
||||
isexistid = true;
|
||||
}
|
||||
if (!isexistid) {
|
||||
fileId = onlyServiceAPI.getFileId(key);
|
||||
}
|
||||
log.info("fileId:" + JSON.toJSONString(fileId));
|
||||
if (fileId != null && !"".equals(fileId)) {
|
||||
//查询之前FileId对应的文件信息
|
||||
@@ -93,7 +100,11 @@ public class FileService {
|
||||
//处理文件的保存
|
||||
OnFile file = onlyServiceAPI.handlerStatus(jsonObject);
|
||||
//查询相同案件最新版本的文件信息
|
||||
file = getNewFileInofoByCaseId(file.getCaseId());
|
||||
if (fileId != null && !"".equals(fileId)) {
|
||||
file = getNewFileInofoByFileId(fileId);
|
||||
} else {
|
||||
file = getNewFileInofoByCaseId(file.getCaseId());
|
||||
}
|
||||
result = WebsocketResult.builder().onFile(file).userId(SecurityUtils.getUserSession().getId()).build();
|
||||
log.info("处理文件的保存:" + JSON.toJSONString(jsonObject));
|
||||
log.info("保存文件结束");
|
||||
@@ -101,10 +112,13 @@ public class FileService {
|
||||
return result;
|
||||
} else if (0 == status || 2 == status || 4 == status) {
|
||||
onlyServiceAPI.close(jsonObject);
|
||||
log.info("文件关闭====",status);
|
||||
} else if (3 == status || 7 == status) {
|
||||
//保存文档错误
|
||||
onlyServiceAPI.close(jsonObject);
|
||||
log.info("保存文档错误====",status);
|
||||
} else if (1 == status) {
|
||||
log.info("文件正在编辑====",status);
|
||||
//文件服务的回调 获取key判断当前文档有多少人在这使用
|
||||
List<Map> actions = JSONObject.parseArray(jsonObject.getString("actions"), Map.class);
|
||||
if ((Integer) actions.get(0).get("type") == 1) {
|
||||
@@ -145,4 +159,17 @@ public class FileService {
|
||||
log.info("caseId:" + caseId + ":fileinfo:" + JSON.toJSONString(file));
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据文件的fileid查询文件信息
|
||||
*/
|
||||
private OnFile getNewFileInofoByFileId(String fileId) {
|
||||
OnFile file = onFileMapper.selectById(fileId);
|
||||
if (file != null) {
|
||||
log.info("caseId:" + file.getCaseId() + ":fileinfo:" + JSON.toJSONString(file));
|
||||
} else {
|
||||
log.info("根据文件id未查询到文件信息");
|
||||
}
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user