Commit 4d3855a9ef56c76058b812725431ad778a5688bf
1 parent
2530b841
青浦时刻表上传代码依赖
Showing
1 changed file
with
164 additions
and
50 deletions
src/main/java/com/bsth/service/impl/TrafficManageServiceImpl.java
| 1 | package com.bsth.service.impl; | 1 | package com.bsth.service.impl; |
| 2 | 2 | ||
| 3 | import com.bsth.data.BasicData; | 3 | import com.bsth.data.BasicData; |
| 4 | +import com.bsth.email.SendEmailController; | ||
| 5 | +import com.bsth.email.entity.EmailBean; | ||
| 4 | import com.bsth.entity.*; | 6 | import com.bsth.entity.*; |
| 5 | import com.bsth.entity.realcontrol.ChildTaskPlan; | 7 | import com.bsth.entity.realcontrol.ChildTaskPlan; |
| 6 | import com.bsth.entity.realcontrol.ScheduleRealInfo; | 8 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| @@ -33,6 +35,7 @@ import org.springframework.data.domain.Sort.Direction; | @@ -33,6 +35,7 @@ import org.springframework.data.domain.Sort.Direction; | ||
| 33 | import org.springframework.stereotype.Service; | 35 | import org.springframework.stereotype.Service; |
| 34 | 36 | ||
| 35 | import java.io.*; | 37 | import java.io.*; |
| 38 | +import java.net.InetAddress; | ||
| 36 | import java.sql.Connection; | 39 | import java.sql.Connection; |
| 37 | import java.sql.PreparedStatement; | 40 | import java.sql.PreparedStatement; |
| 38 | import java.sql.ResultSet; | 41 | import java.sql.ResultSet; |
| @@ -109,6 +112,9 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -109,6 +112,9 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 109 | @Autowired | 112 | @Autowired |
| 110 | private YgcBasicDataService ygcBasicDataService; | 113 | private YgcBasicDataService ygcBasicDataService; |
| 111 | 114 | ||
| 115 | + // 发送邮件 | ||
| 116 | + @Autowired | ||
| 117 | + private SendEmailController sendEmailController; | ||
| 112 | 118 | ||
| 113 | // 运管处上传接口 | 119 | // 运管处上传接口 |
| 114 | private com.bsth.webService.trafficManage.up.org.tempuri.WebServiceSoap webServiceSoapUp; | 120 | private com.bsth.webService.trafficManage.up.org.tempuri.WebServiceSoap webServiceSoapUp; |
| @@ -138,6 +144,10 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -138,6 +144,10 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 138 | private final String userNameUp = "user"; | 144 | private final String userNameUp = "user"; |
| 139 | // 密码 | 145 | // 密码 |
| 140 | private final String passwordUp = "user"; | 146 | private final String passwordUp = "user"; |
| 147 | + // 接收邮件人 | ||
| 148 | + private final String emailSendToAddress = "175912183@qq.com"; | ||
| 149 | + // 记录路单上线的成功、失败线路数 | ||
| 150 | + private Integer countSuccess,countFailure; | ||
| 141 | 151 | ||
| 142 | private synchronized com.bsth.webService.trafficManage.up.org.tempuri.WebServiceSoap getWebServiceSoapUp(){ | 152 | private synchronized com.bsth.webService.trafficManage.up.org.tempuri.WebServiceSoap getWebServiceSoapUp(){ |
| 143 | try { | 153 | try { |
| @@ -396,20 +406,27 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -396,20 +406,27 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 396 | */ | 406 | */ |
| 397 | private String uploadLD(String theDate){ | 407 | private String uploadLD(String theDate){ |
| 398 | String result = "failure"; | 408 | String result = "failure"; |
| 409 | + countSuccess = 0 ;countFailure = 0; | ||
| 399 | Line line; | 410 | Line line; |
| 400 | // 取昨天 的日期 | 411 | // 取昨天 的日期 |
| 401 | String date = theDate == null ?sdfnyr.format(DateUtils.addDays(new Date(), -1)) : theDate; | 412 | String date = theDate == null ?sdfnyr.format(DateUtils.addDays(new Date(), -1)) : theDate; |
| 402 | StringBuffer sf = new StringBuffer(); | 413 | StringBuffer sf = new StringBuffer(); |
| 403 | - String str; | 414 | + StringBuffer logSuccess = new StringBuffer("成功:"); |
| 415 | + StringBuffer logFailure = new StringBuffer("失败:"); | ||
| 416 | + HashMap logXlbmSuccessMap = new HashMap(); | ||
| 417 | + HashMap logXlbmFailureMap = new HashMap(); | ||
| 418 | + HashMap logXlbmMap = new HashMap(); | ||
| 419 | + Results results = null; | ||
| 420 | + String str = "",xlbm; | ||
| 404 | try { | 421 | try { |
| 405 | int counter = 0; // 计数器 | 422 | int counter = 0; // 计数器 |
| 406 | int per = 10; // 每几条线路上传一次路单 | 423 | int per = 10; // 每几条线路上传一次路单 |
| 407 | 424 | ||
| 408 | List<ScheduleRealInfo> list = scheduleRealInfoRepository.setLD(date); | 425 | List<ScheduleRealInfo> list = scheduleRealInfoRepository.setLD(date); |
| 409 | List<Map<String,Object>> listGroup = scheduleRealInfoRepository.setLDGroup(date); | 426 | List<Map<String,Object>> listGroup = scheduleRealInfoRepository.setLDGroup(date); |
| 410 | - Map<String,Object> map = new HashMap<String,Object>(); | 427 | + Map<String,Object> map = new HashMap(); |
| 411 | HashMap<String,String> paramMap; | 428 | HashMap<String,String> paramMap; |
| 412 | - HashMap<String,String> otherMap = new HashMap<String, String>(); | 429 | + HashMap<String,String> otherMap = new HashMap(); |
| 413 | for(Map<String,Object> schRealInfo:listGroup){ | 430 | for(Map<String,Object> schRealInfo:listGroup){ |
| 414 | if(schRealInfo != null){ | 431 | if(schRealInfo != null){ |
| 415 | //根据车辆自编号查询车牌号 | 432 | //根据车辆自编号查询车牌号 |
| @@ -425,9 +442,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -425,9 +442,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 425 | sf.append("<DLDS>"); | 442 | sf.append("<DLDS>"); |
| 426 | } | 443 | } |
| 427 | counter ++; | 444 | counter ++; |
| 445 | + xlbm = BasicData.lineCode2ShangHaiCodeMap.get(schRealInfo.get("xlBm")+""); | ||
| 446 | + // 保存一次路单的线路编码,用于发送邮箱 | ||
| 447 | + if(logXlbmMap.get(xlbm) == null){ | ||
| 448 | + logXlbmMap.put(xlbm,xlbm); | ||
| 449 | + } | ||
| 428 | sf.append("<DLD>"); | 450 | sf.append("<DLD>"); |
| 429 | sf.append("<RQ>"+date+"</RQ>"); | 451 | sf.append("<RQ>"+date+"</RQ>"); |
| 430 | - sf.append("<XLBM>"+BasicData.lineCode2ShangHaiCodeMap.get(schRealInfo.get("xlBm")+"")+"</XLBM>"); | 452 | + sf.append("<XLBM>"+xlbm+"</XLBM>"); |
| 431 | sf.append("<LPBH>"+schRealInfo.get("lpName")+"</LPBH>"); | 453 | sf.append("<LPBH>"+schRealInfo.get("lpName")+"</LPBH>"); |
| 432 | sf.append("<CPH>"+car.getCarPlate()+"</CPH>"); | 454 | sf.append("<CPH>"+car.getCarPlate()+"</CPH>"); |
| 433 | sf.append("<UPDT>"+sdfnyrsfm.format(new Date())+"</UPDT>"); | 455 | sf.append("<UPDT>"+sdfnyrsfm.format(new Date())+"</UPDT>"); |
| @@ -485,39 +507,91 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -485,39 +507,91 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 485 | counter = 0; | 507 | counter = 0; |
| 486 | sf.append("</DLDS>"); | 508 | sf.append("</DLDS>"); |
| 487 | str = sf.toString().replace("'","");// 去掉'号 | 509 | str = sf.toString().replace("'","");// 去掉'号 |
| 488 | - Results results = ssop.setLD(userNameOther, passwordOther, StringEscapeUtils.unescapeHtml(str)); | ||
| 489 | - if(results.isSuccess()){ | ||
| 490 | - result = "success"; | ||
| 491 | - }else{ | ||
| 492 | - result = "failure"; | ||
| 493 | - } | ||
| 494 | - logger.info("setLD:"+str); | ||
| 495 | - logger.info("setLD:"+result); | 510 | + results = ssop.setLD(userNameOther, passwordOther, StringEscapeUtils.unescapeHtml(str)); |
| 511 | + // 记录日志 | ||
| 512 | + result = logRecord(results,logXlbmMap,logXlbmSuccessMap,logXlbmFailureMap,logSuccess,logFailure,str); | ||
| 496 | } | 513 | } |
| 497 | } | 514 | } |
| 498 | // 每per条线路上传后剩下的数据再上传 | 515 | // 每per条线路上传后剩下的数据再上传 |
| 499 | if(counter > 0){ | 516 | if(counter > 0){ |
| 500 | sf.append("</DLDS>"); | 517 | sf.append("</DLDS>"); |
| 501 | str = sf.toString().replace("'","");// 去掉'号 | 518 | str = sf.toString().replace("'","");// 去掉'号 |
| 502 | - Results results = ssop.setLD(userNameOther, passwordOther, StringEscapeUtils.unescapeHtml(str)); | ||
| 503 | - if(results.isSuccess()){ | ||
| 504 | - result = "success"; | ||
| 505 | - }else{ | ||
| 506 | - result = "failure"; | ||
| 507 | - } | ||
| 508 | - logger.info("setLD:"+str); | ||
| 509 | - logger.info("setLD:"+result); | 519 | + results = ssop.setLD(userNameOther, passwordOther, StringEscapeUtils.unescapeHtml(str)); |
| 510 | } | 520 | } |
| 521 | + // 记录日志 | ||
| 522 | + result = logRecord(results,logXlbmMap,logXlbmSuccessMap,logXlbmFailureMap,logSuccess,logFailure,str); | ||
| 511 | } catch (Exception e) { | 523 | } catch (Exception e) { |
| 512 | logger.error("setLD:",e); | 524 | logger.error("setLD:",e); |
| 525 | + logFailure.append(e).append("<br/>"); | ||
| 526 | + for (StackTraceElement traceElement : e.getStackTrace()){ | ||
| 527 | + logFailure.append("\r\t").append(traceElement); | ||
| 528 | + } | ||
| 513 | e.printStackTrace(); | 529 | e.printStackTrace(); |
| 514 | }finally{ | 530 | }finally{ |
| 515 | - | 531 | + try { |
| 532 | + //发送邮件 | ||
| 533 | + EmailBean mail = new EmailBean(); | ||
| 534 | + mail.setSubject(InetAddress.getLocalHost().getHostAddress()+":路单日志数据"+date); | ||
| 535 | + mail.setContent(logSuccess+"<br/>成功数:"+countSuccess+"<br/>" +logFailure+"<br/>失败数:"+countFailure); | ||
| 536 | + sendEmailController.sendMail(emailSendToAddress, mail); | ||
| 537 | + logger.info("setLD-sendMail:邮件发送成功!"); | ||
| 538 | + }catch (Exception e){ | ||
| 539 | + e.printStackTrace(); | ||
| 540 | + logger.error("setLD-sendMail:",e); | ||
| 541 | + } | ||
| 516 | } | 542 | } |
| 517 | return result; | 543 | return result; |
| 518 | } | 544 | } |
| 519 | 545 | ||
| 520 | /** | 546 | /** |
| 547 | + * 记录日志 | ||
| 548 | + * @param results | ||
| 549 | + * @param logXlbmMap | ||
| 550 | + * @param logXlbmSuccessMap | ||
| 551 | + * @param logXlbmFailureMap | ||
| 552 | + * @param logSuccess | ||
| 553 | + * @param logFailure | ||
| 554 | + * @param str | ||
| 555 | + */ | ||
| 556 | + private String logRecord(Results results,HashMap logXlbmMap,HashMap logXlbmSuccessMap,HashMap logXlbmFailureMap,StringBuffer logSuccess, | ||
| 557 | + StringBuffer logFailure,String str){ | ||
| 558 | + String result = "failure"; | ||
| 559 | + // 记录日志 | ||
| 560 | + if(results != null){ | ||
| 561 | + if(results.isSuccess()){// 上传成功 | ||
| 562 | + // 把上线成功的线路编码放入 logXlbmSuccessMap,并记录logSuccess | ||
| 563 | + countSuccess += fillMailXlbmMap(logXlbmMap,logXlbmSuccessMap,logSuccess); | ||
| 564 | + result = "success"; | ||
| 565 | + }else{// 上传失败 | ||
| 566 | + // 把上线失败的线路编码放入 logXlbmFailureMap,并记录logFailure | ||
| 567 | + countFailure += fillMailXlbmMap(logXlbmMap,logXlbmFailureMap,logFailure); | ||
| 568 | + result = "failure"; | ||
| 569 | + } | ||
| 570 | + logger.info("setLD:"+str); | ||
| 571 | + logger.info("setLD:"+result); | ||
| 572 | + results = null; | ||
| 573 | + logXlbmMap = new HashMap(); | ||
| 574 | + } | ||
| 575 | + return result; | ||
| 576 | + } | ||
| 577 | + /** | ||
| 578 | + * 填充线路编码到相应的map | ||
| 579 | + * @param fromMap | ||
| 580 | + * @param toMap | ||
| 581 | + */ | ||
| 582 | + private int fillMailXlbmMap(HashMap fromMap,HashMap toMap,StringBuffer logStr){ | ||
| 583 | + int tmpCount = 0; | ||
| 584 | + for (Object key : fromMap.keySet()) { | ||
| 585 | + if(toMap.get(key) == null){ | ||
| 586 | + toMap.put(key,fromMap.get(key)); | ||
| 587 | + logStr.append(key).append(","); | ||
| 588 | + tmpCount ++; | ||
| 589 | + } | ||
| 590 | + } | ||
| 591 | + fromMap = new HashMap(); | ||
| 592 | + return tmpCount; | ||
| 593 | + } | ||
| 594 | + /** | ||
| 521 | * 上传路单 xml来自文件 | 595 | * 上传路单 xml来自文件 |
| 522 | * @return 上传成功标识 | 596 | * @return 上传成功标识 |
| 523 | */ | 597 | */ |
| @@ -577,7 +651,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -577,7 +651,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 577 | /** | 651 | /** |
| 578 | * 如果car==null,则说明该车辆是从线调中换车功能中加进去的, | 652 | * 如果car==null,则说明该车辆是从线调中换车功能中加进去的, |
| 579 | * 在cars基础信息中查不到车辆的信息,所以忽略该车辆 | 653 | * 在cars基础信息中查不到车辆的信息,所以忽略该车辆 |
| 580 | - */ | 654 | + */ |
| 581 | if(car == null){ | 655 | if(car == null){ |
| 582 | continue; | 656 | continue; |
| 583 | } | 657 | } |
| @@ -745,10 +819,26 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -745,10 +819,26 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 745 | } | 819 | } |
| 746 | 820 | ||
| 747 | /** | 821 | /** |
| 822 | + * 上传计划班次 指定日期 yyyy-MM-dd | ||
| 823 | + * @param theDate | ||
| 824 | + * @return | ||
| 825 | + */ | ||
| 826 | + public String setJHBC(String theDate){ | ||
| 827 | + return uploadJHBC(theDate); | ||
| 828 | + } | ||
| 829 | + | ||
| 830 | + /** | ||
| 831 | + * 上传计划班次 | ||
| 832 | + * @return | ||
| 833 | + */ | ||
| 834 | + public String setJHBC(){ | ||
| 835 | + return uploadJHBC(null); | ||
| 836 | + } | ||
| 837 | + /** | ||
| 748 | * 上传线路计划班次表 | 838 | * 上传线路计划班次表 |
| 749 | */ | 839 | */ |
| 750 | - @Override | ||
| 751 | - public String setJHBC() { | 840 | + |
| 841 | + private String uploadJHBC(String theDate) { | ||
| 752 | String result = "failure"; | 842 | String result = "failure"; |
| 753 | Line line; | 843 | Line line; |
| 754 | StringBuffer sBuffer =new StringBuffer(); | 844 | StringBuffer sBuffer =new StringBuffer(); |
| @@ -758,8 +848,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -758,8 +848,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 758 | SchedulePlanInfo schedulePlanInfo; | 848 | SchedulePlanInfo schedulePlanInfo; |
| 759 | String xlbm,zbh = ""; | 849 | String xlbm,zbh = ""; |
| 760 | Long lp = 0L; | 850 | Long lp = 0L; |
| 761 | - // 取明天的日期 | ||
| 762 | - String tomorrow = sdfnyr.format(DateUtils.addDays(new Date(), +1)); | 851 | + // 取得计划班次时间 |
| 852 | + String tomorrow = theDate == null ? sdfnyr.format(DateUtils.addDays(new Date(), +1)) : theDate; | ||
| 763 | // 查询所有班次 | 853 | // 查询所有班次 |
| 764 | List<SchedulePlanInfo> schedulePlanList = schedulePlanInfoRepository.findLineScheduleBc(tomorrow); | 854 | List<SchedulePlanInfo> schedulePlanList = schedulePlanInfoRepository.findLineScheduleBc(tomorrow); |
| 765 | int j = 0; // 初始化标识 | 855 | int j = 0; // 初始化标识 |
| @@ -853,32 +943,44 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -853,32 +943,44 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 853 | public String setSKB(String ids) { | 943 | public String setSKB(String ids) { |
| 854 | String result = "failure"; | 944 | String result = "failure"; |
| 855 | StringBuffer sBuffer = new StringBuffer(); | 945 | StringBuffer sBuffer = new StringBuffer(); |
| 946 | + DecimalFormat df = new DecimalFormat("######0.000"); | ||
| 856 | try { | 947 | try { |
| 857 | String[] idArray = ids.split(","); | 948 | String[] idArray = ids.split(","); |
| 858 | - StringBuffer sBufferA; | ||
| 859 | - StringBuffer sBufferB; | 949 | + StringBuffer sBufferA ,sBufferB ,sBufferC ; |
| 950 | + double zlc,yylc,singleLc,emptyLc;// 总里程、营运里程、单程、空放里程 | ||
| 951 | + String bcType,sxx;// 班次类型、上下行 | ||
| 860 | // 上传的时刻表集合 | 952 | // 上传的时刻表集合 |
| 861 | List<TTInfo> ttinfoList = new ArrayList<>(); | 953 | List<TTInfo> ttinfoList = new ArrayList<>(); |
| 862 | TTInfo ttInfo; | 954 | TTInfo ttInfo; |
| 863 | TTInfoDetail ttInfoDetail; | 955 | TTInfoDetail ttInfoDetail; |
| 956 | + LineInformation lineInformation; | ||
| 864 | Iterator<TTInfoDetail> ttInfoDetailIterator; | 957 | Iterator<TTInfoDetail> ttInfoDetailIterator; |
| 865 | - HashMap<String,Object> param = new HashMap<String, Object>(); | 958 | + HashMap<String,Object> param ; |
| 866 | sBuffer.append("<SKBs>"); | 959 | sBuffer.append("<SKBs>"); |
| 867 | HashMap<String,String> paramMap; | 960 | HashMap<String,String> paramMap; |
| 868 | - HashMap<String,String> otherMap = new HashMap<String, String>(); | 961 | + HashMap<String,String> otherMap = new HashMap<>(); |
| 869 | for (int i = 0; i < idArray.length; i++) { | 962 | for (int i = 0; i < idArray.length; i++) { |
| 870 | ttInfo = ttInfoRepository.findOne(Long.valueOf(idArray[i])); | 963 | ttInfo = ttInfoRepository.findOne(Long.valueOf(idArray[i])); |
| 871 | if(ttInfo == null) | 964 | if(ttInfo == null) |
| 872 | continue; | 965 | continue; |
| 873 | ttinfoList.add(ttInfo); // 保存时刻表 | 966 | ttinfoList.add(ttInfo); // 保存时刻表 |
| 967 | + zlc = 0.0f; | ||
| 968 | + yylc = 0.0f; | ||
| 969 | + // 获得时刻表 | ||
| 970 | + param = new HashMap(); | ||
| 874 | param.put("ttinfo.id_eq", ttInfo.getId()); | 971 | param.put("ttinfo.id_eq", ttInfo.getId()); |
| 875 | ttInfoDetailIterator = ttInfoDetailRepository.findAll(new CustomerSpecs<TTInfoDetail>(param), | 972 | ttInfoDetailIterator = ttInfoDetailRepository.findAll(new CustomerSpecs<TTInfoDetail>(param), |
| 876 | new Sort(Direction.ASC, "xlDir")).iterator(); | 973 | new Sort(Direction.ASC, "xlDir")).iterator(); |
| 974 | + // 获得lineInformation | ||
| 975 | + param = new HashMap(); | ||
| 976 | + param.put("line.id_eq", ttInfo.getXl().getId()); | ||
| 977 | + lineInformation = lineInformationRepository.findOne(new CustomerSpecs<LineInformation>(param)); | ||
| 877 | if(ttInfoDetailIterator.hasNext()){ | 978 | if(ttInfoDetailIterator.hasNext()){ |
| 878 | sBuffer.append("<SKB>"); | 979 | sBuffer.append("<SKB>"); |
| 879 | sBuffer.append("<XLBM>").append(BasicData.lineId2ShangHaiCodeMap.get(ttInfo.getXl().getId())) | 980 | sBuffer.append("<XLBM>").append(BasicData.lineId2ShangHaiCodeMap.get(ttInfo.getXl().getId())) |
| 880 | .append("</XLBM>"); | 981 | .append("</XLBM>"); |
| 881 | sBufferB = new StringBuffer(); | 982 | sBufferB = new StringBuffer(); |
| 983 | + sBufferC = new StringBuffer(); | ||
| 882 | sBufferB.append("<KSRQ>").append(sdfnyr.format(ttInfo.getQyrq())).append("</KSRQ>"); | 984 | sBufferB.append("<KSRQ>").append(sdfnyr.format(ttInfo.getQyrq())).append("</KSRQ>"); |
| 883 | // 结束日期暂时不要,节假日的班次表才需要,如春节的班次表 | 985 | // 结束日期暂时不要,节假日的班次表才需要,如春节的班次表 |
| 884 | sBufferB.append("<JSRQ>").append("").append("</JSRQ>"); | 986 | sBufferB.append("<JSRQ>").append("").append("</JSRQ>"); |
| @@ -886,43 +988,55 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -886,43 +988,55 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 886 | sBufferB.append("<TBYY>").append("").append("</TBYY>"); | 988 | sBufferB.append("<TBYY>").append("").append("</TBYY>"); |
| 887 | sBufferB.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | 989 | sBufferB.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); |
| 888 | sBufferB.append("<BCList>"); | 990 | sBufferB.append("<BCList>"); |
| 889 | - int num = 1; | ||
| 890 | while (ttInfoDetailIterator.hasNext()) { | 991 | while (ttInfoDetailIterator.hasNext()) { |
| 891 | ttInfoDetail = ttInfoDetailIterator.next(); | 992 | ttInfoDetail = ttInfoDetailIterator.next(); |
| 892 | - if(ttInfoDetail.getBcType().equals("in") || ttInfoDetail.getBcType().equals("out")){ | 993 | + bcType = ttInfoDetail.getBcType(); |
| 994 | + sxx = ttInfoDetail.getXlDir(); | ||
| 995 | + // 进出场班次 | ||
| 996 | + if(bcType.equals("in") || bcType.equals("out")){ | ||
| 997 | + // 进出班次的计划里程,算空驶里程 | ||
| 998 | + emptyLc = ttInfoDetail.getJhlc(); | ||
| 999 | + // 总里程需要加上空驶里程 | ||
| 1000 | + zlc += emptyLc; | ||
| 893 | continue; | 1001 | continue; |
| 894 | } | 1002 | } |
| 895 | - if(num++ == 1){ | ||
| 896 | - sBufferA = new StringBuffer(); | ||
| 897 | - sBufferA.append("<JHZLC>").append(ttInfoDetail.getJhlc()).append("</JHZLC>"); | ||
| 898 | - sBufferA.append("<JHYYLC>").append(ttInfoDetail.getJhlc()).append("</JHYYLC>"); | ||
| 899 | - sBuffer.append(sBufferA).append(sBufferB); | ||
| 900 | - } | ||
| 901 | // 如果发车时间格式错误,忽略此条 | 1003 | // 如果发车时间格式错误,忽略此条 |
| 902 | if(changeTimeFormat(ttInfoDetail) == null){ | 1004 | if(changeTimeFormat(ttInfoDetail) == null){ |
| 903 | continue; | 1005 | continue; |
| 904 | } | 1006 | } |
| 905 | - sBuffer.append("<BC>"); | ||
| 906 | - sBuffer.append("<LPBH>").append(ttInfoDetail.getLp().getLpNo()).append("</LPBH>"); | ||
| 907 | - sBuffer.append("<SXX>").append(ttInfoDetail.getXlDir()).append("</SXX>"); | ||
| 908 | - sBuffer.append("<FCZDMC>").append(BasicData.stationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir() | 1007 | + sBufferC.append("<BC>"); |
| 1008 | + sBufferC.append("<LPBH>").append(ttInfoDetail.getLp().getLpNo()).append("</LPBH>"); | ||
| 1009 | + sBufferC.append("<SXX>").append(sxx).append("</SXX>"); | ||
| 1010 | + sBufferC.append("<FCZDMC>").append(BasicData.stationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir() | ||
| 909 | +"_"+ttInfoDetail.getQdzCode())).append("</FCZDMC>"); | 1011 | +"_"+ttInfoDetail.getQdzCode())).append("</FCZDMC>"); |
| 910 | // 起点站的参数 | 1012 | // 起点站的参数 |
| 911 | otherMap.put("stationMark","B"); | 1013 | otherMap.put("stationMark","B"); |
| 912 | paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); | 1014 | paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); |
| 913 | - sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</ZDXH>"); | ||
| 914 | - sBuffer.append("<JHFCSJ>").append(changeTimeFormat(ttInfoDetail)).append("</JHFCSJ>"); | ||
| 915 | - sBuffer.append("<DDZDMC>").append(BasicData.stationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir() | 1015 | + sBufferC.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</ZDXH>"); |
| 1016 | + sBufferC.append("<JHFCSJ>").append(changeTimeFormat(ttInfoDetail)).append("</JHFCSJ>"); | ||
| 1017 | + sBufferC.append("<DDZDMC>").append(BasicData.stationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir() | ||
| 916 | +"_"+ttInfoDetail.getZdzCode())).append("</DDZDMC>"); | 1018 | +"_"+ttInfoDetail.getZdzCode())).append("</DDZDMC>"); |
| 917 | // 起点站的参数 | 1019 | // 起点站的参数 |
| 918 | otherMap.put("stationMark","E"); | 1020 | otherMap.put("stationMark","E"); |
| 919 | paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); | 1021 | paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); |
| 920 | - sBuffer.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</DDXH>"); | ||
| 921 | - sBuffer.append("<JHDDSJ>").append(calcDdsj(ttInfoDetail.getFcsj(),ttInfoDetail.getBcsj())).append("</JHDDSJ>"); | ||
| 922 | - sBuffer.append("</BC>"); | 1022 | + sBufferC.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</DDXH>"); |
| 1023 | + sBufferC.append("<JHDDSJ>").append(calcDdsj(ttInfoDetail.getFcsj(),ttInfoDetail.getBcsj())).append("</JHDDSJ>"); | ||
| 1024 | + sBufferC.append("</BC>"); | ||
| 1025 | + // 0:上行;1:下行 | ||
| 1026 | + if("0".equals(sxx)){ | ||
| 1027 | + singleLc = lineInformation.getUpMileage(); | ||
| 1028 | + }else{ | ||
| 1029 | + singleLc = lineInformation.getDownMileage(); | ||
| 1030 | + } | ||
| 1031 | + zlc += singleLc ; | ||
| 1032 | + yylc += singleLc; | ||
| 923 | } | 1033 | } |
| 924 | - sBuffer.append("</BCList>"); | ||
| 925 | - sBuffer.append("</SKB>"); | 1034 | + sBufferC.append("</BCList>"); |
| 1035 | + sBufferC.append("</SKB>"); | ||
| 1036 | + sBufferA = new StringBuffer(); | ||
| 1037 | + sBufferA.append("<JHZLC>").append(df.format(zlc)).append("</JHZLC>"); | ||
| 1038 | + sBufferA.append("<JHYYLC>").append(df.format(yylc)).append("</JHYYLC>"); | ||
| 1039 | + sBuffer.append(sBufferA).append(sBufferB).append(sBufferC); | ||
| 926 | } | 1040 | } |
| 927 | } | 1041 | } |
| 928 | sBuffer.append("</SKBs>"); | 1042 | sBuffer.append("</SKBs>"); |