package com.gkhy.labRiskManage.domain.riskReport.repository.jpa;
|
|
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;
|
import org.springframework.stereotype.Repository;
|
|
import java.time.LocalDateTime;
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* 风险评估-评估项
|
*/
|
@Repository
|
public interface RiskAssessPlanRepository extends JpaRepository<RiskAssessPlan, Long>, JpaSpecificationExecutor<RiskAssessPlan> {
|
|
/**
|
* 风险评估计划-查询 by name
|
*/
|
@Query(value = "select t from RiskAssessPlan t where t.assessPlanName = :assessPlanName and t.deleteStatus = 0")
|
RiskAssessPlan getAssessPlanByName(String assessPlanName);
|
/**
|
* 风险评估计划-查询 by id
|
*/
|
@Query(value = "select t from RiskAssessPlan t where t.id = :id and t.deleteStatus = 0")
|
RiskAssessPlan getAssessPlanById(Long id);
|
/**
|
* 风险评估计划-提交 辨识-评价 结果 --弃用
|
*/
|
@Query(value = "update RiskAssessPlan set plan_exec_status = :#{#execStatusSubmitBO.ExecStatus} where id = :#{#execStatusSubmitBO.id}", nativeQuery = true)
|
RiskAssessPlan execStatusSubmit(ExecStatusSubmitBO execStatusSubmitBO);
|
/**
|
* 风险评估计划- 辨识删除 --弃用
|
*/
|
@Query(value = "update RiskAssessPlan set identification_time = :#date where id = :id", nativeQuery = true)
|
RiskAssessPlan deleteIdentification(Long id, LocalDateTime date);
|
/**
|
* 风险评估计划- 评价删除 --弃用
|
*/
|
@Query(value = "update RiskAssessPlan set evaluate_time = :date where id = :id", nativeQuery = true)
|
RiskAssessPlan deleteEvaluate(Long id, LocalDateTime date);
|
/**
|
* 风险评估计划 - 查询 by 实验id
|
*/
|
@Query(value = "select t from RiskAssessPlan t where t.experimentId = :experimentId and t.deleteStatus = 0")
|
List<RiskAssessPlan> getAssessPlanByExperimentId(Long experimentId);
|
|
@Query(value = "select t from RiskAssessPlan t where t.riskUnitId = :riskUnitId and t.deleteStatus = 0")
|
List<RiskAssessPlan> getAssessPlanByUnitId(Long riskUnitId);
|
|
/**
|
* 评估计划 - 查询已派发
|
*/
|
@Query(value = "select t from RiskAssessPlan t where t.planSellStatus = :status and t.deleteStatus = 0")
|
List<RiskAssessPlan> listAssessPlan(Byte status);
|
|
@Query(value = "select t from RiskAssessPlan t where t.deleteStatus = 0 and (t.identificationUserId = :currentUserId or t.evaluateUserId = :currentUserId)")
|
List<RiskAssessPlan> getAssessPlanBySpecialist(Long currentUserId);
|
|
@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);
|
|
|
}
|