197 lines
9.1 KiB
XML
197 lines
9.1 KiB
XML
<?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="cn.iocoder.yudao.module.rescue.mapper.RescueDriverInfoMapper">
|
|
|
|
<resultMap type="cn.iocoder.yudao.module.rescue.domain.RescueDriverInfo" id="RescueDriverInfoResult">
|
|
<result property="id" column="id" />
|
|
<result property="rescueId" column="rescue_id" />
|
|
<result property="driverId" column="driver_id" />
|
|
<result property="driverAccept" column="driver_accept" />
|
|
<result property="driverRejectReason" column="driver_reject_reason" />
|
|
<result property="creator" column="creator" />
|
|
<result property="createTime" column="create_time" />
|
|
<result property="updater" column="updater" />
|
|
<result property="updateTime" column="update_time" />
|
|
</resultMap>
|
|
|
|
<sql id="selectRescueDriverInfoVo">
|
|
select id, rescue_id, driver_id, driver_accept, driver_reject_reason, create_time, creator, update_time, updater from rescue_driver_info
|
|
</sql>
|
|
|
|
<select id="selectRescueDriverInfoList" parameterType="cn.iocoder.yudao.module.rescue.domain.RescueDriverInfo" resultMap="RescueDriverInfoResult">
|
|
<include refid="selectRescueDriverInfoVo"/>
|
|
<where>
|
|
<if test="rescueId != null "> and rescue_id = #{rescueId}</if>
|
|
<if test="driverId != null "> and driver_id = #{driverId}</if>
|
|
<if test="driverAccept != null and driverAccept != ''"> and driver_accept = #{driverAccept}</if>
|
|
<if test="driverRejectReason != null and driverRejectReason != ''"> and driver_reject_reason = #{driverRejectReason}</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectRescueDriverInfoById" parameterType="java.lang.Long" resultMap="RescueDriverInfoResult">
|
|
<include refid="selectRescueDriverInfoVo"/>
|
|
where id = #{id}
|
|
</select>
|
|
|
|
<insert id="insertRescueDriverInfo" parameterType="cn.iocoder.yudao.module.rescue.domain.RescueDriverInfo">
|
|
insert into rescue_driver_info
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="id != null">id,</if>
|
|
<if test="rescueId != null">rescue_id,</if>
|
|
<if test="driverId != null">driver_id,</if>
|
|
<if test="driverAccept != null">driver_accept,</if>
|
|
<if test="driverRejectReason != null">driver_reject_reason,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="id != null">#{id},</if>
|
|
<if test="rescueId != null">#{rescueId},</if>
|
|
<if test="driverId != null">#{driverId},</if>
|
|
<if test="driverAccept != null">#{driverAccept},</if>
|
|
<if test="driverRejectReason != null">#{driverRejectReason},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateRescueDriverInfo" parameterType="cn.iocoder.yudao.module.rescue.domain.RescueDriverInfo">
|
|
update rescue_driver_info
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="rescueId != null">rescue_id = #{rescueId},</if>
|
|
<if test="driverId != null">driver_id = #{driverId},</if>
|
|
<if test="driverAccept != null">driver_accept = #{driverAccept},</if>
|
|
<if test="driverRejectReason != null">driver_reject_reason = #{driverRejectReason},</if>
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
<if test="creator != null">creator = #{creator},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
<if test="updater != null">updater = #{updater},</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<delete id="deleteRescueDriverInfoById" parameterType="java.lang.Long">
|
|
delete from rescue_driver_info where id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteRescueDriverInfoByIds" parameterType="java.lang.String">
|
|
delete from rescue_driver_info where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<select id="driverRescueList" resultType="cn.iocoder.yudao.module.rescue.domain.RescueInfo">
|
|
SELECT
|
|
ri.*,rdi.id as rescueDriverId
|
|
FROM
|
|
`rescue_info` ri
|
|
INNER JOIN rescue_driver_info rdi ON ri.id = rdi.rescue_id AND rdi.driver_accept = '2'
|
|
WHERE
|
|
ri.deleted = 0 and
|
|
rdi.driver_id =#{driverId} and ri.rescue_status = '2'
|
|
and ri.driver_id is null
|
|
ORDER BY rdi.create_time desc
|
|
</select>
|
|
|
|
<select id="driverRescueList2" resultType="cn.iocoder.yudao.module.rescue.domain.RescueInfo">
|
|
SELECT
|
|
ri.*,rdi.id as rescueDriverId
|
|
FROM
|
|
`rescue_info` ri
|
|
INNER JOIN rescue_driver_info rdi ON ri.id = rdi.rescue_id AND rdi.driver_accept = '2' AND rdi.deleted = '0'
|
|
WHERE
|
|
ri.deleted = '0' and
|
|
ri.is_revoke = '0' and
|
|
rdi.driver_id =#{driverId} and ri.rescue_status = '2'
|
|
and ri.driver_id is null
|
|
ORDER BY rdi.create_time desc
|
|
</select>
|
|
|
|
<select id="driverRescuePage" resultType="cn.iocoder.yudao.module.rescue.domain.RescueInfo">
|
|
SELECT
|
|
ri.*,roi.set_money
|
|
FROM
|
|
`rescue_info` ri
|
|
left join rescue_order_info roi on ri.id = roi.rescue_info_id
|
|
WHERE
|
|
ri.driver_id =#{driverId}
|
|
<if test="rescueStatus == '3'.toString()">
|
|
and ri.rescue_status = #{rescueStatus}
|
|
</if>
|
|
<if test="rescueStatus == '5'.toString()">
|
|
and (ri.rescue_status = '5' or ri.rescue_status = '6')
|
|
</if>
|
|
ORDER BY ri.create_time desc
|
|
</select>
|
|
|
|
<select id="driverRescuePage2" resultType="cn.iocoder.yudao.module.rescue.domain.RescueInfo">
|
|
SELECT
|
|
ri.*,roi.set_money
|
|
FROM
|
|
`rescue_info` ri
|
|
left join rescue_order_info roi on ri.id = roi.rescue_info_id AND roi.deleted = '0'
|
|
WHERE
|
|
ri.deleted = '0' and
|
|
ri.driver_id =#{map.driverId}
|
|
<if test="map.rescueStatus == '3'.toString()">
|
|
and ri.rescue_status = #{map.rescueStatus}
|
|
</if>
|
|
<if test="map.rescueStatus == '5'.toString()">
|
|
and (ri.rescue_status = '4' or ri.rescue_status = '5' or ri.rescue_status = '6')
|
|
</if>
|
|
<if test="map.connectionName != null and map.connectionName != ''">
|
|
and (ri.connection_name like concat('%', #{map.connectionName}, '%')
|
|
or ri.connection_phone like concat('%', #{map.connectionName}, '%')
|
|
or ri.license_num like concat('%', #{map.connectionName}, '%')
|
|
or ri.car_owner like concat('%', #{map.connectionName}, '%')
|
|
or ri.car_owner_phone like concat('%', #{map.connectionName}, '%'))
|
|
</if>
|
|
ORDER BY ri.create_time desc
|
|
</select>
|
|
<select id="dqrList" resultType="java.lang.Integer">
|
|
SELECT
|
|
count(1)
|
|
FROM
|
|
`rescue_driver_info` rdi
|
|
INNER JOIN rescue_info ri on rdi.rescue_id = ri.id
|
|
where rdi.deleted = 0 and ri.is_revoke = 0 and rdi.driver_accept ='2' and rdi.driver_id =#{driverId} and ri.rescue_status = '2' and ri.driver_id is null
|
|
</select>
|
|
|
|
<select id="listDispatchDriverByRescueId" resultType="cn.iocoder.yudao.module.rescue.domain.DriverInfo">
|
|
SELECT
|
|
rdi.id AS rescueDriverId,
|
|
rdi.rescue_id AS rescueId,
|
|
di.id,
|
|
cs.name AS userName,
|
|
di.phonenumber,
|
|
COALESCE(primary_car.car_id, secondary_car.car_id) AS driverCarId,
|
|
COALESCE(primary_car.rescue_car_num, secondary_car.rescue_car_num) AS driverCarNum,
|
|
COALESCE(primary_car.car_category, secondary_car.car_category) AS driverCarCategory
|
|
FROM rescue_driver_info rdi
|
|
INNER JOIN driver_info di ON rdi.driver_id = di.id AND di.deleted = 0
|
|
INNER JOIN company_staff cs ON di.user_id = cs.user_id AND cs.deleted = 0
|
|
LEFT JOIN (
|
|
SELECT rdcr.driver_id, rdcr.car_id, rci.rescue_car_num, rci.car_category
|
|
FROM rescue_driver_car_relation rdcr
|
|
INNER JOIN rescue_car_info rci ON rdcr.car_id = rci.id AND rci.deleted = 0
|
|
WHERE rdcr.is_primary = 1 AND rdcr.deleted = 0
|
|
) primary_car ON di.id = primary_car.driver_id
|
|
LEFT JOIN (
|
|
SELECT rdcr1.driver_id, rdcr1.car_id, rci1.rescue_car_num, rci1.car_category
|
|
FROM rescue_driver_car_relation rdcr1
|
|
INNER JOIN rescue_car_info rci1 ON rdcr1.car_id = rci1.id AND rci1.deleted = 0
|
|
WHERE rdcr1.is_primary = 0 AND rdcr1.deleted = 0
|
|
AND rdcr1.id = (
|
|
SELECT MIN(rdcr2.id)
|
|
FROM rescue_driver_car_relation rdcr2
|
|
WHERE rdcr2.driver_id = rdcr1.driver_id
|
|
AND rdcr2.is_primary = 0
|
|
AND rdcr2.deleted = 0
|
|
)
|
|
) secondary_car ON di.id = secondary_car.driver_id AND primary_car.driver_id IS NULL
|
|
WHERE rdi.rescue_id = #{rescueId}
|
|
AND rdi.deleted = 0
|
|
AND (primary_car.car_id IS NOT NULL OR secondary_car.car_id IS NOT NULL)
|
|
ORDER BY rdi.rescue_id, di.id;
|
|
</select>
|
|
</mapper>
|