Subversion Repositories SmartDukaan

Rev

Rev 35454 | Rev 35563 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 35454 Rev 35562
Line 526... Line 526...
526
        if (tickets == null || tickets.isEmpty()) {
526
        if (tickets == null || tickets.isEmpty()) {
527
            return new HashMap<>();
527
            return new HashMap<>();
528
        }
528
        }
529
        // OPTIMIZED: Batch fetch all AuthUsers instead of N+1 queries
529
        // OPTIMIZED: Batch fetch all AuthUsers instead of N+1 queries
530
        List<Integer> authUserIds = tickets.stream()
530
        List<Integer> authUserIds = tickets.stream()
531
                .map(Ticket::getL1AuthUser)
531
                .map(this::getEffectiveAuthUserId)
532
                .filter(id -> id != null && id > 0)
532
                .filter(id -> id != null && id > 0)
533
                .distinct()
533
                .distinct()
534
                .collect(Collectors.toList());
534
                .collect(Collectors.toList());
535
        Map<Integer, AuthUser> authUserById = authRepository.selectByIds(authUserIds).stream()
535
        Map<Integer, AuthUser> authUserById = authRepository.selectByIds(authUserIds).stream()
536
                .collect(Collectors.toMap(AuthUser::getId, au -> au, (a, b) -> a));
536
                .collect(Collectors.toMap(AuthUser::getId, au -> au, (a, b) -> a));
Line 540... Line 540...
540
            authUserIdAndAuthUserMap.put(ticket.getId(), authUserById.get(ticket.getL1AuthUser()));
540
            authUserIdAndAuthUserMap.put(ticket.getId(), authUserById.get(ticket.getL1AuthUser()));
541
        }
541
        }
542
        return authUserIdAndAuthUserMap;
542
        return authUserIdAndAuthUserMap;
543
    }
543
    }
544
 
544
 
-
 
545
    private Integer getEffectiveAuthUserId(Ticket ticket) {
-
 
546
 
-
 
547
        if (ticket.getL1AuthUser() > 0) {
-
 
548
            return ticket.getL1AuthUser();
-
 
549
        }
-
 
550
        if (ticket.getL2AuthUser() > 0) {
-
 
551
            return ticket.getL2AuthUser();
-
 
552
        }
-
 
553
        if (ticket.getL3AuthUser() > 0) {
-
 
554
            return ticket.getL3AuthUser();
-
 
555
        }
-
 
556
        return null;
-
 
557
    }
-
 
558
 
-
 
559
 
545
    @Override
560
    @Override
546
    public Map<Integer, TicketSubCategory> getSubCategoryIdAndSubCategoryMap(List<Integer> subCategoryIds) {
561
    public Map<Integer, TicketSubCategory> getSubCategoryIdAndSubCategoryMap(List<Integer> subCategoryIds) {
547
        Map<Integer, TicketSubCategory> subCategoryIdAndSubCategoryMap = new HashMap<>();
562
        Map<Integer, TicketSubCategory> subCategoryIdAndSubCategoryMap = new HashMap<>();
548
        subCategoryIdAndSubCategoryMap = ticketSubCategoryRepository.selectByIds(subCategoryIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
563
        subCategoryIdAndSubCategoryMap = ticketSubCategoryRepository.selectByIds(subCategoryIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
549
        return subCategoryIdAndSubCategoryMap;
564
        return subCategoryIdAndSubCategoryMap;