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 | 4 | |
| 5 | 5 | import javax.persistence.Column; |
| 6 | 6 | import javax.persistence.Entity; |
| 7 | +import javax.persistence.GeneratedValue; | |
| 8 | +import javax.persistence.GenerationType; | |
| 7 | 9 | import javax.persistence.Id; |
| 8 | 10 | import javax.persistence.Table; |
| 9 | 11 | |
| ... | ... | @@ -31,7 +33,7 @@ import java.util.Date; |
| 31 | 33 | public class Station { |
| 32 | 34 | |
| 33 | 35 | @Id |
| 34 | - /*@GeneratedValue(strategy = GenerationType.IDENTITY)*/ | |
| 36 | +// @GeneratedValue(strategy = GenerationType.IDENTITY) | |
| 35 | 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 | 47 | , nativeQuery=true) |
| 48 | 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 | 53 | * @Description :TODO(站点保存) |
| 52 | 54 | * | ... | ... |
src/main/java/com/bsth/service/impl/LineVersionsServiceImpl.java
| 1 | 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 | 18 | import com.alibaba.fastjson.JSON; |
| 4 | 19 | import com.alibaba.fastjson.JSONArray; |
| 5 | 20 | import com.bsth.common.ResponseCode; |
| ... | ... | @@ -8,28 +23,17 @@ import com.bsth.entity.LineVersions; |
| 8 | 23 | import com.bsth.entity.LsSectionRoute; |
| 9 | 24 | import com.bsth.entity.LsStationRoute; |
| 10 | 25 | import com.bsth.entity.SectionRoute; |
| 26 | +import com.bsth.entity.Station; | |
| 11 | 27 | import com.bsth.entity.StationRoute; |
| 12 | 28 | import com.bsth.repository.LineRepository; |
| 13 | 29 | import com.bsth.repository.LineVersionsRepository; |
| 14 | 30 | import com.bsth.repository.LsSectionRouteRepository; |
| 15 | 31 | import com.bsth.repository.LsStationRouteRepository; |
| 32 | +import com.bsth.repository.StationRepository; | |
| 16 | 33 | import com.bsth.service.LineVersionsService; |
| 17 | 34 | import com.bsth.service.SectionRouteService; |
| 18 | 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 | 63 | |
| 60 | 64 | @Autowired |
| 61 | 65 | StationRouteService stationRouteService; |
| 66 | + | |
| 67 | + @Autowired | |
| 68 | + StationRepository stationRepository; | |
| 69 | + | |
| 62 | 70 | |
| 63 | 71 | @Autowired |
| 64 | 72 | com.bsth.repository.SectionRouteRepository sectionRouteRepository ; |
| ... | ... | @@ -231,7 +239,11 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ |
| 231 | 239 | /** |
| 232 | 240 | * 线路版本添加 |
| 233 | 241 | */ |
| 242 | + /** | |
| 243 | + * | |
| 244 | + */ | |
| 234 | 245 | @Override |
| 246 | + @Transactional | |
| 235 | 247 | public Map<String, Object> add(Map<String, Object> map) { |
| 236 | 248 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| 237 | 249 | Map<String, Object> resultMap = new HashMap<>(); |
| ... | ... | @@ -296,16 +308,49 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ |
| 296 | 308 | List<LsStationRoute> stationList = lsStationRouteRepository.findupdated(Integer.valueOf(map.get("lineId").toString()),map.get("lineCode").toString(),hisVersion); |
| 297 | 309 | |
| 298 | 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 | 344 | LsStationRoute oldData = stationList.get(i); |
| 300 | 345 | |
| 301 | 346 | LsStationRoute newData = new LsStationRoute(); |
| 302 | - | |
| 347 | + | |
| 303 | 348 | newData.setLine(oldData.getLine()); |
| 304 | - newData.setStation(oldData.getStation()); | |
| 349 | + newData.setStation(oldStation); | |
| 305 | 350 | newData.setStationName(oldData.getStationName()); |
| 306 | 351 | newData.setStationRouteCode(oldData.getStationRouteCode()); |
| 307 | 352 | newData.setLineCode(oldData.getLineCode()); |
| 308 | - newData.setStationCode(oldData.getStationCode()); | |
| 353 | + newData.setStationCode(String.valueOf(stationCode)); | |
| 309 | 354 | newData.setStationMark(oldData.getStationMark()); |
| 310 | 355 | newData.setOutStationNmber(oldData.getOutStationNmber()); |
| 311 | 356 | newData.setDirections(oldData.getDirections()); |
| ... | ... | @@ -322,6 +367,34 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ |
| 322 | 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 | 399 | resultMap.put("status", ResponseCode.SUCCESS); |
| 327 | 400 | } catch (ParseException e) { | ... | ... |