VehicleMapper.xml 4.75 KB
<?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.com.glsx.admin.modules.mapper.VehicleMapper">
  <resultMap id="BaseResultMap" type="cn.com.glsx.admin.modules.entity.Vehicle">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="workorder_id" jdbcType="INTEGER" property="workorderId" />
    <result column="owner_name" jdbcType="VARCHAR" property="ownerName" />
    <result column="vin" jdbcType="VARCHAR" property="vin" />
    <result column="owner_sex" jdbcType="VARCHAR" property="ownerSex" />
    <result column="owner_tel" jdbcType="VARCHAR" property="ownerTel" />
    <result column="brand_id" jdbcType="INTEGER" property="brandId" />
    <result column="brand_name" jdbcType="VARCHAR" property="brandName" />
    <result column="series_id" jdbcType="INTEGER" property="seriesId" />
    <result column="series_name" jdbcType="VARCHAR" property="seriesName" />
    <result column="model_id" jdbcType="INTEGER" property="modelId" />
    <result column="model_name" jdbcType="VARCHAR" property="modelName" />
    <result column="config_desc" jdbcType="VARCHAR" property="configDesc" />
    <result column="color" jdbcType="VARCHAR" property="color" />
    <result column="inner_color" jdbcType="VARCHAR" property="innerColor" />
    <result column="license_plate" jdbcType="VARCHAR" property="licensePlate" />
    <result column="vehicle_type" jdbcType="TINYINT" property="vehicleType" />
    <result column="engine" jdbcType="VARCHAR" property="engine" />
    <result column="displacement" jdbcType="VARCHAR" property="displacement" />
    <result column="mileage" jdbcType="VARCHAR" property="mileage" />
    <result column="buy_date" jdbcType="DATE" property="buyDate" />
    <result column="description" jdbcType="VARCHAR" property="description" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="serve_type" jdbcType="TINYINT" property="serveType" />
    <result column="validate_status" jdbcType="TINYINT" property="validateStatus" />
    <result column="validate_info" jdbcType="VARCHAR" property="validateInfo" />
    <result column="del_flag" jdbcType="TINYINT" property="delFlag" />
    <result column="created_date" jdbcType="TIMESTAMP" property="createdDate" />
    <result column="created_by" jdbcType="INTEGER" property="createdBy" />
    <result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate" />
    <result column="updated_by" jdbcType="INTEGER" property="updatedBy" />
    <result column="order_no" jdbcType="INTEGER" property="orderNo" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbg.generated
    -->
    id, workorder_id, owner_name, vin, owner_sex, owner_tel, brand_id, brand_name, series_id, 
    series_name, model_id, model_name, config_desc, color, inner_color, license_plate, 
    vehicle_type, engine, displacement, mileage, buy_date, description, remark, serve_type, 
    validate_status, validate_info, del_flag, created_date, created_by, updated_date, 
    updated_by, order_no
  </sql>

    <select id="linkSnsSearch" resultType="cn.com.glsx.admin.modules.model.VehicleLinkSnsDTO">
        select tv.owner_name name, tv.vin, tv.owner_tel userTel, group_concat(tvd.sn) sns
        from t_vehicle tv
        left join t_vehicle_device tvd on tv.id = tvd.vehicle_id
        left join t_device td on tvd.sn = td.sn
        where tv.del_flag = 0
        and tvd.bind_status = 1
        <if test="deviceSource != null">
            and td.source = #{deviceSource}
        </if>
        group by tv.id
    </select>

    <select id="searchTrialDrive" resultType="cn.com.glsx.admin.modules.model.TrialDriveVehicleDTO">
        select tv.id tempId, tv.order_no workOrderNo, tv.vin, tv.model_name modelName, tv.config_desc vehicleConfig, tv.license_plate licensePlate,
        ttds.area, ttds.province, ttds.city, ttds.shop_name shopName, ttds.shop_code shopCode, ttds.shop_level shop_code,
        group_concat(tvd.sn) sns, tvd.created_date installedTime
        from t_vehicle tv
        left join t_vehicle_device tvd on tv.id = tvd.vehicle_id and tvd.bind_status = 1 and tvd.del_flag = 0
        left join t_user tu on tv.created_by = tu.id and tu.del_flag = 0
        left join t_trial_drive_shop ttds tu.account = ttds.shop_code and ttds.del_flag = 0
        where tv.del_flag = 0
        <if test="searchKey != null and searchKey != '' ">
            and (
            ttds.shop_code like '%'#{name}'%'
            or ttds.shop_name like '%'#{name}'%'
            or tv.vin like '%'#{name}'%'
            or tvd.sn like '%'#{name}'%'
            or tv.model_name like '%'#{name}'%'
            )
        </if>
        group by tv.id;
    </select>
</mapper>