LineVersionsRepository.java
2.83 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package com.bsth.repository;
import java.util.Date;
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.Line;
import com.bsth.entity.LineVersions;
/**
*
* @Interface: LineVersionsRepository(线路Repository数据持久层接口)
*
* @Extends : BaseRepository
*
* @Description: TODO(线路版本Repository数据持久层接口)
*
* @Author bsth@lq
*
* @Version 公交调度系统BS版 0.1
*
*/
@Repository
public interface LineVersionsRepository extends BaseRepository<LineVersions, Integer> {
/**
* 获取线路所有版本
*/
@Query(value = " SELECT lv FROM LineVersions lv where lv.line.id = ?1")
public List<LineVersions> findBylineId(int lineId);
@Transactional
@Modifying
@Query(value = "UPDATE LineVersions lv set lv.line=?2, lv.lineCode=?3, lv.startDate=?4, lv.endDate=?5, "
+ "lv.versions=?6, lv.status=?7, lv.remark=?8 where lv.id=?1")
public int update(Integer id, Line line, String lineCode, Date startDate, Date endDate, Integer versions, Integer status,
String remark);
/**
* 查询待更新线路的线路版本
*/
@Query(value = "SELECT lv FROM LineVersions lv where lv.status = 2 and lv.startDate<sysdate() and lv.endDate > sysdate()")
public List<LineVersions> findupdated();
/**
* 更改为历史版本
*/
@Modifying
@Query(value = "UPDATE LineVersions lv set lv.status=0 where lv.line.id=?1 and lv.lineCode=?2 and lv.status=1")
public void updateOdlVersions(Integer lineId, String lineCode);
/**
* 更改为当前版本
*/
@Modifying
@Query(value = "UPDATE LineVersions lv set lv.status=1 where lv.line.id=?1 and lv.lineCode=?2 and lv.versions=?3")
public void updateNewVersions(Integer lineId, String lineCode, Integer versions);
/**
* 查询线路最大线路版本
*/
@Query(value = "select lv2 from LineVersions lv2 where lv2.line.id =?1 and lv2.versions=(SELECT max(lv.versions) FROM LineVersions lv where lv.line.id = ?1) ")
public LineVersions findLineVersionsMax(int lineId);
/**
* 获取线路版本的上一个版本
*/
@Query(value = " SELECT lv FROM LineVersions lv where lv.line.id = ?1 and lv.versions = (?2 - "+1+")")
public LineVersions findBylineIdAndVersions(Integer id, Integer versions);
/**
* 获取线路版本的上一个版本
*/
@Query(value = " SELECT lv.versions FROM LineVersions lv where lv.line.id = ?1 and lv.status=1")
public Integer findCurrentVersion(Integer id);
/**
* 发布版本
*/
@Transactional
@Modifying
@Query(value = "UPDATE LineVersions lv set lv.isupdate=1 where lv.id=?1 ")
public int issueVersion(int id);
}