Bläddra i källkod

1.站点经纬度编辑界面中可以修改入口经纬度。
2.站点入口只与站点及方向绑定。

zhengqiang 4 år sedan
förälder
incheckning
909e60864d

+ 1 - 3
common/src/main/java/com/jpsoft/bus/modules/bus/dao/StationSubInfoDAO.java

@@ -16,8 +16,6 @@ public interface StationSubInfoDAO {
 	int delete(String id);
 	List<StationSubInfo> list();
 	List<StationSubInfo> search(Map<String,Object> searchParams,List<Sort> sortList);
-
-    StationSubInfo findByStationIdStartEnd(String stationId, String startStationId, String endStationId);
-
+    StationSubInfo findByStationIdAndDirection(String stationId, String direction);
     List<StationSubInfo> findByStationId(String stationId);
 }

+ 2 - 4
common/src/main/java/com/jpsoft/bus/modules/bus/entity/StationSubInfo.java

@@ -21,10 +21,8 @@ public class StationSubInfo {
     private String id;
     @ApiModelProperty(value = "对应站点id")
     private String stationId;
-    @ApiModelProperty(value = "开始站点id")
-    private String startStationId;
-    @ApiModelProperty(value = "终点站点id")
-    private String endStationId;
+    @ApiModelProperty(value = "方向(1-起点到终点,2-终点到起点)")
+    private String direction;
     @ApiModelProperty(value = "经度")
     private Double longitude;
     @ApiModelProperty(value = "纬度")

+ 1 - 3
common/src/main/java/com/jpsoft/bus/modules/bus/service/StationSubInfoService.java

@@ -14,8 +14,6 @@ public interface StationSubInfoService {
 	int delete(String id);
 	List<StationSubInfo> list();
 	Page<StationSubInfo> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,boolean count,List<Sort> sortList);
-
-    StationSubInfo findByStationIdStartEnd(String currentStationId, String startStationId, String endStationId);
-
     List<StationSubInfo> findByStationId(String stationId);
+	StationSubInfo findByStationIdAndDirection(String stationId, String direction);
 }

+ 4 - 4
common/src/main/java/com/jpsoft/bus/modules/bus/service/impl/GpsServiceImpl.java

@@ -354,7 +354,7 @@ public class GpsServiceImpl implements GpsService {
                             distance = stationInfo.getRadius();
                         }
 
-                        if(matchDistance(stationInfo,shiftInfo.getStartStationId(),shiftInfo.getEndStationId(),vehicleInfo,distance)){
+                        if(matchDistance(stationInfo,true,vehicleInfo,distance)){
                            currentStationId = stationInfo.getId();
                            break;
                         }
@@ -385,7 +385,7 @@ public class GpsServiceImpl implements GpsService {
                             distance = stationInfo.getRadius();
                         }
 
-                        if(matchDistance(stationInfo,shiftInfo.getStartStationId(),shiftInfo.getEndStationId(),vehicleInfo,distance)){
+                        if(matchDistance(stationInfo,false,vehicleInfo,distance)){
                             currentStationId = stationInfo.getId();
                             break;
                         }
@@ -450,8 +450,8 @@ public class GpsServiceImpl implements GpsService {
         }
     }
 
-    public boolean matchDistance(StationInfo stationInfo,String startStationId,String endStationId,VehicleInfo vehicleInfo,int distance){
-        StationSubInfo stationSubInfo = stationSubInfoService.findByStationIdStartEnd(stationInfo.getId(),startStationId,endStationId);
+    public boolean matchDistance(StationInfo stationInfo,Boolean frontToEnd,VehicleInfo vehicleInfo,int distance){
+        StationSubInfo stationSubInfo = stationSubInfoService.findByStationIdAndDirection(stationInfo.getId(),frontToEnd ? "1" : "2");
 
         if (stationSubInfo != null){
             StationInfo subStationInfo = new StationInfo();

+ 2 - 2
common/src/main/java/com/jpsoft/bus/modules/bus/service/impl/StationSubInfoServiceImpl.java

@@ -70,8 +70,8 @@ public class StationSubInfoServiceImpl implements StationSubInfoService {
 	}
 
 	@Override
-	public StationSubInfo findByStationIdStartEnd(String currentStationId, String startStationId, String endStationId) {
-		return stationSubInfoDAO.findByStationIdStartEnd(currentStationId,startStationId,endStationId);
+	public StationSubInfo findByStationIdAndDirection(String currentStationId, String direction) {
+		return stationSubInfoDAO.findByStationIdAndDirection(currentStationId,direction);
 	}
 
 	@Override

+ 9 - 20
common/src/main/resources/mapper/bus/StationSubInfo.xml

@@ -6,8 +6,7 @@
     <resultMap id="StationSubInfoMap" type="com.jpsoft.bus.modules.bus.entity.StationSubInfo">
         <id property="id" column="id_"/>
         <result property="stationId" column="station_id"/>
-        <result property="startStationId" column="start_station_id"/>
-        <result property="endStationId" column="end_station_id"/>
+        <result property="direction" column="direction_"/>
         <result property="longitude" column="longitude_"/>
         <result property="latitude" column="latitude_"/>
         <result property="createBy" column="create_by"/>
@@ -25,13 +24,12 @@
         -->
         <![CDATA[
 		insert into bus_station_sub_info
-	    (id_,station_id,start_station_id,end_station_id,longitude_,latitude_,create_by,create_time,update_by,update_time,del_flag,radius_)
+	    (id_,station_id,direction_,longitude_,latitude_,create_by,create_time,update_by,update_time,del_flag,radius_)
 		values
 		(
 			#{id,jdbcType=VARCHAR}
 			,#{stationId,jdbcType=VARCHAR}
-			,#{startStationId,jdbcType=VARCHAR}
-			,#{endStationId,jdbcType=VARCHAR}
+			,#{direction,jdbcType=VARCHAR}
 			,#{longitude,jdbcType= NUMERIC }
 			,#{latitude,jdbcType= NUMERIC }
 			,#{createBy,jdbcType=VARCHAR}
@@ -52,11 +50,8 @@
             <if test="stationId!=null">
                 station_id=#{stationId,jdbcType=VARCHAR},
             </if>
-            <if test="startStationId!=null">
-                start_station_id=#{startStationId,jdbcType=VARCHAR},
-            </if>
-            <if test="endStationId!=null">
-                end_station_id=#{endStationId,jdbcType=VARCHAR},
+            <if test="direction!=null">
+                direction_=#{direction,jdbcType=VARCHAR},
             </if>
             <if test="longitude!=null">
                 longitude_=#{longitude,jdbcType= NUMERIC },
@@ -120,26 +115,20 @@
             <if test="searchParams.minLatitude != null">
                 and latitude_ >= #{searchParams.minLatitude}
             </if>
-
-            <if test="searchParams.startStationId != null">
-                and start_station_id = #{searchParams.startStationId}
-            </if>
-            <if test="searchParams.endStationId != null">
-                and end_station_id = #{searchParams.endStationId}
+            <if test="searchParams.direction != null">
+                and direction_ = #{searchParams.direction}
             </if>
-
         </where>
         <foreach item="sort" collection="sortList" open="order by" separator=",">
             ${sort.name} ${sort.order}
         </foreach>
     </select>
-    <select id="findByStationIdStartEnd" resultMap="StationSubInfoMap">
+    <select id="findByStationIdAndDirection" resultMap="StationSubInfoMap">
         <![CDATA[
 		select * from bus_station_sub_info
 		where del_flag = 0
 		and station_id = #{stationId}
-		and start_station_id = #{startStationId}
-		and end_station_id = #{endStationId}
+		and direction_ = #{direction}
 		limit 1
 		]]>
     </select>

+ 9 - 0
web/src/main/java/com/jpsoft/bus/modules/bus/controller/RouteInfoController.java

@@ -296,6 +296,15 @@ public class RouteInfoController {
                             stationInfo.setUpdateTime(new Date());
 
                             stationInfoService.update(stationInfo);
+
+                            List<StationSubInfo> stationSubInfoList = stationInfoDTO.getStationSubInfoList();
+
+                            for (StationSubInfo stationSubInfo : stationSubInfoList) {
+                                stationSubInfo.setUpdateBy(subject);
+                                stationSubInfo.setUpdateTime(new Date());
+
+                                stationSubInfoService.update(stationSubInfo);
+                            }
                         }
                         else{
                             PojoUtils.map(stationInfoDTO,stationInfo);

+ 7 - 3
web/src/main/java/com/jpsoft/bus/modules/driver/controller/DriverApiController.java

@@ -1209,6 +1209,8 @@ public class DriverApiController {
             }
 
             ShiftInfo shiftInfo = shiftInfoList.get(0);
+            StationInfo firstStation = stationInfoService.get(shiftInfo.getStartStationId());
+            StationInfo lastStation = stationInfoService.get(shiftInfo.getEndStationId());
             StationInfo currentStation = stationInfoService.get(currentStationId);
 
             //记录当前站点的校正记录,以便用来记录站点定位
@@ -1229,13 +1231,15 @@ public class DriverApiController {
                 //如果当前车辆与校正站点距离2km内
                 if (gpsService.matchDistance(currentStation,vehicleInfo,2000)){
                     //创建一个站点附属站点
-                    StationSubInfo stationSubInfo = stationSubInfoService.findByStationIdStartEnd(currentStationId, shiftInfo.getStartStationId(), shiftInfo.getEndStationId());
+                    String direction = firstStation.getSortNo() < lastStation.getSortNo() ? "1" : "2";
+
+                    StationSubInfo stationSubInfo = stationSubInfoService.findByStationIdAndDirection(currentStationId, direction);
+
                     if (stationSubInfo == null) {
                         StationSubInfo stationSubInfo1 = new StationSubInfo();
                         stationSubInfo1.setId(UUID.randomUUID().toString());
                         stationSubInfo1.setStationId(currentStationId);
-                        stationSubInfo1.setStartStationId(shiftInfo.getStartStationId());
-                        stationSubInfo1.setEndStationId(shiftInfo.getEndStationId());
+                        stationSubInfo1.setDirection(direction);
                         stationSubInfo1.setLongitude(new Double(vehicleInfo.getLongitude()));
                         stationSubInfo1.setLatitude(new Double(vehicleInfo.getLatitude()));
                         stationSubInfo1.setRadius(50);