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
1 = 1
and ri.deleted = '0'
and (ri.rescue_status = '1' or ri.rescue_status = '2' or ri.rescue_status = '3')
and roi.order_status = '1'
and ri.rescue_status = '6'
and roi.order_status = '2'
and roi.order_status = '3'
and ri.rescue_status = '8'
and (ri.rescue_type = '5' and ri.rescue_status '6')
and ri.license_num like concat('%', #{map.licenseNum}, '%')
and ri.dept_id in
#{item}
order by ri.create_time desc
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 ri.deleted = '0'
and roi.order_status = #{map.orderStatus}
and if(#{map.rescueStatus} = 0, ri.rescue_status not in(6,8,9), ri.rescue_status = #{map.rescueStatus})
and ri.license_num like concat('%', #{map.licenseNum}, '%')
and ri.connection_name like concat('%', #{map.connectionName}, '%')
and ri.driver_name like concat('%', #{map.driverName}, '%')
and ri.driver_car_num like concat('%', #{map.driverCarNum}, '%')
and ri.rescue_type = #{map.rescueType}
and ri.fee_type = #{map.feeType}
and ri.driver_id is not null
and rescue_time between
concat(#{map.rescueStart}, ' 00:00:00') and concat(#{map.rescueEnd}, ' 23:59:59')
and if(#{map.deptId} = 0, ri.dept_id is null, ri.dept_id = #{map.deptId})
order by ri.create_time desc
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
and ri.driver_name like concat('%', #{driverName}, '%')
and ri.driver_car_num like concat('%', #{driverCarNum}, '%')
and ri.driver_id is not null
and rescue_time like concat(#{rescueStart}, '%')
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
(ri.user_id = #{map.userId} or connection_phone = #{map.connectionPhone})
and (ri.rescue_status = '2' or ri.rescue_status = '3')
and roi.order_status ='1'
and ri.rescue_status ='6'
and roi.order_status ='2'
and roi.order_status ='3'
and ri.license_num like concat('%', #{map.licenseNum}, '%')
order by ri.create_time desc
select *
from rescue_info ri
dept_id = #{map.deptId}
and rescue_type = '5'
and (connection_name like concat('%', #{map.connectionName}, '%') or connection_phone like concat('%',
#{map.connectionPhone},
'%') or
license_num like concat('%', #{map.licenseNum}, '%'))
and rescue_status '6'
and rescue_status =]]> '6'
order by create_time desc
SELECT su.id AS userId,
su.nickname AS nickName,
su.mobile AS phonenumber,
su.sex as sex,
su.avatar as avatar,
di.*
FROM driver_info di
INNER JOIN system_users su ON di.user_id = su.id
AND su.deleted = '0'
WHERE 1 = 1
and su.nickname like concat('%', #{map.nickName}, '%')
and su.mobile like concat('%', #{map.phonenumber}, '%')
and di.driver_status = #{map.driveStatus}
and di.auth_status = #{map.authStatus}
and di.car_type = #{map.carType}
and di.car_license_num like concat('%', #{map.carLicenseNum}, '%')
order by di.create_time desc
SELECT di.*,
su.nickname as real_name,
rci.rescue_car_num
FROM driver_info di
INNER JOIN system_users su ON di.user_id = su.id AND su.deleted = '0'
left join system_dept sd on sd.id = di.dept_id
inner join rescue_car_info rci on rci.possessor_id = di.id
WHERE di.auth_status = '2'
and (su.nickname like concat('%', #{searchValue}, '%') or
di.phonenumber like concat('%', #{searchValue}, '%')
or rci.rescue_car_num like concat('%', #{searchValue}, '%'))
order by di.create_time desc
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 system_users su ON di.user_id = su.id
AND su.deleted = '0'
LEFT JOIN system_dept sd ON sd.id = di.dept_id
INNER JOIN rescue_car_info rci ON rci.possessor_id = di.id
WHERE di.auth_status = '2'
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'
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()) ]]> 3
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 =]]> '5'), 0) as ywcNum,
IFNULL(sum(ri.is_wei_xiu = '1'), 0) as zwxNum
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 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 =]]> '5'), 0) as ywcNum,
IFNULL(sum(ri.is_wei_xiu = '1'), 0) as zwxNum
FROM rescue_info ri
left join rescue_order_info roi on roi.rescue_info_id = ri.id
where 1 = 1
and ri.dept_id in
#{item}
DELETE
FROM rescue_info_detail
WHERE rescue_info_id = #{rescueId};
DELETE
FROM rescue_driver_info
WHERE rescue_id = #{rescueId};
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 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
and rescue_time between concat(#{map.rescueStart}, ' 00:00:00')
and concat(#{map.rescueEnd}, ' 23:59:59')
and ri.license_num like concat('%', #{map.licenseNum}, '%')
and ri.fee_type = #{map.feeType}
and ri.driver_id is not null
and rescue_time between concat(#{map.rescueStart}, ' 00:00:00')
and concat(#{map.rescueEnd}, ' 23:59:59')
and ri.driver_name like concat('%', #{map.driverName}, '%')
and ri.driver_car_num like concat('%', #{map.driverCarNum}, '%')
and rescue_time like concat(#{map.rescueStartMonth}, '%')
order by ri.driver_name desc
SELECT IFNULL(sum(roi.set_money), 0) / 100 as money,
count(ri.id) as rescueNum,
su.nickname as driverName
FROM driver_info di
LEFT JOIN rescue_info ri on ri.driver_id = di.id and ri.rescue_time =]]> #{startTime} and
ri.rescue_time #{endTime}
LEFT JOIN rescue_order_info roi on ri.id = roi.rescue_info_id
INNER JOIN system_users su on di.user_id = su.id
GROUP BY di.id
ORDER BY rescueNum desc
SELECT sd.id,
sd.name AS buckle_name,
t1.buckle_count
FROM (SELECT dept_id,
count(*) AS buckle_count
FROM rescue_info
WHERE rescue_type = '5'
AND deleted = '0'
GROUP BY dept_id) t1
LEFT JOIN system_dept sd ON t1.dept_id = sd.id
ORDER BY sd.id desc
WITH rescue_types AS (
SELECT '1' AS rescue_type, '拖车' AS rescue_type_desc
UNION ALL SELECT '2', '送油'
UNION ALL SELECT '3', '搭电'
UNION ALL SELECT '4', '换台'
UNION ALL SELECT '5', '扣车'
)
SELECT
rt.rescue_type_desc AS rescueType,
COUNT(ri.rescue_type) AS typeCount,
ROUND((COUNT(ri.rescue_type) * 100.0 / NULLIF((SELECT COUNT(*) FROM rescue_info WHERE deleted = b'0' AND rescue_time BETWEEN #{startTime} AND #{endTime} AND tenant_id = #{tenantId}), 0)), 2) AS percentage
FROM
rescue_types rt
LEFT JOIN
rescue_info ri ON rt.rescue_type = ri.rescue_type
AND ri.rescue_time BETWEEN #{startTime} AND #{endTime}
AND ri.tenant_id = #{tenantId}
GROUP BY
rt.rescue_type_desc
ORDER BY
rt.rescue_type;
SELECT
ROW_NUMBER() OVER (ORDER BY COALESCE(SUM(roi.pay_money), 0) DESC) AS sort,
su.nickname,
COALESCE(SUM(roi.set_money), 0) AS money,
COALESCE(COUNT(roi.id), 0) AS count
FROM
driver_info di
LEFT JOIN
system_users su ON di.user_id = su.id
LEFT JOIN
rescue_info ri ON di.id = ri.driver_id
LEFT JOIN
rescue_order_info roi ON ri.id = roi.rescue_info_id
WHERE roi.pay_time BETWEEN #{startTime} AND #{endTime}
GROUP BY
su.nickname,
di.id
ORDER BY
COALESCE(SUM(roi.set_money), 0) DESC;
select
COALESCE((select value from system_dict_data where dict_type = #{dictType} and id = ri.section_road),'其他') name,
count(1) as count
from rescue_info ri
group by name;
SELECT DISTINCT
su.id AS userId,
su.nickname,
su.username,
su.user_type,
su.remark,
su.dept_id,
su.mobile,
su.password,
su.avatar,
su.sex,
su.status,
di.id AS driverId,
di.age,
di.folder_id
FROM driver_info di
INNER JOIN system_users su ON di.user_id = su.id AND su.deleted = 0
LEFT JOIN system_user_role sur ON su.id = sur.user_id AND sur.deleted = 0
LEFT JOIN system_role sr ON sur.role_id = sr.id AND sr.service_package_id = 'jiuyuan' AND sr.deleted = 0
di.deleted = 0
and su.id = #{id}