ElectricInStoreDriveMapper.xml 4.14 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.ElectricInStoreDriveMapper">

    <resultMap id="BaseResultMap" type="cn.com.glsx.admin.modules.entity.ElectricInStoreDrive">
        <id property="id" column="id" jdbcType="INTEGER"/>
        <result property="sn" column="sn" jdbcType="VARCHAR"/>
        <result property="fenceId" column="fence_id" jdbcType="INTEGER"/>
        <result property="sveSystemId" column="sve_system_id" jdbcType="INTEGER"/>
        <result property="positionState" column="position_state" jdbcType="TINYINT"/>
        <result property="gpsState" column="gps_state" jdbcType="TINYINT"/>
        <result property="gpsTime" column="gps_time" jdbcType="TIMESTAMP"/>
        <result property="dayOfMonth" column="dayOfMonth" jdbcType="VARCHAR"/>
        <result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
        <result property="updatedTime" column="updated_time" jdbcType="TIMESTAMP"/>
    </resultMap>

    <resultMap id="InStoreDataMap" type="cn.com.glsx.admin.modules.entity.ElectricInStoreDrive">
        <result property="instoreCnt" column="instoreCnt" jdbcType="INTEGER"/>
        <result property="statDate" column="statDate" jdbcType="VARCHAR"/>
        <result property="dayOfMonth" column="dayOfMonth" jdbcType="INTEGER"/>
    </resultMap>

    <sql id="Base_Column_List">
        id,sn,fence_id,
        sve_system_id,position_state,gps_state,
        gps_time,created_time,updated_time
    </sql>

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

    <select id="getAllTestDrive" parameterType="cn.com.glsx.admin.modules.model.param.ElectricInStoreSearch"
            resultType="cn.com.glsx.admin.modules.model.export.ElectricInStoreExport">
        SELECT
        tu.account shopCode,
        tu.username shopName,
        tv.vin,
        tv.id as vehicleId,
        tv.model_name as modelName,
        GROUP_CONCAT(tvd.sn) as sn,
        tv.created_by as createdBy
        FROM t_vehicle tv
        LEFT JOIN t_vehicle_device tvd on tvd.vehicle_id = tv.id
        LEFT JOIN t_user tu ON tu.id = tv.created_by
        WHERE tu.del_flag = 0
        AND tv.del_flag = 0
        AND tvd.his_type = 1
        <if test="keywords != null and keywords!='' ">
            and (
            tu.account like '%${keywords}%'
            or tu.username like '%${keywords}%'
            or tv.vin like '%${keywords}%'
            or tv.model_name like '%${keywords}%'
            )
        </if>
        group by tv.id
        order by tu.account
    </select>

    <!--    <select id="getInStoreDataList" resultMap="InStoreDataMap">-->
    <!--        select-->
    <!--        case when sum(case when teid.gps_state = 2 then 1 else 0 end) = count(1) then 1 else 0 end as instoreCnt,-->
    <!--        teid.gps_time ,-->
    <!--        day(teid.gps_time) as dayOfMonth-->
    <!--        from t_electric_instore_drive teid-->
    <!--        left join t_vehicle_device tvd on tvd.id = teid.vd_id-->
    <!--        <where>-->
    <!--            <if test="year != null and year != '' and month != null and month != '' ">-->
    <!--                left(teid.gps_time,7) = CONCAT(#{year},'-',#{month})-->
    <!--            </if>-->
    <!--            and tvd.vehicle_id = #{vehicleId}-->
    <!--        </where>-->
    <!--        group by left(teid.gps_time,10)-->
    <!--    </select>-->

    <select id="getInStoreDataList" resultMap="InStoreDataMap">
        select tsid.instore_num as instoreCnt,
        left(tsid.instore_time, 7) as statDate,
        day(str_to_date(tsid.instore_time, '%Y-%m-%d')) as dayOfMonth
        from t_statistics_instore_drive tsid
        left join t_vehicle_device tvd on tvd.id = tsid.vd_id
        <where>
            <if test="year != null and year != '' and month != null and month != '' ">
                left(tsid.instore_time,7) = CONCAT(#{year},'-',#{month})
            </if>
            and tvd.vehicle_id = #{vehicleId}
        </where>
    </select>
</mapper>