Commit 15fe5ca30ea41f6fd2f684fb4b1240d4b9a5fbb2

Authored by 李强
1 parent 6321c1ec

线路文件(环线)生成代码改动

src/main/java/com/bsth/entity/SectionRoute.java
... ... @@ -52,7 +52,7 @@ public class SectionRoute {
52 52 // 是否撤销
53 53 private Integer destroy;
54 54  
55   - /** 是否有路段限速数据 <0:无;1:有>*/
  55 + /** 是否有路段限速数据 <0:未分段;1:分段>*/
56 56 private Integer isRoadeSpeed;
57 57  
58 58 // 描述
... ...
src/main/java/com/bsth/service/impl/StationRouteServiceImpl.java
... ... @@ -11,6 +11,8 @@ import com.bsth.repository.StationRouteRepository;
11 11 import com.bsth.service.StationRouteService;
12 12 import com.bsth.util.FTPClientUtils;
13 13 import com.bsth.util.PackTarGZUtils;
  14 +import com.bsth.util.Geo.GeoUtils;
  15 +import com.bsth.util.Geo.Point;
14 16 import com.bsth.util.db.DBUtils_MS;
15 17 import com.google.common.base.Splitter;
16 18 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -556,9 +558,15 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
556 558  
557 559 clientUtils.deleteFtpFile(url, port, username, password, remotePath, textFileName);
558 560  
559   - /** 行单文件内容 @param:<objects:站点路由;lineId:线路ID>*/
560   - String textStr = newTextFileToFTP(objects,lineId);
  561 + String textStr = "";
561 562  
  563 + boolean tempTag = ishxType(objects);
  564 +
  565 + if(tempTag)
  566 + textStr = hxTextFileToFtp(objects,lineId);// 环线行单文件内容
  567 + else
  568 + textStr = newTextFileToFTP(objects,lineId);/** 双向行单文件内容 @param:<objects:站点路由;lineId:线路ID>*/
  569 +
562 570 /*textStr = line.getName() + "\t" + "2" + "\r" + textStr;*/
563 571  
564 572 textStr = line.getName() + " " + "2" + "\r" + textStr;
... ... @@ -574,9 +582,6 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
574 582 /** 获取txt文件 */
575 583 File textFile = clientUtils.GetFtpFile(url, port, username, password, remotePath, textFileName);
576 584  
577   - /*File[] sources = new File[] {textFile};*/
578   - //File[] sources = new File[] {textFile};
579   -
580 585 File target = new File(odlGzFileName);
581 586  
582 587 // 将txt文件打包
... ... @@ -603,6 +608,24 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
603 608 }
604 609 return resultMap;
605 610 }
  611 + public boolean ishxType(List<Object[]> listObj) {
  612 + boolean tag = true;
  613 + String pointBStr[] = null,pointEStr[] = null;
  614 + int numzd = 0;
  615 + for(int i =0;i<listObj.size();i++) {
  616 + if(listObj.get(i)[3].equals("B") && Integer.valueOf(listObj.get(i)[8].toString())==0)
  617 + pointBStr = listObj.get(i)[2].toString().split(" ");
  618 + else if(listObj.get(i)[3].equals("E") && Integer.valueOf(listObj.get(i)[8].toString())==0)
  619 + pointEStr = listObj.get(i)[2].toString().split(" ");
  620 + if(Integer.valueOf(listObj.get(i)[8].toString())==1)
  621 + numzd++;
  622 + }
  623 + Point p1 = new Point(Double.valueOf(pointBStr[0]),Double.valueOf(pointBStr[1]));
  624 + Point p2 = new Point(Double.valueOf(pointEStr[0]),Double.valueOf(pointEStr[1]));
  625 + if(GeoUtils.getDistance(p1, p2)>100 && numzd>2)
  626 + tag = false;
  627 + return tag;
  628 + }
606 629  
607 630 /**
608 631 * @Description : TODO(形成行单文件内容)
... ... @@ -717,31 +740,79 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
717 740 }
718 741  
719 742 }
720   -
721   - /*
722   - String bdJWPointStr = objects.get(i)[2].toString();
723   -
724   - String bdJWPointA[] = bdJWPointStr.split(" ");
725   -
726   - Map<String, Object> pointsM = new HashMap<String,Object>();
727   -
728   - pointsM.put("lng", bdJWPointA[0]);
729   -
730   - pointsM.put("lat", bdJWPointA[1]);
731   -
732   - System.out.println(objects.get(i)[7].toString());
733   -
734   - sleepStr = sleepStr + GetFormPointOnPolylineSeleepLimit(pointsM,sobje);*/
735 743 }
736 744  
737 745 stationRStr = stationRStr + lng + lat + stationMake + stationNo + stationCode + staitondistance + sleepStr + stationName + enterStr;
738   -
739 746 }
740 747  
741 748 }
742   -
743 749 return stationRStr;
744   -
  750 + }
  751 +
  752 + public String hxTextFileToFtp(List<Object[]> objects,Integer lineId) {
  753 + String restStr = "";
  754 + // windows下的文本文件换行符
  755 + //String enterStr = "\r\n";
  756 + // linux/unix下的文本文件换行符
  757 + String enterStr = "\r";
  758 + int xh = 1 ;
  759 + for(int x =0;x<2;x++) {
  760 + for(int i = 0; i<objects.size();i++) {
  761 + if(Integer.valueOf(objects.get(i)[8].toString())==0) {
  762 + // 经度
  763 + String lng = objects.get(i)[0].equals("") ? "" : objects.get(i)[0].toString();
  764 + // 纬度
  765 + String lat = objects.get(i)[1].equals("") ? "" : objects.get(i)[1].toString();
  766 + lat = "\t" + lat;
  767 + // 站点类型
  768 + String stationMakeStr = objects.get(i)[3].equals("") ? "" : objects.get(i)[3].toString();
  769 + String stationMake = "";
  770 + if(stationMakeStr.equals("E")) {
  771 + stationMake = "\t2";
  772 + }else {
  773 + stationMake ="\t1";
  774 + }
  775 + // 站点序号
  776 + // String stationNo = objects.get(i)[4].equals("") ? "" : objects.get(i)[4].toString();
  777 + String stationNo = "\t" + xh;
  778 + // 站点编码
  779 + String stationCode = objects.get(i)[5].equals("") ? "" : objects.get(i)[5].toString();
  780 + stationCode = "\t" +stationCode;
  781 + double dis = objects.get(i)[6]==null ? 0.0 : Double.parseDouble(objects.get(i)[6].toString())*1000;
  782 + String tempDistc = String.valueOf((int) dis);
  783 + // 站点距离
  784 + String staitondistance = "\t" + tempDistc;
  785 + // 站点名称
  786 + String stationName = objects.get(i)[7].equals("") ? "" : objects.get(i)[7].toString();
  787 + stationName = "\t" +stationName;
  788 + // 限速
  789 + String sleepStr = "";
  790 + // 方向
  791 + int directions = objects.get(i)[8]==null ? null : Integer.valueOf(objects.get(i)[8].toString());
  792 + /** 获取路段路由信息 @pararm:<lineId:线路ID;directions:方向> */
  793 + List<Object[]> sobje = routeRepository.sectionRouteVector(lineId,directions);
  794 + if(sobje.size()==1) {
  795 + double dsleepStr = sobje.get(0)[2] == null ? 60d : Double.valueOf(sobje.get(0)[2].toString());
  796 + sleepStr = "\t" + new DecimalFormat("0").format(dsleepStr);
  797 + }else if(sobje.size()>1){
  798 + /** 这里暂时只根据站点名称去匹配所在路段的限速值 ,如果路段名称"至"之前的地名与站点名称等同,就认为站点在路段上。 */
  799 + for(int j =0;j<sobje.size();j++) {
  800 + String sectionName = sobje.get(j)[3].toString();
  801 + String sectionNameA[] = sectionName.split("至");
  802 + if(stationName.equals(sectionNameA[0])){
  803 + /*sleepStr = sobje.get(j)[2].toString();*/
  804 + double dsleepStrt = sobje.get(0)[2] == null ? 60d : Double.valueOf(sobje.get(j)[2].toString());
  805 + sleepStr = "\t" + new DecimalFormat("0").format(dsleepStrt);
  806 + }
  807 + }
  808 + }
  809 + xh++;
  810 + restStr = restStr + lng + lat + stationMake + stationNo + stationCode + staitondistance + sleepStr + stationName + enterStr;
  811 + }
  812 + }
  813 + }
  814 + System.out.println(restStr);
  815 + return restStr;
745 816 }
746 817  
747 818 public String GetFormPointOnPolylineSeleepLimit(Map<String, Object> p,List<Object[]> listObjArra) {
... ...
src/main/java/com/bsth/util/Geo/SHCJ2BDJW.java
... ... @@ -27,9 +27,11 @@ public class SHCJ2BDJW {
27 27  
28 28 /*String sqlSelect = "SELECT b.SHAPESTRING as SHAPE , b.id as ID FROM jjwgps_t_gjldb b where SHAPESTRING is not null order by b.ldbh asc ";*/
29 29 /*String sqlSelect = "select s.id,s.descriptions from bsth_c_station s order by s.id asc ";*/
30   - String sqlSelect = "SELECT s.id,s.descriptions FROM bsth_c_section s order by s.id asc ";
  30 + String sqlSelect = "select s.id,s.x,s.y from bsth_c_station s where id >=26882 order by s.id asc";
  31 + /*String sqlSelect = "SELECT s.id,s.descriptions FROM bsth_c_section s order by s.id asc ";*/
31 32  
32   - String sqlUpdate = "UPDATE bsth_c_section SET csection_vector = ST_GeomFromText(?) , bsection_vector=ST_GeomFromText(?) , gsection_vector=ST_GeomFromText(?) where id = ?";
  33 + /*String sqlUpdate = "UPDATE bsth_c_section SET csection_vector = ST_GeomFromText(?) , bsection_vector=ST_GeomFromText(?) , gsection_vector=ST_GeomFromText(?) where id = ?";*/
  34 + String sqlUpdate = "UPDATE bsth_c_station SET b_jwpoints= ? , g_lonx=? , g_laty=? where id = ?";
33 35  
34 36 List<Map<String, Object>> list = new ArrayList<>();
35 37  
... ... @@ -44,8 +46,9 @@ public class SHCJ2BDJW {
44 46  
45 47 Map<String, Object> map = new HashMap<String, Object>();
46 48  
47   - map.put("descriptions", rs.getString("descriptions"));
48   -
  49 + /*map.put("descriptions", rs.getString("descriptions"));*/
  50 + map.put("x", rs.getString("x"));
  51 + map.put("y", rs.getString("y"));
49 52 map.put("id", rs.getInt("id"));
50 53  
51 54 list.add(map);
... ... @@ -55,10 +58,21 @@ public class SHCJ2BDJW {
55 58  
56 59 Map<String, Object> temp = list.get(i);
57 60 // POINT (8229.30921617 -933.16425265)
58   - String lineString = temp.get("descriptions").toString();
59   - int id = Integer.parseInt(temp.get("id").toString());
  61 + //String lineString = temp.get("descriptions").toString();
  62 +
  63 + Double lng = Double.parseDouble(temp.get("x").toString());
  64 + Double lat = Double.parseDouble(temp.get("y").toString());
  65 + Map map_2 = JWDUtil.ConvertSHToJW(lng,lat);
60 66  
61   - String arrayP[] = lineString.substring(lineString.indexOf("(")+1, lineString.length()-1).split(", ");
  67 + String b_jwpoints = "";
  68 + Float g_lonx=0.0f,g_laty=0.0f;
  69 + int id = Integer.parseInt(temp.get("id").toString());
  70 + g_lonx = Float.parseFloat(map_2.get("x").toString());
  71 + g_laty = Float.parseFloat(map_2.get("y").toString());
  72 + Location location = TransGPS.LocationMake(Float.parseFloat(map_2.get("x").toString()), Float.parseFloat(map_2.get("y").toString()));
  73 + location = TransGPS.bd_encrypt(TransGPS.transformFromWGSToGCJ(location));
  74 + b_jwpoints = (location.getLng()+0.000727) + " " + (location.getLat() - 0.0000624);
  75 + //String arrayP[] = lineString.substring(lineString.indexOf("(")+1, lineString.length()-1).split(", ");
62 76 /*String arrayP[] = lineString.substring(lineString.indexOf("(")+1, lineString.length()-1).split(" ");
63 77 String b_jwpoints = "";
64 78 Float g_lonx=0.0f,g_laty=0.0f,x=0.0f,y=0.0f;*/
... ... @@ -76,7 +90,7 @@ public class SHCJ2BDJW {
76 90 b_jwpoints = (location.getLng()+0.000727) + " " + (location.getLat() - 0.0000624);*/
77 91 //b_jwpoints = (location.getLng()) + " " + (location.getLat());
78 92  
79   - String csection_vector="",bsection_vector="",gsection_vector="";
  93 + /* String csection_vector="",bsection_vector="",gsection_vector="";
80 94  
81 95 for(int k =0;k<arrayP.length;k++) {
82 96  
... ... @@ -103,20 +117,20 @@ public class SHCJ2BDJW {
103 117 }
104 118  
105 119  
106   - }
  120 + }*/
107 121  
108 122 ps = null;
109   - bsection_vector = "LINESTRING(" + bsection_vector +")";
110   - csection_vector = "LINESTRING(" + csection_vector +")";
111   - gsection_vector = "LINESTRING(" + gsection_vector +")";
  123 + //bsection_vector = "LINESTRING(" + bsection_vector +")";
  124 + //csection_vector = "LINESTRING(" + csection_vector +")";
  125 + //gsection_vector = "LINESTRING(" + gsection_vector +")";
112 126  
113 127 ps = conn.prepareStatement(sqlUpdate);
114 128  
115 129 // String sqlUpdate = "UPDATE bsth_c_section SET csection_vector = ? , bsection_vector=? , gsection_vector=? where id = ?";
116   - ps.setString(1, csection_vector);
117   - ps.setString(2, bsection_vector);
118   - ps.setString(3, gsection_vector);
119   - ps.setInt(4, id);
  130 + //ps.setString(1, csection_vector);
  131 + //ps.setString(2, bsection_vector);
  132 + //ps.setString(3, gsection_vector);
  133 + //ps.setInt(4, id);
120 134  
121 135 //int stauts = ps.executeUpdate();
122 136 // String sqlUpdate = "UPDATE bsth_c_station SET b_jwpoints = ?1 , g_lonx=?2 , g_laty=?3 , x = ?4 , y = ?5 where id = ?6";
... ... @@ -126,6 +140,11 @@ public class SHCJ2BDJW {
126 140 ps.setFloat(4, x);
127 141 ps.setFloat(5, y);
128 142 ps.setFloat(6, id);*/
  143 +
  144 + ps.setString(1, b_jwpoints);
  145 + ps.setFloat(2, g_lonx);
  146 + ps.setFloat(3, g_laty);
  147 + ps.setFloat(4, id);
129 148 int stauts = ps.executeUpdate();
130 149 System.out.println(stauts);
131 150 }
... ...
src/main/resources/static/pages/base/station/edit_select.html
... ... @@ -177,7 +177,7 @@ $(&#39;#editPositions_select_mobal&#39;).on(&#39;editSelectMobal_show&#39;, function(e, map,drm,
177 177 map.clearMarkAndOverlays();
178 178  
179 179 // 打开绘制工具
180   - PositionsDrawingManagerObj.openDrawingManager();
  180 + drm.openDrawingManager();
181 181  
182 182 // 根据站点位置在地图定位
183 183 map.localtionPoint(editStationName);
... ...