From f0fe710b028e8593130dd28b9275e2caf75af83c Mon Sep 17 00:00:00 2001 From: baoge <751575283@qq.com> Date: Wed, 8 May 2024 14:07:35 +0800 Subject: [PATCH] =?UTF-8?q?opt:=20=E5=8D=95=E6=8D=AE=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=AE=A1=E6=A0=B8=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/nl/wms/schedule/EasBillSchedule.java | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) 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)); } }