Commit 27b10d29b436511fa0942d805fd9203b14b95095
1 parent
895efb67
运管处路单上传BUG修改
Showing
1 changed file
with
141 additions
and
32 deletions
src/main/java/com/bsth/service/impl/TrafficManageServiceImpl.java
| ... | ... | @@ -134,12 +134,19 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 134 | 134 | * 上传线路信息 |
| 135 | 135 | */ |
| 136 | 136 | @Override |
| 137 | - public String setXL() { | |
| 137 | + public String setXL(Map<String, Object> param) { | |
| 138 | 138 | String result = "failure"; |
| 139 | 139 | StringBuffer sBuffer = new StringBuffer(); |
| 140 | 140 | try { |
| 141 | - Iterator<Line> lineIterator = lineRepository.findAll().iterator(); | |
| 141 | + Map<String,Object> map = new HashMap<String,Object>(); | |
| 142 | + map.put("lineCode_eq", param.get("xl.lineCode_like")+""); | |
| 143 | + Iterator<Line> lineIterator; | |
| 142 | 144 | Line line = null; |
| 145 | + if(param.get("xl.lineCode_like").equals("")){ | |
| 146 | + lineIterator = lineRepository.findAll().iterator(); | |
| 147 | + }else { | |
| 148 | + line = lineRepository.findOne(new CustomerSpecs<Line>(map)); | |
| 149 | + } | |
| 143 | 150 | List<StationRoute> upStationsList = null;// 上行站点路由集 |
| 144 | 151 | List<StationRoute> downStationsList = null;// 下行站点路由集 |
| 145 | 152 | List<LineInformation> lineInformationsList = null; |
| ... | ... | @@ -147,14 +154,15 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 147 | 154 | sBuffer.append("<Data>"); |
| 148 | 155 | sBuffer.append("<RequestOrg>上海巴士拓华科技发展有限公司</RequestOrg>"); |
| 149 | 156 | sBuffer.append("<DataList>"); |
| 150 | - while(lineIterator.hasNext()){ | |
| 151 | - line = lineIterator.next(); | |
| 152 | - if(!line.getName().equals("浦江4路")){ | |
| 153 | - continue; | |
| 154 | - } | |
| 155 | - if(BasicData.lineId2ShangHaiCodeMap.get(line.getId()) == null | |
| 157 | +// while(lineIterator.hasNext()){ | |
| 158 | +// line = lineIterator.next(); | |
| 159 | +// if(BasicData.lineId2ShangHaiCodeMap.get(line.getId()) == null | |
| 160 | +// || line.getInUse() == 0){ | |
| 161 | +// continue; | |
| 162 | +// } | |
| 163 | + if(BasicData.lineId2ShangHaiCodeMap.get(line.getId()) == null | |
| 156 | 164 | || line.getInUse() == 0){ |
| 157 | - continue; | |
| 165 | + return result; | |
| 158 | 166 | } |
| 159 | 167 | sBuffer.append("<LINE_ID>").append(line.getId()).append("</LINE_ID>"); |
| 160 | 168 | sBuffer.append("<LINE_CODE>").append(BasicData.lineId2ShangHaiCodeMap.get(line.getId())).append("</LINE_CODE>"); |
| ... | ... | @@ -176,7 +184,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 176 | 184 | startId = packagStationPointXml(upStationsList, sBuffer, startId); |
| 177 | 185 | packagStationPointXml(downStationsList, sBuffer, startId); |
| 178 | 186 | sBuffer.append("</LinePointList>"); |
| 179 | - } | |
| 187 | +// } | |
| 180 | 188 | sBuffer.append("</DataList>"); |
| 181 | 189 | sBuffer.append("</Data>"); |
| 182 | 190 | System.out.println(sBuffer.toString()); |
| ... | ... | @@ -301,6 +309,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 301 | 309 | List<ScheduleRealInfo> list = scheduleRealInfoRepository.setLD(date); |
| 302 | 310 | List<Map<String,Object>> listGroup = scheduleRealInfoRepository.setLDGroup(date); |
| 303 | 311 | Map<String,Object> map = new HashMap<String,Object>(); |
| 312 | + HashMap<String,String> paramMap; | |
| 313 | + HashMap<String,String> otherMap = new HashMap<String, String>(); | |
| 304 | 314 | for(Map<String,Object> schRealInfo:listGroup){ |
| 305 | 315 | if(schRealInfo != null){ |
| 306 | 316 | //根据车辆自编号查询车牌号 |
| ... | ... | @@ -347,16 +357,20 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 347 | 357 | sf.append("<SJGH>"+scheduleRealInfo.getjGh()+"</SJGH>"); |
| 348 | 358 | sf.append("<SXX>"+scheduleRealInfo.getXlDir()+"</SXX>"); |
| 349 | 359 | sf.append("<FCZDMC>"+scheduleRealInfo.getQdzName()+"</FCZDMC>"); |
| 350 | - sf.append("<FCZDXH>" + getYgcStationNumByLineCodeAndDirectionAndStationName( | |
| 351 | - scheduleRealInfo.getXlBm(), scheduleRealInfo.getXlDir(), scheduleRealInfo.getQdzCode()) + "</FCZDXH>"); | |
| 360 | + // 起点站的参数 | |
| 361 | + otherMap.put("stationMark","B"); | |
| 362 | + paramMap = packageYgcStationNumParam(scheduleRealInfo,otherMap); | |
| 363 | + sf.append("<FCZDXH>" + getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap) + "</FCZDXH>"); | |
| 352 | 364 | sf.append("<FCZDBM>"+scheduleRealInfo.getQdzCode()+"</FCZDBM>"); |
| 353 | 365 | sf.append("<JHFCSJ>"+scheduleRealInfo.getFcsj()+"</JHFCSJ>"); |
| 354 | 366 | sf.append("<DFSJ>"+scheduleRealInfo.getDfsj()+"</DFSJ>"); |
| 355 | 367 | sf.append("<SJFCSJ>"+scheduleRealInfo.getFcsjActual()+"</SJFCSJ>"); |
| 356 | 368 | sf.append("<FCZDLX>"+""+"</FCZDLX>"); |
| 357 | 369 | sf.append("<DDZDMC>"+scheduleRealInfo.getZdzName()+"</DDZDMC>"); |
| 358 | - sf.append("<DDZDXH>"+ getYgcStationNumByLineCodeAndDirectionAndStationName( | |
| 359 | - scheduleRealInfo.getXlBm(), scheduleRealInfo.getXlDir(), scheduleRealInfo.getZdzCode()) +"</DDZDXH>"); | |
| 370 | + // 终点站的参数 | |
| 371 | + otherMap.put("stationMark","E"); | |
| 372 | + paramMap = packageYgcStationNumParam(scheduleRealInfo,otherMap); | |
| 373 | + sf.append("<DDZDXH>"+ getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap) +"</DDZDXH>"); | |
| 360 | 374 | sf.append("<DDZDBM>"+scheduleRealInfo.getZdzCode()+"</DDZDBM>"); |
| 361 | 375 | sf.append("<JHDDSJ>"+scheduleRealInfo.getZdsj()+"</JHDDSJ>"); |
| 362 | 376 | sf.append("<SJDDSJ>"+scheduleRealInfo.getZdsjActual()+"</SJDDSJ>"); |
| ... | ... | @@ -650,6 +664,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 650 | 664 | List<SchedulePlanInfo> schedulePlanList = schedulePlanInfoRepository.findLineScheduleBc(tomorrow); |
| 651 | 665 | int j = 0; // 初始化标识 |
| 652 | 666 | if(schedulePlanList != null ){ |
| 667 | + HashMap<String,String> paramMap; | |
| 668 | + HashMap<String,String> otherMap = new HashMap<String, String>(); | |
| 653 | 669 | int size = schedulePlanList.size(); |
| 654 | 670 | for (int i = 0; i < size; i++) { |
| 655 | 671 | schedulePlanInfo = schedulePlanList.get(i); |
| ... | ... | @@ -676,12 +692,16 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 676 | 692 | sBuffer.append("<SJGH>").append(schedulePlanInfo.getjGh()).append("</SJGH>"); |
| 677 | 693 | sBuffer.append("<SXX>").append(schedulePlanInfo.getXlDir()).append("</SXX>"); |
| 678 | 694 | sBuffer.append("<FCZDMC>").append(schedulePlanInfo.getQdzName()).append("</FCZDMC>"); |
| 679 | - sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName( | |
| 680 | - schedulePlanInfo.getXlBm(), schedulePlanInfo.getXlDir(), schedulePlanInfo.getQdzCode())).append("</ZDXH>"); | |
| 695 | + // 起点站的参数 | |
| 696 | + otherMap.put("stationMark","B"); | |
| 697 | + paramMap = packageYgcStationNumParam(schedulePlanInfo,otherMap); | |
| 698 | + sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap)).append("</ZDXH>"); | |
| 681 | 699 | sBuffer.append("<JHFCSJ>").append(schedulePlanInfo.getFcsj()).append("</JHFCSJ>"); |
| 682 | 700 | sBuffer.append("<DDZDMC>").append(schedulePlanInfo.getZdzName()).append("</DDZDMC>"); |
| 683 | - sBuffer.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName( | |
| 684 | - schedulePlanInfo.getXlBm(), schedulePlanInfo.getXlDir(), schedulePlanInfo.getZdzCode())).append("</DDXH>"); | |
| 701 | + // 起点站的参数 | |
| 702 | + otherMap.put("stationMark","E"); | |
| 703 | + paramMap = packageYgcStationNumParam(schedulePlanInfo,otherMap); | |
| 704 | + sBuffer.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap)).append("</DDXH>"); | |
| 685 | 705 | sBuffer.append("<JHDDSJ>").append(calcDdsj(schedulePlanInfo.getFcsj(),schedulePlanInfo.getBcsj())) |
| 686 | 706 | .append("</JHDDSJ>"); |
| 687 | 707 | sBuffer.append("</BC>"); |
| ... | ... | @@ -743,6 +763,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 743 | 763 | HashMap<String,Object> param = new HashMap<String, Object>(); |
| 744 | 764 | String lineCode ; |
| 745 | 765 | sBuffer.append("<SKBs>"); |
| 766 | + HashMap<String,String> paramMap; | |
| 767 | + HashMap<String,String> otherMap = new HashMap<String, String>(); | |
| 746 | 768 | for (int i = 0; i < idArray.length; i++) { |
| 747 | 769 | ttInfo = ttInfoRepository.findOne(Long.valueOf(idArray[i])); |
| 748 | 770 | if(ttInfo == null) |
| ... | ... | @@ -783,12 +805,16 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 783 | 805 | sBuffer.append("<LPBH>").append(ttInfoDetail.getLp().getLpNo()).append("</LPBH>"); |
| 784 | 806 | sBuffer.append("<SXX>").append(ttInfoDetail.getXlDir()).append("</SXX>"); |
| 785 | 807 | sBuffer.append("<FCZDMC>").append(ttInfoDetail.getQdz().getStationName()).append("</FCZDMC>"); |
| 786 | - sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName( | |
| 787 | - lineCode, ttInfoDetail.getXlDir(), ttInfoDetail.getQdz().getStationCod())).append("</ZDXH>"); | |
| 808 | + // 起点站的参数 | |
| 809 | + otherMap.put("stationMark","B"); | |
| 810 | + paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); | |
| 811 | + sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap)).append("</ZDXH>"); | |
| 788 | 812 | sBuffer.append("<JHFCSJ>").append(changeTimeFormat(ttInfoDetail)).append("</JHFCSJ>"); |
| 789 | 813 | sBuffer.append("<DDZDMC>").append(ttInfoDetail.getZdz().getStationName()).append("</DDZDMC>"); |
| 790 | - sBuffer.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName( | |
| 791 | - lineCode, ttInfoDetail.getXlDir(), ttInfoDetail.getZdz().getStationCod())).append("</DDXH>"); | |
| 814 | + // 起点站的参数 | |
| 815 | + otherMap.put("stationMark","E"); | |
| 816 | + paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); | |
| 817 | + sBuffer.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap)).append("</DDXH>"); | |
| 792 | 818 | sBuffer.append("<JHDDSJ>").append(calcDdsj(ttInfoDetail.getFcsj(),ttInfoDetail.getBcsj())).append("</JHDDSJ>"); |
| 793 | 819 | sBuffer.append("</BC>"); |
| 794 | 820 | } |
| ... | ... | @@ -1136,6 +1162,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 1136 | 1162 | private int packagStationXml(List<StationRoute> stationsList,StringBuffer sBuffer,int startId){ |
| 1137 | 1163 | int size = stationsList.size(); |
| 1138 | 1164 | StationRoute srRoute; |
| 1165 | + HashMap<String,String> paraMap; | |
| 1139 | 1166 | String zdlx ;// 站点类型:0:起点站、1:终点站、2:中途站 |
| 1140 | 1167 | for (int i = 0; i < size; i++) { |
| 1141 | 1168 | srRoute = stationsList.get(i); |
| ... | ... | @@ -1147,10 +1174,11 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 1147 | 1174 | }else{ |
| 1148 | 1175 | zdlx = "2"; |
| 1149 | 1176 | } |
| 1177 | + paraMap = packageYgcStationNumParam(srRoute,null); | |
| 1150 | 1178 | sBuffer.append("<Station>"); |
| 1151 | - sBuffer.append("<STATION_ID>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(srRoute.getLineCode(),srRoute.getDirections()+"",srRoute.getStationCode())).append("</STATION_ID>"); | |
| 1179 | + sBuffer.append("<STATION_ID>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paraMap)).append("</STATION_ID>"); | |
| 1152 | 1180 | sBuffer.append("<UPDDOWN>").append(srRoute.getDirections()).append("</UPDDOWN>"); |
| 1153 | - sBuffer.append("<STATION_NO>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(srRoute.getLineCode(),srRoute.getDirections()+"",srRoute.getStationCode())).append("</STATION_NO>"); | |
| 1181 | + sBuffer.append("<STATION_NO>").append(i).append("</STATION_NO>"); | |
| 1154 | 1182 | sBuffer.append("<STATION_CODE>").append(srRoute.getStationCode()).append("</STATION_CODE>"); |
| 1155 | 1183 | sBuffer.append("<STATION_NAME>").append(srRoute.getStationName()).append("</STATION_NAME>"); |
| 1156 | 1184 | sBuffer.append("<STATION_LON>").append(srRoute.getStation().getgLonx()).append("</STATION_LON>"); |
| ... | ... | @@ -1173,6 +1201,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 1173 | 1201 | private int packagStationPointXml(List<StationRoute> stationsList,StringBuffer sBuffer,int startId){ |
| 1174 | 1202 | int size = stationsList.size(); |
| 1175 | 1203 | StationRoute srRoute; |
| 1204 | + HashMap<String,String> paraMap; | |
| 1176 | 1205 | String zdlx ;// 站点类型:0:起点站、1:终点站、2:中途站 |
| 1177 | 1206 | for (int i = 0; i < size; i++) { |
| 1178 | 1207 | srRoute = stationsList.get(i); |
| ... | ... | @@ -1184,8 +1213,9 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 1184 | 1213 | }else{ |
| 1185 | 1214 | zdlx = "2"; |
| 1186 | 1215 | } |
| 1216 | + paraMap = packageYgcStationNumParam(srRoute,null); | |
| 1187 | 1217 | sBuffer.append("<Point>"); |
| 1188 | - sBuffer.append("<POINT_ID>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(srRoute.getLineCode(),srRoute.getDirections()+"",srRoute.getStationCode())).append("</POINT_ID>"); | |
| 1218 | + sBuffer.append("<POINT_ID>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paraMap)).append("</POINT_ID>"); | |
| 1189 | 1219 | sBuffer.append("<UPDDOWN>").append(srRoute.getDirections()).append("</UPDDOWN>"); |
| 1190 | 1220 | sBuffer.append("<POINTLON>").append(srRoute.getStation().getgLonx()).append("</POINTLON>"); |
| 1191 | 1221 | sBuffer.append("<POINTLAT>").append(srRoute.getStation().getgLaty()).append("</POINTLAT>"); |
| ... | ... | @@ -1196,15 +1226,94 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 1196 | 1226 | } |
| 1197 | 1227 | |
| 1198 | 1228 | /** |
| 1199 | - * | |
| 1200 | - * @param lineCode 线路编码 | |
| 1201 | - * @param direction 线路方向 | |
| 1202 | - * @param stationCode 让点名称 | |
| 1229 | + * 获取运管处站点序号 | |
| 1230 | + * @param map | |
| 1203 | 1231 | * @return 运管处站点序号 |
| 1204 | 1232 | */ |
| 1205 | - private Integer getYgcStationNumByLineCodeAndDirectionAndStationName(String lineCode,String direction,String stationCode){ | |
| 1206 | - Integer number = 0; | |
| 1207 | - number = BasicData.stationName2YgcNumber.get(lineCode+"_"+direction+"_"+stationCode); | |
| 1233 | + private Integer getYgcStationNumByLineCodeAndDirectionAndStationName(HashMap<String,String> map){ | |
| 1234 | + // 线路编码 | |
| 1235 | + String lineCode = map.get("lineCode"); | |
| 1236 | + // 线路走向 0:上行 1:下行 | |
| 1237 | + String direction = map.get("direction"); | |
| 1238 | + // 站点编码 | |
| 1239 | + String stationCode = map.get("stationCode"); | |
| 1240 | + // 站点类型:B:起点站 Z:中途站 E:终点站 T:停车场 | |
| 1241 | + String stationMark = map.get("stationMark"); | |
| 1242 | + String[] marks = null; | |
| 1243 | + // 起点站,先从起点找,找不到再从中途站找,最后从终点找 | |
| 1244 | + if(stationMark.equals("B")){ | |
| 1245 | + marks= new String[]{"B","Z","E"}; | |
| 1246 | + }else if(stationMark.equals("E")){// 终点站相反 | |
| 1247 | + marks= new String[]{"E","Z","B"}; | |
| 1248 | + }else if(stationMark.equals("Z")){ | |
| 1249 | + marks= new String[]{"Z"}; | |
| 1250 | + } | |
| 1251 | + Integer number = null; | |
| 1252 | + for (int i = 0 ;i < marks.length ; i ++){ | |
| 1253 | + number = BasicData.stationName2YgcNumber.get(lineCode+"_"+direction+"_"+stationCode+"_"+marks[i]); | |
| 1254 | + if(number != null){ | |
| 1255 | + break; | |
| 1256 | + } | |
| 1257 | + } | |
| 1208 | 1258 | return number == null ? 0 : number; |
| 1209 | 1259 | } |
| 1260 | + | |
| 1261 | + /** | |
| 1262 | + * 封装查询站序条件 | |
| 1263 | + * @param obj | |
| 1264 | + * @return | |
| 1265 | + */ | |
| 1266 | + private HashMap packageYgcStationNumParam(Object obj,HashMap<String,String> otherParam){ | |
| 1267 | + HashMap<String,String> map = new HashMap<String,String>(); | |
| 1268 | + String lineCode = "",direction = "",stationCode = "",stationMark = ""; | |
| 1269 | + // 站点路由 | |
| 1270 | + if(obj instanceof StationRoute){ | |
| 1271 | + StationRoute sr = (StationRoute)obj; | |
| 1272 | + lineCode = sr.getLineCode(); | |
| 1273 | + direction = String.valueOf(sr.getDirections()); | |
| 1274 | + stationCode = sr.getStationCode(); | |
| 1275 | + stationMark = sr.getStationMark(); | |
| 1276 | + }else if(obj instanceof ScheduleRealInfo){ //实际排班计划明细。 | |
| 1277 | + ScheduleRealInfo sri = (ScheduleRealInfo)obj; | |
| 1278 | + lineCode = sri.getXlBm(); | |
| 1279 | + direction = sri.getXlDir(); | |
| 1280 | + if(otherParam != null && otherParam.get("stationMark") != null){ | |
| 1281 | + stationMark = otherParam.get("stationMark"); | |
| 1282 | + if(stationMark.equals("B")){ // 起点站 | |
| 1283 | + stationCode = sri.getQdzCode(); | |
| 1284 | + }else if(stationMark.equals("E")){ // 终点站 | |
| 1285 | + stationCode = sri.getZdzCode(); | |
| 1286 | + } | |
| 1287 | + } | |
| 1288 | + }else if(obj instanceof SchedulePlanInfo){ //排班计划明细 | |
| 1289 | + SchedulePlanInfo spi = (SchedulePlanInfo)obj; | |
| 1290 | + lineCode = spi.getXlBm(); | |
| 1291 | + direction = spi.getXlDir(); | |
| 1292 | + if(otherParam != null && otherParam.get("stationMark") != null){ | |
| 1293 | + stationMark = otherParam.get("stationMark"); | |
| 1294 | + if(stationMark.equals("B")){ // 起点站 | |
| 1295 | + stationCode = spi.getQdzCode(); | |
| 1296 | + }else if(stationMark.equals("E")){ // 终点站 | |
| 1297 | + stationCode = spi.getZdzCode(); | |
| 1298 | + } | |
| 1299 | + } | |
| 1300 | + }else if(obj instanceof TTInfoDetail){ //时刻表明细 | |
| 1301 | + TTInfoDetail ttid = (TTInfoDetail)obj; | |
| 1302 | + lineCode = ttid.getXl().getLineCode(); | |
| 1303 | + direction = ttid.getXlDir(); | |
| 1304 | + if(otherParam != null && otherParam.get("stationMark") != null){ | |
| 1305 | + stationMark = otherParam.get("stationMark"); | |
| 1306 | + if(stationMark.equals("B")){ // 起点站 | |
| 1307 | + stationCode = ttid.getQdz().getStationCod(); | |
| 1308 | + }else if(stationMark.equals("E")){ // 终点站 | |
| 1309 | + stationCode = ttid.getZdz().getStationCod(); | |
| 1310 | + } | |
| 1311 | + } | |
| 1312 | + } | |
| 1313 | + map.put("lineCode",lineCode);// 站点编码 | |
| 1314 | + map.put("direction",direction); // 上下行 | |
| 1315 | + map.put("stationCode",stationCode); // 站点编号 | |
| 1316 | + map.put("stationMark",stationMark); // 站点类型 | |
| 1317 | + return map; | |
| 1318 | + } | |
| 1210 | 1319 | } | ... | ... |