Parcourir la source

车辆站点更新时判断乘客是否过站

fllmoyu il y a 4 ans
Parent
commit
75a1049bce

+ 45 - 7
common/src/main/java/com/jpsoft/bus/modules/bus/callback/GpsDataCallbackImpl.java

@@ -1,17 +1,12 @@
 package com.jpsoft.bus.modules.bus.callback;
 
 import cn.hutool.core.lang.UUID;
-import com.jpsoft.bus.modules.bus.entity.ShiftInfo;
-import com.jpsoft.bus.modules.bus.service.GpsService;
-import com.jpsoft.bus.modules.bus.service.ShiftInfoService;
+import com.jpsoft.bus.modules.bus.entity.*;
+import com.jpsoft.bus.modules.bus.service.*;
 import com.jpsoft.bus.modules.common.utils.CommonUtil;
 import com.jpsoft.gps.callback.GpsDataCallback;
 import com.jpsoft.gps.utils.GPSUtil;
 import com.jpsoft.bus.config.GpsParamConfig;
-import com.jpsoft.bus.modules.bus.entity.GpsDataInfo;
-import com.jpsoft.bus.modules.bus.entity.VehicleInfo;
-import com.jpsoft.bus.modules.bus.service.GpsDataInfoService;
-import com.jpsoft.bus.modules.bus.service.VehicleInfoService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.joda.time.DateTime;
@@ -36,6 +31,12 @@ public class GpsDataCallbackImpl implements GpsDataCallback {
     @Autowired
     private GpsService gpsService;
 
+    @Autowired
+    private StationInfoService stationInfoService;
+
+    @Autowired
+    private PassengerInfoService passengerInfoService;
+
     @Autowired
     private ShiftInfoService shiftInfoService;
 
@@ -120,6 +121,43 @@ public class GpsDataCallbackImpl implements GpsDataCallback {
                         if (!shiftInfo.getCurrentStationId().equals(stationId)){
                             shiftInfo.setCurrentStationId(stationId);
                             shiftInfoService.update(shiftInfo);
+
+                            //当前站点
+                            StationInfo currentStation = stationInfoService.get(stationId);
+                            //此线路的所有站点
+                            List<StationInfo> stationInfoList = stationInfoService.findByRouteId(shiftInfo.getRouteId());
+
+                            //站点集合大小
+                            int stationSize = stationInfoList.size();
+
+                            int currentStationIndex = stationInfoList.indexOf(currentStation);
+
+
+
+                            //查询乘客表是否有过站的情况
+
+                            List<PassengerInfo> passengerInfoList = passengerInfoService.findByShiftStatusPayStatusNotTicketDown(shiftInfo.getId(),"1","1",stationId);
+                            if (passengerInfoList.size()>0){
+                                for (PassengerInfo passengerInfo : passengerInfoList){
+
+                                    //乘客购票的下车站点
+                                    StationInfo downStation = stationInfoService.get(passengerInfo.getTicketDownStationId());
+                                    int downStationIndex = stationInfoList.indexOf(downStation);
+                                    //按照线路顺行并且当前站点大于乘客购票站点,则过站
+                                    if (shiftInfo.getStartStationId().equals(stationInfoList.get(0).getId()) && currentStationIndex > downStationIndex){
+                                        passengerInfo.setPayStatus("2");
+                                        passengerInfoService.update(passengerInfo);
+                                    }
+
+                                    //按照线路逆行并且当前站点小于乘客购票站点,则过站
+                                    if (!shiftInfo.getStartStationId().equals(stationInfoList.get(0).getId()) && currentStationIndex < downStationIndex){
+                                        passengerInfo.setPayStatus("2");
+                                        passengerInfoService.update(passengerInfo);
+                                    }
+
+
+                                }
+                            }
                         }
                     }
                 }catch (Exception ex){

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

@@ -17,4 +17,6 @@ public interface PassengerInfoDAO {
 	List<PassengerInfo> search(Map<String,Object> searchParams,List<Sort> sortList);
 
     List<PassengerInfo> findByPersonIdShiftIdStatus(Long personId, String shiftId, String status);
+
+    List<PassengerInfo> findByShiftStatusPayStatusNotTicketDown(String shiftId, String status, String payStatus,String ticketDownStationId);
 }

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

@@ -24,4 +24,6 @@ public interface PassengerInfoService {
     void passengerFace(VehicleInfo vehicleInfo, ShiftInfo shiftInfo, String retFileUrl, String recordTime, String stationId,String personId) throws Exception;
 
 	DriverBuyTicketDTO driverBuyTicket(PassengerInfo passengerInfo, String ticketUpStationId, String ticketDownStationId, String ticketType, String goodsTicket, String totalFee, String payName,String paymentId) throws Exception;
+
+    List<PassengerInfo> findByShiftStatusPayStatusNotTicketDown(String shiftId, String status, String payStatus,String ticketDownStationId);
 }

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

@@ -245,4 +245,9 @@ public class PassengerInfoServiceImpl implements PassengerInfoService {
 
 		return driverBuyTicketDTO;
 	}
+
+    @Override
+    public List<PassengerInfo> findByShiftStatusPayStatusNotTicketDown(String shiftId, String status, String payStatus,String ticketDownStationId) {
+        return passengerInfoDAO.findByShiftStatusPayStatusNotTicketDown(shiftId,status,payStatus,ticketDownStationId);
+    }
 }

+ 11 - 0
common/src/main/resources/mapper/bus/PassengerInfo.xml

@@ -193,4 +193,15 @@
 			and status_ = #{status}
 		</if>
 	</select>
+
+	<select id="findByShiftStatusPayStatusNotTicketDown" resultMap="PassengerInfoMap">
+		<![CDATA[
+		select  * from bus_passenger_info
+		where del_flag = 0
+		and vehicle_shift_id = #{shiftId}
+		and status_ = #{status}
+		and pay_status = #{payStatus}
+		and ticket_down_station_id <> #{ticketDownStationId}
+		]]>
+	</select>
 </mapper>