|
@@ -49,34 +49,32 @@ public class TaskSync {
|
|
|
private IUserClient userClient;
|
|
|
|
|
|
|
|
|
- public void reSigningEVisaStatusSync(List<InformationQuery> dtos, String header) {
|
|
|
+ public void reSigningEVisaStatusSync(InformationQuery dto, String header) {
|
|
|
log.info("数据正在重刷,线程名称:{}", Thread.currentThread().getName());
|
|
|
|
|
|
- for (InformationQuery dto : dtos) {
|
|
|
- informationQueryService.update(new LambdaUpdateWrapper<InformationQuery>()
|
|
|
- .eq(InformationQuery::getId, dto.getId())
|
|
|
- .set(InformationQuery::getEVisaPdfUrl, null)
|
|
|
- .set(InformationQuery::getUpdateTime, DateTime.now())
|
|
|
-
|
|
|
- .set(InformationQuery::getPdfUrl, null));
|
|
|
- R result = this.saveNodePdf(dto.getClassify() + "", dto.getWbsId() + "", dto.getContractId() + "", dto.getProjectId() + "", header);
|
|
|
-
|
|
|
- LambdaUpdateWrapper<InformationQuery> lambda = Wrappers.<InformationQuery>update().lambda();
|
|
|
- if (result == null || result.getCode() != 200) {
|
|
|
- //重签失败
|
|
|
- lambda.set(InformationQuery::getSaveAgain, 3)
|
|
|
- .set(InformationQuery::getEVisaPdfUrl, dto.getEVisaPdfUrl())
|
|
|
- .setSql("save_again_count = save_again_count + 1")
|
|
|
- .set(InformationQuery::getPdfUrl, dto.getPdfUrl());
|
|
|
- } else {
|
|
|
- //成功重签
|
|
|
- lambda.set(InformationQuery::getSaveAgain, 2);
|
|
|
- }
|
|
|
- lambda.set(InformationQuery::getUpdateTime, DateTime.now());
|
|
|
- lambda.eq(InformationQuery::getId, dto.getId());
|
|
|
-
|
|
|
- informationQueryService.update(lambda);
|
|
|
+ informationQueryService.update(new LambdaUpdateWrapper<InformationQuery>()
|
|
|
+ .eq(InformationQuery::getId, dto.getId())
|
|
|
+ .set(InformationQuery::getEVisaPdfUrl, null)
|
|
|
+ .set(InformationQuery::getUpdateTime, DateTime.now())
|
|
|
+
|
|
|
+ .set(InformationQuery::getPdfUrl, null));
|
|
|
+ R result = this.saveNodePdf(dto.getClassify() + "", dto.getWbsId() + "", dto.getContractId() + "", dto.getProjectId() + "", header);
|
|
|
+
|
|
|
+ LambdaUpdateWrapper<InformationQuery> lambda = Wrappers.<InformationQuery>update().lambda();
|
|
|
+ if (result == null || result.getCode() != 200) {
|
|
|
+ //重签失败
|
|
|
+ lambda.set(InformationQuery::getSaveAgain, 3)
|
|
|
+ .set(InformationQuery::getEVisaPdfUrl, dto.getEVisaPdfUrl())
|
|
|
+ .setSql("save_again_count = save_again_count + 1")
|
|
|
+ .set(InformationQuery::getPdfUrl, dto.getPdfUrl());
|
|
|
+ } else {
|
|
|
+ //成功重签
|
|
|
+ lambda.set(InformationQuery::getSaveAgain, 2);
|
|
|
}
|
|
|
+ lambda.set(InformationQuery::getUpdateTime, DateTime.now());
|
|
|
+ lambda.eq(InformationQuery::getId, dto.getId());
|
|
|
+
|
|
|
+ informationQueryService.update(lambda);
|
|
|
log.info("数据重刷完毕,线程名称:{}", Thread.currentThread().getName());
|
|
|
}
|
|
|
|
|
@@ -86,7 +84,7 @@ public class TaskSync {
|
|
|
* 一个小时检查一次
|
|
|
*/
|
|
|
@Scheduled(cron = "0 0 * * * ?")
|
|
|
- public void updateStuckTask(){
|
|
|
+ public void updateStuckTask() {
|
|
|
List<InformationQuery> list = informationQueryService.list(Wrappers.<InformationQuery>lambdaQuery()
|
|
|
.eq(InformationQuery::getSaveAgain, 1)
|
|
|
.eq(InformationQuery::getIsDeleted, 0));
|
|
@@ -98,9 +96,11 @@ public class TaskSync {
|
|
|
ids.add(informationQuery.getId());
|
|
|
}
|
|
|
}
|
|
|
- informationQueryService.update(null, Wrappers.<InformationQuery>lambdaUpdate()
|
|
|
- .set(InformationQuery::getSaveAgain, 0)
|
|
|
- .in(InformationQuery::getId, ids));
|
|
|
+ if (CollectionUtils.isNotEmpty(ids)) {
|
|
|
+ informationQueryService.update(null, Wrappers.<InformationQuery>lambdaUpdate()
|
|
|
+ .set(InformationQuery::getSaveAgain, 0)
|
|
|
+ .in(InformationQuery::getId, ids));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -118,30 +118,27 @@ public class TaskSync {
|
|
|
//失败重刷次数小于2次
|
|
|
.lt(InformationQuery::getSaveAgainCount, 2)
|
|
|
.last("limit 50"));
|
|
|
- if(CollectionUtils.isEmpty(list)){
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- List<List<InformationQuery>> partition = Lists.partition(list, 10);
|
|
|
-
|
|
|
- for (List<InformationQuery> informationQueries : partition) {
|
|
|
- List<Long> collect = informationQueries.stream().map(InformationQuery::getId).collect(Collectors.toList());
|
|
|
+ for (InformationQuery informationQueries : list) {
|
|
|
//修改状态之后开始重刷
|
|
|
boolean update = informationQueryService.update(Wrappers.<InformationQuery>update().lambda()
|
|
|
.set(InformationQuery::getSaveAgain, 1)
|
|
|
.set(InformationQuery::getUpdateTime, DateTime.now())
|
|
|
- .in(InformationQuery::getId, collect));
|
|
|
+ .eq(InformationQuery::getId, informationQueries.getId()));
|
|
|
if (update) {
|
|
|
CompletableFuture.runAsync(() -> {
|
|
|
try {
|
|
|
/*===============执行批量任务===============*/
|
|
|
this.reSigningEVisaStatusSync(informationQueries, header);
|
|
|
} catch (Exception e) {
|
|
|
- log.error("执行重刷任务失败,任务ID列表:{}", collect, e);
|
|
|
+ log.error("执行重刷任务失败,任务ID列表:{}", informationQueries.getId(), e);
|
|
|
// 可选:回滚状态或标记为失败
|
|
|
}
|
|
|
}, executor).exceptionally(throwable -> {
|
|
|
- log.error("异步任务执行异常,任务ID列表:{}", collect, throwable);
|
|
|
+ log.error("异步任务执行异常,任务ID列表:{}", informationQueries.getId(), throwable);
|
|
|
return null;
|
|
|
});
|
|
|
}
|