<?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.pubauditlog.dao.impl.PubAuditLogDaoImpl">
    <resultMap id="get-PubAuditLogEntity-result" type="com.hzya.frame.grpU8.nxproof.pubauditlog.entity.PubAuditLogEntity">
        <result property="billId" column="billId" />
        <result property="gsdm" column="gsdm" />
        <result property="kjnd" column="kjnd" />
        <result property="logId" column="logId" />
        <result property="billname" column="billname" />
        <result property="flowcode" column="flowcode" />
        <result property="flowname" column="flowname" />
        <result property="modname" column="modname" />
        <result property="bizname" column="bizname" />
        <result property="nodename" column="nodename" />
        <result property="nodeseq" column="nodeseq" />
        <result property="auditorId" column="auditorId" />
        <result property="auditor" column="auditor" />
        <result property="adatetime" column="adatetime" />
        <result property="remark" column="remark" />
        <result property="atype" column="atype" />
        <result property="amt" column="amt" />
        <result property="servdatetime" column="servdatetime" />
        <result property="computername" column="computername" />
    </resultMap>

   <sql id="PubAuditLogEntity_Base_Column_List">
GSDM,KJN
   </sql>

    <!--查询logId最大值+1-->
    <select id="PubAuditLogEntity_list_base_max" resultMap="get-PubAuditLogEntity-result" parameterType="com.hzya.frame.grpU8.nxproof.pubauditlog.entity.PubAuditLogEntity">
        select isnull(max(logid)+1,1) as logId from PUBAUDITLOG WHERE gsdm = #{gsdm} AND kjnd = #{kjnd}
    </select>
    <!--查询logseq最大值+1-->
    <select id="PubAuditLogEntity_list_base_logseq" resultMap="get-PubAuditLogEntity-result" parameterType="com.hzya.frame.grpU8.nxproof.pubauditlog.entity.PubAuditLogEntity">
        select isnull(max(logseq)+1,1) as logseq from PUBAUDITLOG WHERE gsdm = #{gsdm} AND kjnd = #{kjnd}
    </select>


    <!--保存 单据保存时使用 直接送审和已审核-->
    <insert id="PubAuditLogEntity_insert" parameterType="com.hzya.frame.grpU8.nxproof.pubauditlog.entity.PubAuditLogEntity">
        insert into PubAuditLog(
        <if test="billId != null and billId !='' "> BillID, </if>
        <if test="logId != null and logId !='' "> LOGID, </if>
        <if test="billname != null and billname !='' "> BILLNAME, </if>
        <if test="flowcode != null and flowcode !='' "> FLOWCODE, </if>
        <if test="flowname != null and flowname !='' "> FLOWNAME, </if>
        <if test="modname != null and modname !='' "> MODNAME, </if>
        <if test="bizname != null and bizname !='' "> BIZNAME, </if>
        <if test="nodename != null and nodename !='' "> NODENAME, </if>
        <if test="nodeseq != null and nodeseq !='' "> NODESEQ, </if>
        <if test="auditorId != null and auditorId !='' "> AUDITORID, </if>
        <if test="auditor != null and auditor !='' "> AUDITOR, </if>
        <if test="adatetime != null and adatetime !='' "> ADATETIME, </if>
        <if test="remark != null and remark !='' "> REMARK, </if>
        <if test="atype != null and atype !='' "> ATYPE, </if>
        <if test="amt != null and amt !='' "> AMT, </if>
        <if test="servdatetime != null and servdatetime !='' "> ServDateTime, </if>
        <if test="computername != null and computername !='' "> ComputerName, </if>
        <if test="gsdm != null and gsdm !='' "> GSDM, </if>
        <if test="kjnd != null and kjnd !='' "> KJND </if>
        )
        values (
        <if test="billId != null and billId !='' "> #{billId}, </if>
        <if test="logId != null and logId !='' "> #{logId}, </if>
        <if test="billname != null and billname !='' "> #{billname}, </if>
        <if test="flowcode != null and flowcode !='' "> #{flowcode}, </if>
        <if test="flowname != null and flowname !='' "> #{flowname}, </if>
        <if test="modname != null and modname !='' "> #{modname}, </if>
        <if test="bizname != null and bizname !='' "> #{bizname}, </if>
        <if test="nodename != null and nodename !='' "> #{nodename}, </if>
        <if test="nodeseq != null and nodeseq !='' "> #{nodeseq}, </if>
        <if test="auditorId != null and auditorId !='' "> #{auditorId}, </if>
        <if test="auditor != null and auditor !='' "> #{auditor}, </if>
        <if test="adatetime != null and adatetime !='' "> replace(replace(replace(CONVERT (VARCHAR, getdate(), 120),'-',''),':',''),' ',''), </if>
        <if test="remark != null and remark !='' "> #{remark}, </if>
        <if test="atype != null and atype !='' "> #{atype}, </if>
        <if test="amt != null and amt !='' "> #{amt}, </if>
        <if test="servdatetime != null and servdatetime !='' "> CONVERT (VARCHAR, getdate(), 120), </if>
        <if test="computername != null and computername !='' "> #{computername}, </if>
        <if test="gsdm != null and gsdm !='' "> #{gsdm}, </if>
        <if test="kjnd != null and kjnd !='' "> #{kjnd} </if>
        )
    </insert>

    <!--删除 单据删除时使用-->
    <delete id="PubAuditLogEntity_delete" parameterType="com.hzya.frame.grpU8.nxproof.pubauditlog.entity.PubAuditLogEntity">
        DELETE
        FROM
            PubAuditLog
        WHERE
            GSDM = #{gsdm}
          AND KJND = #{kjnd}
          AND BillID = #{billId}
    </delete>

</mapper>
