@Override
public List<ExpenseListingDTO> getExpenseListByServiceFileId(Long serviceFileId) {
if (Long.valueOf(serviceFileId) != null) {
List<ExpenseListDetail> expenseListDetail = expenseListDetailRepository.findByServiceFileId(serviceFileId);
List<ExpenseList> expenseList = expenseListRepository.findByExpenseListDetailListIn(expenseListDetail);
//
List<ExpenseListingDTO> expenseListDtoList = expenseListMapper.expenseListDTOToExpenseListingDTO(expenseListMapper.entityListToDtoList(expenseList));
expenseListDtoList.parallelStream().forEach(dto -> {
dto.setTotalAmount(
expenseListDetail.stream().filter(s -> s.getOperationType().equals(OperationType.NEW_EXPENSE.getValue()) || s.getOperationType().equals(OperationType.EXPENSE_RETURN.getValue()))
.filter(s -> !s.getStatus().equals(ExpenseListDetailStatus.PASSIVE.getValue())).map(ExpenseListDetail::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
});
return expenseListDtoList.stream()
.distinct()
.collect(Collectors.toList());
}
return Collections.emptyList();
}
This function returns a list. But there ara some same lists on my output. I want to remove duplicates. But it didn't work. What is the problem in here?