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

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

@@ -19,4 +19,6 @@ public interface ShiftInfoDAO {
     List<ShiftInfo> findByDriverIdAndStatus(Long driverId, String status);
 
     List<ShiftInfo> findByVehicleIdAndStatus(String vehicleId, String status);
+
+    List<ShiftInfo> findByRouteIdAndStatus(String routeId, String status);
 }

+ 21 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/dto/NearbyShiftDTO.java

@@ -0,0 +1,21 @@
+package com.jpsoft.bus.modules.bus.dto;
+
+import lombok.Data;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2021-4-13 17:07
+ */
+@Data
+public class NearbyShiftDTO {
+
+    private String id;
+
+    private String routeName;
+
+    private String startStationName;
+
+    private String endStationName;
+
+    private String currentStationName;
+}

+ 17 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/dto/NearbyStationDTO.java

@@ -0,0 +1,17 @@
+package com.jpsoft.bus.modules.bus.dto;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2021-4-13 17:07
+ */
+@Data
+public class NearbyStationDTO {
+
+    private String stationName;
+
+    private List<NearbyShiftDTO> nearbyShiftDTOList;
+}

+ 2 - 2
common/src/main/java/com/jpsoft/bus/modules/bus/dto/VehicleStationDTO.java

@@ -17,7 +17,7 @@ public class VehicleStationDTO {
 
     private String stationName;
 
-    private String longitude;
-    private String latitude;
+    private Double longitude;
+    private Double latitude;
 
 }

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

@@ -25,9 +25,9 @@ public class StationInfo {
         @ApiModelProperty(value = "站点名称")
     private String name;
         @ApiModelProperty(value = "经度")
-    private String longitude;
+    private Double longitude;
         @ApiModelProperty(value = "纬度")
-    private String latitude;
+    private Double latitude;
         @ApiModelProperty(value = "1-起点,2-途径,3-终点")
     private Integer classify;
         @ApiModelProperty(value = "创建人")

+ 1 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/service/ShiftInfoService.java

@@ -22,4 +22,5 @@ public interface ShiftInfoService {
 
     void createShift(VehicleInfo vehicleInfo, String driverId, String startStationId, String endStationId) throws Exception;
 
+    List<ShiftInfo> findByRouteIdAndStatus(String routeId, String status);
 }

+ 5 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/service/impl/ShiftInfoServiceImpl.java

@@ -114,4 +114,9 @@ public class ShiftInfoServiceImpl implements ShiftInfoService {
 
 
 	}
+
+	@Override
+	public List<ShiftInfo> findByRouteIdAndStatus(String routeId, String status) {
+		return shiftInfoDAO.findByRouteIdAndStatus(routeId,status);
+	}
 }

+ 9 - 0
common/src/main/resources/mapper/bus/ShiftInfo.xml

@@ -159,4 +159,13 @@
 		and status_ = #{status}
 		]]>
 	</select>
+
+	<select id="findByRouteIdAndStatus" resultMap="ShiftInfoMap">
+		<![CDATA[
+		select * from bus_shift_info
+		where del_flag = 0
+		and route_id = #{routeId}
+		and status_ = #{status}
+		]]>
+	</select>
 </mapper>

+ 22 - 4
common/src/main/resources/mapper/bus/StationInfo.xml

@@ -32,8 +32,8 @@
 ,#{sortNo,jdbcType= NUMERIC }
 ,#{routeId,jdbcType=VARCHAR}
 ,#{name,jdbcType=VARCHAR}
-,#{longitude,jdbcType=VARCHAR}
-,#{latitude,jdbcType=VARCHAR}
+,#{longitude,jdbcType=DOUBLE}
+,#{latitude,jdbcType=DOUBLE}
 ,#{classify,jdbcType= NUMERIC }
 ,#{createBy,jdbcType=VARCHAR}
 ,#{createTime,jdbcType= TIMESTAMP }
@@ -59,10 +59,10 @@
 		name_=#{name,jdbcType=VARCHAR},
 		</if>
 				<if test="longitude!=null">
-		longitude_=#{longitude,jdbcType=VARCHAR},
+		longitude_=#{longitude,jdbcType=DOUBLE},
 		</if>
 				<if test="latitude!=null">
-		latitude_=#{latitude,jdbcType=VARCHAR},
+		latitude_=#{latitude,jdbcType=DOUBLE},
 		</if>
 				<if test="classify!=null">
 		classify_=#{classify,jdbcType= NUMERIC },
@@ -106,6 +106,24 @@ id_,sort_no,route_id,name_,longitude_,latitude_,classify_,create_by,create_time,
 			<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>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">
 	        ${sort.name} ${sort.order}

+ 1 - 0
web/src/main/java/com/jpsoft/bus/config/WebMvcConfig.java

@@ -70,6 +70,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
 				.excludePathPatterns("/mobile/passengerApi/createPassengerOrder")
 				.excludePathPatterns("/mobile/passengerApi/deletePassengerOrder")
 				.excludePathPatterns("/mobile/passengerApi/updatePassengerOrder")
+				.excludePathPatterns("/mobile/passengerApi/passengerNearbyStation")
 				.excludePathPatterns("/aliPay/**")
 				.excludePathPatterns("/wxPay/**")
 				;

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

@@ -112,8 +112,8 @@ public class RouteInfoController {
                     String[] arr = stationDTO.getLocation().split(",");
 
                     if(arr.length>1){
-                        stationInfo.setLongitude(arr[0]);
-                        stationInfo.setLatitude(arr[1]);
+                        stationInfo.setLongitude(Double.parseDouble(arr[0]));
+                        stationInfo.setLatitude(Double.parseDouble(arr[1]));
                     }
 
                     stationInfo.setDelFlag(false);
@@ -166,7 +166,7 @@ public class RouteInfoController {
                     stationInfoDTO.setId(stationInfo.getId());
                     stationInfoDTO.setName(stationInfo.getName());
 
-                    if(StringUtils.isNotEmpty(stationInfo.getLongitude()) && StringUtils.isNotEmpty(stationInfo.getLatitude())){
+                    if(stationInfo.getLongitude() ==null && stationInfo.getLatitude() == null){
                         stationInfoDTO.setLocation(stationInfo.getLongitude()+","+stationInfo.getLatitude());
                     }
 
@@ -251,8 +251,8 @@ public class RouteInfoController {
                                 String[] arr = stationInfoDTO.getLocation().split(",");
 
                                 if (arr.length > 1) {
-                                    stationInfo.setLongitude(arr[0]);
-                                    stationInfo.setLatitude(arr[1]);
+                                    stationInfo.setLongitude(Double.parseDouble(arr[0]));
+                                    stationInfo.setLatitude(Double.parseDouble(arr[1]));
                                 }
                             }
 
@@ -276,8 +276,8 @@ public class RouteInfoController {
                                 String[] arr = stationInfoDTO.getLocation().split(",");
 
                                 if (arr.length > 1) {
-                                    stationInfo.setLongitude(arr[0]);
-                                    stationInfo.setLatitude(arr[1]);
+                                    stationInfo.setLongitude(Double.parseDouble(arr[0]));
+                                    stationInfo.setLatitude(Double.parseDouble(arr[1]));
                                 }
                             }
 

+ 5 - 5
web/src/main/java/com/jpsoft/bus/modules/bus/controller/StationInfoController.java

@@ -62,7 +62,7 @@ public class StationInfoController {
 
         return msgResult;
     }
-    
+
     @ApiOperation(value="添加信息")
     @PostMapping("add")
     public MessageResult<StationInfo> add(@RequestBody StationInfo stationInfo,@RequestAttribute String subject){
@@ -73,7 +73,7 @@ public class StationInfoController {
             stationInfo.setDelFlag(false);
             stationInfo.setCreateBy(subject);
             stationInfo.setCreateTime(new Date());
-            
+
             int affectCount = stationInfoService.insert(stationInfo);
 
             if (affectCount > 0) {
@@ -128,7 +128,7 @@ public class StationInfoController {
         try {
             stationInfo.setUpdateBy(subject);
             stationInfo.setUpdateTime(new Date());
-            
+
             int affectCount = stationInfoService.update(stationInfo);
 
             if (affectCount > 0) {
@@ -312,8 +312,8 @@ public class StationInfoController {
                     stationInfo.setId(UUID.randomUUID().toString());
                     stationInfo.setName(name);
                     stationInfo.setClassify(classify);
-                    stationInfo.setLongitude(longitude);
-                    stationInfo.setLatitude(Latitude);
+                    stationInfo.setLongitude(Double.parseDouble(longitude));
+                    stationInfo.setLatitude(Double.parseDouble(Latitude));
                     stationInfo.setRouteId(routeId);
 
                     stationInfo.setDelFlag(false);

+ 63 - 0
web/src/main/java/com/jpsoft/bus/modules/mobile/controller/PassengerApiController.java

@@ -685,4 +685,67 @@ public class PassengerApiController {
         return messageResult;
     }
 
+
+    @PostMapping("passengerNearbyStation")
+    @ApiOperation(value = "乘客附近站点")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "longitude", value = "经度", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "latitude", value = "纬度", required = true, paramType = "form")
+    })
+    public MessageResult<Map> passengerNearbyStation(String longitude,String latitude,@RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
+ @RequestParam(value = "pageSize", defaultValue = "5") int pageSize) {
+        MessageResult<Map> messageResult = new MessageResult<>();
+
+        try {
+
+            Double lo = Double.valueOf(longitude);
+            Double la = Double.valueOf(latitude);
+
+            Double maxLo = lo + 0.005D;
+            Double minLo = lo - 0.005D;
+            Double maxLa = la + 0.004D;
+            Double minLa = la - 0.004D;
+
+
+            Map<String,Object> searchParams = new HashMap<>();
+            searchParams.put("maxLongitude",maxLo);
+            searchParams.put("minLongitude",minLo);
+            searchParams.put("maxLatitude",maxLa);
+            searchParams.put("minLatitude",minLa);
+
+            List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("create_time","desc"));
+
+            Page<StationInfo> page = stationInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
+
+            List<StationInfo> stationInfoList = page.getResult();
+            if (stationInfoList.size()>0){
+                for (StationInfo stationInfo : stationInfoList){
+                    List<ShiftInfo> shiftInfoList = shiftInfoService.findByRouteIdAndStatus(stationInfo.getRouteId(),"1");
+                    if (shiftInfoList.size()>0){
+                        for (ShiftInfo shiftInfo : shiftInfoList){
+
+                        }
+                    }
+                }
+            }
+
+
+
+
+
+
+            messageResult.setResult(true);
+            messageResult.setCode(200);
+        } catch (Exception ex) {
+            log.error(ex.getMessage());
+            messageResult.setCode(400);
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
+
 }