diff --git a/nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillDetailServiceImpl.java b/nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillDetailServiceImpl.java index 869a8e7..68612fe 100644 --- a/nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillDetailServiceImpl.java +++ b/nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillDetailServiceImpl.java @@ -199,7 +199,8 @@ public class EasOutInBillDetailServiceImpl extends ServiceImpl 1) { entityList.forEach(r -> { UpdateWrapper updateWrapper = new UpdateWrapper<>(); - updateWrapper.set("djzt", "审核"); + //批量待审核 + updateWrapper.set("djzt", "2"); updateWrapper.eq("flid", r.getFlid()); updateWrapper.set("czsl", r.getSl()); updateWrapper.set("sysl", 0); @@ -208,7 +209,7 @@ public class EasOutInBillDetailServiceImpl extends ServiceImpl updateWrapper = new UpdateWrapper<>(); if(sysl.compareTo(BigDecimal.ZERO)==0) { - updateWrapper.set("djzt", "待审核"); + //待审核 + updateWrapper.set("djzt", "1"); } updateWrapper.eq("flid", entityList.get(0).getFlid()); updateWrapper.set("czsl", czsl); 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 dbbf431..c10aabe 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 @@ -15,6 +15,7 @@ import org.nl.config.IdUtil; import org.nl.wms.database.eas.dao.EasOutInBillDetail; import org.nl.wms.database.eas.dao.HomeBillCounts; import org.nl.wms.database.eas.dao.mapper.EasOutInBillDetailMapper; +import org.nl.wms.database.eas.dao.mapper.EasOutInBillMapper; import org.nl.wms.database.eas.service.IeasOutInBillService; import org.nl.wms.ext.eas.WmsToEasService; import org.springframework.beans.factory.annotation.Value; @@ -76,21 +77,48 @@ public class EasBillSchedule { } + + + /** - * eas单据数据同步 + * eas单据自动审核 */ @Async("taskExecutor") @Scheduled(cron = "0/30 * * * * *") public void automaticAuditBills() { - - List easOutInBillDetailList = easOutInBillDetailMapper.selectList(new LambdaQueryWrapper().eq(EasOutInBillDetail::getDjzt, "待审核")); - - - + // 单据明细批量出入库单 + List easOutInBillDetailList1 = easOutInBillDetailMapper + .selectList(new LambdaQueryWrapper().eq(EasOutInBillDetail::getDjzt, "1")); + List djidList = easOutInBillDetailList1.stream() + .map(EasOutInBillDetail::getDjid) + .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<>(); + groupSizeMap.forEach((id, count) -> { + List billList = easOutInBillService + .list(new LambdaQueryWrapper().eq(EasOutInBill::getDjid, id)); + if (billList.size() == count) { + auditDjidList.add(id); + } + }); + updateBillsInBatch(djidList, auditDjidList); + } + private void updateBillsInBatch(List djidList, List auditDjidList) { + if (!auditDjidList.isEmpty()||!djidList.isEmpty()) { + EasOutInBill easOutInBills = new EasOutInBill(); + easOutInBills.setDjzt("审核"); + djidList.addAll(auditDjidList); + easOutInBillService.update(easOutInBills, new LambdaQueryWrapper().in(EasOutInBill::getDjid, djidList)); + } } + /** * 定时删除源头已删除单据 */