Commit 5bf9656ad66c5e5cec26f2983cde3bcdc3fd03ba
1 parent
5c62f2ed
运管处时刻表调整
Showing
1 changed file
with
129 additions
and
118 deletions
src/main/java/com/bsth/service/impl/TrafficManageServiceImpl.java
| 1 | 1 | package com.bsth.service.impl; |
| 2 | 2 | |
| 3 | -import java.io.BufferedOutputStream; | |
| 4 | -import java.io.File; | |
| 5 | -import java.io.FileOutputStream; | |
| 6 | -import java.io.IOException; | |
| 7 | -import java.sql.Connection; | |
| 8 | -import java.sql.PreparedStatement; | |
| 9 | -import java.sql.ResultSet; | |
| 10 | -import java.text.DecimalFormat; | |
| 11 | -import java.text.SimpleDateFormat; | |
| 12 | -import java.util.Date; | |
| 13 | -import java.util.HashMap; | |
| 14 | -import java.util.Iterator; | |
| 15 | -import java.util.List; | |
| 16 | -import java.util.Map; | |
| 17 | -import java.util.Set; | |
| 18 | - | |
| 19 | -import org.apache.commons.lang.time.DateUtils; | |
| 20 | -import org.slf4j.Logger; | |
| 21 | -import org.slf4j.LoggerFactory; | |
| 22 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 23 | -import org.springframework.data.domain.Sort; | |
| 24 | -import org.springframework.data.domain.Sort.Direction; | |
| 25 | -import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; | |
| 26 | -import org.springframework.stereotype.Service; | |
| 27 | - | |
| 28 | 3 | import com.bsth.data.BasicData; |
| 29 | -import com.bsth.entity.Cars; | |
| 30 | -import com.bsth.entity.Line; | |
| 31 | -import com.bsth.entity.LineInformation; | |
| 32 | -import com.bsth.entity.Personnel; | |
| 33 | -import com.bsth.entity.StationRoute; | |
| 4 | +import com.bsth.entity.*; | |
| 34 | 5 | import com.bsth.entity.realcontrol.ChildTaskPlan; |
| 35 | 6 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 36 | 7 | import com.bsth.entity.schedule.SchedulePlanInfo; |
| 37 | 8 | import com.bsth.entity.schedule.TTInfo; |
| 38 | 9 | import com.bsth.entity.schedule.TTInfoDetail; |
| 39 | 10 | import com.bsth.entity.search.CustomerSpecs; |
| 40 | -import com.bsth.repository.CarsRepository; | |
| 41 | -import com.bsth.repository.LineInformationRepository; | |
| 42 | -import com.bsth.repository.LineRepository; | |
| 43 | -import com.bsth.repository.PersonnelRepository; | |
| 44 | -import com.bsth.repository.StationRouteRepository; | |
| 45 | -import com.bsth.repository.schedule.CarConfigInfoRepository; | |
| 46 | -import com.bsth.repository.schedule.EmployeeConfigInfoRepository; | |
| 47 | -import com.bsth.repository.schedule.SchedulePlanInfoRepository; | |
| 48 | -import com.bsth.repository.schedule.TTInfoDetailRepository; | |
| 49 | -import com.bsth.repository.schedule.TTInfoRepository; | |
| 11 | +import com.bsth.repository.*; | |
| 12 | +import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | |
| 13 | +import com.bsth.repository.schedule.*; | |
| 50 | 14 | import com.bsth.service.TrafficManageService; |
| 51 | 15 | import com.bsth.util.TimeUtils; |
| 52 | 16 | import com.bsth.util.db.DBUtils_MS; |
| ... | ... | @@ -54,7 +18,25 @@ import com.bsth.webService.trafficManage.geotool.services.Internal; |
| 54 | 18 | import com.bsth.webService.trafficManage.geotool.services.InternalPortType; |
| 55 | 19 | import com.bsth.webService.trafficManage.org.tempuri.WebServiceLocator; |
| 56 | 20 | import com.bsth.webService.trafficManage.org.tempuri.WebServiceSoap; |
| 57 | -import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | |
| 21 | +import org.apache.commons.lang.time.DateUtils; | |
| 22 | +import org.slf4j.Logger; | |
| 23 | +import org.slf4j.LoggerFactory; | |
| 24 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 25 | +import org.springframework.data.domain.Sort; | |
| 26 | +import org.springframework.data.domain.Sort.Direction; | |
| 27 | +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; | |
| 28 | +import org.springframework.stereotype.Service; | |
| 29 | + | |
| 30 | +import java.io.BufferedOutputStream; | |
| 31 | +import java.io.File; | |
| 32 | +import java.io.FileOutputStream; | |
| 33 | +import java.io.IOException; | |
| 34 | +import java.sql.Connection; | |
| 35 | +import java.sql.PreparedStatement; | |
| 36 | +import java.sql.ResultSet; | |
| 37 | +import java.text.DecimalFormat; | |
| 38 | +import java.text.SimpleDateFormat; | |
| 39 | +import java.util.*; | |
| 58 | 40 | /** |
| 59 | 41 | * |
| 60 | 42 | * @ClassName: TrafficManageServiceImpl(运管处接口service业务层实现类) |
| ... | ... | @@ -63,7 +45,7 @@ import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; |
| 63 | 45 | * |
| 64 | 46 | * @Description: TODO(运管处接口service业务层) |
| 65 | 47 | * |
| 66 | - * @Author bsth@z | |
| 48 | + * @Author bsth@zq | |
| 67 | 49 | * |
| 68 | 50 | * @Date 2016年10月28日 上午9:21:17 |
| 69 | 51 | * |
| ... | ... | @@ -158,8 +140,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 158 | 140 | @Override |
| 159 | 141 | public String setXL() { |
| 160 | 142 | String result = "failure"; |
| 143 | + StringBuffer sBuffer = new StringBuffer(); | |
| 161 | 144 | try { |
| 162 | - StringBuffer sBuffer = new StringBuffer(); ; | |
| 163 | 145 | Iterator<Line> lineIterator = lineRepository.findAll().iterator(); |
| 164 | 146 | Line line = null; |
| 165 | 147 | List<StationRoute> stationsList = null;// 站点路由集 |
| ... | ... | @@ -168,7 +150,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 168 | 150 | sBuffer.append("<XLs>"); |
| 169 | 151 | while(lineIterator.hasNext()){ |
| 170 | 152 | line = lineIterator.next(); |
| 171 | - if(BasicData.lineId2ShangHaiCodeMap.get(line.getId()) == null){ | |
| 153 | + if(BasicData.lineId2ShangHaiCodeMap.get(line.getId()) == null | |
| 154 | + || line.getInUse() == 0){ | |
| 172 | 155 | continue; |
| 173 | 156 | } |
| 174 | 157 | sBuffer.append("<XL>"); |
| ... | ... | @@ -208,7 +191,6 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 208 | 191 | sBuffer.append("</XLs>"); |
| 209 | 192 | System.out.println(sBuffer.toString()); |
| 210 | 193 | if(sBuffer.indexOf("<XL>") != -1){ |
| 211 | - logger.info("setXL:"+sBuffer.toString()); | |
| 212 | 194 | String portResult = portType.setXL(userNameXl, passwordXl, sBuffer.toString()); |
| 213 | 195 | String portArray[] = portResult.split("\n"); |
| 214 | 196 | if(portArray.length >= 4){ |
| ... | ... | @@ -224,8 +206,10 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 224 | 206 | } |
| 225 | 207 | } |
| 226 | 208 | } catch (Exception e) { |
| 209 | + logger.error("setXL:",e); | |
| 227 | 210 | e.printStackTrace(); |
| 228 | 211 | }finally{ |
| 212 | + logger.info("setXL:"+sBuffer.toString()); | |
| 229 | 213 | logger.info("setXL:"+result); |
| 230 | 214 | } |
| 231 | 215 | return result; |
| ... | ... | @@ -237,8 +221,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 237 | 221 | @Override |
| 238 | 222 | public String setCL() { |
| 239 | 223 | String result = "failure"; |
| 224 | + StringBuffer sBuffer =new StringBuffer(); | |
| 240 | 225 | try { |
| 241 | - StringBuffer sBuffer =new StringBuffer(); | |
| 242 | 226 | sBuffer.append("<CLs>"); |
| 243 | 227 | Cars cars = null; |
| 244 | 228 | String company; |
| ... | ... | @@ -258,13 +242,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 258 | 242 | sBuffer.append("</CL>"); |
| 259 | 243 | } |
| 260 | 244 | sBuffer.append("</CLs>"); |
| 261 | - logger.info("setCL:"+sBuffer.toString()); | |
| 262 | 245 | if(ssop.setCL(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ |
| 263 | 246 | result = "success"; |
| 264 | 247 | } |
| 265 | 248 | } catch (Exception e) { |
| 249 | + logger.error("setCL:",e); | |
| 266 | 250 | e.printStackTrace(); |
| 267 | 251 | }finally{ |
| 252 | + logger.info("setCL:"+sBuffer.toString()); | |
| 268 | 253 | logger.info("setCL:"+result); |
| 269 | 254 | } |
| 270 | 255 | return result; |
| ... | ... | @@ -276,8 +261,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 276 | 261 | @Override |
| 277 | 262 | public String setSJ() { |
| 278 | 263 | String result = "failure"; |
| 264 | + StringBuffer sBuffer =new StringBuffer(); | |
| 279 | 265 | try { |
| 280 | - StringBuffer sBuffer =new StringBuffer(); | |
| 281 | 266 | sBuffer.append("<SJs>"); |
| 282 | 267 | Personnel personnel = null; |
| 283 | 268 | String company; |
| ... | ... | @@ -295,13 +280,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 295 | 280 | sBuffer.append("</SJ>"); |
| 296 | 281 | } |
| 297 | 282 | sBuffer.append("</SJs>"); |
| 298 | - logger.info("setSJ:"+sBuffer.toString()); | |
| 299 | 283 | if(ssop.setSJ(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ |
| 300 | 284 | result = "success"; |
| 301 | 285 | }; |
| 302 | 286 | } catch (Exception e) { |
| 287 | + logger.error("setSJ:",e); | |
| 303 | 288 | e.printStackTrace(); |
| 304 | 289 | }finally{ |
| 290 | + logger.info("setSJ:"+sBuffer.toString()); | |
| 305 | 291 | logger.info("setSJ:"+result); |
| 306 | 292 | } |
| 307 | 293 | return result; |
| ... | ... | @@ -309,15 +295,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 309 | 295 | |
| 310 | 296 | /** |
| 311 | 297 | * 上传路单 |
| 312 | - * @param date | |
| 313 | - * @return xml格式的字符串 | |
| 298 | + * @return 上传成功标识 | |
| 314 | 299 | */ |
| 315 | 300 | public String setLD(){ |
| 316 | 301 | String result = "failure"; |
| 317 | 302 | // 取昨天 的日期 |
| 318 | 303 | String date = sdfnyr.format(DateUtils.addDays(new Date(), -1)); |
| 304 | + StringBuffer sf = new StringBuffer(); | |
| 319 | 305 | try { |
| 320 | - StringBuffer sf = new StringBuffer(); | |
| 321 | 306 | sf.append("<DLDS>"); |
| 322 | 307 | List<ScheduleRealInfo> list = scheduleRealInfoRepository.setLD(date); |
| 323 | 308 | List<ScheduleRealInfo> listGroup = scheduleRealInfoRepository.setLDGroup(date); |
| ... | ... | @@ -368,20 +353,19 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 368 | 353 | sf.append("</LD>"); |
| 369 | 354 | } |
| 370 | 355 | } |
| 371 | - | |
| 372 | 356 | sf.append("</LDList>"); |
| 373 | 357 | sf.append("</DLD>"); |
| 374 | 358 | } |
| 375 | 359 | } |
| 376 | - | |
| 377 | 360 | sf.append("</DLDS>"); |
| 378 | - logger.info("setLD:"+sf.toString()); | |
| 379 | 361 | if(ssop.setLD(userNameOther, passwordOther, sf.toString()).isSuccess()){ |
| 380 | 362 | result = "success"; |
| 381 | 363 | } |
| 382 | 364 | } catch (Exception e) { |
| 365 | + logger.error("setLD:",e); | |
| 383 | 366 | e.printStackTrace(); |
| 384 | 367 | }finally{ |
| 368 | + logger.info("setLD:"+sf.toString()); | |
| 385 | 369 | logger.info("setLD:"+result); |
| 386 | 370 | } |
| 387 | 371 | return result; |
| ... | ... | @@ -389,15 +373,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 389 | 373 | |
| 390 | 374 | /** |
| 391 | 375 | * 上传里程油耗 |
| 392 | - * @param date | |
| 393 | - * @return | |
| 376 | + * @return 上传成功标识 | |
| 394 | 377 | */ |
| 395 | 378 | public String setLCYH(){ |
| 396 | 379 | String result = "failure"; |
| 397 | 380 | // 取昨天 的日期 |
| 398 | 381 | String date = sdfnyr.format(DateUtils.addDays(new Date(), -1)); |
| 382 | + StringBuffer sf = new StringBuffer(); | |
| 399 | 383 | try { |
| 400 | - StringBuffer sf = new StringBuffer(); | |
| 401 | 384 | sf.append("<LCYHS>"); |
| 402 | 385 | List<ScheduleRealInfo> listGroup = scheduleRealInfoRepository.setLCYHGroup(date); |
| 403 | 386 | List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDate(date); |
| ... | ... | @@ -451,13 +434,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 451 | 434 | } |
| 452 | 435 | } |
| 453 | 436 | sf.append("</LCYHS>"); |
| 454 | - logger.info("setLCYH:"+sf.toString()); | |
| 455 | 437 | if(ssop.setLCYH(userNameOther, passwordOther, sf.toString()).isSuccess()){ |
| 456 | 438 | result = "success"; |
| 457 | 439 | } |
| 458 | 440 | } catch (Exception e) { |
| 441 | + logger.error("setLCYH:",e); | |
| 459 | 442 | e.printStackTrace(); |
| 460 | 443 | }finally{ |
| 444 | + logger.info("setLCYH:"+sf.toString()); | |
| 461 | 445 | logger.info("setLCYH:"+result); |
| 462 | 446 | } |
| 463 | 447 | return result; |
| ... | ... | @@ -471,8 +455,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 471 | 455 | String result = "failure"; |
| 472 | 456 | // 取昨天 的日期 |
| 473 | 457 | String date = sdfnyr.format(DateUtils.addDays(new Date(), -1)); |
| 458 | + StringBuffer sf = new StringBuffer(); | |
| 474 | 459 | try { |
| 475 | - StringBuffer sf = new StringBuffer(); | |
| 476 | 460 | sf.append("<DDRBS>"); |
| 477 | 461 | List<ScheduleRealInfo> listGroup = scheduleRealInfoRepository.setDDRBGroup(date); |
| 478 | 462 | List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDate(date); |
| ... | ... | @@ -554,13 +538,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 554 | 538 | } |
| 555 | 539 | } |
| 556 | 540 | sf.append("</DDRBS>"); |
| 557 | - logger.info("setDDRB:"+sf.toString()); | |
| 558 | 541 | if(ssop.setDDRB(userNameOther, passwordOther, sf.toString()).isSuccess()){ |
| 559 | 542 | result = "success"; |
| 560 | 543 | } |
| 561 | 544 | } catch (Exception e) { |
| 545 | + logger.error("setDDRB:",e); | |
| 562 | 546 | e.printStackTrace(); |
| 563 | 547 | }finally{ |
| 548 | + logger.info("setDDRB:"+sf.toString()); | |
| 564 | 549 | logger.info("setDDRB:"+result); |
| 565 | 550 | } |
| 566 | 551 | return result; |
| ... | ... | @@ -572,8 +557,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 572 | 557 | @Override |
| 573 | 558 | public String setJHBC() { |
| 574 | 559 | String result = "failure"; |
| 560 | + StringBuffer sBuffer =new StringBuffer(); | |
| 575 | 561 | try { |
| 576 | - StringBuffer sBuffer =new StringBuffer(); | |
| 577 | 562 | sBuffer.append("<JHBCs>"); |
| 578 | 563 | // 声明变量 |
| 579 | 564 | SchedulePlanInfo schedulePlanInfo = null; |
| ... | ... | @@ -633,13 +618,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 633 | 618 | } |
| 634 | 619 | } |
| 635 | 620 | sBuffer.append("</JHBCs>"); |
| 636 | - logger.info("setJHBC:"+sBuffer.toString()); | |
| 637 | 621 | if(ssop.setJHBC(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ |
| 638 | 622 | result = "success"; |
| 639 | 623 | } |
| 640 | 624 | } catch (Exception e) { |
| 625 | + logger.error("setJHBC:",e); | |
| 641 | 626 | e.printStackTrace(); |
| 642 | 627 | }finally{ |
| 628 | + logger.info("setJHBC:"+sBuffer.toString()); | |
| 643 | 629 | logger.info("setJHBC:"+result); |
| 644 | 630 | } |
| 645 | 631 | return result; |
| ... | ... | @@ -651,14 +637,15 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 651 | 637 | @Override |
| 652 | 638 | public String setSKB(String ids) { |
| 653 | 639 | String result = "failure"; |
| 640 | + StringBuffer sBuffer = new StringBuffer(); | |
| 654 | 641 | try { |
| 655 | 642 | String[] idArray = ids.split(","); |
| 656 | - StringBuffer sBuffer = new StringBuffer(); | |
| 643 | + StringBuffer sBufferA; | |
| 644 | + StringBuffer sBufferB; | |
| 657 | 645 | TTInfo ttInfo; |
| 658 | - TTInfoDetail ttInfoDetail; | |
| 646 | + TTInfoDetail ttInfoDetail = null; | |
| 659 | 647 | Iterator<TTInfoDetail> ttInfoDetailIterator; |
| 660 | 648 | HashMap<String,Object> param = new HashMap<String, Object>(); |
| 661 | - String ttinfoJhlc = null;//计划总里程 | |
| 662 | 649 | String lineCode ; |
| 663 | 650 | sBuffer.append("<SKBs>"); |
| 664 | 651 | for (int i = 0; i < idArray.length; i++) { |
| ... | ... | @@ -668,57 +655,61 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 668 | 655 | param.put("ttinfo.id_eq", ttInfo.getId()); |
| 669 | 656 | ttInfoDetailIterator = ttInfoDetailRepository.findAll(new CustomerSpecs<TTInfoDetail>(param), |
| 670 | 657 | new Sort(Direction.ASC, "xlDir")).iterator(); |
| 671 | - sBuffer.append("<SKB>"); | |
| 672 | - sBuffer.append("<XLBM>").append(BasicData.lineId2ShangHaiCodeMap.get(ttInfo.getXl().getId())) | |
| 673 | - .append("</XLBM>"); | |
| 674 | - ttinfoJhlc = new String(); | |
| 675 | - sBuffer.append("<JHZLC>").append(ttinfoJhlc).append("</JHZLC>"); | |
| 676 | - sBuffer.append("<JHYYLC>").append(ttinfoJhlc).append("</JHYYLC>"); | |
| 677 | - sBuffer.append("<KSRQ>").append(sdfnyr.format(ttInfo.getQyrq())).append("</KSRQ>"); | |
| 678 | - sBuffer.append("<JSRQ>").append(sdfnyr.format(ttInfo.getQyrq())).append("</JSRQ>");///////// | |
| 679 | - sBuffer.append("<ZJZX>").append(changeRuleDay(ttInfo.getRule_days())).append("</ZJZX>"); | |
| 680 | - sBuffer.append("<TBYY>").append("").append("</TBYY>"); | |
| 681 | - sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | |
| 682 | - int num = 1; | |
| 683 | - // 加上<BCList> | |
| 684 | 658 | if(ttInfoDetailIterator.hasNext()){ |
| 685 | - sBuffer.append("<BCList>"); | |
| 686 | - } | |
| 687 | - while (ttInfoDetailIterator.hasNext()) { | |
| 688 | - ttInfoDetail = ttInfoDetailIterator.next(); | |
| 689 | - if(ttInfoDetail.getBcType().equals("in") || ttInfoDetail.getBcType().equals("out")){ | |
| 690 | - continue; | |
| 659 | + sBuffer.append("<SKB>"); | |
| 660 | + sBuffer.append("<XLBM>").append(BasicData.lineId2ShangHaiCodeMap.get(ttInfo.getXl().getId())) | |
| 661 | + .append("</XLBM>"); | |
| 662 | + sBufferB = new StringBuffer(); | |
| 663 | + sBufferB.append("<KSRQ>").append(sdfnyr.format(ttInfo.getQyrq())).append("</KSRQ>"); | |
| 664 | + // 结束日期暂时不要,节假日的班次表才需要,如春节的班次表 | |
| 665 | + sBufferB.append("<JSRQ>").append("").append("</JSRQ>"); | |
| 666 | + sBufferB.append("<ZJZX>").append(changeRuleDay(ttInfo.getRule_days())).append("</ZJZX>"); | |
| 667 | + sBufferB.append("<TBYY>").append("").append("</TBYY>"); | |
| 668 | + sBufferB.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | |
| 669 | + sBufferB.append("<BCList>"); | |
| 670 | + int num = 1; | |
| 671 | + while (ttInfoDetailIterator.hasNext()) { | |
| 672 | + ttInfoDetail = ttInfoDetailIterator.next(); | |
| 673 | + if(ttInfoDetail.getBcType().equals("in") || ttInfoDetail.getBcType().equals("out")){ | |
| 674 | + continue; | |
| 675 | + } | |
| 676 | + if(num++ == 1){ | |
| 677 | + sBufferA = new StringBuffer(); | |
| 678 | + sBufferA.append("<JHZLC>").append(ttInfoDetail.getJhlc()).append("</JHZLC>"); | |
| 679 | + sBufferA.append("<JHYYLC>").append(ttInfoDetail.getJhlc()).append("</JHYYLC>"); | |
| 680 | + sBuffer.append(sBufferA).append(sBufferB); | |
| 681 | + } | |
| 682 | + lineCode = ttInfoDetail.getXl().getLineCode(); | |
| 683 | + // 如果发车时间格式错误,忽略此条 | |
| 684 | + if(changeTimeFormat(ttInfoDetail) == null){ | |
| 685 | + continue; | |
| 686 | + } | |
| 687 | + sBuffer.append("<BC>"); | |
| 688 | + sBuffer.append("<LPBH>").append(ttInfoDetail.getLp().getLpNo()).append("</LPBH>"); | |
| 689 | + sBuffer.append("<SXX>").append(ttInfoDetail.getXlDir()).append("</SXX>"); | |
| 690 | + sBuffer.append("<FCZDMC>").append(ttInfoDetail.getQdz().getStationName()).append("</FCZDMC>"); | |
| 691 | + sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName( | |
| 692 | + lineCode, ttInfoDetail.getXlDir(), ttInfoDetail.getQdz().getStationName())).append("</ZDXH>"); | |
| 693 | + sBuffer.append("<JHFCSJ>").append(changeTimeFormat(ttInfoDetail)).append("</JHFCSJ>"); | |
| 694 | + sBuffer.append("<DDZDMC>").append(ttInfoDetail.getZdz().getStationName()).append("</DDZDMC>"); | |
| 695 | + sBuffer.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName( | |
| 696 | + lineCode, ttInfoDetail.getXlDir(), ttInfoDetail.getZdz().getStationName())).append("</DDXH>"); | |
| 697 | + sBuffer.append("<JHDDSJ>").append(calcDdsj(ttInfoDetail.getFcsj(),ttInfoDetail.getBcsj())).append("</JHDDSJ>"); | |
| 698 | + sBuffer.append("</BC>"); | |
| 691 | 699 | } |
| 692 | - ttinfoJhlc = ttInfoDetail.getJhlc()+"";// 设置计划总里程 | |
| 693 | - lineCode = ttInfoDetail.getXl().getLineCode(); | |
| 694 | - sBuffer.append("<BC>"); | |
| 695 | - sBuffer.append("<LPBH>").append(ttInfoDetail.getLp().getLpNo()).append("</LPBH>"); | |
| 696 | - sBuffer.append("<SXX>").append(ttInfoDetail.getXlDir()).append("</SXX>"); | |
| 697 | - sBuffer.append("<FCZDMC>").append(ttInfoDetail.getQdz().getStationName()).append("</FCZDMC>"); | |
| 698 | - sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName( | |
| 699 | - lineCode, ttInfoDetail.getXlDir(), ttInfoDetail.getQdz().getStationName())).append("</ZDXH>"); | |
| 700 | - sBuffer.append("<JHFCSJ>").append(ttInfoDetail.getFcsj()).append("</JHFCSJ>"); | |
| 701 | - sBuffer.append("<DDZDMC>").append(ttInfoDetail.getZdz().getStationName()).append("</DDZDMC>"); | |
| 702 | - sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName( | |
| 703 | - lineCode, ttInfoDetail.getXlDir(), ttInfoDetail.getZdz().getStationName())).append("</ZDXH>"); | |
| 704 | - sBuffer.append("<JHDDSJ>").append(calcDdsj(ttInfoDetail.getFcsj(),ttInfoDetail.getBcsj())).append("</JHDDSJ>"); | |
| 705 | - sBuffer.append("</BC>"); | |
| 706 | - | |
| 707 | - num++; | |
| 708 | - } | |
| 709 | - if(sBuffer.indexOf("<BCList>") != -1){ | |
| 710 | 700 | sBuffer.append("</BCList>"); |
| 701 | + sBuffer.append("</SKB>"); | |
| 711 | 702 | } |
| 712 | - sBuffer.append("</SKB>"); | |
| 713 | 703 | } |
| 714 | 704 | sBuffer.append("</SKBs>"); |
| 715 | - logger.info("setSKB:"+sBuffer.toString()); | |
| 716 | 705 | if(ssop.setSKB(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ |
| 717 | 706 | result = "success"; |
| 718 | 707 | } |
| 719 | 708 | } catch (Exception e) { |
| 709 | + logger.error("setSKB:", e); | |
| 720 | 710 | e.printStackTrace(); |
| 721 | 711 | }finally{ |
| 712 | + logger.info("setSKB:"+sBuffer.toString()); | |
| 722 | 713 | logger.info("setSKB:"+result); |
| 723 | 714 | } |
| 724 | 715 | return result; |
| ... | ... | @@ -730,8 +721,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 730 | 721 | @Override |
| 731 | 722 | public String setXLPC() { |
| 732 | 723 | String result = "failure"; |
| 724 | + StringBuffer sBuffer =new StringBuffer(); | |
| 733 | 725 | try { |
| 734 | - StringBuffer sBuffer =new StringBuffer(); | |
| 735 | 726 | sBuffer.append("<XLPCs>"); |
| 736 | 727 | // 声明变量 |
| 737 | 728 | Line line = null; |
| ... | ... | @@ -773,13 +764,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 773 | 764 | sBuffer.append("</XLPC>"); |
| 774 | 765 | } |
| 775 | 766 | sBuffer.append("</XLPCs>"); |
| 776 | - logger.info("setXLPC:"+sBuffer.toString()); | |
| 777 | 767 | if(ssop.setXLPC(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ |
| 778 | 768 | result = "success"; |
| 779 | 769 | } |
| 780 | 770 | } catch (Exception e) { |
| 771 | + logger.error("setXLPC:",e); | |
| 781 | 772 | e.printStackTrace(); |
| 782 | 773 | }finally{ |
| 774 | + logger.info("setXLPC:"+sBuffer.toString()); | |
| 783 | 775 | logger.info("setXLPC:"+result); |
| 784 | 776 | } |
| 785 | 777 | return result; |
| ... | ... | @@ -832,13 +824,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 832 | 824 | sBuffer.append("</CS>"); |
| 833 | 825 | } |
| 834 | 826 | sBuffer.append("</CSs>"); |
| 835 | - logger.info("setCS:"+sBuffer.toString()); | |
| 836 | 827 | if(ssop.setCS(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ |
| 837 | 828 | result = "success"; |
| 838 | 829 | } |
| 839 | 830 | } catch (Exception e) { |
| 831 | + logger.error("setCS:",e); | |
| 840 | 832 | e.printStackTrace(); |
| 841 | 833 | } finally { |
| 834 | + logger.info("setCS:"+sBuffer.toString()); | |
| 842 | 835 | logger.info("setCS:"+result); |
| 843 | 836 | DBUtils_MS.close(rs, ps, conn); |
| 844 | 837 | } |
| ... | ... | @@ -949,11 +942,11 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 949 | 942 | min = fullTime % 60; |
| 950 | 943 | sumHour = Integer.valueOf(fcsjArray[0])+hour; |
| 951 | 944 | if(sumHour >= 24){ |
| 952 | - result = sumHour - 24+":"; | |
| 945 | + result = String.format("%02d",sumHour - 24); | |
| 953 | 946 | }else{ |
| 954 | - result = sumHour +":"; | |
| 947 | + result = String.format("%02d",sumHour);; | |
| 955 | 948 | } |
| 956 | - result +=String.format("%02d", min); | |
| 949 | + result +=":"+String.format("%02d", min); | |
| 957 | 950 | }else{ |
| 958 | 951 | result = fcsj; |
| 959 | 952 | } |
| ... | ... | @@ -961,6 +954,26 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 961 | 954 | } |
| 962 | 955 | |
| 963 | 956 | /** |
| 957 | + * 改变时间格式 | |
| 958 | + * @param ttInfoDetail 时刻表详细 | |
| 959 | + * @return xx:yy | |
| 960 | + */ | |
| 961 | + private String changeTimeFormat(TTInfoDetail ttInfoDetail){ | |
| 962 | + String result = "00:00"; | |
| 963 | + String fcsj = ttInfoDetail.getFcsj(); | |
| 964 | + if(fcsj.indexOf(":") != -1){ | |
| 965 | + // 时和分隔开 | |
| 966 | + String[] fcsjArray = fcsj.split(":"); | |
| 967 | + result = String.format("%02d", Integer.valueOf(fcsjArray[0]))+":"; | |
| 968 | + result +=String.format("%02d", Integer.valueOf(fcsjArray[1])); | |
| 969 | + }else{ | |
| 970 | + result = null; | |
| 971 | + logger.info("setSKB:发车时间错误:ttInfoDetail.id="+ttInfoDetail.getId()); | |
| 972 | + } | |
| 973 | + return result; | |
| 974 | + } | |
| 975 | + | |
| 976 | + /** | |
| 964 | 977 | * 拼装线路计划班次表的XML |
| 965 | 978 | * @param sBuffer |
| 966 | 979 | * @param schedulePlanInfo |
| ... | ... | @@ -993,7 +1006,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 993 | 1006 | flag = 0; |
| 994 | 1007 | } |
| 995 | 1008 | result += flag; |
| 996 | - if(i !=ruleDayArray.length ){ | |
| 1009 | + if(i !=ruleDayArray.length -1){ | |
| 997 | 1010 | result +=","; |
| 998 | 1011 | } |
| 999 | 1012 | } |
| ... | ... | @@ -1017,15 +1030,15 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 1017 | 1030 | } |
| 1018 | 1031 | } |
| 1019 | 1032 | /** |
| 1020 | - * @param stations 站点路由集 | |
| 1033 | + * @param stationsList 站点路由集 | |
| 1021 | 1034 | * @param sBuffer sBuffer |
| 1022 | - * @param StartId 站点序号起始ID | |
| 1035 | + * @param startId 站点序号起始ID | |
| 1023 | 1036 | * |
| 1024 | 1037 | * @return 站点序号累加后的ID |
| 1025 | 1038 | */ |
| 1026 | 1039 | private int packagStationXml(List<StationRoute> stationsList,StringBuffer sBuffer,int startId){ |
| 1027 | 1040 | int size = stationsList.size(); |
| 1028 | - StationRoute srRoute = null; | |
| 1041 | + StationRoute srRoute; | |
| 1029 | 1042 | String zdlx ;// 站点类型:0:起点站、1:终点站、2:中途站 |
| 1030 | 1043 | for (int i = 0; i < size; i++) { |
| 1031 | 1044 | srRoute = stationsList.get(i); |
| ... | ... | @@ -1062,9 +1075,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 1062 | 1075 | */ |
| 1063 | 1076 | private Integer getYgcStationNumByLineCodeAndDirectionAndStationName(String lineCode,String direction,String stationName){ |
| 1064 | 1077 | Integer number = 0; |
| 1065 | - Map<String, Map> dirs2Statioin = BasicData.stationName2YgcNumber.get(lineCode); | |
| 1066 | - Map<String, Integer> station2Number = dirs2Statioin.get(direction); | |
| 1067 | - number = station2Number.get(stationName); | |
| 1078 | + number = BasicData.stationName2YgcNumber.get(lineCode+"_"+direction+"_"+stationName); | |
| 1068 | 1079 | return number; |
| 1069 | 1080 | } |
| 1070 | 1081 | } | ... | ... |