Untitled

 avatar
unknown
plain_text
22 days ago
1.4 kB
5
Indexable
@Query("""
    SELECT s AS staff,
           ar.id AS attendanceRecordId,
           ar.timeOffTypeName AS timeOffTypeName,
           ar.timeOffPaidType AS timeOffPaidType,
           ar.timeOffRequestItemAmount AS timeOffAmount,
           ar.timeOffRequestId AS timeOffRequestId,
           ar.timeOffItemId AS timeOffItemId
    FROM Staff s
    LEFT JOIN AttendanceRecord ar
           ON ar.staffId = s.id
          AND ar.dateId BETWEEN :startDateId AND :endDateId
          AND ar.recordSource = 'TIME_OFF_SYNC'
    WHERE s.companyId = :companyId
      AND s.disabled = false
      AND EXISTS (
              SELECT 1 FROM StaffAssignedStore sas
              WHERE sas.staffId = s.id AND sas.storeId IN :storeIds
          )
      AND ( ar.id IS NOT NULL
            OR NOT EXISTS (
                   SELECT 1 FROM AttendanceRecord ar2
                   WHERE ar2.staffId = s.id
                     AND ar2.dateId BETWEEN :startDateId AND :endDateId
               ))
    ORDER BY (CASE WHEN ar.id IS NULL THEN 1 ELSE 0 END) ASC,
             s.fullName ASC,
             s.id ASC
    """)
Page<DayOffStaffRow> findDayOffStaff(   // ← fix the typo too
        @Param("companyId") long companyId,
        @Param("storeIds") Collection<Long> storeIds,
        @Param("startDateId") int startDateId,
        @Param("endDateId") int endDateId,
        Pageable pageable);
Editor is loading...
Leave a Comment