在线编辑-更新基线信息接口。
This commit is contained in:
+72
-1
@@ -1,6 +1,7 @@
|
||||
package com.jero.modules.onlyoffice.controller;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@@ -21,7 +22,9 @@ import com.jero.modules.oss.entity.OSSFile;
|
||||
import com.jero.modules.oss.service.IOSSFileService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -39,6 +42,8 @@ import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -369,7 +374,11 @@ public class OnlyOfficeController {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
LambdaQueryWrapper<OnlineFileLog> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(OnlineFileLog::getHisId, fileId);
|
||||
wrapper.eq(OnlineFileLog::getDataType, dataType);
|
||||
if (StringUtils.equals(dataType,"0")) {
|
||||
wrapper.isNull(OnlineFileLog::getDataType);
|
||||
} else if (StringUtils.equals(dataType,"1")) {
|
||||
wrapper.eq(OnlineFileLog::getDataType, dataType);
|
||||
}
|
||||
wrapper.eq(OnlineFileLog::getValidFlag, "0");
|
||||
wrapper.orderByDesc(OnlineFileLog::getCreateTime);
|
||||
List<OnlineFileLog> onlineFileLogList = onlineFileLogDao.selectList(wrapper);
|
||||
@@ -486,5 +495,67 @@ public class OnlyOfficeController {
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
@ApiOperation(value = "更新基线信息")
|
||||
@PostMapping("/updateOnlineFileLogJxInfo")
|
||||
public Result<String> updateOnlineFileLogJxInfo(@RequestBody JSONObject json){
|
||||
String jxFileName = json.getString("jxFileName");
|
||||
String fileId = json.getString("fileId");
|
||||
String dataType = "1";
|
||||
|
||||
Date now = new Date();
|
||||
OnlineFileLog createTimeLatestOnlineFileLog = this.getCreateTimeLatestOnlineFileLog(fileId,now);
|
||||
createTimeLatestOnlineFileLog.setJxFileName(jxFileName);
|
||||
createTimeLatestOnlineFileLog.setDataType(dataType);
|
||||
|
||||
this.onlineFileLogDao.updateById(createTimeLatestOnlineFileLog);
|
||||
return Result.OK();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取在线编辑文件保存历史,更新基线信息使用。
|
||||
* @return
|
||||
*/
|
||||
public OnlineFileLog getCreateTimeLatestOnlineFileLog(String fileId,Date now){
|
||||
QueryWrapper<OnlineFileLog> ofLogQueryWrap = new QueryWrapper<>();
|
||||
ofLogQueryWrap.lambda().eq(OnlineFileLog::getHisId,fileId);
|
||||
ofLogQueryWrap.lambda().orderByDesc(OnlineFileLog::getCreateTime);
|
||||
List<OnlineFileLog> onlineFileLogs = this.onlineFileLogDao.selectList(ofLogQueryWrap);
|
||||
|
||||
OnlineFileLog result = null;
|
||||
if (CollectionUtils.isNotEmpty(onlineFileLogs)) {
|
||||
result = onlineFileLogs.get(0);
|
||||
}
|
||||
if (ObjectUtils.isNotEmpty(result)) {
|
||||
long nowTime = now.getTime();
|
||||
long createTime = result.getCreateTime().getTime();
|
||||
|
||||
// 如果数据的创建时间大于当前时间,直接返回
|
||||
if (createTime > nowTime) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// 计算时间差
|
||||
long diff = Math.abs(nowTime - createTime);
|
||||
|
||||
// 判断时间差是否小于等于10秒
|
||||
if (diff <= 10 * 1000) {
|
||||
System.out.println("两个日期在十秒内");
|
||||
} else {
|
||||
System.out.println("两个日期不在十秒内");
|
||||
|
||||
result = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (ObjectUtils.isEmpty(result)){
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
result = this.getCreateTimeLatestOnlineFileLog(fileId,now);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user