|
|
@ -177,20 +177,20 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
try { |
|
|
|
insertBills(easOutInBillDetails, existingIds); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("异常信息:" + e.toString()); |
|
|
|
log.error("异常信息:" + e); |
|
|
|
} |
|
|
|
}, pool); |
|
|
|
CompletableFuture.runAsync(() -> { |
|
|
|
try { |
|
|
|
updateBills(easOutInBillDetails, existingIds); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("异常信息:" + e.toString()); |
|
|
|
log.error("异常信息:" + e); |
|
|
|
} |
|
|
|
}, pool); |
|
|
|
// CompletableFuture.runAsync(() -> {
|
|
|
|
// //todo 检查事务是否会失效
|
|
|
|
// autoDeleteBill(easOutInBillDetails, existingIds);
|
|
|
|
// }, pool);
|
|
|
|
CompletableFuture.runAsync(() -> { |
|
|
|
//todo 检查事务是否会失效
|
|
|
|
autoDeleteBill(easOutInBillDetails, existingIds); |
|
|
|
}, pool); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -254,10 +254,6 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
return bill; |
|
|
|
}) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
//主表
|
|
|
|
//easOutInBillMapper.insertBatch(billList);
|
|
|
|
//明细表
|
|
|
|
//easOutInBillDetailMapper.insertBatch(detailList);
|
|
|
|
CompletableFuture.runAsync(() -> { |
|
|
|
//主表
|
|
|
|
for (EasOutInBill entity : billList) { |
|
|
@ -284,18 +280,24 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
Set<String> ids = existingIds.stream().map(EasOutInBillDetail::getFlid).collect(Collectors.toSet()); |
|
|
|
// 过滤出需要插入的新单据,并根据来源设置 ID
|
|
|
|
List<EasOutInBillDetail> insertEasBills = easOutInBillDetails.stream() |
|
|
|
.filter(bill -> ids.contains(bill.getDjid())) |
|
|
|
.filter(r -> r.getXgsj() != null) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
if (CollectionUtils.isNotEmpty(insertEasBills)) { |
|
|
|
//比较insertEasBills与existingIds的修改时间进行按需更新
|
|
|
|
for (EasOutInBillDetail entity : insertEasBills) { |
|
|
|
EasOutInBillDetail existing = existingIds.stream() |
|
|
|
.filter(e -> { |
|
|
|
boolean isUpdate = false; |
|
|
|
try { |
|
|
|
return e.getFlid().equals(entity.getFlid()) && org.nl.common.utils.DateUtil.getDate(e.getXgsj()).after(org.nl.common.utils.DateUtil.getDate(entity.getXgsj())); |
|
|
|
if (e.getFlid().equals(entity.getFlid())) { |
|
|
|
if (e.getXgsj() == null || org.nl.common.utils.DateUtil.getDate(entity.getXgsj()).after(org.nl.common.utils.DateUtil.getDate(e.getXgsj()))) { |
|
|
|
isUpdate = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (ParseException ex) { |
|
|
|
throw new RuntimeException(ex); |
|
|
|
} |
|
|
|
return isUpdate; |
|
|
|
}) |
|
|
|
.findFirst() |
|
|
|
.orElse(null); |
|
|
@ -349,13 +351,19 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
.filter(e -> !easFlidSet.contains(e.getFlid())) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
if (CollectionUtils.isNotEmpty(idsToDelete)) { |
|
|
|
//找出idsToDelete中DJID相同且元素只有一个的集合,说明是最后一个明细行要被删除,那么主单据也要被删除
|
|
|
|
Map<String, Long> idCounts = idsToDelete.stream() |
|
|
|
Map<String, Long> idCount1 = idsToDelete.stream() |
|
|
|
.collect(Collectors.groupingBy(EasOutInBillDetail::getDjid, Collectors.counting())); |
|
|
|
Set<String> billIds = idCounts.entrySet().stream() |
|
|
|
.filter(entry -> entry.getValue() == 1) |
|
|
|
.map(Map.Entry::getKey) |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
Map<String, Long> idCount2 = existingIds.stream() |
|
|
|
.collect(Collectors.groupingBy(EasOutInBillDetail::getDjid, Collectors.counting())); |
|
|
|
Set<String> billIds = new HashSet<>(); |
|
|
|
idCount1.forEach((k, v) -> { |
|
|
|
//遍历idCount1中的djid,与idCount2的比较,如果相等,判断value的个等于idCount2,则记录key到一个新的set集合中
|
|
|
|
if (idCount2.containsKey(k)) { |
|
|
|
if (idCount2.get(k).equals(v)) { |
|
|
|
billIds.add(k); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
if (CollectionUtils.isNotEmpty(billIds)) { |
|
|
|
//删除主数据
|
|
|
|
deleteAll(billIds); |
|
|
@ -365,7 +373,6 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
Set<String> filds = idsToDelete.stream().map(EasOutInBillDetail::getFlid).collect(Collectors.toSet()); |
|
|
|
queryWrapper.in(EasOutInBillDetail::getFlid, filds); |
|
|
|
easOutInBillDetailMapper.delete(queryWrapper); |
|
|
|
|
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("定时删除源头已删除单据-autoDeleteBill接口回滚,出现异常: {}", e); |
|
|
|