366 lines
15 KiB
XML
366 lines
15 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.RescueInfoMapper">
|
||
|
|
|
||
|
|
<select id="selectRescueInfoList" parameterType="cn.iocoder.yudao.module.rescue.domain.RescueInfo" resultType="cn.iocoder.yudao.module.rescue.domain.RescueInfo">
|
||
|
|
SELECT
|
||
|
|
ri.*,roi.order_status,roi.set_money
|
||
|
|
FROM
|
||
|
|
rescue_info ri
|
||
|
|
left join rescue_order_info roi on roi.rescue_info_id = ri.id
|
||
|
|
<where>
|
||
|
|
1=1
|
||
|
|
<if test="rescueStatus != null ">
|
||
|
|
<choose>
|
||
|
|
<when test="rescueStatus == '1'.toString()">
|
||
|
|
<!-- 救援中 -->
|
||
|
|
and (ri.rescue_status = '1' or ri.rescue_status = '2' or ri.rescue_status = '3')
|
||
|
|
</when>
|
||
|
|
<when test="rescueStatus == '2'.toString()">
|
||
|
|
<!--待支付 -->
|
||
|
|
and roi.order_status ='1'
|
||
|
|
</when>
|
||
|
|
<when test="rescueStatus == '3'.toString()">
|
||
|
|
<!-- 待取车 -->
|
||
|
|
and ri.rescue_status ='6'
|
||
|
|
</when>
|
||
|
|
<when test="rescueStatus == '4'.toString()">
|
||
|
|
<!-- 评价 -->
|
||
|
|
and roi.order_status ='2'
|
||
|
|
</when>
|
||
|
|
<when test="rescueStatus == '5'.toString()">
|
||
|
|
<!-- 评价 -->
|
||
|
|
and roi.order_status ='3'
|
||
|
|
</when>
|
||
|
|
<when test="rescueStatus == '8'.toString()">
|
||
|
|
<!-- 已还车 -->
|
||
|
|
and ri.rescue_status ='8'
|
||
|
|
</when>
|
||
|
|
<when test="rescueStatus == '9'.toString()">
|
||
|
|
<!-- 扣车中未解扣 -->
|
||
|
|
and (ri.rescue_type ='5' and ri.rescue_status <![CDATA[<]]> '6')
|
||
|
|
</when>
|
||
|
|
</choose>
|
||
|
|
</if>
|
||
|
|
<if test="licenseNum != null ">
|
||
|
|
and ri.license_num like concat('%',#{licenseNum},'%')
|
||
|
|
</if>
|
||
|
|
${params.dataScope}
|
||
|
|
</where>
|
||
|
|
order by ri.create_time desc
|
||
|
|
</select>
|
||
|
|
<select id="selectRescueListSystem2" parameterType="cn.iocoder.yudao.module.rescue.domain.RescueInfo" resultType="cn.iocoder.yudao.module.rescue.domain.RescueInfo">
|
||
|
|
SELECT
|
||
|
|
ri.*,roi.order_status,roi.set_money,roi.id as rescueOrderId,roi.pay_money,roi.pay_time
|
||
|
|
FROM
|
||
|
|
rescue_info ri
|
||
|
|
left join rescue_order_info roi on roi.rescue_info_id = ri.id
|
||
|
|
<where>
|
||
|
|
<if test="orderStatus != null and orderStatus != ''">
|
||
|
|
and roi.order_status = #{orderStatus}
|
||
|
|
</if>
|
||
|
|
<if test="rescueStatus != null and rescueStatus != ''">
|
||
|
|
and ri.rescue_status = #{rescueStatus}
|
||
|
|
</if>
|
||
|
|
<if test="licenseNum != null ">
|
||
|
|
and ri.license_num like concat('%',#{licenseNum},'%')
|
||
|
|
</if>
|
||
|
|
<if test="connectionName != null ">
|
||
|
|
and ri.connection_name like concat('%',#{connectionName},'%')
|
||
|
|
</if>
|
||
|
|
<if test="driverName != null ">
|
||
|
|
and ri.driver_name like concat('%',#{driverName},'%')
|
||
|
|
</if>
|
||
|
|
<if test="driverCarNum != null ">
|
||
|
|
and ri.driver_car_num like concat('%',#{driverCarNum},'%')
|
||
|
|
</if>
|
||
|
|
<if test="rescueType != null ">
|
||
|
|
and ri.rescue_type = #{rescueType}
|
||
|
|
</if>
|
||
|
|
<if test="feeType != null ">
|
||
|
|
and ri.fee_type = #{feeType}
|
||
|
|
</if>
|
||
|
|
<if test="flag != null ">
|
||
|
|
and ri.driver_id is not null
|
||
|
|
</if>
|
||
|
|
<if test="rescueStart != null and rescueEnd != null"> and rescue_time between concat(#{rescueStart},' 00:00:00') and concat(#{rescueEnd},' 23:59:59') </if>
|
||
|
|
|
||
|
|
</where>
|
||
|
|
order by ri.create_time desc
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="listData" resultType="com.alibaba.fastjson.JSONObject">
|
||
|
|
SELECT
|
||
|
|
sum(set_money/100) as allMoney,count(1) as allNum,sum(case when ri.car_type ='1' then (set_money/100)* ${rescueTcBig}
|
||
|
|
when ri.car_type ='2' then (set_money/100)* ${rescueTcMid}
|
||
|
|
when ri.car_type ='3' then (set_money/100)* ${rescueTcSmall} else 0 end) as tcAll
|
||
|
|
FROM
|
||
|
|
rescue_info ri
|
||
|
|
left join rescue_order_info roi on roi.rescue_info_id = ri.id
|
||
|
|
<where>
|
||
|
|
<if test="driverName != null ">
|
||
|
|
and ri.driver_name like concat('%',#{driverName},'%')
|
||
|
|
</if>
|
||
|
|
<if test="driverCarNum != null ">
|
||
|
|
and ri.driver_car_num like concat('%',#{driverCarNum},'%')
|
||
|
|
</if>
|
||
|
|
<if test="flag != null ">
|
||
|
|
and ri.driver_id is not null
|
||
|
|
</if>
|
||
|
|
<if test="rescueStart != null "> and rescue_time like concat(#{rescueStart},'%') </if>
|
||
|
|
${params.dataScope}
|
||
|
|
</where>
|
||
|
|
</select>
|
||
|
|
<select id="selectRescueInfoListApp" parameterType="cn.iocoder.yudao.module.rescue.domain.RescueInfo" resultType="cn.iocoder.yudao.module.rescue.domain.RescueInfo">
|
||
|
|
SELECT
|
||
|
|
ri.*,roi.order_status,roi.set_money
|
||
|
|
FROM
|
||
|
|
rescue_info ri
|
||
|
|
left join rescue_order_info roi on roi.rescue_info_id = ri.id
|
||
|
|
<where>
|
||
|
|
(ri.user_id = #{userId} or connection_phone =#{connectionPhone})
|
||
|
|
<if test="rescueStatus != null ">
|
||
|
|
<choose>
|
||
|
|
<when test="rescueStatus == '1'.toString()">
|
||
|
|
<!-- 救援中 -->
|
||
|
|
and (ri.rescue_status = '1' or ri.rescue_status = '2' or ri.rescue_status = '3')
|
||
|
|
</when>
|
||
|
|
<when test="rescueStatus == '2'.toString()">
|
||
|
|
<!--待支付 -->
|
||
|
|
and roi.order_status ='1'
|
||
|
|
</when>
|
||
|
|
<when test="rescueStatus == '3'.toString()">
|
||
|
|
<!-- 待取车 -->
|
||
|
|
and ri.rescue_status ='6'
|
||
|
|
</when>
|
||
|
|
<when test="rescueStatus == '4'.toString()">
|
||
|
|
<!-- 评价 -->
|
||
|
|
and roi.order_status ='2'
|
||
|
|
</when>
|
||
|
|
<when test="rescueStatus == '5'.toString()">
|
||
|
|
<!-- 评价 -->
|
||
|
|
and roi.order_status ='3'
|
||
|
|
</when>
|
||
|
|
<when test="rescueStatus == '8'.toString()">
|
||
|
|
<!-- 已还车 -->
|
||
|
|
and ri.rescue_status ='8'
|
||
|
|
</when>
|
||
|
|
</choose>
|
||
|
|
</if>
|
||
|
|
<if test="licenseNum != null ">
|
||
|
|
and ri.license_num like concat('%',#{licenseNum},'%')
|
||
|
|
</if>
|
||
|
|
</where>
|
||
|
|
order by ri.create_time desc
|
||
|
|
|
||
|
|
</select>
|
||
|
|
<select id="getKcList" parameterType="cn.iocoder.yudao.module.rescue.domain.RescueInfo" resultType="cn.iocoder.yudao.module.rescue.domain.RescueInfo">
|
||
|
|
select * from rescue_info ri
|
||
|
|
<where>
|
||
|
|
dept_id = #{deptId} and rescue_type = '5'
|
||
|
|
<if test="connectionName != null and connectionName != ''">
|
||
|
|
and (connection_name like concat('%', #{connectionName}, '%') or connection_phone like concat('%', #{connectionPhone}, '%') or license_num like concat('%',#{licenseNum}, '%'))
|
||
|
|
</if>
|
||
|
|
<if test="rescueStatus != null ">
|
||
|
|
<choose>
|
||
|
|
<when test="rescueStatus == '1'.toString()">
|
||
|
|
<!-- 扣车中 -->
|
||
|
|
and rescue_status <![CDATA[<]]> '6'
|
||
|
|
</when>
|
||
|
|
<when test="rescueStatus == '2'.toString()">
|
||
|
|
<!-- 已解 -->
|
||
|
|
and rescue_status <![CDATA[>=]]> '6'
|
||
|
|
</when>
|
||
|
|
</choose>
|
||
|
|
</if>
|
||
|
|
</where>
|
||
|
|
order by create_time desc
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="driverList" resultType="cn.iocoder.yudao.module.rescue.domain.DriverInfo">
|
||
|
|
SELECT
|
||
|
|
su.user_id AS userId,
|
||
|
|
su.nick_name AS nickName,
|
||
|
|
su.phonenumber AS phonenumber,
|
||
|
|
su.user_age as userAge,
|
||
|
|
su.sex as sex,
|
||
|
|
su.avatar as avatar,
|
||
|
|
su.real_name as realName,
|
||
|
|
di.*
|
||
|
|
FROM
|
||
|
|
driver_info di
|
||
|
|
INNER JOIN sys_user su ON di.user_id = su.user_id
|
||
|
|
AND su.del_flag = '0'
|
||
|
|
WHERE 1=1
|
||
|
|
<if test="realName!=null and realName!=''">
|
||
|
|
and su.real_name like concat('%',#{realName},'%')
|
||
|
|
</if>
|
||
|
|
<if test="phonenumber!=null and phonenumber!=''">
|
||
|
|
and su.phonenumber = #{phonenumber}
|
||
|
|
</if>
|
||
|
|
<if test="driveStatus!=null and driveStatus!=''">
|
||
|
|
and di.driver_status = #{driveStatus}
|
||
|
|
</if>
|
||
|
|
<if test="authStatus!=null and authStatus!=''">
|
||
|
|
and di.auth_status = #{authStatus}
|
||
|
|
</if>
|
||
|
|
<if test="carType!=null and carType!=''">
|
||
|
|
and di.car_type = #{carType}
|
||
|
|
</if>
|
||
|
|
<if test="carLicenseNum!=null and carLicenseNum!=''">
|
||
|
|
and di.car_license_num like concat('%',#{carLicenseNum},'%')
|
||
|
|
</if>
|
||
|
|
${params.dataScope}
|
||
|
|
order by di.create_time desc
|
||
|
|
</select>
|
||
|
|
<select id="driverListApp" resultType="cn.iocoder.yudao.module.rescue.dto.DriverInfo2Dto">
|
||
|
|
SELECT
|
||
|
|
di.*,su.real_name,rci.rescue_car_num
|
||
|
|
FROM
|
||
|
|
driver_info di
|
||
|
|
INNER JOIN sys_user su ON di.user_id = su.user_id AND su.del_flag = '0'
|
||
|
|
left join sys_dept sd on sd.dept_id = di.dept_id
|
||
|
|
inner join rescue_car_info rci on rci.possessor_id = di.id
|
||
|
|
WHERE di.auth_status='2'
|
||
|
|
<if test="searchValue!=null and searchValue!=''">
|
||
|
|
and (su.real_name like concat('%',#{searchValue},'%') or di.phonenumber like concat('%',#{searchValue},'%') or rci.rescue_car_num like concat('%',#{searchValue},'%'))
|
||
|
|
</if>
|
||
|
|
order by di.create_time desc
|
||
|
|
</select>
|
||
|
|
<select id="driverInMap2" resultType="java.util.Map">
|
||
|
|
SELECT
|
||
|
|
IFNULL(sum(di.driver_status='1'),0) as kxNum,IFNULL(sum(di.driver_status='2'),0) as ztNum,IFNULL(sum(di.driver_status='3'),0) as mlNum,IFNULL(sum(di.driver_status='4'),0) as lxNum
|
||
|
|
FROM
|
||
|
|
driver_info di
|
||
|
|
INNER JOIN sys_user su ON di.user_id = su.user_id
|
||
|
|
AND su.del_flag = '0'
|
||
|
|
LEFT JOIN sys_dept sd ON sd.dept_id = di.dept_id
|
||
|
|
INNER JOIN rescue_car_info rci ON rci.possessor_id = di.id
|
||
|
|
WHERE
|
||
|
|
di.auth_status = '2'
|
||
|
|
</select>
|
||
|
|
<update id="dealOverTimeRescue" >
|
||
|
|
UPDATE rescue_info
|
||
|
|
SET need_system = '1'
|
||
|
|
WHERE
|
||
|
|
need_system = '0'
|
||
|
|
AND driver_id IS NULL
|
||
|
|
AND TIMESTAMPDIFF(
|
||
|
|
MINUTE,
|
||
|
|
rescue_time,
|
||
|
|
NOW()) > 5
|
||
|
|
AND rescue_status = '2'
|
||
|
|
</update>
|
||
|
|
<select id="getOverTimeRescue" resultType="cn.iocoder.yudao.module.rescue.domain.RescueInfo">
|
||
|
|
SELECT
|
||
|
|
ri.*, MAX(rdi.driver_level) as driverLevel
|
||
|
|
FROM
|
||
|
|
rescue_info ri
|
||
|
|
INNER JOIN rescue_driver_info rdi ON ri.id = rdi.rescue_id
|
||
|
|
WHERE
|
||
|
|
ri.driver_id IS NULL
|
||
|
|
AND ri.rescue_status = '2'
|
||
|
|
GROUP BY ri.id
|
||
|
|
HAVING
|
||
|
|
TIMESTAMPDIFF(
|
||
|
|
MINUTE,
|
||
|
|
MAX(rdi.create_time),
|
||
|
|
NOW()) <![CDATA[>]]> 3
|
||
|
|
</select>
|
||
|
|
<select id="getRescueStatistics" resultType="java.util.Map">
|
||
|
|
SELECT
|
||
|
|
IFNULL(sum(ri.rescue_status = '2' or ri.rescue_status = '3'),0) as jyzNum,
|
||
|
|
IFNULL(sum(roi.order_status ='1'),0) as dzfNum,
|
||
|
|
IFNULL(sum(ri.rescue_status ='6'),0) as dqcNum,
|
||
|
|
IFNULL(sum(ri.rescue_status <![CDATA[>=]]> '5' ),0) as ywcNum
|
||
|
|
FROM
|
||
|
|
rescue_info ri
|
||
|
|
left join rescue_order_info roi on roi.rescue_info_id = ri.id
|
||
|
|
where ri.user_id = #{userId} or connection_phone =#{connectionPhone}
|
||
|
|
</select>
|
||
|
|
<select id="getRescueStatisticsByAdmin" resultType="java.util.Map">
|
||
|
|
SELECT
|
||
|
|
IFNULL(sum(ri.rescue_status = '2' or ri.rescue_status = '3'),0) as jyzNum,
|
||
|
|
IFNULL(sum(roi.order_status ='1'),0) as dzfNum,
|
||
|
|
IFNULL(sum(ri.rescue_status ='6'),0) as dqcNum,
|
||
|
|
IFNULL(sum(ri.rescue_status <![CDATA[>=]]> '5' ),0) as ywcNum
|
||
|
|
FROM
|
||
|
|
rescue_info ri
|
||
|
|
left join rescue_order_info roi on roi.rescue_info_id = ri.id
|
||
|
|
where 1=1
|
||
|
|
${params.dataScope}
|
||
|
|
</select>
|
||
|
|
<delete id="deleteOtherInfo1">
|
||
|
|
DELETE
|
||
|
|
FROM
|
||
|
|
rescue_info_detail
|
||
|
|
WHERE
|
||
|
|
rescue_info_id = #{rescueId};
|
||
|
|
|
||
|
|
|
||
|
|
</delete>
|
||
|
|
<delete id="deleteOtherInfo2">
|
||
|
|
DELETE
|
||
|
|
FROM
|
||
|
|
rescue_driver_info
|
||
|
|
WHERE
|
||
|
|
rescue_id = #{rescueId};
|
||
|
|
</delete>
|
||
|
|
|
||
|
|
<select id="getDriverCarNum" resultType="com.alibaba.fastjson.JSONObject">
|
||
|
|
SELECT
|
||
|
|
count( 1 ) as allNum,ifnull(sum(case when start_scale is null then 0 when end_scale is null then 0 else end_scale - start_scale end ),0) as allDistance
|
||
|
|
FROM
|
||
|
|
rescue_info
|
||
|
|
where driver_id = #{driverId} and driver_car_num = #{carNum} and rescue_time like concat(#{time},'%')
|
||
|
|
</select>
|
||
|
|
<select id="getRescueInfoByDriver" resultType="cn.iocoder.yudao.module.rescue.domain.RescueInfo">
|
||
|
|
SELECT
|
||
|
|
ri.*,roi.order_status,roi.set_money,roi.id as rescueOrderId,roi.pay_money,roi.pay_time
|
||
|
|
FROM
|
||
|
|
rescue_info ri
|
||
|
|
left join rescue_order_info roi on roi.rescue_info_id = ri.id
|
||
|
|
where
|
||
|
|
driver_id is not null
|
||
|
|
<if test="rescueStart != null and rescueEnd != null"> and rescue_time between concat(#{rescueStart},' 00:00:00') and concat(#{rescueEnd},' 23:59:59') </if>
|
||
|
|
<if test="licenseNum != null ">
|
||
|
|
and ri.license_num like concat('%',#{licenseNum},'%')
|
||
|
|
</if>
|
||
|
|
<if test="feeType != null ">
|
||
|
|
and ri.fee_type = #{feeType}
|
||
|
|
</if>
|
||
|
|
<if test="flag != null ">
|
||
|
|
and ri.driver_id is not null
|
||
|
|
</if>
|
||
|
|
<if test="rescueStart != null and rescueEnd != null"> and rescue_time between concat(#{rescueStart},' 00:00:00') and concat(#{rescueEnd},' 23:59:59') </if>
|
||
|
|
|
||
|
|
<if test="driverName != null ">
|
||
|
|
and ri.driver_name like concat('%',#{driverName},'%')
|
||
|
|
</if>
|
||
|
|
<if test="driverCarNum != null ">
|
||
|
|
and ri.driver_car_num like concat('%',#{driverCarNum},'%')
|
||
|
|
</if>
|
||
|
|
<if test="rescueStartMonth != null">
|
||
|
|
and rescue_time like concat(#{rescueStartMonth},'%')
|
||
|
|
</if>
|
||
|
|
${params.dataScope}
|
||
|
|
|
||
|
|
order by ri.driver_name desc
|
||
|
|
</select>
|
||
|
|
<select id="statisticsInfo" resultType="com.alibaba.fastjson.JSONObject">
|
||
|
|
SELECT
|
||
|
|
IFNULL(sum(roi.set_money),0)/100 as money,count(ri.id) as rescueNum,su.real_name as driverName
|
||
|
|
FROM
|
||
|
|
driver_info di
|
||
|
|
LEFT JOIN rescue_info ri on ri.driver_id = di.id and ri.rescue_time <![CDATA[>=]]> #{startTime} and ri.rescue_time <![CDATA[<=]]> #{endTime}
|
||
|
|
LEFT JOIN rescue_order_info roi on ri.id = roi.rescue_info_id
|
||
|
|
INNER JOIN sys_user su on di.user_id = su.user_id
|
||
|
|
GROUP BY di.id
|
||
|
|
ORDER BY rescueNum desc
|
||
|
|
</select>
|
||
|
|
|
||
|
|
</mapper>
|