diff --git a/nlsso-server/src/main/java/org/nl/wms/schedule/EasBillSchedule.java b/nlsso-server/src/main/java/org/nl/wms/schedule/EasBillSchedule.java index c10aabe..cbf179c 100644 --- a/nlsso-server/src/main/java/org/nl/wms/schedule/EasBillSchedule.java +++ b/nlsso-server/src/main/java/org/nl/wms/schedule/EasBillSchedule.java @@ -77,44 +77,49 @@ public class EasBillSchedule { } - - - /** * eas单据自动审核 */ @Async("taskExecutor") @Scheduled(cron = "0/30 * * * * *") + @Transactional(rollbackFor = Exception.class) public void automaticAuditBills() { // 单据明细批量出入库单 List easOutInBillDetailList1 = easOutInBillDetailMapper .selectList(new LambdaQueryWrapper().eq(EasOutInBillDetail::getDjzt, "1")); - List djidList = easOutInBillDetailList1.stream() + List djIdList1 = easOutInBillDetailList1.stream() .map(EasOutInBillDetail::getDjid) + .distinct() .collect(Collectors.toList()); //单个明细出入库单 List easOutInBillDetailList2 = easOutInBillDetailMapper .selectList(new LambdaQueryWrapper().eq(EasOutInBillDetail::getDjzt, "2")); Map groupSizeMap = easOutInBillDetailList2.stream() .collect(Collectors.groupingBy(EasOutInBillDetail::getDjid, Collectors.counting())); - List auditDjidList = new ArrayList<>(); + List djIdList2 = new ArrayList<>(); groupSizeMap.forEach((id, count) -> { List billList = easOutInBillService .list(new LambdaQueryWrapper().eq(EasOutInBill::getDjid, id)); if (billList.size() == count) { - auditDjidList.add(id); + djIdList2.add(id); } }); - updateBillsInBatch(djidList, auditDjidList); + updateBillInBatch(djIdList1, djIdList2); } - private void updateBillsInBatch(List djidList, List auditDjidList) { - if (!auditDjidList.isEmpty()||!djidList.isEmpty()) { + private void updateBillInBatch(List djIdList1, List djIdList2) { + if (!djIdList1.isEmpty() || !djIdList2.isEmpty()) { + //修改主表 EasOutInBill easOutInBills = new EasOutInBill(); easOutInBills.setDjzt("审核"); - djidList.addAll(auditDjidList); - easOutInBillService.update(easOutInBills, new LambdaQueryWrapper().in(EasOutInBill::getDjid, djidList)); + djIdList1.addAll(djIdList2); + easOutInBillService.update(easOutInBills, new LambdaQueryWrapper().in(EasOutInBill::getDjid, djIdList1)); + //修改明细表 + EasOutInBillDetail easOutInBillDetail = new EasOutInBillDetail(); + easOutInBillDetail.setDjzt("审核"); + easOutInBillDetailMapper.update(easOutInBillDetail, new LambdaQueryWrapper() + .in(EasOutInBillDetail::getDjid, djIdList1)); } }