LsInoutSectionRouteRepository.java
2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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 order by sr.sectionrouteCode")
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);
/**
* 在站点路由更新时(站点路由可能改变路由编号,如起点、改变上一站点)
* 将当前路由编号及以后的编号批量递增10
* @param sectionRoute
*/
@Modifying
@Query(value="UPDATE bsth_c_ls_inout_sectionroute set sectionroute_code = (sectionroute_code + 10) where line = :#{#sectionRoute.line.id} and destroy = 0 and versions = :#{#sectionRoute.versions} and directions = :#{#sectionRoute.directions} and sectionroute_code >= :#{#sectionRoute.sectionrouteCode}", nativeQuery=true)
void updateSectiouRouteCode(LsInoutSectionRoute sectionRoute);
/**
* 撤销线路版本下某个方向进出场整个路由组
* @param lineCode
* @param version
* @param start
* @param end
*/
@Modifying
@Query(value="UPDATE bsth_c_ls_inout_sectionroute set destroy = 1 where id = ?1 and versions = ?2 and start = ?3 and end = ?4", nativeQuery=true)
void destroy(String lineCode, int version, String start, String end);
/**
* 按ID撤销进出场路由组中一个路由
* @param id
*/
@Modifying
@Query(value="UPDATE bsth_c_ls_inout_sectionroute set destroy = 1 where id = ?1", nativeQuery=true)
void destroy(Integer id);
}