<?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="com.elephant.framework.galaxy.aroad.module.zhjg.mapper.ZhjgLzglCxysxkMapper">

  <resultMap id="zhjgLzglCxysxkMap" type="com.elephant.framework.galaxy.aroad.module.zhjg.entity.ZhjgLzglCxysxk">
        <id property="id" column="id"/>
        <result property="rq" column="rq"/>
        <result property="xkdh" column="xkdh"/>
        <result property="cph" column="cph"/>
        <result property="cd" column="cd"/>
        <result property="kd" column="kd"/>
        <result property="gd" column="gd"/>
        <result property="zs" column="zs"/>
        <result property="hwmc" column="hwmc"/>
        <result property="chzz" column="chzz"/>
        <result property="txlx" column="txlx"/>
        <result property="blsj" column="blsj"/>
        <result property="txsj" column="txsj"/>
        <result property="cydw" column="cydw"/>
        <result property="blzt" column="blzt"/>
        <result property="sqdh" column="sqdh"/>
        <result property="sqdworgr" column="sqdworgr"/>
        <result property="gccph" column="gccph"/>
        <result property="qqdd" column="qqdd"/>
        <result property="sldw" column="sldw"/>
        <result property="slr" column="slr"/>
        <result property="dwjb" column="dwjb"/>
        <result property="blfw" column="blfw"/>
        <result property="status" column="status"/>
        <result property="ifks" column="ifks"/>
  </resultMap>
      <select id="selectCxysXkgsByCurrentDate" resultMap="zhjgLzglCxysxkMap">
            select *
            from t_zhjg_lzgl_cxysxk
            <where>
              <if test="startDate!=null">
                    str_to_date(substring_index(txsj,'-', 1), '%Y年%m月%e日')&gt;=#{startDate}
              </if>
              <if test="endDate!=null">
                    and str_to_date(substring_index(txsj,'-', -1), '%Y年%m月%e日')&lt;=#{endDate}
              </if>
              <if test="cph!=null">
                  and cph like CONCAT('%',#{cph}, '%')
              </if>
                <if test="xkdh!=null">
                    and xkdh like CONCAT('%',#{xkdh}, '%')
                </if>
                and ifks=2
            </where>
      </select>

    <select id="selectCountKsFzSpByDate" resultType="Integer">
        select count(*) from t_zhjg_lzgl_cxysxk
        <where>
            <if test="xkdh">
                TRIM(xkdh) like CONCAT('',#{xkdh},'%')
            </if>
            <if test="startDate">
                and rq &gt;= #{startDate}
            </if>
            <if test="endDate">
                and rq &lt;= #{endDate}
            </if>
            and ifks=1
        </where>
    </select>
</mapper>
