| | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | @RequiredArgsConstructor |
| | |
| | | |
| | | //删除出库记录 |
| | | public void deleteStockOutRecord(Long recordId, String recordType) { |
| | | StockOutRecord one = stockOutRecordService.getOne(new QueryWrapper<StockOutRecord>() |
| | | List<StockOutRecord> records = stockOutRecordService.list(new QueryWrapper<StockOutRecord>() |
| | | .lambda().eq(StockOutRecord::getRecordId, recordId) |
| | | .eq(StockOutRecord::getRecordType, recordType), false); |
| | | if (ObjectUtils.isNotEmpty(one)) { |
| | | if (ReviewStatusEnum.APPROVED.getCode().equals(one.getApprovalStatus())) { |
| | | stockOutRecordService.batchDelete(Collections.singletonList(one.getId())); |
| | | } else { |
| | | stockOutRecordService.removeById(one.getId()); |
| | | } |
| | | .eq(StockOutRecord::getRecordType, recordType)); |
| | | if (ObjectUtils.isEmpty(records)) { |
| | | return; |
| | | } |
| | | List<Long> approvedIds = records.stream() |
| | | .filter(one -> ReviewStatusEnum.APPROVED.getCode().equals(one.getApprovalStatus())) |
| | | .map(StockOutRecord::getId) |
| | | .toList(); |
| | | List<Long> pendingIds = records.stream() |
| | | .filter(one -> !ReviewStatusEnum.APPROVED.getCode().equals(one.getApprovalStatus())) |
| | | .map(StockOutRecord::getId) |
| | | .toList(); |
| | | if (!approvedIds.isEmpty()) { |
| | | stockOutRecordService.batchDelete(approvedIds); |
| | | } |
| | | if (!pendingIds.isEmpty()) { |
| | | stockOutRecordService.removeByIds(pendingIds); |
| | | } |
| | | |
| | | } |