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