<?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.stylefeng.guns.modular.system.dao.TDriverMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.TDriver">
|
<id column="id" property="id" />
|
<result column="code" property="code" />
|
<result column="name" property="name" />
|
<result column="avatar" property="avatar" />
|
<result column="phone" property="phone" />
|
<result column="password" property="password" />
|
<result column="sex" property="sex" />
|
<result column="source" property="source" />
|
<result column="emergencyContact" property="emergencyContact" />
|
<result column="emergencyPhone" property="emergencyPhone" />
|
<result column="driverLicenseNumber" property="driverLicenseNumber" />
|
<result column="driverLicense" property="driverLicense" />
|
<result column="idcard" property="idcard" />
|
<result column="idcardFront" property="idcardFront" />
|
<result column="idcardBack" property="idcardBack" />
|
<result column="inviterType" property="inviterType" />
|
<result column="inviterId" property="inviterId" />
|
<result column="agentId" property="agentId" />
|
<result column="branchOfficeId" property="branchOfficeId" />
|
<result column="balance" property="balance" />
|
<result column="approvalStatus" property="approvalStatus" />
|
<result column="approvalNotes" property="approvalNotes" />
|
<result column="approvalUserId" property="approvalUserId" />
|
<result column="approvalTime" property="approvalTime" />
|
<result column="serverStatus" property="serverStatus" />
|
<result column="integral" property="integral" />
|
<result column="status" property="status" />
|
<result column="createTime" property="createTime" />
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, code, name, avatar, phone, password, sex, source, emergencyContact, emergencyPhone, driverLicenseNumber, driverLicense, idcard, idcardFront, idcardBack, inviterType, inviterId, agentId, branchOfficeId, balance, approvalStatus, approvalNotes, approvalUserId, approvalTime, serverStatus, integral, status, createTime
|
</sql>
|
<select id="queryIdleDriver" resultType="com.stylefeng.guns.modular.system.model.TDriver">
|
select
|
id as id,
|
account as account,
|
jobNumber as jobNumber,
|
phone as phone,
|
password as password,
|
name as name,
|
sex as sex,
|
idCard as idCard,
|
companyId as companyId,
|
franchiseeId as franchiseeId,
|
headImgUrl as headImgUrl,
|
faceImgUrl as faceImgUrl,
|
idCardImgUrl1 as idCardImgUrl1,
|
idCardImgUrl2 as idCardImgUrl2,
|
placeOfEmployment as placeOfEmployment,
|
birthday as birthday,
|
bankCardNumber as bankCardNumber,
|
driverNationality as driverNationality,
|
driverNation as driverNation,
|
driverMaritalStatus as driverMaritalStatus,
|
driverLanguageLevel as driverLanguageLevel,
|
driverEducation as driverEducation,
|
driverCensus as driverCensus,
|
driverAddress as driverAddress,
|
driverContactAddress as driverContactAddress,
|
driverAge as driverAge,
|
driveCard as driveCard,
|
driveCardImgUrl as driveCardImgUrl,
|
driverType as driverType,
|
getDriverLicenseDate as getDriverLicenseDate,
|
driverLicenseOn as driverLicenseOn,
|
driverLicenseOff as driverLicenseOff,
|
taxiDriver as taxiDriver,
|
taxiAptitudeCard as taxiAptitudeCard,
|
networkCarlssueImg as networkCarlssueImg,
|
networkCarlssueOrganization as networkCarlssueOrganization,
|
networkCarlssueDate as networkCarlssueDate,
|
getNetworkCarProofDate as getNetworkCarProofDate,
|
networkCarProofOn as networkCarProofOn,
|
networkCarProofOff as networkCarProofOff,
|
registerDate as registerDate,
|
fullTimeDriver as fullTimeDriver,
|
inDriverBlacklist as inDriverBlacklist,
|
commercialType as commercialType,
|
contractCompany as contractCompany,
|
contractOn as contractOn,
|
contractOff as contractOff,
|
emergencyContact as emergencyContact,
|
emergencyContactPhone as emergencyContactPhone,
|
emergencyContactAddress as emergencyContactAddress,
|
remark as remark,
|
isPlatCar as isPlatCar,
|
carId as carId,
|
authState as authState,
|
state as state,
|
addType as addType,
|
balance as balance,
|
flag as flag,
|
insertTime as insertTime,
|
insertUser as insertUser,
|
updateTime as updateTime,
|
updateUser as updateUser
|
from t_driver
|
where flag != 3 and state = 2 and authState = 2
|
<if test="null != companyId">
|
<choose>
|
<when test="companyId != 1">
|
and companyId = #{companyId} or franchiseeId = #{companyId}
|
</when>
|
<otherwise>
|
and companyId is null or companyId = 0 or companyId = 1 or franchiseeId is null or franchiseeId = 0
|
</otherwise>
|
</choose>
|
|
</if>
|
and id in
|
(
|
select driverId from t_driver_work where startTime < now() and state = 1 and `type` like CONCAT('%', #{type}, '%')
|
)
|
and id in (select driverId from t_driver_orders where `type` = #{type})
|
</select>
|
|
<!-- 查询有车检服务权限的司机列表(分页) -->
|
<select id="queryCheckServiceDrivers" resultType="com.stylefeng.guns.modular.system.controller.resp.DriverDispatchInfoResp">
|
SELECT
|
d.id,
|
d.name,
|
d.phone,
|
COALESCE(bo.branchOfficeName, '') as branchOfficeName,
|
CASE
|
WHEN bo.branchOfficeName IS NOT NULL THEN bo.branchOfficeName
|
ELSE ''
|
END as agentName,
|
d.serverStatus,
|
d.approvalStatus
|
FROM t_driver d
|
LEFT JOIN t_branch_office bo ON d.branchOfficeId = bo.id AND bo.status = 1
|
WHERE d.checkServer = #{checkServer}
|
AND d.approvalStatus = #{approvalStatus}
|
AND d.status = #{status}
|
<if test="excludeDriverId != null">
|
AND d.id != #{excludeDriverId}
|
</if>
|
ORDER BY d.serverStatus ASC, d.createTime DESC
|
<if test="offset != null and limit != null">
|
LIMIT #{offset}, #{limit}
|
</if>
|
</select>
|
|
<!-- 查询有车检服务权限的司机列表(支持搜索) -->
|
<select id="queryCheckServiceDriversWithSearch" resultType="com.stylefeng.guns.modular.system.controller.resp.DriverDispatchInfoResp">
|
SELECT
|
d.id,
|
d.name,
|
d.phone,
|
COALESCE(bo.branchOfficeName, '') as branchOfficeName,
|
CASE
|
WHEN a.merchantName IS NOT NULL THEN a.merchantName
|
ELSE ''
|
END as agentName,
|
d.serverStatus,
|
d.approvalStatus
|
FROM t_driver d
|
LEFT JOIN t_branch_office bo ON d.branchOfficeId = bo.id AND bo.status = 1
|
LEFT JOIN t_agent a ON bo.agentId = a.id AND a.status = 1
|
<where>
|
d.serverStatus = 1
|
AND d.checkServer = #{checkServer}
|
AND d.approvalStatus = #{approvalStatus}
|
AND d.status = #{status}
|
<if test="excludeDriverId != null">
|
AND d.id != #{excludeDriverId}
|
</if>
|
<if test="keyword != null and keyword != ''">
|
AND (d.name LIKE CONCAT('%', #{keyword}, '%') OR d.phone LIKE CONCAT('%', #{keyword}, '%'))
|
</if>
|
<if test="branchOfficeId != null">
|
AND d.branchOfficeId = #{branchOfficeId}
|
</if>
|
</where>
|
ORDER BY d.serverStatus ASC, d.createTime DESC
|
</select>
|
|
<!-- 统计有车检服务权限的司机总数(支持搜索) -->
|
<select id="countCheckServiceDriversWithSearch" resultType="java.lang.Long">
|
SELECT COUNT(1)
|
FROM t_driver d
|
LEFT JOIN t_branch_office bo ON d.branchOfficeId = bo.id AND bo.status = 1
|
LEFT JOIN t_agent a ON bo.agentId = a.id AND a.status = 1
|
<where>
|
d.serverStatus = 1
|
AND d.checkServer = #{checkServer}
|
AND d.approvalStatus = #{approvalStatus}
|
AND d.status = #{status}
|
<if test="excludeDriverId != null">
|
AND d.id != #{excludeDriverId}
|
</if>
|
<if test="keyword != null and keyword != ''">
|
AND (d.name LIKE CONCAT('%', #{keyword}, '%') OR d.phone LIKE CONCAT('%', #{keyword}, '%'))
|
</if>
|
</where>
|
ORDER BY d.serverStatus ASC, d.createTime DESC
|
</select>
|
|
</mapper>
|