更新基线信息逻辑完善。
This commit is contained in:
+21
-30
@@ -526,7 +526,7 @@ public class OnlyOfficeController {
|
||||
Date now = new Date();
|
||||
logger.info("更新基线信息开始==========================================");
|
||||
logger.info("时间:" + DateUtils.date2Str(now,DateUtils.time_sdf.get()));
|
||||
// 查询总次数,如果查了超过10次还没有查出来,则终止本次更新.
|
||||
// 查询总次数
|
||||
int queryCount = 0;
|
||||
OnlineFileLog createTimeLatestOnlineFileLog = this.getCreateTimeLatestOnlineFileLog(fileId,now,queryCount);
|
||||
if (null != createTimeLatestOnlineFileLog) {
|
||||
@@ -596,6 +596,8 @@ public class OnlyOfficeController {
|
||||
logger.info("基线版本文件上传接口结束==========================================");
|
||||
|
||||
this.onlineFileLogDao.updateById(createTimeLatestOnlineFileLog);
|
||||
} else {
|
||||
return Result.error("更新基线信息失败!");
|
||||
}
|
||||
return Result.OK();
|
||||
}
|
||||
@@ -616,36 +618,25 @@ public class OnlyOfficeController {
|
||||
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) && queryCount < 10){
|
||||
queryCount ++;
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
if (ObjectUtils.isEmpty(result)){
|
||||
// 如果查了超过5次还没有查出来,则取该文件的最新创建历史数据进行更新
|
||||
if (queryCount < 5) {
|
||||
queryCount ++;
|
||||
try {
|
||||
Thread.sleep(6000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
result = this.getCreateTimeLatestOnlineFileLog(fileId,now,queryCount);
|
||||
} else {
|
||||
QueryWrapper<OnlineFileLog> ofLogQuery = new QueryWrapper<>();
|
||||
ofLogQuery.lambda().eq(OnlineFileLog::getHisId,fileId);
|
||||
ofLogQuery.lambda().orderByDesc(OnlineFileLog::getCreateTime);
|
||||
List<OnlineFileLog> onlineFileLogList = this.onlineFileLogDao.selectList(ofLogQuery);
|
||||
if (CollectionUtils.isNotEmpty(onlineFileLogList)) {
|
||||
result = onlineFileLogList.get(0);
|
||||
}
|
||||
}
|
||||
result = this.getCreateTimeLatestOnlineFileLog(fileId,now,queryCount);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user