StationServiceImpl.java 21.9 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771
package com.bsth.service.impl;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;



import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.bsth.common.ResponseCode;
import com.bsth.entity.Line;
import com.bsth.entity.Section;
import com.bsth.entity.SectionRoute;
import com.bsth.entity.Station;
import com.bsth.entity.StationRoute;
import com.bsth.repository.LineRepository;
import com.bsth.repository.SectionRepository;
import com.bsth.repository.SectionRouteRepository;
import com.bsth.repository.StationRepository;
import com.bsth.repository.StationRouteRepository;
import com.bsth.service.StationService;

/**
 * 
 * @ClassName: StationServiceImpl(站点service业务层实现类)
 * 
 * @Extends : BaseService
 * 
 * @Description: TODO(站点service业务层)
 * 
 * @Author bsth@lq
 * 
 * @Date 2016年05月03日 上午9:21:17
 *
 * @Version 公交调度系统BS版 0.1
 * 
 */

@Service
public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implements StationService{
	
	@Autowired
	private StationRepository repository;
	
	@Autowired
	private StationRouteRepository routeRepository;
	
	@Autowired 
	private LineRepository lineRepository;
	
	@Autowired
	private SectionRepository sectionRepository;
	
	@Autowired
	private SectionRouteRepository sectionRouteRepository;
	
	Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Override
	public Map<String, Object> systemSaveStations(Map<String, Object> map) {
		
		Map<String, Object> resultMap = new HashMap<String,Object>();
		
		try {
			
			// 站点信息字符传
			String stationJSON = map.get("stationJSON").toString().equals("")  ? "" : map.get("stationJSON").toString();
			
			// 路段信息字符串
			String sectionJSON = map.get("sectionJSON").toString().equals("")  ? "" : map.get("sectionJSON").toString();
			
			// 方向
			int directions = Integer.parseInt(map.get("directions").toString());
			
			// 是否撤销
			int destroy = map.get("destroy").equals("") ? 0 : Integer.parseInt(map.get("destroy").toString());
			
			// 版本
			int versions = map.get("versions").equals("") ? 0 : Integer.parseInt(map.get("versions").toString());
			
			// 坐标类型
			String dbType =  map.get("dbType").equals("") ? "" : map.get("dbType").toString();
			
			// 限速
			String speedLimitStr = map.get("speedLimit").equals("") ? "" : map.get("speedLimit").toString();
			
			// 线路ID
			int lineId = map.get("lineId").toString().equals("") ? 0 : Integer.parseInt(map.get("lineId").toString());
			
			// 线路信息
			Line resultLine = lineRepository.findOne(lineId);
			
			if(!stationJSON.equals("")) {
				
				JSONArray stationsArray = JSONArray.parseArray(stationJSON);
				
				if(stationsArray.size()>0) {
					
					for(int i = 0;i <stationsArray.size();i++) {
						
						// 站点名称
						String stationName = stationsArray.getJSONObject(i).equals("") ? "" : stationsArray.getJSONObject(i).get("name").toString();
						
						Double distance = stationsArray.getJSONObject(i).get("distance").equals("") ? 0 : Double.parseDouble(stationsArray.getJSONObject(i).get("distance").toString());
						
						// 转成公里
						distance = distance/1000;
						
						BigDecimal d = new BigDecimal(distance);
						
						distance = d.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
						
						Double duration = stationsArray.getJSONObject(i).get("duration").equals("") ? 0 : Double.parseDouble(stationsArray.getJSONObject(i).get("duration").toString());
						
						// 转成分钟
						duration = duration/60;
						
						BigDecimal t = new BigDecimal(duration);
						
						duration = t.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
						
						// 百度经纬度坐标
						String bJwpoints = "";
						
						// 百度坐标经度
						String bLonx = JSONObject.parseObject(stationsArray.getJSONObject(i).get("potion").toString()).get("lng").toString();
						
						// 百度坐标纬度
						String bLatx = JSONObject.parseObject(stationsArray.getJSONObject(i).get("potion").toString()).get("lat").toString();
						
						// 百度经纬度
						bJwpoints = bLonx + " " + bLatx;
						
						List<Object[]> stationNameList = repository.findStationName(stationName);
						
						boolean isHave = isHaveStationname(bJwpoints,stationNameList);
						
						// 初始化站点对象
						Station arg0 =  new Station();
						
						// 站点编码
						int stationCode = 0;
						
						if(isHave) {
							
							Integer stationId = Integer.parseInt(stationNameList.get(0)[1].toString());
							
							arg0 = repository.findOne(stationId);
							
							stationCode = Integer.parseInt(arg0.getStationCod());
							
						}else {
							
							stationCode = repository.stationMaxId();
							
							arg0.setStationName(stationName);
							
							// 原坐标类型
							arg0.setDbType(dbType);
							
							// 站点地理位置WGS坐标经度
							String gLonx = JSONObject.parseObject(stationsArray.getJSONObject(i).get("WGSpotion").toString()).get("Lng").toString();
							arg0.setgLonx(Float.parseFloat(gLonx));
							
							// 站点地理位置WGS坐标纬度
							String gLaty = JSONObject.parseObject(stationsArray.getJSONObject(i).get("WGSpotion").toString()).get("Lat").toString();
							arg0.setgLaty(Float.parseFloat(gLaty));
							
							// 半径
							int radius =  map.get("radius").equals("") ? 0 : Integer.parseInt(map.get("radius").toString());
							arg0.setRadius(radius);
							
							// 图形类型
							String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString();
							arg0.setShapesType(shapesType);
							
							// 站点编码
							arg0.setStationCod(String.valueOf(stationCode+1));
							
							// 是否想撤销
							arg0.setDestroy(destroy);
							
							// 版本号
							arg0.setVersions(versions);
							
							arg0.setbJwpoints(bJwpoints);
							
							// 插入站点信息
							repository.save(arg0);
							
						}
						
						// 站点路由对象
						StationRoute route = new StationRoute();
						
						// 站点名称
						route.setStationName(stationName);
						
						route.setDistances(distance);
						
						route.setToTime(duration);
						
						
						// 站点编码
						route.setStationCode(arg0.getStationCod());
						
						// 站点序号
						route.setStationRouteCode((i+1)*10);
						
						// 站点类型
						if(i==0) {
							
							// 起始站
							route.setStationMark("B");
							
						}else if(i==stationsArray.size()-1) {
							
							// 终点站
							route.setStationMark("E");
							
						}else {
							
							// 中途站
							route.setStationMark("Z");
							
						}
						
						// 版本号
						route.setVersions(versions);
						
						// 站点ID
						route.setStation(arg0);
						
						// 方向
						route.setDirections(directions);
						
						// 线路ID
						route.setLine(resultLine);
						
						// 线路编码
						route.setLineCode(resultLine.getLineCode());
						
						
						// 插入站点路由信息 
						routeRepository.save(route);
						
					}
					
				}
				
			}
			
			// 如果路段信息JSON字符串不为空
			if(!sectionJSON.equals("")) {
				
				// 转换成JSON数组
				JSONArray sectionsArray = JSONArray.parseArray(sectionJSON);
				
				// 原始线状图形坐标集合
				String sectionsBpoints = "";
				
				// WGS线状图形坐标集合
				String sectionsWJPpoints = "";
				
				// 遍历
				for(int s = 0 ;s<sectionsArray.size();s++) {
					
					String pointsLngStr = sectionsArray.getJSONObject(s).get("lng").toString();
					
					String pointsLatStr = sectionsArray.getJSONObject(s).get("lat").toString();
					
					String WGSLngStr = JSONObject.parseObject(sectionsArray.getJSONObject(s).get("WGSpotion").toString()).get("Lng").toString();
					
					String WGSLatStr = JSONObject.parseObject(sectionsArray.getJSONObject(s).get("WGSpotion").toString()).get("Lat").toString();
					
					if(s==0) {
						
						sectionsBpoints = pointsLngStr + " " + pointsLatStr;
						
						sectionsWJPpoints = WGSLngStr + " " + WGSLatStr;
						
					}else {
						
						sectionsBpoints = sectionsBpoints + "," +  pointsLngStr + " " + pointsLatStr;
						
						sectionsWJPpoints = sectionsWJPpoints + ","  +   WGSLngStr + " " + WGSLatStr;
						
					}
					
					
				}
				
				int sectionMaxId = sectionRepository.sectionMaxId();
				
				String sectionCode = String.valueOf(sectionMaxId+1);
				
				String upOrDownStr = "";
				
				if(directions==0){
					
					upOrDownStr = "上行路段";
					
				}else if(directions==1){
					
					upOrDownStr = "下行路段";
					
				}
				
			    // 路段名称
				String sectionName = resultLine.getName()+upOrDownStr;
				
				// 交出路
				String crosesRoad = "";
				
				// 终止节点
				String endNode = "";
				
				// 开始节点
				String startNode = "";
				
				// 中间节点
				String middleNode = "";
				
				// WGS坐标点集合
				String gsectionVector = "LINESTRING(" + sectionsWJPpoints +")";
				
				// 原坐标点集合
				String bsectionVector = "LINESTRING(" + sectionsBpoints + ")";
				
				// 城建坐标点集合
				String csectionVector = "";
				
				// 路段类型
				String sectionType = "";
				
				// 道路编码
				String roadCoding = "";
				
				// 路段距离
				double sectionDistance = 0;
				
				// 路段时间
				double sectionTime = 0;
				
				// 限速
				double speedLimit = Double.parseDouble(speedLimitStr);
				
				// 说明
				String descriptions = "";
				
				
				sectionRepository.systemSave(sectionCode, sectionName, crosesRoad, endNode, startNode, 
											
											 middleNode, gsectionVector, bsectionVector, sectionType, csectionVector, 
											 
											 roadCoding, sectionDistance, sectionTime, dbType, speedLimit, 
											 
											 descriptions, versions);
											 
				
				
				Section section = sectionRepository.findOne(Integer.parseInt(sectionCode));
				
				// 路段路由
				SectionRoute sectionRoute = new SectionRoute();
				
				// 路段序号
				sectionRoute.setSectionrouteCode(1);
				
				// 线路编码
				sectionRoute.setLineCode(resultLine.getLineCode());
				
				// 路段ID
				sectionRoute.setSection(section);
				
				// 线路ID
				sectionRoute.setLine(resultLine);
				
				// 路段编码
				sectionRoute.setSectionCode(sectionCode);
				
				// 版本
				sectionRoute.setVersions(versions);
				
				// 方向
				sectionRoute.setDirections(directions);
				
				sectionRouteRepository.save(sectionRoute);
			}
			
			resultMap.put("status", ResponseCode.SUCCESS);
			
		} catch (Exception e) {
			
			resultMap.put("status", ResponseCode.ERROR);
			
			logger.error("save erro.", e);
			
		}
		
		return resultMap;
	}
	
	
	public boolean isHaveStationname(String bJwpoints,List<Object[]> stationNameList) {
		
		boolean temp = true;
		
		if(stationNameList.size()>0) {
			
			for(int k = 0 ; k <stationNameList.size();k++) {
				
				if(bJwpoints.equals(stationNameList.get(k)[0])){
					
					return temp; 
					
				}else {
					
					temp = false;
					
				}
				
			}
			
		}else {
			
			temp = false;
		}
		
		return temp;
	}
	
	@Override
	public int getStationCode() {
		
		return repository.stationMaxId();
		
	}

	@Override
	public Map<String, Object> stationSaveMap(Map<String, Object> map) {
		
		Map<String, Object> resultMap = new HashMap<String, Object>();
		
		try {
			
			// 站点编码
			String stationCod = map.get("stationCod").equals("") ? "" : map.get("stationCod").toString();
			
			// 站点名称
			String stationName = map.get("stationName").equals("") ? "" : map.get("stationName").toString();
			
			// 道路编码
			String roadCoding = map.get("roadCoding").equals("") ? "" : map.get("roadCoding").toString();
			
			// 原坐标类型
			String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString();
			
			// 原坐标点
			String bJwpoints = map.get("bJwpoints").equals("") ? "" : map.get("bJwpoints").toString();
			
			// WGS经纬度
			String gJwpoints = map.get("gJwpoints").equals("") ? null : map.get("gJwpoints").toString();
			
			String gJwpointsArray []= null;
			
			if(gJwpoints!=null) {
				
				gJwpointsArray = gJwpoints.split(" ");
				
			}
			
			// 方向
			Integer directions = map.get("directions").equals("") ? null : Integer.parseInt(map.get("directions").toString());
			
			// 距离
			Double distances =  map.get("distances").equals("") ? null : Double.parseDouble(map.get("distances").toString());
			
			// 时间
			Double toTime = map.get("toTime").equals("") ? null : Double.parseDouble(map.get("toTime").toString());
			
			// WGS经纬度
			Float gLonx = Float.parseFloat(gJwpointsArray[0]);
			
			// WGS纬度
			Float gLaty = Float.parseFloat(gJwpointsArray[1]);
			
			// 城建坐标经度
			Float x = map.get("x").equals("") ?  null : Float.parseFloat(map.get("x").toString());
			
			// 城建坐标纬度
			Float y = map.get("y").equals("") ? null : Float.parseFloat(map.get("y").toString());
			
			// 多边形WGS坐标点集合
			String gPloygonGrid = map.get("gPolygonGrid").equals("") ? "" : map.get("gPolygonGrid").toString();
			
			// 多边形原坐标点集合
			String bPloygonGrid = map.get("bPolygonGrid").equals("") ? "" : map.get("bPolygonGrid").toString();
			
			// 是否撤销
			Integer destroy = map.get("destroy").equals("") ? null : Integer.parseInt(map.get("destroy").toString());
			
			// 圆半径
			Integer radius = map.get("radius").equals("") ? null : Integer.parseInt(map.get("radius").toString());
			
			// 图形类型
			String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString();
			
			// 版本
			Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString());
			
			// 说明
			String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString();
			
			// 创建人
			Integer createBy = map.get("createBy").equals("") ? null : Integer.parseInt(map.get("createBy").toString());
			
			// 修改人
			Integer updateBy = map.get("updateBy").equals("") ?  null : Integer.parseInt(map.get("updateBy").toString());
			
			int line = map.get("lineId").equals("") ? 0 : Integer.parseInt(map.get("lineId").toString());
			
			// 线路信息
			Line resultLine = lineRepository.findOne(line);
			
			String stationRouteCode = map.get("stationRouteCode").equals("") ? "" : map.get("stationRouteCode").toString();
			
			String stationMark = map.get("stationMark").equals("") ? "" : map.get("stationMark").toString();
			
			String stationRouteCodeArray [] = null;
			
			
			if(stationRouteCode!="") {
				
				stationRouteCodeArray= stationRouteCode.split("_");
				
			}
			
			
			
			repository.stationSave(stationCod, stationName, roadCoding, dbType, bJwpoints, 
						
									gLonx, gLaty, x, y, gPloygonGrid,bPloygonGrid, destroy, radius, 
									
									shapesType, versions, descriptions, createBy, updateBy);
									
									
			
			int staitonId = repository.stationMaxId();
			
			Station station = repository.findOne(staitonId);
			
			StationRoute arg0 = new StationRoute();
			
			arg0.setLine(resultLine);
			
			arg0.setStation(station);
			
			arg0.setStationName(stationName);
			
			arg0.setStationCode(station.getStationCod());
			
			arg0.setStationRouteCode(Integer.parseInt(stationRouteCodeArray[0])+1);
			
			arg0.setStationMark(stationMark);
			
			arg0.setDirections(directions);
			
			arg0.setDistances(distances);
			
			arg0.setToTime(toTime);
			
			arg0.setVersions(versions);
			
			arg0.setDescriptions(descriptions);
			
			routeRepository.save(arg0);
			
			resultMap.put("status", ResponseCode.SUCCESS);
			
			
		} catch (Exception e) {

			resultMap.put("status", ResponseCode.ERROR);
			
			logger.error("save erro.", e);
			
		}
		
		
		
		
		return resultMap;
	}

	@Override
	public Map<String, Object> stationUpdate(Map<String, Object> map) {
		
		Map<String, Object> resultMap = new HashMap<String, Object>();
		
		try {
			
			// 站点Id
			Integer stationId = map.get("stationId").equals("") ? null : Integer.parseInt(map.get("stationId").toString());
			
			String stationCod = map.get("stationCod").equals("") ? "" : map.get("stationCod").toString();
			
			// 站点名称
			String stationName = map.get("stationName").equals("") ? "" : map.get("stationName").toString();
			
			// 所在道路编码
			String roadCoding = map.get("roadCoding").equals("") ? "" : map.get("roadCoding").toString();
			
			// 经纬坐标类型 
			String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString();
			
			// 百度经纬度坐标
			String bJwpoints = map.get("bJwpoints").equals("") ? "" : map.get("bJwpoints").toString();
			
			// WGS经纬度坐标
			String gJwpoints = map.get("gJwpoints").equals("") ? "" : map.get("gJwpoints").toString();
			
			// 站点地理位置WGS坐标经度
			String gLonx = "";
			
			// 站点地理位置WGS坐标纬度
			String gLaty = "";
			
			if(gJwpoints!=null) {
				
				String gJwpointsArray[] = gJwpoints.split(" ");
				
				gLonx = gJwpointsArray[0];
				
				gLaty = gJwpointsArray[1];
				
			}
			
			// 图形类型
			String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString();
			
			// 圆形半径
			Integer radius = map.get("radius").equals("") ? null : Integer.parseInt(map.get("radius").toString());
			
			// 多边形空间WGS坐标点集合
			String gPolygonGrid = map.get("gPolygonGrid").equals("") ? "" : map.get("gPolygonGrid").toString();
			
			// 多边形空间原坐标坐标点集合
			String bPolygonGrid = map.get("bPolygonGrid").equals("") ? "" : map.get("bPolygonGrid").toString();
			
			// 是否撤销
			Integer destroy = map.get("destroy").equals("") ? null : Integer.parseInt(map.get("destroy").toString());
			
			// 版本号
			Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString());
			
			// 描述与说明
			String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString();
			
			Float x = map.get("x").equals("") ? null  : Float.parseFloat(map.get("x").toString());
			
			Float y = map.get("y").equals("") ?  null  : Float.parseFloat(map.get("y").toString());
			
			// 更新
			repository.stationUpdate(stationCod, stationName, roadCoding, dbType, bJwpoints, gLonx, gLaty, x, y, bPolygonGrid, gPolygonGrid, destroy, radius, shapesType, versions, descriptions, stationId);
			
			// 站点路由Id
			Integer stationRouteId = map.get("stationRouteId").equals("") ? null : Integer.parseInt(map.get("stationRouteId").toString());
			
			StationRoute resultS = routeRepository.findOne(stationRouteId); 
			
			// 站点路由序号
			String stationRouteCodeStr = map.get("stationRouteCode").equals("") ? null : map.get("stationRouteCode").toString();
						
			Integer stationRouteCode = null;
						
			if(stationRouteCodeStr!=null) {
							
					String stationRouteCodeAraay[] = stationRouteCodeStr.split("_");
					
					Integer old_code = resultS.getStationRouteCode();
					
					Integer new_code = Integer.parseInt(stationRouteCodeAraay[0].toString())+10;
					
					if(new_code==old_code){
						
						stationRouteCode = new_code;
						
					}else if(new_code>old_code) {
						
						stationRouteCode = new_code+1;
						
					}else if(new_code<old_code) {
						
						stationRouteCode = new_code-1;
						
					}
					
					
					// stationRouteCode = Integer.parseInt(stationRouteCodeAraay[0].toString()) + 10;
					
			}
			
			stationRouteCode = stationRouteCode == null ? 10 : stationRouteCode;
			
			Integer LineId = map.get("stationRouteLine").equals("") ? null : Integer.parseInt(map.get("stationRouteLine").toString());
			
			String stationMark = map.get("stationMark").equals("") ? null : map.get("stationMark").toString();
			
			Double distances = map.get("distances").equals("") ? null : Double.parseDouble(map.get("distances").toString());
			
			Double toTime = map.get("toTime").equals("") ? null : Double.parseDouble(map.get("toTime").toString());
			
			Integer directions = map.get("directions").equals("") ? null : Integer.parseInt(map.get("directions").toString());
			
			Station station = repository.findOne(stationId);
			
			Line line = lineRepository.findOne(LineId);
			
			
			StationRoute stationRoute = new StationRoute();
			
			stationRoute.setStationName(stationName);
			
			stationRoute.setId(stationRouteId);
			
			stationRoute.setStationRouteCode(stationRouteCode);
			
			stationRoute.setStation(station);
			
			stationRoute.setStationCode(station.getStationCod());
			
			stationRoute.setLine(line);
			
			stationRoute.setLineCode(line.getLineCode());
			
			stationRoute.setStationMark(stationMark);
			
			stationRoute.setDistances(distances);
			
			stationRoute.setToTime(toTime);
			
			stationRoute.setDirections(directions);
			
			stationRoute.setVersions(versions);
			
			stationRoute.setDescriptions(descriptions);
			
			routeRepository.save(stationRoute);
			
			resultMap.put("status", ResponseCode.SUCCESS);
			
		} catch (Exception e) {
			
			resultMap.put("status", ResponseCode.ERROR);
			
			logger.error("save erro.", e);
			
		}
		return resultMap;
	}

}