Commit 819094988d6688f3ceae7602442d1717659638fe

Authored by zq
1 parent f0d23567

运管处bug修改

src/main/java/com/bsth/service/impl/TrafficManageServiceImpl.java
... ... @@ -37,6 +37,8 @@ import java.sql.ResultSet;
37 37 import java.text.DecimalFormat;
38 38 import java.text.SimpleDateFormat;
39 39 import java.util.*;
  40 +import java.util.regex.Pattern;
  41 +
40 42 /**
41 43 *
42 44 * @ClassName: TrafficManageServiceImpl(运管处接口service业务层实现类)
... ... @@ -299,6 +301,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{
299 301 */
300 302 public String setLD(){
301 303 String result = "failure";
  304 + Line line;
302 305 // 取昨天 的日期
303 306 String date = sdfnyr.format(DateUtils.addDays(new Date(), -1));
304 307 StringBuffer sf = new StringBuffer();
... ... @@ -312,6 +315,11 @@ public class TrafficManageServiceImpl implements TrafficManageService{
312 315 //根据车辆自编号查询车牌号
313 316 map.put("insideCode_eq", schRealInfo.getClZbh());
314 317 Cars car = carsRepository.findOne(new CustomerSpecs<Cars>(map));
  318 + // 获取线路是否使用标识,如果未使用,则不查该线路数据
  319 + line = lineRepository.findByLineCode(schRealInfo.getXlBm());
  320 + if(line.getInUse() == null || line.getInUse() == 0){
  321 + continue;
  322 + }
315 323 sf.append("<DLD>");
316 324 sf.append("<RQ>"+schRealInfo.getScheduleDateStr()+"</RQ>");
317 325 sf.append("<XLBM>"+BasicData.lineCode2ShangHaiCodeMap.get(schRealInfo.getXlBm())+"</XLBM>");
... ... @@ -557,14 +565,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{
557 565 @Override
558 566 public String setJHBC() {
559 567 String result = "failure";
  568 + Line line;
560 569 StringBuffer sBuffer =new StringBuffer();
561 570 try {
562 571 sBuffer.append("<JHBCs>");
563 572 // 声明变量
564   - SchedulePlanInfo schedulePlanInfo = null;
565   - String xlbm = "",zbh = "";
  573 + SchedulePlanInfo schedulePlanInfo;
  574 + String xlbm,zbh = "";
566 575 Long lp = 0L;
567   - int startSerialNum = 0,endSerialNum = 0;;
568 576 // 取明天的日期
569 577 String tomorrow = sdfnyr.format(DateUtils.addDays(new Date(), +1));
570 578 // 查询所有班次
... ... @@ -573,8 +581,13 @@ public class TrafficManageServiceImpl implements TrafficManageService{
573 581 int size = schedulePlanList.size();
574 582 for (int i = 0; i < size; i++) {
575 583 schedulePlanInfo = schedulePlanList.get(i);
  584 + xlbm = schedulePlanInfo.getXlBm();
  585 + // 获取线路是否使用标识,如果未使用,则不查该线路数据
  586 + line = lineRepository.findByLineCode(xlbm);
  587 + if(line.getInUse() == null || line.getInUse() == 0){
  588 + continue;
  589 + }
576 590 if(i == 0){// 第一次,则初始化值
577   - xlbm = schedulePlanInfo.getXlBm();
578 591 zbh = schedulePlanInfo.getClZbh();
579 592 lp = schedulePlanInfo.getLp();
580 593 // 拼装XML
... ... @@ -605,18 +618,28 @@ public class TrafficManageServiceImpl implements TrafficManageService{
605 618 sBuffer.append("</JHBC>");
606 619 }
607 620 }else{
608   - xlbm = schedulePlanInfo.getXlBm();
609 621 zbh = schedulePlanInfo.getClZbh();
610 622 lp = schedulePlanInfo.getLp();
611 623 sBuffer.append("</BCList>");
612 624 sBuffer.append("</JHBC>");
613   - startSerialNum = 0;
614   - endSerialNum = 0;
615 625 // 拼装XML
616 626 assembleJHBC(sBuffer, schedulePlanInfo, xlbm, zbh, lp);
617 627 }
618 628 }
619 629 }
  630 + // 判断XML是否以</BCList>结尾,如果不是,则加上
  631 + String regex = "^*</JHBC>$";
  632 + Pattern p = Pattern.compile(regex);
  633 + java.util.regex.Matcher m = p.matcher(sBuffer);
  634 + boolean isEndWithTrueFlag = false;
  635 + while (m.find()) {
  636 + isEndWithTrueFlag = true;
  637 + }
  638 + // 加上缺失的标签
  639 + if(!isEndWithTrueFlag){
  640 + sBuffer.append("</BCList>");
  641 + sBuffer.append("</JHBC>");
  642 + }
620 643 sBuffer.append("</JHBCs>");
621 644 if(ssop.setJHBC(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){
622 645 result = "success";
... ... @@ -643,7 +666,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{
643 666 StringBuffer sBufferA;
644 667 StringBuffer sBufferB;
645 668 TTInfo ttInfo;
646   - TTInfoDetail ttInfoDetail = null;
  669 + TTInfoDetail ttInfoDetail;
647 670 Iterator<TTInfoDetail> ttInfoDetailIterator;
648 671 HashMap<String,Object> param = new HashMap<String, Object>();
649 672 String lineCode ;
... ... @@ -1027,6 +1050,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{
1027 1050 company = "浦东金高公交公司";
1028 1051 }else if(company.equals("南汇公司")){
1029 1052 company = "浦东南汇公交公司";
  1053 + }else if(company.equals("青浦公交")){
  1054 + company = "浦东青浦公交公司";
1030 1055 }
1031 1056 }
1032 1057 /**
... ...