1150 lines
48 KiB
XML
1150 lines
48 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="com.mhd.user.domain.userAggregate.repository.mapper.UserDriverMapper">
|
|
|
|
<sql id="selectUserDriverVo">
|
|
SELECT
|
|
a.driver_id,
|
|
a.user_id,
|
|
a.user_driver_enterprise_id,
|
|
a.user_driver_type,
|
|
a.driver_allow_driving_type_id,
|
|
a.driver_allow_driving_type_name,
|
|
a.driver_certification_authority,
|
|
a.driver_license_first_date,
|
|
a.driver_license_date_from,
|
|
a.driver_license_date_to,
|
|
a.driver_license_front_url,
|
|
a.driver_license_back_url,
|
|
a.driver_license_number,
|
|
a.driver_license_long,
|
|
a.driver_work_license_authority_code,
|
|
a.driver_work_license_authority_name,
|
|
a.driver_work_license_number,
|
|
a.driver_work_license_type_id,
|
|
a.driver_work_license_type_name,
|
|
a.driver_work_license_first_date,
|
|
a.driver_work_license_date_from,
|
|
a.driver_work_license_date_to,
|
|
a.driver_work_license_long,
|
|
a.driver_integrity_assessment_url,
|
|
a.driver_work_license_front_url,
|
|
a.work_certificate_back_img_url,
|
|
a.create_time,
|
|
a.create_by,
|
|
a.create_by_name,
|
|
a.update_time,
|
|
a.update_by,
|
|
a.update_by_name,
|
|
a.del_flag,
|
|
a.driver_fill,
|
|
a.driver_fill_time,
|
|
a.driver_fill_auth_id,
|
|
a.driver_fill_auth_name,
|
|
a.driver_fill_auth_remark,
|
|
a.driver_enterprise_code,
|
|
a.promo_code,
|
|
b.top_organization_id,
|
|
b.organization_id,
|
|
b.organization_name,
|
|
b.user_phone,
|
|
b.user_name,
|
|
b.user_account,
|
|
b.user_member_code,
|
|
b.user_idcard_number,
|
|
b.user_idcard_date_from,
|
|
b.user_idcard_date_to,
|
|
b.user_idcard_long,
|
|
b.user_idcard_front_url,
|
|
b.user_idcard_back_url,
|
|
b.user_idcard_inhand_url,
|
|
b.user_area_county_id,
|
|
b.user_area_name,
|
|
b.user_area_address,
|
|
b.user_remark,
|
|
b.user_auth_status,
|
|
b.user_birthday,
|
|
b.avatar,
|
|
ude.driver_business_license_number,
|
|
ude.driver_business_license_owner,
|
|
ude.driver_business_license_date_from,
|
|
ude.driver_business_license_date_to,
|
|
ude.driver_business_license_long,
|
|
ude.driver_enterprise_name,
|
|
ude.driver_enterprise_license_date_from,
|
|
ude.driver_enterprise_license_date_to,
|
|
ude.driver_enterprise_license_long,
|
|
ude.driver_enterprise_fill,
|
|
ude.driver_enterprise_fill_time,
|
|
WM_CONCAT(dvb.vehicle_license_plate_number) AS vehicleLicensePlateNumber,
|
|
dvb.vehicle_id ,
|
|
WM_CONCAT(m.motorcade_name) AS driverTeamName,
|
|
ud.driver_enterprise_name companyName
|
|
FROM
|
|
user_driver a
|
|
LEFT JOIN "USER" b ON a.user_id = b.user_id AND b.del_flag = 1
|
|
LEFT JOIN user_driver_enterprise ude ON a.user_id = ude.user_id AND ude.del_flag = 1
|
|
LEFT JOIN driver_vehicle_bind dvb ON a.user_id = dvb.user_id AND dvb.del_flag = 1
|
|
LEFT JOIN motorcade m ON a.driver_id = m.motorcade_header_id AND m.del_flag = 1
|
|
LEFT JOIN user_driver_enterprise ud ON a.user_driver_enterprise_id = ud.user_driver_enterprise_id AND ud.del_flag = 1
|
|
WHERE
|
|
a.del_flag = 1
|
|
</sql>
|
|
|
|
<sql id="selectUserDriverVo1">
|
|
SELECT
|
|
a.driver_id,
|
|
a.user_driver_type,
|
|
a.driver_allow_driving_type_id,
|
|
a.driver_allow_driving_type_name,
|
|
a.driver_certification_authority,
|
|
a.driver_license_first_date,
|
|
a.driver_license_date_from,
|
|
a.driver_license_date_to,
|
|
a.driver_license_front_url,
|
|
a.driver_license_back_url,
|
|
a.driver_license_number,
|
|
a.driver_license_long,
|
|
cast(a.driver_work_license_authority_code as BIGINT) as driver_work_license_authority_code,
|
|
a.driver_work_license_authority_name,
|
|
a.driver_work_license_number,
|
|
a.driver_work_license_type_id,
|
|
a.driver_work_license_type_name,
|
|
a.driver_work_license_first_date,
|
|
a.driver_work_license_date_from,
|
|
a.driver_work_license_date_to,
|
|
a.driver_work_license_long,
|
|
a.driver_integrity_assessment_url,
|
|
a.driver_work_license_front_url,
|
|
a.work_certificate_back_img_url,
|
|
b.create_time,
|
|
b.create_by,
|
|
b.create_by_name,
|
|
b.update_time,
|
|
b.update_by,
|
|
b.update_by_name,
|
|
a.del_flag,
|
|
a.driver_fill,
|
|
a.driver_fill_time,
|
|
a.driver_fill_auth_id,
|
|
a.driver_fill_auth_name,
|
|
a.driver_fill_auth_remark,
|
|
b.top_organization_id,
|
|
b.organization_id,
|
|
b.user_id,
|
|
b.user_phone,
|
|
b.user_name,
|
|
b.user_account,
|
|
b.user_member_code,
|
|
b.user_idcard_number,
|
|
b.user_idcard_date_from,
|
|
b.user_idcard_date_to,
|
|
b.user_idcard_long,
|
|
b.user_idcard_front_url,
|
|
b.user_idcard_back_url,
|
|
b.user_idcard_inhand_url,
|
|
b.user_area_county_id,
|
|
b.user_area_name,
|
|
b.user_area_address,
|
|
b.user_remark,
|
|
b.user_auth_status,
|
|
b.user_birthday,
|
|
b.avatar,
|
|
b.organization_name,
|
|
b.is_driver_bidding,
|
|
ude.driver_business_license_number,
|
|
ude.driver_business_license_owner,
|
|
ude.driver_business_license_date_from,
|
|
ude.driver_business_license_date_to,
|
|
ude.driver_business_license_long,
|
|
ude.driver_business_license_checkout_status,
|
|
ude.driver_business_license_checkout_reason,
|
|
ude.driver_enterprise_name,
|
|
ude.driver_enterprise_license_date_from,
|
|
ude.driver_enterprise_license_date_to,
|
|
ude.driver_enterprise_license_long,
|
|
ude.driver_enterprise_fill,
|
|
ude.driver_enterprise_fill_time,
|
|
ude.driver_enterprise_fill_auth_id,
|
|
ude.driver_enterprise_fill_auth_name,
|
|
ude.driver_enterprise_fill_auth_remark,
|
|
ude.driver_enterprise_social_credit_code,
|
|
ude.driver_enterprise_address,
|
|
ude.driver_enterprise_license_front_url,
|
|
ude.driver_corp_idcard_front_url,
|
|
ude.driver_corp_idcard_back_url,
|
|
ude.driver_corp_idcard_inhand_url,
|
|
ude.driver_corp_idcard_date_from,
|
|
ude.driver_corp_idcard_date_to,
|
|
ude.driver_corp_idcard_long,
|
|
ude.driver_business_license_front_url,
|
|
ud.driver_captain_fill,
|
|
ude.driver_corp_legal_name,
|
|
ude.driver_corp_name,
|
|
ude.driver_corp_idcard_number,
|
|
r.roleName,
|
|
dvb.vehicle_id,
|
|
WM_CONCAT(DISTINCT dvb.vehicle_license_plate_number ) AS vehicleLicensePlateNumber,
|
|
WM_CONCAT(DISTINCT m.motorcade_name ) AS driverTeamName
|
|
FROM
|
|
"USER" b
|
|
LEFT JOIN (
|
|
SELECT
|
|
user_id,
|
|
LISTAGG(DISTINCT r.role_name, '&') WITHIN GROUP(ORDER BY r.role_name) AS roleName
|
|
FROM
|
|
role r
|
|
LEFT JOIN user_role ur ON r.role_id = ur.role_id
|
|
AND ur.del_flag = 1
|
|
WHERE
|
|
r.del_flag = 1
|
|
AND role_code IN ( 'driver', 'carrier', 'captain' )
|
|
GROUP BY
|
|
user_id
|
|
) r ON r.user_id = b.user_id
|
|
LEFT JOIN user_driver a ON a.user_id = b.user_id
|
|
LEFT JOIN user_driver_enterprise ude ON b.user_id = ude.user_id
|
|
AND ude.driver_type = 1
|
|
LEFT JOIN user_driver_enterprise ud ON b.user_id = ud.user_id
|
|
AND ud.driver_type = 2
|
|
LEFT JOIN driver_vehicle_bind dvb ON b.user_id = dvb.driver_bind_id
|
|
AND dvb.del_flag = 1
|
|
AND dvb.default_flag = 1
|
|
left join motorcade_driver md on a.user_id = md.user_id and md.del_flag = 1
|
|
left join motorcade m on md.motorcade_id = m.motorcade_id and m.del_flag = 1
|
|
|
|
LEFT JOIN motorcade mo ON a.driver_id = mo.motorcade_header_id
|
|
AND m.del_flag = 1
|
|
left join motorcade_driver mdr on mo.motorcade_id = mdr.motorcade_id and mdr.del_flag = 1
|
|
WHERE
|
|
b.del_flag = 1
|
|
AND ( a.del_flag = 1 OR a.del_flag IS NULL )
|
|
AND ( ude.del_flag = 1 OR ude.del_flag IS NULL )
|
|
AND ( ud.del_flag = 1 OR ud.del_flag IS NULL )
|
|
AND b.business_type IN ( 2, 3 )
|
|
</sql>
|
|
|
|
<sql id="selectUserDriverVo2">
|
|
SELECT a.driver_id,
|
|
a.driver_allow_driving_type_id,
|
|
a.driver_allow_driving_type_name,
|
|
a.driver_certification_authority,
|
|
a.driver_license_first_date,
|
|
a.driver_license_date_from,
|
|
a.driver_license_date_to,
|
|
a.driver_license_front_url,
|
|
a.driver_license_back_url,
|
|
a.driver_license_number,
|
|
a.driver_license_long,
|
|
a.driver_work_license_authority_code,
|
|
a.driver_work_license_authority_name,
|
|
a.driver_work_license_number,
|
|
a.driver_work_license_type_id,
|
|
a.driver_work_license_type_name,
|
|
a.driver_work_license_first_date,
|
|
a.driver_work_license_date_from,
|
|
a.driver_work_license_date_to,
|
|
a.driver_work_license_long,
|
|
a.driver_integrity_assessment_url,
|
|
a.driver_work_license_front_url,
|
|
a.work_certificate_back_img_url,
|
|
a.create_time,
|
|
a.create_by,
|
|
a.create_by_name,
|
|
a.update_time,
|
|
a.update_by,
|
|
a.update_by_name,
|
|
a.del_flag,
|
|
a.driver_fill,
|
|
a.driver_fill_time,
|
|
a.driver_fill_auth_id,
|
|
a.driver_fill_auth_name,
|
|
a.driver_fill_auth_remark,
|
|
b.user_id,
|
|
b.top_organization_id,
|
|
b.organization_id,
|
|
b.organization_name,
|
|
b.department_id,
|
|
b.user_phone,
|
|
b.user_name,
|
|
b.user_account,
|
|
b.user_member_code,
|
|
b.user_idcard_number,
|
|
b.user_idcard_date_from,
|
|
b.user_idcard_date_to,
|
|
b.user_idcard_long,
|
|
b.user_idcard_front_url,
|
|
b.user_idcard_back_url,
|
|
b.user_idcard_inhand_url,
|
|
b.user_area_county_id,
|
|
b.user_area_name,
|
|
b.user_area_address,
|
|
b.user_remark,
|
|
b.user_auth_status,
|
|
b.user_birthday,
|
|
b.driver_enterprise_code,
|
|
b.avatar,
|
|
ude.driver_business_license_number,
|
|
ude.driver_business_license_owner,
|
|
ude.driver_business_license_date_from,
|
|
ude.driver_business_license_date_to,
|
|
ude.driver_business_license_long,
|
|
ude.driver_enterprise_name,
|
|
ude.driver_enterprise_license_date_from,
|
|
ude.driver_enterprise_license_date_to,
|
|
ude.driver_enterprise_license_long,
|
|
ude.driver_enterprise_fill,
|
|
ude.driver_enterprise_fill_time,
|
|
ude.driver_corp_legal_name,
|
|
ude.driver_corp_name,
|
|
ude.driver_corp_idcard_number,
|
|
WM_CONCAT(dvb.vehicle_license_plate_number) AS vehicleLicensePlateNumber,
|
|
WM_CONCAT(m.motorcade_name) AS driverTeamName,
|
|
md.motorcade_id motorcade_header_id
|
|
FROM "USER" b
|
|
LEFT JOIN user_driver a ON a.user_id = b.user_id AND b.del_flag = 1
|
|
LEFT JOIN user_driver_enterprise ude ON a.user_id = ude.user_id AND ude.del_flag = 1
|
|
LEFT JOIN driver_vehicle_bind dvb ON a.user_id = dvb.user_id AND dvb.del_flag = 1
|
|
LEFT JOIN motorcade m ON a.driver_id = m.motorcade_header_id AND m.del_flag = 1
|
|
LEFT JOIN motorcade_driver md ON md.user_id = a.user_id AND md.del_flag = 1
|
|
WHERE b.del_flag = 1
|
|
</sql>
|
|
|
|
<select id="selectUserDriverByUserId" parameterType="java.lang.Long" resultType="java.lang.Long">
|
|
SELECT a.driver_id
|
|
FROM user_driver a
|
|
WHERE a.del_flag = 1
|
|
AND a.user_id = #{values}
|
|
</select>
|
|
|
|
<select id="selectUserNameByDriverId" parameterType="java.lang.Long" resultType="java.lang.String">
|
|
SELECT
|
|
u.user_name
|
|
FROM
|
|
user_driver a
|
|
LEFT JOIN
|
|
"USER" u
|
|
ON u.user_id = a.user_id AND u.del_flag = 1
|
|
WHERE
|
|
a.del_flag = 1
|
|
AND a.driver_id = #{values}
|
|
</select>
|
|
|
|
<select id="userDriverList" parameterType="com.mhd.user.domain.userAggregate.repository.todo.UserDriverDO"
|
|
resultType="com.mhd.common.core.domain.po.UserDriverListPo">
|
|
<include refid="selectUserDriverVo1"/>
|
|
<include refid="common_where"></include>
|
|
GROUP BY b.user_id
|
|
ORDER BY b.create_time DESC
|
|
</select>
|
|
|
|
<select id="userDriverListCount" parameterType="com.mhd.user.domain.userAggregate.repository.todo.UserDriverDO"
|
|
resultType = "java.lang.Integer">
|
|
select count(1)
|
|
from ( select b.user_id
|
|
from "USER" b
|
|
left join (select user_id, WM_CONCAT(r.role_name separator '&') roleName
|
|
from role r
|
|
left join user_role ur on r.role_id = ur.role_id and ur.del_flag = 1
|
|
where r.del_flag = 1
|
|
and role_code in ('driver', 'carrier', 'captain', 'must')
|
|
group by user_id) r on r.user_id = b.user_id
|
|
left join user_driver a on a.user_id = b.user_id
|
|
left join user_driver_enterprise ude on b.user_id = ude.user_id and ude.driver_type = 1
|
|
left join user_driver_enterprise ud on b.user_id = ud.user_id and ud.driver_type = 2
|
|
left join driver_vehicle_bind dvb on b.user_id = dvb.driver_bind_id and dvb.del_flag = 1 and dvb.default_flag = 1
|
|
left join motorcade m on a.driver_id = m.motorcade_header_id and m.del_flag = 1
|
|
where b.del_flag = 1 and (ude.del_flag = 1 or ud.del_flag = 1 or a.del_flag = 1)
|
|
<include refid="common_where"></include>
|
|
GROUP BY b.user_id ) y
|
|
</select>
|
|
|
|
<select id="selectStowageUserDriverList" parameterType="com.mhd.user.domain.userAggregate.repository.todo.UserDriverDO"
|
|
resultType="com.mhd.user.domain.userAggregate.repository.po.UserDriverPo">
|
|
SELECT a.driver_id,
|
|
a.user_id,
|
|
CONCAT(b.user_name, " ",b.user_phone) AS driver_label,
|
|
a.driver_allow_driving_type_id,
|
|
a.driver_allow_driving_type_name,
|
|
a.driver_certification_authority,
|
|
a.driver_license_first_date,
|
|
a.driver_license_date_from,
|
|
a.driver_license_date_to,
|
|
a.driver_license_front_url,
|
|
a.driver_license_back_url,
|
|
a.driver_license_number,
|
|
a.driver_license_long,
|
|
a.driver_work_license_authority_code,
|
|
a.driver_work_license_authority_name,
|
|
a.driver_work_license_number,
|
|
a.driver_work_license_type_id,
|
|
a.driver_work_license_type_name,
|
|
a.driver_work_license_first_date,
|
|
a.driver_work_license_date_from,
|
|
a.driver_work_license_date_to,
|
|
a.driver_work_license_long,
|
|
a.driver_work_license_front_url,
|
|
a.create_time,
|
|
a.create_by,
|
|
a.create_by_name,
|
|
a.update_time,
|
|
a.update_by,
|
|
a.update_by_name,
|
|
a.del_flag,
|
|
a.driver_fill,
|
|
a.driver_fill_time,
|
|
b.top_organization_id,
|
|
b.user_phone,
|
|
b.user_name,
|
|
b.user_account,
|
|
b.user_member_code,
|
|
b.user_idcard_number,
|
|
b.user_idcard_date_from,
|
|
b.user_idcard_date_to,
|
|
b.user_idcard_long,
|
|
b.user_idcard_front_url,
|
|
b.user_idcard_back_url,
|
|
b.user_idcard_inhand_url,
|
|
b.user_area_county_id,
|
|
b.user_area_name,
|
|
b.user_area_address,
|
|
b.user_remark,
|
|
dvb.vehicle_license_plate_number
|
|
FROM user_driver a
|
|
LEFT JOIN "USER" b ON a.user_id = b.user_id
|
|
LEFT JOIN driver_vehicle_bind dvb ON dvb.driver_bind_id = b.user_id AND dvb.del_flag = 1 AND default_flag = 1
|
|
WHERE a.del_flag = 1
|
|
AND b.del_flag = 1
|
|
<include refid="common_where"></include>
|
|
<include refid="common_where_stowage"></include>
|
|
ORDER BY a.create_time DESC
|
|
</select>
|
|
|
|
|
|
<!--根据用户ID查询承运人信息-->
|
|
<select id="findByUserId" parameterType="java.lang.Long"
|
|
resultType="com.mhd.user.domain.userAggregate.repository.po.UserDriverPo">
|
|
<include refid="selectUserDriverVo"/>
|
|
and a.user_id = #{value}
|
|
|
|
</select>
|
|
|
|
<!--根据用户ID查询承运人信息-->
|
|
<select id="selectByUserId" parameterType="java.lang.Long"
|
|
resultType="com.mhd.user.domain.userAggregate.repository.po.UserDriverPo">
|
|
<include refid="selectUserDriverVo"/>
|
|
and a.user_id = #{value}
|
|
|
|
</select>
|
|
<!--根据司机ID查询承运人信息-->
|
|
<select id="findByDriverId" parameterType="java.lang.Long"
|
|
resultType="com.mhd.user.domain.userAggregate.repository.po.UserDriverPo">
|
|
<include refid="selectUserDriverVo"/>
|
|
and a.driver_id = #{value}
|
|
|
|
</select>
|
|
<!--根据用户ID查询承运人信息-->
|
|
<select id="findByVehicleId" parameterType="com.mhd.user.domain.userAggregate.repository.todo.UserDriverDO"
|
|
resultType="com.mhd.user.domain.userAggregate.repository.po.UserDriverPo">
|
|
<include refid="selectUserDriverVo"/>
|
|
and a.vehicle_id = #{userDriverDO.vehicleId}
|
|
and b.top_organization_id = #{userDriverDO.topOrganizationId}
|
|
</select>
|
|
|
|
<select id="userDriverCount" resultType="com.mhd.user.domain.userAggregate.repository.po.UserDriverPo" parameterType="com.mhd.user.domain.userAggregate.repository.todo.UserDriverDO">
|
|
SELECT
|
|
a.driver_id,
|
|
a.user_id,
|
|
a.driver_fill
|
|
FROM
|
|
user_driver a
|
|
LEFT JOIN "USER" b ON a.user_id = b.user_id
|
|
AND b.del_flag = 1
|
|
WHERE
|
|
a.del_flag = 1
|
|
<include refid="common_where_one"></include>
|
|
GROUP BY a.driver_id
|
|
ORDER BY a.create_time DESC
|
|
</select>
|
|
|
|
<sql id="common_where_stowage">
|
|
|
|
<choose>
|
|
<when test="userDriverDO.userAccountType != null and userDriverDO.userAccountType == 3 and userDriverDO.topOrganizationId != null">
|
|
and b.top_organization_id = #{userDriverDO.topOrganizationId}
|
|
</when>
|
|
<otherwise>
|
|
and (b.organization_id = #{userDriverDO.organizationId} or b.organization_id = #{userDriverDO.topOrganizationId})
|
|
</otherwise>
|
|
</choose>
|
|
</sql>
|
|
|
|
<sql id="common_where_one">
|
|
/* 组织ID集合 */
|
|
<!-- <if test="userDriverDO.permissionOrganizationIds!=null and userDriverDO.permissionOrganizationIds.size > 0">-->
|
|
<!-- AND b.organization_id IN-->
|
|
<!-- <foreach collection="userDriverDO.permissionOrganizationIds" item="organizationId" index="index" open="(" separator=" , "-->
|
|
<!-- close=")">-->
|
|
<!-- #{organizationId}-->
|
|
<!-- </foreach>-->
|
|
<!-- </if>-->
|
|
|
|
<if test="userDriverDO.createBy != null">
|
|
and (b.create_by = #{userDriverDO.createBy}
|
|
or b.user_id = #{userDriverDO.createBy}
|
|
or m.motorcade_header_id = #{userDriverDO.createBy})
|
|
</if>
|
|
<if test="userDriverDO.createBy != null and userDriverDO.organizationIdList == null">
|
|
and b.create_by = #{userDriverDO.createBy}</if>
|
|
<if test="userDriverDO.organizationIdList != null and userDriverDO.createBy == null">
|
|
AND b.organization_id in
|
|
<foreach item="id" collection="userDriverDO.organizationIdList" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
<if test="userDriverDO.organizationIdList != null and userDriverDO.createBy != null">
|
|
AND (b.organization_id in
|
|
<foreach item="id" collection="userDriverDO.organizationIdList" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
OR b.create_by = #{userDriverDO.createBy})
|
|
</if>
|
|
</sql>
|
|
|
|
<select id="selectBindDriverInfoByIds" resultType="com.mhd.user.interfaces.facadeApi.Po.UserDriverBindListPo" parameterType="java.util.Set">
|
|
SELECT
|
|
a.driver_id,
|
|
a.user_id,
|
|
a.driver_fill,
|
|
b.avatar,
|
|
b.user_phone,
|
|
b.user_name,
|
|
b.user_account
|
|
FROM
|
|
user_driver a
|
|
LEFT JOIN "USER" b ON a.user_id = b.user_id AND b.del_flag = 1
|
|
WHERE
|
|
a.del_flag = 1
|
|
AND a.driver_id IN
|
|
<foreach collection="driverIdList" item="item" index="index" open="(" separator=" , "
|
|
close=")">
|
|
#{item}
|
|
</foreach>
|
|
</select>
|
|
|
|
<!--通用的查询条件-->
|
|
<sql id="common_where">
|
|
/*姓名*/
|
|
<!-- <if test="userDriverDO.userName != null and userDriverDO.userName != ''">-->
|
|
<!-- and b.user_name like concat('%' , #{userDriverDO.userName} , '%')-->
|
|
<!-- </if>-->
|
|
/*姓名/手机号/邮箱*/
|
|
<if test="userDriverDO.userName != null and userDriverDO.userName != ''">
|
|
AND concat( b.user_name, b.user_phone, b.user_email ) LIKE concat ('%' , #{userDriverDO.userName} , '%')
|
|
</if>
|
|
/*账号*/
|
|
<if test="userDriverDO.userAccount != null and userDriverDO.userAccount != ''">
|
|
AND b.user_account like concat('%', #{userDriverDO.userAccount}, '%')
|
|
</if>
|
|
/*角色*/
|
|
<if test="userDriverDO.roleName != null and userDriverDO.roleName != ''">
|
|
AND r.roleName like concat('%', #{userDriverDO.roleName}, '%')
|
|
</if>
|
|
/*车牌号*/
|
|
<if test="userDriverDO.vehicleLicensePlateNumber != null and userDriverDO.vehicleLicensePlateNumber != ''">
|
|
and dvb.vehicle_license_plate_number like concat('%' , #{userDriverDO.vehicleLicensePlateNumber} , '%')
|
|
</if>
|
|
/*车队名称*/
|
|
<if test="userDriverDO.driverTeamName != null and userDriverDO.driverTeamName != ''">
|
|
and m.motorcade_name like concat('%' , #{userDriverDO.driverTeamName} , '%')
|
|
</if>
|
|
/*承运人认证状态*/
|
|
<if test="userDriverDO.driverFill != null and userDriverDO.driverFill != ''">
|
|
and a.driver_fill = #{userDriverDO.driverFill}
|
|
</if>
|
|
/*承运人认证状态*/
|
|
<if test="userDriverDO.driverAuthStatus != null">
|
|
and a.driver_fill = #{userDriverDO.driverAuthStatus}
|
|
</if>
|
|
/*车队长认证*/
|
|
<if test="userDriverDO.driverCaptainFill != null">
|
|
and ud.driver_captain_fill = #{userDriverDO.driverCaptainFill}
|
|
</if>
|
|
/*实名认证状态*/
|
|
<if test="userDriverDO.userAuthStatus != null and userDriverDO.userAuthStatus != ''">
|
|
and b.user_auth_status = #{userDriverDO.userAuthStatus}
|
|
</if>
|
|
/*运输企业认证*/
|
|
<!-- <if test="userDriverDO.userAuthStatus != null and userDriverDO.userAuthStatus != ''">-->
|
|
<!-- and b.user_auth_status = #{userDriverDO.userAuthStatus}-->
|
|
<!-- </if>-->
|
|
<if test="userDriverDO.driverEnterpriseFill != null and userDriverDO.driverEnterpriseFill != ''">
|
|
and ude.driver_enterprise_fill = #{userDriverDO.driverEnterpriseFill}
|
|
</if>
|
|
/*身份证号*/
|
|
<if test="userDriverDO.userIdcardNumber != null and userDriverDO.userIdcardNumber != ''">
|
|
and b.user_idcard_number like concat('%' , #{userDriverDO.userIdcardNumber} , '%')
|
|
</if>
|
|
/*身份证有效期*/
|
|
<if test="userDriverDO.userIdcardDateFrom!=null and userDriverDO.userIdcardDateTo!=null ">
|
|
and DATE_FORMAT(b.user_idcard_date_to,'%Y-%m-%d') <![CDATA[>=]]>
|
|
DATE_FORMAT(#{userDriverDO.userIdcardDateFrom},'%Y-%m-%d')
|
|
and DATE_FORMAT(b.user_idcard_date_to,'%Y-%m-%d') <![CDATA[<=]]>
|
|
DATE_FORMAT(#{userDriverDO.userIdcardDateTo},'%Y-%m-%d')
|
|
</if>
|
|
/*详细地址*/
|
|
<if test="userDriverDO.userAreaAddress != null and userDriverDO.userAreaAddress != ''">
|
|
and b.user_area_address like concat('%' , #{userDriverDO.userAreaAddress} , '%')
|
|
</if>
|
|
/*司机用户类型*/
|
|
<if test="userDriverDO.userDriverType != null">
|
|
and a.user_driver_type = #{userDriverDO.userDriverType}
|
|
</if>
|
|
/*准驾车型id*/
|
|
<if test="userDriverDO.driverAllowDrivingTypeId != null and userDriverDO.driverAllowDrivingTypeId != ''">
|
|
and a.driver_allow_driving_type_id = #{userDriverDO.driverAllowDrivingTypeId}
|
|
</if>
|
|
/*驾驶证有效期*/
|
|
<if test="userDriverDO.driverLicenseDateFrom!=null and userDriverDO.driverLicenseDateTo!=null ">
|
|
and DATE_FORMAT(a.driver_license_date_to,'%Y-%m-%d') <![CDATA[>=]]>
|
|
DATE_FORMAT(#{userDriverDO.driverLicenseDateFrom},'%Y-%m-%d')
|
|
and DATE_FORMAT(a.driver_license_date_to,'%Y-%m-%d') <![CDATA[<=]]>
|
|
DATE_FORMAT(#{userDriverDO.driverLicenseDateTo},'%Y-%m-%d')
|
|
</if>
|
|
/*从业资格有效期*/
|
|
<if test="userDriverDO.driverWorkLicenseDateFrom!=null and userDriverDO.driverWorkLicenseDateTo!=null ">
|
|
and DATE_FORMAT(a.driver_work_license_date_to,'%Y-%m-%d') <![CDATA[>=]]>
|
|
DATE_FORMAT(#{userDriverDO.driverWorkLicenseDateFrom},'%Y-%m-%d')
|
|
and DATE_FORMAT(a.driver_work_license_date_to,'%Y-%m-%d') <![CDATA[<=]]>
|
|
DATE_FORMAT(#{userDriverDO.driverWorkLicenseDateTo},'%Y-%m-%d')
|
|
</if>
|
|
/*从业资格证号*/
|
|
<if test="userDriverDO.driverWorkLicenseNumber != null and userDriverDO.driverWorkLicenseNumber != ''">
|
|
and a.driver_work_license_number like concat('%' , #{userDriverDO.driverWorkLicenseNumber} , '%')
|
|
</if>
|
|
/*从业资格证发证省份编码*/
|
|
<if test="userDriverDO.driverWorkLicenseAuthorityCode != null and userDriverDO.driverWorkLicenseAuthorityCode != ''">
|
|
and a.driver_work_license_authority_code = #{userDriverDO.driverWorkLicenseAuthorityCode}
|
|
</if>
|
|
/*经营许可证号*/
|
|
<if test="userDriverDO.driverBusinessLicenseNumber != null and userDriverDO.driverBusinessLicenseNumber != ''">
|
|
and ude.driver_business_license_number = #{userDriverDO.driverBusinessLicenseNumber}
|
|
</if>
|
|
/*经营许可证有效期*/
|
|
<if test="userDriverDO.driverBusinessLicenseDateFrom!=null and userDriverDO.driverBusinessLicenseDateTo!=null ">
|
|
and DATE_FORMAT(ude.driver_business_license_date_from,'%Y-%m-%d') <![CDATA[>=]]>
|
|
DATE_FORMAT(#{userDriverDO.driverBusinessLicenseDateFrom},'%Y-%m-%d')
|
|
and DATE_FORMAT(ude.driver_business_license_date_to,'%Y-%m-%d') <![CDATA[<=]]>
|
|
DATE_FORMAT(#{userDriverDO.driverBusinessLicenseDateTo},'%Y-%m-%d')
|
|
</if>
|
|
/*企业名称*/
|
|
<if test="userDriverDO.driverEnterpriseName != null and userDriverDO.driverEnterpriseName != ''">
|
|
and ude.driver_enterprise_name like concat('%' , #{userDriverDO.driverEnterpriseName} , '%')
|
|
</if>
|
|
/*企业统一社会信用代码*/
|
|
<if test="userDriverDO.driverEnterpriseSocialCreditCode != null and userDriverDO.driverEnterpriseSocialCreditCode != ''">
|
|
and ude.driver_enterprise_social_credit_code like concat('%' , #{userDriverDO.driverEnterpriseSocialCreditCode} , '%')
|
|
</if>
|
|
/*营业期限*/
|
|
<if test="userDriverDO.driverEnterpriseLicenseDateFrom!=null and userDriverDO.driverEnterpriseLicenseDateTo!=null ">
|
|
and DATE_FORMAT(ude.driver_enterprise_license_date_from,'%Y-%m-%d') <![CDATA[>=]]>
|
|
DATE_FORMAT(#{userDriverDO.driverEnterpriseLicenseDateFrom},'%Y-%m-%d')
|
|
and DATE_FORMAT(ude.driver_enterprise_license_date_to,'%Y-%m-%d') <![CDATA[<=]]>
|
|
DATE_FORMAT(#{userDriverDO.driverEnterpriseLicenseDateTo},'%Y-%m-%d')
|
|
</if>
|
|
/*添加人员*/
|
|
<if test="userDriverDO.createByName != null and userDriverDO.createByName != ''">
|
|
and b.create_by_name like concat('%' , #{userDriverDO.createByName} , '%')
|
|
</if>
|
|
/*添加时间*/
|
|
<if test="userDriverDO.createTimeFrom!=null and userDriverDO.createTimeTo!=null ">
|
|
and DATE_FORMAT(b.create_time,'%Y-%m-%d') <![CDATA[>=]]>
|
|
DATE_FORMAT(#{userDriverDO.createTimeFrom},'%Y-%m-%d')
|
|
and DATE_FORMAT(b.create_time,'%Y-%m-%d') <![CDATA[<=]]>
|
|
DATE_FORMAT(#{userDriverDO.createTimeTo},'%Y-%m-%d')
|
|
</if>
|
|
/*审核人员*/
|
|
<if test="userDriverDO.driverFillAuthName != null and userDriverDO.driverFillAuthName != ''">
|
|
and a.driver_fill_auth_name like concat('%' , #{userDriverDO.driverFillAuthName} , '%')
|
|
</if>
|
|
/*审核时间*/
|
|
<if test="userDriverDO.userAuthTimeFrom!=null and userDriverDO.userAuthTimeTo!=null ">
|
|
and DATE_FORMAT(a.driver_fill_time,'%Y-%m-%d') <![CDATA[>=]]>
|
|
DATE_FORMAT(#{userDriverDO.userAuthTimeFrom},'%Y-%m-%d')
|
|
and DATE_FORMAT(a.driver_fill_time,'%Y-%m-%d') <![CDATA[<=]]>
|
|
DATE_FORMAT(#{userDriverDO.userAuthTimeTo},'%Y-%m-%d')
|
|
</if>
|
|
/*车牌号*/
|
|
<if test="userDriverDO.vehicleLicensePlateNumberTwo != null and userDriverDO.vehicleLicensePlateNumberTwo != ''">
|
|
and c.vehicle_license_plate_number like concat('%' , #{userDriverDO.vehicleLicensePlateNumberTwo} , '%')
|
|
</if>
|
|
<!-- <if test="userDriverDO.synthesize != null and userDriverDO.synthesize != ''">
|
|
and (b.vehicle_license_plate_number like concat('%' , #{userDriverDO.synthesize} , '%') OR u.user_name LIKE concat('%' , #{userDriverDO.synthesize} , '%') OR concat('%' , #{userDriverDO.synthesize} , '%'))
|
|
</if>-->
|
|
/* 组织ID集合 */
|
|
<!-- <if test="userDriverDO.permissionOrganizationIds!=null and userDriverDO.permissionOrganizationIds.size > 0">-->
|
|
<!-- AND b.organization_id IN-->
|
|
<!-- <foreach collection="userDriverDO.permissionOrganizationIds" item="organizationId" index="index" open="(" separator=" , "-->
|
|
<!-- close=")">-->
|
|
<!-- #{organizationId}-->
|
|
<!-- </foreach>-->
|
|
<!-- </if>-->
|
|
|
|
<if test="userDriverDO.organizationId != null"> and b.organization_id = #{userDriverDO.organizationId}</if>
|
|
<if test="userDriverDO.createBy != null">
|
|
and (b.create_by = #{userDriverDO.createBy}
|
|
or b.user_id = #{userDriverDO.createBy}
|
|
or mo.motorcade_header_id = #{userDriverDO.createBy})
|
|
</if>
|
|
<if test="userDriverDO.organizationIdList != null and userDriverDO.createBy == null">
|
|
AND b.organization_id in
|
|
<foreach item="id" collection="userDriverDO.organizationIdList" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
<if test="userDriverDO.organizationIdList != null and userDriverDO.createBy != null">
|
|
AND (b.organization_id in
|
|
<foreach item="id" collection="userDriverDO.organizationIdList" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
OR b.create_by = #{userDriverDO.createBy})
|
|
</if>
|
|
|
|
</sql>
|
|
|
|
<!--根据用户ID查询承运人信息-->
|
|
<select id="findMotorcadeVehicleList" parameterType="com.mhd.user.domain.userAggregate.repository.todo.UserDriverDO"
|
|
resultType="com.mhd.user.domain.motorcade.repository.po.MotorcadeDriverAppPo">
|
|
SELECT
|
|
m.motorcade_header_id,
|
|
md.user_id,
|
|
WM_CONCAT( c.vehicle_license_plate_number ) AS vehicleLicensePlateNumber,
|
|
u.user_phone,
|
|
u.user_name,
|
|
u.avatar,
|
|
u.user_auth_status,
|
|
ud.driver_fill
|
|
FROM
|
|
motorcade_driver md
|
|
LEFT JOIN driver_vehicle_bind c ON c.driver_bind_id = md.user_id
|
|
AND c.del_flag = 1
|
|
LEFT JOIN user_driver ud ON md.user_id = ud.user_id
|
|
AND ud.del_flag = 1
|
|
LEFT JOIN "USER" u ON ud.user_id = u.user_id
|
|
LEFT JOIN motorcade m ON md.motorcade_id = m.motorcade_id
|
|
WHERE
|
|
md.del_flag = 1
|
|
<include refid="common_where_two"></include>
|
|
GROUP BY
|
|
md.user_id
|
|
</select>
|
|
|
|
<sql id="common_where_two">
|
|
<if test="userDriverDO.motorcadeId != null">
|
|
AND md.motorcade_id = #{userDriverDO.motorcadeId}
|
|
</if>
|
|
<if test="userDriverDO.driverInfo != null and userDriverDO.driverInfo != ''">
|
|
AND (u.user_name like concat('%' , #{userDriverDO.driverInfo} , '%') OR u.user_phone like concat('%' , #{userDriverDO.driverInfo} , '%'))
|
|
</if>
|
|
</sql>
|
|
|
|
<select id="selectVehicleIdList" parameterType="java.lang.Long" resultType="java.lang.Long">
|
|
SELECT
|
|
vehicle_id
|
|
FROM
|
|
driver_vehicle_bind
|
|
WHERE
|
|
del_flag = 1
|
|
and driver_id = #{values}
|
|
</select>
|
|
|
|
<select id="selectDriverMangerList" parameterType="com.mhd.user.domain.userAggregate.repository.todo.UserDriverDO"
|
|
resultType="com.mhd.user.domain.userAggregate.repository.po.UserDriverPo">
|
|
SELECT
|
|
d.driver_id,
|
|
u.user_name,
|
|
u.user_auth_status
|
|
FROM
|
|
user_driver d
|
|
LEFT JOIN
|
|
"USER" u
|
|
ON d.user_id = u.user_id
|
|
LEFT JOIN
|
|
driver_vehicle_bind b
|
|
ON b.driver_id = d.driver_id
|
|
WHERE
|
|
<where>
|
|
<if test="conditionStatus != null and conditionStatus == '0'.toString()">
|
|
d.create_by = #{createBy}
|
|
<if test="driverIdList!=null and driverIdList.size > 0">
|
|
OR d.driver_id IN
|
|
<foreach collection="driverIdList" item="id" index="index" open="(" separator=" , " close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
</if>
|
|
<if test="conditionStatus != null and conditionStatus == '1'.toString()">
|
|
d.create_by = #{createBy}
|
|
</if>
|
|
<if test="conditionStatus != null and conditionStatus == '2'.toString()">
|
|
<if test="driverIdList!=null and driverIdList.size > 0">
|
|
OR d.driver_id IN
|
|
<foreach collection="driverIdList" item="id" index="index" open="(" separator=" , " close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
</if>
|
|
<!-- <if test="synthesize != null and synthesize != ''">-->
|
|
<!-- d.create_by = #{createBy}-->
|
|
<!-- </if>-->
|
|
<!-- <if test="synthesize != null and synthesize != ''">-->
|
|
<!-- and (b.vehicle_license_plate_number like concat('%' , #{synthesize} , '%') OR u.user_name LIKE concat('%' , #{synthesize} , '%') OR concat('%' , #{synthesize} , '%'))-->
|
|
<!-- </if>-->
|
|
</where>
|
|
|
|
GROUP BY d.driver_id
|
|
</select>
|
|
|
|
<select id="selectDriverInvitationList" resultType="com.mhd.user.domain.motorcade.repository.po.MotorcadeDriverAppPo" parameterType="com.mhd.user.domain.userAggregate.repository.todo.UserDriverDO">
|
|
SELECT
|
|
ud.user_id,
|
|
u.user_name,
|
|
u.user_phone,
|
|
u.avatar,
|
|
dvb.vehicle_license_plate_number,
|
|
dvb.vehicle_type_name,
|
|
r.roleCode
|
|
FROM
|
|
user_driver ud
|
|
LEFT JOIN "USER" u ON ud.user_id = u.user_id
|
|
AND u.del_flag = 1
|
|
LEFT JOIN (SELECT
|
|
user_id,
|
|
LISTAGG(DISTINCT r.role_code, '&') WITHIN GROUP(ORDER BY r.role_code) AS roleCode
|
|
FROM
|
|
role r
|
|
LEFT JOIN user_role ur ON r.role_id = ur.role_id
|
|
AND ur.del_flag = 1
|
|
WHERE
|
|
r.del_flag = 1
|
|
AND role_code IN ( 'driver', 'carrier', 'captain' )
|
|
GROUP BY
|
|
user_id
|
|
) r ON r.user_id = u.user_id
|
|
LEFT JOIN driver_vehicle_bind dvb ON dvb.user_id = ud.user_id
|
|
AND dvb.del_flag = 1
|
|
WHERE
|
|
ud.del_flag = 1
|
|
<include refid="driverInvitation_where"></include>
|
|
GROUP BY
|
|
ud.user_id
|
|
ORDER BY
|
|
ud.create_time DESC
|
|
</select>
|
|
<select id="getAllDriverList" resultType="com.mhd.user.domain.motorcade.repository.po.MotorcadeDriverAppPo">
|
|
SELECT
|
|
d.driver_id,
|
|
d.user_id,
|
|
u.user_name,
|
|
u.user_auth_status,
|
|
d.driver_fill,
|
|
dvb.vehicle_license_plate_number,
|
|
dvb.vehicle_id,
|
|
u.user_phone
|
|
FROM
|
|
user_driver d
|
|
LEFT JOIN driver_vehicle_bind dvb ON d.user_id = dvb.driver_bind_id AND dvb.del_flag = 1
|
|
LEFT JOIN "USER" u ON d.user_id = u.user_id
|
|
LEFT JOIN user_driver_enterprise ude ON d.user_driver_enterprise_id = ude.user_driver_enterprise_id
|
|
LEFT JOIN motorcade_driver md ON d.user_id = md.user_id and md.del_flag = 1
|
|
LEFT JOIN motorcade m ON m.motorcade_id = md.motorcade_id
|
|
WHERE
|
|
d.del_flag = 1
|
|
AND ( ude.user_id = #{createBy}
|
|
OR m.motorcade_header_id = #{createBy}
|
|
OR d.user_id = #{createBy})
|
|
<include refid="driverManageList"></include>
|
|
GROUP BY
|
|
d.user_id
|
|
</select>
|
|
<select id="getMyDriverList" resultType="com.mhd.user.domain.motorcade.repository.po.MotorcadeDriverAppPo">
|
|
SELECT
|
|
d.driver_id,
|
|
d.user_id,
|
|
u.user_name,
|
|
u.user_auth_status,
|
|
d.driver_fill,
|
|
dvb.vehicle_license_plate_number,
|
|
dvb.vehicle_id,
|
|
u.user_phone,
|
|
ude.user_driver_enterprise_id,
|
|
m.motorcade_id
|
|
FROM
|
|
user_driver d
|
|
LEFT JOIN driver_vehicle_bind dvb ON d.user_id = dvb.driver_bind_id AND dvb.del_flag = 1
|
|
LEFT JOIN "USER" u ON d.user_id = u.user_id
|
|
LEFT JOIN user_driver_enterprise ude ON d.user_driver_enterprise_id = ude.user_driver_enterprise_id
|
|
LEFT JOIN motorcade_driver md ON d.user_id = md.user_id and md.del_flag = 1
|
|
LEFT JOIN motorcade m ON m.motorcade_id = md.motorcade_id
|
|
WHERE
|
|
d.del_flag = 1
|
|
AND (
|
|
(m.motorcade_header_id = #{createBy} AND d.create_by = #{createBy}) OR ude.user_id = #{createBy}
|
|
)
|
|
<include refid="driverManageList"></include>
|
|
GROUP BY
|
|
d.user_id
|
|
</select>
|
|
<select id="getOutDriverList" resultType="com.mhd.user.domain.motorcade.repository.po.MotorcadeDriverAppPo">
|
|
SELECT
|
|
d.user_id,
|
|
d.driver_id,
|
|
u.user_name,
|
|
u.user_auth_status,
|
|
u.avatar,
|
|
d.driver_fill,
|
|
dvb.vehicle_license_plate_number,
|
|
dvb.vehicle_id,
|
|
u.user_phone,
|
|
m.motorcade_id
|
|
FROM
|
|
user_driver d
|
|
LEFT JOIN driver_vehicle_bind dvb ON d.user_id = dvb.driver_bind_id AND dvb.del_flag = 1
|
|
LEFT JOIN "USER" u ON d.user_id = u.user_id
|
|
LEFT JOIN motorcade_driver md ON d.user_id = md.user_id and md.del_flag = 1
|
|
LEFT JOIN motorcade m ON m.motorcade_id = md.motorcade_id
|
|
WHERE
|
|
d.del_flag = 1
|
|
AND m.motorcade_header_id = #{createBy}
|
|
and d.create_by != #{createBy}
|
|
and d.user_id != #{createBy}
|
|
<include refid="driverManageList"></include>
|
|
GROUP BY user_id
|
|
</select>
|
|
<sql id="driverManageList">
|
|
<if test="driverInfo != null and driverInfo != ''">
|
|
AND (dvb.vehicle_license_plate_number like concat('%', #{driverInfo}, '%')
|
|
or u.user_name like concat('%', #{driverInfo}, '%'))
|
|
</if>
|
|
</sql>
|
|
|
|
<sql id="driverInvitation_where">
|
|
<if test="userDriverDO.organizationId != null">
|
|
AND u.organization_id = #{userDriverDO.organizationId}
|
|
</if>
|
|
<if test="userDriverDO.driverInfo != null and userDriverDO.driverInfo != ''">
|
|
AND (dvb.vehicle_license_plate_number = #{userDriverDO.driverInfo} OR u.user_phone = #{userDriverDO.driverInfo})
|
|
</if>
|
|
<if test="userDriverDO.userInfo != null and userDriverDO.userInfo != ''">
|
|
AND (u.user_name = #{userDriverDO.userInfo} OR u.user_phone = #{userDriverDO.userInfo})
|
|
</if>
|
|
</sql>
|
|
|
|
<select id="userDriverAuthList" resultType="com.mhd.user.domain.userAggregate.repository.po.UserDriverPo">
|
|
select ud.driver_id,
|
|
u.user_id,
|
|
u.user_name,
|
|
u.user_phone,
|
|
u.user_account,
|
|
ude.user_driver_enterprise_id,
|
|
ude.driver_enterprise_name
|
|
from "USER" u
|
|
left join user_driver ud on ud.user_id = u.user_id and u.del_flag = 1
|
|
left join user_driver_enterprise ude
|
|
on u.user_id = ude.user_id and ude.del_flag = 1
|
|
where u.del_flag = 1
|
|
<if test="createBy != null"> and u.create_by = #{createBy}</if>
|
|
<if test="createBy != null and organizationIdList == null">
|
|
and u.create_by = #{createBy}</if>
|
|
<if test="organizationIdList != null and createBy == null">
|
|
AND u.organization_id in
|
|
<foreach item="id" collection="organizationIdList" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
<if test="organizationIdList != null and createBy != null">
|
|
AND (u.organization_id in
|
|
<foreach item="id" collection="organizationIdList" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
OR u.create_by = #{createBy})
|
|
</if>
|
|
</select>
|
|
|
|
<select id="motorcadeAuthCaptainList" resultType="java.util.HashMap">
|
|
select u.user_id userId,
|
|
u.top_organization_id topOrganizationId,
|
|
u.organization_id organizationId,
|
|
u.organization_name organizationName,
|
|
u.user_phone userPhone,
|
|
u.user_name userName,
|
|
u.user_account userAccount,
|
|
u.user_member_code userMemberCode,
|
|
u.user_idcard_number userIdcardNumber,
|
|
u.avatar avatar,
|
|
u.user_email userEmail,
|
|
u.user_area_county_id userAreaCountyId,
|
|
u.user_area_name userAreaName,
|
|
u.user_area_address userAreaAddress,
|
|
u.user_auth_status userAuthStatus,
|
|
u.user_birthday userBirthday,
|
|
concat(ude.driver_captain_fill,'') driverCaptainFill
|
|
from "USER" u
|
|
left join user_driver_enterprise ude on u.user_id = ude.user_id and ude.del_flag = 1
|
|
where u.del_flag = 1
|
|
and ude.driver_captain_fill = 3
|
|
and u.user_auth_status = 3
|
|
and u.top_organization_id = #{topOrganizationId}
|
|
</select>
|
|
|
|
<select id="getRegionDriverList" resultType="com.mhd.user.domain.userAggregate.repository.po.UserDriverPo">
|
|
select
|
|
u.user_id,
|
|
u.user_name,
|
|
u.user_phone,
|
|
u.user_idcard_number,
|
|
dvb.driver_vehicle_bind_id,
|
|
dvb.vehicle_license_plate_number,
|
|
dvb.vehicle_type_name,
|
|
ud.driver_fill
|
|
from user_driver ud
|
|
left join "USER" u on ud.user_id = u.user_id
|
|
left join driver_vehicle_bind dvb on ud.user_id = dvb.driver_bind_id and dvb.del_flag = 1 and dvb.default_flag = 1
|
|
where ud.del_flag = 1 and u.del_flag = 1
|
|
<if test="userDriverDO.topOrganizationId != null and userDriverDO.topOrganizationId != ''">
|
|
and u.top_organization_id = #{userDriverDO.topOrganizationId}
|
|
</if>
|
|
/*姓名/手机号/邮箱*/
|
|
<if test="userDriverDO.userPhone != null and userDriverDO.userPhone != ''">
|
|
and u.user_phone and concat ('%' , #{userDriverDO.userPhone} , '%')
|
|
</if>
|
|
/*姓名*/
|
|
<if test="userDriverDO.userName != null and userDriverDO.userName != ''">
|
|
and u.user_name like concat('%' , #{userDriverDO.userName} , '%')
|
|
</if>
|
|
<if test="userDriverDO.queryIds != null and userDriverDO.queryIds != ''">
|
|
and u.user_id in
|
|
<foreach item="item" index="index" collection="userDriverDO.queryIds.split(',')" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
</select>
|
|
|
|
<select id="getDriverCountByMatter" parameterType="com.mhd.common.core.domain.todo.StatisticalMattersDo"
|
|
resultType = "java.lang.Integer">
|
|
select
|
|
a.count + b.count
|
|
from (select count(1) as count
|
|
from "USER" u
|
|
left join user_driver ud on u.user_id = ud.user_id
|
|
<where>
|
|
u.del_flag = 1
|
|
and ud.del_flag = 1
|
|
and ud.driver_fill = 2
|
|
<if test="statisticalMattersDo.organizationId != null and statisticalMattersDo.organizationId != ''">
|
|
and u.organization_id = #{statisticalMattersDo.organizationId}
|
|
</if>
|
|
</where>
|
|
) a,
|
|
(select
|
|
ifnull(
|
|
sum(case when ude.driver_enterprise_fill = 2 then 1 end)
|
|
+
|
|
sum(case when ude.driver_captain_fill = 2 then 1 end), 0) as count
|
|
from "USER" u
|
|
left join user_driver_enterprise ude on u.user_id = ude.user_id
|
|
<where>
|
|
u.del_flag = 1
|
|
and ude.del_flag = 1
|
|
<if test="statisticalMattersDo.organizationId != null and statisticalMattersDo.organizationId != ''">
|
|
and u.organization_id = #{statisticalMattersDo.organizationId}
|
|
</if>
|
|
</where>
|
|
) b
|
|
</select>
|
|
|
|
<!--根据用户ID查询承运人信息-->
|
|
<select id="getDriverByUserId" parameterType="java.lang.Long"
|
|
resultType="com.mhd.user.domain.userAggregate.repository.po.UserDriverPo">
|
|
select
|
|
ud.*,
|
|
u.user_name,
|
|
u.user_phone,
|
|
ude.driver_enterprise_name,
|
|
ude.driver_enterprise_code
|
|
from user_driver ud
|
|
left join "USER" u on u.user_id = ud.user_id
|
|
left join user_driver_enterprise ude
|
|
on ude.user_driver_enterprise_id = ud.user_driver_enterprise_id and ude.del_flag = 1 and
|
|
driver_type = 1
|
|
<where>
|
|
ud.del_flag = 1
|
|
and u.del_flag = 1;
|
|
and u.user_id = #{value}
|
|
</where>
|
|
</select>
|
|
|
|
<select id="getDriverDataByUserId" parameterType="java.lang.Long"
|
|
resultType="com.mhd.user.domain.userAggregate.repository.po.UserDriverPo">
|
|
<include refid="selectUserDriverVo2"/>
|
|
and b.user_id = #{value}
|
|
</select>
|
|
|
|
<select id="getDriverSummaryData" parameterType="java.lang.Long"
|
|
resultType="com.mhd.user.domain.userAggregate.repository.po.UserDriverPo">
|
|
<include refid="selectUserDriverVo1"/>
|
|
and b.user_id = #{value}
|
|
group by b.user_id
|
|
</select>
|
|
<select id="getDriverCountList" resultType="com.mhd.user.domain.userAggregate.repository.po.DriverCountPo" parameterType="com.mhd.user.domain.userAggregate.repository.todo.UserDriverDO">
|
|
SELECT
|
|
b.user_id,
|
|
a.driver_fill,
|
|
ude.driver_enterprise_fill,
|
|
ud.driver_captain_fill
|
|
FROM
|
|
"USER" b
|
|
LEFT JOIN user_driver a ON a.user_id = b.user_id
|
|
LEFT JOIN user_driver_enterprise ude ON b.user_id = ude.user_id
|
|
AND ude.driver_type = 1
|
|
LEFT JOIN user_driver_enterprise ud ON b.user_id = ud.user_id
|
|
AND ud.driver_type = 2
|
|
LEFT JOIN driver_vehicle_bind dvb ON b.user_id = dvb.driver_bind_id
|
|
AND dvb.del_flag = 1
|
|
AND dvb.default_flag = 1
|
|
LEFT JOIN motorcade m ON a.driver_id = m.motorcade_header_id
|
|
AND m.del_flag = 1
|
|
left join motorcade_driver md on m.motorcade_id = md.motorcade_id and md.del_flag = 1
|
|
WHERE
|
|
b.del_flag = 1
|
|
AND ( a.del_flag = 1 OR a.del_flag IS NULL )
|
|
AND ( ude.del_flag = 1 OR ude.del_flag IS NULL )
|
|
AND ( ud.del_flag = 1 OR ud.del_flag IS NULL )
|
|
AND b.business_type IN ( 2, 3 )
|
|
<include refid="common_where_one"></include>
|
|
GROUP BY
|
|
b.user_id
|
|
ORDER BY
|
|
a.create_time DESC
|
|
</select>
|
|
<select id="getByMotorcade" resultType="com.mhd.user.domain.userAggregate.repository.po.UserDriverPo">
|
|
SELECT
|
|
m.motorcade_id,
|
|
m.motorcade_header_id,
|
|
a.driver_id,
|
|
a.user_id,
|
|
a.create_by
|
|
FROM
|
|
"USER" u
|
|
LEFT JOIN user_driver a ON u.user_id = a.user_id
|
|
LEFT JOIN motorcade_driver md ON a.user_id = md.user_id
|
|
LEFT JOIN motorcade m ON m.motorcade_id = md.motorcade_id
|
|
WHERE
|
|
u.del_flag = 1 and a.del_flag = 1
|
|
AND m.motorcade_id = #{motorcadeId} AND u.create_by = #{motorcadeHeaderId} and a.user_id != #{motorcadeHeaderId}
|
|
</select>
|
|
|
|
</mapper>
|