liujie
2026-04-01 4b33796be3887c81fa40fba2f55dce4489cff041
admin-server/src/main/java/com/estate/expert/admin/domain/exam/record/error/ErrorRecordRepository.java
@@ -99,6 +99,39 @@
            "and w.deleted = false")
    List<ErrorRecord> listDeviceErrors(Integer checkTaskId);
    @Query("select w.problem.id, count(w) from ErrorRecord w " +
            "where w.deleted = false " +
            "and w.device is null " +
            "and w.level is not null " +
            "and w.problem is not null " +
            "and w.problem.id in :problemIds " +
            "and w.checkTask.project.id = :projectId " +
            "and w.checkTask.state in :taskStates " +
            "group by w.problem.id")
    List<Object[]> countSystemHazardsByProjectAndProblemIds(@Param("projectId") Integer projectId,
                                                           @Param("taskStates") List<com.estate.expert.admin.domain.exam.task.check.CheckTaskState> taskStates,
                                                           @Param("problemIds") List<Integer> problemIds);
    @Query("select w.problem.id, count(w) from ErrorRecord w " +
            "where w.deleted = false " +
            "and w.device is null " +
            "and w.problem is not null " +
            "and w.problem.id in :problemIds " +
            "and w.checkTask.id in :taskIds " +
            "group by w.problem.id")
    List<Object[]> countSystemHazardsByTaskIdsAndProblemIds(@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.record_type = 'error' " +
            "and r.check_task_id in (:taskIds) " +
            "group by r.device_id, r.problem_id", nativeQuery = true)
    List<Object[]> countDeviceHazardsByTaskIds(@Param("taskIds") List<Integer> taskIds);
    //根据人员来获取检查成果
    @Query("select w from ErrorRecord w where w.deleted = false  and w.creator.id = :creatorId"+ " and ( :startDate is null or w.createTime >= :startDate) " +
            "and ( :endDate is null or w.createTime < :endDate) " )
@@ -116,4 +149,4 @@
    @Query("select w from ErrorRecord w join fetch w.problem pr join fetch w.checkTask c join fetch c.project p where w.deleted = false and pr.hierarchyId = 1 " )
    List<ErrorRecord> getErrorRecordByNotDevice();
}
}