VehicleDocMapper.xml 3.31 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
      t6.username AS shopName,
      t6.account AS shopCode,
      t4.shop_level AS shopLevel,
      t1.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.id as vehicleId,
      t1.config_desc AS configDesc,
      t5.status as status,
      (select dict_label from t_dict_data  where dict_value=t5.status and dict_type = 'approval_status') AS approvalStatus,
      max(t5.created_date) as created_date,
      t5.id,
      t5.remark as remark
      FROM
      t_vehicle t1
      LEFT JOIN (select * from (select * from t_approval ORDER BY id desc)t  group by t.biz_id,t.biz_type) t5 ON (t1.ID = t5.biz_id AND t5.biz_type=2)
      LEFT JOIN t_trial_drive_shop t4 ON t1.created_by = t4.created_by
      LEFT JOIN t_user t6 ON t6.id = t1.created_by
      left join t_electric_fence t7 on t4.fence_id=t7.id
      WHERE
      t1.del_flag = 0
      and t6.username is not null
      <if test="search.approvalStatus !=null and search.approvalStatus != ''">
          and t5.status=#{search.approvalStatus}
      </if>
      <if test="search.submitStatus ==1">
          and t5.id is not null
      </if>
      <if test="search.submitStatus ==0">
          and t5.id is null
      </if>
      <if test="search.keywords !=null and search.keywords != ''">
          and (t6.username like concat('%',#{search.keywords},'%')
         or t6.account like concat('%',#{search.keywords},'%')
          or t7.fence_name like concat('%',#{search.keywords},'%')
          )
      </if>
        GROUP BY
            t1.id
            order by t1.created_date desc
  </select>

</mapper>