LsInoutSectionRouteRepository.java 1.84 KB
package com.bsth.repository;

import com.bsth.entity.LsInoutSectionRoute;
import com.bsth.entity.LsSectionRoute;
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 java.util.List;

/**
 * 
 * @Interface: SectionRouteRepository(路段路由Repository数据持久层接口)
 * 
 * @Extends : BaseRepository
 * 
 * @Description: TODO(路段路由Repository数据持久层接口)
 * 
 * @Author bsth@lq
 *
 * @Version 公交调度系统BS版 0.1
 * 
 */

@Repository
public interface LsInoutSectionRouteRepository extends BaseRepository<LsInoutSectionRoute, Long> {

	/**
	 * 查询待更新线路的路段路由
	 */
	@Query(value = "SELECT sr FROM LsInoutSectionRoute sr where sr.line.id =?1 and sr.versions=?2 and sr.start=?3 and sr.end=?4 and sr.destroy=0")
	List<LsInoutSectionRoute> getRouteByStartEnd(int lineId, int version, String start, String end);

	/**
	 *
	 * @param lineCode
	 * @param version
	 * @param start
	 * @param end
	 * @param sectionrouteCode
	 */
	@Modifying
	@Query(value="UPDATE bsth_c_ls_inout_sectionroute set sectionroute_code = (sectionroute_code+1) where line_code = ?1 and versions = ?2  and start = ?3 and end = ?4 and sectionroute_code >=?5 and destroy = 0", nativeQuery=true)
	public void sectionUpdSectionRouteCode(String lineCode, int version, String start, String end, Integer sectionrouteCode);

	/**
	 * 撤销线路某版本进出场
	 * @param lineCode
	 * @param version
	 * @param start
	 * @param end
	 */
	@Modifying
	@Query(value="UPDATE bsth_c_ls_inout_sectionroute set destroy = 1 where line_code = ?1 and versions = ?2  and start = ?3 and end = ?4", nativeQuery=true)
	public void destroy(String lineCode, int version, String start, String end);
}