package com.yeejoin.amos.patrol.business.dao.repository;

import java.util.List;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.yeejoin.amos.patrol.dao.entity.PlanTaskDetail;
@Repository("planTaskDetail")
public interface IPlanTaskDetailDao extends BaseDao<PlanTaskDetail, Long> {

	@Modifying
	@Transactional
	@Query(value = "DELETE FROM p_plan_task_detail WHERE point_id IN (?1)", nativeQuery = true)
	void deletePlanTaskDetailByPointId(List<Long> pointIds);
	
	/**
	 * 根据任务id获取任务详情
	 * @param planTaskId
	 * @return
	 */
	public List<PlanTaskDetail> findAllByTaskNo(Long planTaskId);
	
	/**
	 * 根据任务id及状态获取计划详情
	 * @param planTaskId
	 * @return
	 */
	public List<PlanTaskDetail> findAllByTaskNoAndStatus(Long planTaskId,String status);
	
	
	int countByIsFinish(int status);
	
	int countByIsFinishAndTaskNo(int status,Long taskNo);
	
	@Modifying
	@Transactional
	@Query(value = "DELETE FROM p_plan_task_detail WHERE task_no IN (?1)", nativeQuery = true)
	void deletePlanTaskDetailByTaskNo(List<Long> planTaskNo);

	@Query(value = "select * FROM p_plan_task_detail WHERE point_id IN (?1)", nativeQuery = true)
    List<PlanTaskDetail> findALLByPointId(Long pointId);
}
