Commit f7e6c71a96a2cf8c829547ff01fd7f324f30a5da
1 parent
3ced2fc6
bug修改:时刻表上传运管处,没有站点名称和站点序号,从历史路由中取到站点名称和站点序号
Showing
2 changed files
with
83 additions
and
5 deletions
src/main/java/com/bsth/repository/LsStationRouteRepository.java
| 1 | package com.bsth.repository; | 1 | package com.bsth.repository; |
| 2 | 2 | ||
| 3 | import java.util.List; | 3 | import java.util.List; |
| 4 | +import java.util.Map; | ||
| 4 | 5 | ||
| 5 | import org.springframework.data.jpa.repository.EntityGraph; | 6 | import org.springframework.data.jpa.repository.EntityGraph; |
| 6 | import org.springframework.data.jpa.repository.Modifying; | 7 | import org.springframework.data.jpa.repository.Modifying; |
| @@ -52,4 +53,21 @@ public interface LsStationRouteRepository extends BaseRepository<LsStationRoute, | @@ -52,4 +53,21 @@ public interface LsStationRouteRepository extends BaseRepository<LsStationRoute, | ||
| 52 | @Modifying | 53 | @Modifying |
| 53 | @Query(value="UPDATE bsth_c_ls_stationroute set destroy = 1 where line = ?1 and directions = ?2 and versions = ?3", nativeQuery=true) | 54 | @Query(value="UPDATE bsth_c_ls_stationroute set destroy = 1 where line = ?1 and directions = ?2 and versions = ?3", nativeQuery=true) |
| 54 | public void batchDestroy(Integer sectionRouteLine, Integer directions, Integer versions); | 55 | public void batchDestroy(Integer sectionRouteLine, Integer directions, Integer versions); |
| 56 | + | ||
| 57 | + /** | ||
| 58 | + * 按线路编码查询各站点的顺序号 | ||
| 59 | + * @param lineCode 线路编码 | ||
| 60 | + * @param lineVersion 版本号 | ||
| 61 | + * @return | ||
| 62 | + */ | ||
| 63 | + @Query("SELECT new map(" + | ||
| 64 | + "lineCode as lineCode,directions as directions,stationName as stationName,stationCode as stationCode," + | ||
| 65 | + "line.linePlayType as linePlayType,s.stationMark as stationMark) " + | ||
| 66 | + "FROM " + | ||
| 67 | + "LsStationRoute s " + | ||
| 68 | + "WHERE " + | ||
| 69 | + "s.destroy = 0 AND s.lineCode = ?1 AND s.versions = ?2 " + | ||
| 70 | + "ORDER BY " + | ||
| 71 | + "lineCode,directions,stationRouteCode") | ||
| 72 | + List<Map<String, String>> findLineWithLineCode4Ygc(String lineCode,Integer lineVersion); | ||
| 55 | } | 73 | } |
src/main/java/com/bsth/service/impl/TrafficManageServiceImpl.java
| @@ -77,6 +77,10 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -77,6 +77,10 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 77 | @Autowired | 77 | @Autowired |
| 78 | private StationRouteRepository stationRouteRepository; | 78 | private StationRouteRepository stationRouteRepository; |
| 79 | 79 | ||
| 80 | + // 历史站点路由repository | ||
| 81 | + @Autowired | ||
| 82 | + private LsStationRouteRepository lsStationRouteRepository; | ||
| 83 | + | ||
| 80 | @Autowired | 84 | @Autowired |
| 81 | private SectionRepository sectionRepository; | 85 | private SectionRepository sectionRepository; |
| 82 | 86 | ||
| @@ -944,6 +948,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -944,6 +948,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 944 | String result = "failure"; | 948 | String result = "failure"; |
| 945 | StringBuffer sBuffer = new StringBuffer(); | 949 | StringBuffer sBuffer = new StringBuffer(); |
| 946 | DecimalFormat df = new DecimalFormat("######0.000"); | 950 | DecimalFormat df = new DecimalFormat("######0.000"); |
| 951 | + Map<String,String> lsStationCode2NameMap; | ||
| 952 | + Map<String, Integer> lsStationName2YgcNumber; | ||
| 947 | try { | 953 | try { |
| 948 | String[] idArray = ids.split(","); | 954 | String[] idArray = ids.split(","); |
| 949 | StringBuffer sBufferA ,sBufferB ,sBufferC ; | 955 | StringBuffer sBufferA ,sBufferB ,sBufferC ; |
| @@ -960,10 +966,17 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -960,10 +966,17 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 960 | HashMap<String,String> paramMap; | 966 | HashMap<String,String> paramMap; |
| 961 | HashMap<String,String> otherMap = new HashMap<>(); | 967 | HashMap<String,String> otherMap = new HashMap<>(); |
| 962 | for (int i = 0; i < idArray.length; i++) { | 968 | for (int i = 0; i < idArray.length; i++) { |
| 963 | - ttInfo = ttInfoRepository.findOne(Long.valueOf(idArray[i])); | 969 | + long ttinfoId = Long.valueOf(idArray[i]); |
| 970 | + ttInfo = ttInfoRepository.findOne(ttinfoId); | ||
| 964 | if(ttInfo == null) | 971 | if(ttInfo == null) |
| 965 | continue; | 972 | continue; |
| 966 | ttinfoList.add(ttInfo); // 保存时刻表 | 973 | ttinfoList.add(ttInfo); // 保存时刻表 |
| 974 | + // 得到时刻表版本号 | ||
| 975 | + int lineVersion = ttInfo.getLineVersion(); | ||
| 976 | + // 查询历史站点路由 | ||
| 977 | + lsStationCode2NameMap = getLsStationCode(ttInfo.getXl().getLineCode(),lineVersion); | ||
| 978 | + // 查询历史站点路由 | ||
| 979 | + lsStationName2YgcNumber = getLsStationRoute(ttInfo.getXl().getLineCode(),lineVersion); | ||
| 967 | zlc = 0.0f; | 980 | zlc = 0.0f; |
| 968 | yylc = 0.0f; | 981 | yylc = 0.0f; |
| 969 | // 获得时刻表 | 982 | // 获得时刻表 |
| @@ -1007,19 +1020,19 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -1007,19 +1020,19 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 1007 | sBufferC.append("<BC>"); | 1020 | sBufferC.append("<BC>"); |
| 1008 | sBufferC.append("<LPBH>").append(ttInfoDetail.getLp().getLpNo()).append("</LPBH>"); | 1021 | sBufferC.append("<LPBH>").append(ttInfoDetail.getLp().getLpNo()).append("</LPBH>"); |
| 1009 | sBufferC.append("<SXX>").append(sxx).append("</SXX>"); | 1022 | sBufferC.append("<SXX>").append(sxx).append("</SXX>"); |
| 1010 | - sBufferC.append("<FCZDMC>").append(BasicData.stationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir() | 1023 | + sBufferC.append("<FCZDMC>").append(lsStationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir() |
| 1011 | +"_"+ttInfoDetail.getQdzCode())).append("</FCZDMC>"); | 1024 | +"_"+ttInfoDetail.getQdzCode())).append("</FCZDMC>"); |
| 1012 | // 起点站的参数 | 1025 | // 起点站的参数 |
| 1013 | otherMap.put("stationMark","B"); | 1026 | otherMap.put("stationMark","B"); |
| 1014 | paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); | 1027 | paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); |
| 1015 | - sBufferC.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</ZDXH>"); | 1028 | + sBufferC.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,lsStationName2YgcNumber)).append("</ZDXH>"); |
| 1016 | sBufferC.append("<JHFCSJ>").append(changeTimeFormat(ttInfoDetail)).append("</JHFCSJ>"); | 1029 | sBufferC.append("<JHFCSJ>").append(changeTimeFormat(ttInfoDetail)).append("</JHFCSJ>"); |
| 1017 | - sBufferC.append("<DDZDMC>").append(BasicData.stationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir() | 1030 | + sBufferC.append("<DDZDMC>").append(lsStationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir() |
| 1018 | +"_"+ttInfoDetail.getZdzCode())).append("</DDZDMC>"); | 1031 | +"_"+ttInfoDetail.getZdzCode())).append("</DDZDMC>"); |
| 1019 | // 起点站的参数 | 1032 | // 起点站的参数 |
| 1020 | otherMap.put("stationMark","E"); | 1033 | otherMap.put("stationMark","E"); |
| 1021 | paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); | 1034 | paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); |
| 1022 | - sBufferC.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</DDXH>"); | 1035 | + sBufferC.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,lsStationName2YgcNumber)).append("</DDXH>"); |
| 1023 | sBufferC.append("<JHDDSJ>").append(calcDdsj(ttInfoDetail.getFcsj(),ttInfoDetail.getBcsj())).append("</JHDDSJ>"); | 1036 | sBufferC.append("<JHDDSJ>").append(calcDdsj(ttInfoDetail.getFcsj(),ttInfoDetail.getBcsj())).append("</JHDDSJ>"); |
| 1024 | sBufferC.append("</BC>"); | 1037 | sBufferC.append("</BC>"); |
| 1025 | // 0:上行;1:下行 | 1038 | // 0:上行;1:下行 |
| @@ -1520,4 +1533,51 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -1520,4 +1533,51 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 1520 | map.put("stationMark",stationMark); // 站点类型 | 1533 | map.put("stationMark",stationMark); // 站点类型 |
| 1521 | return map; | 1534 | return map; |
| 1522 | } | 1535 | } |
| 1536 | + | ||
| 1537 | + /** | ||
| 1538 | + * 取得历史站点编码和站点名称的对应关系 | ||
| 1539 | + * @return | ||
| 1540 | + */ | ||
| 1541 | + private Map<String, String> getLsStationCode(String lineCode,int lineVersion){ | ||
| 1542 | + Map<String,Object> map = new HashMap<>(); | ||
| 1543 | + map.put("lineCode_eq", lineCode); | ||
| 1544 | + map.put("versions_eq",lineVersion); | ||
| 1545 | + LsStationRoute lsroute; | ||
| 1546 | + Iterator<LsStationRoute> iterator = lsStationRouteRepository.findAll(new CustomerSpecs<LsStationRoute>(map)).iterator(); | ||
| 1547 | + Map<String, String> stationCode2Name = new HashMap<>(); | ||
| 1548 | + while (iterator.hasNext()) { | ||
| 1549 | + lsroute = iterator.next(); | ||
| 1550 | + stationCode2Name.put(lsroute.getLineCode() + "_" + lsroute.getDirections() + "_" + lsroute.getStationCode(), lsroute.getStationName()); | ||
| 1551 | + } | ||
| 1552 | + return stationCode2Name; | ||
| 1553 | + } | ||
| 1554 | + | ||
| 1555 | + private Map<String, Integer> getLsStationRoute(String xlbm,int lineVersion){ | ||
| 1556 | + Map<String, Integer> tempStationName2YgcNumber = new HashMap<String, Integer>(); | ||
| 1557 | + /** | ||
| 1558 | + * 加载运管处的站点及序号 | ||
| 1559 | + * 上行从1开始,下行顺序续编 | ||
| 1560 | + */ | ||
| 1561 | + List<Map<String, String>> ygcLines = lsStationRouteRepository.findLineWithLineCode4Ygc(xlbm,lineVersion); | ||
| 1562 | + if(ygcLines != null && ygcLines.size() > 0){ | ||
| 1563 | + int size = ygcLines.size(); | ||
| 1564 | + Map<String, String> tempMap ; | ||
| 1565 | + int num = 1; | ||
| 1566 | + String key; | ||
| 1567 | + String lineCode = ""; | ||
| 1568 | + for (int i = 0; i < size; i ++){ | ||
| 1569 | + tempMap = ygcLines.get(i); | ||
| 1570 | + if(lineCode.equals("")){ | ||
| 1571 | + lineCode = tempMap.get("lineCode"); | ||
| 1572 | + }else if(!lineCode.equals(tempMap.get("lineCode"))){ | ||
| 1573 | + num = 1; | ||
| 1574 | + lineCode = tempMap.get("lineCode"); | ||
| 1575 | + } | ||
| 1576 | + key = tempMap.get("lineCode") + "_"+String.valueOf(tempMap.get("directions")) | ||
| 1577 | + + "_"+tempMap.get("stationCode")+ "_"+tempMap.get("stationMark"); | ||
| 1578 | + tempStationName2YgcNumber.put(key,num++); | ||
| 1579 | + } | ||
| 1580 | + } | ||
| 1581 | + return tempStationName2YgcNumber; | ||
| 1582 | + } | ||
| 1523 | } | 1583 | } |