Commit a896941c8d35c500e5f0bf8bb6b745299b6af3d0
1 parent
9f313699
统计报表:到离站中车辆与站点查询可查历史配车与站点;调度历史消息添加设备回复与驾驶员回复
Showing
4 changed files
with
785 additions
and
746 deletions
Too many changes to show.
To preserve performance only 4 of 10 files are displayed.
src/main/java/com/bsth/controller/report/ReportController.java
| @@ -294,6 +294,11 @@ public class ReportController { | @@ -294,6 +294,11 @@ public class ReportController { | ||
| 294 | return service.carList(map); | 294 | return service.carList(map); |
| 295 | } | 295 | } |
| 296 | 296 | ||
| 297 | + @RequestMapping(value="/carListByHistory",method = RequestMethod.GET) | ||
| 298 | + public List<Map<String,String>> carListByHistory(@RequestParam Map<String, Object> map){ | ||
| 299 | + return service.carListByHistory(map); | ||
| 300 | + } | ||
| 301 | + | ||
| 297 | @RequestMapping(value="/userList",method = RequestMethod.GET) | 302 | @RequestMapping(value="/userList",method = RequestMethod.GET) |
| 298 | public List<Map<String,String>> userList(@RequestParam Map<String, Object> map){ | 303 | public List<Map<String,String>> userList(@RequestParam Map<String, Object> map){ |
| 299 | return service.userList(map); | 304 | return service.userList(map); |
src/main/java/com/bsth/data/BasicData.java
| @@ -6,9 +6,11 @@ import java.util.ArrayList; | @@ -6,9 +6,11 @@ import java.util.ArrayList; | ||
| 6 | import java.util.Calendar; | 6 | import java.util.Calendar; |
| 7 | import java.util.Date; | 7 | import java.util.Date; |
| 8 | import java.util.HashMap; | 8 | import java.util.HashMap; |
| 9 | +import java.util.HashSet; | ||
| 9 | import java.util.Iterator; | 10 | import java.util.Iterator; |
| 10 | import java.util.List; | 11 | import java.util.List; |
| 11 | import java.util.Map; | 12 | import java.util.Map; |
| 13 | +import java.util.Set; | ||
| 12 | 14 | ||
| 13 | import org.apache.commons.lang3.StringUtils; | 15 | import org.apache.commons.lang3.StringUtils; |
| 14 | import org.slf4j.Logger; | 16 | import org.slf4j.Logger; |
| @@ -71,6 +73,9 @@ public class BasicData { | @@ -71,6 +73,9 @@ public class BasicData { | ||
| 71 | //车辆和线路对照 | 73 | //车辆和线路对照 |
| 72 | public static Map<String, Line> nbbm2LineMap; | 74 | public static Map<String, Line> nbbm2LineMap; |
| 73 | 75 | ||
| 76 | + //线路历史配车(K: 线路编码 ,V:List<车辆自编号>) | ||
| 77 | + public static Map<String, List<String>> lineCodeHistoryNbbmMap; | ||
| 78 | + | ||
| 74 | //线路ID和code 对照 | 79 | //线路ID和code 对照 |
| 75 | public static BiMap<Integer, String> lineId2CodeMap; | 80 | public static BiMap<Integer, String> lineId2CodeMap; |
| 76 | 81 | ||
| @@ -180,6 +185,7 @@ public class BasicData { | @@ -180,6 +185,7 @@ public class BasicData { | ||
| 180 | loadLineInfo(); | 185 | loadLineInfo(); |
| 181 | //车辆和线路映射信息 | 186 | //车辆和线路映射信息 |
| 182 | loadNbbm2LineInfo(); | 187 | loadNbbm2LineInfo(); |
| 188 | + loadLineCodeHistoryNbbmMapInfo(); | ||
| 183 | //人员信息 | 189 | //人员信息 |
| 184 | loadPersonnelInfo(); | 190 | loadPersonnelInfo(); |
| 185 | //公司信息 | 191 | //公司信息 |
| @@ -293,6 +299,30 @@ public class BasicData { | @@ -293,6 +299,30 @@ public class BasicData { | ||
| 293 | } | 299 | } |
| 294 | 300 | ||
| 295 | /** | 301 | /** |
| 302 | + * @Title: loadLineCodeHistoryNbbmMapInfo | ||
| 303 | + * @Description: TODO(线路历史配车) | ||
| 304 | + */ | ||
| 305 | + public void loadLineCodeHistoryNbbmMapInfo() { | ||
| 306 | + Iterator<CarConfigInfo> allIterator = carConfigInfoRepository.findAll().iterator(); | ||
| 307 | + Map<String, List<String>> ccMap = new HashMap<>(); //用list保持排序 | ||
| 308 | + Map<String, Set<String>> sMap = new HashMap<>(); //用Set去重 | ||
| 309 | + | ||
| 310 | + CarConfigInfo cci; | ||
| 311 | + while (allIterator.hasNext()) { | ||
| 312 | + cci = allIterator.next(); | ||
| 313 | + String lineCode = cci.getXl().getLineCode(); | ||
| 314 | + if(!ccMap.containsKey(lineCode)){ | ||
| 315 | + ccMap.put(lineCode, new ArrayList<String>()); | ||
| 316 | + sMap.put(lineCode, new HashSet<String>()); | ||
| 317 | + } | ||
| 318 | + if(sMap.get(lineCode).add(cci.getCl().getInsideCode())){ | ||
| 319 | + ccMap.get(lineCode).add(cci.getCl().getInsideCode()); | ||
| 320 | + } | ||
| 321 | + } | ||
| 322 | + lineCodeHistoryNbbmMap = ccMap; | ||
| 323 | + } | ||
| 324 | + | ||
| 325 | + /** | ||
| 296 | * @Title: loadLineInfo | 326 | * @Title: loadLineInfo |
| 297 | * @Description: TODO(加载线路相关信息) | 327 | * @Description: TODO(加载线路相关信息) |
| 298 | */ | 328 | */ |
src/main/java/com/bsth/repository/StationRouteRepository.java
| 1 | -package com.bsth.repository; | ||
| 2 | - | ||
| 3 | -import java.util.List; | ||
| 4 | -import java.util.Map; | ||
| 5 | - | ||
| 6 | -import org.springframework.data.domain.Page; | ||
| 7 | -import org.springframework.data.domain.Pageable; | ||
| 8 | -import org.springframework.data.domain.Sort; | ||
| 9 | -import org.springframework.data.jpa.domain.Specification; | ||
| 10 | -import org.springframework.data.jpa.repository.EntityGraph; | ||
| 11 | -import org.springframework.data.jpa.repository.Modifying; | ||
| 12 | -import org.springframework.data.jpa.repository.Query; | ||
| 13 | -import org.springframework.stereotype.Repository; | ||
| 14 | -import org.springframework.transaction.annotation.Transactional; | ||
| 15 | - | ||
| 16 | -import com.bsth.entity.Line; | ||
| 17 | -import com.bsth.entity.StationRoute; | ||
| 18 | - | ||
| 19 | -/** | ||
| 20 | - * | ||
| 21 | - * @Interface: StationRouteRepository(站点路由Repository数据持久层接口) | ||
| 22 | - * | ||
| 23 | - * @Extends : BaseRepository | ||
| 24 | - * | ||
| 25 | - * @Description: TODO(站点路由Repository数据持久层接口) | ||
| 26 | - * | ||
| 27 | - * @Author bsth@lq | ||
| 28 | - * | ||
| 29 | - * @Date 2016年5月03日 上午9:21:17 | ||
| 30 | - * | ||
| 31 | - * @Version 公交调度系统BS版 0.1 | ||
| 32 | - * | ||
| 33 | - */ | ||
| 34 | - | ||
| 35 | -@Repository | ||
| 36 | -public interface StationRouteRepository extends BaseRepository<StationRoute, Integer> { | ||
| 37 | - | ||
| 38 | - @Query(value = "SELECT a.`stationRoute.id`," + | ||
| 39 | - "a.`stationRoute.line`," + | ||
| 40 | - "a.`stationRoute.station`," + | ||
| 41 | - "a.`stationRoute.stationName`," + | ||
| 42 | - "a.`stationRoute.stationRouteCode`," + | ||
| 43 | - "a.`stationRoute.lineCode`," + | ||
| 44 | - "a.`stationRoute.stationMark`," + | ||
| 45 | - "a.`stationRoute.outStationNmber`," + | ||
| 46 | - "a.`stationRoute.directions`," + | ||
| 47 | - "a.`stationRoute.distances`," + | ||
| 48 | - "a.`stationRoute.toTime`," + | ||
| 49 | - "a.`stationRoute.firstTime`," + | ||
| 50 | - "a.`stationRoute.endTime`," + | ||
| 51 | - "a.`stationRoute.descriptions`," + | ||
| 52 | - "a.`stationRoute.versions`," + | ||
| 53 | - "b.id AS 'station.id'," + | ||
| 54 | - "b.station_cod AS 'station.stationCod'," + | ||
| 55 | - "b.station_name AS 'station.stationName'," + | ||
| 56 | - "b.road_coding AS 'station.roadCoding'," + | ||
| 57 | - "b.db_type AS 'station.dbType'," + | ||
| 58 | - "b.b_jwpoints AS 'station.bJwpoints'," + | ||
| 59 | - "b.g_lonx AS 'station.gLonx'," + | ||
| 60 | - "b.g_lonx AS 'station.gLaty'," + | ||
| 61 | - "b.x AS 'station.x'," + | ||
| 62 | - "b.y AS 'station.y'," + | ||
| 63 | - "b.shapes_type AS 'station.shapesType'," + | ||
| 64 | - "b.radius AS 'station.radius'," + | ||
| 65 | - "ST_AsText(b.g_polygon_grid) AS 'station.gPolygonGrid'," + | ||
| 66 | - "ST_AsText(b.b_polygon_grid) AS 'station.bPolygonGrid'," + | ||
| 67 | - "b.destroy AS 'station.destroy'," + | ||
| 68 | - "b.versions AS 'station.versions'," + | ||
| 69 | - "b.descriptions AS 'station.descriptions', " + | ||
| 70 | - "a.`stationRoute.industryCode` " + | ||
| 71 | - " FROM (" + | ||
| 72 | - "SELECT r.id AS 'stationRoute.id'," + | ||
| 73 | - " r.line AS 'stationRoute.line'," + | ||
| 74 | - "r.station AS 'stationRoute.station'," + | ||
| 75 | - "r.station_name AS 'stationRoute.stationName'," + | ||
| 76 | - "r.station_route_code as 'stationRoute.stationRouteCode'," + | ||
| 77 | - "r.line_code AS 'stationRoute.lineCode'," + | ||
| 78 | - "r.station_mark AS 'stationRoute.stationMark'," + | ||
| 79 | - "r.out_station_nmber AS 'stationRoute.outStationNmber'," + | ||
| 80 | - "r.directions AS 'stationRoute.directions'," + | ||
| 81 | - "r.distances AS 'stationRoute.distances'," + | ||
| 82 | - "r.to_time AS 'stationRoute.toTime'," + | ||
| 83 | - "r.first_time AS 'stationRoute.firstTime'," + | ||
| 84 | - "r.end_time AS 'stationRoute.endTime'," + | ||
| 85 | - "r.descriptions AS 'stationRoute.descriptions'," + | ||
| 86 | - "r.versions AS 'stationRoute.versions', " + | ||
| 87 | - "r.industry_code AS 'stationRoute.industryCode' " + | ||
| 88 | - " FROM bsth_c_stationroute r WHERE r.line = ?1 and r.directions = ?2 and r.destroy=0) a " + | ||
| 89 | - "LEFT JOIN bsth_c_station b " + | ||
| 90 | - "ON a.`stationRoute.station` = b.id ORDER BY a.`stationRoute.stationRouteCode` ASC", nativeQuery=true) | ||
| 91 | - List<Object[]> findPoints(int line,int directions); | ||
| 92 | - | ||
| 93 | - @Query("select r from StationRoute r where r.line.id=?1 and r.destroy=0 order by r.directions ASC ,r.stationRouteCode ASC") | ||
| 94 | - // @Query(value = "SELECT * from bsth_c_stationroute line = ?1 and destroy=0 bsth_c_station ORDER BY directions ASC, stationRouteCode ASC", nativeQuery=true) | ||
| 95 | - List<StationRoute> findStationExport(int line); | ||
| 96 | - | ||
| 97 | - /** | ||
| 98 | - * @Description :TODO(查询线路某方向下的站点序号与类型) | ||
| 99 | - * | ||
| 100 | - * @param map <lineId:线路ID; direction:方向;stationRouteCode:站点编码> | ||
| 101 | - * | ||
| 102 | - * @return List<Map<String, Object>> | ||
| 103 | - */ | ||
| 104 | - @Query(value = "select t.station_route_code,t.station_mark from bsth_c_stationroute t where " + | ||
| 105 | - " t.station_route_code =(" + | ||
| 106 | - "select MAX(station_route_code) as stationRouteCode from bsth_c_stationroute r WHERE " + | ||
| 107 | - "r.line=?1 and r.directions =?2 and station_route_code< ?3 and r.destroy = 0 ) and t.line=?1 and t.directions = ?2 AND t.destroy = 0", nativeQuery=true) | ||
| 108 | - List<Object[]> findUpStationRouteCode(Integer lineId,Integer direction,Integer stationRouteCode); | ||
| 109 | - | ||
| 110 | - /** | ||
| 111 | - * @param version | ||
| 112 | - * @Description :TODO(查询下个站点) | ||
| 113 | - * | ||
| 114 | - * @param map <lineId:线路ID; direction:方向;stationRouteCode:站点编码> | ||
| 115 | - * | ||
| 116 | - * @return List<Map<String, Object>> | ||
| 117 | - */ | ||
| 118 | - @Query(value = "SELECT a.stationRouteLine," + | ||
| 119 | - " a.stationRouteStation," + | ||
| 120 | - " a.stationRouteCode," + | ||
| 121 | - " a.stationRouteLIneCode," + | ||
| 122 | - " a.stationRouteStationMark," + | ||
| 123 | - " a.stationOutStationNmber," + | ||
| 124 | - " a.stationRoutedirections," + | ||
| 125 | - " a.stationRouteDistances," + | ||
| 126 | - " a.stationRouteToTime," + | ||
| 127 | - " a.staitonRouteFirstTime," + | ||
| 128 | - " a.stationRouteEndTime," + | ||
| 129 | - " a.stationRouteDescriptions," + | ||
| 130 | - " a.stationRouteDestroy," + | ||
| 131 | - " a.stationRouteVersions," + | ||
| 132 | - " a.stationRouteCreateBy," + | ||
| 133 | - " a.stationRouteCreateDate," + | ||
| 134 | - " a.stationRouteUpdateBy," + | ||
| 135 | - " a.stationRouteUpdateDate," + | ||
| 136 | - " b.id AS stationId," + | ||
| 137 | - " b.station_cod AS stationCode," + | ||
| 138 | - " a.stationRouteName," + | ||
| 139 | - " b.road_coding AS stationRoadCoding," + | ||
| 140 | - " b.db_type AS stationDbType," + | ||
| 141 | - " b.b_jwpoints AS stationJwpoints," + | ||
| 142 | - " b.g_lonx AS stationGlonx," + | ||
| 143 | - " b.g_laty AS stationGlaty," + | ||
| 144 | - " b.x AS stationX," + | ||
| 145 | - " b.y AS stationY," + | ||
| 146 | - " ST_AsText(b.b_polygon_grid) as stationBPolyonGrid," + | ||
| 147 | - " ST_AsText(b.g_polygon_grid) AS stationGPloyonGrid, " + | ||
| 148 | - " b.destroy AS stationDestroy," + | ||
| 149 | - " b.radius AS stationRadius," + | ||
| 150 | - " b.shapes_type AS stationShapesType," + | ||
| 151 | - " b.versions AS stationVersions," + | ||
| 152 | - " b.descriptions AS sttationDescriptions," + | ||
| 153 | - " b.create_by AS stationCreateBy," + | ||
| 154 | - " b.create_date AS stationCreateDate," + | ||
| 155 | - " b.update_by AS stationUpdateBy," + | ||
| 156 | - " b.update_date AS stationUpdateDate," + | ||
| 157 | - " a.stationRouteId, " + | ||
| 158 | - " b.station_name as zdmc, " + | ||
| 159 | - " a.industryCode"+ | ||
| 160 | - " FROM " + | ||
| 161 | - "( SELECT s.id AS stationRouteId," + | ||
| 162 | - " s.line AS stationRouteLine," + | ||
| 163 | - " s.station as stationRouteStation," + | ||
| 164 | - " s.station_name AS stationRouteName," + | ||
| 165 | - " s.station_route_code as stationRouteCode," + | ||
| 166 | - " s.industry_code as industryCode," + | ||
| 167 | - " s.line_code AS stationRouteLIneCode," + | ||
| 168 | - " s.station_mark AS stationRouteStationMark," + | ||
| 169 | - " s.out_station_nmber AS stationOutStationNmber," + | ||
| 170 | - " s.directions AS stationRoutedirections," + | ||
| 171 | - " s.distances AS stationRouteDistances," + | ||
| 172 | - " s.to_time AS stationRouteToTime," + | ||
| 173 | - " s.first_time AS staitonRouteFirstTime," + | ||
| 174 | - " s.end_time AS stationRouteEndTime," + | ||
| 175 | - " s.descriptions AS stationRouteDescriptions," + | ||
| 176 | - " s.destroy AS stationRouteDestroy," + | ||
| 177 | - " s.versions AS stationRouteVersions," + | ||
| 178 | - " s.create_by AS stationRouteCreateBy," + | ||
| 179 | - " s.create_date AS stationRouteCreateDate," + | ||
| 180 | - " s.update_by AS stationRouteUpdateBy," + | ||
| 181 | - " s.update_date AS stationRouteUpdateDate FROM bsth_c_ls_stationroute s WHERE s.versions = ?4 and s.station_route_code =(" + | ||
| 182 | - "select MIN(station_route_code) as stationRouteCode from bsth_c_ls_stationroute r WHERE " + | ||
| 183 | - "r.line=?1 and r.directions =?2 and station_route_code > ?3 and r.destroy = 0 and versions = ?4 ) and s.line=?1 and s.directions = ?2 AND s.destroy = 0) a " + | ||
| 184 | - " LEFT JOIN bsth_c_station b ON a.stationRouteStation = b.id", nativeQuery=true) | ||
| 185 | - List<Object[]> findDownStationRoute(Integer id,Integer direction,Integer stationRouteCode, Integer version); | ||
| 186 | - | ||
| 187 | - /** | ||
| 188 | - * @Description :TODO(站点中心点坐标查询) | ||
| 189 | - * | ||
| 190 | - * @param map <lineId:线路ID; direction:方向> | ||
| 191 | - * | ||
| 192 | - * @return List<Object[]> | ||
| 193 | - */ | ||
| 194 | - /*@Query(value = "SELECT s.b_jwpoints,s.station_name FROM (" + | ||
| 195 | - "SELECT b.station FROM bsth_c_stationroute b where b.line =?1 and b.directions = ?2 and b.destroy=0) r " + | ||
| 196 | - "LEFT JOIN bsth_c_station s on r.station = s.id", nativeQuery=true)*/ | ||
| 197 | - @Query(value = "SELECT s.b_jwpoints,r.station_name,r.station_route_code FROM (" + | ||
| 198 | - "SELECT b.station,b.station_route_code,b.station_name FROM bsth_c_stationroute b where b.line =?1 and b.directions = ?2 and b.destroy=0) r " + | ||
| 199 | - "LEFT JOIN bsth_c_station s on r.station = s.id order by r.station_route_code asc", nativeQuery=true) | ||
| 200 | - List<Object[]> getSelectStationRouteCenterPoints(Integer lineId,Integer direction); | ||
| 201 | - | ||
| 202 | - /** | ||
| 203 | - * @Description :TODO(撤销站点) | ||
| 204 | - * | ||
| 205 | - * @param map <lineId:线路ID; destroy:是否撤销(0:否;1:是)> | ||
| 206 | - * | ||
| 207 | - */ | ||
| 208 | - @Transactional | ||
| 209 | - @Modifying | ||
| 210 | - @Query(value="UPDATE bsth_c_stationroute SET " + | ||
| 211 | - "destroy = ?2 WHERE id = ?1", nativeQuery=true) | ||
| 212 | - void stationRouteIsDestroyUpd(Integer stationRouteId, Integer destroy); | ||
| 213 | - | ||
| 214 | - | ||
| 215 | - /** | ||
| 216 | - * @Description : TODO(根据线路ID生成行单) | ||
| 217 | - * | ||
| 218 | - * @param lineId:线路ID | ||
| 219 | - * | ||
| 220 | - * @return List<Object[]>:{[0]:g_lonx(GPS经度);[1]:g_laty(GPS纬度);[2]:b_jwpoints(百度经纬度坐标) | ||
| 221 | - * | ||
| 222 | - * [3]:station_mark(站点类型);[4]:station_route_code(站点序号);[5]:station_cod(站点编码); | ||
| 223 | - * | ||
| 224 | - * [6]:distances(站点距离);[7]:station_name(站点名称);[8]:directions(方向)} | ||
| 225 | - */ | ||
| 226 | - @Query(value = "SELECT * FROM ("+ | ||
| 227 | - "SELECT b.g_lonx," + | ||
| 228 | - "b.g_laty,b.b_jwpoints," + | ||
| 229 | - "a.station_mark," + | ||
| 230 | - "a.station_route_code," + | ||
| 231 | - "b.station_cod," + | ||
| 232 | - "a.distances,"+ | ||
| 233 | - "a.station_name," + | ||
| 234 | - "a.directions FROM (SELECT " + | ||
| 235 | - "s.station_mark," + | ||
| 236 | - "s.station_route_code," + | ||
| 237 | - "s.directions," + | ||
| 238 | - "s.distances,"+ | ||
| 239 | - "s.station_name,"+ | ||
| 240 | - "s.station FROM bsth_c_stationroute s where s.line = ?1 and s.destroy=0) a " + | ||
| 241 | - "LEFT JOIN bsth_c_station b " + | ||
| 242 | - " on a.station = b.id ORDER BY a.directions ASC ) k ORDER BY k.directions,k.station_route_code ASC", nativeQuery=true) | ||
| 243 | - List<Object[]> usingSingle(Integer lineId); | ||
| 244 | - | ||
| 245 | - /** | ||
| 246 | - * @Description : TODO(根据站点路由Id查询详情) | ||
| 247 | - * | ||
| 248 | - * @param id:站点路由ID | ||
| 249 | - * | ||
| 250 | - * @return List<Object[]> | ||
| 251 | - */ | ||
| 252 | - @Query(value = "SELECT a.stationRouteLine," + | ||
| 253 | - " a.stationRouteStation," + | ||
| 254 | - " a.stationRouteCode," + | ||
| 255 | - " a.stationRouteLIneCode," + | ||
| 256 | - " a.stationRouteStationMark," + | ||
| 257 | - " a.stationOutStationNmber," + | ||
| 258 | - " a.stationRoutedirections," + | ||
| 259 | - " a.stationRouteDistances," + | ||
| 260 | - " a.stationRouteToTime," + | ||
| 261 | - " a.staitonRouteFirstTime," + | ||
| 262 | - " a.stationRouteEndTime," + | ||
| 263 | - " a.stationRouteDescriptions," + | ||
| 264 | - " a.stationRouteDestroy," + | ||
| 265 | - " a.stationRouteVersions," + | ||
| 266 | - " a.stationRouteCreateBy," + | ||
| 267 | - " a.stationRouteCreateDate," + | ||
| 268 | - " a.stationRouteUpdateBy," + | ||
| 269 | - " a.stationRouteUpdateDate," + | ||
| 270 | - " b.id AS stationId," + | ||
| 271 | - " b.station_cod AS stationCode," + | ||
| 272 | - " a.stationRouteName," + | ||
| 273 | - " b.road_coding AS stationRoadCoding," + | ||
| 274 | - " b.db_type AS stationDbType," + | ||
| 275 | - " b.b_jwpoints AS stationJwpoints," + | ||
| 276 | - " b.g_lonx AS stationGlonx," + | ||
| 277 | - " b.g_laty AS stationGlaty," + | ||
| 278 | - " b.x AS stationX," + | ||
| 279 | - " b.y AS stationY," + | ||
| 280 | - " ST_AsText(b.b_polygon_grid) as stationBPolyonGrid," + | ||
| 281 | - " ST_AsText(b.g_polygon_grid) AS stationGPloyonGrid, " + | ||
| 282 | - " b.destroy AS stationDestroy," + | ||
| 283 | - " b.radius AS stationRadius," + | ||
| 284 | - " b.shapes_type AS stationShapesType," + | ||
| 285 | - " b.versions AS stationVersions," + | ||
| 286 | - " b.descriptions AS sttationDescriptions," + | ||
| 287 | - " b.create_by AS stationCreateBy," + | ||
| 288 | - " b.create_date AS stationCreateDate," + | ||
| 289 | - " b.update_by AS stationUpdateBy," + | ||
| 290 | - " b.update_date AS stationUpdateDate," + | ||
| 291 | - " a.stationRouteId,b.station_name as zdmc, " + | ||
| 292 | - " a.industryCode "+ | ||
| 293 | - " FROM " + | ||
| 294 | - "( SELECT s.id AS stationRouteId," + | ||
| 295 | - " s.line AS stationRouteLine," + | ||
| 296 | - " s.station as stationRouteStation," + | ||
| 297 | - " s.station_name AS stationRouteName," + | ||
| 298 | - " s.station_route_code as stationRouteCode," + | ||
| 299 | - " s.industry_code as industryCode," + | ||
| 300 | - " s.line_code AS stationRouteLIneCode," + | ||
| 301 | - " s.station_mark AS stationRouteStationMark," + | ||
| 302 | - " s.out_station_nmber AS stationOutStationNmber," + | ||
| 303 | - " s.directions AS stationRoutedirections," + | ||
| 304 | - " s.distances AS stationRouteDistances," + | ||
| 305 | - " s.to_time AS stationRouteToTime," + | ||
| 306 | - " s.first_time AS staitonRouteFirstTime," + | ||
| 307 | - " s.end_time AS stationRouteEndTime," + | ||
| 308 | - " s.descriptions AS stationRouteDescriptions," + | ||
| 309 | - " s.destroy AS stationRouteDestroy," + | ||
| 310 | - " s.versions AS stationRouteVersions," + | ||
| 311 | - " s.create_by AS stationRouteCreateBy," + | ||
| 312 | - " s.create_date AS stationRouteCreateDate," + | ||
| 313 | - " s.update_by AS stationRouteUpdateBy," + | ||
| 314 | - " s.update_date AS stationRouteUpdateDate FROM bsth_c_stationroute s WHERE s.id = ?1 ) a " + | ||
| 315 | - " LEFT JOIN bsth_c_station b ON a.stationRouteStation = b.id", nativeQuery=true) | ||
| 316 | - List<Object[]> findStationRouteInfo(Integer id); | ||
| 317 | - | ||
| 318 | - /** | ||
| 319 | - * @Description : TODO(根据站点路由Id查询详情) | ||
| 320 | - * | ||
| 321 | - * @param id:站点路由ID | ||
| 322 | - * | ||
| 323 | - * @return List<Object[]> | ||
| 324 | - */ | ||
| 325 | - @Query(value = "SELECT a.stationRouteLine," + | ||
| 326 | - " a.stationRouteStation," + | ||
| 327 | - " a.stationRouteCode," + | ||
| 328 | - " a.stationRouteLIneCode," + | ||
| 329 | - " a.stationRouteStationMark," + | ||
| 330 | - " a.stationOutStationNmber," + | ||
| 331 | - " a.stationRoutedirections," + | ||
| 332 | - " a.stationRouteDistances," + | ||
| 333 | - " a.stationRouteToTime," + | ||
| 334 | - " a.staitonRouteFirstTime," + | ||
| 335 | - " a.stationRouteEndTime," + | ||
| 336 | - " a.stationRouteDescriptions," + | ||
| 337 | - " a.stationRouteDestroy," + | ||
| 338 | - " a.stationRouteVersions," + | ||
| 339 | - " a.stationRouteCreateBy," + | ||
| 340 | - " a.stationRouteCreateDate," + | ||
| 341 | - " a.stationRouteUpdateBy," + | ||
| 342 | - " a.stationRouteUpdateDate," + | ||
| 343 | - " b.id AS stationId," + | ||
| 344 | - " b.station_cod AS stationCode," + | ||
| 345 | - " a.stationRouteName," + | ||
| 346 | - " b.road_coding AS stationRoadCoding," + | ||
| 347 | - " b.db_type AS stationDbType," + | ||
| 348 | - " b.b_jwpoints AS stationJwpoints," + | ||
| 349 | - " b.g_lonx AS stationGlonx," + | ||
| 350 | - " b.g_laty AS stationGlaty," + | ||
| 351 | - " b.x AS stationX," + | ||
| 352 | - " b.y AS stationY," + | ||
| 353 | - " ST_AsText(b.b_polygon_grid) as stationBPolyonGrid," + | ||
| 354 | - " ST_AsText(b.g_polygon_grid) AS stationGPloyonGrid, " + | ||
| 355 | - " b.destroy AS stationDestroy," + | ||
| 356 | - " b.radius AS stationRadius," + | ||
| 357 | - " b.shapes_type AS stationShapesType," + | ||
| 358 | - " b.versions AS stationVersions," + | ||
| 359 | - " b.descriptions AS sttationDescriptions," + | ||
| 360 | - " b.create_by AS stationCreateBy," + | ||
| 361 | - " b.create_date AS stationCreateDate," + | ||
| 362 | - " b.update_by AS stationUpdateBy," + | ||
| 363 | - " b.update_date AS stationUpdateDate," + | ||
| 364 | - " a.stationRouteId," + | ||
| 365 | - "b.station_name as zdmc, "+ | ||
| 366 | - "a.industryCode "+ | ||
| 367 | - " FROM ( SELECT s.id AS stationRouteId," + | ||
| 368 | - " s.line AS stationRouteLine," + | ||
| 369 | - " s.station as stationRouteStation," + | ||
| 370 | - " s.station_name AS stationRouteName," + | ||
| 371 | - " s.station_route_code as stationRouteCode," + | ||
| 372 | - " s.industry_code as industryCode," + | ||
| 373 | - " s.line_code AS stationRouteLIneCode," + | ||
| 374 | - " s.station_mark AS stationRouteStationMark," + | ||
| 375 | - " s.out_station_nmber AS stationOutStationNmber," + | ||
| 376 | - " s.directions AS stationRoutedirections," + | ||
| 377 | - " s.distances AS stationRouteDistances," + | ||
| 378 | - " s.to_time AS stationRouteToTime," + | ||
| 379 | - " s.first_time AS staitonRouteFirstTime," + | ||
| 380 | - " s.end_time AS stationRouteEndTime," + | ||
| 381 | - " s.descriptions AS stationRouteDescriptions," + | ||
| 382 | - " s.destroy AS stationRouteDestroy," + | ||
| 383 | - " s.versions AS stationRouteVersions," + | ||
| 384 | - " s.create_by AS stationRouteCreateBy," + | ||
| 385 | - " s.create_date AS stationRouteCreateDate," + | ||
| 386 | - " s.update_by AS stationRouteUpdateBy," + | ||
| 387 | - " s.update_date AS stationRouteUpdateDate FROM bsth_c_stationroute s WHERE s.line = ?1 and s.directions = ?2 and s.destroy = 0) a " + | ||
| 388 | - " LEFT JOIN bsth_c_station b ON a.stationRouteStation = b.id order by a.stationRouteCode", nativeQuery=true) | ||
| 389 | - List<Object[]> getStationRouteList(Integer lineId, Integer dir); | ||
| 390 | - | ||
| 391 | - List<StationRoute> findByLine(Line line); | ||
| 392 | - | ||
| 393 | - @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH) | ||
| 394 | - @Query("select s from StationRoute s where s.destroy=0") | ||
| 395 | - List<StationRoute> findAllEffective(); | ||
| 396 | - | ||
| 397 | - @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH) | ||
| 398 | - @Override | ||
| 399 | - Page<StationRoute> findAll(Specification<StationRoute> spec, Pageable pageable); | ||
| 400 | - | ||
| 401 | - @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH) | ||
| 402 | - @Override | ||
| 403 | - List<StationRoute> findAll(Specification<StationRoute> spec); | ||
| 404 | - | ||
| 405 | - @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH) | ||
| 406 | - @Override | ||
| 407 | - List<StationRoute> findAll(Specification<StationRoute> spec, Sort sort); | ||
| 408 | - | ||
| 409 | - @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH) | ||
| 410 | - @Override | ||
| 411 | - @Query(value = "select r from StationRoute r where r.destroy=0") | ||
| 412 | - List<StationRoute> findAll(); | ||
| 413 | - | ||
| 414 | - @Query("select new map(sr.station.id as stationid, sr.stationName as stationname) from StationRoute sr where sr.line.id=?1 and sr.directions=?2") | ||
| 415 | - List<Map<String, Object>> findStations(Integer xlid, Integer xldir); | ||
| 416 | - | ||
| 417 | - @Query("select r from StationRoute r where r.lineCode=?1 and r.directions=?2 and r.destroy=0 order by r.stationRouteCode") | ||
| 418 | - List<StationRoute> findByLine(String lineCode, int updown); | ||
| 419 | - | ||
| 420 | - @Query("select r from StationRoute r where r.line.id=?1 and r.directions=?2 and r.destroy=0 order by r.stationRouteCode") | ||
| 421 | - List<StationRoute> findByLine(Integer lineId, Integer dir); | ||
| 422 | - | ||
| 423 | - @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH) | ||
| 424 | - @Query("select s from StationRoute s where s.destroy=0 and s.lineCode=?1") | ||
| 425 | - List<StationRoute> findByLineCode(String lineCode); | ||
| 426 | - | ||
| 427 | - @Query("SELECT new map(" + | ||
| 428 | - "lineCode as lineCode,directions as directions,stationName as stationName,stationCode as stationCode," + | ||
| 429 | - "line.linePlayType as linePlayType,s.stationMark as stationMark) " + | ||
| 430 | - "FROM " + | ||
| 431 | - "StationRoute s " + | ||
| 432 | - "WHERE " + | ||
| 433 | - "s.destroy = 0 " + | ||
| 434 | - "and s.lineCode in(select lineCode from Line where inUse = 1) " + | ||
| 435 | - "ORDER BY " + | ||
| 436 | - "lineCode,directions,stationRouteCode") | ||
| 437 | - List<Map<String, String>> findLineWithYgcAndInuse(); | ||
| 438 | - | ||
| 439 | - @Query("SELECT new map(" + | ||
| 440 | - "lineCode as lineCode,directions as directions,stationName as stationName,stationCode as stationCode," + | ||
| 441 | - "line.linePlayType as linePlayType,s.stationMark as stationMark) " + | ||
| 442 | - "FROM " + | ||
| 443 | - "StationRoute s " + | ||
| 444 | - "WHERE " + | ||
| 445 | - "s.destroy = 0 " + | ||
| 446 | - "ORDER BY " + | ||
| 447 | - "lineCode,directions,stationRouteCode") | ||
| 448 | - List<Map<String, String>> findAllLineWithYgc(); | ||
| 449 | - | ||
| 450 | - @Query("SELECT new map(" + | ||
| 451 | - "lineCode as lineCode,directions as directions,stationName as stationName,stationCode as stationCode," + | ||
| 452 | - "line.linePlayType as linePlayType,s.stationMark as stationMark) " + | ||
| 453 | - "FROM " + | ||
| 454 | - "StationRoute s " + | ||
| 455 | - "WHERE " + | ||
| 456 | - "s.destroy = 0 and s.lineCode = ?1 " + | ||
| 457 | - "ORDER BY " + | ||
| 458 | - "lineCode,directions,stationRouteCode") | ||
| 459 | - List<Map<String, String>> findLineWithYgcByLine(String lineCode); | ||
| 460 | - | ||
| 461 | - @Modifying | ||
| 462 | - @Query(value="update bsth_c_stationroute set directions = case directions when 1 then 0 when 0 then 1 end where line = ?1 ", nativeQuery=true) | ||
| 463 | - void stationRouteDir(Integer line); | ||
| 464 | - | ||
| 465 | - @Modifying | ||
| 466 | - @Query(value="update bsth_c_stationroute set distances =?2 where id = ?1 ", nativeQuery=true) | ||
| 467 | - void upddis(Integer id,Double dis); | ||
| 468 | - | ||
| 469 | - @Modifying | ||
| 470 | - @Query(value="UPDATE bsth_c_stationroute set station_route_code = (station_route_code+10) where line = ?1 and directions = ?2 and station_route_code >=?3 and destroy = 0", nativeQuery=true) | ||
| 471 | - void stationUpdStationRouteCode(Integer line,Integer dir,Integer routeCod); | ||
| 472 | - | ||
| 473 | - /** | ||
| 474 | - * 更新路线前撤销线路原有站点 | ||
| 475 | - * | ||
| 476 | - * @param line | ||
| 477 | - * @param dir | ||
| 478 | - */ | ||
| 479 | - @Modifying | ||
| 480 | - @Query(value="UPDATE bsth_c_stationroute set destroy = 1 where line = ?1 and directions = ?2", nativeQuery=true) | ||
| 481 | - void stationRouteUpdDestroy(Integer line,Integer dir); | ||
| 482 | - | ||
| 483 | - @Modifying | ||
| 484 | - @Query(value="UPDATE bsth_c_stationroute set destroy = 1 where id = ?1", nativeQuery=true) | ||
| 485 | - void stationRouteIsDestroyUpdBatch(Integer ids); | ||
| 486 | - | ||
| 487 | - /** | ||
| 488 | - * | ||
| 489 | - * | ||
| 490 | - * @param line | ||
| 491 | - * @param dir | ||
| 492 | - */ | ||
| 493 | - @Modifying | ||
| 494 | - @Query(value="insert into (select * from bsth_c_stationroute_cache where line = ?1 and directions = ?2) bsth_c_stationroute", nativeQuery=true) | ||
| 495 | - void stationRouteUpdate(Integer line,Integer dir); | ||
| 496 | - | ||
| 497 | - // 更具线路批量撤销 | ||
| 498 | - @Modifying | ||
| 499 | - @Query(value="UPDATE StationRoute sr set sr.destroy = 1 where sr.line.id = ?1 and sr.lineCode = ?2") | ||
| 500 | - void batchUpdate(Integer lineId, String lineCode); | ||
| 501 | - | ||
| 502 | - // 批量删除 | ||
| 503 | - @Modifying | ||
| 504 | - @Query(value="delete from StationRoute sr where sr.line.id = ?1 and sr.lineCode = ?2") | ||
| 505 | - void batchDelete(Integer lineId, String lineCode); | ||
| 506 | - | ||
| 507 | - | ||
| 508 | - // 批量修改站点行业编码 | ||
| 509 | - @Modifying | ||
| 510 | - @Query(value="update bsth_c_stationroute set industry_code =?2 where id = ?1 ", nativeQuery=true) | ||
| 511 | - void updIndustryCode(Integer id,String IndustryCode); | ||
| 512 | -} | 1 | +package com.bsth.repository; |
| 2 | + | ||
| 3 | +import java.util.List; | ||
| 4 | +import java.util.Map; | ||
| 5 | + | ||
| 6 | +import org.springframework.data.domain.Page; | ||
| 7 | +import org.springframework.data.domain.Pageable; | ||
| 8 | +import org.springframework.data.domain.Sort; | ||
| 9 | +import org.springframework.data.jpa.domain.Specification; | ||
| 10 | +import org.springframework.data.jpa.repository.EntityGraph; | ||
| 11 | +import org.springframework.data.jpa.repository.Modifying; | ||
| 12 | +import org.springframework.data.jpa.repository.Query; | ||
| 13 | +import org.springframework.stereotype.Repository; | ||
| 14 | +import org.springframework.transaction.annotation.Transactional; | ||
| 15 | + | ||
| 16 | +import com.bsth.entity.Line; | ||
| 17 | +import com.bsth.entity.StationRoute; | ||
| 18 | + | ||
| 19 | +/** | ||
| 20 | + * | ||
| 21 | + * @Interface: StationRouteRepository(站点路由Repository数据持久层接口) | ||
| 22 | + * | ||
| 23 | + * @Extends : BaseRepository | ||
| 24 | + * | ||
| 25 | + * @Description: TODO(站点路由Repository数据持久层接口) | ||
| 26 | + * | ||
| 27 | + * @Author bsth@lq | ||
| 28 | + * | ||
| 29 | + * @Date 2016年5月03日 上午9:21:17 | ||
| 30 | + * | ||
| 31 | + * @Version 公交调度系统BS版 0.1 | ||
| 32 | + * | ||
| 33 | + */ | ||
| 34 | + | ||
| 35 | +@Repository | ||
| 36 | +public interface StationRouteRepository extends BaseRepository<StationRoute, Integer> { | ||
| 37 | + | ||
| 38 | + @Query(value = "SELECT a.`stationRoute.id`," + | ||
| 39 | + "a.`stationRoute.line`," + | ||
| 40 | + "a.`stationRoute.station`," + | ||
| 41 | + "a.`stationRoute.stationName`," + | ||
| 42 | + "a.`stationRoute.stationRouteCode`," + | ||
| 43 | + "a.`stationRoute.lineCode`," + | ||
| 44 | + "a.`stationRoute.stationMark`," + | ||
| 45 | + "a.`stationRoute.outStationNmber`," + | ||
| 46 | + "a.`stationRoute.directions`," + | ||
| 47 | + "a.`stationRoute.distances`," + | ||
| 48 | + "a.`stationRoute.toTime`," + | ||
| 49 | + "a.`stationRoute.firstTime`," + | ||
| 50 | + "a.`stationRoute.endTime`," + | ||
| 51 | + "a.`stationRoute.descriptions`," + | ||
| 52 | + "a.`stationRoute.versions`," + | ||
| 53 | + "b.id AS 'station.id'," + | ||
| 54 | + "b.station_cod AS 'station.stationCod'," + | ||
| 55 | + "b.station_name AS 'station.stationName'," + | ||
| 56 | + "b.road_coding AS 'station.roadCoding'," + | ||
| 57 | + "b.db_type AS 'station.dbType'," + | ||
| 58 | + "b.b_jwpoints AS 'station.bJwpoints'," + | ||
| 59 | + "b.g_lonx AS 'station.gLonx'," + | ||
| 60 | + "b.g_lonx AS 'station.gLaty'," + | ||
| 61 | + "b.x AS 'station.x'," + | ||
| 62 | + "b.y AS 'station.y'," + | ||
| 63 | + "b.shapes_type AS 'station.shapesType'," + | ||
| 64 | + "b.radius AS 'station.radius'," + | ||
| 65 | + "ST_AsText(b.g_polygon_grid) AS 'station.gPolygonGrid'," + | ||
| 66 | + "ST_AsText(b.b_polygon_grid) AS 'station.bPolygonGrid'," + | ||
| 67 | + "b.destroy AS 'station.destroy'," + | ||
| 68 | + "b.versions AS 'station.versions'," + | ||
| 69 | + "b.descriptions AS 'station.descriptions', " + | ||
| 70 | + "a.`stationRoute.industryCode` " + | ||
| 71 | + " FROM (" + | ||
| 72 | + "SELECT r.id AS 'stationRoute.id'," + | ||
| 73 | + " r.line AS 'stationRoute.line'," + | ||
| 74 | + "r.station AS 'stationRoute.station'," + | ||
| 75 | + "r.station_name AS 'stationRoute.stationName'," + | ||
| 76 | + "r.station_route_code as 'stationRoute.stationRouteCode'," + | ||
| 77 | + "r.line_code AS 'stationRoute.lineCode'," + | ||
| 78 | + "r.station_mark AS 'stationRoute.stationMark'," + | ||
| 79 | + "r.out_station_nmber AS 'stationRoute.outStationNmber'," + | ||
| 80 | + "r.directions AS 'stationRoute.directions'," + | ||
| 81 | + "r.distances AS 'stationRoute.distances'," + | ||
| 82 | + "r.to_time AS 'stationRoute.toTime'," + | ||
| 83 | + "r.first_time AS 'stationRoute.firstTime'," + | ||
| 84 | + "r.end_time AS 'stationRoute.endTime'," + | ||
| 85 | + "r.descriptions AS 'stationRoute.descriptions'," + | ||
| 86 | + "r.versions AS 'stationRoute.versions', " + | ||
| 87 | + "r.industry_code AS 'stationRoute.industryCode' " + | ||
| 88 | + " FROM bsth_c_stationroute r WHERE r.line = ?1 and r.directions = ?2 and r.destroy=0) a " + | ||
| 89 | + "LEFT JOIN bsth_c_station b " + | ||
| 90 | + "ON a.`stationRoute.station` = b.id ORDER BY a.`stationRoute.stationRouteCode` ASC", nativeQuery=true) | ||
| 91 | + List<Object[]> findPoints(int line,int directions); | ||
| 92 | + | ||
| 93 | + @Query("select r from StationRoute r where r.line.id=?1 and r.destroy=0 order by r.directions ASC ,r.stationRouteCode ASC") | ||
| 94 | + // @Query(value = "SELECT * from bsth_c_stationroute line = ?1 and destroy=0 bsth_c_station ORDER BY directions ASC, stationRouteCode ASC", nativeQuery=true) | ||
| 95 | + List<StationRoute> findStationExport(int line); | ||
| 96 | + | ||
| 97 | + /** | ||
| 98 | + * @Description :TODO(查询线路某方向下的站点序号与类型) | ||
| 99 | + * | ||
| 100 | + * @param map <lineId:线路ID; direction:方向;stationRouteCode:站点编码> | ||
| 101 | + * | ||
| 102 | + * @return List<Map<String, Object>> | ||
| 103 | + */ | ||
| 104 | + @Query(value = "select t.station_route_code,t.station_mark from bsth_c_stationroute t where " + | ||
| 105 | + " t.station_route_code =(" + | ||
| 106 | + "select MAX(station_route_code) as stationRouteCode from bsth_c_stationroute r WHERE " + | ||
| 107 | + "r.line=?1 and r.directions =?2 and station_route_code< ?3 and r.destroy = 0 ) and t.line=?1 and t.directions = ?2 AND t.destroy = 0", nativeQuery=true) | ||
| 108 | + List<Object[]> findUpStationRouteCode(Integer lineId,Integer direction,Integer stationRouteCode); | ||
| 109 | + | ||
| 110 | + /** | ||
| 111 | + * @param version | ||
| 112 | + * @Description :TODO(查询下个站点) | ||
| 113 | + * | ||
| 114 | + * @param map <lineId:线路ID; direction:方向;stationRouteCode:站点编码> | ||
| 115 | + * | ||
| 116 | + * @return List<Map<String, Object>> | ||
| 117 | + */ | ||
| 118 | + @Query(value = "SELECT a.stationRouteLine," + | ||
| 119 | + " a.stationRouteStation," + | ||
| 120 | + " a.stationRouteCode," + | ||
| 121 | + " a.stationRouteLIneCode," + | ||
| 122 | + " a.stationRouteStationMark," + | ||
| 123 | + " a.stationOutStationNmber," + | ||
| 124 | + " a.stationRoutedirections," + | ||
| 125 | + " a.stationRouteDistances," + | ||
| 126 | + " a.stationRouteToTime," + | ||
| 127 | + " a.staitonRouteFirstTime," + | ||
| 128 | + " a.stationRouteEndTime," + | ||
| 129 | + " a.stationRouteDescriptions," + | ||
| 130 | + " a.stationRouteDestroy," + | ||
| 131 | + " a.stationRouteVersions," + | ||
| 132 | + " a.stationRouteCreateBy," + | ||
| 133 | + " a.stationRouteCreateDate," + | ||
| 134 | + " a.stationRouteUpdateBy," + | ||
| 135 | + " a.stationRouteUpdateDate," + | ||
| 136 | + " b.id AS stationId," + | ||
| 137 | + " b.station_cod AS stationCode," + | ||
| 138 | + " a.stationRouteName," + | ||
| 139 | + " b.road_coding AS stationRoadCoding," + | ||
| 140 | + " b.db_type AS stationDbType," + | ||
| 141 | + " b.b_jwpoints AS stationJwpoints," + | ||
| 142 | + " b.g_lonx AS stationGlonx," + | ||
| 143 | + " b.g_laty AS stationGlaty," + | ||
| 144 | + " b.x AS stationX," + | ||
| 145 | + " b.y AS stationY," + | ||
| 146 | + " ST_AsText(b.b_polygon_grid) as stationBPolyonGrid," + | ||
| 147 | + " ST_AsText(b.g_polygon_grid) AS stationGPloyonGrid, " + | ||
| 148 | + " b.destroy AS stationDestroy," + | ||
| 149 | + " b.radius AS stationRadius," + | ||
| 150 | + " b.shapes_type AS stationShapesType," + | ||
| 151 | + " b.versions AS stationVersions," + | ||
| 152 | + " b.descriptions AS sttationDescriptions," + | ||
| 153 | + " b.create_by AS stationCreateBy," + | ||
| 154 | + " b.create_date AS stationCreateDate," + | ||
| 155 | + " b.update_by AS stationUpdateBy," + | ||
| 156 | + " b.update_date AS stationUpdateDate," + | ||
| 157 | + " a.stationRouteId, " + | ||
| 158 | + " b.station_name as zdmc, " + | ||
| 159 | + " a.industryCode"+ | ||
| 160 | + " FROM " + | ||
| 161 | + "( SELECT s.id AS stationRouteId," + | ||
| 162 | + " s.line AS stationRouteLine," + | ||
| 163 | + " s.station as stationRouteStation," + | ||
| 164 | + " s.station_name AS stationRouteName," + | ||
| 165 | + " s.station_route_code as stationRouteCode," + | ||
| 166 | + " s.industry_code as industryCode," + | ||
| 167 | + " s.line_code AS stationRouteLIneCode," + | ||
| 168 | + " s.station_mark AS stationRouteStationMark," + | ||
| 169 | + " s.out_station_nmber AS stationOutStationNmber," + | ||
| 170 | + " s.directions AS stationRoutedirections," + | ||
| 171 | + " s.distances AS stationRouteDistances," + | ||
| 172 | + " s.to_time AS stationRouteToTime," + | ||
| 173 | + " s.first_time AS staitonRouteFirstTime," + | ||
| 174 | + " s.end_time AS stationRouteEndTime," + | ||
| 175 | + " s.descriptions AS stationRouteDescriptions," + | ||
| 176 | + " s.destroy AS stationRouteDestroy," + | ||
| 177 | + " s.versions AS stationRouteVersions," + | ||
| 178 | + " s.create_by AS stationRouteCreateBy," + | ||
| 179 | + " s.create_date AS stationRouteCreateDate," + | ||
| 180 | + " s.update_by AS stationRouteUpdateBy," + | ||
| 181 | + " s.update_date AS stationRouteUpdateDate FROM bsth_c_ls_stationroute s WHERE s.versions = ?4 and s.station_route_code =(" + | ||
| 182 | + "select MIN(station_route_code) as stationRouteCode from bsth_c_ls_stationroute r WHERE " + | ||
| 183 | + "r.line=?1 and r.directions =?2 and station_route_code > ?3 and r.destroy = 0 and versions = ?4 ) and s.line=?1 and s.directions = ?2 AND s.destroy = 0) a " + | ||
| 184 | + " LEFT JOIN bsth_c_station b ON a.stationRouteStation = b.id", nativeQuery=true) | ||
| 185 | + List<Object[]> findDownStationRoute(Integer id,Integer direction,Integer stationRouteCode, Integer version); | ||
| 186 | + | ||
| 187 | + /** | ||
| 188 | + * @Description :TODO(站点中心点坐标查询) | ||
| 189 | + * | ||
| 190 | + * @param map <lineId:线路ID; direction:方向> | ||
| 191 | + * | ||
| 192 | + * @return List<Object[]> | ||
| 193 | + */ | ||
| 194 | + /*@Query(value = "SELECT s.b_jwpoints,s.station_name FROM (" + | ||
| 195 | + "SELECT b.station FROM bsth_c_stationroute b where b.line =?1 and b.directions = ?2 and b.destroy=0) r " + | ||
| 196 | + "LEFT JOIN bsth_c_station s on r.station = s.id", nativeQuery=true)*/ | ||
| 197 | + @Query(value = "SELECT s.b_jwpoints,r.station_name,r.station_route_code FROM (" + | ||
| 198 | + "SELECT b.station,b.station_route_code,b.station_name FROM bsth_c_stationroute b where b.line =?1 and b.directions = ?2 and b.destroy=0) r " + | ||
| 199 | + "LEFT JOIN bsth_c_station s on r.station = s.id order by r.station_route_code asc", nativeQuery=true) | ||
| 200 | + List<Object[]> getSelectStationRouteCenterPoints(Integer lineId,Integer direction); | ||
| 201 | + | ||
| 202 | + /** | ||
| 203 | + * @Description :TODO(撤销站点) | ||
| 204 | + * | ||
| 205 | + * @param map <lineId:线路ID; destroy:是否撤销(0:否;1:是)> | ||
| 206 | + * | ||
| 207 | + */ | ||
| 208 | + @Transactional | ||
| 209 | + @Modifying | ||
| 210 | + @Query(value="UPDATE bsth_c_stationroute SET " + | ||
| 211 | + "destroy = ?2 WHERE id = ?1", nativeQuery=true) | ||
| 212 | + void stationRouteIsDestroyUpd(Integer stationRouteId, Integer destroy); | ||
| 213 | + | ||
| 214 | + | ||
| 215 | + /** | ||
| 216 | + * @Description : TODO(根据线路ID生成行单) | ||
| 217 | + * | ||
| 218 | + * @param lineId:线路ID | ||
| 219 | + * | ||
| 220 | + * @return List<Object[]>:{[0]:g_lonx(GPS经度);[1]:g_laty(GPS纬度);[2]:b_jwpoints(百度经纬度坐标) | ||
| 221 | + * | ||
| 222 | + * [3]:station_mark(站点类型);[4]:station_route_code(站点序号);[5]:station_cod(站点编码); | ||
| 223 | + * | ||
| 224 | + * [6]:distances(站点距离);[7]:station_name(站点名称);[8]:directions(方向)} | ||
| 225 | + */ | ||
| 226 | + @Query(value = "SELECT * FROM ("+ | ||
| 227 | + "SELECT b.g_lonx," + | ||
| 228 | + "b.g_laty,b.b_jwpoints," + | ||
| 229 | + "a.station_mark," + | ||
| 230 | + "a.station_route_code," + | ||
| 231 | + "b.station_cod," + | ||
| 232 | + "a.distances,"+ | ||
| 233 | + "a.station_name," + | ||
| 234 | + "a.directions FROM (SELECT " + | ||
| 235 | + "s.station_mark," + | ||
| 236 | + "s.station_route_code," + | ||
| 237 | + "s.directions," + | ||
| 238 | + "s.distances,"+ | ||
| 239 | + "s.station_name,"+ | ||
| 240 | + "s.station FROM bsth_c_stationroute s where s.line = ?1 and s.destroy=0) a " + | ||
| 241 | + "LEFT JOIN bsth_c_station b " + | ||
| 242 | + " on a.station = b.id ORDER BY a.directions ASC ) k ORDER BY k.directions,k.station_route_code ASC", nativeQuery=true) | ||
| 243 | + List<Object[]> usingSingle(Integer lineId); | ||
| 244 | + | ||
| 245 | + /** | ||
| 246 | + * @Description : TODO(根据站点路由Id查询详情) | ||
| 247 | + * | ||
| 248 | + * @param id:站点路由ID | ||
| 249 | + * | ||
| 250 | + * @return List<Object[]> | ||
| 251 | + */ | ||
| 252 | + @Query(value = "SELECT a.stationRouteLine," + | ||
| 253 | + " a.stationRouteStation," + | ||
| 254 | + " a.stationRouteCode," + | ||
| 255 | + " a.stationRouteLIneCode," + | ||
| 256 | + " a.stationRouteStationMark," + | ||
| 257 | + " a.stationOutStationNmber," + | ||
| 258 | + " a.stationRoutedirections," + | ||
| 259 | + " a.stationRouteDistances," + | ||
| 260 | + " a.stationRouteToTime," + | ||
| 261 | + " a.staitonRouteFirstTime," + | ||
| 262 | + " a.stationRouteEndTime," + | ||
| 263 | + " a.stationRouteDescriptions," + | ||
| 264 | + " a.stationRouteDestroy," + | ||
| 265 | + " a.stationRouteVersions," + | ||
| 266 | + " a.stationRouteCreateBy," + | ||
| 267 | + " a.stationRouteCreateDate," + | ||
| 268 | + " a.stationRouteUpdateBy," + | ||
| 269 | + " a.stationRouteUpdateDate," + | ||
| 270 | + " b.id AS stationId," + | ||
| 271 | + " b.station_cod AS stationCode," + | ||
| 272 | + " a.stationRouteName," + | ||
| 273 | + " b.road_coding AS stationRoadCoding," + | ||
| 274 | + " b.db_type AS stationDbType," + | ||
| 275 | + " b.b_jwpoints AS stationJwpoints," + | ||
| 276 | + " b.g_lonx AS stationGlonx," + | ||
| 277 | + " b.g_laty AS stationGlaty," + | ||
| 278 | + " b.x AS stationX," + | ||
| 279 | + " b.y AS stationY," + | ||
| 280 | + " ST_AsText(b.b_polygon_grid) as stationBPolyonGrid," + | ||
| 281 | + " ST_AsText(b.g_polygon_grid) AS stationGPloyonGrid, " + | ||
| 282 | + " b.destroy AS stationDestroy," + | ||
| 283 | + " b.radius AS stationRadius," + | ||
| 284 | + " b.shapes_type AS stationShapesType," + | ||
| 285 | + " b.versions AS stationVersions," + | ||
| 286 | + " b.descriptions AS sttationDescriptions," + | ||
| 287 | + " b.create_by AS stationCreateBy," + | ||
| 288 | + " b.create_date AS stationCreateDate," + | ||
| 289 | + " b.update_by AS stationUpdateBy," + | ||
| 290 | + " b.update_date AS stationUpdateDate," + | ||
| 291 | + " a.stationRouteId,b.station_name as zdmc, " + | ||
| 292 | + " a.industryCode "+ | ||
| 293 | + " FROM " + | ||
| 294 | + "( SELECT s.id AS stationRouteId," + | ||
| 295 | + " s.line AS stationRouteLine," + | ||
| 296 | + " s.station as stationRouteStation," + | ||
| 297 | + " s.station_name AS stationRouteName," + | ||
| 298 | + " s.station_route_code as stationRouteCode," + | ||
| 299 | + " s.industry_code as industryCode," + | ||
| 300 | + " s.line_code AS stationRouteLIneCode," + | ||
| 301 | + " s.station_mark AS stationRouteStationMark," + | ||
| 302 | + " s.out_station_nmber AS stationOutStationNmber," + | ||
| 303 | + " s.directions AS stationRoutedirections," + | ||
| 304 | + " s.distances AS stationRouteDistances," + | ||
| 305 | + " s.to_time AS stationRouteToTime," + | ||
| 306 | + " s.first_time AS staitonRouteFirstTime," + | ||
| 307 | + " s.end_time AS stationRouteEndTime," + | ||
| 308 | + " s.descriptions AS stationRouteDescriptions," + | ||
| 309 | + " s.destroy AS stationRouteDestroy," + | ||
| 310 | + " s.versions AS stationRouteVersions," + | ||
| 311 | + " s.create_by AS stationRouteCreateBy," + | ||
| 312 | + " s.create_date AS stationRouteCreateDate," + | ||
| 313 | + " s.update_by AS stationRouteUpdateBy," + | ||
| 314 | + " s.update_date AS stationRouteUpdateDate FROM bsth_c_stationroute s WHERE s.id = ?1 ) a " + | ||
| 315 | + " LEFT JOIN bsth_c_station b ON a.stationRouteStation = b.id", nativeQuery=true) | ||
| 316 | + List<Object[]> findStationRouteInfo(Integer id); | ||
| 317 | + | ||
| 318 | + /** | ||
| 319 | + * @Description : TODO(根据站点路由Id查询详情) | ||
| 320 | + * | ||
| 321 | + * @param id:站点路由ID | ||
| 322 | + * | ||
| 323 | + * @return List<Object[]> | ||
| 324 | + */ | ||
| 325 | + @Query(value = "SELECT a.stationRouteLine," + | ||
| 326 | + " a.stationRouteStation," + | ||
| 327 | + " a.stationRouteCode," + | ||
| 328 | + " a.stationRouteLIneCode," + | ||
| 329 | + " a.stationRouteStationMark," + | ||
| 330 | + " a.stationOutStationNmber," + | ||
| 331 | + " a.stationRoutedirections," + | ||
| 332 | + " a.stationRouteDistances," + | ||
| 333 | + " a.stationRouteToTime," + | ||
| 334 | + " a.staitonRouteFirstTime," + | ||
| 335 | + " a.stationRouteEndTime," + | ||
| 336 | + " a.stationRouteDescriptions," + | ||
| 337 | + " a.stationRouteDestroy," + | ||
| 338 | + " a.stationRouteVersions," + | ||
| 339 | + " a.stationRouteCreateBy," + | ||
| 340 | + " a.stationRouteCreateDate," + | ||
| 341 | + " a.stationRouteUpdateBy," + | ||
| 342 | + " a.stationRouteUpdateDate," + | ||
| 343 | + " b.id AS stationId," + | ||
| 344 | + " b.station_cod AS stationCode," + | ||
| 345 | + " a.stationRouteName," + | ||
| 346 | + " b.road_coding AS stationRoadCoding," + | ||
| 347 | + " b.db_type AS stationDbType," + | ||
| 348 | + " b.b_jwpoints AS stationJwpoints," + | ||
| 349 | + " b.g_lonx AS stationGlonx," + | ||
| 350 | + " b.g_laty AS stationGlaty," + | ||
| 351 | + " b.x AS stationX," + | ||
| 352 | + " b.y AS stationY," + | ||
| 353 | + " ST_AsText(b.b_polygon_grid) as stationBPolyonGrid," + | ||
| 354 | + " ST_AsText(b.g_polygon_grid) AS stationGPloyonGrid, " + | ||
| 355 | + " b.destroy AS stationDestroy," + | ||
| 356 | + " b.radius AS stationRadius," + | ||
| 357 | + " b.shapes_type AS stationShapesType," + | ||
| 358 | + " b.versions AS stationVersions," + | ||
| 359 | + " b.descriptions AS sttationDescriptions," + | ||
| 360 | + " b.create_by AS stationCreateBy," + | ||
| 361 | + " b.create_date AS stationCreateDate," + | ||
| 362 | + " b.update_by AS stationUpdateBy," + | ||
| 363 | + " b.update_date AS stationUpdateDate," + | ||
| 364 | + " a.stationRouteId," + | ||
| 365 | + "b.station_name as zdmc, "+ | ||
| 366 | + "a.industryCode "+ | ||
| 367 | + " FROM ( SELECT s.id AS stationRouteId," + | ||
| 368 | + " s.line AS stationRouteLine," + | ||
| 369 | + " s.station as stationRouteStation," + | ||
| 370 | + " s.station_name AS stationRouteName," + | ||
| 371 | + " s.station_route_code as stationRouteCode," + | ||
| 372 | + " s.industry_code as industryCode," + | ||
| 373 | + " s.line_code AS stationRouteLIneCode," + | ||
| 374 | + " s.station_mark AS stationRouteStationMark," + | ||
| 375 | + " s.out_station_nmber AS stationOutStationNmber," + | ||
| 376 | + " s.directions AS stationRoutedirections," + | ||
| 377 | + " s.distances AS stationRouteDistances," + | ||
| 378 | + " s.to_time AS stationRouteToTime," + | ||
| 379 | + " s.first_time AS staitonRouteFirstTime," + | ||
| 380 | + " s.end_time AS stationRouteEndTime," + | ||
| 381 | + " s.descriptions AS stationRouteDescriptions," + | ||
| 382 | + " s.destroy AS stationRouteDestroy," + | ||
| 383 | + " s.versions AS stationRouteVersions," + | ||
| 384 | + " s.create_by AS stationRouteCreateBy," + | ||
| 385 | + " s.create_date AS stationRouteCreateDate," + | ||
| 386 | + " s.update_by AS stationRouteUpdateBy," + | ||
| 387 | + " s.update_date AS stationRouteUpdateDate FROM bsth_c_stationroute s WHERE s.line = ?1 and s.directions = ?2 and s.destroy = 0) a " + | ||
| 388 | + " LEFT JOIN bsth_c_station b ON a.stationRouteStation = b.id order by a.stationRouteCode", nativeQuery=true) | ||
| 389 | + List<Object[]> getStationRouteList(Integer lineId, Integer dir); | ||
| 390 | + | ||
| 391 | + List<StationRoute> findByLine(Line line); | ||
| 392 | + | ||
| 393 | + @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH) | ||
| 394 | + @Query("select s from StationRoute s where s.destroy=0") | ||
| 395 | + List<StationRoute> findAllEffective(); | ||
| 396 | + | ||
| 397 | + @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH) | ||
| 398 | + @Override | ||
| 399 | + Page<StationRoute> findAll(Specification<StationRoute> spec, Pageable pageable); | ||
| 400 | + | ||
| 401 | + @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH) | ||
| 402 | + @Override | ||
| 403 | + List<StationRoute> findAll(Specification<StationRoute> spec); | ||
| 404 | + | ||
| 405 | + @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH) | ||
| 406 | + @Override | ||
| 407 | + List<StationRoute> findAll(Specification<StationRoute> spec, Sort sort); | ||
| 408 | + | ||
| 409 | + @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH) | ||
| 410 | + @Override | ||
| 411 | + @Query(value = "select r from StationRoute r where r.destroy=0") | ||
| 412 | + List<StationRoute> findAll(); | ||
| 413 | + | ||
| 414 | + @Query("select new map(sr.station.id as stationid, sr.stationName as stationname) from StationRoute sr where sr.line.id=?1 and sr.directions=?2") | ||
| 415 | + List<Map<String, Object>> findStations(Integer xlid, Integer xldir); | ||
| 416 | + | ||
| 417 | + @Query("select r from StationRoute r where r.lineCode=?1 and r.directions=?2 and r.destroy=0 order by r.stationRouteCode") | ||
| 418 | + List<StationRoute> findByLine(String lineCode, int updown); | ||
| 419 | + | ||
| 420 | + @Query("select r from StationRoute r where r.line.id=?1 and r.directions=?2 and r.destroy=0 order by r.stationRouteCode") | ||
| 421 | + List<StationRoute> findByLine(Integer lineId, Integer dir); | ||
| 422 | + | ||
| 423 | + @Query("select r from StationRoute r where r.lineCode=?1 and r.directions=?2 order by r.destroy, r.stationRouteCode") | ||
| 424 | + List<StationRoute> findAllByLine(String lineCode, int updown); | ||
| 425 | + | ||
| 426 | + @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH) | ||
| 427 | + @Query("select s from StationRoute s where s.destroy=0 and s.lineCode=?1") | ||
| 428 | + List<StationRoute> findByLineCode(String lineCode); | ||
| 429 | + | ||
| 430 | + @Query("SELECT new map(" + | ||
| 431 | + "lineCode as lineCode,directions as directions,stationName as stationName,stationCode as stationCode," + | ||
| 432 | + "line.linePlayType as linePlayType,s.stationMark as stationMark) " + | ||
| 433 | + "FROM " + | ||
| 434 | + "StationRoute s " + | ||
| 435 | + "WHERE " + | ||
| 436 | + "s.destroy = 0 " + | ||
| 437 | + "and s.lineCode in(select lineCode from Line where inUse = 1) " + | ||
| 438 | + "ORDER BY " + | ||
| 439 | + "lineCode,directions,stationRouteCode") | ||
| 440 | + List<Map<String, String>> findLineWithYgcAndInuse(); | ||
| 441 | + | ||
| 442 | + @Query("SELECT new map(" + | ||
| 443 | + "lineCode as lineCode,directions as directions,stationName as stationName,stationCode as stationCode," + | ||
| 444 | + "line.linePlayType as linePlayType,s.stationMark as stationMark) " + | ||
| 445 | + "FROM " + | ||
| 446 | + "StationRoute s " + | ||
| 447 | + "WHERE " + | ||
| 448 | + "s.destroy = 0 " + | ||
| 449 | + "ORDER BY " + | ||
| 450 | + "lineCode,directions,stationRouteCode") | ||
| 451 | + List<Map<String, String>> findAllLineWithYgc(); | ||
| 452 | + | ||
| 453 | + @Query("SELECT new map(" + | ||
| 454 | + "lineCode as lineCode,directions as directions,stationName as stationName,stationCode as stationCode," + | ||
| 455 | + "line.linePlayType as linePlayType,s.stationMark as stationMark) " + | ||
| 456 | + "FROM " + | ||
| 457 | + "StationRoute s " + | ||
| 458 | + "WHERE " + | ||
| 459 | + "s.destroy = 0 and s.lineCode = ?1 " + | ||
| 460 | + "ORDER BY " + | ||
| 461 | + "lineCode,directions,stationRouteCode") | ||
| 462 | + List<Map<String, String>> findLineWithYgcByLine(String lineCode); | ||
| 463 | + | ||
| 464 | + @Modifying | ||
| 465 | + @Query(value="update bsth_c_stationroute set directions = case directions when 1 then 0 when 0 then 1 end where line = ?1 ", nativeQuery=true) | ||
| 466 | + void stationRouteDir(Integer line); | ||
| 467 | + | ||
| 468 | + @Modifying | ||
| 469 | + @Query(value="update bsth_c_stationroute set distances =?2 where id = ?1 ", nativeQuery=true) | ||
| 470 | + void upddis(Integer id,Double dis); | ||
| 471 | + | ||
| 472 | + @Modifying | ||
| 473 | + @Query(value="UPDATE bsth_c_stationroute set station_route_code = (station_route_code+10) where line = ?1 and directions = ?2 and station_route_code >=?3 and destroy = 0", nativeQuery=true) | ||
| 474 | + void stationUpdStationRouteCode(Integer line,Integer dir,Integer routeCod); | ||
| 475 | + | ||
| 476 | + /** | ||
| 477 | + * 更新路线前撤销线路原有站点 | ||
| 478 | + * | ||
| 479 | + * @param line | ||
| 480 | + * @param dir | ||
| 481 | + */ | ||
| 482 | + @Modifying | ||
| 483 | + @Query(value="UPDATE bsth_c_stationroute set destroy = 1 where line = ?1 and directions = ?2", nativeQuery=true) | ||
| 484 | + void stationRouteUpdDestroy(Integer line,Integer dir); | ||
| 485 | + | ||
| 486 | + @Modifying | ||
| 487 | + @Query(value="UPDATE bsth_c_stationroute set destroy = 1 where id = ?1", nativeQuery=true) | ||
| 488 | + void stationRouteIsDestroyUpdBatch(Integer ids); | ||
| 489 | + | ||
| 490 | + /** | ||
| 491 | + * | ||
| 492 | + * | ||
| 493 | + * @param line | ||
| 494 | + * @param dir | ||
| 495 | + */ | ||
| 496 | + @Modifying | ||
| 497 | + @Query(value="insert into (select * from bsth_c_stationroute_cache where line = ?1 and directions = ?2) bsth_c_stationroute", nativeQuery=true) | ||
| 498 | + void stationRouteUpdate(Integer line,Integer dir); | ||
| 499 | + | ||
| 500 | + // 更具线路批量撤销 | ||
| 501 | + @Modifying | ||
| 502 | + @Query(value="UPDATE StationRoute sr set sr.destroy = 1 where sr.line.id = ?1 and sr.lineCode = ?2") | ||
| 503 | + void batchUpdate(Integer lineId, String lineCode); | ||
| 504 | + | ||
| 505 | + // 批量删除 | ||
| 506 | + @Modifying | ||
| 507 | + @Query(value="delete from StationRoute sr where sr.line.id = ?1 and sr.lineCode = ?2") | ||
| 508 | + void batchDelete(Integer lineId, String lineCode); | ||
| 509 | + | ||
| 510 | + | ||
| 511 | + // 批量修改站点行业编码 | ||
| 512 | + @Modifying | ||
| 513 | + @Query(value="update bsth_c_stationroute set industry_code =?2 where id = ?1 ", nativeQuery=true) | ||
| 514 | + void updIndustryCode(Integer id,String IndustryCode); | ||
| 515 | +} |
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
| 1 | -package com.bsth.repository.realcontrol; | ||
| 2 | - | ||
| 3 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 4 | -import com.bsth.entity.schedule.CarConfigInfo; | ||
| 5 | -import com.bsth.repository.BaseRepository; | ||
| 6 | -import org.springframework.data.domain.Page; | ||
| 7 | -import org.springframework.data.domain.Pageable; | ||
| 8 | -import org.springframework.data.jpa.domain.Specification; | ||
| 9 | -import org.springframework.data.jpa.repository.EntityGraph; | ||
| 10 | -import org.springframework.data.jpa.repository.Modifying; | ||
| 11 | -import org.springframework.data.jpa.repository.Query; | ||
| 12 | -import org.springframework.stereotype.Repository; | ||
| 13 | - | ||
| 14 | -import javax.transaction.Transactional; | ||
| 15 | -import java.util.List; | ||
| 16 | -import java.util.Map; | ||
| 17 | - | ||
| 18 | -@Repository | ||
| 19 | -public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealInfo, Long>{ | ||
| 20 | - | ||
| 21 | - @Query("select s from ScheduleRealInfo s where s.xlBm in ?1") | ||
| 22 | - List<ScheduleRealInfo> findByLines(List<String> lines); | ||
| 23 | - | ||
| 24 | - | ||
| 25 | - @Query(value="select s from ScheduleRealInfo s where s.id = ?1 ") | ||
| 26 | - ScheduleRealInfo scheduleById(Long id); | ||
| 27 | - | ||
| 28 | - @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr = ?2 and bc_type not in ('in','out') order by (lpName+1),clZbh,realExecDate,dfsj") | ||
| 29 | - List<ScheduleRealInfo> scheduleDailyQp(String line,String date); | ||
| 30 | - | ||
| 31 | - @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr = ?2 GROUP BY s.id,s.jGh,s.clZbh,s.lpName order by (lpName+1)") | ||
| 32 | - List<ScheduleRealInfo> queryUserInfo(String line,String date); | ||
| 33 | - | ||
| 34 | - @Query(value="select min(s.id), s.jGh,s.clZbh,s.lpName,min(s.jName) from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr = ?2 GROUP BY s.jGh,s.clZbh,s.lpName order by (lpName+1)") | ||
| 35 | - List<Object[]> queryUserInfo2(String line,String date); | ||
| 36 | - | ||
| 37 | - @Query(value="select min(s.id), s.clZbh from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr = ?2 GROUP BY s.clZbh ") | ||
| 38 | - List<Object[]> queryUserInfo3(String line,String date); | ||
| 39 | - | ||
| 40 | - @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 order by bcs") | ||
| 41 | - List<ScheduleRealInfo> exportWaybill(String jName,String clZbh,String lpName); | ||
| 42 | - | ||
| 43 | - //把sum(addMileage) 替换为0 数据表去掉了 add_mileage 字段 | ||
| 44 | - @Query(value="select new map(clZbh as clZbh,jGh as jGh,jName as jName,sum(jhlc) as zgl," | ||
| 45 | - + "0 as ksgl,count(jName) as bcs) from ScheduleRealInfo s where" | ||
| 46 | - + " s.xlBm = ?1 and s.scheduleDateStr = ?2 group by clZbh,jGh,jName") | ||
| 47 | - List<Map<String, Object>> dailyInfo(String line,String date); | ||
| 48 | - | ||
| 49 | - @Query(value="select d.device_id,d.sender,d.txt_content,d.timestamp,d.line_code from " | ||
| 50 | - + " bsth_v_directive_60 d where d.line_code=?1 and d.timestamp >=?2 and " | ||
| 51 | - + "d.timestamp <=?3 and d.device_id like %?4% ",nativeQuery=true) | ||
| 52 | - List<Object[]> historyMessage(String line,long d,long t,String code); | ||
| 53 | - | ||
| 54 | - @Query(value="SELECT r.xl_name,r.lp_name,r.cl_zbh,count(*) as cs " | ||
| 55 | - + " FROM bsth_c_s_sp_info_real r RIGHT JOIN bsth_v_directive_60 d " | ||
| 56 | - + " ON r.id = d.sch WHERE d.is_dispatch = 1 AND r.xl_bm like %?1% AND " | ||
| 57 | - + " r.schedule_date_str = ?2 and r.cl_zbh like %?3% group by " | ||
| 58 | - + " lp_name,xl_name,cl_zbh",nativeQuery=true) | ||
| 59 | - List<Object[]> historyMessageCount(String line,String date,String code); | ||
| 60 | - | ||
| 61 | - @Query(value="SELECT r.xl_name,r.cl_zbh,d.sender,d.timestamp,d.txt_content " | ||
| 62 | - + " FROM bsth_c_s_sp_info_real r RIGHT JOIN bsth_v_directive_60 d " | ||
| 63 | - + " ON r.id = d.sch WHERE d.is_dispatch = 1 AND r.xl_bm like %?1% AND " | ||
| 64 | - + " r.schedule_date_str = ?2 and r.cl_zbh =?3 ",nativeQuery=true) | ||
| 65 | - List<Object[]> historyMessageList(String line,String date,String code); | ||
| 66 | - | ||
| 67 | - @Query(value = "select max(id) from ScheduleRealInfo") | ||
| 68 | - Long getMaxId(); | ||
| 69 | - | ||
| 70 | - @Query(value = "select count(*) from ScheduleRealInfo s where s.scheduleDateStr = ?1") | ||
| 71 | - int countByDate(String date); | ||
| 72 | - | ||
| 73 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 74 | - @Query(value = "select DISTINCT s from ScheduleRealInfo s where s.scheduleDateStr = ?1") | ||
| 75 | - List<ScheduleRealInfo> findByDate(String dateStr); | ||
| 76 | - | ||
| 77 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 78 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr = ?2 and cl_zbh=?3 order by bcs") | ||
| 79 | - List<ScheduleRealInfo> findByDate2(String line,String date,String clzbh); | ||
| 80 | - | ||
| 81 | - @Query(value="select count(jName) from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and s.status = -1") | ||
| 82 | - int findCjbc(String jName,String clZbh,String lpName); | ||
| 83 | - | ||
| 84 | - @Query(value="select count(jName) from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and sflj != 0") | ||
| 85 | - int findLjbc(String jName,String clZbh,String lpName); | ||
| 86 | - | ||
| 87 | - @Query(value="SELECT request_code,FROM_UNIXTIME(TIMESTAMP / 1000,'%Y-%m-%d %T') as TIMESTAMP ,device_id FROM bsth_v_report_80 WHERE FROM_UNIXTIME( TIMESTAMP / 1000,'%Y-%m-%d') = ?2 AND line_id = ?1 and device_id like %?3%",nativeQuery=true) | ||
| 88 | - List<Object[]> account(String line,String date,String code); | ||
| 89 | - | ||
| 90 | - @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr >= ?2 " | ||
| 91 | - + " and s.scheduleDateStr <= ?3 and s.lpName like %?4% " | ||
| 92 | - + " and clZbh like %?5% order by s.fcsj") | ||
| 93 | - List<ScheduleRealInfo> correctForm(String line,String startDate,String endDate,String lpName,String code); | ||
| 94 | - | ||
| 95 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 96 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and s.scheduleDateStr = ?4 and s.xlBm=?5 order by realExecDate,fcsj") | ||
| 97 | - List<ScheduleRealInfo> queryListWaybill(String jName,String clZbh,String lpName,String date,String line); | ||
| 98 | - | ||
| 99 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 100 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.jGh = ?1 and s.clZbh = ?2 and s.lpName = ?3 and s.scheduleDateStr = ?4 and s.xlBm=?5 order by realExecDate,fcsj") | ||
| 101 | - List<ScheduleRealInfo> queryListWaybillXcld(String jGh,String clZbh,String lpName,String date,String line); | ||
| 102 | - | ||
| 103 | -// @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 104 | -// @Query(value="select DISTINCT s from ScheduleRealInfo s where s.jGh like %?1% and s.clZbh like %?2% and s.scheduleDate = str_to_date(?3,'%Y-%m-%d') and s.gsBm like %?4% and s.fgsBm like %?5% order by realExecDate,fcsj") | ||
| 105 | -// List<ScheduleRealInfo> queryListWaybill3(String jName,String clZbh,String date,String gsbm,String fgsbm); | ||
| 106 | - | ||
| 107 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 108 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr = ?2 order by s.xlBm,s.clZbh,s.jGh,s.realExecDate,s.fcsj") | ||
| 109 | - List<ScheduleRealInfo> scheduleByDateAndLineTjrb(String line,String date); | ||
| 110 | - | ||
| 111 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 112 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr = ?2 and s.xlDir=?3 and s.fcsjActual is not null and s.zdsjActual is not null order by s.realExecDate,s.fcsjActual") | ||
| 113 | - List<ScheduleRealInfo> scheduleByDateAndLineInOut(String line,String date,String zd); | ||
| 114 | - | ||
| 115 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 116 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.clZbh = ?1 and s.scheduleDateStr = ?2 and xlBm =?3 order by realExecDate,fcsj") | ||
| 117 | - List<ScheduleRealInfo> queryListWaybill2(String clZbh,String date,String line); | ||
| 118 | - | ||
| 119 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 120 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.jGh like %?1% and s.clZbh like %?2% and s.scheduleDateStr = ?3 and s.gsBm like %?4% and s.fgsBm like %?5% order by realExecDate,dfsj") | ||
| 121 | - List<ScheduleRealInfo> queryListWaybill3(String jName,String clZbh,String date,String gsbm,String fgsbm); | ||
| 122 | - | ||
| 123 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 124 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.scheduleDateStr >=?3 and s.scheduleDateStr <=?4 order by bcs") | ||
| 125 | - List<ScheduleRealInfo> queryListWaybill4(String jName,String clZbh,String date,String enddate); | ||
| 126 | - | ||
| 127 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 128 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr = ?2") | ||
| 129 | - List<ScheduleRealInfo> scheduleDaily(String line,String date); | ||
| 130 | - | ||
| 131 | - @Query(value = "select count(*) from ScheduleRealInfo s where s.xlBm=?1 and s.scheduleDateStr=?2") | ||
| 132 | - int countByLineCodeAndDate(String xlBm, String schDate); | ||
| 133 | - | ||
| 134 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 135 | - @Query(value = "select DISTINCT s from ScheduleRealInfo s where s.xlBm=?1 and s.scheduleDateStr=?2 and ccService=false") | ||
| 136 | - List<ScheduleRealInfo> findByLineCodeAndDate(String xlBm, String schDate); | ||
| 137 | - | ||
| 138 | - @Modifying | ||
| 139 | - @Transactional | ||
| 140 | - @Query(value = "delete ScheduleRealInfo s where s.xlBm=?1 and s.scheduleDateStr=?2") | ||
| 141 | - void deleteByLineCodeAndDate(String xlBm, String schDate); | ||
| 142 | - | ||
| 143 | - //去掉了 xlBm is not null | ||
| 144 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 145 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm like %?1% and s.scheduleDateStr = ?2 order by s.xlDir,s.realExecDate,s.fcsj, lpName") | ||
| 146 | - List<ScheduleRealInfo> scheduleByDateAndLine(String line,String date); | ||
| 147 | - | ||
| 148 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 149 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm =?1 and s.scheduleDateStr = ?2 order by s.lpName, s.realExecDate,s.fcsj") | ||
| 150 | - List<ScheduleRealInfo> scheduleByDateAndLineQp(String line,String date); | ||
| 151 | - | ||
| 152 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 153 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm =?1 and s.scheduleDateStr = ?2 and s.ccService=false order by s.lpName, s.realExecDate,s.fcsj") | ||
| 154 | - List<ScheduleRealInfo> scheduleDdrb(String line,String date); | ||
| 155 | - | ||
| 156 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 157 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr= ?2 and s.ccService=false order by s.xlDir,s.realExecDate,s.fcsj, s.lpName") | ||
| 158 | - List<ScheduleRealInfo> scheduleDdrb2(String line,String date); | ||
| 159 | - | ||
| 160 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 161 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where gsBm like %?1% and fgsBm like %?2% and s.scheduleDateStr = ?3 order by s.xlDir,s.realExecDate,s.fcsj, s.lpName") | ||
| 162 | - List<ScheduleRealInfo> scheduleByDateAndLineByGs_(String gsdm,String fgsdm,String date); | ||
| 163 | - | ||
| 164 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 165 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where gsBm like %?1% and fgsBm like %?2% and s.scheduleDateStr = ?3 and s.bcType not in ('in','out','ldks') order by s.xlDir,s.realExecDate,s.fcsj, s.lpName") | ||
| 166 | - List<ScheduleRealInfo> scheduleByDateAndLineByGs(String gsdm,String fgsdm,String date); | ||
| 167 | - | ||
| 168 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 169 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr= ?2 order by s.xlDir,s.realExecDate,s.fcsj, s.lpName") | ||
| 170 | - List<ScheduleRealInfo> scheduleByDateAndLineQp2(String line,String date); | ||
| 171 | - | ||
| 172 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 173 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr = ?2 and s.bcType not in ('in','out','ldks') order by s.xlBm,s.realExecDate,s.fcsj") | ||
| 174 | - List<ScheduleRealInfo> scheduleByDateAndLine2(String line,String date); | ||
| 175 | - | ||
| 176 | - //按月统计 | ||
| 177 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 178 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm like %?1% and s.scheduleDateStr = ?2 and s.bcType not in ('in','out','ldks') order by s.xlBm") | ||
| 179 | - List<ScheduleRealInfo> scheduleByDateAndLine3(String line,String date); | ||
| 180 | - | ||
| 181 | - //按照时间段统计 | ||
| 182 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 183 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm like %?1% and s.scheduleDateStr between ?2 and ?3 and gsBm = ?4 and fgsBm like %?5% order by s.fgsBm, s.xlBm") | ||
| 184 | - List<ScheduleRealInfo> scheduleByDateAndLineTj(String line,String date,String date2,String gsdm,String fgsdm); | ||
| 185 | - | ||
| 186 | - //按照时间段统计 | ||
| 187 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 188 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr >= ?2 and s.scheduleDateStr<= ?3 order by s.fgsBm,s.xlBm") | ||
| 189 | - List<ScheduleRealInfo> scheduleByDateAndLineTj2(String line,String date,String date2); | ||
| 190 | - //月报表 | ||
| 191 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 192 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr >= ?2 and s.scheduleDateStr<= ?3 order by s.xlBm") | ||
| 193 | - List<ScheduleRealInfo> scheduleByDateAndLineYbb(String line,String date,String date2); | ||
| 194 | - | ||
| 195 | - | ||
| 196 | - @Query(value="select new map(s.scheduleDate as scheduleDate,s.xlBm as xlBm,s.clZbh as clZbh,s.jGh as jGh,s.lpName as lpName,min(CONCAT(s.realExecDate,' ',s.fcsj)) AS realExecDate ) from ScheduleRealInfo s where s.xlBm like %?1% and s.scheduleDateStr = ?2 and s.gsBm like %?3% and s.fgsBm like %?4% and s.clZbh like %?5% GROUP BY xlBm,clZbh,jGh,scheduleDate,lpName ORDER BY clZbh,realExecDate") | ||
| 197 | - List<Map<String,Object>> yesterdayDataList(String line,String date,String gsbm,String fgsbm,String nbbm); | ||
| 198 | - | ||
| 199 | - @Query(value="select new map(s.scheduleDate as scheduleDate,s.xlBm as xlBm,s.clZbh as clZbh,s.jGh as jGh,s.lpName as lpName,min(CONCAT(s.realExecDate,' ',s.fcsj)) AS realExecDate ) from ScheduleRealInfo s where s.xlBm =?1 and s.scheduleDateStr = ?2 and s.gsBm like %?3% and s.fgsBm like %?4% and s.clZbh like %?5% GROUP BY xlBm,clZbh,jGh,scheduleDate,lpName ORDER BY clZbh,realExecDate") | ||
| 200 | - List<Map<String,Object>> yesterdayDataList_eq(String line,String date,String gsbm,String fgsbm,String nbbm); | ||
| 201 | - | ||
| 202 | - @Query(value="select s from ScheduleRealInfo s where s.scheduleDateStr = ?1 ORDER BY xlBm,lpName,clZbh,xlDir") | ||
| 203 | - List<ScheduleRealInfo> setLD(String date); | ||
| 204 | - | ||
| 205 | - @Query(value="select new map(xlBm as xlBm,lpName as lpName,clZbh as clZbh) from ScheduleRealInfo s where s.scheduleDateStr = ?1 GROUP BY xlBm,lpName,clZbh ORDER BY xlBm,lpName,clZbh") | ||
| 206 | - List<Map<String,Object>> setLDGroup(String date); | ||
| 207 | - | ||
| 208 | - @Query(value="select new map(xlBm as xlBm,clZbh as clZbh) from ScheduleRealInfo s where s.scheduleDateStr = ?1 GROUP BY xlBm,clZbh ORDER BY xlBm,clZbh") | ||
| 209 | - List<Map<String,Object>> setLCYHGroup(String date); | ||
| 210 | - | ||
| 211 | - @Query(value="select new map(xlBm as xlBm) from ScheduleRealInfo s where s.scheduleDateStr = ?1 GROUP BY xlBm ORDER BY xlBm") | ||
| 212 | - List<Map<String,Object>> setDDRBGroup(String date); | ||
| 213 | - | ||
| 214 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 215 | - @Override | ||
| 216 | - Page<ScheduleRealInfo> findAll(Specification<ScheduleRealInfo> spec, Pageable pageable); | ||
| 217 | - | ||
| 218 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 219 | - @Override | ||
| 220 | - List<ScheduleRealInfo> findAll(Specification<ScheduleRealInfo> spec); | ||
| 221 | - | ||
| 222 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 223 | - @Override | ||
| 224 | - List<ScheduleRealInfo> findAll(); | ||
| 225 | - | ||
| 226 | - @Modifying | ||
| 227 | - @Transactional | ||
| 228 | - @Query(value = "update ScheduleRealInfo s set s.lpChange=1 where s.id=?1 ") | ||
| 229 | - Integer updateLpChange(Long id); | ||
| 230 | - | ||
| 231 | - @Query(value = "select count (s.id) from ScheduleRealInfo s where s.clZbh=?1 and s.scheduleDateStr=?2 and s.xlBm=?3 and s.qdzCode=?4") | ||
| 232 | - Long isCircleQdz(String clzbh,String sdr,String xlbm,String qdzCode); | ||
| 233 | - | ||
| 234 | -} | 1 | +package com.bsth.repository.realcontrol; |
| 2 | + | ||
| 3 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 4 | +import com.bsth.entity.schedule.CarConfigInfo; | ||
| 5 | +import com.bsth.repository.BaseRepository; | ||
| 6 | +import org.springframework.data.domain.Page; | ||
| 7 | +import org.springframework.data.domain.Pageable; | ||
| 8 | +import org.springframework.data.jpa.domain.Specification; | ||
| 9 | +import org.springframework.data.jpa.repository.EntityGraph; | ||
| 10 | +import org.springframework.data.jpa.repository.Modifying; | ||
| 11 | +import org.springframework.data.jpa.repository.Query; | ||
| 12 | +import org.springframework.stereotype.Repository; | ||
| 13 | + | ||
| 14 | +import javax.transaction.Transactional; | ||
| 15 | +import java.util.List; | ||
| 16 | +import java.util.Map; | ||
| 17 | + | ||
| 18 | +@Repository | ||
| 19 | +public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealInfo, Long>{ | ||
| 20 | + | ||
| 21 | + @Query("select s from ScheduleRealInfo s where s.xlBm in ?1") | ||
| 22 | + List<ScheduleRealInfo> findByLines(List<String> lines); | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + @Query(value="select s from ScheduleRealInfo s where s.id = ?1 ") | ||
| 26 | + ScheduleRealInfo scheduleById(Long id); | ||
| 27 | + | ||
| 28 | + @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr = ?2 and bc_type not in ('in','out') order by (lpName+1),clZbh,realExecDate,dfsj") | ||
| 29 | + List<ScheduleRealInfo> scheduleDailyQp(String line,String date); | ||
| 30 | + | ||
| 31 | + @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr = ?2 GROUP BY s.id,s.jGh,s.clZbh,s.lpName order by (lpName+1)") | ||
| 32 | + List<ScheduleRealInfo> queryUserInfo(String line,String date); | ||
| 33 | + | ||
| 34 | + @Query(value="select min(s.id), s.jGh,s.clZbh,s.lpName,min(s.jName) from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr = ?2 GROUP BY s.jGh,s.clZbh,s.lpName order by (lpName+1)") | ||
| 35 | + List<Object[]> queryUserInfo2(String line,String date); | ||
| 36 | + | ||
| 37 | + @Query(value="select min(s.id), s.clZbh from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr = ?2 GROUP BY s.clZbh ") | ||
| 38 | + List<Object[]> queryUserInfo3(String line,String date); | ||
| 39 | + | ||
| 40 | + @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 order by bcs") | ||
| 41 | + List<ScheduleRealInfo> exportWaybill(String jName,String clZbh,String lpName); | ||
| 42 | + | ||
| 43 | + //把sum(addMileage) 替换为0 数据表去掉了 add_mileage 字段 | ||
| 44 | + @Query(value="select new map(clZbh as clZbh,jGh as jGh,jName as jName,sum(jhlc) as zgl," | ||
| 45 | + + "0 as ksgl,count(jName) as bcs) from ScheduleRealInfo s where" | ||
| 46 | + + " s.xlBm = ?1 and s.scheduleDateStr = ?2 group by clZbh,jGh,jName") | ||
| 47 | + List<Map<String, Object>> dailyInfo(String line,String date); | ||
| 48 | + | ||
| 49 | + @Query(value="select d.device_id,d.sender,d.txt_content,d.timestamp,d.line_code, " | ||
| 50 | + + " d.reply46,d.reply47 from " | ||
| 51 | + + " bsth_v_directive_60 d where d.line_code=?1 and d.device_id=?2 " | ||
| 52 | + + " and d.timestamp >=?3 and d.timestamp <=?4 ",nativeQuery=true) | ||
| 53 | + List<Object[]> historyMessage(String line,String code,long d,long t); | ||
| 54 | + | ||
| 55 | + @Query(value="SELECT r.xl_name,r.lp_name,r.cl_zbh,count(*) as cs " | ||
| 56 | + + " FROM bsth_c_s_sp_info_real r RIGHT JOIN bsth_v_directive_60 d " | ||
| 57 | + + " ON r.id = d.sch WHERE d.is_dispatch = 1 AND r.xl_bm like %?1% AND " | ||
| 58 | + + " r.schedule_date_str = ?2 and r.cl_zbh like %?3% group by " | ||
| 59 | + + " lp_name,xl_name,cl_zbh",nativeQuery=true) | ||
| 60 | + List<Object[]> historyMessageCount(String line,String date,String code); | ||
| 61 | + | ||
| 62 | + @Query(value="SELECT r.xl_name,r.cl_zbh,d.sender,d.timestamp,d.txt_content " | ||
| 63 | + + " FROM bsth_c_s_sp_info_real r RIGHT JOIN bsth_v_directive_60 d " | ||
| 64 | + + " ON r.id = d.sch WHERE d.is_dispatch = 1 AND r.xl_bm like %?1% AND " | ||
| 65 | + + " r.schedule_date_str = ?2 and r.cl_zbh =?3 ",nativeQuery=true) | ||
| 66 | + List<Object[]> historyMessageList(String line,String date,String code); | ||
| 67 | + | ||
| 68 | + @Query(value = "select max(id) from ScheduleRealInfo") | ||
| 69 | + Long getMaxId(); | ||
| 70 | + | ||
| 71 | + @Query(value = "select count(*) from ScheduleRealInfo s where s.scheduleDateStr = ?1") | ||
| 72 | + int countByDate(String date); | ||
| 73 | + | ||
| 74 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 75 | + @Query(value = "select DISTINCT s from ScheduleRealInfo s where s.scheduleDateStr = ?1") | ||
| 76 | + List<ScheduleRealInfo> findByDate(String dateStr); | ||
| 77 | + | ||
| 78 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 79 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr = ?2 and cl_zbh=?3 order by bcs") | ||
| 80 | + List<ScheduleRealInfo> findByDate2(String line,String date,String clzbh); | ||
| 81 | + | ||
| 82 | + @Query(value="select count(jName) from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and s.status = -1") | ||
| 83 | + int findCjbc(String jName,String clZbh,String lpName); | ||
| 84 | + | ||
| 85 | + @Query(value="select count(jName) from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and sflj != 0") | ||
| 86 | + int findLjbc(String jName,String clZbh,String lpName); | ||
| 87 | + | ||
| 88 | + @Query(value="SELECT request_code,FROM_UNIXTIME(TIMESTAMP / 1000,'%Y-%m-%d %T') as TIMESTAMP ,device_id FROM bsth_v_report_80 WHERE FROM_UNIXTIME( TIMESTAMP / 1000,'%Y-%m-%d') = ?2 AND line_id = ?1 and device_id like %?3%",nativeQuery=true) | ||
| 89 | + List<Object[]> account(String line,String date,String code); | ||
| 90 | + | ||
| 91 | + @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr >= ?2 " | ||
| 92 | + + " and s.scheduleDateStr <= ?3 and s.lpName like %?4% " | ||
| 93 | + + " and clZbh like %?5% order by s.fcsj") | ||
| 94 | + List<ScheduleRealInfo> correctForm(String line,String startDate,String endDate,String lpName,String code); | ||
| 95 | + | ||
| 96 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 97 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and s.scheduleDateStr = ?4 and s.xlBm=?5 order by realExecDate,fcsj") | ||
| 98 | + List<ScheduleRealInfo> queryListWaybill(String jName,String clZbh,String lpName,String date,String line); | ||
| 99 | + | ||
| 100 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 101 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.jGh = ?1 and s.clZbh = ?2 and s.lpName = ?3 and s.scheduleDateStr = ?4 and s.xlBm=?5 order by realExecDate,fcsj") | ||
| 102 | + List<ScheduleRealInfo> queryListWaybillXcld(String jGh,String clZbh,String lpName,String date,String line); | ||
| 103 | + | ||
| 104 | +// @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 105 | +// @Query(value="select DISTINCT s from ScheduleRealInfo s where s.jGh like %?1% and s.clZbh like %?2% and s.scheduleDate = str_to_date(?3,'%Y-%m-%d') and s.gsBm like %?4% and s.fgsBm like %?5% order by realExecDate,fcsj") | ||
| 106 | +// List<ScheduleRealInfo> queryListWaybill3(String jName,String clZbh,String date,String gsbm,String fgsbm); | ||
| 107 | + | ||
| 108 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 109 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr = ?2 order by s.xlBm,s.clZbh,s.jGh,s.realExecDate,s.fcsj") | ||
| 110 | + List<ScheduleRealInfo> scheduleByDateAndLineTjrb(String line,String date); | ||
| 111 | + | ||
| 112 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 113 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr = ?2 and s.xlDir=?3 and s.fcsjActual is not null and s.zdsjActual is not null order by s.realExecDate,s.fcsjActual") | ||
| 114 | + List<ScheduleRealInfo> scheduleByDateAndLineInOut(String line,String date,String zd); | ||
| 115 | + | ||
| 116 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 117 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.clZbh = ?1 and s.scheduleDateStr = ?2 and xlBm =?3 order by realExecDate,fcsj") | ||
| 118 | + List<ScheduleRealInfo> queryListWaybill2(String clZbh,String date,String line); | ||
| 119 | + | ||
| 120 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 121 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.jGh like %?1% and s.clZbh like %?2% and s.scheduleDateStr = ?3 and s.gsBm like %?4% and s.fgsBm like %?5% order by realExecDate,dfsj") | ||
| 122 | + List<ScheduleRealInfo> queryListWaybill3(String jName,String clZbh,String date,String gsbm,String fgsbm); | ||
| 123 | + | ||
| 124 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 125 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.scheduleDateStr >=?3 and s.scheduleDateStr <=?4 order by bcs") | ||
| 126 | + List<ScheduleRealInfo> queryListWaybill4(String jName,String clZbh,String date,String enddate); | ||
| 127 | + | ||
| 128 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 129 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr = ?2") | ||
| 130 | + List<ScheduleRealInfo> scheduleDaily(String line,String date); | ||
| 131 | + | ||
| 132 | + @Query(value = "select count(*) from ScheduleRealInfo s where s.xlBm=?1 and s.scheduleDateStr=?2") | ||
| 133 | + int countByLineCodeAndDate(String xlBm, String schDate); | ||
| 134 | + | ||
| 135 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 136 | + @Query(value = "select DISTINCT s from ScheduleRealInfo s where s.xlBm=?1 and s.scheduleDateStr=?2 and ccService=false") | ||
| 137 | + List<ScheduleRealInfo> findByLineCodeAndDate(String xlBm, String schDate); | ||
| 138 | + | ||
| 139 | + @Modifying | ||
| 140 | + @Transactional | ||
| 141 | + @Query(value = "delete ScheduleRealInfo s where s.xlBm=?1 and s.scheduleDateStr=?2") | ||
| 142 | + void deleteByLineCodeAndDate(String xlBm, String schDate); | ||
| 143 | + | ||
| 144 | + //去掉了 xlBm is not null | ||
| 145 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 146 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm like %?1% and s.scheduleDateStr = ?2 order by s.xlDir,s.realExecDate,s.fcsj, lpName") | ||
| 147 | + List<ScheduleRealInfo> scheduleByDateAndLine(String line,String date); | ||
| 148 | + | ||
| 149 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 150 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm =?1 and s.scheduleDateStr = ?2 order by s.lpName, s.realExecDate,s.fcsj") | ||
| 151 | + List<ScheduleRealInfo> scheduleByDateAndLineQp(String line,String date); | ||
| 152 | + | ||
| 153 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 154 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm =?1 and s.scheduleDateStr = ?2 and s.ccService=false order by s.lpName, s.realExecDate,s.fcsj") | ||
| 155 | + List<ScheduleRealInfo> scheduleDdrb(String line,String date); | ||
| 156 | + | ||
| 157 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 158 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr= ?2 and s.ccService=false order by s.xlDir,s.realExecDate,s.fcsj, s.lpName") | ||
| 159 | + List<ScheduleRealInfo> scheduleDdrb2(String line,String date); | ||
| 160 | + | ||
| 161 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 162 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where gsBm like %?1% and fgsBm like %?2% and s.scheduleDateStr = ?3 order by s.xlDir,s.realExecDate,s.fcsj, s.lpName") | ||
| 163 | + List<ScheduleRealInfo> scheduleByDateAndLineByGs_(String gsdm,String fgsdm,String date); | ||
| 164 | + | ||
| 165 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 166 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where gsBm like %?1% and fgsBm like %?2% and s.scheduleDateStr = ?3 and s.bcType not in ('in','out','ldks') order by s.xlDir,s.realExecDate,s.fcsj, s.lpName") | ||
| 167 | + List<ScheduleRealInfo> scheduleByDateAndLineByGs(String gsdm,String fgsdm,String date); | ||
| 168 | + | ||
| 169 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 170 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr= ?2 order by s.xlDir,s.realExecDate,s.fcsj, s.lpName") | ||
| 171 | + List<ScheduleRealInfo> scheduleByDateAndLineQp2(String line,String date); | ||
| 172 | + | ||
| 173 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 174 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr = ?2 and s.bcType not in ('in','out','ldks') order by s.xlBm,s.realExecDate,s.fcsj") | ||
| 175 | + List<ScheduleRealInfo> scheduleByDateAndLine2(String line,String date); | ||
| 176 | + | ||
| 177 | + //按月统计 | ||
| 178 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 179 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm like %?1% and s.scheduleDateStr = ?2 and s.bcType not in ('in','out','ldks') order by s.xlBm") | ||
| 180 | + List<ScheduleRealInfo> scheduleByDateAndLine3(String line,String date); | ||
| 181 | + | ||
| 182 | + //按照时间段统计 | ||
| 183 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 184 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm like %?1% and s.scheduleDateStr between ?2 and ?3 and gsBm = ?4 and fgsBm like %?5% order by s.fgsBm, s.xlBm") | ||
| 185 | + List<ScheduleRealInfo> scheduleByDateAndLineTj(String line,String date,String date2,String gsdm,String fgsdm); | ||
| 186 | + | ||
| 187 | + //按照时间段统计 | ||
| 188 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 189 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr >= ?2 and s.scheduleDateStr<= ?3 order by s.fgsBm,s.xlBm") | ||
| 190 | + List<ScheduleRealInfo> scheduleByDateAndLineTj2(String line,String date,String date2); | ||
| 191 | + //月报表 | ||
| 192 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 193 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr >= ?2 and s.scheduleDateStr<= ?3 order by s.xlBm") | ||
| 194 | + List<ScheduleRealInfo> scheduleByDateAndLineYbb(String line,String date,String date2); | ||
| 195 | + | ||
| 196 | + | ||
| 197 | + @Query(value="select new map(s.scheduleDate as scheduleDate,s.xlBm as xlBm,s.clZbh as clZbh,s.jGh as jGh,s.lpName as lpName,min(CONCAT(s.realExecDate,' ',s.fcsj)) AS realExecDate ) from ScheduleRealInfo s where s.xlBm like %?1% and s.scheduleDateStr = ?2 and s.gsBm like %?3% and s.fgsBm like %?4% and s.clZbh like %?5% GROUP BY xlBm,clZbh,jGh,scheduleDate,lpName ORDER BY clZbh,realExecDate") | ||
| 198 | + List<Map<String,Object>> yesterdayDataList(String line,String date,String gsbm,String fgsbm,String nbbm); | ||
| 199 | + | ||
| 200 | + @Query(value="select new map(s.scheduleDate as scheduleDate,s.xlBm as xlBm,s.clZbh as clZbh,s.jGh as jGh,s.lpName as lpName,min(CONCAT(s.realExecDate,' ',s.fcsj)) AS realExecDate ) from ScheduleRealInfo s where s.xlBm =?1 and s.scheduleDateStr = ?2 and s.gsBm like %?3% and s.fgsBm like %?4% and s.clZbh like %?5% GROUP BY xlBm,clZbh,jGh,scheduleDate,lpName ORDER BY clZbh,realExecDate") | ||
| 201 | + List<Map<String,Object>> yesterdayDataList_eq(String line,String date,String gsbm,String fgsbm,String nbbm); | ||
| 202 | + | ||
| 203 | + @Query(value="select s from ScheduleRealInfo s where s.scheduleDateStr = ?1 ORDER BY xlBm,lpName,clZbh,xlDir") | ||
| 204 | + List<ScheduleRealInfo> setLD(String date); | ||
| 205 | + | ||
| 206 | + @Query(value="select new map(xlBm as xlBm,lpName as lpName,clZbh as clZbh) from ScheduleRealInfo s where s.scheduleDateStr = ?1 GROUP BY xlBm,lpName,clZbh ORDER BY xlBm,lpName,clZbh") | ||
| 207 | + List<Map<String,Object>> setLDGroup(String date); | ||
| 208 | + | ||
| 209 | + @Query(value="select new map(xlBm as xlBm,clZbh as clZbh) from ScheduleRealInfo s where s.scheduleDateStr = ?1 GROUP BY xlBm,clZbh ORDER BY xlBm,clZbh") | ||
| 210 | + List<Map<String,Object>> setLCYHGroup(String date); | ||
| 211 | + | ||
| 212 | + @Query(value="select new map(xlBm as xlBm) from ScheduleRealInfo s where s.scheduleDateStr = ?1 GROUP BY xlBm ORDER BY xlBm") | ||
| 213 | + List<Map<String,Object>> setDDRBGroup(String date); | ||
| 214 | + | ||
| 215 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 216 | + @Override | ||
| 217 | + Page<ScheduleRealInfo> findAll(Specification<ScheduleRealInfo> spec, Pageable pageable); | ||
| 218 | + | ||
| 219 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 220 | + @Override | ||
| 221 | + List<ScheduleRealInfo> findAll(Specification<ScheduleRealInfo> spec); | ||
| 222 | + | ||
| 223 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | ||
| 224 | + @Override | ||
| 225 | + List<ScheduleRealInfo> findAll(); | ||
| 226 | + | ||
| 227 | + @Modifying | ||
| 228 | + @Transactional | ||
| 229 | + @Query(value = "update ScheduleRealInfo s set s.lpChange=1 where s.id=?1 ") | ||
| 230 | + Integer updateLpChange(Long id); | ||
| 231 | + | ||
| 232 | + @Query(value = "select count (s.id) from ScheduleRealInfo s where s.clZbh=?1 and s.scheduleDateStr=?2 and s.xlBm=?3 and s.qdzCode=?4") | ||
| 233 | + Long isCircleQdz(String clzbh,String sdr,String xlbm,String qdzCode); | ||
| 234 | + | ||
| 235 | +} |