فهرست منبع

新增入口点

fllmoyu 4 سال پیش
والد
کامیت
9356310df6

+ 2 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/dao/StationSubInfoDAO.java

@@ -16,4 +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);
 }

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

@@ -41,5 +41,5 @@ public class StationSubInfo {
 	    @ApiModelProperty(value = "更新时间")
     private Date updateTime;
         @ApiModelProperty(value = "是否删除")
-    private Boolean delFlag;
+    private Boolean delFlag = false;
 }

+ 2 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/service/StationSubInfoService.java

@@ -14,4 +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);
 }

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

@@ -1,5 +1,6 @@
 package com.jpsoft.bus.modules.bus.service.impl;
 
+import com.github.pagehelper.Page;
 import com.jpsoft.bus.modules.bus.dto.StationStatusDTO;
 import com.jpsoft.bus.modules.bus.entity.*;
 import com.jpsoft.bus.modules.bus.service.*;
@@ -36,6 +37,9 @@ public class GpsServiceImpl implements GpsService {
     @Autowired
     private RestTemplate restTemplate;
 
+    @Autowired
+    private StationSubInfoService stationSubInfoService;
+
     @Autowired
     private VehicleInfoService vehicleInfoService;
 
@@ -305,8 +309,6 @@ public class GpsServiceImpl implements GpsService {
         if (shiftInfoList.size() > 0) {
             ShiftInfo shiftInfo = shiftInfoList.get(0);
 
-
-
             RouteInfo routeInfo = routeInfoService.get(shiftInfo.getRouteId());
 
             List<StationInfo> stationInfoList = stationInfoService.findByRouteId(routeInfo.getId());
@@ -394,6 +396,36 @@ public class GpsServiceImpl implements GpsService {
                     }
                 }
 
+                //gps修改站点时,查询是否有附属站点
+                if (!manual){
+
+                    Double lo = Double.valueOf(vehicleInfo.getLongitude());
+                    Double la = Double.valueOf(vehicleInfo.getLatestAddress());
+
+                    //50米
+                    Double maxLo = lo + 0.0005D;
+                    Double minLo = lo - 0.0005D;
+                    Double maxLa = la + 0.0004D;
+                    Double minLa = la - 0.0004D;
+
+
+                    Map<String, Object> searchParams = new HashMap<>();
+                    searchParams.put("maxLongitude", maxLo);
+                    searchParams.put("minLongitude", minLo);
+                    searchParams.put("maxLatitude", maxLa);
+                    searchParams.put("minLatitude", minLa);
+                    searchParams.put("startStationId",shiftInfo.getStartStationId());
+                    searchParams.put("endStationId",shiftInfo.getEndStationId());
+                    List<Sort> sortList = new ArrayList<>();
+                    sortList.add(new Sort("create_time", "desc"));
+                    Page<StationSubInfo> page = stationSubInfoService.pageSearch(searchParams,1,1,false,sortList);
+                    List<StationSubInfo> stationSubInfoList = page.getResult();
+                    if (stationSubInfoList.size()>0){
+                        StationSubInfo stationSubInfo = stationSubInfoList.get(0);
+                        currentStationId = stationSubInfo.getStationId();
+                    }
+                }
+
             }
         }
         return currentStationId;

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

@@ -30,14 +30,14 @@ public class StationSubInfoServiceImpl implements StationSubInfoService {
 	public int insert(StationSubInfo model) {
 		// TODO Auto-generated method stub
 		//model.setId(UUID.randomUUID().toString());
-		
+
 		return stationSubInfoDAO.insert(model);
 	}
 
 	@Override
 	public int update(StationSubInfo model) {
 		// TODO Auto-generated method stub
-		return stationSubInfoDAO.update(model);		
+		return stationSubInfoDAO.update(model);
 	}
 
 	@Override
@@ -50,22 +50,27 @@ public class StationSubInfoServiceImpl implements StationSubInfoService {
 	public boolean exist(String id) {
 		// TODO Auto-generated method stub
 		int count = stationSubInfoDAO.exist(id);
-		
+
 		return count > 0 ? true : false;
 	}
-	
+
 	@Override
 	public List<StationSubInfo> list() {
 		// TODO Auto-generated method stub
 		return stationSubInfoDAO.list();
 	}
-		
+
 	@Override
 	public Page<StationSubInfo> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
         Page<StationSubInfo> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
             stationSubInfoDAO.search(searchParams,sortList);
         });
-        
+
         return page;
 	}
+
+	@Override
+	public StationSubInfo findByStationIdStartEnd(String currentStationId, String startStationId, String endStationId) {
+		return stationSubInfoDAO.findByStationIdStartEnd(currentStationId,startStationId,endStationId);
+	}
 }

+ 38 - 2
common/src/main/resources/mapper/bus/StationSubInfo.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!-- namespace必须指向DAO接口 -->
 <mapper namespace="com.jpsoft.bus.modules.bus.dao.StationSubInfoDAO">
@@ -81,7 +81,7 @@
 	where id_=#{id}
 	</update>
 	<select id="get" parameterType="string" resultMap="StationSubInfoMap">
-		select 
+		select
 id_,station_id,start_station_id,end_station_id,longitude_,latitude_,create_by,create_time,update_by,update_time,del_flag		from bus_station_sub_info where id_=#{0}
 	</select>
 	<select id="exist" parameterType="string" resultType="int">
@@ -98,9 +98,45 @@ id_,station_id,start_station_id,end_station_id,longitude_,latitude_,create_by,cr
 			<if test="searchParams.id != null">
 				and ID_ like #{searchParams.id}
 			</if>
+			<if test="searchParams.maxLongitude != null">
+				<![CDATA[
+				and longitude_ <= #{searchParams.maxLongitude}
+				]]>
+			</if>
+			<if test="searchParams.minLongitude != null">
+				<![CDATA[
+				and longitude_ >= #{searchParams.minLongitude}
+				]]>
+			</if>
+			<if test="searchParams.maxLatitude != null">
+				<![CDATA[
+				and latitude_ <= #{searchParams.maxLatitude}
+				]]>
+			</if>
+			<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>
+
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">
 	        ${sort.name} ${sort.order}
 	 	</foreach>
 	</select>
+	<select id="findByStationIdStartEnd" 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}
+		limit 1
+		]]>
+	</select>
 </mapper>

+ 21 - 0
web/src/main/java/com/jpsoft/bus/modules/driver/controller/DriverApiController.java

@@ -67,6 +67,9 @@ public class DriverApiController {
     @Autowired
     private PriceInfoService priceInfoService;
 
+    @Autowired
+    private StationSubInfoService stationSubInfoService;
+
     @Autowired
     private BaiduService baiduService;
 
@@ -1107,6 +1110,24 @@ public class DriverApiController {
                 sysLog.setRemoteIp(HttpUtil.getIpAddress(request));
                 sysLog.setCreateTime(new Date());
                 logService.insert(sysLog);
+
+                //创建一个站点附属站点
+                StationSubInfo stationSubInfo = stationSubInfoService.findByStationIdStartEnd(currentStationId,shiftInfo.getStartStationId(),shiftInfo.getEndStationId());
+                if (stationSubInfo == null){
+                    StationSubInfo stationSubInfo1 = new StationSubInfo();
+                    stationSubInfo1.setId(UUID.randomUUID().toString());
+                    stationSubInfo1.setStationId(currentStationId);
+                    stationSubInfo1.setStartStationId(shiftInfo.getStartStationId());
+                    stationSubInfo1.setEndStationId(shiftInfo.getEndStationId());
+                    stationSubInfo1.setLongitude(new BigDecimal(vehicleInfo.getLongitude()));
+                    stationSubInfo1.setLatitude(new BigDecimal(vehicleInfo.getLatitude()));
+                    stationSubInfo1.setCreateTime(new Date());
+                    stationSubInfoService.insert(stationSubInfo1);
+                }else {
+                    stationSubInfo.setLongitude(new BigDecimal(vehicleInfo.getLongitude()));
+                    stationSubInfo.setLatitude(new BigDecimal(vehicleInfo.getLatitude()));
+                    stationSubInfoService.update(stationSubInfo);
+                }
             }
 
             //改gps后,会自动修改当前站点,只能往后改