Bläddra i källkod

Merge remote-tracking branch 'origin/master'

yanliming 4 år sedan
förälder
incheckning
7165565712

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

@@ -23,4 +23,6 @@ public interface PassengerInfoDAO {
     List<PassengerInfo> findByOpenIdAndStatus(String openId, String status,String payStatus);
 
 	List<PassengerInfo> findByOpenIdAndVehicleShiftId(String openId, String vehicleShiftId, String status, String payStatus);
+
+    List<PassengerInfo> findByShiftIdAndStatus(String shiftId, String status);
 }

+ 16 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/dto/LonLatDTO.java

@@ -0,0 +1,16 @@
+package com.jpsoft.bus.modules.bus.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2021-4-27 10:34
+ */
+@Data
+public class LonLatDTO {
+
+    private Double longitude;
+
+    private Double latitude;
+}

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

@@ -1,5 +1,6 @@
 package com.jpsoft.bus.modules.bus.dto;
 
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.util.List;
@@ -15,6 +16,10 @@ public class NearbyStationDTO {
 
     private String stationId;
 
+    private Double longitude;
+
+    private Double latitude;
+
     private Integer distance;
 
     private List<NearbyShiftDTO> nearbyShiftDTOList;

+ 14 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/dto/PassengerRecordDTO.java

@@ -29,6 +29,20 @@ public class PassengerRecordDTO {
 
     private BigDecimal totalFee;
 
+    private String status;
+
+    private String statusName;
+
+    public String getStatusName(String status){
+        String statusName = "未过期";
+
+        if (!"1".equals(status)){
+            statusName = "已过期";
+        }
+
+        return statusName;
+    }
+
 
     public String getTicketTypeName(String ticketType){
         String ticketTypeName = "成人票";

+ 8 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/dto/PassengerRecordDetailDTO.java

@@ -3,9 +3,11 @@ package com.jpsoft.bus.modules.bus.dto;
 import com.jpsoft.bus.modules.bus.entity.DriverInfo;
 import com.jpsoft.bus.modules.bus.entity.RouteInfo;
 import com.jpsoft.bus.modules.bus.entity.ShiftInfo;
+import com.jpsoft.bus.modules.bus.entity.VehicleInfo;
 import lombok.Data;
 
 import java.math.BigDecimal;
+import java.util.List;
 
 /**
  * @author 墨鱼_mo
@@ -18,8 +20,14 @@ public class PassengerRecordDetailDTO {
 
     private ShiftInfo shiftInfo;
 
+    private VehicleInfo vehicleInfo;
+
     private RouteInfo routeInfo;
 
+    private List<LonLatDTO> routeStationLonLat;
+
+    private List<LonLatDTO> ticketUpDownLonLat;
+
     private String tripName;
 
     private String ticketDes;

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

@@ -37,4 +37,6 @@ public interface PassengerInfoService {
     List<PassengerInfo> findByOpenIdAndStatus(String openId, String status,String payStatus);
 
 	List<PassengerInfo> findByOpenIdAndVehicleShiftId(String openId, String vehicleShiftId, String status,String payStatus);
+
+    List<PassengerInfo> findByShiftIdAndStatus(String shiftId, String status);
 }

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

@@ -25,4 +25,6 @@ public interface ShiftInfoService {
     List<ShiftInfo> findByRouteIdAndStatus(String routeId, String status);
 
     List<ShiftInfo> findByRouteIdAndStatusAndStartStationId(String routeId, String status, String startStationId);
+
+    void finishShift(ShiftInfo shiftInfo);
 }

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

@@ -484,4 +484,9 @@ public class PassengerInfoServiceImpl implements PassengerInfoService {
     public List<PassengerInfo> findByOpenIdAndVehicleShiftId(String openId, String vehicleShiftId, String status, String payStatus) {
         return passengerInfoDAO.findByOpenIdAndVehicleShiftId(openId,vehicleShiftId,status,payStatus);
     }
+
+    @Override
+    public List<PassengerInfo> findByShiftIdAndStatus(String shiftId, String status) {
+        return passengerInfoDAO.findByShiftIdAndStatus(shiftId,status);
+    }
 }

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

@@ -7,8 +7,10 @@ import java.util.UUID;
 import javax.annotation.Resource;
 
 import com.jpsoft.bus.modules.bus.dto.StationStatusDTO;
+import com.jpsoft.bus.modules.bus.entity.PassengerInfo;
 import com.jpsoft.bus.modules.bus.entity.VehicleInfo;
 import com.jpsoft.bus.modules.bus.service.GpsService;
+import com.jpsoft.bus.modules.bus.service.PassengerInfoService;
 import com.sun.xml.bind.v2.TODO;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -30,6 +32,9 @@ public class ShiftInfoServiceImpl implements ShiftInfoService {
 	@Autowired
 	private GpsService gpsService;
 
+	@Autowired
+	private PassengerInfoService passengerInfoService;
+
 	@Override
 	public ShiftInfo get(String id) {
 		// TODO Auto-generated method stub
@@ -129,4 +134,26 @@ public class ShiftInfoServiceImpl implements ShiftInfoService {
 	public List<ShiftInfo> findByRouteIdAndStatusAndStartStationId(String routeId, String status, String startStationId) {
 		return shiftInfoDAO.findByRouteIdAndStatusAndStartStationId(routeId,status,startStationId);
 	}
+
+	@Override
+	public void finishShift(ShiftInfo shiftInfo) {
+
+
+		shiftInfo.setStatus("2");
+		shiftInfo.setFinishTime(new Date());
+		shiftInfo.setUpdateTime(new Date());
+		update(shiftInfo);
+
+		//修改当前班次下所有未下次乘客为下车状态
+		List<PassengerInfo> passengerInfoList = passengerInfoService.findByShiftIdAndStatus(shiftInfo.getId(),"1");
+		if (passengerInfoList.size()>0){
+			for (PassengerInfo passengerInfo : passengerInfoList){
+				passengerInfo.setStatus("2");
+				passengerInfo.setDownTime(new Date());
+				passengerInfo.setUpdateTime(new Date());
+				passengerInfo.setUpdateBy(shiftInfo.getUpdateBy());
+				passengerInfoService.update(passengerInfo);
+			}
+		}
+	}
 }

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

@@ -255,4 +255,13 @@
         and t3.id_ = #{vehicleShiftId}
         order by t1.create_time asc
     </select>
+
+    <select id="findByShiftIdAndStatus" resultMap="PassengerInfoMap">
+        <![CDATA[
+        select * from bus_passenger_info
+        where del_flag = 0
+        and vehicle_shift_id = #{shiftId}
+        and status_ = #{status}
+        ]]>
+    </select>
 </mapper>

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

@@ -89,6 +89,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
 				.excludePathPatterns("/mobile/passengerApi/passengerRemindList")
 				.excludePathPatterns("/mobile/passengerApi/passengerShiftRemindList")
 				.excludePathPatterns("/mobile/passengerApi/helpCenterList")
+				.excludePathPatterns("/mobile/passengerApi/vehicleStationDis")
 
 
 		;

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

@@ -1118,15 +1118,19 @@ public class DriverApiController {
             if (shiftInfoList.size() == 0){
                 throw new Exception("车辆没有相关班次信息");
             }
-
             ShiftInfo shiftInfo = shiftInfoList.get(0);
+            shiftInfo.setUpdateBy(subject);
+            //收班
+            shiftInfoService.finishShift(shiftInfo);
+
 
-            shiftInfo.setStatus("2");
+
+            /*shiftInfo.setStatus("2");
             shiftInfo.setFinishTime(new Date());
             shiftInfo.setUpdateTime(new Date());
             shiftInfo.setUpdateBy(subject);
 
-            shiftInfoService.update(shiftInfo);
+            shiftInfoService.update(shiftInfo);*/
 
             //todo 填写具体代码
             messageResult.setData(shiftInfo.getFinishTime());

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

@@ -254,6 +254,8 @@ public class PassengerApiController {
             //班次信息
             ShiftInfo shiftInfo = shiftInfoList.get(0);
 
+            DriverInfo driverInfo = driverInfoService.get(shiftInfo.getDriverId());
+
             //车辆信息
             VehicleInfo vehicleInfo = vehicleInfoService.get(id);
 
@@ -282,6 +284,8 @@ public class PassengerApiController {
             map.put("endTime", routeInfo.getEndTime());
             map.put("routeName", routeInfo.getName());
             map.put("mapPath", routeInfo.getMapPath());
+            map.put("driver",driverInfo);
+            map.put("licensePlateNumber",vehicleInfo.getLicensePlateNumber());
             //    map.put("stationList",vehicleStationDTOList);
             messageResult.setData(map);
             messageResult.setResult(true);
@@ -948,6 +952,8 @@ public class PassengerApiController {
 
             nearbyStationDTO.setStationId(stationInfo.getId());
             nearbyStationDTO.setStationName(stationInfo.getName());
+            nearbyStationDTO.setLatitude(stationInfo.getLatitude());
+            nearbyStationDTO.setLongitude(stationInfo.getLongitude());
 
             for (int n = 0; n < 2; n++) {
                 String startStationId = stationInfoList1.get(0).getId();
@@ -1124,6 +1130,103 @@ public class PassengerApiController {
         return messageResult;
     }
 
+    @PostMapping("vehicleStationDis")
+    @ApiOperation(value = "站点车辆距离")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "routeId", value = "线路id", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "startStationId", value = "开始站点id", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "currentStationId", value = "当前站点id", required = true, paramType = "form")
+    })
+    public MessageResult<String> vehicleStationDis(String routeId, String startStationId,String currentStationId) {
+        MessageResult<String> messageResult = new MessageResult<>();
+
+        try {
+
+            if (StringUtils.isBlank(routeId) || StringUtils.isBlank(startStationId)) {
+                throw new Exception("参数错误");
+            }
+
+            List<StationInfo> stationInfoList = stationInfoService.findByRouteId(routeId);
+            //是否顺路
+            Boolean tmp = true;
+            if (!startStationId.equals(stationInfoList.get(0).getId())){
+                tmp = false;
+            }
+
+            List<ShiftInfo> shiftInfoList = shiftInfoService.findByRouteIdAndStatusAndStartStationId(routeId,"1",startStationId);
+            //查询的当前站
+            StationInfo currentStation = stationInfoService.get(currentStationId);
+
+            String des = null;
+            if (shiftInfoList.size()>0){
+                String vehicleId = "";
+                int n = 1000;
+                for (ShiftInfo shiftInfo : shiftInfoList){
+                    //班次当前站
+                    StationInfo stationInfo = stationInfoService.get(shiftInfo.getCurrentStationId());
+                    int stationInfoIndex = stationInfoList.indexOf(stationInfo);
+
+                    int currentStationIndex = stationInfoList.indexOf(currentStation);
+                    if (tmp){
+                        if (stationInfoIndex<=currentStationIndex){
+                          int  m = currentStationIndex - stationInfoIndex;
+                            if (m<n){
+                                n = m;
+                                vehicleId = shiftInfo.getVehicleId();
+                            }
+                        }
+
+                    }
+                    if (!tmp){
+                        if (stationInfoIndex >= currentStationIndex){
+                            int  m = stationInfoIndex - currentStationIndex;
+                            if (m<n){
+                                n = m;
+                                vehicleId = shiftInfo.getVehicleId();
+                            }
+                        }
+                    }
+
+                }
+
+                if (StringUtils.isNotBlank(vehicleId)){
+                    //车辆
+                    VehicleInfo vehicleInfo = vehicleInfoService.get(vehicleId);
+                    //距离
+                    GlobalCoordinates source = new GlobalCoordinates(Double.valueOf(vehicleInfo.getLatitude()), Double.valueOf(vehicleInfo.getLongitude()));
+                    GlobalCoordinates target = new GlobalCoordinates(Double.valueOf(currentStation.getLatitude()), Double.valueOf(currentStation.getLongitude()));
+
+                    double meter1 = CommonUtil.getDistanceMeter(source, target, Ellipsoid.Sphere);
+
+                    int intMeter = (new Double(meter1)).intValue();
+                    //距离详情
+                    String distanceStr = null;
+                    if (intMeter >= 1000) {
+                        distanceStr = intMeter / 1000 + "公里";
+                    } else {
+                        distanceStr = intMeter + "米";
+                    }
+                    des = n + "站 "+ distanceStr;
+                }
+            }
+
+            messageResult.setData(des);
+            messageResult.setCode(200);
+            messageResult.setResult(true);
+
+
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+            messageResult.setCode(400);
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
+
+
 
     @PostMapping("routeList")
     @ApiOperation(value = "乘客查询线路列表")
@@ -1411,6 +1514,8 @@ public class PassengerApiController {
                     passengerRecordDTO.setGoodTicket(orderInfo.getGoodsTicket());
                     passengerRecordDTO.setPayTime(DateUtil.format(orderInfo.getPayTime(), "yyyy-MM-dd HH:mm:ss"));
                     passengerRecordDTO.setTotalFee(orderInfo.getTotalFee());
+                    passengerRecordDTO.setStatus(passengerInfo.getStatus());
+                    passengerRecordDTO.setStatusName(passengerRecordDTO.getStatusName(passengerInfo.getStatus()));
                     list.add(passengerRecordDTO);
 
                 }
@@ -1459,8 +1564,19 @@ public class PassengerApiController {
             ShiftInfo shiftInfo = shiftInfoService.get(passengerInfo.getVehicleShiftId());
             //开始站
             StationInfo startStation = stationInfoService.get(shiftInfo.getStartStationId());
+            LonLatDTO lonLatDTO1 = new LonLatDTO();
+            lonLatDTO1.setLatitude(startStation.getLatitude());
+            lonLatDTO1.setLongitude(startStation.getLongitude());
             //终点站
             StationInfo endStation = stationInfoService.get(shiftInfo.getEndStationId());
+            LonLatDTO lonLatDTO2 = new LonLatDTO();
+            lonLatDTO2.setLatitude(endStation.getLatitude());
+            lonLatDTO2.setLongitude(endStation.getLongitude());
+
+            List<LonLatDTO> routeStationLonLat = new ArrayList<>();
+            routeStationLonLat.add(lonLatDTO1);
+            routeStationLonLat.add(lonLatDTO2);
+
 
             shiftInfo.setStartStationName(startStation.getName());
             shiftInfo.setEndStationName(endStation.getName());
@@ -1468,13 +1584,27 @@ public class PassengerApiController {
             //线路
             RouteInfo routeInfo = routeInfoService.get(shiftInfo.getRouteId());
 
+            //车辆
+            VehicleInfo vehicleInfo = vehicleInfoService.get(shiftInfo.getVehicleId());
+
             //司机
             DriverInfo driverInfo = driverInfoService.get(shiftInfo.getDriverId());
 
             //购票上车站点
             StationInfo ticketUpStation = stationInfoService.get(orderInfo.getTicketUpStationId());
+            LonLatDTO lonLatDTO3 = new LonLatDTO();
+            lonLatDTO3.setLatitude(ticketUpStation.getLatitude());
+            lonLatDTO3.setLongitude(ticketUpStation.getLongitude());
+
             //购票下次站点
             StationInfo ticketDownStation = stationInfoService.get(orderInfo.getTicketDownStationId());
+            LonLatDTO lonLatDTO4 = new LonLatDTO();
+            lonLatDTO4.setLatitude(ticketDownStation.getLatitude());
+            lonLatDTO4.setLongitude(ticketDownStation.getLongitude());
+
+            List<LonLatDTO> ticketUpDownLonLat = new ArrayList<>();
+            ticketUpDownLonLat.add(lonLatDTO3);
+            ticketUpDownLonLat.add(lonLatDTO4);
 
             //购票类型
             String ticketTypeName = "成人票";
@@ -1495,6 +1625,9 @@ public class PassengerApiController {
             passengerRecordDetailDTO.setTicketStatus(passengerInfo.getStatus());
             passengerRecordDetailDTO.setTicketStatusName(passengerRecordDetailDTO.getTicketStatusName(passengerRecordDetailDTO.getTicketStatus()));
             passengerRecordDetailDTO.setShiftInfo(shiftInfo);
+            passengerRecordDetailDTO.setVehicleInfo(vehicleInfo);
+            passengerRecordDetailDTO.setRouteStationLonLat(routeStationLonLat);
+            passengerRecordDetailDTO.setTicketUpDownLonLat(ticketUpDownLonLat);
 
             messageResult.setData(passengerRecordDetailDTO);
             messageResult.setCode(200);

+ 6 - 5
web/src/main/java/com/jpsoft/bus/modules/mq/listener/StationRemindListener.java

@@ -2,10 +2,7 @@ package com.jpsoft.bus.modules.mq.listener;
 
 import com.jpsoft.bus.config.WxConfig;
 import com.jpsoft.bus.modules.bus.entity.*;
-import com.jpsoft.bus.modules.bus.service.RouteInfoService;
-import com.jpsoft.bus.modules.bus.service.StationInfoService;
-import com.jpsoft.bus.modules.bus.service.StationRemindService;
-import com.jpsoft.bus.modules.bus.service.VehicleInfoService;
+import com.jpsoft.bus.modules.bus.service.*;
 import com.jpsoft.bus.modules.common.utils.CommonUtil;
 import com.jpsoft.bus.modules.common.utils.WechatMessageUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -31,6 +28,9 @@ public class StationRemindListener {
     @Autowired
     private VehicleInfoService vehicleInfoService;
 
+    @Autowired
+    private DriverInfoService driverInfoService;
+
     @Autowired
     private StationRemindService stationRemindService;
 
@@ -57,13 +57,14 @@ public class StationRemindListener {
             StationInfo endStation = stationInfoService.get(shiftInfo.getEndStationId());
 
             VehicleInfo vehicleInfo = vehicleInfoService.get(shiftInfo.getVehicleId());
+            DriverInfo driverInfo = driverInfoService.get(shiftInfo.getDriverId());
 
             //当前车辆所在站点
             StationInfo stationInfo = stationInfoService.get(shiftInfo.getCurrentStationId());
 
             for (StationRemind stationRemind : stationRemindList) {
                 try {
-                    String remindStr = "上车刷脸听到“感谢乘车”通行,入座扫码手机购票。";
+                    String remindStr = "上车刷脸听到“感谢乘车”通行,入座扫码手机购票。司机:"+driverInfo.getName() + ",电话:"+ driverInfo.getPhone();
 
                     if (stationRemind.getRemindType() != null && stationRemind.getRemindType() == 2) {
                         //下车提醒要判断是不是同一个班次