StationRepository.java 1.74 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.Station;

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

@Repository
public interface StationRepository extends BaseRepository<Station, Integer> {
	
	/**
	 * @Description :TODO(查询最大站点ID)
	 * 
	 * @return int <站点id>
	 */
	@Query(value = "SELECT IFNULL(MAX(id), 0) FROM bsth_c_station", nativeQuery = true)
	int stationMaxId();

	@Query(value = " SELECT CONCAT(ST_X(t.center_point), ' ', ST_Y(t.center_point)) b_jwpoints,t.id FROM (" +
			" SELECT b.id,b.center_point,b.station_name,a.directions FROM (" +
			" SELECT s.station,s.station_name,s.directions FROM bsth_c_stationroute s where s.destroy = 0 and s.directions = ?1) a " +
			" LEFT JOIN bsth_c_station b on a.station = b. id) t where t.station_name LIKE ?2"
			, nativeQuery=true)
	List<Object[]> findStationName(Integer dir , String stationName);
	
	@Query(value = "SELECT ST_AsText(b.buffer_polygon_wgs) g_polygon_grid, b.shaped_type,CONCAT(ST_X(a.center_point), ' ', ST_Y(a.center_point)) g_center_point , b.radius, a.station_code, b.station_name FROM bsth_c_station a JOIN bsth_c_stationroute b ON a.id = b.station WHERE b.line_code = ?1 AND a.station_code = ?2", nativeQuery = true)
	Object[][] bufferAera(String lineCode, String stationCode);
}