Explorar o código

增加保存本地人脸图片信息

zhengqiang %!s(int64=4) %!d(string=hai) anos
pai
achega
871dfc2537

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

@@ -27,6 +27,8 @@ public class PassengerDetailDTO {
 
     private String imageUrl;
 
+    private String localImageUrl;
+
     private String upStationId;
 
     private String upStationName;

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

@@ -29,6 +29,8 @@ public class PassengerInfo {
     private Long userId;
     @ApiModelProperty(value = "乘车人照片")
     private String imageUrl;
+    @ApiModelProperty(value = "乘车人本地照片")
+    private String localImageUrl;
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
     @ApiModelProperty(value = "上车时间")

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

@@ -22,7 +22,7 @@ public interface PassengerInfoService {
 
 	List<PassengerInfo> findByPersonIdShiftIdStatus(Long personId,String shiftId,String status);
 
-    void passengerFace(VehicleInfo vehicleInfo, ShiftInfo shiftInfo, String retFileUrl, String recordTime, String stationId,Long libId,Long personId) throws Exception;
+    void passengerFace(VehicleInfo vehicleInfo, ShiftInfo shiftInfo, String retFileUrl, String recordTime, String stationId,Long libId,Long personId,String localImageUrl) throws Exception;
 
 	DriverBuyTicketDTO driverBuyTicket(PassengerInfo passengerInfo, String ticketUpStationId, String ticketDownStationId, String ticketType, String goodsTicket, String totalFee, String payName,String paymentId) throws Exception;
 

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

@@ -20,7 +20,7 @@ public interface ShiftInfoService {
 
     List<ShiftInfo> findByVehicleIdAndStatus(String vehicleId, String status);
 
-    void createShift(VehicleInfo vehicleInfo, Long driverId, String startStationId, String endStationId) throws Exception;
+	ShiftInfo createShift(VehicleInfo vehicleInfo, Long driverId, String startStationId, String endStationId) throws Exception;
 
     List<ShiftInfo> findByRouteIdAndStatus(String routeId, String status);
 }

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

@@ -244,7 +244,7 @@ public class GpsServiceImpl implements GpsService {
          StationInfo currentStation = stationInfoService.get(shiftInfo.getCurrentStationId());
 
          //下一站站点
-        StationInfo nextStation = null;
+         StationInfo nextStation = null;
 
          Integer index = stationInfoList.indexOf(currentStation);
 
@@ -260,7 +260,8 @@ public class GpsServiceImpl implements GpsService {
          }
 
          if(StringUtils.isNotEmpty(vehicleInfo.getLatitude())
-         && StringUtils.isNotEmpty(vehicleInfo.getLatitude())) {
+         && StringUtils.isNotEmpty(vehicleInfo.getLatitude())
+         && currentStation!=null) {
              //车辆离当前站点的距离
              GlobalCoordinates source = new GlobalCoordinates(Double.valueOf(vehicleInfo.getLatitude()), Double.valueOf(vehicleInfo.getLongitude()));
              GlobalCoordinates target = new GlobalCoordinates(Double.valueOf(currentStation.getLatitude()), Double.valueOf(currentStation.getLongitude()));
@@ -308,9 +309,16 @@ public class GpsServiceImpl implements GpsService {
             List<StationInfo> stationInfoList = stationInfoService.findByRouteId(routeInfo.getId());
             currentStationId = shiftInfo.getCurrentStationId();
 
-            //当前站点
-            StationInfo currentStation = stationInfoService.get(currentStationId);
-            int currentIndex = currentStation.getSortNo();
+            int currentIndex = 0;
+
+            if(StringUtils.isNotEmpty(currentStationId)){
+                //当前站点
+                StationInfo currentStation = stationInfoService.get(currentStationId);
+
+                if(currentStation!=null) {
+                    currentIndex = currentStation.getSortNo();
+                }
+            }
 
             //线路终点站
             StationInfo endStation = stationInfoService.get(shiftInfo.getEndStationId());

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

@@ -117,7 +117,7 @@ public class PassengerInfoServiceImpl implements PassengerInfoService {
 
     @Override
     public void passengerFace(VehicleInfo vehicleInfo, ShiftInfo shiftInfo, String retFileUrl, String recordTime,
-                              String stationId,Long libId, Long personId) throws Exception {
+                              String stationId,Long libId, Long personId,String localImageUrl) throws Exception {
         Date recordDate = DateUtil.parse(recordTime, "yyyy-MM-dd HH:mm:ss");
 
         //查询是否有已上车的乘客记录
@@ -125,6 +125,7 @@ public class PassengerInfoServiceImpl implements PassengerInfoService {
 
         if (passengerInfoList.size() > 0) {
             PassengerInfo passengerInfo = passengerInfoList.get(0);
+            passengerInfo.setLocalImageUrl(localImageUrl);
             passengerInfo.setDownTime(recordDate);
             passengerInfo.setDownStationId(stationId);
             passengerInfo.setStatus("2");
@@ -144,6 +145,8 @@ public class PassengerInfoServiceImpl implements PassengerInfoService {
                 passengerInfo.setPayStatus("0");
                 passengerInfo.setCreateTime(new Date());
 
+                passengerInfo.setLocalImageUrl(localImageUrl);
+
                 if (StringUtils.isNotEmpty(retFileUrl)) {
                     passengerInfo.setImageUrl(retFileUrl);
                 } else {

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

@@ -6,9 +6,11 @@ import java.util.Map;
 import java.util.UUID;
 import javax.annotation.Resource;
 
+import com.jpsoft.bus.modules.bus.dto.StationStatusDTO;
 import com.jpsoft.bus.modules.bus.entity.VehicleInfo;
 import com.jpsoft.bus.modules.bus.service.GpsService;
 import com.sun.xml.bind.v2.TODO;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
@@ -88,7 +90,7 @@ public class ShiftInfoServiceImpl implements ShiftInfoService {
 	}
 
 	@Override
-	public void createShift(VehicleInfo vehicleInfo, Long driverId, String startStationId, String endStationId) throws Exception {
+	public ShiftInfo createShift(VehicleInfo vehicleInfo, Long driverId, String startStationId, String endStationId) throws Exception {
 		List<ShiftInfo> shiftInfoList = findByVehicleIdAndStatus(vehicleInfo.getId(),"1");
 		if (shiftInfoList.size()>0){
 			for (ShiftInfo shiftInfo : shiftInfoList){
@@ -97,8 +99,11 @@ public class ShiftInfoServiceImpl implements ShiftInfoService {
 			}
 		}
 		//TODO 根据经纬度查询当前站点
-		//String currentStationId = gpsService.getLatelyStation(vehicleInfo.getId());
-		String currentStationId = startStationId;
+		String currentStationId = gpsService.getLatelyStation(vehicleInfo.getId());
+
+		if (StringUtils.isEmpty(currentStationId)) {
+			currentStationId = startStationId;
+		}
 
 		ShiftInfo shiftInfo = new ShiftInfo();
 		shiftInfo.setId(UUID.randomUUID().toString());
@@ -112,7 +117,7 @@ public class ShiftInfoServiceImpl implements ShiftInfoService {
 		shiftInfo.setCreateTime(new Date());
 		insert(shiftInfo);
 
-
+		return shiftInfo;
 	}
 
 	@Override

+ 7 - 1
common/src/main/resources/mapper/bus/PassengerInfo.xml

@@ -10,6 +10,7 @@
         <result property="vehiclePersonId" column="vehicle_person_id"/>
         <result property="userId" column="user_id"/>
         <result property="imageUrl" column="image_url"/>
+        <result property="localImageUrl" column="local_image_url"/>
         <result property="upTime" column="up_time"/>
         <result property="downTime" column="down_time"/>
         <result property="upStationId" column="up_station_id"/>
@@ -38,7 +39,8 @@
         <![CDATA[
 		insert into bus_passenger_info
 	    (id_,vehicle_shift_id,vehicle_lib_id,vehicle_person_id,user_id,image_url,up_time,down_time,up_station_id,
-	    down_station_id,status_,pay_status,create_by,create_time,update_by,update_time,del_flag,ticket_up_station_id,ticket_down_station_id)
+	    down_station_id,status_,pay_status,create_by,create_time,update_by,update_time,del_flag,
+	    ticket_up_station_id,ticket_down_station_id,local_image_url)
 		values
 		(
 			#{id,jdbcType=VARCHAR}
@@ -60,6 +62,7 @@
 			,#{delFlag,jdbcType= NUMERIC }
 			,#{ticketUpStationId,jdbcType=VARCHAR}
 			,#{ticketDownStationId,jdbcType=VARCHAR}
+			,#{localImageUrl,jdbcType=VARCHAR}
 		)
 	]]>
     </insert>
@@ -84,6 +87,9 @@
             <if test="imageUrl!=null">
                 image_url=#{imageUrl,jdbcType=VARCHAR},
             </if>
+            <if test="localImageUrl!=null">
+                local_image_url=#{localImageUrl,jdbcType=VARCHAR},
+            </if>
             <if test="upTime!=null">
                 up_time=#{upTime,jdbcType= TIMESTAMP },
             </if>

+ 47 - 6
web/src/main/java/com/jpsoft/bus/modules/driver/controller/DriverApiController.java

@@ -318,10 +318,13 @@ public class DriverApiController {
             @ApiImplicitParam(name = "endStationId", value = "终点站id", required = true, paramType = "form")
 
     })
-    public MessageResult<Map> createShift(Long driverId,String startStationId,String endStationId ,String token, @RequestAttribute String subject) {
+    public MessageResult<Map> createShift(@RequestBody JSONObject requestBody, @RequestAttribute String subject) {
         MessageResult<Map> messageResult = new MessageResult<>();
 
         try {
+            Long driverId = requestBody.getLong("driverId");
+            String startStationId = requestBody.getString("startStationId");
+            String endStationId = requestBody.getString("endStationId");
 
             VehicleInfo vehicleInfo = vehicleInfoService.get(subject);
             if (vehicleInfo == null){
@@ -332,26 +335,60 @@ public class DriverApiController {
                 throw new Exception("司机不存在");
             }
 
-            List<ShiftInfo> shiftInfo = shiftInfoService.findByDriverIdAndStatus(driverInfo.getId(),"1");
+            List<ShiftInfo> shiftInfoList = shiftInfoService.findByDriverIdAndStatus(driverInfo.getId(),"1");
 
-            if (shiftInfo.size()>0){
+            if (shiftInfoList.size()>0){
                 throw new Exception("已有正在运行的班次!");
             }
 
             //始发站
             StationInfo start = stationInfoService.get(startStationId);
+
             //终点站
             StationInfo end = stationInfoService.get(endStationId);
+
             if (start == null || end == null){
                 throw new Exception("站点错误");
             }
+
             if (!start.getRouteId().equals(vehicleInfo.getRouteId()) || !end.getRouteId().equals(vehicleInfo.getRouteId())){
                 throw new Exception("站点错误");
             }
-            shiftInfoService.createShift(vehicleInfo,driverId,startStationId,endStationId);
 
+            ShiftInfo shiftInfo = shiftInfoService.createShift(vehicleInfo,driverId,startStationId,endStationId);
+
+            //司机名称
+            shiftInfo.setDriverName(driverInfo.getName());
+
+            //车辆车牌
+            shiftInfo.setVehicleNumber(vehicleInfo.getLicensePlateNumber());
+
+            //路线名称
+            RouteInfo routeInfo = routeInfoService.get(vehicleInfo.getRouteId());
+
+            shiftInfo.setRouteName(routeInfo.getName());
+
+            //起始站
+            shiftInfo.setStartStationName(start.getName());
+
+            //当前站点
+            StationInfo currentStation = stationInfoService.get(shiftInfo.getCurrentStationId());
+
+            if(currentStation != null) {
+                shiftInfo.setCurrentStationName(currentStation.getName());
+            }
+
+            //终点站
+            shiftInfo.setEndStationName(end.getName());
+
+            List<StationInfo> stationInfoList = stationInfoService.findByRouteId(shiftInfo.getRouteId());
+
+            Map<String,Object> dataMap = new HashMap<>();
+            dataMap.put("shiftInfo", shiftInfo);
+            dataMap.put("stationInfoList", stationInfoList);
 
             messageResult.setResult(true);
+            messageResult.setData(dataMap);
             messageResult.setCode(200);
         } catch (Exception ex) {
             log.error(ex.getMessage(),ex);
@@ -393,14 +430,16 @@ public class DriverApiController {
             //当前站点
             StationInfo currentStation = stationInfoService.get(shiftInfo.getCurrentStationId());
 
+            //根据车辆当前坐标
             StationStatusDTO stationStatusDTO = gpsService.queryStation(vehicleInfo.getId());
+
             Map<String,Object> map = new HashMap<>();
             map.put("startStationId",startStation.getId());
             map.put("startStationName",startStation.getName());
             map.put("endStationId",endStation.getId());
             map.put("endStationName",endStation.getName());
 
-            if(currentStation!=null) {
+            if(currentStation != null) {
                 map.put("currentStationId", currentStation.getId());
                 map.put("currentStationName", currentStation.getName());
             }
@@ -478,6 +517,7 @@ public class DriverApiController {
             Long personId = requestBody.getLong("personId");
             String photoBase64Data = requestBody.getString("photoBase64Data");
             String recordTime = requestBody.getString("recordTime");
+            String localImageUrl = requestBody.getString("localImageUrl");
 
             //同一辆车相同乘客上下车登记间隔1分钟
             String key = subject + "_" + personId;
@@ -515,7 +555,7 @@ public class DriverApiController {
                     currentStationId = gpsDataInfo.getStationId();
                 }
 
-                passengerInfoService.passengerFace(vehicleInfo, shiftInfo, retFileUrl, recordTime, currentStationId,libId, personId);
+                passengerInfoService.passengerFace(vehicleInfo, shiftInfo, retFileUrl, recordTime, currentStationId,libId, personId,localImageUrl);
                 messageResult.setResult(true);
                 messageResult.setCode(200);
             }
@@ -645,6 +685,7 @@ public class DriverApiController {
             passengerDetailDTO.setVehicleLibId(passengerInfo.getVehicleLibId());
             passengerDetailDTO.setVehiclePersonId(passengerInfo.getVehiclePersonId());
             passengerDetailDTO.setImageUrl(passengerInfo.getImageUrl());
+            passengerDetailDTO.setLocalImageUrl(passengerInfo.getLocalImageUrl());
             passengerDetailDTO.setUpTime(passengerInfo.getUpTime());
             passengerDetailDTO.setUpStationId(passengerInfo.getUpStationId());