SectionRouteRepository.java 2.43 KB
package com.bsth.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.bsth.entity.SectionRoute;

/**
 * 
 * @Interface: SectionRouteRepository(路段路由Repository数据持久层接口)
 * 
 * @Extends : BaseRepository
 * 
 * @Description: TODO(路段路由Repository数据持久层接口)
 * 
 * @Author bsth@lq
 * 
 * @Date 2016年05月03日 上午9:21:17
 *
 * @Version 公交调度系统BS版 0.1
 * 
 */

@Repository
public interface SectionRouteRepository extends BaseRepository<SectionRoute, Integer> {
	
	/**
	 * @Description :TODO(查询路段信息)
	 * 
	 * @param map <lineId:线路ID; directions:方向>
	 * 
	 * @return List<Object[]>
	 */
	@Query(value ="SELECT  a.sectionrouteId," +
			 "a.sectionrouteLine," +
			" a.sectionrouteLineCode," +
			" a.sectionrouteSection," +
			" a.sectionrouteSectionCode," +
			" a.sectionrouteCode," +
			" a.sectionrouteDirections," +
			" b.id AS sectionId," +
			" b.section_code AS sectionCode," +
			" b.section_name AS sectionName," +
			" b.croses_road AS sectionRoad," +
			" b.end_node AS sectionEndNode," +
			" b.start_node AS sectionStartNode," +
			" b.middle_node AS sectionMiddleNode," +
	        " b.section_type AS sectionType," +
			" b.csection_vector AS sectionCsectionVector," +
			" AsText(b.bsection_vector) AS sectionBsectionVector," +
			" AsText(b.gsection_vector) sectionGsectionVector," +
			" b.road_coding AS sectionRoadCoding," +
			" b.section_distance AS sectionDistance," +
            " b.section_time AS sectionTime," +
			" b.db_type AS sectiondbType," +
			" b.speed_limit AS sectionSpeedLimet FROM (" +
						"SELECT  r.id AS sectionrouteId," +
								"r.line AS sectionrouteLine," +
								"r.line_code AS sectionrouteLineCode," +
								"r.section AS sectionrouteSection," +
								"r.section_code AS sectionrouteSectionCode," +
								"r.sectionroute_code AS sectionrouteCode," +
								"r.directions AS sectionrouteDirections" +
								" FROM bsth_c_sectionroute r where r.line = ?1 and r.directions = ?2 and r.destroy=0 ) a " +
								"	LEFT JOIN bsth_c_section b  ON a.sectionrouteSection = b.id", nativeQuery=true)
	List<Object[]> getSectionRoute(int lineId, int directions);
	
}