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.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, JpaSpecificationExecutor { /** * 风险评估计划-查询 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 getAssessPlanByExperimentId(Long experimentId); @Query(value = "select t from RiskAssessPlan t where t.riskUnitId = :riskUnitId and t.deleteStatus = 0") List getAssessPlanByUnitId(Long riskUnitId); /** * 评估计划 - 查询已派发 */ @Query(value = "select t from RiskAssessPlan t where t.planSellStatus = :status and t.deleteStatus = 0") List listAssessPlan(Byte status); @Query(value = "select t from RiskAssessPlan t where t.deleteStatus = 0 and (t.identificationUserId = :currentUserId or t.evaluateUserId = :currentUserId)") List getAssessPlanBySpecialist(Long currentUserId); @Query(value = "select t from RiskAssessPlan t where t.deleteStatus = 0 and t.riskUnitId = :basicId and riskType = 1") List getAssessPlanByInherentUnit(Long basicId); }