Commit cb883e25a39e2dc554b88e11a9d7c6512bcf5c03
1 parent
fa0b3cfb
BUG修复(上传线路站级,出现站点序号为0的情况)
Showing
3 changed files
with
58 additions
and
12 deletions
src/main/java/com/bsth/repository/StationRouteRepository.java
| ... | ... | @@ -274,6 +274,17 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int |
| 274 | 274 | "ORDER BY " + |
| 275 | 275 | "lineCode,directions,stationRouteCode") |
| 276 | 276 | List<Map<String, String>> findAllLineWithYgc(); |
| 277 | + | |
| 278 | + @Query("SELECT new map(" + | |
| 279 | + "lineCode as lineCode,directions as directions,stationName as stationName,stationCode as stationCode," + | |
| 280 | + "line.linePlayType as linePlayType,s.stationMark as stationMark) " + | |
| 281 | + "FROM " + | |
| 282 | + "StationRoute s " + | |
| 283 | + "WHERE " + | |
| 284 | + "s.destroy = 0 and s.lineCode = ?1 " + | |
| 285 | + "ORDER BY " + | |
| 286 | + "lineCode,directions,stationRouteCode") | |
| 287 | + List<Map<String, String>> findLineWithYgcByLine(String lineCode); | |
| 277 | 288 | |
| 278 | 289 | @Modifying |
| 279 | 290 | @Query(value="update bsth_c_stationroute set directions = case directions when 1 then 0 when 0 then 1 end where line_code = ?1 ", nativeQuery=true) | ... | ... |
src/main/java/com/bsth/service/impl/TrafficManageServiceImpl.java
| ... | ... | @@ -200,13 +200,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 200 | 200 | |
| 201 | 201 | // 先查上行 |
| 202 | 202 | upStationsList = stationRouteRepository.findByLine(line.getLineCode(), 0); |
| 203 | + Map<String, Integer> stationNumMap = getStationName2YgcNumberMap(line.getLineCode()); | |
| 203 | 204 | int startId = 1; |
| 204 | - startId = packagStationXml(upStationsList, sBuffer, startId); | |
| 205 | + startId = packagStationXml(upStationsList, sBuffer, startId,stationNumMap); | |
| 205 | 206 | // 环线不查下行 |
| 206 | 207 | if(line.getLinePlayType() != 1){ |
| 207 | 208 | // 再查下行 |
| 208 | 209 | downStationsList = stationRouteRepository.findByLine(line.getLineCode(), 1); |
| 209 | - packagStationXml(downStationsList, sBuffer, startId); | |
| 210 | + packagStationXml(downStationsList, sBuffer, startId,stationNumMap); | |
| 210 | 211 | } |
| 211 | 212 | sBuffer.append("</StationList>"); |
| 212 | 213 | |
| ... | ... | @@ -223,6 +224,10 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 223 | 224 | sBuffer.append("</LinePointList>"); |
| 224 | 225 | sBuffer.append("</XL>"); |
| 225 | 226 | sBuffer.append("</XLs>"); |
| 227 | + // 临时添加,后面删除 | |
| 228 | + if(sBuffer.indexOf("<ZDXH>0</ZDXH>") != -1){ | |
| 229 | + return "0"; | |
| 230 | + } | |
| 226 | 231 | // 调用上传方法 |
| 227 | 232 | if(getWebServiceSoapUp().setXL(userNameUp,passwordUp,sBuffer.toString()).isSuccess()){ |
| 228 | 233 | result = "success"; |
| ... | ... | @@ -240,6 +245,28 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 240 | 245 | } |
| 241 | 246 | |
| 242 | 247 | /** |
| 248 | + * 加载运管处的站点及序号 | |
| 249 | + * 上行从1开始,下行顺序续编 | |
| 250 | + */ | |
| 251 | + private Map<String, Integer> getStationName2YgcNumberMap (String lineCode){ | |
| 252 | + Map<String, Integer> resultMap = new HashMap<>(); | |
| 253 | + List<Map<String, String>> ygcLines = stationRouteRepository.findLineWithYgcByLine(lineCode); | |
| 254 | + if(ygcLines != null && ygcLines.size() > 0){ | |
| 255 | + int size = ygcLines.size(); | |
| 256 | + Map<String, String> tempMap ; | |
| 257 | + int num = 1; | |
| 258 | + String key; | |
| 259 | + for (int i = 0; i < size; i ++){ | |
| 260 | + tempMap = ygcLines.get(i); | |
| 261 | + key = tempMap.get("lineCode") + "_"+String.valueOf(tempMap.get("directions")) | |
| 262 | + + "_"+tempMap.get("stationCode")+ "_"+tempMap.get("stationMark"); | |
| 263 | + resultMap.put(key,num++); | |
| 264 | + } | |
| 265 | + } | |
| 266 | + return resultMap; | |
| 267 | + } | |
| 268 | + | |
| 269 | + /** | |
| 243 | 270 | * 上传线路信息(按in_use上传) |
| 244 | 271 | */ |
| 245 | 272 | @Override |
| ... | ... | @@ -431,7 +458,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 431 | 458 | // 起点站的参数 |
| 432 | 459 | otherMap.put("stationMark","B"); |
| 433 | 460 | paramMap = packageYgcStationNumParam(scheduleRealInfo,otherMap); |
| 434 | - sf.append("<FCZDXH>" + getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap) + "</FCZDXH>"); | |
| 461 | + sf.append("<FCZDXH>" + getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null) + "</FCZDXH>"); | |
| 435 | 462 | sf.append("<FCZDBM>"+scheduleRealInfo.getQdzCode()+"</FCZDBM>"); |
| 436 | 463 | sf.append("<JHFCSJ>"+scheduleRealInfo.getFcsj()+"</JHFCSJ>"); |
| 437 | 464 | sf.append("<DFSJ>"+scheduleRealInfo.getDfsj()+"</DFSJ>"); |
| ... | ... | @@ -441,7 +468,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 441 | 468 | // 终点站的参数 |
| 442 | 469 | otherMap.put("stationMark","E"); |
| 443 | 470 | paramMap = packageYgcStationNumParam(scheduleRealInfo,otherMap); |
| 444 | - sf.append("<DDZDXH>"+ getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap) +"</DDZDXH>"); | |
| 471 | + sf.append("<DDZDXH>"+ getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null) +"</DDZDXH>"); | |
| 445 | 472 | sf.append("<DDZDBM>"+scheduleRealInfo.getZdzCode()+"</DDZDBM>"); |
| 446 | 473 | sf.append("<JHDDSJ>"+scheduleRealInfo.getZdsj()+"</JHDDSJ>"); |
| 447 | 474 | sf.append("<SJDDSJ>"+scheduleRealInfo.getZdsjActual()+"</SJDDSJ>"); |
| ... | ... | @@ -768,13 +795,13 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 768 | 795 | // 起点站的参数 |
| 769 | 796 | otherMap.put("stationMark","B"); |
| 770 | 797 | paramMap = packageYgcStationNumParam(schedulePlanInfo,otherMap); |
| 771 | - sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap)).append("</ZDXH>"); | |
| 798 | + sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</ZDXH>"); | |
| 772 | 799 | sBuffer.append("<JHFCSJ>").append(schedulePlanInfo.getFcsj()).append("</JHFCSJ>"); |
| 773 | 800 | sBuffer.append("<DDZDMC>").append(schedulePlanInfo.getZdzName()).append("</DDZDMC>"); |
| 774 | 801 | // 起点站的参数 |
| 775 | 802 | otherMap.put("stationMark","E"); |
| 776 | 803 | paramMap = packageYgcStationNumParam(schedulePlanInfo,otherMap); |
| 777 | - sBuffer.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap)).append("</DDXH>"); | |
| 804 | + sBuffer.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</DDXH>"); | |
| 778 | 805 | sBuffer.append("<JHDDSJ>").append(calcDdsj(schedulePlanInfo.getFcsj(),schedulePlanInfo.getBcsj())) |
| 779 | 806 | .append("</JHDDSJ>"); |
| 780 | 807 | sBuffer.append("</BC>"); |
| ... | ... | @@ -883,14 +910,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 883 | 910 | // 起点站的参数 |
| 884 | 911 | otherMap.put("stationMark","B"); |
| 885 | 912 | paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); |
| 886 | - sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap)).append("</ZDXH>"); | |
| 913 | + sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</ZDXH>"); | |
| 887 | 914 | sBuffer.append("<JHFCSJ>").append(changeTimeFormat(ttInfoDetail)).append("</JHFCSJ>"); |
| 888 | 915 | sBuffer.append("<DDZDMC>").append(BasicData.stationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir() |
| 889 | 916 | +"_"+ttInfoDetail.getZdzCode())).append("</DDZDMC>"); |
| 890 | 917 | // 起点站的参数 |
| 891 | 918 | otherMap.put("stationMark","E"); |
| 892 | 919 | paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); |
| 893 | - sBuffer.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap)).append("</DDXH>"); | |
| 920 | + sBuffer.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</DDXH>"); | |
| 894 | 921 | sBuffer.append("<JHDDSJ>").append(calcDdsj(ttInfoDetail.getFcsj(),ttInfoDetail.getBcsj())).append("</JHDDSJ>"); |
| 895 | 922 | sBuffer.append("</BC>"); |
| 896 | 923 | } |
| ... | ... | @@ -1214,7 +1241,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 1214 | 1241 | * |
| 1215 | 1242 | * @return 站点序号累加后的ID |
| 1216 | 1243 | */ |
| 1217 | - private int packagStationXml(List<StationRoute> stationsList,StringBuffer sBuffer,int startId){ | |
| 1244 | + private int packagStationXml(List<StationRoute> stationsList,StringBuffer sBuffer,int startId,Map<String, Integer> stationNumMap){ | |
| 1218 | 1245 | int size = stationsList.size(); |
| 1219 | 1246 | StationRoute srRoute; |
| 1220 | 1247 | HashMap<String,String> paraMap; |
| ... | ... | @@ -1231,7 +1258,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 1231 | 1258 | } |
| 1232 | 1259 | paraMap = packageYgcStationNumParam(srRoute,null); |
| 1233 | 1260 | sBuffer.append("<Station>"); |
| 1234 | - sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paraMap)).append("</ZDXH>"); | |
| 1261 | + sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paraMap,stationNumMap)).append("</ZDXH>"); | |
| 1235 | 1262 | sBuffer.append("<SXX>").append(srRoute.getDirections()).append("</SXX>"); |
| 1236 | 1263 | sBuffer.append("<ZDMC>").append(srRoute.getStationName()).append("</ZDMC>"); |
| 1237 | 1264 | sBuffer.append("<ZDBM>").append(srRoute.getStationCode()).append("</ZDBM>"); |
| ... | ... | @@ -1287,7 +1314,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 1287 | 1314 | * @param map |
| 1288 | 1315 | * @return 运管处站点序号 |
| 1289 | 1316 | */ |
| 1290 | - private Integer getYgcStationNumByLineCodeAndDirectionAndStationName(HashMap<String,String> map){ | |
| 1317 | + private Integer getYgcStationNumByLineCodeAndDirectionAndStationName(HashMap<String,String> map,Map<String, Integer> stationNumMap){ | |
| 1291 | 1318 | // 线路编码 |
| 1292 | 1319 | String lineCode = map.get("lineCode"); |
| 1293 | 1320 | // 线路走向 0:上行 1:下行 |
| ... | ... | @@ -1305,9 +1332,15 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 1305 | 1332 | }else if(stationMark.equals("Z")){ |
| 1306 | 1333 | marks= new String[]{"Z"}; |
| 1307 | 1334 | } |
| 1335 | + // 默认从缓存BasicData.stationName2YgcNumber | |
| 1336 | + Map<String, Integer> tempMap = BasicData.stationName2YgcNumber; | |
| 1337 | + // 如果传入的stationNumMap不为空,则不是缓存取,而从stationNumMap取 | |
| 1338 | + if(stationNumMap != null){ | |
| 1339 | + tempMap = stationNumMap; | |
| 1340 | + } | |
| 1308 | 1341 | Integer number = null; |
| 1309 | 1342 | for (int i = 0 ;i < marks.length ; i ++){ |
| 1310 | - number = BasicData.stationName2YgcNumber.get(lineCode+"_"+direction+"_"+stationCode+"_"+marks[i]); | |
| 1343 | + number = tempMap.get(lineCode+"_"+direction+"_"+stationCode+"_"+marks[i]); | |
| 1311 | 1344 | if(number != null){ |
| 1312 | 1345 | break; |
| 1313 | 1346 | } | ... | ... |
src/main/resources/static/pages/trafficManage/js/lineStationUpload.js