更新基线信息逻辑完善。
This commit is contained in:
+21
-30
@@ -526,7 +526,7 @@ public class OnlyOfficeController {
|
|||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
logger.info("更新基线信息开始==========================================");
|
logger.info("更新基线信息开始==========================================");
|
||||||
logger.info("时间:" + DateUtils.date2Str(now,DateUtils.time_sdf.get()));
|
logger.info("时间:" + DateUtils.date2Str(now,DateUtils.time_sdf.get()));
|
||||||
// 查询总次数,如果查了超过10次还没有查出来,则终止本次更新.
|
// 查询总次数
|
||||||
int queryCount = 0;
|
int queryCount = 0;
|
||||||
OnlineFileLog createTimeLatestOnlineFileLog = this.getCreateTimeLatestOnlineFileLog(fileId,now,queryCount);
|
OnlineFileLog createTimeLatestOnlineFileLog = this.getCreateTimeLatestOnlineFileLog(fileId,now,queryCount);
|
||||||
if (null != createTimeLatestOnlineFileLog) {
|
if (null != createTimeLatestOnlineFileLog) {
|
||||||
@@ -596,6 +596,8 @@ public class OnlyOfficeController {
|
|||||||
logger.info("基线版本文件上传接口结束==========================================");
|
logger.info("基线版本文件上传接口结束==========================================");
|
||||||
|
|
||||||
this.onlineFileLogDao.updateById(createTimeLatestOnlineFileLog);
|
this.onlineFileLogDao.updateById(createTimeLatestOnlineFileLog);
|
||||||
|
} else {
|
||||||
|
return Result.error("更新基线信息失败!");
|
||||||
}
|
}
|
||||||
return Result.OK();
|
return Result.OK();
|
||||||
}
|
}
|
||||||
@@ -616,36 +618,25 @@ public class OnlyOfficeController {
|
|||||||
result = onlineFileLogs.get(0);
|
result = onlineFileLogs.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (ObjectUtils.isNotEmpty(result)) {
|
if (ObjectUtils.isEmpty(result)){
|
||||||
// long nowTime = now.getTime();
|
// 如果查了超过5次还没有查出来,则取该文件的最新创建历史数据进行更新
|
||||||
// long createTime = result.getCreateTime().getTime();
|
if (queryCount < 5) {
|
||||||
//
|
queryCount ++;
|
||||||
// // 如果数据的创建时间大于当前时间,直接返回
|
try {
|
||||||
// if (createTime > nowTime) {
|
Thread.sleep(6000);
|
||||||
// return result;
|
} catch (InterruptedException e) {
|
||||||
// }
|
e.printStackTrace();
|
||||||
//
|
}
|
||||||
// // 计算时间差
|
result = this.getCreateTimeLatestOnlineFileLog(fileId,now,queryCount);
|
||||||
// long diff = Math.abs(nowTime - createTime);
|
} else {
|
||||||
//
|
QueryWrapper<OnlineFileLog> ofLogQuery = new QueryWrapper<>();
|
||||||
// // 判断时间差是否小于等于10秒
|
ofLogQuery.lambda().eq(OnlineFileLog::getHisId,fileId);
|
||||||
// if (diff <= 10 * 1000) {
|
ofLogQuery.lambda().orderByDesc(OnlineFileLog::getCreateTime);
|
||||||
// System.out.println("两个日期在十秒内");
|
List<OnlineFileLog> onlineFileLogList = this.onlineFileLogDao.selectList(ofLogQuery);
|
||||||
// } else {
|
if (CollectionUtils.isNotEmpty(onlineFileLogList)) {
|
||||||
// System.out.println("两个日期不在十秒内");
|
result = onlineFileLogList.get(0);
|
||||||
//
|
}
|
||||||
// result = null;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (ObjectUtils.isEmpty(result) && queryCount < 10){
|
|
||||||
queryCount ++;
|
|
||||||
try {
|
|
||||||
Thread.sleep(10000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
result = this.getCreateTimeLatestOnlineFileLog(fileId,now,queryCount);
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user