소스 검색

gps实时数据更新添加站点

fllmoyu 4 년 전
부모
커밋
5b94db0fb6

+ 11 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/callback/GpsDataCallbackImpl.java

@@ -73,6 +73,7 @@ public class GpsDataCallbackImpl implements GpsDataCallback {
                 }
             }
 
+            GpsDataInfo gpsDataInfo0 = null;
             if(allowInsert) {
                 log.warn("保存历史数据:{}", deviceNo);
                 GpsDataInfo gpsDataInfo = new GpsDataInfo();
@@ -83,7 +84,9 @@ public class GpsDataCallbackImpl implements GpsDataCallback {
                 gpsDataInfo.setLongitude(longitude);
                 gpsDataInfo.setDelFlag(false);
 
+
                 gpsDataInfoService.insert(gpsDataInfo);
+                gpsDataInfo0 = gpsDataInfo;
 
                 valueOperations.set(histKey, (new Date()).getTime(), 1, TimeUnit.HOURS);
             }
@@ -123,6 +126,9 @@ public class GpsDataCallbackImpl implements GpsDataCallback {
                             shiftInfo.setCurrentStationId(stationId);
                             shiftInfoService.update(shiftInfo);
 
+
+
+
                             //当前站点
                             StationInfo currentStation = stationInfoService.get(stationId);
                             //此线路的所有站点
@@ -161,6 +167,11 @@ public class GpsDataCallbackImpl implements GpsDataCallback {
                                 }
                             }
                         }
+
+                        if (gpsDataInfo0 != null){
+                            gpsDataInfo0.setStationId(shiftInfo.getCurrentStationId());
+                            gpsDataInfoService.update(gpsDataInfo0);
+                        }
                     }
                 }catch (Exception ex){
                     log.error(ex.getMessage(),ex);

+ 3 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/dao/GpsDataInfoDAO.java

@@ -4,6 +4,7 @@ import com.jpsoft.bus.modules.bus.entity.GpsDataInfo;
 import com.jpsoft.bus.modules.common.dto.Sort;
 import org.springframework.stereotype.Repository;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -17,4 +18,6 @@ public interface GpsDataInfoDAO {
 	List<GpsDataInfo> list();
 	List<GpsDataInfo> search(Map<String, Object> searchParams, List<Sort> sortList);
     GpsDataInfo findLast(String deviceNo);
+
+    GpsDataInfo findByDeviceNoAndCreateTime(String gpsDeviceNo, Date maxTime, Date minTime);
 }

+ 3 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/entity/GpsDataInfo.java

@@ -34,6 +34,9 @@ public class GpsDataInfo {
      */
     @ApiModelProperty(value = "纬度")
     private String latitude;
+
+    @ApiModelProperty(value = "站点id")
+    private String stationId;
     /**
      * 创建人
      */

+ 3 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/service/GpsDataInfoService.java

@@ -4,6 +4,7 @@ import com.github.pagehelper.Page;
 import com.jpsoft.bus.modules.bus.entity.GpsDataInfo;
 import com.jpsoft.bus.modules.common.dto.Sort;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -16,4 +17,6 @@ public interface GpsDataInfoService {
 	List<GpsDataInfo> list();
 	Page<GpsDataInfo> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, boolean count, List<Sort> sortList);
     GpsDataInfo findLast(String deviceNo);
+
+    GpsDataInfo findByDeviceNoAndCreateTime(String gpsDeviceNo, Date maxTime, Date minTime);
 }

+ 6 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/service/impl/GpsDataInfoServiceImpl.java

@@ -10,6 +10,7 @@ import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -72,4 +73,9 @@ public class GpsDataInfoServiceImpl implements GpsDataInfoService {
 	public GpsDataInfo findLast(String deviceNo) {
 		return gpsDataInfoDAO.findLast(deviceNo);
 	}
+
+	@Override
+	public GpsDataInfo findByDeviceNoAndCreateTime(String gpsDeviceNo, Date maxTime, Date minTime) {
+		return gpsDataInfoDAO.findByDeviceNoAndCreateTime(gpsDeviceNo,maxTime,minTime);
+	}
 }

+ 19 - 3
common/src/main/resources/mapper/bus/GpsDataInfo.xml

@@ -8,6 +8,7 @@
         <result property="deviceNo" column="device_no"/>
         <result property="longitude" column="longitude_"/>
         <result property="latitude" column="latitude_"/>
+        <result property="stationId" column="station_id"/>
         <result property="createBy" column="create_by"/>
         <result property="createTime" column="create_time"/>
         <result property="updateBy" column="update_by"/>
@@ -22,13 +23,14 @@
         -->
         <![CDATA[
 		insert into bus_gps_data_info
-	    (id_,device_no,longitude_,latitude_,create_by,create_time,update_by,update_time,del_flag)
+	    (id_,device_no,longitude_,latitude_,station_id,create_by,create_time,update_by,update_time,del_flag)
 		values
 		(
             #{id,jdbcType=VARCHAR}
             ,#{deviceNo,jdbcType=VARCHAR}
             ,#{longitude,jdbcType=VARCHAR}
             ,#{latitude,jdbcType=VARCHAR}
+            ,#{stationId,jdbcType=VARCHAR}
             ,#{createBy,jdbcType=VARCHAR}
             ,#{createTime,jdbcType= TIMESTAMP }
             ,#{updateBy,jdbcType=VARCHAR}
@@ -52,6 +54,9 @@
             <if test="latitude!=null">
                 latitude_=#{latitude,jdbcType=VARCHAR},
             </if>
+            <if test="stationId != null">
+                station_id = #{stationId,jdbcType=VARCHAR},
+            </if>
             <if test="createBy!=null">
                 create_by=#{createBy,jdbcType=VARCHAR},
             </if>
@@ -71,8 +76,7 @@
         where id_=#{id}
     </update>
     <select id="get" parameterType="string" resultMap="GpsDataInfoMap">
-        select id_,device_no,longitude_,latitude_,create_by,create_time,update_by,update_time,del_flag
-        from bus_gps_data_info where id_=#{0}
+        select * from bus_gps_data_info where id_=#{0}
     </select>
     <select id="exist" parameterType="string" resultType="int">
         select count(*) from bus_gps_data_info where id_=#{0}
@@ -109,4 +113,16 @@
         where device_no=#{deviceNo}
         order by create_time desc limit 1
     </select>
+
+    <select id="findByDeviceNoAndCreateTime" resultMap="GpsDataInfoMap">
+        <![CDATA[
+        select * from bus_gps_data_info
+        where del_flag = 0
+        and device_no = #{gpsDeviceNo}
+        and create_time <= #{maxTime}
+        and create_time >= #{minTime}
+        limit 1
+        ]]>
+
+    </select>
 </mapper>

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

@@ -69,6 +69,9 @@ public class DriverApiController {
     @Autowired
     private BaiduService baiduService;
 
+    @Autowired
+    private GpsDataInfoService gpsDataInfoService;
+
     @Autowired
     private OrderInfoService orderInfoService;
 
@@ -490,7 +493,19 @@ public class DriverApiController {
                     retFileUrl = OSSUtil.uploadBase64(photoBase64Data,personId+".jpg",ossConfig);
                 }
 
-                passengerInfoService.passengerFace(vehicleInfo, shiftInfo, retFileUrl, recordTime, shiftInfo.getCurrentStationId(), personId);
+                String currentStationId = shiftInfo.getCurrentStationId();
+                //班次的当前站点和GPS记录对比验证
+                //记录时间往后偏移1min
+                Date time = DateUtil.parse(recordTime,"yyyy-MM-dd HH:mm:ss");
+                Date offsetTime = DateUtil.offsetMinute(time,-1);
+                //查询gps记录表中此时间段间的记录
+                GpsDataInfo gpsDataInfo = gpsDataInfoService.findByDeviceNoAndCreateTime(vehicleInfo.getGpsDeviceNo(),time,offsetTime);
+                if (gpsDataInfo != null && StringUtils.isNotBlank(gpsDataInfo.getStationId())){
+                    currentStationId = gpsDataInfo.getStationId();
+                }
+
+
+                passengerInfoService.passengerFace(vehicleInfo, shiftInfo, retFileUrl, recordTime, currentStationId, personId);
                 messageResult.setResult(true);
                 messageResult.setCode(200);
             }
@@ -861,10 +876,10 @@ public class DriverApiController {
             list.add("ticket");
             PaymentInfo paymentInfo = paymentInfoService.findByCompanyId(vehicleInfo.getCompanyId());
             if (paymentInfo != null){
-                if (StringUtils.isNotBlank(paymentInfo.getSubMchId())){
+                if (paymentInfo.getIsOpenWechat()){
                     list.add("wechat");
                 }
-                if (StringUtils.isNotBlank(paymentInfo.getAppAuthToken())){
+                if (paymentInfo.getIsOpenAlipay()){
                     list.add("alipay");
                 }
             }