瀏覽代碼

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	common/src/main/java/com/jpsoft/bus/modules/bus/entity/VehicleInfo.java
#	common/src/main/resources/mapper/bus/VehicleInfo.xml
xiao547607 4 年之前
父節點
當前提交
4f02655459

+ 13 - 6
common/src/main/java/com/jpsoft/bus/modules/bus/callback/GpsDataCallbackImpl.java

@@ -1,6 +1,7 @@
 package com.jpsoft.bus.modules.bus.callback;
 
 import cn.hutool.core.lang.UUID;
+import com.alipay.api.domain.DeviceInfo;
 import com.jpsoft.bus.modules.base.entity.MergeOrderInfo;
 import com.jpsoft.bus.modules.base.entity.OrderInfo;
 import com.jpsoft.bus.modules.base.service.MergeOrderInfoService;
@@ -15,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.joda.time.DateTime;
 import org.joda.time.Minutes;
+import org.joda.time.Seconds;
 import org.springframework.amqp.rabbit.core.RabbitTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.ValueOperations;
@@ -74,7 +76,15 @@ public class GpsDataCallbackImpl implements GpsDataCallback {
 
         if (Double.valueOf(longitude) > 0 && Double.valueOf(latitude) > 0) {
             String histKey = deviceNo+"_history_time";
-            int intervalMinutes = 1;
+
+            //更新车辆经纬度
+            VehicleInfo v = vehicleInfoService.findByGpsDeviceNo(deviceNo);
+
+            Integer intervalSeconds = v.getTrailInterval();
+
+            if (intervalSeconds==null){
+                intervalSeconds = 60; //默认为60秒
+            }
 
             Long time = (Long)valueOperations.get(histKey);
 
@@ -86,9 +96,9 @@ public class GpsDataCallbackImpl implements GpsDataCallback {
             else{
                 DateTime createTime = new DateTime(time);
 
-                int minutes = Minutes.minutesBetween(createTime, DateTime.now()).getMinutes();
+                int seconds = Seconds.secondsBetween(createTime, DateTime.now()).getSeconds();
 
-                if (minutes>=intervalMinutes){
+                if (seconds>=intervalSeconds){
                     allowInsert = true;
                 }
             }
@@ -111,9 +121,6 @@ public class GpsDataCallbackImpl implements GpsDataCallback {
                 valueOperations.set(histKey, (new Date()).getTime(), 1, TimeUnit.HOURS);
             }
 
-            //更新车辆经纬度
-            VehicleInfo v = vehicleInfoService.findByGpsDeviceNo(deviceNo);
-
             if (v != null) {
                 log.warn("更新车辆经纬度:{}->({},{})", v.getLicensePlateNumber(), longitude, latitude);
 

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

@@ -45,8 +45,8 @@ public class GpsDataInfo {
     /**
      * 创建时间
      */
-    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     @ApiModelProperty(value = "创建时间")
     private Date createTime;
     /**
@@ -57,8 +57,8 @@ public class GpsDataInfo {
     /**
      * 更新时间
      */
-    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     @ApiModelProperty(value = "更新时间")
     private Date updateTime;
     /**

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

@@ -5,6 +5,7 @@ import java.util.Date;
 import java.text.SimpleDateFormat;
 import java.math.BigDecimal;
 
+import org.springframework.data.annotation.Transient;
 import org.springframework.format.annotation.DateTimeFormat;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
@@ -119,4 +120,7 @@ public class PassengerInfo {
 
     @ApiModelProperty(value = "购票方式")
     private String payName;
+
+    @Transient
+    private BigDecimal totalFee;
 }

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

@@ -65,6 +65,8 @@ public class VehicleInfo {
     private String latestAddress;
     @ApiModelProperty(value = "运行线路名称")
     private String routeName;
+    @ApiModelProperty(value = "轨迹间隔(秒)")
+    private Integer trailInterval;
     @ApiModelProperty(value = "车主ID")
     private String accountId;
     @ApiModelProperty(value = "车主名称")

+ 3 - 2
common/src/main/java/com/jpsoft/bus/modules/bus/service/impl/GpsServiceImpl.java

@@ -329,6 +329,7 @@ public class GpsServiceImpl implements GpsService {
             StationInfo endStation = stationInfoService.get(shiftInfo.getEndStationId());
 
             boolean frontToEnd = true;
+            int maxPassStation = stationInfoList.size() - 2; //一次性最多查n-2个站点,避免环形
         //    int distance = 100;
 
             if (stationInfoList.size() > 0) {
@@ -362,7 +363,7 @@ public class GpsServiceImpl implements GpsService {
                         if (!manual) {
                             n++;
 
-                            if (n >= 2) {
+                            if (n >= maxPassStation) {
                                 break;
                             }
                         }
@@ -392,7 +393,7 @@ public class GpsServiceImpl implements GpsService {
                         //非人为设置当前站点则只查后两站
                         if (!manual) {
                             n++;
-                            if (n >= 2) {
+                            if (n >= maxPassStation) {
                                 break;
                             }
                         }

+ 196 - 55
common/src/main/resources/mapper/bus/VehicleInfo.xml

@@ -36,7 +36,42 @@
 	</selectKey>
 	-->
 	<![CDATA[
+    <resultMap id="VehicleInfoMap" type="com.jpsoft.bus.modules.bus.entity.VehicleInfo">
+        <id property="id" column="id_"/>
+        <result property="routeId" column="route_id"/>
+        <result property="licensePlateNumber" column="license_plate_number"/>
+        <result property="activationCode" column="activation_code"/>
+        <result property="gpsDeviceNo" column="gps_device_no"/>
+        <result property="deviceNo" column="device_no"/>
+        <result property="picture" column="picture_"/>
+        <result property="loadNumber" column="load_number"/>
+        <result property="longitude" column="longitude_"/>
+        <result property="latitude" column="latitude_"/>
+        <result property="status" column="status_"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="delFlag" column="del_flag"/>
+        <result property="companyId" column="company_id"/>
+        <result property="running" column="running_"/>
+        <result property="acc" column="acc_"/>
+        <result property="online" column="online_"/>
+        <result property="latestAddress" column="latest_address"/>
+        <result property="routeName" column="route_name"/>
+        <result property="trailInterval" column="trail_interval"/>
+    </resultMap>
+    <insert id="insert" parameterType="com.jpsoft.bus.modules.bus.entity.VehicleInfo">
+        <!--
+        <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
+            select sys_guid() from dual
+        </selectKey>
+        -->
+        <![CDATA[
 		insert into bus_vehicle_info
+	    (id_,route_id,license_plate_number,activation_code,gps_device_no,device_no,picture_,
+	    load_number,longitude_,latitude_,status_,create_by,create_time,update_by,
+	    update_time,del_flag,company_id,running_,acc_,online_,latest_address,trail_interval)
 	    (id_,route_id,license_plate_number,activation_code,gps_device_no,device_no,picture_,load_number,longitude_,latitude_,status_,create_by,create_time,update_by,update_time,del_flag,company_id,running_,acc_,online_,latest_address,
 	    account_id)
 		values
@@ -63,6 +98,28 @@
 ,#{online,jdbcType= NUMERIC }
 ,#{latestAddress,jdbcType=VARCHAR}
 ,#{accountId,jdbcType=VARCHAR}
+			#{id,jdbcType=VARCHAR}
+			,#{routeId,jdbcType=VARCHAR}
+			,#{licensePlateNumber,jdbcType=VARCHAR}
+			,#{activationCode,jdbcType=VARCHAR}
+			,#{gpsDeviceNo,jdbcType=VARCHAR}
+			,#{deviceNo,jdbcType=VARCHAR}
+			,#{picture,jdbcType=VARCHAR}
+			,#{loadNumber,jdbcType= NUMERIC }
+			,#{longitude,jdbcType=VARCHAR}
+			,#{latitude,jdbcType=VARCHAR}
+			,#{status,jdbcType=VARCHAR}
+			,#{createBy,jdbcType=VARCHAR}
+			,#{createTime,jdbcType= TIMESTAMP }
+			,#{updateBy,jdbcType=VARCHAR}
+			,#{updateTime,jdbcType= TIMESTAMP }
+			,#{delFlag,jdbcType= NUMERIC }
+			,#{companyId,jdbcType=VARCHAR}
+			,#{running,jdbcType= NUMERIC }
+			,#{acc,jdbcType= NUMERIC }
+			,#{online,jdbcType= NUMERIC }
+			,#{latestAddress,jdbcType=VARCHAR}
+			,#{trailInterval,jdbcType= NUMERIC}
 		)
 	]]>
 	</insert>
@@ -149,6 +206,90 @@
 	</select>
 	<select id="search" parameterType="hashmap" resultMap="VehicleInfoMap">
 		<![CDATA[
+    </insert>
+    <delete id="delete" parameterType="string">
+        delete from bus_vehicle_info where id_=#{id,jdbcType=VARCHAR}
+    </delete>
+    <update id="update" parameterType="com.jpsoft.bus.modules.bus.entity.VehicleInfo">
+        update bus_vehicle_info
+        <set>
+            <if test="routeId!=null">
+                route_id=#{routeId,jdbcType=VARCHAR},
+            </if>
+            <if test="licensePlateNumber!=null">
+                license_plate_number=#{licensePlateNumber,jdbcType=VARCHAR},
+            </if>
+            <if test="activationCode!=null">
+                activation_code=#{activationCode,jdbcType=VARCHAR},
+            </if>
+            <if test="gpsDeviceNo!=null">
+                gps_device_no=#{gpsDeviceNo,jdbcType=VARCHAR},
+            </if>
+            <if test="deviceNo!=null">
+                device_no=#{deviceNo,jdbcType=VARCHAR},
+            </if>
+            <if test="picture!=null">
+                picture_=#{picture,jdbcType=VARCHAR},
+            </if>
+            <if test="loadNumber!=null">
+                load_number=#{loadNumber,jdbcType= NUMERIC },
+            </if>
+            <if test="longitude!=null">
+                longitude_=#{longitude,jdbcType=VARCHAR},
+            </if>
+            <if test="latitude!=null">
+                latitude_=#{latitude,jdbcType=VARCHAR},
+            </if>
+            <if test="status!=null">
+                status_=#{status,jdbcType=VARCHAR},
+            </if>
+            <if test="createBy!=null">
+                create_by=#{createBy,jdbcType=VARCHAR},
+            </if>
+            <if test="createTime!=null">
+                create_time=#{createTime,jdbcType= TIMESTAMP },
+            </if>
+            <if test="updateBy!=null">
+                update_by=#{updateBy,jdbcType=VARCHAR},
+            </if>
+            <if test="updateTime!=null">
+                update_time=#{updateTime,jdbcType= TIMESTAMP },
+            </if>
+            <if test="delFlag!=null">
+                del_flag=#{delFlag,jdbcType= NUMERIC },
+            </if>
+            <if test="companyId!=null">
+                company_id=#{companyId,jdbcType=VARCHAR},
+            </if>
+            <if test="running!=null">
+                running_=#{running,jdbcType= NUMERIC },
+            </if>
+            <if test="acc!=null">
+                acc_=#{acc,jdbcType= NUMERIC },
+            </if>
+            <if test="online!=null">
+                online_=#{online,jdbcType= NUMERIC },
+            </if>
+            <if test="latestAddress!=null">
+                latest_address=#{latestAddress,jdbcType=VARCHAR},
+            </if>
+            <if test="trailInterval!=null">
+                trail_interval=#{trailInterval,jdbcType=VARCHAR},
+            </if>
+        </set>
+        where id_=#{id}
+    </update>
+    <select id="get" parameterType="string" resultMap="VehicleInfoMap">
+        select * from bus_vehicle_info where id_=#{0}
+    </select>
+    <select id="exist" parameterType="string" resultType="int">
+        select count(*) from bus_vehicle_info where id_=#{0}
+    </select>
+    <select id="list" resultMap="VehicleInfoMap">
+        select * from bus_vehicle_info
+    </select>
+    <select id="search" parameterType="hashmap" resultMap="VehicleInfoMap">
+        <![CDATA[
 			SELECT
 				a.*,
 				b.name_ AS route_name
@@ -156,74 +297,74 @@
 				bus_vehicle_info a
 				LEFT JOIN bus_route_info b ON a.route_id = b.id_
 		]]>
-		<where>
-			a.del_flag=false
-			<if test="searchParams.licensePlateNumber != null">
-				and a.license_plate_number like #{searchParams.licensePlateNumber}
-			</if>
-			<if test="searchParams.companyId != null">
-				and a.company_id = #{searchParams.companyId}
-			</if>
-			<if test="searchParams.gpsDeviceNo != null">
-				and a.gps_device_no like #{searchParams.gpsDeviceNo}
-			</if>
-			<if test="searchParams.deviceNo != null">
-				and a.device_no like #{searchParams.deviceNo}
-			</if>
-		</where>
-		<foreach item="sort" collection="sortList"  open="order by" separator=",">
-	        ${sort.name} ${sort.order}
-	 	</foreach>
-	</select>
+        <where>
+            a.del_flag=false
+            <if test="searchParams.licensePlateNumber != null">
+                and a.license_plate_number like #{searchParams.licensePlateNumber}
+            </if>
+            <if test="searchParams.companyId != null">
+                and a.company_id = #{searchParams.companyId}
+            </if>
+            <if test="searchParams.gpsDeviceNo != null">
+                and a.gps_device_no like #{searchParams.gpsDeviceNo}
+            </if>
+            <if test="searchParams.deviceNo != null">
+                and a.device_no like #{searchParams.deviceNo}
+            </if>
+        </where>
+        <foreach item="sort" collection="sortList" open="order by" separator=",">
+            ${sort.name} ${sort.order}
+        </foreach>
+    </select>
 
-	<select id="findByCodeAndCarNum" resultMap="VehicleInfoMap">
-		<![CDATA[
+    <select id="findByCodeAndCarNum" resultMap="VehicleInfoMap">
+        <![CDATA[
 		select * from bus_vehicle_info
 		where del_flag = 0
 		and license_plate_number = #{carNum}
 		and activation_code = #{activationCode}
 		]]>
-	</select>
+    </select>
 
-	<select id="findByGpsDeviceNo" resultMap="VehicleInfoMap">
-		select * from bus_vehicle_info where del_flag=0 and gps_device_no=#{0}
-		order by create_time desc limit 1
-	</select>
+    <select id="findByGpsDeviceNo" resultMap="VehicleInfoMap">
+        select * from bus_vehicle_info where del_flag=0 and gps_device_no=#{0}
+        order by create_time desc limit 1
+    </select>
 
-	<update id="updateGps" parameterType="com.jpsoft.bus.modules.bus.entity.VehicleInfo">
-		update bus_vehicle_info
-		<set>
-			update_time=now(),
-			running_=1,
+    <update id="updateGps" parameterType="com.jpsoft.bus.modules.bus.entity.VehicleInfo">
+        update bus_vehicle_info
+        <set>
+            update_time=now(),
+            running_=1,
             online_=1,
-			<if test="longitude!=null">
-				longitude_=#{longitude,jdbcType=VARCHAR},
-			</if>
-			<if test="latitude!=null">
-				latitude_=#{latitude,jdbcType=VARCHAR},
-			</if>
-			<if test="latestAddress!=null">
-				latest_address=#{latestAddress,jdbcType=VARCHAR},
-			</if>
-		</set>
-		where id_=#{id}
-	</update>
+            <if test="longitude!=null">
+                longitude_=#{longitude,jdbcType=VARCHAR},
+            </if>
+            <if test="latitude!=null">
+                latitude_=#{latitude,jdbcType=VARCHAR},
+            </if>
+            <if test="latestAddress!=null">
+                latest_address=#{latestAddress,jdbcType=VARCHAR},
+            </if>
+        </set>
+        where id_=#{id}
+    </update>
 
-	<select id="findByCarNum" resultMap="VehicleInfoMap">
-		select * from bus_vehicle_info where del_flag=0 and license_plate_number=#{carNum}
-		order by create_time desc limit 1
-	</select>
+    <select id="findByCarNum" resultMap="VehicleInfoMap">
+        select * from bus_vehicle_info where del_flag=0 and license_plate_number=#{carNum}
+        order by create_time desc limit 1
+    </select>
 
-	<select id="findByCompanyId" resultMap="VehicleInfoMap">
-		<![CDATA[
+    <select id="findByCompanyId" resultMap="VehicleInfoMap">
+        <![CDATA[
 		select * from bus_vehicle_info
 		where del_flag = 0
 		and company_id = #{companyId}
 		]]>
-	</select>
-	<select id="getRunningList" resultMap="VehicleInfoMap">
-		select * from bus_vehicle_info
-		where del_flag=0
-		and running_=1
-	</select>
+    </select>
+    <select id="getRunningList" resultMap="VehicleInfoMap">
+        select * from bus_vehicle_info
+        where del_flag=0
+        and running_=1
+    </select>
 </mapper>

+ 2 - 2
web/src/main/java/com/jpsoft/bus/modules/bus/controller/VehicleInfoController.java

@@ -404,8 +404,8 @@ public class VehicleInfoController {
         List<Sort> sortList = new ArrayList<>();
         sortList.add(new Sort("create_time","desc"));
 
-        if (pageSize>100){
-            pageSize = 100;
+        if (pageSize>1000){
+            pageSize = 1000;
         }
 
         Page<GpsDataInfo> page = gpsDataInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);

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

@@ -720,14 +720,16 @@ public class DriverApiController {
             sortList.add(new Sort("create_time","desc"));
             Page<PassengerInfo> page = passengerInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
 
-//            for (PassengerInfo passengerInfo : page.getResult()) {
-//                List<OrderInfo> orderInfoList = orderInfoService.findByPassengerIdAndPayStatus(passengerInfo.getId(),20);
+            for (PassengerInfo passengerInfo : page.getResult()) {
+                if ("1".equals(passengerInfo.getPayStatus())) {
+                    List<OrderInfo> orderInfoList = orderInfoService.findByPassengerIdAndPayStatus(passengerInfo.getId(), 20);
 
-                //乘客最后一次购票信息
-//                if (orderInfoList.size()>0){
-//                    passengerInfo.setTicketType(orderInfoList.get(0).getTicketType());
-//                }
-//            }
+                    //乘客最后一次购票信息
+                    if (orderInfoList.size() > 0) {
+                        passengerInfo.setTotalFee(orderInfoList.get(0).getTotalFee());
+                    }
+                }
+            }
 
             messageResult.setData(PojoUtils.pageWrapper(page));
             messageResult.setResult(true);

+ 1 - 1
web/src/main/resources/application-dev.yml

@@ -1,5 +1,5 @@
 server:
-  port: 8087
+  port: 8086
   servlet:
     context-path: /smart-bus-server
 

+ 1 - 1
web/src/main/resources/application.yml

@@ -1,5 +1,5 @@
 server:
-  port: 8087
+  port: 8086
   servlet:
     context-path: /smart-bus-server
 # 需要设置外置容器的tomcat8 maxPostSize