VehicleDocMapper.xml 3.29 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.VehicleDocMapper">
  <resultMap id="BaseResultMap" type="cn.com.glsx.admin.modules.entity.VehicleDoc">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="vehicle_id" jdbcType="INTEGER" property="vehicleId" />
    <result column="type" jdbcType="TINYINT" property="docType" />
    <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="url" jdbcType="VARCHAR" property="docUrl" />
    <result column="name" jdbcType="VARCHAR" property="docName" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbg.generated
    -->
    id, vehicle_id,doc_name, type, del_flag, created_date, created_by, updated_date, updated_by,
    doc_url
  </sql>


  <select id="findByCondition" resultMap="BaseResultMap">
        select * from t_vehicle_doc
    <where>
      <if test="vehicleId !=null and vehicleId != ''">
      and vehicle_id=#{vehicleId}
    </if>
      <if test="docType !=null and docType != ''">
        and type=#{docType}
      </if>
    </where>
  </select>

  <select id="search" resultType="cn.com.glsx.admin.modules.model.VehicleApproDto">
      SELECT
      t4.shop_name AS shopName,
      t4.shop_code AS shopCode,
      t4.shop_level AS shopLevel,
      t4.area AS area,
      t4.province AS province,
      t4.city AS city,
      t4.created_by as createdBy,
      t1.vin,
      t1.inner_color AS innerColor,
      t1.color AS color,
      t1.model_name AS modelName,
      t1.vehicle_type AS vehicleType,
      t1.config_desc AS configDesc,
      t6.dict_label AS approvalStatus,
      if(dict_label=null,"0","1") as submitStatus
      FROM
      t_vehicle t1
      LEFT JOIN t_vehicle_device t2 ON t1.id = t2.vehicle_id
      LEFT JOIN t_electric_fence_sns t3 ON t2.sn = t3.sn
      LEFT JOIN t_trial_drive_shop t4 ON t3.fence_id = t4.fence_id
      left join t_electric_fence t7 on t4.fence_id=t7.id
      LEFT JOIN t_approval t5 ON t1.ID = t5.biz_id
      LEFT JOIN t_dict_data t6 ON t5.biz_type = t6.dict_value
      WHERE
      t1.del_flag = 0
      AND t2.bind_status = 1
      and t6.dict_type = 'approval_status'
      and t4.shop_name is not null
      <if test="search.approvalStatus !=null and search.approvalStatus != ''">
          and t5.status=#{search.status}
      </if>
      <if test="search.submitStatus ==0">
          and t6.dict_label is null
      </if>
      <if test="search.submitStatus ==1">
          and t6.dict_label is not null
      </if>
      <if test="search.keywords !=null and search.keywords != ''">
          and (t4.shop_name like concat('%',#{search.keywords},'%')
         or t4.shop_code like concat('%',#{search.keywords},'%')
          or t7.fence_name like concat('%',#{search.keywords},'%')
          )
      </if>
        GROUP BY
            t1.id
  </select>

</mapper>