“mitao”
2026-03-25 8f30811c233b02eb692107c03befaef8a55ca45a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.estate.expert.admin.domain.exam.record;
 
import com.estate.expert.admin.domain.common.EntityBaseRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
 
import java.util.List;
 
public interface RecordRepository extends EntityBaseRepository<Record> {
 
    @Query("select r.problem.id, count(r) from Record r " +
            "where r.deleted = false " +
            "and r.device is null " +
            "and r.problem is not null " +
            "and r.problem.id in :problemIds " +
            "and r.checkTask.id in :taskIds " +
            "group by r.problem.id")
    List<Object[]> countSystemChecksByTaskIdsAndProblemIds(@Param("taskIds") List<Integer> taskIds,
                                                           @Param("problemIds") List<Integer> problemIds);
 
    @Query(value = "select r.device_id, r.problem_id, count(*) " +
            "from record r " +
            "where r.deleted = false " +
            "and r.device_id is not null " +
            "and r.problem_id is not null " +
            "and r.check_task_id in (:taskIds) " +
            "group by r.device_id, r.problem_id", nativeQuery = true)
    List<Object[]> countDeviceChecksByTaskIds(@Param("taskIds") List<Integer> taskIds);
}