TrialDriveReportMapper.xml 3.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.TrialDriveReportMapper">
    <resultMap id="BaseResultMap"
               type="cn.com.glsx.admin.modules.model.export.TrialDriveReportExport">
        <result column="shopCode" jdbcType="VARCHAR" property="shopCode"/>
        <result column="shopName" jdbcType="VARCHAR" property="shopName"/>
        <result column="vehicleTypeName" jdbcType="VARCHAR" property="vehicleTypeName"/>
        <result column="sn" jdbcType="VARCHAR" property="sn"/>
        <result column="vin" jdbcType="VARCHAR" property="vin"/>
        <result column="statDate" jdbcType="VARCHAR" property="statDate"/>
        <result column="dayCount" jdbcType="INTEGER" property="dayCount"/>
        <result column="cnttotal" jdbcType="INTEGER" property="cnttotal"/>
    </resultMap>

    <resultMap id="PageBaseMap"
               type="cn.com.glsx.admin.modules.model.export.TrialDriveReportExport">
        <result column="shopCode" jdbcType="VARCHAR" property="shopCode"/>
        <result column="shopName" jdbcType="VARCHAR" property="shopName"/>
        <result column="sn" jdbcType="VARCHAR" property="sn"/>
        <result column="vin" jdbcType="VARCHAR" property="vin"/>
        <result column="vehicleId" jdbcType="INTEGER" property="vehicleId"/>
        <result column="vehicleTypeName" jdbcType="VARCHAR" property="vehicleTypeName"/>
    </resultMap>

    <select id="getTestDrivePageList"
            parameterType="cn.com.glsx.admin.modules.model.param.TrialDriveReportSearch"
            resultMap="PageBaseMap">
        SELECT
        tu.account shopCode,
        tu.username shopName,
        tv.vin,
        tv.id as vehicleId,
        case when tv.type_id is null then tv.model_name else concat(tv.sub_brand_name, '/', series_name) end vehicleTypeName
        FROM t_vehicle tv
        inner join t_trial_drive_vehicle ttdv on ttdv.vehicle_id = tv.id
        LEFT JOIN t_user tu ON tu.id = ttdv.created_by
        WHERE tu.del_flag = 0
        AND tv.del_flag = 0
        AND ttdv.del_flag = 0
        <if test="keywords != null and keywords!='' ">
            and (
            tu.account like '%${keywords}%'
            or tu.username like '%${keywords}%'
            )
        </if>
        order by tu.account
    </select>

    <select id="getTestDriveData" parameterType="cn.com.glsx.admin.modules.model.param.TrialDriveReportSearch"
            resultType="cn.com.glsx.admin.modules.model.export.TrialDriveReportExport">
        select tsfd.drive_num as cnttotal,
        left(tsfd.drive_time,7) as statDate,
        day(str_to_date(tsfd.drive_time, '%Y-%m-%d')) as dayCount
        from t_statistics_fence_drive tsfd
        left join t_vehicle_device tvd on tvd.sn = tsfd.sn
        <where>
            <choose>
                <when test="year != null and year != '' and month != null and month != '' ">
                    left(tsfd.drive_time,7) = CONCAT(#{year},'-',#{month})
                </when>
                <otherwise>
                    <if test="year != null and year != '' ">
                        left(tsfd.drive_time,4) = #{year}
                    </if>
                    <if test="month != null and month != '' ">
                        right(left(tsfd.drive_time,7),2) = #{month}
                    </if>
                </otherwise>
            </choose>
            and tvd.vehicle_id = #{vehicleId}
            and tvd.bind_status = 1
            and tvd.trial_type = 1
            and tvd.del_flag = 0
        </where>
    </select>

    <select id="getYearWithData" resultType="java.lang.String">
        select distinct left (journey_time, 4)
        from t_electric_fence_drive
    </select>
</mapper>