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 | package com.bsth.service.impl; | 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 | import com.bsth.data.BasicData; | 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 | import com.bsth.entity.realcontrol.ChildTaskPlan; | 5 | import com.bsth.entity.realcontrol.ChildTaskPlan; |
| 35 | import com.bsth.entity.realcontrol.ScheduleRealInfo; | 6 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 36 | import com.bsth.entity.schedule.SchedulePlanInfo; | 7 | import com.bsth.entity.schedule.SchedulePlanInfo; |
| 37 | import com.bsth.entity.schedule.TTInfo; | 8 | import com.bsth.entity.schedule.TTInfo; |
| 38 | import com.bsth.entity.schedule.TTInfoDetail; | 9 | import com.bsth.entity.schedule.TTInfoDetail; |
| 39 | import com.bsth.entity.search.CustomerSpecs; | 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 | import com.bsth.service.TrafficManageService; | 14 | import com.bsth.service.TrafficManageService; |
| 51 | import com.bsth.util.TimeUtils; | 15 | import com.bsth.util.TimeUtils; |
| 52 | import com.bsth.util.db.DBUtils_MS; | 16 | import com.bsth.util.db.DBUtils_MS; |
| @@ -54,7 +18,25 @@ import com.bsth.webService.trafficManage.geotool.services.Internal; | @@ -54,7 +18,25 @@ import com.bsth.webService.trafficManage.geotool.services.Internal; | ||
| 54 | import com.bsth.webService.trafficManage.geotool.services.InternalPortType; | 18 | import com.bsth.webService.trafficManage.geotool.services.InternalPortType; |
| 55 | import com.bsth.webService.trafficManage.org.tempuri.WebServiceLocator; | 19 | import com.bsth.webService.trafficManage.org.tempuri.WebServiceLocator; |
| 56 | import com.bsth.webService.trafficManage.org.tempuri.WebServiceSoap; | 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 | * @ClassName: TrafficManageServiceImpl(运管处接口service业务层实现类) | 42 | * @ClassName: TrafficManageServiceImpl(运管处接口service业务层实现类) |
| @@ -63,7 +45,7 @@ import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | @@ -63,7 +45,7 @@ import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | ||
| 63 | * | 45 | * |
| 64 | * @Description: TODO(运管处接口service业务层) | 46 | * @Description: TODO(运管处接口service业务层) |
| 65 | * | 47 | * |
| 66 | - * @Author bsth@z | 48 | + * @Author bsth@zq |
| 67 | * | 49 | * |
| 68 | * @Date 2016年10月28日 上午9:21:17 | 50 | * @Date 2016年10月28日 上午9:21:17 |
| 69 | * | 51 | * |
| @@ -158,8 +140,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -158,8 +140,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 158 | @Override | 140 | @Override |
| 159 | public String setXL() { | 141 | public String setXL() { |
| 160 | String result = "failure"; | 142 | String result = "failure"; |
| 143 | + StringBuffer sBuffer = new StringBuffer(); | ||
| 161 | try { | 144 | try { |
| 162 | - StringBuffer sBuffer = new StringBuffer(); ; | ||
| 163 | Iterator<Line> lineIterator = lineRepository.findAll().iterator(); | 145 | Iterator<Line> lineIterator = lineRepository.findAll().iterator(); |
| 164 | Line line = null; | 146 | Line line = null; |
| 165 | List<StationRoute> stationsList = null;// 站点路由集 | 147 | List<StationRoute> stationsList = null;// 站点路由集 |
| @@ -168,7 +150,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -168,7 +150,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 168 | sBuffer.append("<XLs>"); | 150 | sBuffer.append("<XLs>"); |
| 169 | while(lineIterator.hasNext()){ | 151 | while(lineIterator.hasNext()){ |
| 170 | line = lineIterator.next(); | 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 | continue; | 155 | continue; |
| 173 | } | 156 | } |
| 174 | sBuffer.append("<XL>"); | 157 | sBuffer.append("<XL>"); |
| @@ -208,7 +191,6 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -208,7 +191,6 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 208 | sBuffer.append("</XLs>"); | 191 | sBuffer.append("</XLs>"); |
| 209 | System.out.println(sBuffer.toString()); | 192 | System.out.println(sBuffer.toString()); |
| 210 | if(sBuffer.indexOf("<XL>") != -1){ | 193 | if(sBuffer.indexOf("<XL>") != -1){ |
| 211 | - logger.info("setXL:"+sBuffer.toString()); | ||
| 212 | String portResult = portType.setXL(userNameXl, passwordXl, sBuffer.toString()); | 194 | String portResult = portType.setXL(userNameXl, passwordXl, sBuffer.toString()); |
| 213 | String portArray[] = portResult.split("\n"); | 195 | String portArray[] = portResult.split("\n"); |
| 214 | if(portArray.length >= 4){ | 196 | if(portArray.length >= 4){ |
| @@ -224,8 +206,10 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -224,8 +206,10 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 224 | } | 206 | } |
| 225 | } | 207 | } |
| 226 | } catch (Exception e) { | 208 | } catch (Exception e) { |
| 209 | + logger.error("setXL:",e); | ||
| 227 | e.printStackTrace(); | 210 | e.printStackTrace(); |
| 228 | }finally{ | 211 | }finally{ |
| 212 | + logger.info("setXL:"+sBuffer.toString()); | ||
| 229 | logger.info("setXL:"+result); | 213 | logger.info("setXL:"+result); |
| 230 | } | 214 | } |
| 231 | return result; | 215 | return result; |
| @@ -237,8 +221,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -237,8 +221,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 237 | @Override | 221 | @Override |
| 238 | public String setCL() { | 222 | public String setCL() { |
| 239 | String result = "failure"; | 223 | String result = "failure"; |
| 224 | + StringBuffer sBuffer =new StringBuffer(); | ||
| 240 | try { | 225 | try { |
| 241 | - StringBuffer sBuffer =new StringBuffer(); | ||
| 242 | sBuffer.append("<CLs>"); | 226 | sBuffer.append("<CLs>"); |
| 243 | Cars cars = null; | 227 | Cars cars = null; |
| 244 | String company; | 228 | String company; |
| @@ -258,13 +242,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -258,13 +242,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 258 | sBuffer.append("</CL>"); | 242 | sBuffer.append("</CL>"); |
| 259 | } | 243 | } |
| 260 | sBuffer.append("</CLs>"); | 244 | sBuffer.append("</CLs>"); |
| 261 | - logger.info("setCL:"+sBuffer.toString()); | ||
| 262 | if(ssop.setCL(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | 245 | if(ssop.setCL(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ |
| 263 | result = "success"; | 246 | result = "success"; |
| 264 | } | 247 | } |
| 265 | } catch (Exception e) { | 248 | } catch (Exception e) { |
| 249 | + logger.error("setCL:",e); | ||
| 266 | e.printStackTrace(); | 250 | e.printStackTrace(); |
| 267 | }finally{ | 251 | }finally{ |
| 252 | + logger.info("setCL:"+sBuffer.toString()); | ||
| 268 | logger.info("setCL:"+result); | 253 | logger.info("setCL:"+result); |
| 269 | } | 254 | } |
| 270 | return result; | 255 | return result; |
| @@ -276,8 +261,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -276,8 +261,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 276 | @Override | 261 | @Override |
| 277 | public String setSJ() { | 262 | public String setSJ() { |
| 278 | String result = "failure"; | 263 | String result = "failure"; |
| 264 | + StringBuffer sBuffer =new StringBuffer(); | ||
| 279 | try { | 265 | try { |
| 280 | - StringBuffer sBuffer =new StringBuffer(); | ||
| 281 | sBuffer.append("<SJs>"); | 266 | sBuffer.append("<SJs>"); |
| 282 | Personnel personnel = null; | 267 | Personnel personnel = null; |
| 283 | String company; | 268 | String company; |
| @@ -295,13 +280,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -295,13 +280,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 295 | sBuffer.append("</SJ>"); | 280 | sBuffer.append("</SJ>"); |
| 296 | } | 281 | } |
| 297 | sBuffer.append("</SJs>"); | 282 | sBuffer.append("</SJs>"); |
| 298 | - logger.info("setSJ:"+sBuffer.toString()); | ||
| 299 | if(ssop.setSJ(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | 283 | if(ssop.setSJ(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ |
| 300 | result = "success"; | 284 | result = "success"; |
| 301 | }; | 285 | }; |
| 302 | } catch (Exception e) { | 286 | } catch (Exception e) { |
| 287 | + logger.error("setSJ:",e); | ||
| 303 | e.printStackTrace(); | 288 | e.printStackTrace(); |
| 304 | }finally{ | 289 | }finally{ |
| 290 | + logger.info("setSJ:"+sBuffer.toString()); | ||
| 305 | logger.info("setSJ:"+result); | 291 | logger.info("setSJ:"+result); |
| 306 | } | 292 | } |
| 307 | return result; | 293 | return result; |
| @@ -309,15 +295,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -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 | public String setLD(){ | 300 | public String setLD(){ |
| 316 | String result = "failure"; | 301 | String result = "failure"; |
| 317 | // 取昨天 的日期 | 302 | // 取昨天 的日期 |
| 318 | String date = sdfnyr.format(DateUtils.addDays(new Date(), -1)); | 303 | String date = sdfnyr.format(DateUtils.addDays(new Date(), -1)); |
| 304 | + StringBuffer sf = new StringBuffer(); | ||
| 319 | try { | 305 | try { |
| 320 | - StringBuffer sf = new StringBuffer(); | ||
| 321 | sf.append("<DLDS>"); | 306 | sf.append("<DLDS>"); |
| 322 | List<ScheduleRealInfo> list = scheduleRealInfoRepository.setLD(date); | 307 | List<ScheduleRealInfo> list = scheduleRealInfoRepository.setLD(date); |
| 323 | List<ScheduleRealInfo> listGroup = scheduleRealInfoRepository.setLDGroup(date); | 308 | List<ScheduleRealInfo> listGroup = scheduleRealInfoRepository.setLDGroup(date); |
| @@ -368,20 +353,19 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -368,20 +353,19 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 368 | sf.append("</LD>"); | 353 | sf.append("</LD>"); |
| 369 | } | 354 | } |
| 370 | } | 355 | } |
| 371 | - | ||
| 372 | sf.append("</LDList>"); | 356 | sf.append("</LDList>"); |
| 373 | sf.append("</DLD>"); | 357 | sf.append("</DLD>"); |
| 374 | } | 358 | } |
| 375 | } | 359 | } |
| 376 | - | ||
| 377 | sf.append("</DLDS>"); | 360 | sf.append("</DLDS>"); |
| 378 | - logger.info("setLD:"+sf.toString()); | ||
| 379 | if(ssop.setLD(userNameOther, passwordOther, sf.toString()).isSuccess()){ | 361 | if(ssop.setLD(userNameOther, passwordOther, sf.toString()).isSuccess()){ |
| 380 | result = "success"; | 362 | result = "success"; |
| 381 | } | 363 | } |
| 382 | } catch (Exception e) { | 364 | } catch (Exception e) { |
| 365 | + logger.error("setLD:",e); | ||
| 383 | e.printStackTrace(); | 366 | e.printStackTrace(); |
| 384 | }finally{ | 367 | }finally{ |
| 368 | + logger.info("setLD:"+sf.toString()); | ||
| 385 | logger.info("setLD:"+result); | 369 | logger.info("setLD:"+result); |
| 386 | } | 370 | } |
| 387 | return result; | 371 | return result; |
| @@ -389,15 +373,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -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 | public String setLCYH(){ | 378 | public String setLCYH(){ |
| 396 | String result = "failure"; | 379 | String result = "failure"; |
| 397 | // 取昨天 的日期 | 380 | // 取昨天 的日期 |
| 398 | String date = sdfnyr.format(DateUtils.addDays(new Date(), -1)); | 381 | String date = sdfnyr.format(DateUtils.addDays(new Date(), -1)); |
| 382 | + StringBuffer sf = new StringBuffer(); | ||
| 399 | try { | 383 | try { |
| 400 | - StringBuffer sf = new StringBuffer(); | ||
| 401 | sf.append("<LCYHS>"); | 384 | sf.append("<LCYHS>"); |
| 402 | List<ScheduleRealInfo> listGroup = scheduleRealInfoRepository.setLCYHGroup(date); | 385 | List<ScheduleRealInfo> listGroup = scheduleRealInfoRepository.setLCYHGroup(date); |
| 403 | List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDate(date); | 386 | List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDate(date); |
| @@ -451,13 +434,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -451,13 +434,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 451 | } | 434 | } |
| 452 | } | 435 | } |
| 453 | sf.append("</LCYHS>"); | 436 | sf.append("</LCYHS>"); |
| 454 | - logger.info("setLCYH:"+sf.toString()); | ||
| 455 | if(ssop.setLCYH(userNameOther, passwordOther, sf.toString()).isSuccess()){ | 437 | if(ssop.setLCYH(userNameOther, passwordOther, sf.toString()).isSuccess()){ |
| 456 | result = "success"; | 438 | result = "success"; |
| 457 | } | 439 | } |
| 458 | } catch (Exception e) { | 440 | } catch (Exception e) { |
| 441 | + logger.error("setLCYH:",e); | ||
| 459 | e.printStackTrace(); | 442 | e.printStackTrace(); |
| 460 | }finally{ | 443 | }finally{ |
| 444 | + logger.info("setLCYH:"+sf.toString()); | ||
| 461 | logger.info("setLCYH:"+result); | 445 | logger.info("setLCYH:"+result); |
| 462 | } | 446 | } |
| 463 | return result; | 447 | return result; |
| @@ -471,8 +455,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -471,8 +455,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 471 | String result = "failure"; | 455 | String result = "failure"; |
| 472 | // 取昨天 的日期 | 456 | // 取昨天 的日期 |
| 473 | String date = sdfnyr.format(DateUtils.addDays(new Date(), -1)); | 457 | String date = sdfnyr.format(DateUtils.addDays(new Date(), -1)); |
| 458 | + StringBuffer sf = new StringBuffer(); | ||
| 474 | try { | 459 | try { |
| 475 | - StringBuffer sf = new StringBuffer(); | ||
| 476 | sf.append("<DDRBS>"); | 460 | sf.append("<DDRBS>"); |
| 477 | List<ScheduleRealInfo> listGroup = scheduleRealInfoRepository.setDDRBGroup(date); | 461 | List<ScheduleRealInfo> listGroup = scheduleRealInfoRepository.setDDRBGroup(date); |
| 478 | List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDate(date); | 462 | List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDate(date); |
| @@ -554,13 +538,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -554,13 +538,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 554 | } | 538 | } |
| 555 | } | 539 | } |
| 556 | sf.append("</DDRBS>"); | 540 | sf.append("</DDRBS>"); |
| 557 | - logger.info("setDDRB:"+sf.toString()); | ||
| 558 | if(ssop.setDDRB(userNameOther, passwordOther, sf.toString()).isSuccess()){ | 541 | if(ssop.setDDRB(userNameOther, passwordOther, sf.toString()).isSuccess()){ |
| 559 | result = "success"; | 542 | result = "success"; |
| 560 | } | 543 | } |
| 561 | } catch (Exception e) { | 544 | } catch (Exception e) { |
| 545 | + logger.error("setDDRB:",e); | ||
| 562 | e.printStackTrace(); | 546 | e.printStackTrace(); |
| 563 | }finally{ | 547 | }finally{ |
| 548 | + logger.info("setDDRB:"+sf.toString()); | ||
| 564 | logger.info("setDDRB:"+result); | 549 | logger.info("setDDRB:"+result); |
| 565 | } | 550 | } |
| 566 | return result; | 551 | return result; |
| @@ -572,8 +557,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -572,8 +557,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 572 | @Override | 557 | @Override |
| 573 | public String setJHBC() { | 558 | public String setJHBC() { |
| 574 | String result = "failure"; | 559 | String result = "failure"; |
| 560 | + StringBuffer sBuffer =new StringBuffer(); | ||
| 575 | try { | 561 | try { |
| 576 | - StringBuffer sBuffer =new StringBuffer(); | ||
| 577 | sBuffer.append("<JHBCs>"); | 562 | sBuffer.append("<JHBCs>"); |
| 578 | // 声明变量 | 563 | // 声明变量 |
| 579 | SchedulePlanInfo schedulePlanInfo = null; | 564 | SchedulePlanInfo schedulePlanInfo = null; |
| @@ -633,13 +618,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -633,13 +618,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 633 | } | 618 | } |
| 634 | } | 619 | } |
| 635 | sBuffer.append("</JHBCs>"); | 620 | sBuffer.append("</JHBCs>"); |
| 636 | - logger.info("setJHBC:"+sBuffer.toString()); | ||
| 637 | if(ssop.setJHBC(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | 621 | if(ssop.setJHBC(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ |
| 638 | result = "success"; | 622 | result = "success"; |
| 639 | } | 623 | } |
| 640 | } catch (Exception e) { | 624 | } catch (Exception e) { |
| 625 | + logger.error("setJHBC:",e); | ||
| 641 | e.printStackTrace(); | 626 | e.printStackTrace(); |
| 642 | }finally{ | 627 | }finally{ |
| 628 | + logger.info("setJHBC:"+sBuffer.toString()); | ||
| 643 | logger.info("setJHBC:"+result); | 629 | logger.info("setJHBC:"+result); |
| 644 | } | 630 | } |
| 645 | return result; | 631 | return result; |
| @@ -651,14 +637,15 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -651,14 +637,15 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 651 | @Override | 637 | @Override |
| 652 | public String setSKB(String ids) { | 638 | public String setSKB(String ids) { |
| 653 | String result = "failure"; | 639 | String result = "failure"; |
| 640 | + StringBuffer sBuffer = new StringBuffer(); | ||
| 654 | try { | 641 | try { |
| 655 | String[] idArray = ids.split(","); | 642 | String[] idArray = ids.split(","); |
| 656 | - StringBuffer sBuffer = new StringBuffer(); | 643 | + StringBuffer sBufferA; |
| 644 | + StringBuffer sBufferB; | ||
| 657 | TTInfo ttInfo; | 645 | TTInfo ttInfo; |
| 658 | - TTInfoDetail ttInfoDetail; | 646 | + TTInfoDetail ttInfoDetail = null; |
| 659 | Iterator<TTInfoDetail> ttInfoDetailIterator; | 647 | Iterator<TTInfoDetail> ttInfoDetailIterator; |
| 660 | HashMap<String,Object> param = new HashMap<String, Object>(); | 648 | HashMap<String,Object> param = new HashMap<String, Object>(); |
| 661 | - String ttinfoJhlc = null;//计划总里程 | ||
| 662 | String lineCode ; | 649 | String lineCode ; |
| 663 | sBuffer.append("<SKBs>"); | 650 | sBuffer.append("<SKBs>"); |
| 664 | for (int i = 0; i < idArray.length; i++) { | 651 | for (int i = 0; i < idArray.length; i++) { |
| @@ -668,57 +655,61 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -668,57 +655,61 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 668 | param.put("ttinfo.id_eq", ttInfo.getId()); | 655 | param.put("ttinfo.id_eq", ttInfo.getId()); |
| 669 | ttInfoDetailIterator = ttInfoDetailRepository.findAll(new CustomerSpecs<TTInfoDetail>(param), | 656 | ttInfoDetailIterator = ttInfoDetailRepository.findAll(new CustomerSpecs<TTInfoDetail>(param), |
| 670 | new Sort(Direction.ASC, "xlDir")).iterator(); | 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 | if(ttInfoDetailIterator.hasNext()){ | 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 | sBuffer.append("</BCList>"); | 700 | sBuffer.append("</BCList>"); |
| 701 | + sBuffer.append("</SKB>"); | ||
| 711 | } | 702 | } |
| 712 | - sBuffer.append("</SKB>"); | ||
| 713 | } | 703 | } |
| 714 | sBuffer.append("</SKBs>"); | 704 | sBuffer.append("</SKBs>"); |
| 715 | - logger.info("setSKB:"+sBuffer.toString()); | ||
| 716 | if(ssop.setSKB(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | 705 | if(ssop.setSKB(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ |
| 717 | result = "success"; | 706 | result = "success"; |
| 718 | } | 707 | } |
| 719 | } catch (Exception e) { | 708 | } catch (Exception e) { |
| 709 | + logger.error("setSKB:", e); | ||
| 720 | e.printStackTrace(); | 710 | e.printStackTrace(); |
| 721 | }finally{ | 711 | }finally{ |
| 712 | + logger.info("setSKB:"+sBuffer.toString()); | ||
| 722 | logger.info("setSKB:"+result); | 713 | logger.info("setSKB:"+result); |
| 723 | } | 714 | } |
| 724 | return result; | 715 | return result; |
| @@ -730,8 +721,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -730,8 +721,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 730 | @Override | 721 | @Override |
| 731 | public String setXLPC() { | 722 | public String setXLPC() { |
| 732 | String result = "failure"; | 723 | String result = "failure"; |
| 724 | + StringBuffer sBuffer =new StringBuffer(); | ||
| 733 | try { | 725 | try { |
| 734 | - StringBuffer sBuffer =new StringBuffer(); | ||
| 735 | sBuffer.append("<XLPCs>"); | 726 | sBuffer.append("<XLPCs>"); |
| 736 | // 声明变量 | 727 | // 声明变量 |
| 737 | Line line = null; | 728 | Line line = null; |
| @@ -773,13 +764,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -773,13 +764,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 773 | sBuffer.append("</XLPC>"); | 764 | sBuffer.append("</XLPC>"); |
| 774 | } | 765 | } |
| 775 | sBuffer.append("</XLPCs>"); | 766 | sBuffer.append("</XLPCs>"); |
| 776 | - logger.info("setXLPC:"+sBuffer.toString()); | ||
| 777 | if(ssop.setXLPC(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | 767 | if(ssop.setXLPC(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ |
| 778 | result = "success"; | 768 | result = "success"; |
| 779 | } | 769 | } |
| 780 | } catch (Exception e) { | 770 | } catch (Exception e) { |
| 771 | + logger.error("setXLPC:",e); | ||
| 781 | e.printStackTrace(); | 772 | e.printStackTrace(); |
| 782 | }finally{ | 773 | }finally{ |
| 774 | + logger.info("setXLPC:"+sBuffer.toString()); | ||
| 783 | logger.info("setXLPC:"+result); | 775 | logger.info("setXLPC:"+result); |
| 784 | } | 776 | } |
| 785 | return result; | 777 | return result; |
| @@ -832,13 +824,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -832,13 +824,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 832 | sBuffer.append("</CS>"); | 824 | sBuffer.append("</CS>"); |
| 833 | } | 825 | } |
| 834 | sBuffer.append("</CSs>"); | 826 | sBuffer.append("</CSs>"); |
| 835 | - logger.info("setCS:"+sBuffer.toString()); | ||
| 836 | if(ssop.setCS(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | 827 | if(ssop.setCS(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ |
| 837 | result = "success"; | 828 | result = "success"; |
| 838 | } | 829 | } |
| 839 | } catch (Exception e) { | 830 | } catch (Exception e) { |
| 831 | + logger.error("setCS:",e); | ||
| 840 | e.printStackTrace(); | 832 | e.printStackTrace(); |
| 841 | } finally { | 833 | } finally { |
| 834 | + logger.info("setCS:"+sBuffer.toString()); | ||
| 842 | logger.info("setCS:"+result); | 835 | logger.info("setCS:"+result); |
| 843 | DBUtils_MS.close(rs, ps, conn); | 836 | DBUtils_MS.close(rs, ps, conn); |
| 844 | } | 837 | } |
| @@ -949,11 +942,11 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -949,11 +942,11 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 949 | min = fullTime % 60; | 942 | min = fullTime % 60; |
| 950 | sumHour = Integer.valueOf(fcsjArray[0])+hour; | 943 | sumHour = Integer.valueOf(fcsjArray[0])+hour; |
| 951 | if(sumHour >= 24){ | 944 | if(sumHour >= 24){ |
| 952 | - result = sumHour - 24+":"; | 945 | + result = String.format("%02d",sumHour - 24); |
| 953 | }else{ | 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 | }else{ | 950 | }else{ |
| 958 | result = fcsj; | 951 | result = fcsj; |
| 959 | } | 952 | } |
| @@ -961,6 +954,26 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -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 | * 拼装线路计划班次表的XML | 977 | * 拼装线路计划班次表的XML |
| 965 | * @param sBuffer | 978 | * @param sBuffer |
| 966 | * @param schedulePlanInfo | 979 | * @param schedulePlanInfo |
| @@ -993,7 +1006,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -993,7 +1006,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 993 | flag = 0; | 1006 | flag = 0; |
| 994 | } | 1007 | } |
| 995 | result += flag; | 1008 | result += flag; |
| 996 | - if(i !=ruleDayArray.length ){ | 1009 | + if(i !=ruleDayArray.length -1){ |
| 997 | result +=","; | 1010 | result +=","; |
| 998 | } | 1011 | } |
| 999 | } | 1012 | } |
| @@ -1017,15 +1030,15 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -1017,15 +1030,15 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 1017 | } | 1030 | } |
| 1018 | } | 1031 | } |
| 1019 | /** | 1032 | /** |
| 1020 | - * @param stations 站点路由集 | 1033 | + * @param stationsList 站点路由集 |
| 1021 | * @param sBuffer sBuffer | 1034 | * @param sBuffer sBuffer |
| 1022 | - * @param StartId 站点序号起始ID | 1035 | + * @param startId 站点序号起始ID |
| 1023 | * | 1036 | * |
| 1024 | * @return 站点序号累加后的ID | 1037 | * @return 站点序号累加后的ID |
| 1025 | */ | 1038 | */ |
| 1026 | private int packagStationXml(List<StationRoute> stationsList,StringBuffer sBuffer,int startId){ | 1039 | private int packagStationXml(List<StationRoute> stationsList,StringBuffer sBuffer,int startId){ |
| 1027 | int size = stationsList.size(); | 1040 | int size = stationsList.size(); |
| 1028 | - StationRoute srRoute = null; | 1041 | + StationRoute srRoute; |
| 1029 | String zdlx ;// 站点类型:0:起点站、1:终点站、2:中途站 | 1042 | String zdlx ;// 站点类型:0:起点站、1:终点站、2:中途站 |
| 1030 | for (int i = 0; i < size; i++) { | 1043 | for (int i = 0; i < size; i++) { |
| 1031 | srRoute = stationsList.get(i); | 1044 | srRoute = stationsList.get(i); |
| @@ -1062,9 +1075,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -1062,9 +1075,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 1062 | */ | 1075 | */ |
| 1063 | private Integer getYgcStationNumByLineCodeAndDirectionAndStationName(String lineCode,String direction,String stationName){ | 1076 | private Integer getYgcStationNumByLineCodeAndDirectionAndStationName(String lineCode,String direction,String stationName){ |
| 1064 | Integer number = 0; | 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 | return number; | 1079 | return number; |
| 1069 | } | 1080 | } |
| 1070 | } | 1081 | } |