Browse Source

opt: 单据批量自动审核;

test-20240527
龚宝雄 7 months ago
parent
commit
f0fe710b02
  1. 27
      nlsso-server/src/main/java/org/nl/wms/schedule/EasBillSchedule.java

27
nlsso-server/src/main/java/org/nl/wms/schedule/EasBillSchedule.java

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

Loading…
Cancel
Save