<?xml version="1.0" encoding="UTF-8" ?>
|
<!DOCTYPE mapper
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<mapper namespace="com.ruoyi.system.mapper.VehicleGpsSegmentMileageMapper">
|
|
<resultMap type="VehicleGpsSegmentMileage" id="VehicleGpsSegmentMileageResult">
|
<result property="segmentId" column="segment_id" />
|
<result property="vehicleId" column="vehicle_id" />
|
<result property="vehicleNo" column="vehicle_no" />
|
<result property="segmentStartTime" column="segment_start_time" />
|
<result property="segmentEndTime" column="segment_end_time" />
|
<result property="startLongitude" column="start_longitude" />
|
<result property="startLatitude" column="start_latitude" />
|
<result property="endLongitude" column="end_longitude" />
|
<result property="endLatitude" column="end_latitude" />
|
<result property="segmentDistance" column="segment_distance" />
|
<result property="gpsPointCount" column="gps_point_count" />
|
<result property="gpsIds" column="gps_ids" />
|
<result property="taskId" column="task_id" />
|
<result property="taskCode" column="task_code" />
|
<result property="calculateMethod" column="calculate_method" />
|
<result property="createTime" column="create_time" />
|
<result property="updateTime" column="update_time" />
|
</resultMap>
|
|
<sql id="selectVehicleGpsSegmentMileageVo">
|
SELECT segment_id, vehicle_id, vehicle_no, segment_start_time, segment_end_time,
|
start_longitude, start_latitude, end_longitude, end_latitude,
|
segment_distance, gps_point_count, gps_ids, task_id, task_code,
|
calculate_method, create_time, update_time
|
FROM tb_vehicle_gps_segment_mileage
|
</sql>
|
|
<select id="selectVehicleGpsSegmentMileageList" parameterType="VehicleGpsSegmentMileage" resultMap="VehicleGpsSegmentMileageResult">
|
<include refid="selectVehicleGpsSegmentMileageVo"/>
|
<where>
|
<if test="vehicleId != null">
|
AND vehicle_id = #{vehicleId}
|
</if>
|
<if test="vehicleNo != null and vehicleNo != ''">
|
AND vehicle_no = #{vehicleNo}
|
</if>
|
<if test="params.beginTime != null and params.beginTime != ''">
|
AND segment_start_time >= #{params.beginTime}
|
</if>
|
<if test="params.endTime != null and params.endTime != ''">
|
AND segment_end_time <= #{params.endTime}
|
</if>
|
</where>
|
ORDER BY segment_start_time DESC
|
</select>
|
|
<select id="selectVehicleGpsSegmentMileageById" parameterType="Long" resultMap="VehicleGpsSegmentMileageResult">
|
<include refid="selectVehicleGpsSegmentMileageVo"/>
|
WHERE segment_id = #{segmentId}
|
</select>
|
|
<select id="selectByVehicleIdAndTime" resultMap="VehicleGpsSegmentMileageResult">
|
<include refid="selectVehicleGpsSegmentMileageVo"/>
|
WHERE vehicle_id = #{vehicleId} AND segment_start_time = #{segmentStartTime}
|
</select>
|
|
<select id="selectSegmentsByDateRange" resultMap="VehicleGpsSegmentMileageResult">
|
<include refid="selectVehicleGpsSegmentMileageVo"/>
|
WHERE vehicle_id = #{vehicleId}
|
AND segment_start_time >= #{startDate}
|
AND segment_end_time <= #{endDate}
|
ORDER BY segment_start_time
|
</select>
|
|
<!-- 按任务ID查询分段里程列表 -->
|
<select id="selectSegmentsByTaskId" resultMap="VehicleGpsSegmentMileageResult">
|
<include refid="selectVehicleGpsSegmentMileageVo"/>
|
WHERE task_id = #{taskId}
|
ORDER BY segment_start_time
|
</select>
|
|
<!-- 查询任务的总里程(直接求和) -->
|
<select id="selectTotalMileageByTaskId" resultType="java.math.BigDecimal">
|
SELECT COALESCE(SUM(segment_distance), 0)
|
FROM tb_vehicle_gps_segment_mileage
|
WHERE task_id = #{taskId}
|
</select>
|
|
<insert id="insertVehicleGpsSegmentMileage" parameterType="VehicleGpsSegmentMileage">
|
INSERT INTO tb_vehicle_gps_segment_mileage
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="vehicleId != null">vehicle_id,</if>
|
<if test="vehicleNo != null">vehicle_no,</if>
|
<if test="segmentStartTime != null">segment_start_time,</if>
|
<if test="segmentEndTime != null">segment_end_time,</if>
|
<if test="startLongitude != null">start_longitude,</if>
|
<if test="startLatitude != null">start_latitude,</if>
|
<if test="endLongitude != null">end_longitude,</if>
|
<if test="endLatitude != null">end_latitude,</if>
|
<if test="segmentDistance != null">segment_distance,</if>
|
<if test="gpsPointCount != null">gps_point_count,</if>
|
<if test="gpsIds != null">gps_ids,</if>
|
<if test="taskId != null">task_id,</if>
|
<if test="taskCode != null">task_code,</if>
|
<if test="calculateMethod != null">calculate_method,</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="vehicleId != null">#{vehicleId},</if>
|
<if test="vehicleNo != null">#{vehicleNo},</if>
|
<if test="segmentStartTime != null">#{segmentStartTime},</if>
|
<if test="segmentEndTime != null">#{segmentEndTime},</if>
|
<if test="startLongitude != null">#{startLongitude},</if>
|
<if test="startLatitude != null">#{startLatitude},</if>
|
<if test="endLongitude != null">#{endLongitude},</if>
|
<if test="endLatitude != null">#{endLatitude},</if>
|
<if test="segmentDistance != null">#{segmentDistance},</if>
|
<if test="gpsPointCount != null">#{gpsPointCount},</if>
|
<if test="gpsIds != null">#{gpsIds},</if>
|
<if test="taskId != null">#{taskId},</if>
|
<if test="taskCode != null">#{taskCode},</if>
|
<if test="calculateMethod != null">#{calculateMethod},</if>
|
</trim>
|
</insert>
|
|
<update id="updateVehicleGpsSegmentMileage" parameterType="VehicleGpsSegmentMileage">
|
UPDATE tb_vehicle_gps_segment_mileage
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="vehicleNo != null">vehicle_no = #{vehicleNo},</if>
|
<if test="segmentEndTime != null">segment_end_time = #{segmentEndTime},</if>
|
<if test="endLongitude != null">end_longitude = #{endLongitude},</if>
|
<if test="endLatitude != null">end_latitude = #{endLatitude},</if>
|
<if test="segmentDistance != null">segment_distance = #{segmentDistance},</if>
|
<if test="gpsPointCount != null">gps_point_count = #{gpsPointCount},</if>
|
<if test="calculateMethod != null">calculate_method = #{calculateMethod},</if>
|
</trim>
|
WHERE segment_id = #{segmentId}
|
</update>
|
|
<delete id="deleteVehicleGpsSegmentMileageById" parameterType="Long">
|
DELETE FROM tb_vehicle_gps_segment_mileage WHERE segment_id = #{segmentId}
|
</delete>
|
|
<delete id="deleteVehicleGpsSegmentMileageByIds" parameterType="String">
|
DELETE FROM tb_vehicle_gps_segment_mileage WHERE segment_id IN
|
<foreach item="segmentId" collection="array" open="(" separator="," close=")">
|
#{segmentId}
|
</foreach>
|
</delete>
|
|
<!-- 记录GPS点已被计算 -->
|
<insert id="insertGpsCalculated">
|
INSERT INTO tb_vehicle_gps_calculated (gps_id, segment_id, vehicle_id, create_time)
|
VALUES (#{gpsId}, #{segmentId}, #{vehicleId}, NOW())
|
</insert>
|
|
<!-- 检查GPS点是否已被计算 -->
|
<select id="selectGpsCalculatedSegmentId" resultType="Long">
|
SELECT segment_id FROM tb_vehicle_gps_calculated WHERE gps_id = #{gpsId} LIMIT 1
|
</select>
|
</mapper>
|