Commit 77bc991295e3d9a9f56dadd38cffc765fd7050db

Authored by 李强
1 parent a4b0b9bd

恢复线路文件上传功能版本,之前被人还原到最初的版本了。

src/main/java/com/bsth/service/impl/StationRouteServiceImpl.java
@@ -668,25 +668,23 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ @@ -668,25 +668,23 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ
668 * @return String 668 * @return String
669 */ 669 */
670 public String newTextFileToFTP(List<Object[]> objects,Integer lineId) { 670 public String newTextFileToFTP(List<Object[]> objects,Integer lineId) {
671 -  
672 // 返回值String 671 // 返回值String
673 String stationRStr = ""; 672 String stationRStr = "";
674 -  
675 // windows下的文本文件换行符 673 // windows下的文本文件换行符
676 //String enterStr = "\r\n"; 674 //String enterStr = "\r\n";
677 -  
678 // linux/unix下的文本文件换行符 675 // linux/unix下的文本文件换行符
679 String enterStr = "\r"; 676 String enterStr = "\r";
680 - 677 + int defaultZdxh = 0;
681 if(objects.size()>0) { 678 if(objects.size()>0) {
682 -  
683 for(int i = 0; i<objects.size();i++) { 679 for(int i = 0; i<objects.size();i++) {
684 - 680 + defaultZdxh ++ ;
685 // 经度 681 // 经度
686 - String lng = objects.get(i)[0].equals("") ? "" : objects.get(i)[0].toString(); 682 + String lng = objects.get(i)[0].equals("") ? "0" : objects.get(i)[0].toString();
687 683
688 // 纬度 684 // 纬度
689 - String lat = objects.get(i)[1].equals("") ? "" : objects.get(i)[1].toString(); 685 + String lat = objects.get(i)[1].equals("") ? "0" : objects.get(i)[1].toString();
  686 +
  687 + Point point = new Point(Double.valueOf(lng), Double.valueOf(lat));
690 688
691 lat = "\t" + lat; 689 lat = "\t" + lat;
692 690
@@ -696,23 +694,32 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ @@ -696,23 +694,32 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
696 String stationMake = ""; 694 String stationMake = "";
697 695
698 if(stationMakeStr.equals("E")) { 696 if(stationMakeStr.equals("E")) {
699 -  
700 stationMake = "\t2"; 697 stationMake = "\t2";
701 -  
702 }else { 698 }else {
703 -  
704 stationMake ="\t1"; 699 stationMake ="\t1";
705 -  
706 } 700 }
707 701
708 // 站点序号 702 // 站点序号
709 - String stationNo = objects.get(i)[4].equals("") ? "" : objects.get(i)[4].toString(); 703 + // String stationNo = objects.get(i)[4].equals("") ? "" : objects.get(i)[4].toString();
  704 + String stationNo = String.valueOf(defaultZdxh);
710 705
711 stationNo = "\t" + stationNo; 706 stationNo = "\t" + stationNo;
712 707
713 // 站点编码 708 // 站点编码
714 String stationCode = objects.get(i)[5].equals("") ? "" : objects.get(i)[5].toString(); 709 String stationCode = objects.get(i)[5].equals("") ? "" : objects.get(i)[5].toString();
715 710
  711 + int len = stationCode.length();
  712 + if(len<8) {
  713 + int dx = 8 - len;
  714 + String addStr = "";
  715 + for(int p =0;p<dx;p++) {
  716 + addStr = addStr + "0";
  717 + }
  718 + stationCode = addStr + stationCode;
  719 + }else if(len>8){
  720 + stationCode = stationCode.substring(8);
  721 + }
  722 +
716 stationCode = "\t" +stationCode; 723 stationCode = "\t" +stationCode;
717 724
718 double dis = objects.get(i)[6]==null ? 0.0 : Double.parseDouble(objects.get(i)[6].toString())*1000; 725 double dis = objects.get(i)[6]==null ? 0.0 : Double.parseDouble(objects.get(i)[6].toString())*1000;
@@ -732,41 +739,33 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ @@ -732,41 +739,33 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
732 739
733 // 限速 740 // 限速
734 String sleepStr = ""; 741 String sleepStr = "";
735 -  
736 // 方向 742 // 方向
737 int directions = objects.get(i)[8]==null ? null : Integer.valueOf(objects.get(i)[8].toString()); 743 int directions = objects.get(i)[8]==null ? null : Integer.valueOf(objects.get(i)[8].toString());
738 -  
739 /** 获取路段路由信息 @pararm:<lineId:线路ID;directions:方向> */ 744 /** 获取路段路由信息 @pararm:<lineId:线路ID;directions:方向> */
740 List<Object[]> sobje = routeRepository.sectionRouteVector(lineId,directions); 745 List<Object[]> sobje = routeRepository.sectionRouteVector(lineId,directions);
741 -  
742 if(sobje.size()==1) { 746 if(sobje.size()==1) {
743 -  
744 - double dsleepStr = sobje.get(0)[2] == null ? 60d : Double.valueOf(sobje.get(0)[2].toString());  
745 -  
746 - sleepStr = "\t" + new DecimalFormat("0").format(dsleepStr);  
747 - 747 + int dsleepStr = sobje.get(0)[2] == null || sobje.get(0)[2].equals("") ? 60 : Integer.valueOf(sobje.get(0)[2].toString());
  748 + sleepStr = "\t" + String.valueOf(dsleepStr);
748 }else if(sobje.size()>1){ 749 }else if(sobje.size()>1){
749 -  
750 - /** 这里暂时只根据站点名称去匹配所在路段的限速值 ,如果路段名称"至"之前的地名与站点名称等同,就认为站点在路段上。 */  
751 for(int j =0;j<sobje.size();j++) { 750 for(int j =0;j<sobje.size();j++) {
752 -  
753 - String sectionName = sobje.get(j)[3].toString();  
754 -  
755 - String sectionNameA[] = sectionName.split("至");  
756 -  
757 - if(stationName.equals(sectionNameA[0])){  
758 -  
759 - /*sleepStr = sobje.get(j)[2].toString();*/  
760 -  
761 - double dsleepStrt = sobje.get(0)[2] == null ? 60d : Double.valueOf(sobje.get(j)[2].toString());  
762 -  
763 - sleepStr = "\t" + new DecimalFormat("0").format(dsleepStrt);  
764 - 751 + double dsleepStrt = sobje.get(j)[2] == null || sobje.get(j)[2].equals("") ? 60d : Double.valueOf(sobje.get(j)[2].toString());
  752 + String pointsStr = sobje.get(j)[1]==null || sobje.get(j)[1].equals("") ? null : sobje.get(j)[1].toString();
  753 + pointsStr = pointsStr.substring(11, pointsStr.length()-1);
  754 + List<Point> ps = new ArrayList<>();
  755 + String[] pArray = pointsStr.split(",");
  756 + for(int a = 0; a <pArray.length; a++) {
  757 + String[] tmepA = pArray[a].split(" ");
  758 + Point temp = new Point(Double.valueOf(tmepA[0]), Double.valueOf(tmepA[1]));
  759 + ps.add(temp);
  760 + }
  761 + if(GeoUtils.isInSection(ps, point)) {
  762 + sleepStr = "\t" + String.valueOf((int)dsleepStrt);
  763 + break;
765 } 764 }
766 -  
767 } 765 }
768 } 766 }
769 - 767 + if(sleepStr.equals(""))
  768 + sleepStr = "\t" + "60";
770 stationRStr = stationRStr + lng + lat + stationMake + stationNo + stationCode + staitondistance + sleepStr + stationName + enterStr; 769 stationRStr = stationRStr + lng + lat + stationMake + stationNo + stationCode + staitondistance + sleepStr + stationName + enterStr;
771 } 770 }
772 771
@@ -785,9 +784,12 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ @@ -785,9 +784,12 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
785 for(int i = 0; i<objects.size();i++) { 784 for(int i = 0; i<objects.size();i++) {
786 if(Integer.valueOf(objects.get(i)[8].toString())==0) { 785 if(Integer.valueOf(objects.get(i)[8].toString())==0) {
787 // 经度 786 // 经度
788 - String lng = objects.get(i)[0].equals("") ? "" : objects.get(i)[0].toString(); 787 + String lng = objects.get(i)[0].equals("") ? "0" : objects.get(i)[0].toString();
  788 +
789 // 纬度 789 // 纬度
790 - String lat = objects.get(i)[1].equals("") ? "" : objects.get(i)[1].toString(); 790 + String lat = objects.get(i)[1].equals("") ? "0" : objects.get(i)[1].toString();
  791 +
  792 + Point point = new Point(Double.valueOf(lng), Double.valueOf(lat));
791 lat = "\t" + lat; 793 lat = "\t" + lat;
792 // 站点类型 794 // 站点类型
793 String stationMakeStr = objects.get(i)[3].equals("") ? "" : objects.get(i)[3].toString(); 795 String stationMakeStr = objects.get(i)[3].equals("") ? "" : objects.get(i)[3].toString();
@@ -802,6 +804,17 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ @@ -802,6 +804,17 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
802 String stationNo = "\t" + xh; 804 String stationNo = "\t" + xh;
803 // 站点编码 805 // 站点编码
804 String stationCode = objects.get(i)[5].equals("") ? "" : objects.get(i)[5].toString(); 806 String stationCode = objects.get(i)[5].equals("") ? "" : objects.get(i)[5].toString();
  807 + int len = stationCode.length();
  808 + if(len<8) {
  809 + int dx = 8 - len;
  810 + String addStr = "";
  811 + for(int p =0;p<dx;p++) {
  812 + addStr = addStr + "0";
  813 + }
  814 + stationCode = addStr + stationCode;
  815 + }else if(len>8){
  816 + stationCode = stationCode.substring(8);
  817 + }
805 stationCode = "\t" +stationCode; 818 stationCode = "\t" +stationCode;
806 double dis = objects.get(i)[6]==null ? 0.0 : Double.parseDouble(objects.get(i)[6].toString())*1000; 819 double dis = objects.get(i)[6]==null ? 0.0 : Double.parseDouble(objects.get(i)[6].toString())*1000;
807 String tempDistc = String.valueOf((int) dis); 820 String tempDistc = String.valueOf((int) dis);
@@ -817,20 +830,28 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ @@ -817,20 +830,28 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
817 /** 获取路段路由信息 @pararm:<lineId:线路ID;directions:方向> */ 830 /** 获取路段路由信息 @pararm:<lineId:线路ID;directions:方向> */
818 List<Object[]> sobje = routeRepository.sectionRouteVector(lineId,directions); 831 List<Object[]> sobje = routeRepository.sectionRouteVector(lineId,directions);
819 if(sobje.size()==1) { 832 if(sobje.size()==1) {
820 - double dsleepStr = sobje.get(0)[2] == null ? 60d : Double.valueOf(sobje.get(0)[2].toString());  
821 - sleepStr = "\t" + new DecimalFormat("0").format(dsleepStr); 833 + int dsleepStr = sobje.get(0)[2] == null || sobje.get(0)[2].equals("") ? 60 : Integer.valueOf(sobje.get(0)[2].toString());
  834 + sleepStr = "\t" + String.valueOf(dsleepStr);
822 }else if(sobje.size()>1){ 835 }else if(sobje.size()>1){
823 - /** 这里暂时只根据站点名称去匹配所在路段的限速值 ,如果路段名称"至"之前的地名与站点名称等同,就认为站点在路段上。 */  
824 for(int j =0;j<sobje.size();j++) { 836 for(int j =0;j<sobje.size();j++) {
825 - String sectionName = sobje.get(j)[3].toString();  
826 - String sectionNameA[] = sectionName.split("至");  
827 - if(stationName.equals(sectionNameA[0])){  
828 - /*sleepStr = sobje.get(j)[2].toString();*/  
829 - double dsleepStrt = sobje.get(0)[2] == null ? 60d : Double.valueOf(sobje.get(j)[2].toString());  
830 - sleepStr = "\t" + new DecimalFormat("0").format(dsleepStrt); 837 + double dsleepStrt = sobje.get(j)[2] == null || sobje.get(j)[2].equals("") ? 60d : Double.valueOf(sobje.get(j)[2].toString());
  838 + String pointsStr = sobje.get(j)[1]==null || sobje.get(j)[1].equals("") ? null : sobje.get(j)[1].toString();
  839 + pointsStr = pointsStr.substring(11, pointsStr.length()-1);
  840 + List<Point> ps = new ArrayList<>();
  841 + String[] pArray = pointsStr.split(",");
  842 + for(int a = 0; a <pArray.length; a++) {
  843 + String[] tmepA = pArray[a].split(" ");
  844 + Point temp = new Point(Double.valueOf(tmepA[0]), Double.valueOf(tmepA[1]));
  845 + ps.add(temp);
  846 + }
  847 + if(GeoUtils.isInSection(ps, point)) {
  848 + sleepStr = "\t" + String.valueOf((int)dsleepStrt);
  849 + break;
831 } 850 }
832 } 851 }
833 } 852 }
  853 + if(sleepStr.equals(""))
  854 + sleepStr = "\t" + "60";
834 xh++; 855 xh++;
835 restStr = restStr + lng + lat + stationMake + stationNo + stationCode + staitondistance + sleepStr + stationName + enterStr; 856 restStr = restStr + lng + lat + stationMake + stationNo + stationCode + staitondistance + sleepStr + stationName + enterStr;
836 } 857 }