package com.dashitech.businessdata.dao;

import com.dashitech.businessdata.entity.WorkOrderEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by xuweihua on 2020/11/20.
 */
public interface IWorkOrderDAO  extends JpaRepository<WorkOrderEntity, String> {
    @SuppressWarnings("unchecked")
    WorkOrderEntity save(WorkOrderEntity workOrderEntity);

    @Query(value = "select * from itsm_transport_workorder where patientId =?1 and gdstate in(69,70,71,433) " +
            "and task_type_id in (SELECT id from itsm_task_type WHERE delete_flag = 0 and association_type_id = " +
            "(SELECT id from itsm_base_dictionary WHERE _key = 'association_types' and _value = 'inspect' LIMIT 1))",nativeQuery = true)
    List<WorkOrderEntity> selectWorkOrderByPatientId(String patientId);
}
