<?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.hzya.frame.grpU8.nxproof.glczrz.dao.impl.GlCzrzDaoImpl">

    <resultMap id="get-GlCzrzEntity-result" type="com.hzya.frame.grpU8.nxproof.glczrz.entity.GlCzrzEntity" >
       <result property="station" column="station" jdbcType="VARCHAR"/>
           <result property="no" column="no" jdbcType="INTEGER"/>
           <result property="name" column="name" jdbcType="VARCHAR"/>
           <result property="date" column="date" jdbcType="VARCHAR"/>
           <result property="zwrq" column="zwrq" jdbcType="VARCHAR"/>
           <result property="qssj" column="qssj" jdbcType="VARCHAR"/>
           <result property="zzsj" column="zzsj" jdbcType="VARCHAR"/>
           <result property="cznr" column="cznr" jdbcType="VARCHAR"/>
           <result property="cznrkz" column="CZNRKZ" jdbcType="VARCHAR"/>
        </resultMap>
    <!-- 查询的字段-->
    <sql id = "GlCzrzEntity_Base_Column_List">
        station
       ,no 
        ,name 
        ,date 
        ,zwrq 
        ,qssj 
        ,zzsj 
        ,cznr 
        ,CZNRKZ 
     </sql>
 <!-- 查询 采用==查询 -->
 <select id="entity_list_base" resultMap="get-GlCzrzEntity-result" parameterType = "com.hzya.frame.grpU8.nxproof.glczrz.entity.GlCzrzEntity">
    select
    <include refid="GlCzrzEntity_Base_Column_List" />
    from GL_Czrz
    <trim prefix="where" prefixOverrides="and"> 
        <if test="station != null and station != ''"> and station = #{station} </if>
            <if test="no != null"> and no = #{no} </if>
            <if test="name != null and name != ''"> and name = #{name} </if>
            <if test="date != null and date != ''"> and date = #{date} </if>
            <if test="zwrq != null and zwrq != ''"> and zwrq = #{zwrq} </if>
            <if test="qssj != null and qssj != ''"> and qssj = #{qssj} </if>
            <if test="zzsj != null and zzsj != ''"> and zzsj = #{zzsj} </if>
            <if test="cznr != null and cznr != ''"> and cznr = #{cznr} </if>
            <if test="cznrkz != null and cznrkz != ''"> and CZNRKZ = #{cznrkz} </if>
    </trim>
</select>
    
<!-- 查询符合条件的数量 -->
<select id="entity_count" resultType="Integer" parameterType = "com.hzya.frame.grpU8.nxproof.glczrz.entity.GlCzrzEntity">
        select  count(1)   from GL_Czrz
    <trim prefix="where" prefixOverrides="and"> 
        <if test="station != null and station != ''"> and station = #{station} </if>
            <if test="no != null"> and no = #{no} </if>
            <if test="name != null and name != ''"> and name = #{name} </if>
            <if test="date != null and date != ''"> and date = #{date} </if>
            <if test="zwrq != null and zwrq != ''"> and zwrq = #{zwrq} </if>
            <if test="qssj != null and qssj != ''"> and qssj = #{qssj} </if>
            <if test="zzsj != null and zzsj != ''"> and zzsj = #{zzsj} </if>
            <if test="cznr != null and cznr != ''"> and cznr = #{cznr} </if>
            <if test="cznrkz != null and cznrkz != ''"> and CZNRKZ = #{cznrkz} </if>
    </trim>
    </select>

    <!-- 分页查询列表 采用like格式 -->
<select id="entity_list_like" resultMap="get-GlCzrzEntity-result" parameterType = "com.hzya.frame.grpU8.nxproof.glczrz.entity.GlCzrzEntity">
    select
    <include refid="GlCzrzEntity_Base_Column_List" />
    from GL_Czrz
    <trim prefix="where" prefixOverrides="and"> 
        <if test="station != null and station != ''"> and station like concat('%',#{station},'%') </if>
            <if test="no != null"> and no like concat('%',#{no},'%') </if>
            <if test="name != null and name != ''"> and name like concat('%',#{name},'%') </if>
            <if test="date != null and date != ''"> and date like concat('%',#{date},'%') </if>
            <if test="zwrq != null and zwrq != ''"> and zwrq like concat('%',#{zwrq},'%') </if>
            <if test="qssj != null and qssj != ''"> and qssj like concat('%',#{qssj},'%') </if>
            <if test="zzsj != null and zzsj != ''"> and zzsj like concat('%',#{zzsj},'%') </if>
            <if test="cznr != null and cznr != ''"> and cznr like concat('%',#{cznr},'%') </if>
            <if test="cznrkz != null and cznrkz != ''"> and CZNRKZ like concat('%',#{cznrkz},'%') </if>
    </trim>
</select>

<!-- 查询列表 字段采用or格式 -->
<select id="GlCzrzentity_list_or" resultMap="get-GlCzrzEntity-result" parameterType = "com.hzya.frame.grpU8.nxproof.glczrz.entity.GlCzrzEntity">
    select
    <include refid="GlCzrzEntity_Base_Column_List" />
    from GL_Czrz
    <trim prefix="where" prefixOverrides="and"> 
         <if test="station != null and station != ''"> or station = #{station} </if>
             <if test="no != null"> or no = #{no} </if>
             <if test="name != null and name != ''"> or name = #{name} </if>
             <if test="date != null and date != ''"> or date = #{date} </if>
             <if test="zwrq != null and zwrq != ''"> or zwrq = #{zwrq} </if>
             <if test="qssj != null and qssj != ''"> or qssj = #{qssj} </if>
             <if test="zzsj != null and zzsj != ''"> or zzsj = #{zzsj} </if>
             <if test="cznr != null and cznr != ''"> or cznr = #{cznr} </if>
             <if test="cznrkz != null and cznrkz != ''"> or CZNRKZ = #{cznrkz} </if>
    </trim>
</select>

    <!--操作日志no最大值+1-->
    <select id="queryCzrzNo" resultMap="get-GlCzrzEntity-result" parameterType = "com.hzya.frame.grpU8.nxproof.glczrz.entity.GlCzrzEntity">
        select isnull(max(no),0)+1 as no from Gl_czrz   where station like concat(#{station},'%')
    </select>

<!--新增所有列-->
<insert id="entity_insert" parameterType = "com.hzya.frame.grpU8.nxproof.glczrz.entity.GlCzrzEntity" keyProperty="station" useGeneratedKeys="true">
    insert into GL_Czrz(
  <trim suffix="" suffixOverrides=",">
            <if test="no != null"> no , </if>
            <if test="name != null and name != ''"> name , </if>
            <if test="date != null and date != ''"> date , </if>
            <if test="zwrq != null and zwrq != ''"> zwrq , </if>
            <if test="qssj != null and qssj != ''"> qssj , </if>
            <if test="zzsj != null and zzsj != ''"> zzsj , </if>
            <if test="cznr != null and cznr != ''"> cznr , </if>
            <if test="cznrkz != null and cznrkz != ''"> CZNRKZ , </if>
            <if test="station != null and station != ''"> station  </if>
  </trim>
  )values(
 <trim suffix="" suffixOverrides=",">
            <if test="no != null"> #{no} ,</if>
            <if test="name != null and name != ''"> #{name} ,</if>
            <if test="date != null and date != ''"> select convert(char(8),getdate(),112),</if>
            <if test="zwrq != null and zwrq != ''"> select convert(char(8),getdate(),112) ,</if>
            <if test="qssj != null and qssj != ''"> select convert(char(8),getdate(),108) ,</if>
            <if test="zzsj != null and zzsj != ''"> select convert(char(8),getdate(),108) ,</if>
            <if test="cznr != null and cznr != ''"> #{cznr} ,</if>
            <if test="cznrkz != null and cznrkz != ''"> #{cznrkz} ,</if>
            <if test="station != null and station != ''"> #{station} </if>
  </trim>
  )  
</insert>
<!-- 批量新增 -->
<insert id="entityInsertBatch" keyProperty="station" useGeneratedKeys="true">
  insert into GL_Czrz(name, date, zwrq, qssj, zzsj, cznr, CZNRKZ,  sts) 
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.name},#{entity.date},#{entity.zwrq},#{entity.qssj},#{entity.zzsj},#{entity.cznr},#{entity.cznrkz}, 'Y')
    </foreach>
</insert>
<!-- 批量新增或者修改-->
<insert id="entityInsertOrUpdateBatch" keyProperty="station" useGeneratedKeys="true">
    insert into GL_Czrz(name, date, zwrq, qssj, zzsj, cznr, CZNRKZ)
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.name},#{entity.date},#{entity.zwrq},#{entity.qssj},#{entity.zzsj},#{entity.cznr},#{entity.cznrkz})
    </foreach>
    on duplicate key update
    name = values(name),
    date = values(date),
    zwrq = values(zwrq),
    qssj = values(qssj),
    zzsj = values(zzsj),
    cznr = values(cznr),
    CZNRKZ = values(CZNRKZ)</insert>
<!--通过主键修改方法-->
<update id="entity_update" parameterType = "com.hzya.frame.grpU8.nxproof.glczrz.entity.GlCzrzEntity" >
update GL_Czrz  set
<trim suffix="" suffixOverrides=",">
  <if test="name != null and name != ''"> name = #{name},</if>
  <if test="date != null and date != ''"> date = #{date},</if>
  <if test="zwrq != null and zwrq != ''"> zwrq = #{zwrq},</if>
  <if test="qssj != null and qssj != ''"> qssj = #{qssj},</if>
  <if test="zzsj != null and zzsj != ''"> zzsj = #{zzsj},</if>
  <if test="cznr != null and cznr != ''"> cznr = #{cznr},</if>
  <if test="cznrkz != null and cznrkz != ''"> CZNRKZ = #{cznrkz},</if>
</trim>
where station = #{station}
</update>
<!-- 逻辑删除 -->
<update id="entity_logicDelete" parameterType = "com.hzya.frame.grpU8.nxproof.glczrz.entity.GlCzrzEntity" >
update GL_Czrz  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
where station = #{station}
</update>
<!-- 多条件逻辑删除 -->
<update id="entity_logicDelete_Multi_Condition" parameterType = "com.hzya.frame.grpU8.nxproof.glczrz.entity.GlCzrzEntity" >
update GL_Czrz  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
 <trim prefix="where" prefixOverrides="and"> 
        <if test="station != null and station != ''"> and station = #{station} </if>
            <if test="no != null"> and no = #{no} </if>
            <if test="name != null and name != ''"> and name = #{name} </if>
            <if test="date != null and date != ''"> and date = #{date} </if>
            <if test="zwrq != null and zwrq != ''"> and zwrq = #{zwrq} </if>
            <if test="qssj != null and qssj != ''"> and qssj = #{qssj} </if>
            <if test="zzsj != null and zzsj != ''"> and zzsj = #{zzsj} </if>
            <if test="cznr != null and cznr != ''"> and cznr = #{cznr} </if>
            <if test="cznrkz != null and cznrkz != ''"> and CZNRKZ = #{cznrkz} </if>
    </trim>
</update>
<!--通过主键删除-->
<delete id="entity_delete">
    delete from GL_Czrz where station = #{station}
</delete>

</mapper>

