heheng
2025-05-16 8485affcb0d4de05059d80cb1e844d6b18291654
src/main/java/com/gkhy/labRiskManage/domain/riskReport/repository/jpa/RiskAssessPlanRepository.java
@@ -3,6 +3,7 @@
import com.gkhy.labRiskManage.domain.riskReport.entity.RiskAssessPlan;
import com.gkhy.labRiskManage.domain.riskReport.model.bo.ExecStatusSubmitBO;
import com.gkhy.labRiskManage.domain.riskReport.model.dto.AssessPlanQueryDTO;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
@@ -63,5 +64,20 @@
    @Query(value = "select t from RiskAssessPlan t where t.deleteStatus = 0 and t.riskUnitId = :basicId and riskType = 1")
    List<RiskAssessPlan> getAssessPlanByInherentUnit(Long basicId);
    @Query("SELECT COUNT(DISTINCT p.id) FROM RiskAssessPlan p " +
            "WHERE p.deleteStatus = 0 " +
            "AND (:assessPlanName IS NULL OR p.assessPlanName LIKE %:assessPlanName%) " +
            "AND (:experimentId IS NULL OR p.experimentId = :experimentId) " +
            "AND (:planUserId IS NULL OR p.planUserId = :planUserId) " +
            "and(coalesce(:riskUnitIds,null) is null  or p.riskUnitId in :riskUnitIds)")
    Long countDynamic(
            String assessPlanName,
            Long experimentId,
            Long planUserId,
            List<Long> riskUnitIds);
}