Commit 23c16f72207b0550963d7201f004f07fb169ab6e
1 parent
be0beb26
"copy station!"
Showing
3 changed files
with
95 additions
and
18 deletions
src/main/java/com/bsth/entity/Station.java
| @@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | @@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
| 4 | 4 | ||
| 5 | import javax.persistence.Column; | 5 | import javax.persistence.Column; |
| 6 | import javax.persistence.Entity; | 6 | import javax.persistence.Entity; |
| 7 | +import javax.persistence.GeneratedValue; | ||
| 8 | +import javax.persistence.GenerationType; | ||
| 7 | import javax.persistence.Id; | 9 | import javax.persistence.Id; |
| 8 | import javax.persistence.Table; | 10 | import javax.persistence.Table; |
| 9 | 11 | ||
| @@ -31,7 +33,7 @@ import java.util.Date; | @@ -31,7 +33,7 @@ import java.util.Date; | ||
| 31 | public class Station { | 33 | public class Station { |
| 32 | 34 | ||
| 33 | @Id | 35 | @Id |
| 34 | - /*@GeneratedValue(strategy = GenerationType.IDENTITY)*/ | 36 | +// @GeneratedValue(strategy = GenerationType.IDENTITY) |
| 35 | private Integer id; | 37 | private Integer id; |
| 36 | 38 | ||
| 37 | // 站点编码 | 39 | // 站点编码 |
src/main/java/com/bsth/repository/StationRepository.java
| @@ -47,6 +47,8 @@ public interface StationRepository extends BaseRepository<Station, Integer> { | @@ -47,6 +47,8 @@ public interface StationRepository extends BaseRepository<Station, Integer> { | ||
| 47 | , nativeQuery=true) | 47 | , nativeQuery=true) |
| 48 | List<Object[]> findStationName(Integer dir , String stationName); | 48 | List<Object[]> findStationName(Integer dir , String stationName); |
| 49 | 49 | ||
| 50 | + @Query("select s from Station s where s.id = ?1") | ||
| 51 | + Station findByIdReturnMojo(Integer id); | ||
| 50 | /** | 52 | /** |
| 51 | * @Description :TODO(站点保存) | 53 | * @Description :TODO(站点保存) |
| 52 | * | 54 | * |
src/main/java/com/bsth/service/impl/LineVersionsServiceImpl.java
| 1 | package com.bsth.service.impl; | 1 | package com.bsth.service.impl; |
| 2 | 2 | ||
| 3 | +import java.sql.PreparedStatement; | ||
| 4 | +import java.sql.SQLException; | ||
| 5 | +import java.text.ParseException; | ||
| 6 | +import java.text.SimpleDateFormat; | ||
| 7 | +import java.util.Date; | ||
| 8 | +import java.util.HashMap; | ||
| 9 | +import java.util.List; | ||
| 10 | +import java.util.Map; | ||
| 11 | + | ||
| 12 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 13 | +import org.springframework.jdbc.core.BatchPreparedStatementSetter; | ||
| 14 | +import org.springframework.jdbc.core.JdbcTemplate; | ||
| 15 | +import org.springframework.stereotype.Service; | ||
| 16 | +import org.springframework.transaction.annotation.Transactional; | ||
| 17 | + | ||
| 3 | import com.alibaba.fastjson.JSON; | 18 | import com.alibaba.fastjson.JSON; |
| 4 | import com.alibaba.fastjson.JSONArray; | 19 | import com.alibaba.fastjson.JSONArray; |
| 5 | import com.bsth.common.ResponseCode; | 20 | import com.bsth.common.ResponseCode; |
| @@ -8,28 +23,17 @@ import com.bsth.entity.LineVersions; | @@ -8,28 +23,17 @@ import com.bsth.entity.LineVersions; | ||
| 8 | import com.bsth.entity.LsSectionRoute; | 23 | import com.bsth.entity.LsSectionRoute; |
| 9 | import com.bsth.entity.LsStationRoute; | 24 | import com.bsth.entity.LsStationRoute; |
| 10 | import com.bsth.entity.SectionRoute; | 25 | import com.bsth.entity.SectionRoute; |
| 26 | +import com.bsth.entity.Station; | ||
| 11 | import com.bsth.entity.StationRoute; | 27 | import com.bsth.entity.StationRoute; |
| 12 | import com.bsth.repository.LineRepository; | 28 | import com.bsth.repository.LineRepository; |
| 13 | import com.bsth.repository.LineVersionsRepository; | 29 | import com.bsth.repository.LineVersionsRepository; |
| 14 | import com.bsth.repository.LsSectionRouteRepository; | 30 | import com.bsth.repository.LsSectionRouteRepository; |
| 15 | import com.bsth.repository.LsStationRouteRepository; | 31 | import com.bsth.repository.LsStationRouteRepository; |
| 32 | +import com.bsth.repository.StationRepository; | ||
| 16 | import com.bsth.service.LineVersionsService; | 33 | import com.bsth.service.LineVersionsService; |
| 17 | import com.bsth.service.SectionRouteService; | 34 | import com.bsth.service.SectionRouteService; |
| 18 | import com.bsth.service.StationRouteService; | 35 | import com.bsth.service.StationRouteService; |
| 19 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 20 | -import org.springframework.jdbc.core.BatchPreparedStatementSetter; | ||
| 21 | -import org.springframework.jdbc.core.JdbcTemplate; | ||
| 22 | -import org.springframework.stereotype.Service; | ||
| 23 | -import org.springframework.transaction.annotation.Transactional; | ||
| 24 | - | ||
| 25 | -import java.sql.PreparedStatement; | ||
| 26 | -import java.sql.SQLException; | ||
| 27 | -import java.text.ParseException; | ||
| 28 | -import java.text.SimpleDateFormat; | ||
| 29 | -import java.util.Date; | ||
| 30 | -import java.util.HashMap; | ||
| 31 | -import java.util.List; | ||
| 32 | -import java.util.Map; | 36 | +import com.bsth.util.GetUIDAndCode; |
| 33 | 37 | ||
| 34 | /** | 38 | /** |
| 35 | * | 39 | * |
| @@ -59,6 +63,10 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ | @@ -59,6 +63,10 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ | ||
| 59 | 63 | ||
| 60 | @Autowired | 64 | @Autowired |
| 61 | StationRouteService stationRouteService; | 65 | StationRouteService stationRouteService; |
| 66 | + | ||
| 67 | + @Autowired | ||
| 68 | + StationRepository stationRepository; | ||
| 69 | + | ||
| 62 | 70 | ||
| 63 | @Autowired | 71 | @Autowired |
| 64 | com.bsth.repository.SectionRouteRepository sectionRouteRepository ; | 72 | com.bsth.repository.SectionRouteRepository sectionRouteRepository ; |
| @@ -231,7 +239,11 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ | @@ -231,7 +239,11 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ | ||
| 231 | /** | 239 | /** |
| 232 | * 线路版本添加 | 240 | * 线路版本添加 |
| 233 | */ | 241 | */ |
| 242 | + /** | ||
| 243 | + * | ||
| 244 | + */ | ||
| 234 | @Override | 245 | @Override |
| 246 | + @Transactional | ||
| 235 | public Map<String, Object> add(Map<String, Object> map) { | 247 | public Map<String, Object> add(Map<String, Object> map) { |
| 236 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 248 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| 237 | Map<String, Object> resultMap = new HashMap<>(); | 249 | Map<String, Object> resultMap = new HashMap<>(); |
| @@ -296,16 +308,49 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ | @@ -296,16 +308,49 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ | ||
| 296 | List<LsStationRoute> stationList = lsStationRouteRepository.findupdated(Integer.valueOf(map.get("lineId").toString()),map.get("lineCode").toString(),hisVersion); | 308 | List<LsStationRoute> stationList = lsStationRouteRepository.findupdated(Integer.valueOf(map.get("lineId").toString()),map.get("lineCode").toString(),hisVersion); |
| 297 | 309 | ||
| 298 | for(int i =0;i<stationList.size();i++) { | 310 | for(int i =0;i<stationList.size();i++) { |
| 311 | + | ||
| 312 | + | ||
| 313 | + Station newStation = stationRepository.findByIdReturnMojo(stationList.get(i).getStation().getId()); | ||
| 314 | + Station oldStation = new Station(); | ||
| 315 | + long stationCode = GetUIDAndCode.getStationId(); | ||
| 316 | + oldStation.setStationCod(String.valueOf(stationCode)); | ||
| 317 | + oldStation.setId((int)stationCode); | ||
| 318 | +// oldStation.setStationCod(newStation.getStationCod()); | ||
| 319 | + | ||
| 320 | + oldStation.setAddr(newStation.getAddr()); | ||
| 321 | + oldStation.setbJwpoints(newStation.getbJwpoints()); | ||
| 322 | + oldStation.setbPolygonGrid(newStation.getbPolygonGrid()); | ||
| 323 | + oldStation.setCreateDate(new Date()); | ||
| 324 | + oldStation.setDbType(newStation.getDbType()); | ||
| 325 | + oldStation.setDescriptions(newStation.getDescriptions()); | ||
| 326 | + oldStation.setDestroy(newStation.getDestroy()); | ||
| 327 | + oldStation.setgLaty(newStation.getgLaty()); | ||
| 328 | + oldStation.setgLonx(newStation.getgLonx()); | ||
| 329 | + oldStation.setbPolygonGrid(newStation.getbPolygonGrid()); | ||
| 330 | + oldStation.setIsHarbourStation(newStation.getIsHarbourStation()); | ||
| 331 | + oldStation.setIsHaveLed(newStation.getIsHaveLed()); | ||
| 332 | + oldStation.setIsHaveShelter(newStation.getIsHaveShelter()); | ||
| 333 | + oldStation.setRadius(newStation.getRadius()); | ||
| 334 | + oldStation.setRoadCoding(newStation.getRoadCoding()); | ||
| 335 | + oldStation.setShapesType(newStation.getShapesType()); | ||
| 336 | + oldStation.setStationName(newStation.getStationName()); | ||
| 337 | + oldStation.setX(newStation.getX()); | ||
| 338 | + oldStation.setY(newStation.getY()); | ||
| 339 | + | ||
| 340 | + | ||
| 341 | + stationRepository.save(oldStation); | ||
| 342 | + | ||
| 343 | + | ||
| 299 | LsStationRoute oldData = stationList.get(i); | 344 | LsStationRoute oldData = stationList.get(i); |
| 300 | 345 | ||
| 301 | LsStationRoute newData = new LsStationRoute(); | 346 | LsStationRoute newData = new LsStationRoute(); |
| 302 | - | 347 | + |
| 303 | newData.setLine(oldData.getLine()); | 348 | newData.setLine(oldData.getLine()); |
| 304 | - newData.setStation(oldData.getStation()); | 349 | + newData.setStation(oldStation); |
| 305 | newData.setStationName(oldData.getStationName()); | 350 | newData.setStationName(oldData.getStationName()); |
| 306 | newData.setStationRouteCode(oldData.getStationRouteCode()); | 351 | newData.setStationRouteCode(oldData.getStationRouteCode()); |
| 307 | newData.setLineCode(oldData.getLineCode()); | 352 | newData.setLineCode(oldData.getLineCode()); |
| 308 | - newData.setStationCode(oldData.getStationCode()); | 353 | + newData.setStationCode(String.valueOf(stationCode)); |
| 309 | newData.setStationMark(oldData.getStationMark()); | 354 | newData.setStationMark(oldData.getStationMark()); |
| 310 | newData.setOutStationNmber(oldData.getOutStationNmber()); | 355 | newData.setOutStationNmber(oldData.getOutStationNmber()); |
| 311 | newData.setDirections(oldData.getDirections()); | 356 | newData.setDirections(oldData.getDirections()); |
| @@ -322,6 +367,34 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ | @@ -322,6 +367,34 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ | ||
| 322 | lsStationRouteRepository.save(newData); | 367 | lsStationRouteRepository.save(newData); |
| 323 | } | 368 | } |
| 324 | 369 | ||
| 370 | + | ||
| 371 | +// for(int i =0;i<stationList.size();i++) { | ||
| 372 | +// LsStationRoute oldData = stationList.get(i); | ||
| 373 | +// | ||
| 374 | +// LsStationRoute newData = new LsStationRoute(); | ||
| 375 | +// | ||
| 376 | +// newData.setLine(oldData.getLine()); | ||
| 377 | +// newData.setStation(oldData.getStation()); | ||
| 378 | +// newData.setStationName(oldData.getStationName()); | ||
| 379 | +// newData.setStationRouteCode(oldData.getStationRouteCode()); | ||
| 380 | +// newData.setLineCode(oldData.getLineCode()); | ||
| 381 | +// newData.setStationCode(oldData.getStationCode()); | ||
| 382 | +// newData.setStationMark(oldData.getStationMark()); | ||
| 383 | +// newData.setOutStationNmber(oldData.getOutStationNmber()); | ||
| 384 | +// newData.setDirections(oldData.getDirections()); | ||
| 385 | +// newData.setDistances(oldData.getDistances()); | ||
| 386 | +// newData.setToTime(oldData.getToTime()); | ||
| 387 | +// newData.setFirstTime(oldData.getFirstTime()); | ||
| 388 | +// newData.setEndTime(oldData.getEndTime()); | ||
| 389 | +// newData.setEndTime(oldData.getEndTime()); | ||
| 390 | +// newData.setDescriptions(oldData.getDescriptions()); | ||
| 391 | +// newData.setIndustryCode(oldData.getIndustryCode()); | ||
| 392 | +// newData.setDestroy(0); | ||
| 393 | +// newData.setVersions(versions); | ||
| 394 | +// | ||
| 395 | +// lsStationRouteRepository.save(newData); | ||
| 396 | +// } | ||
| 397 | + | ||
| 325 | } | 398 | } |
| 326 | resultMap.put("status", ResponseCode.SUCCESS); | 399 | resultMap.put("status", ResponseCode.SUCCESS); |
| 327 | } catch (ParseException e) { | 400 | } catch (ParseException e) { |