Commit 35f5420e20eb9a332fe781c66d762f1c7c2987fa
1 parent
16a6e003
修正上传至运管处的时刻表的总里程、营运里程
Showing
1 changed file
with
47 additions
and
25 deletions
src/main/java/com/bsth/service/impl/TrafficManageServiceImpl.java
| ... | ... | @@ -942,32 +942,42 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 942 | 942 | public String setSKB(String ids) { |
| 943 | 943 | String result = "failure"; |
| 944 | 944 | StringBuffer sBuffer = new StringBuffer(); |
| 945 | + DecimalFormat df = new DecimalFormat("######0.000"); | |
| 945 | 946 | try { |
| 946 | 947 | String[] idArray = ids.split(","); |
| 947 | - StringBuffer sBufferA; | |
| 948 | - StringBuffer sBufferB; | |
| 948 | + StringBuffer sBufferA ,sBufferB = null,sBufferC = null; | |
| 949 | + double zlc = 0.0f,yylc = 0.0f,singleLc,emptyLc;// 总里程、营运里程、单程、空放里程 | |
| 950 | + String bcType,sxx;// 班次类型、上下行 | |
| 949 | 951 | // 上传的时刻表集合 |
| 950 | 952 | List<TTInfo> ttinfoList = new ArrayList<>(); |
| 951 | 953 | TTInfo ttInfo; |
| 952 | 954 | TTInfoDetail ttInfoDetail; |
| 955 | + LineInformation lineInformation; | |
| 953 | 956 | Iterator<TTInfoDetail> ttInfoDetailIterator; |
| 954 | - HashMap<String,Object> param = new HashMap<String, Object>(); | |
| 957 | + HashMap<String,Object> param ; | |
| 955 | 958 | sBuffer.append("<SKBs>"); |
| 956 | 959 | HashMap<String,String> paramMap; |
| 957 | - HashMap<String,String> otherMap = new HashMap<String, String>(); | |
| 960 | + HashMap<String,String> otherMap = new HashMap<>(); | |
| 958 | 961 | for (int i = 0; i < idArray.length; i++) { |
| 959 | 962 | ttInfo = ttInfoRepository.findOne(Long.valueOf(idArray[i])); |
| 960 | 963 | if(ttInfo == null) |
| 961 | 964 | continue; |
| 962 | 965 | ttinfoList.add(ttInfo); // 保存时刻表 |
| 966 | + // 获得时刻表 | |
| 967 | + param = new HashMap(); | |
| 963 | 968 | param.put("ttinfo.id_eq", ttInfo.getId()); |
| 964 | 969 | ttInfoDetailIterator = ttInfoDetailRepository.findAll(new CustomerSpecs<TTInfoDetail>(param), |
| 965 | 970 | new Sort(Direction.ASC, "xlDir")).iterator(); |
| 971 | + // 获得lineInformation | |
| 972 | + param = new HashMap(); | |
| 973 | + param.put("line.id_eq", ttInfo.getXl().getId()); | |
| 974 | + lineInformation = lineInformationRepository.findOne(new CustomerSpecs<LineInformation>(param)); | |
| 966 | 975 | if(ttInfoDetailIterator.hasNext()){ |
| 967 | 976 | sBuffer.append("<SKB>"); |
| 968 | 977 | sBuffer.append("<XLBM>").append(BasicData.lineId2ShangHaiCodeMap.get(ttInfo.getXl().getId())) |
| 969 | 978 | .append("</XLBM>"); |
| 970 | 979 | sBufferB = new StringBuffer(); |
| 980 | + sBufferC = new StringBuffer(); | |
| 971 | 981 | sBufferB.append("<KSRQ>").append(sdfnyr.format(ttInfo.getQyrq())).append("</KSRQ>"); |
| 972 | 982 | // 结束日期暂时不要,节假日的班次表才需要,如春节的班次表 |
| 973 | 983 | sBufferB.append("<JSRQ>").append("").append("</JSRQ>"); |
| ... | ... | @@ -975,46 +985,58 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 975 | 985 | sBufferB.append("<TBYY>").append("").append("</TBYY>"); |
| 976 | 986 | sBufferB.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); |
| 977 | 987 | sBufferB.append("<BCList>"); |
| 978 | - int num = 1; | |
| 979 | 988 | while (ttInfoDetailIterator.hasNext()) { |
| 980 | 989 | ttInfoDetail = ttInfoDetailIterator.next(); |
| 981 | - if(ttInfoDetail.getBcType().equals("in") || ttInfoDetail.getBcType().equals("out")){ | |
| 990 | + bcType = ttInfoDetail.getBcType(); | |
| 991 | + sxx = ttInfoDetail.getXlDir(); | |
| 992 | + // 进出场班次 | |
| 993 | + if(bcType.equals("in") || bcType.equals("out")){ | |
| 994 | + // 进出班次的计划里程,算空驶里程 | |
| 995 | + emptyLc = ttInfoDetail.getJhlc(); | |
| 996 | + // 总里程需要加上空驶里程 | |
| 997 | + zlc += emptyLc; | |
| 982 | 998 | continue; |
| 983 | 999 | } |
| 984 | - if(num++ == 1){ | |
| 985 | - sBufferA = new StringBuffer(); | |
| 986 | - sBufferA.append("<JHZLC>").append(ttInfoDetail.getJhlc()).append("</JHZLC>"); | |
| 987 | - sBufferA.append("<JHYYLC>").append(ttInfoDetail.getJhlc()).append("</JHYYLC>"); | |
| 988 | - sBuffer.append(sBufferA).append(sBufferB); | |
| 989 | - } | |
| 990 | 1000 | // 如果发车时间格式错误,忽略此条 |
| 991 | 1001 | if(changeTimeFormat(ttInfoDetail) == null){ |
| 992 | 1002 | continue; |
| 993 | 1003 | } |
| 994 | - sBuffer.append("<BC>"); | |
| 995 | - sBuffer.append("<LPBH>").append(ttInfoDetail.getLp().getLpNo()).append("</LPBH>"); | |
| 996 | - sBuffer.append("<SXX>").append(ttInfoDetail.getXlDir()).append("</SXX>"); | |
| 997 | - sBuffer.append("<FCZDMC>").append(BasicData.stationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir() | |
| 1004 | + sBufferC.append("<BC>"); | |
| 1005 | + sBufferC.append("<LPBH>").append(ttInfoDetail.getLp().getLpNo()).append("</LPBH>"); | |
| 1006 | + sBufferC.append("<SXX>").append(sxx).append("</SXX>"); | |
| 1007 | + sBufferC.append("<FCZDMC>").append(BasicData.stationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir() | |
| 998 | 1008 | +"_"+ttInfoDetail.getQdzCode())).append("</FCZDMC>"); |
| 999 | 1009 | // 起点站的参数 |
| 1000 | 1010 | otherMap.put("stationMark","B"); |
| 1001 | 1011 | paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); |
| 1002 | - sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</ZDXH>"); | |
| 1003 | - sBuffer.append("<JHFCSJ>").append(changeTimeFormat(ttInfoDetail)).append("</JHFCSJ>"); | |
| 1004 | - sBuffer.append("<DDZDMC>").append(BasicData.stationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir() | |
| 1012 | + sBufferC.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</ZDXH>"); | |
| 1013 | + sBufferC.append("<JHFCSJ>").append(changeTimeFormat(ttInfoDetail)).append("</JHFCSJ>"); | |
| 1014 | + sBufferC.append("<DDZDMC>").append(BasicData.stationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir() | |
| 1005 | 1015 | +"_"+ttInfoDetail.getZdzCode())).append("</DDZDMC>"); |
| 1006 | 1016 | // 起点站的参数 |
| 1007 | 1017 | otherMap.put("stationMark","E"); |
| 1008 | 1018 | paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); |
| 1009 | - sBuffer.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</DDXH>"); | |
| 1010 | - sBuffer.append("<JHDDSJ>").append(calcDdsj(ttInfoDetail.getFcsj(),ttInfoDetail.getBcsj())).append("</JHDDSJ>"); | |
| 1011 | - sBuffer.append("</BC>"); | |
| 1019 | + sBufferC.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</DDXH>"); | |
| 1020 | + sBufferC.append("<JHDDSJ>").append(calcDdsj(ttInfoDetail.getFcsj(),ttInfoDetail.getBcsj())).append("</JHDDSJ>"); | |
| 1021 | + sBufferC.append("</BC>"); | |
| 1022 | + // 0:上行;1:下行 | |
| 1023 | + if("0".equals(sxx)){ | |
| 1024 | + singleLc = lineInformation.getUpMileage(); | |
| 1025 | + }else{ | |
| 1026 | + singleLc = lineInformation.getDownMileage(); | |
| 1027 | + } | |
| 1028 | + zlc += singleLc ; | |
| 1029 | + yylc += singleLc; | |
| 1012 | 1030 | } |
| 1013 | - sBuffer.append("</BCList>"); | |
| 1014 | - sBuffer.append("</SKB>"); | |
| 1031 | + sBufferC.append("</BCList>"); | |
| 1032 | + sBufferC.append("</SKB>"); | |
| 1015 | 1033 | } |
| 1016 | 1034 | } |
| 1017 | - sBuffer.append("</SKBs>"); | |
| 1035 | + | |
| 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).append("</SKBs>"); | |
| 1018 | 1040 | if(ssop.setSKB(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ |
| 1019 | 1041 | result = "success"; |
| 1020 | 1042 | SKBUploadLogger skbUploadLogger ; | ... | ... |