Commit 4dbf2667d75071b0f2ea7cc455c61bac560f7691
1 parent
135aed2f
1.ftp上传换成站点路由名称,
2.线路版本更新是带上站点行业编码
Showing
3 changed files
with
33 additions
and
31 deletions
src/main/java/com/bsth/repository/SectionRouteRepository.java
| @@ -30,11 +30,11 @@ public interface SectionRouteRepository extends BaseRepository<SectionRoute, Int | @@ -30,11 +30,11 @@ public interface SectionRouteRepository extends BaseRepository<SectionRoute, Int | ||
| 30 | 30 | ||
| 31 | // 查询最大ID | 31 | // 查询最大ID |
| 32 | @Query(value = "SELECT IFNULL(num,0) as maxId from (SELECT MAX(id) as num FROM bsth_c_sectionroute) k" , nativeQuery=true) | 32 | @Query(value = "SELECT IFNULL(num,0) as maxId from (SELECT MAX(id) as num FROM bsth_c_sectionroute) k" , nativeQuery=true) |
| 33 | - public long sectionRouteMaxId(); | 33 | + long sectionRouteMaxId(); |
| 34 | 34 | ||
| 35 | // 查询最大ID | 35 | // 查询最大ID |
| 36 | @Query(value = "SELECT IFNULL(num,0) as maxId from (SELECT MAX(sectionroute_code) as num FROM bsth_c_sectionroute where line_code = 601010 and directions = 1 and destroy = 0) k" , nativeQuery=true) | 36 | @Query(value = "SELECT IFNULL(num,0) as maxId from (SELECT MAX(sectionroute_code) as num FROM bsth_c_sectionroute where line_code = 601010 and directions = 1 and destroy = 0) k" , nativeQuery=true) |
| 37 | - public int sectionRouteCodeMaxId(); | 37 | + int sectionRouteCodeMaxId(); |
| 38 | 38 | ||
| 39 | /** | 39 | /** |
| 40 | * @Description :TODO(查询路段信息) | 40 | * @Description :TODO(查询路段信息) |
| @@ -173,15 +173,15 @@ public interface SectionRouteRepository extends BaseRepository<SectionRoute, Int | @@ -173,15 +173,15 @@ public interface SectionRouteRepository extends BaseRepository<SectionRoute, Int | ||
| 173 | 173 | ||
| 174 | @Modifying | 174 | @Modifying |
| 175 | @Query(value="UPDATE bsth_c_sectionroute set sectionroute_code = (sectionroute_code+1) where line = ?1 and directions = ?2 and sectionroute_code >=?3 and destroy = 0", nativeQuery=true) | 175 | @Query(value="UPDATE bsth_c_sectionroute set sectionroute_code = (sectionroute_code+1) where line = ?1 and directions = ?2 and sectionroute_code >=?3 and destroy = 0", nativeQuery=true) |
| 176 | - public void sectionUpdSectionRouteCode(Integer line,Integer dir,Integer routeCod); | 176 | + void sectionUpdSectionRouteCode(Integer line,Integer dir,Integer routeCod); |
| 177 | 177 | ||
| 178 | @Modifying | 178 | @Modifying |
| 179 | @Query(value="UPDATE bsth_c_sectionroute set sectionroute_code = (sectionroute_code+1) where line_code = ?1 and directions = ?2 and sectionroute_code >=?3 and destroy = 0", nativeQuery=true) | 179 | @Query(value="UPDATE bsth_c_sectionroute set sectionroute_code = (sectionroute_code+1) where line_code = ?1 and directions = ?2 and sectionroute_code >=?3 and destroy = 0", nativeQuery=true) |
| 180 | - public void sectionUpdSectionRouteCode(String lineCode,Integer dir,int routeCod); | 180 | + void sectionUpdSectionRouteCode(String lineCode,Integer dir,int routeCod); |
| 181 | 181 | ||
| 182 | @Modifying | 182 | @Modifying |
| 183 | @Query(value="UPDATE bsth_c_sectionroute set destroy = 1 where id = ?1", nativeQuery=true) | 183 | @Query(value="UPDATE bsth_c_sectionroute set destroy = 1 where id = ?1", nativeQuery=true) |
| 184 | - public void sectionRouteIsDestroyUpdBatch(Integer id); | 184 | + void sectionRouteIsDestroyUpdBatch(Integer id); |
| 185 | 185 | ||
| 186 | /** | 186 | /** |
| 187 | * 更新路线前撤销线路原有路段 | 187 | * 更新路线前撤销线路原有路段 |
| @@ -191,22 +191,22 @@ public interface SectionRouteRepository extends BaseRepository<SectionRoute, Int | @@ -191,22 +191,22 @@ public interface SectionRouteRepository extends BaseRepository<SectionRoute, Int | ||
| 191 | */ | 191 | */ |
| 192 | @Modifying | 192 | @Modifying |
| 193 | @Query(value="UPDATE bsth_c_sectionroute set destroy = 1 where line = ?1 and directions = ?2", nativeQuery=true) | 193 | @Query(value="UPDATE bsth_c_sectionroute set destroy = 1 where line = ?1 and directions = ?2", nativeQuery=true) |
| 194 | - public void sectionRouteUpdDestroy(Integer line,Integer dir); | 194 | + void sectionRouteUpdDestroy(Integer line,Integer dir); |
| 195 | 195 | ||
| 196 | @Modifying | 196 | @Modifying |
| 197 | @Query(value="update bsth_c_sectionroute set directions = case directions when 1 then 0 when 0 then 1 end where line_code = ?1 ", nativeQuery=true) | 197 | @Query(value="update bsth_c_sectionroute set directions = case directions when 1 then 0 when 0 then 1 end where line_code = ?1 ", nativeQuery=true) |
| 198 | - public void sectionRouteDir(Integer line); | 198 | + void sectionRouteDir(Integer line); |
| 199 | 199 | ||
| 200 | // 更具线路批量撤销 | 200 | // 更具线路批量撤销 |
| 201 | @Modifying | 201 | @Modifying |
| 202 | @Query(value="UPDATE SectionRoute sr set sr.destroy = 1 where sr.line.id = ?1 and sr.lineCode = ?2") | 202 | @Query(value="UPDATE SectionRoute sr set sr.destroy = 1 where sr.line.id = ?1 and sr.lineCode = ?2") |
| 203 | - public void batchUpdate(Integer lineId, String lineCode); | 203 | + void batchUpdate(Integer lineId, String lineCode); |
| 204 | 204 | ||
| 205 | // 批量删除 | 205 | // 批量删除 |
| 206 | @Modifying | 206 | @Modifying |
| 207 | - @Query(value="delete from SectionRoute sr where sr.line.id = ?1 and sr.lineCode = ?2") | ||
| 208 | - public void batchDelete(Integer lineId, String lineCode); | 207 | + @Query(value="delete from SectionRoute sr where sr.lineCode = ?1") |
| 208 | + void batchDelete(String lineCode); | ||
| 209 | 209 | ||
| 210 | @Query("select r from SectionRoute r where r.line.id=?1 and r.directions=?2 and r.destroy=0 order by r.sectionrouteCode") | 210 | @Query("select r from SectionRoute r where r.line.id=?1 and r.directions=?2 and r.destroy=0 order by r.sectionrouteCode") |
| 211 | - public List<SectionRoute> findByLine(Integer lineId, Integer dir); | 211 | + List<SectionRoute> findByLine(Integer lineId, Integer dir); |
| 212 | } | 212 | } |
src/main/java/com/bsth/repository/StationRouteRepository.java
| @@ -229,12 +229,13 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int | @@ -229,12 +229,13 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int | ||
| 229 | "a.station_route_code," + | 229 | "a.station_route_code," + |
| 230 | "b.station_cod," + | 230 | "b.station_cod," + |
| 231 | "a.distances,"+ | 231 | "a.distances,"+ |
| 232 | - "s.station_name," + | 232 | + "a.station_name," + |
| 233 | "a.directions FROM (SELECT " + | 233 | "a.directions FROM (SELECT " + |
| 234 | "s.station_mark," + | 234 | "s.station_mark," + |
| 235 | "s.station_route_code," + | 235 | "s.station_route_code," + |
| 236 | "s.directions," + | 236 | "s.directions," + |
| 237 | "s.distances,"+ | 237 | "s.distances,"+ |
| 238 | + "s.station_name," + | ||
| 238 | "s.station FROM bsth_c_stationroute s where s.line = ?1 and s.destroy=0) a " + | 239 | "s.station FROM bsth_c_stationroute s where s.line = ?1 and s.destroy=0) a " + |
| 239 | "LEFT JOIN bsth_c_station b " + | 240 | "LEFT JOIN bsth_c_station b " + |
| 240 | " on a.station = b.id ORDER BY a.directions ASC ) k ORDER BY k.directions,k.station_route_code ASC", nativeQuery=true) | 241 | " on a.station = b.id ORDER BY a.directions ASC ) k ORDER BY k.directions,k.station_route_code ASC", nativeQuery=true) |
| @@ -499,8 +500,8 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int | @@ -499,8 +500,8 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int | ||
| 499 | 500 | ||
| 500 | // 批量删除 | 501 | // 批量删除 |
| 501 | @Modifying | 502 | @Modifying |
| 502 | - @Query(value="delete from StationRoute sr where sr.line.id = ?1 and sr.lineCode = ?2") | ||
| 503 | - void batchDelete(Integer lineId, String lineCode); | 503 | + @Query(value="delete from StationRoute sr where sr.lineCode = ?1") |
| 504 | + void batchDelete(String lineCode); | ||
| 504 | 505 | ||
| 505 | 506 | ||
| 506 | // 批量修改站点行业编码 | 507 | // 批量修改站点行业编码 |
src/main/java/com/bsth/service/impl/LineVersionsServiceImpl.java
| @@ -13,6 +13,8 @@ import com.bsth.repository.LineRepository; | @@ -13,6 +13,8 @@ import com.bsth.repository.LineRepository; | ||
| 13 | import com.bsth.repository.LineVersionsRepository; | 13 | import com.bsth.repository.LineVersionsRepository; |
| 14 | import com.bsth.repository.LsSectionRouteRepository; | 14 | import com.bsth.repository.LsSectionRouteRepository; |
| 15 | import com.bsth.repository.LsStationRouteRepository; | 15 | import com.bsth.repository.LsStationRouteRepository; |
| 16 | +import com.bsth.repository.SectionRouteRepository; | ||
| 17 | +import com.bsth.repository.StationRouteRepository; | ||
| 16 | import com.bsth.service.LineVersionsService; | 18 | import com.bsth.service.LineVersionsService; |
| 17 | import com.bsth.service.SectionRouteService; | 19 | import com.bsth.service.SectionRouteService; |
| 18 | import com.bsth.service.StationRouteService; | 20 | import com.bsth.service.StationRouteService; |
| @@ -59,12 +61,12 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ | @@ -59,12 +61,12 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ | ||
| 59 | 61 | ||
| 60 | @Autowired | 62 | @Autowired |
| 61 | StationRouteService stationRouteService; | 63 | StationRouteService stationRouteService; |
| 62 | - | 64 | + |
| 63 | @Autowired | 65 | @Autowired |
| 64 | - com.bsth.repository.SectionRouteRepository sectionRouteRepository ; | ||
| 65 | - | 66 | + SectionRouteRepository sectionRouteRepository ; |
| 67 | + | ||
| 66 | @Autowired | 68 | @Autowired |
| 67 | - com.bsth.repository.StationRouteRepository stationRouteRepository ; | 69 | + StationRouteRepository stationRouteRepository ; |
| 68 | 70 | ||
| 69 | @Autowired | 71 | @Autowired |
| 70 | LsSectionRouteRepository lsSectionRouteRepository ; | 72 | LsSectionRouteRepository lsSectionRouteRepository ; |
| @@ -136,18 +138,16 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ | @@ -136,18 +138,16 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ | ||
| 136 | List<LsStationRoute> lsStationRoutes = lsStationRouteRepository.findupdated(lineId, lineCode, versions); | 138 | List<LsStationRoute> lsStationRoutes = lsStationRouteRepository.findupdated(lineId, lineCode, versions); |
| 137 | if (lsSectionRoutes.size() != 0 && lsStationRoutes.size() != 0) { | 139 | if (lsSectionRoutes.size() != 0 && lsStationRoutes.size() != 0) { |
| 138 | // 更新 | 140 | // 更新 |
| 139 | - final List<SectionRoute> sectionRoutes = JSONArray.parseArray(JSON.toJSONString(lsSectionRoutes), SectionRoute.class); | ||
| 140 | - final List<StationRoute> stationRoutes = JSONArray.parseArray(JSON.toJSONString(lsStationRoutes), StationRoute.class); | ||
| 141 | - //sectionRouteService.batchUpdate(lineId, lineCode); | ||
| 142 | - //sectionRouteRepository.batchDelete(lineId, lineCode); | ||
| 143 | - | 141 | + final List<StationRoute> stationRoutes = JSONArray.parseArray(JSON.toJSONString(lsStationRoutes), StationRoute.class); |
| 142 | + final List<SectionRoute> sectionRoutes = JSONArray.parseArray(JSON.toJSONString(lsSectionRoutes), SectionRoute.class); | ||
| 143 | + | ||
| 144 | + // 只能使用jdbc插入,应为历史表同步到当前表的时候,带有id,用jpa会报错 | ||
| 144 | jdbcTemplate.update("delete from bsth_c_stationroute where line = ? and line_code = ?", lineId, lineCode); | 145 | jdbcTemplate.update("delete from bsth_c_stationroute where line = ? and line_code = ?", lineId, lineCode); |
| 145 | - | ||
| 146 | String stationSql ="insert into bsth_c_stationroute(id,line,station,station_name,station_route_code," | 146 | String stationSql ="insert into bsth_c_stationroute(id,line,station,station_name,station_route_code," |
| 147 | + "line_code,station_code,station_mark,directions,distances,to_time,destroy,versions," | 147 | + "line_code,station_code,station_mark,directions,distances,to_time,destroy,versions," |
| 148 | - + "create_date,update_date) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; | 148 | + + "create_date,update_date,industry_code) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; |
| 149 | jdbcTemplate.batchUpdate(stationSql, new BatchPreparedStatementSetter() { | 149 | jdbcTemplate.batchUpdate(stationSql, new BatchPreparedStatementSetter() { |
| 150 | - | 150 | + |
| 151 | @Override | 151 | @Override |
| 152 | public void setValues(PreparedStatement ps, int i) throws SQLException { | 152 | public void setValues(PreparedStatement ps, int i) throws SQLException { |
| 153 | StationRoute sRoute = stationRoutes.get(i); | 153 | StationRoute sRoute = stationRoutes.get(i); |
| @@ -166,9 +166,10 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ | @@ -166,9 +166,10 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ | ||
| 166 | ps.setInt(12, sRoute.getDestroy()); | 166 | ps.setInt(12, sRoute.getDestroy()); |
| 167 | ps.setInt(13, sRoute.getVersions()); | 167 | ps.setInt(13, sRoute.getVersions()); |
| 168 | ps.setDate(14, new java.sql.Date(sRoute.getCreateDate().getTime())); | 168 | ps.setDate(14, new java.sql.Date(sRoute.getCreateDate().getTime())); |
| 169 | - ps.setDate(15, new java.sql.Date(sRoute.getUpdateDate().getTime())); | 169 | + ps.setDate(15, new java.sql.Date(sRoute.getUpdateDate().getTime())); |
| 170 | + ps.setString(16,sRoute.getIndustryCode()); | ||
| 170 | } | 171 | } |
| 171 | - | 172 | + |
| 172 | @Override | 173 | @Override |
| 173 | public int getBatchSize() { | 174 | public int getBatchSize() { |
| 174 | // TODO Auto-generated method stub | 175 | // TODO Auto-generated method stub |
| @@ -176,12 +177,12 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ | @@ -176,12 +177,12 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ | ||
| 176 | } | 177 | } |
| 177 | } ); | 178 | } ); |
| 178 | jdbcTemplate.update("delete from bsth_c_sectionroute where line = ? and line_code = ?", lineId, lineCode); | 179 | jdbcTemplate.update("delete from bsth_c_sectionroute where line = ? and line_code = ?", lineId, lineCode); |
| 179 | - | 180 | + |
| 180 | String sectionSql ="insert into bsth_c_sectionroute(id,line_code,section_code,sectionroute_code," | 181 | String sectionSql ="insert into bsth_c_sectionroute(id,line_code,section_code,sectionroute_code," |
| 181 | + "directions,line,section,create_date,update_date,versions," | 182 | + "directions,line,section,create_date,update_date,versions," |
| 182 | + "destroy) values(?,?,?,?,?,?,?,?,?,?,?)"; | 183 | + "destroy) values(?,?,?,?,?,?,?,?,?,?,?)"; |
| 183 | jdbcTemplate.batchUpdate(sectionSql, new BatchPreparedStatementSetter() { | 184 | jdbcTemplate.batchUpdate(sectionSql, new BatchPreparedStatementSetter() { |
| 184 | - | 185 | + |
| 185 | @Override | 186 | @Override |
| 186 | public void setValues(PreparedStatement ps, int i) throws SQLException { | 187 | public void setValues(PreparedStatement ps, int i) throws SQLException { |
| 187 | SectionRoute sRoute = sectionRoutes.get(i); | 188 | SectionRoute sRoute = sectionRoutes.get(i); |
| @@ -197,7 +198,7 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ | @@ -197,7 +198,7 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ | ||
| 197 | ps.setInt(10, sRoute.getVersions()); | 198 | ps.setInt(10, sRoute.getVersions()); |
| 198 | ps.setInt(11, sRoute.getDestroy()); | 199 | ps.setInt(11, sRoute.getDestroy()); |
| 199 | } | 200 | } |
| 200 | - | 201 | + |
| 201 | @Override | 202 | @Override |
| 202 | public int getBatchSize() { | 203 | public int getBatchSize() { |
| 203 | // TODO Auto-generated method stub | 204 | // TODO Auto-generated method stub |