I have two Lists which I get - one from xlsx file, the second one - by select from database
@Component
public class ReadExcelDemo implements CommandLineRunner {
@Autowired
private TakeDataService dataService;
private List<Integer> list;
private List<TakeData> dates;
@Override
public void run(String... args) {
try
{
FileInputStream file = new FileInputStream("Report.xlsx");
XSSFWorkbook workbook = new XSSFWorkbook(file);
XSSFSheet sheet = workbook.getSheetAt(0);
for (Row row : sheet) {
Iterator<Cell> cellIterator = row.cellIterator();
while (cellIterator.hasNext()) {
Cell cell = cellIterator.next();
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
if (cell.getColumnIndex() == 0) {
list = new ArrayList<>();
list.add((int) cell.getNumericCellValue());
//System.out.println(list);
}
}
}
}
file.close();
}
catch (Exception e)
{
e.printStackTrace();
}
takeData();
printDifference();
}
public void takeData() {
dates = new ArrayList<>(dataService.takeData());
// System.out.println(dates);
}
public void printDifference() {
List<Integer> id = dates.stream().map(TakeData::getId).collect(Collectors.toList());
// for (Integer a : list) {
// id.remove(a);
// }
//List<Integer> difference = new ArrayList<>(CollectionUtils.disjunction(list, id));
Set<Integer> diff = new HashSet<>(id);
System.out.println(list.stream().filter(((Predicate<? super Integer>) diff :: contains).negate()).collect(Collectors.toList()));
}
}
I need to find the difference between these Lists and just print the result of this difference to the console. I have already tried many routers, but most likely it's not the implementation, but something else.