StationRouteCacheRepository.java 2.5 KB
package com.bsth.repository;

import java.util.List;
import java.util.Map;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.EntityGraph;
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.Line;
import com.bsth.entity.StationRoute;
import com.bsth.entity.StationRouteCache;

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

@Repository
public interface StationRouteCacheRepository extends BaseRepository<StationRouteCache, Integer> {
	
	/**
	 * @Description :TODO(站点中心点坐标查询)
	 * 
	 * @param map <lineId:线路ID; direction:方向>
	 * 
	 * @return List<Object[]>
	 */
	/*@Query(value = "SELECT s.b_jwpoints,s.station_name FROM (" +
						"SELECT b.station FROM bsth_c_stationroute b where b.line =?1 and b.directions = ?2 and b.destroy=0) r " +
				   "LEFT JOIN bsth_c_station s on r.station = s.id", nativeQuery=true)*/
	@Query(value = "SELECT s.b_jwpoints,r.station_name,r.station_route_code FROM (" +
			"SELECT b.station,b.station_route_code,b.station_name FROM bsth_c_stationroute_cache b where b.line =?1 and b.directions = ?2 and b.destroy=0) r " +
	   "LEFT JOIN bsth_c_station s on r.station = s.id order by r.station_route_code asc", nativeQuery=true)
	List<Object[]> getSelectStationRouteCenterPoints(Integer lineId,Integer direction);
	
	/**
     * 查询站点路由
     */
    @Query("select r from StationRouteCache r where r.lineCode=?1 and r.directions=?2 and r.destroy=0 order by r.stationRouteCode")
    public List<StationRouteCache> findstationRoute(String lineCode,Integer dir);
	
	/**
     * 更新路线删除线路缓存站点
     * 
     * @param line
     * @param dir
     */
    @Modifying
    @Query(value="delete from bsth_c_stationroute_cache where line = ?1 and directions = ?2 ", nativeQuery=true)
    public void stationRouteCacheDel(Integer line,Integer dir);
    
}