VehicleMapper.xml 8.04 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.stdinterface.modules.mapper.VehicleMapper">
    <resultMap id="BaseResultMap" type="cn.com.glsx.stdinterface.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="sub_brand_id" jdbcType="INTEGER" property="subBrandId"/>
        <result column="sub_brand_name" jdbcType="VARCHAR" property="subBrandName"/>
        <result column="series_id" jdbcType="INTEGER" property="seriesId"/>
        <result column="series_name" jdbcType="VARCHAR" property="seriesName"/>
        <result column="type_id" jdbcType="INTEGER" property="typeId"/>
        <result column="type_name" jdbcType="VARCHAR" property="typeName"/>
        <result column="model_id" jdbcType="INTEGER" property="modelId"/>
        <result column="model_name" jdbcType="VARCHAR" property="modelName"/>
        <result column="config_id" jdbcType="INTEGER" property="configId"/>
        <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_type" jdbcType="INTEGER" property="buyType"/>
        <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="sale_manager" jdbcType="VARCHAR" property="saleManager"/>
        <result column="sale_manager_phone" jdbcType="VARCHAR" property="saleManagerPhone"/>
        <result column="validate_status" jdbcType="TINYINT" property="validateStatus"/>
        <result column="vehicle_usages" jdbcType="TINYINT" property="vehicleUsages"/>
        <result column="validate_info" jdbcType="VARCHAR" property="validateInfo"/>
        <result column="settle_flag" jdbcType="TINYINT" property="settleFlag"/>
        <result column="ref_vehicle_id" jdbcType="INTEGER" property="refVehicleId"/>
        <result column="ref_order_id" jdbcType="INTEGER" property="refOrderId"/>
        <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="registration_date" jdbcType="TIMESTAMP" property="registrationDate"/>
        <result column="sale_manager" jdbcType="VARCHAR" property="saleManager"/>
        <result column="sale_manager_phone" jdbcType="VARCHAR" property="saleManagerPhone"/>
        <result column="buy_type" jdbcType="DATE" property="buyType"/>
    </resultMap>

    <resultMap id="VehicleDeviceOperatorResultMap" type="cn.com.glsx.stdinterface.modules.entity.VehicleDeviceOperator">
        <result column="sn" jdbcType="INTEGER" property="sn"/>
        <result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
        <result column="updated_by" jdbcType="VARCHAR" property="updatedBy"/>
    </resultMap>

    <sql id="Base_Column_List">
        <!--
          WARNING - @mbg.generated
        -->
        id, workorder_id, owner_name, vin, owner_sex, owner_tel, brand_id, brand_name, sub_brand_id,
        sub_brand_name, series_id, series_name, type_id, type_name, model_id, model_name,
        config_id, config_desc, color, inner_color, license_plate, vehicle_type, engine,
        displacement, mileage, buy_type, buy_date, description, remark, serve_type, sale_manager,
        sale_manager_phone, validate_status, vehicle_usages, validate_info, settle_flag, del_flag, created_date,
        created_by, updated_date, updated_by, registration_date, ref_vehicle_id, ref_order_id
    </sql>

    <select id="selectByWorkOrderId" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_vehicle
        where del_flag = 0
        and workorder_id = #{workOrderId}
    </select>

    <select id="selectAllByNotNullRefVehicleId" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_vehicle
        where del_flag = 0
        and ref_vehicle_id is not null
    </select>

    <select id="selectByRefWorkOrderId" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_vehicle
        where del_flag = 0
        and ref_order_id = #{refOrderId}
        limit 1
    </select>

    <select id="selectByRefVehicleId" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_vehicle
        where del_flag = 0
        and ref_vehicle_id = #{refVehicleId}
        limit 1
    </select>

    <select id="selectByNullCreateBy" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_vehicle
        where del_flag = 0
        and ref_vehicle_id is not null
        and created_by is null
    </select>

    <update id="updateCreateByByRefVehicleIds">
        update t_vehicle
        set created_by = #{userId}
        where ref_vehicle_id is not null
        and ref_vehicle_id in
        <foreach collection="refVehicleIds" open="(" close=")" separator="," item="item">
            #{item}
        </foreach>
    </update>

    <select id="getVehicleBySn" resultMap="BaseResultMap">
        select
        tv.id,
        tv.vin,
        tv.created_by,
        tv.created_date
        from t_vehicle tv
        left join t_vehicle_device tvd on tv.id = tvd.vehicle_id
        where tvd.sn = #{sn}
        and tvd.del_flag = 0 and tv.del_flag = 0
        and tvd.bind_status = 1;
    </select>

    <select id="selectByWorkOrderIdAndVin" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_vehicle
        where del_flag = 0
        and workorder_id = #{workOrderId}
        and vin=#{vin}
    </select>


    <select id="getVehicleByVdId" resultMap="BaseResultMap">
        select
        tv.vin,
        tv.owner_name,
        tv.license_plate
        from t_vehicle tv
        left join t_vehicle_device tvd on tv.id = tvd.vehicle_id
        where tvd.id = #{vdId}
        and tvd.del_flag = 0
        and tv.del_flag = 0
        and tvd.bind_status = 1
    </select>

    <select id="listVehicleBySn" resultMap="VehicleDeviceOperatorResultMap">
        select
        tvd.sn,
        tv.created_by,
        tv.updated_by
        from t_vehicle tv
        left join t_vehicle_device tvd on tv.id = tvd.vehicle_id
        <where>
            and tvd.del_flag = 0
            and tv.del_flag = 0
            and tvd.bind_status = 1
            and tvd.sn in
            <foreach collection="sn" separator="," open="(" close=")" item="item">
                #{item}
            </foreach>
        </where>
    </select>
</mapper>