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