<?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.dhcc.finance.main.dao.CwGlVoucherMapper">
    <resultMap id="BaseResultMap" type="com.dhcc.finance.main.domain.CwGlVoucher">
        <id column="PK_VOUCHER" jdbcType="VARCHAR" property="pkVoucher"/>
        <result column="PK_GLORGBOOK" jdbcType="VARCHAR" property="pkGlorgbook"/>
        <result column="FQMJBH" jdbcType="VARCHAR" property="fqmjbh"/>
        <result column="PK_VOUCHERTY" jdbcType="VARCHAR" property="pkVoucherty"/>
        <result column="PK_SYSTEM" jdbcType="VARCHAR" property="pkSystem"/>
        <result column="TRADECODE" jdbcType="VARCHAR" property="tradecode"/>
        <result column="VOUCHERTYPE" jdbcType="VARCHAR" property="vouchertype"/>
        <result column="ABSTRACTS" jdbcType="VARCHAR" property="abstracts"/>
        <result column="PK_PREPARED" jdbcType="VARCHAR" property="pkPrepared"/>
        <result column="PREPAREDATE" jdbcType="DATE" property="preparedate"/>
        <result column="ISAUDIT" jdbcType="VARCHAR" property="isaudit"/>
        <result column="PK_AUDIT" jdbcType="VARCHAR" property="pkAudit"/>
        <result column="AUDITDATE" jdbcType="DATE" property="auditdate"/>
        <result column="ISSIGN" jdbcType="VARCHAR" property="issign"/>
        <result column="PK_SIGN" jdbcType="VARCHAR" property="pkSign"/>
        <result column="SIGNDATE" jdbcType="DATE" property="signdate"/>
        <result column="VOUCHERNO" jdbcType="VARCHAR" property="voucherno"/>
        <result column="ISMODIFY" jdbcType="VARCHAR" property="ismodify"/>
        <result column="YEAR" jdbcType="VARCHAR" property="year"/>
        <result column="PERIOD" jdbcType="VARCHAR" property="period"/>
        <result column="TEMPSAVE" jdbcType="VARCHAR" property="tempsave"/>
        <result column="TOTALDEBIT" jdbcType="DECIMAL" property="totaldebit"/>
        <result column="TOTALCREDIT" jdbcType="DECIMAL" property="totalcredit"/>
        <result column="OCC_DATE" jdbcType="TIMESTAMP" property="occDate"/>
        <result column="USE_STATE" jdbcType="VARCHAR" property="useState"/>
        <result column="CREATE_USER" jdbcType="VARCHAR" property="createUser"/>
        <result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="UPDATE_USER" jdbcType="VARCHAR" property="updateUser"/>
        <result column="UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="REMARK" jdbcType="VARCHAR" property="remark"/>
    </resultMap>
    <resultMap id="BaseResultMap1" type="com.dhcc.finance.main.model.CwGlVoucherAndName">
        <id column="PK_VOUCHER" jdbcType="VARCHAR" property="pkVoucher"/>
        <result column="PK_GLORGBOOK" jdbcType="VARCHAR" property="pkGlorgbook"/>
        <result column="CODE" jdbcType="VARCHAR" property="code"/>
        <result column="NAME" jdbcType="VARCHAR" property="name"/>
        <result column="FQMJBH" jdbcType="VARCHAR" property="fqmjbh"/>
        <result column="PK_VOUCHERTY" jdbcType="VARCHAR" property="pkVoucherty"/>
        <result column="PK_SYSTEM" jdbcType="VARCHAR" property="pkSystem"/>
        <result column="TRADECODE" jdbcType="VARCHAR" property="tradecode"/>
        <result column="VOUCHERTYPE" jdbcType="VARCHAR" property="vouchertype"/>
        <result column="ABSTRACTS" jdbcType="VARCHAR" property="abstracts"/>
        <result column="PK_PREPARED" jdbcType="VARCHAR" property="pkPrepared"/>
        <result column="PK_PREPAREDUSER" jdbcType="VARCHAR" property="pkPreparedUser"/>
        <result column="PREPAREDATE" jdbcType="DATE" property="preparedate"/>
        <result column="ISAUDIT" jdbcType="VARCHAR" property="isaudit"/>
        <result column="PK_AUDIT" jdbcType="VARCHAR" property="pkAudit"/>
        <result column="PK_AUDITUSER" jdbcType="VARCHAR" property="pkAuditUser"/>
        <result column="AUDITDATE" jdbcType="DATE" property="auditdate"/>
        <result column="ISSIGN" jdbcType="VARCHAR" property="issign"/>
        <result column="PK_SIGN" jdbcType="VARCHAR" property="pkSign"/>
        <result column="PK_SIGNUSER" jdbcType="VARCHAR" property="pkSignUser"/>
        <result column="SIGNDATE" jdbcType="DATE" property="signdate"/>
        <result column="VOUCHERNO" jdbcType="VARCHAR" property="voucherno"/>
        <result column="ISMODIFY" jdbcType="VARCHAR" property="ismodify"/>
        <result column="YEAR" jdbcType="VARCHAR" property="year"/>
        <result column="PERIOD" jdbcType="VARCHAR" property="period"/>
        <result column="TEMPSAVE" jdbcType="VARCHAR" property="tempsave"/>
        <result column="TOTALDEBIT" jdbcType="DECIMAL" property="totaldebit"/>
        <result column="TOTALCREDIT" jdbcType="DECIMAL" property="totalcredit"/>
        <result column="OCC_DATE" jdbcType="TIMESTAMP" property="occDate"/>
        <result column="USE_STATE" jdbcType="VARCHAR" property="useState"/>
        <result column="CREATE_USER" jdbcType="VARCHAR" property="createUser"/>
        <result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="UPDATE_USER" jdbcType="VARCHAR" property="updateUser"/>
        <result column="UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="REMARK" jdbcType="VARCHAR" property="remark"/>
    </resultMap>
    <resultMap id="BaseResultMap3" type="com.dhcc.finance.main.model.CwGlVoucherWeb">
        <id column="PK_VOUCHER" jdbcType="VARCHAR" property="pkVoucher"/>
        <result column="PK_GLORGBOOK" jdbcType="VARCHAR" property="pkGlorgbook"/>
        <result column="NAME" jdbcType="VARCHAR" property="name"/>
        <result column="FQMJBH" jdbcType="VARCHAR" property="fqmjbh"/>
        <result column="PK_VOUCHERTY" jdbcType="VARCHAR" property="pkVoucherty"/>
        <result column="PK_SYSTEM" jdbcType="VARCHAR" property="pkSystem"/>
        <result column="TRADECODE" jdbcType="VARCHAR" property="tradecode"/>
        <result column="VOUCHERTYPE" jdbcType="VARCHAR" property="vouchertype"/>
        <result column="ABSTRACTS" jdbcType="VARCHAR" property="abstracts"/>
        <result column="PK_PREPARED" jdbcType="VARCHAR" property="pkPrepared"/>
        <result column="PREPAREDATE" jdbcType="DATE" property="preparedate"/>
        <result column="ISAUDIT" jdbcType="VARCHAR" property="isaudit"/>
        <result column="PK_AUDIT" jdbcType="VARCHAR" property="pkAudit"/>
        <result column="AUDITDATE" jdbcType="DATE" property="auditdate"/>
        <result column="ISSIGN" jdbcType="VARCHAR" property="issign"/>
        <result column="PK_SIGN" jdbcType="VARCHAR" property="pkSign"/>
        <result column="SIGNDATE" jdbcType="DATE" property="signdate"/>
        <result column="VOUCHERNO" jdbcType="VARCHAR" property="voucherno"/>
        <result column="ISMODIFY" jdbcType="VARCHAR" property="ismodify"/>
        <result column="YEAR" jdbcType="VARCHAR" property="year"/>
        <result column="PERIOD" jdbcType="VARCHAR" property="period"/>
        <result column="TEMPSAVE" jdbcType="VARCHAR" property="tempsave"/>
        <result column="TOTALDEBIT" jdbcType="DECIMAL" property="totaldebit"/>
        <result column="TOTALCREDIT" jdbcType="DECIMAL" property="totalcredit"/>
        <result column="OCC_DATE" jdbcType="TIMESTAMP" property="occDate"/>
        <result column="USE_STATE" jdbcType="VARCHAR" property="useState"/>
        <result column="CREATE_USER" jdbcType="VARCHAR" property="createUser"/>
        <result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="UPDATE_USER" jdbcType="VARCHAR" property="updateUser"/>
        <result column="UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="REMARK" jdbcType="VARCHAR" property="remark"/>
        <collection property="cwGlDetailList" resultMap="com.dhcc.finance.main.dao.CwGlDetailMapper.BaseResultMap2"/>
    </resultMap>
    <resultMap id="BaseResultMap4" type="com.dhcc.finance.main.domain.CwGlDetail">
        <id column="PK_DETAIL" jdbcType="VARCHAR" property="pkDetail"/>
        <result column="PK_VOUCHER" jdbcType="VARCHAR" property="pkVoucher"/>
        <result column="DETAILINDEX" jdbcType="VARCHAR" property="detailindex"/>
        <result column="ABSTRACTS" jdbcType="VARCHAR" property="abstracts"/>
        <result column="PK_ACCSUBJ" jdbcType="VARCHAR" property="pkAccsubj"/>
        <result column="SUBJCODE" jdbcType="VARCHAR" property="subjcode"/>
        <result column="SUBJNAME" jdbcType="VARCHAR" property="subjname"/>
        <result column="PK_CURRTYPE" jdbcType="VARCHAR" property="pkCurrtype"/>
        <result column="DEBITAMOUNT" jdbcType="DECIMAL" property="debitamount"/>
        <result column="CREDITAMOUNT" jdbcType="DECIMAL" property="creditamount"/>
        <result column="LOCALDEBITAMOUNT" jdbcType="DECIMAL" property="localdebitamount"/>
        <result column="LOCALCREDITAMOUNT" jdbcType="DECIMAL" property="localcreditamount"/>
        <result column="ASSID" jdbcType="VARCHAR" property="assid"/>
        <result column="QTY" jdbcType="VARCHAR" property="qty"/>
        <result column="USE_STATE" jdbcType="VARCHAR" property="useState"/>
        <result column="CREATE_USER" jdbcType="VARCHAR" property="createUser"/>
        <result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="UPDATE_USER" jdbcType="VARCHAR" property="updateUser"/>
        <result column="UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="REMARK" jdbcType="VARCHAR" property="remark"/>
    </resultMap>
    <sql id="Example_Where_Clause">
        <where>
            <foreach collection="oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
                                             separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Update_By_Example_Where_Clause">
        <where>
            <foreach collection="example.oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
                                             separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Base_Column_List">
        PK_VOUCHER, PK_GLORGBOOK, FQMJBH, PK_VOUCHERTY, PK_SYSTEM, TRADECODE, VOUCHERTYPE,
    ABSTRACTS, PK_PREPARED, PREPAREDATE, ISAUDIT, PK_AUDIT, AUDITDATE, ISSIGN, PK_SIGN, 
    SIGNDATE, VOUCHERNO, ISMODIFY, YEAR, PERIOD, TEMPSAVE, TOTALDEBIT, TOTALCREDIT, OCC_DATE, 
    USE_STATE, CREATE_USER, CREATE_TIME, UPDATE_USER, UPDATE_TIME, REMARK
    </sql>
    <select id="selectByExample" parameterType="com.dhcc.finance.main.domain.CwGlVoucherExample"
            resultMap="BaseResultMap">
        select
        <if test="distinct">
            distinct
        </if>
        <include refid="Base_Column_List"/>
        from cw_gl_voucher
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
    </select>
    <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from cw_gl_voucher
        where PK_VOUCHER = #{pkVoucher,jdbcType=VARCHAR}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
        delete
        from cw_gl_voucher
        where PK_VOUCHER = #{pkVoucher,jdbcType=VARCHAR}
    </delete>
    <delete id="deleteByExample" parameterType="com.dhcc.finance.main.domain.CwGlVoucherExample">
        delete from cw_gl_voucher
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </delete>
    <insert id="insert" parameterType="com.dhcc.finance.main.domain.CwGlVoucher">
        insert into cw_gl_voucher (PK_VOUCHER, PK_GLORGBOOK, FQMJBH,
                                   PK_VOUCHERTY, PK_SYSTEM, TRADECODE,
                                   VOUCHERTYPE, ABSTRACTS, PK_PREPARED,
                                   PREPAREDATE, ISAUDIT, PK_AUDIT,
                                   AUDITDATE, ISSIGN, PK_SIGN,
                                   SIGNDATE, VOUCHERNO, ISMODIFY,
                                   YEAR, PERIOD, TEMPSAVE,
                                   TOTALDEBIT, TOTALCREDIT, OCC_DATE,
                                   USE_STATE, CREATE_USER, CREATE_TIME,
                                   UPDATE_USER, UPDATE_TIME, REMARK)
        values (#{pkVoucher,jdbcType=VARCHAR}, #{pkGlorgbook,jdbcType=VARCHAR}, #{fqmjbh,jdbcType=VARCHAR},
                #{pkVoucherty,jdbcType=VARCHAR}, #{pkSystem,jdbcType=VARCHAR}, #{tradecode,jdbcType=VARCHAR},
                #{vouchertype,jdbcType=VARCHAR}, #{abstracts,jdbcType=VARCHAR}, #{pkPrepared,jdbcType=VARCHAR},
                #{preparedate,jdbcType=DATE}, #{isaudit,jdbcType=VARCHAR}, #{pkAudit,jdbcType=VARCHAR},
                #{auditdate,jdbcType=DATE}, #{issign,jdbcType=VARCHAR}, #{pkSign,jdbcType=VARCHAR},
                #{signdate,jdbcType=DATE}, #{voucherno,jdbcType=VARCHAR}, #{ismodify,jdbcType=VARCHAR},
                #{year,jdbcType=VARCHAR}, #{period,jdbcType=VARCHAR}, #{tempsave,jdbcType=VARCHAR},
                #{totaldebit,jdbcType=DECIMAL}, #{totalcredit,jdbcType=DECIMAL}, #{occDate,jdbcType=TIMESTAMP},
                #{useState,jdbcType=VARCHAR}, #{createUser,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
                #{updateUser,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{remark,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective" parameterType="com.dhcc.finance.main.domain.CwGlVoucher">
        insert into cw_gl_voucher
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="pkVoucher != null">
                PK_VOUCHER,
            </if>
            <if test="pkGlorgbook != null">
                PK_GLORGBOOK,
            </if>
            <if test="fqmjbh != null">
                FQMJBH,
            </if>
            <if test="pkVoucherty != null">
                PK_VOUCHERTY,
            </if>
            <if test="pkSystem != null">
                PK_SYSTEM,
            </if>
            <if test="tradecode != null">
                TRADECODE,
            </if>
            <if test="vouchertype != null">
                VOUCHERTYPE,
            </if>
            <if test="abstracts != null">
                ABSTRACTS,
            </if>
            <if test="pkPrepared != null">
                PK_PREPARED,
            </if>
            <if test="preparedate != null">
                PREPAREDATE,
            </if>
            <if test="isaudit != null">
                ISAUDIT,
            </if>
            <if test="pkAudit != null">
                PK_AUDIT,
            </if>
            <if test="auditdate != null">
                AUDITDATE,
            </if>
            <if test="issign != null">
                ISSIGN,
            </if>
            <if test="pkSign != null">
                PK_SIGN,
            </if>
            <if test="signdate != null">
                SIGNDATE,
            </if>
            <if test="voucherno != null">
                VOUCHERNO,
            </if>
            <if test="ismodify != null">
                ISMODIFY,
            </if>
            <if test="year != null">
                YEAR,
            </if>
            <if test="period != null">
                PERIOD,
            </if>
            <if test="tempsave != null">
                TEMPSAVE,
            </if>
            <if test="totaldebit != null">
                TOTALDEBIT,
            </if>
            <if test="totalcredit != null">
                TOTALCREDIT,
            </if>
            <if test="occDate != null">
                OCC_DATE,
            </if>
            <if test="useState != null">
                USE_STATE,
            </if>
            <if test="createUser != null">
                CREATE_USER,
            </if>
            <if test="createTime != null">
                CREATE_TIME,
            </if>
            <if test="updateUser != null">
                UPDATE_USER,
            </if>
            <if test="updateTime != null">
                UPDATE_TIME,
            </if>
            <if test="remark != null">
                REMARK,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="pkVoucher != null">
                #{pkVoucher,jdbcType=VARCHAR},
            </if>
            <if test="pkGlorgbook != null">
                #{pkGlorgbook,jdbcType=VARCHAR},
            </if>
            <if test="fqmjbh != null">
                #{fqmjbh,jdbcType=VARCHAR},
            </if>
            <if test="pkVoucherty != null">
                #{pkVoucherty,jdbcType=VARCHAR},
            </if>
            <if test="pkSystem != null">
                #{pkSystem,jdbcType=VARCHAR},
            </if>
            <if test="tradecode != null">
                #{tradecode,jdbcType=VARCHAR},
            </if>
            <if test="vouchertype != null">
                #{vouchertype,jdbcType=VARCHAR},
            </if>
            <if test="abstracts != null">
                #{abstracts,jdbcType=VARCHAR},
            </if>
            <if test="pkPrepared != null">
                #{pkPrepared,jdbcType=VARCHAR},
            </if>
            <if test="preparedate != null">
                #{preparedate,jdbcType=DATE},
            </if>
            <if test="isaudit != null">
                #{isaudit,jdbcType=VARCHAR},
            </if>
            <if test="pkAudit != null">
                #{pkAudit,jdbcType=VARCHAR},
            </if>
            <if test="auditdate != null">
                #{auditdate,jdbcType=DATE},
            </if>
            <if test="issign != null">
                #{issign,jdbcType=VARCHAR},
            </if>
            <if test="pkSign != null">
                #{pkSign,jdbcType=VARCHAR},
            </if>
            <if test="signdate != null">
                #{signdate,jdbcType=DATE},
            </if>
            <if test="voucherno != null">
                #{voucherno,jdbcType=VARCHAR},
            </if>
            <if test="ismodify != null">
                #{ismodify,jdbcType=VARCHAR},
            </if>
            <if test="year != null">
                #{year,jdbcType=VARCHAR},
            </if>
            <if test="period != null">
                #{period,jdbcType=VARCHAR},
            </if>
            <if test="tempsave != null">
                #{tempsave,jdbcType=VARCHAR},
            </if>
            <if test="totaldebit != null">
                #{totaldebit,jdbcType=DECIMAL},
            </if>
            <if test="totalcredit != null">
                #{totalcredit,jdbcType=DECIMAL},
            </if>
            <if test="occDate != null">
                #{occDate,jdbcType=TIMESTAMP},
            </if>
            <if test="useState != null">
                #{useState,jdbcType=VARCHAR},
            </if>
            <if test="createUser != null">
                #{createUser,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateUser != null">
                #{updateUser,jdbcType=VARCHAR},
            </if>
            <if test="updateTime != null">
                #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="remark != null">
                #{remark,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
    <select id="countByExample" parameterType="com.dhcc.finance.main.domain.CwGlVoucherExample"
            resultType="java.lang.Long">
        select count(*) from cw_gl_voucher
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </select>
    <update id="updateByExampleSelective" parameterType="map">
        update cw_gl_voucher
        <set>
            <if test="record.pkVoucher != null">
                PK_VOUCHER = #{record.pkVoucher,jdbcType=VARCHAR},
            </if>
            <if test="record.pkGlorgbook != null">
                PK_GLORGBOOK = #{record.pkGlorgbook,jdbcType=VARCHAR},
            </if>
            <if test="record.fqmjbh != null">
                FQMJBH = #{record.fqmjbh,jdbcType=VARCHAR},
            </if>
            <if test="record.pkVoucherty != null">
                PK_VOUCHERTY = #{record.pkVoucherty,jdbcType=VARCHAR},
            </if>
            <if test="record.pkSystem != null">
                PK_SYSTEM = #{record.pkSystem,jdbcType=VARCHAR},
            </if>
            <if test="record.tradecode != null">
                TRADECODE = #{record.tradecode,jdbcType=VARCHAR},
            </if>
            <if test="record.vouchertype != null">
                VOUCHERTYPE = #{record.vouchertype,jdbcType=VARCHAR},
            </if>
            <if test="record.abstracts != null">
                ABSTRACTS = #{record.abstracts,jdbcType=VARCHAR},
            </if>
            <if test="record.pkPrepared != null">
                PK_PREPARED = #{record.pkPrepared,jdbcType=VARCHAR},
            </if>
            <if test="record.preparedate != null">
                PREPAREDATE = #{record.preparedate,jdbcType=DATE},
            </if>
            <if test="record.isaudit != null">
                ISAUDIT = #{record.isaudit,jdbcType=VARCHAR},
            </if>
            <if test="record.pkAudit != null">
                PK_AUDIT = #{record.pkAudit,jdbcType=VARCHAR},
            </if>
            <if test="record.auditdate != null">
                AUDITDATE = #{record.auditdate,jdbcType=DATE},
            </if>
            <if test="record.issign != null">
                ISSIGN = #{record.issign,jdbcType=VARCHAR},
            </if>
            <if test="record.pkSign != null">
                PK_SIGN = #{record.pkSign,jdbcType=VARCHAR},
            </if>
            <if test="record.signdate != null">
                SIGNDATE = #{record.signdate,jdbcType=DATE},
            </if>
            <if test="record.voucherno != null">
                VOUCHERNO = #{record.voucherno,jdbcType=VARCHAR},
            </if>
            <if test="record.ismodify != null">
                ISMODIFY = #{record.ismodify,jdbcType=VARCHAR},
            </if>
            <if test="record.year != null">
                YEAR = #{record.year,jdbcType=VARCHAR},
            </if>
            <if test="record.period != null">
                PERIOD = #{record.period,jdbcType=VARCHAR},
            </if>
            <if test="record.tempsave != null">
                TEMPSAVE = #{record.tempsave,jdbcType=VARCHAR},
            </if>
            <if test="record.totaldebit != null">
                TOTALDEBIT = #{record.totaldebit,jdbcType=DECIMAL},
            </if>
            <if test="record.totalcredit != null">
                TOTALCREDIT = #{record.totalcredit,jdbcType=DECIMAL},
            </if>
            <if test="record.occDate != null">
                OCC_DATE = #{record.occDate,jdbcType=TIMESTAMP},
            </if>
            <if test="record.useState != null">
                USE_STATE = #{record.useState,jdbcType=VARCHAR},
            </if>
            <if test="record.createUser != null">
                CREATE_USER = #{record.createUser,jdbcType=VARCHAR},
            </if>
            <if test="record.createTime != null">
                CREATE_TIME = #{record.createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="record.updateUser != null">
                UPDATE_USER = #{record.updateUser,jdbcType=VARCHAR},
            </if>
            <if test="record.updateTime != null">
                UPDATE_TIME = #{record.updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="record.remark != null">
                REMARK = #{record.remark,jdbcType=VARCHAR},
            </if>
        </set>
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByExample" parameterType="map">
        update cw_gl_voucher
        set PK_VOUCHER = #{record.pkVoucher,jdbcType=VARCHAR},
        PK_GLORGBOOK = #{record.pkGlorgbook,jdbcType=VARCHAR},
        FQMJBH = #{record.fqmjbh,jdbcType=VARCHAR},
        PK_VOUCHERTY = #{record.pkVoucherty,jdbcType=VARCHAR},
        PK_SYSTEM = #{record.pkSystem,jdbcType=VARCHAR},
        TRADECODE = #{record.tradecode,jdbcType=VARCHAR},
        VOUCHERTYPE = #{record.vouchertype,jdbcType=VARCHAR},
        ABSTRACTS = #{record.abstracts,jdbcType=VARCHAR},
        PK_PREPARED = #{record.pkPrepared,jdbcType=VARCHAR},
        PREPAREDATE = #{record.preparedate,jdbcType=DATE},
        ISAUDIT = #{record.isaudit,jdbcType=VARCHAR},
        PK_AUDIT = #{record.pkAudit,jdbcType=VARCHAR},
        AUDITDATE = #{record.auditdate,jdbcType=DATE},
        ISSIGN = #{record.issign,jdbcType=VARCHAR},
        PK_SIGN = #{record.pkSign,jdbcType=VARCHAR},
        SIGNDATE = #{record.signdate,jdbcType=DATE},
        VOUCHERNO = #{record.voucherno,jdbcType=VARCHAR},
        ISMODIFY = #{record.ismodify,jdbcType=VARCHAR},
        YEAR = #{record.year,jdbcType=VARCHAR},
        PERIOD = #{record.period,jdbcType=VARCHAR},
        TEMPSAVE = #{record.tempsave,jdbcType=VARCHAR},
        TOTALDEBIT = #{record.totaldebit,jdbcType=DECIMAL},
        TOTALCREDIT = #{record.totalcredit,jdbcType=DECIMAL},
        OCC_DATE = #{record.occDate,jdbcType=TIMESTAMP},
        USE_STATE = #{record.useState,jdbcType=VARCHAR},
        CREATE_USER = #{record.createUser,jdbcType=VARCHAR},
        CREATE_TIME = #{record.createTime,jdbcType=TIMESTAMP},
        UPDATE_USER = #{record.updateUser,jdbcType=VARCHAR},
        UPDATE_TIME = #{record.updateTime,jdbcType=TIMESTAMP},
        REMARK = #{record.remark,jdbcType=VARCHAR}
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.dhcc.finance.main.domain.CwGlVoucher">
        update cw_gl_voucher
        <set>
            <if test="pkGlorgbook != null">
                PK_GLORGBOOK = #{pkGlorgbook,jdbcType=VARCHAR},
            </if>
            <if test="fqmjbh != null">
                FQMJBH = #{fqmjbh,jdbcType=VARCHAR},
            </if>
            <if test="pkVoucherty != null">
                PK_VOUCHERTY = #{pkVoucherty,jdbcType=VARCHAR},
            </if>
            <if test="pkSystem != null">
                PK_SYSTEM = #{pkSystem,jdbcType=VARCHAR},
            </if>
            <if test="tradecode != null">
                TRADECODE = #{tradecode,jdbcType=VARCHAR},
            </if>
            <if test="vouchertype != null">
                VOUCHERTYPE = #{vouchertype,jdbcType=VARCHAR},
            </if>
            <if test="abstracts != null">
                ABSTRACTS = #{abstracts,jdbcType=VARCHAR},
            </if>
            <if test="pkPrepared != null">
                PK_PREPARED = #{pkPrepared,jdbcType=VARCHAR},
            </if>
            <if test="preparedate != null">
                PREPAREDATE = #{preparedate,jdbcType=DATE},
            </if>
            <if test="isaudit != null">
                ISAUDIT = #{isaudit,jdbcType=VARCHAR},
            </if>
            <if test="pkAudit != null">
                PK_AUDIT = #{pkAudit,jdbcType=VARCHAR},
            </if>
            <if test="auditdate != null">
                AUDITDATE = #{auditdate,jdbcType=DATE},
            </if>
            <if test="issign != null">
                ISSIGN = #{issign,jdbcType=VARCHAR},
            </if>
            <if test="pkSign != null">
                PK_SIGN = #{pkSign,jdbcType=VARCHAR},
            </if>
            <if test="signdate != null">
                SIGNDATE = #{signdate,jdbcType=DATE},
            </if>
            <if test="voucherno != null">
                VOUCHERNO = #{voucherno,jdbcType=VARCHAR},
            </if>
            <if test="ismodify != null">
                ISMODIFY = #{ismodify,jdbcType=VARCHAR},
            </if>
            <if test="year != null">
                YEAR = #{year,jdbcType=VARCHAR},
            </if>
            <if test="period != null">
                PERIOD = #{period,jdbcType=VARCHAR},
            </if>
            <if test="tempsave != null">
                TEMPSAVE = #{tempsave,jdbcType=VARCHAR},
            </if>
            <if test="totaldebit != null">
                TOTALDEBIT = #{totaldebit,jdbcType=DECIMAL},
            </if>
            <if test="totalcredit != null">
                TOTALCREDIT = #{totalcredit,jdbcType=DECIMAL},
            </if>
            <if test="occDate != null">
                OCC_DATE = #{occDate,jdbcType=TIMESTAMP},
            </if>
            <if test="useState != null">
                USE_STATE = #{useState,jdbcType=VARCHAR},
            </if>
            <if test="createUser != null">
                CREATE_USER = #{createUser,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateUser != null">
                UPDATE_USER = #{updateUser,jdbcType=VARCHAR},
            </if>
            <if test="updateTime != null">
                UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="remark != null">
                REMARK = #{remark,jdbcType=VARCHAR},
            </if>
        </set>
        where PK_VOUCHER = #{pkVoucher,jdbcType=VARCHAR}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.dhcc.finance.main.domain.CwGlVoucher">
        update cw_gl_voucher
        set PK_GLORGBOOK = #{pkGlorgbook,jdbcType=VARCHAR},
            FQMJBH       = #{fqmjbh,jdbcType=VARCHAR},
            PK_VOUCHERTY = #{pkVoucherty,jdbcType=VARCHAR},
            PK_SYSTEM    = #{pkSystem,jdbcType=VARCHAR},
            TRADECODE    = #{tradecode,jdbcType=VARCHAR},
            VOUCHERTYPE  = #{vouchertype,jdbcType=VARCHAR},
            ABSTRACTS    = #{abstracts,jdbcType=VARCHAR},
            PK_PREPARED  = #{pkPrepared,jdbcType=VARCHAR},
            PREPAREDATE  = #{preparedate,jdbcType=DATE},
            ISAUDIT      = #{isaudit,jdbcType=VARCHAR},
            PK_AUDIT     = #{pkAudit,jdbcType=VARCHAR},
            AUDITDATE    = #{auditdate,jdbcType=DATE},
            ISSIGN       = #{issign,jdbcType=VARCHAR},
            PK_SIGN      = #{pkSign,jdbcType=VARCHAR},
            SIGNDATE     = #{signdate,jdbcType=DATE},
            VOUCHERNO    = #{voucherno,jdbcType=VARCHAR},
            ISMODIFY     = #{ismodify,jdbcType=VARCHAR},
            YEAR         = #{year,jdbcType=VARCHAR},
            PERIOD       = #{period,jdbcType=VARCHAR},
            TEMPSAVE     = #{tempsave,jdbcType=VARCHAR},
            TOTALDEBIT   = #{totaldebit,jdbcType=DECIMAL},
            TOTALCREDIT  = #{totalcredit,jdbcType=DECIMAL},
            OCC_DATE     = #{occDate,jdbcType=TIMESTAMP},
            USE_STATE    = #{useState,jdbcType=VARCHAR},
            CREATE_USER  = #{createUser,jdbcType=VARCHAR},
            CREATE_TIME  = #{createTime,jdbcType=TIMESTAMP},
            UPDATE_USER  = #{updateUser,jdbcType=VARCHAR},
            UPDATE_TIME  = #{updateTime,jdbcType=TIMESTAMP},
            REMARK       = #{remark,jdbcType=VARCHAR}
        where PK_VOUCHER = #{pkVoucher,jdbcType=VARCHAR}
    </update>
    <sql id="Zdy_Column_List1">
        a.PK_VOUCHER, a.PK_GLORGBOOK, a.FQMJBH,a.PK_VOUCHERTY, a.PK_SYSTEM, a.VOUCHERTYPE,a.ABSTRACTS, a.PK_PREPARED, a.PREPAREDATE,
    a.ISAUDIT, a.PK_AUDIT, a.AUDITDATE, a.ISSIGN, a.PK_SIGN, a.SIGNDATE, a.VOUCHERNO, a.ISMODIFY, a.YEAR, 
    a.PERIOD, a.TEMPSAVE, a.TOTALDEBIT, a.TOTALCREDIT, a.OCC_DATE,a.USE_STATE, a.CREATE_USER, a.CREATE_TIME, a.UPDATE_USER, a.UPDATE_TIME, a.REMARK
    </sql>
    <sql id="Zdy_Column_List2">
        b.PK_DETAIL, b.PK_VOUCHER, b.DETAILINDEX, b.ABSTRACTS, b.PK_ACCSUBJ, b.SUBJCODE, b.SUBJNAME, b.PK_CURRTYPE,
    b.DEBITAMOUNT, b.CREDITAMOUNT, b.LOCALDEBITAMOUNT, b.LOCALCREDITAMOUNT, b.ASSID, b.QTY, 
    b.USE_STATE, b.CREATE_USER, b.CREATE_TIME, b.UPDATE_USER, b.UPDATE_TIME, b.REMARK
    </sql>
    <sql id="Zdy_Column_List3">
        c.PK_FREEVALUE, c.ASSID, c.ASSINDEX, c.CHECKTYPE, c.CHECKVALUE, c.VALUECODE, c.VALUENAME,
    c.USE_STATE, c.CREATE_USER, c.CREATE_TIME, c.UPDATE_USER, c.UPDATE_TIME, c.REMARK
    </sql>
    <!-- 查询制单详情dml -->
    <select id="selectOrderMakingDetil" parameterType="java.lang.String" resultMap="BaseResultMap3">
        select
        <include refid="Zdy_Column_List1"/>,
        <include refid="Zdy_Column_List2"/>,
        <include refid="Zdy_Column_List3"/>
        from cw_gl_voucher a
        left join CW_GL_DETAIL b on a.PK_VOUCHER=b.PK_VOUCHER and b.USE_STATE=#{useState,jdbcType=VARCHAR}
        left join CW_GL_FREEVALUE c on b.ASSID=c.ASSID and c.USE_STATE='1'
        where a.PK_VOUCHER=#{pkVoucher,jdbcType=VARCHAR} and a.USE_STATE=#{useState,jdbcType=VARCHAR}
        order by a.PREPAREDATE desc, a.CREATE_TIME desc

    </select>
    <!--        查询审核信息 -->
    <select id="selectForAuditByLike" parameterType="com.dhcc.finance.main.model.CwGlVoucherAndLike"
            resultMap="BaseResultMap1">
        select PK_VOUCHER,PK_GLORGBOOK,
        (select name from CW_BD_GLORGBOOK b where b.PK_GLORGBOOK=temp.PK_GLORGBOOK) as NAME,
        FQMJBH,PK_VOUCHERTY, PK_SYSTEM, VOUCHERTYPE,ABSTRACTS,PK_PREPARED,
        (select USER_NAME from sys_user_info b where b.USER_ID = temp.PK_PREPARED ) as PK_PREPAREDUSER,
        PREPAREDATE,
        ISAUDIT, PK_AUDIT,
        (select USER_NAME from sys_user_info b where b.USER_ID = temp.PK_AUDIT ) as PK_AUDITUSER,
        AUDITDATE, ISSIGN, PK_SIGN,
        (select USER_NAME from sys_user_info b where b.USER_ID = temp.PK_SIGN ) as PK_SIGNUSER,
        SIGNDATE, VOUCHERNO, ISMODIFY, YEAR,
        PERIOD, TEMPSAVE, TOTALDEBIT, TOTALCREDIT, OCC_DATE,USE_STATE, CREATE_USER, CREATE_TIME, UPDATE_USER,
        UPDATE_TIME, REMARK
        from CW_GL_VOUCHER temp
        where temp.USE_STATE='1' and temp.VOUCHERTYPE ='1'
        <if test="pkGlorgbook !=null">
            and temp.PK_GLORGBOOK = #{pkGlorgbook,jdbcType=VARCHAR}
        </if>
        <if test="fqmjbh !=null">
            and temp.FQMJBH = #{fqmjbh,jdbcType=VARCHAR}
        </if>
        <if test="period !=null">
            and temp.PERIOD = #{period,jdbcType=VARCHAR}
        </if>
        <if test="pkPrepared !=null">
            and temp.PK_PREPARED = #{pkPrepared,jdbcType=VARCHAR}
        </if>
        <if test="pkAudit !=null">
            and temp.PK_AUDIT = #{pkAudit,jdbcType=VARCHAR}
        </if>
        <if test="pkSystem !=null">
            and temp.PK_SYSTEM = #{pkSystem,jdbcType=VARCHAR}
        </if>
        <if test="pkSign !=null">
            and temp.PK_SIGN = #{pkSign,jdbcType=VARCHAR}
        </if>
        <if test="vouchertype !=null">
            and temp.VOUCHERTYPE = #{vouchertype,jdbcType=VARCHAR}
        </if>
        <if test="abstracts !=null">
            and temp.ABSTRACTS LIKE "%"#{abstracts,jdbcType=VARCHAR}"%"
        </if>
        <if test="vouchernoMin !=null and vouchernoMax == null">
            <![CDATA[ and temp.VOUCHERNO >= #{vouchernoMin,jdbcType=VARCHAR} + 0 ]]>
        </if>
        <if test="vouchernoMin == null and vouchernoMax !=null">
            <![CDATA[ and temp.VOUCHERNO <= #{vouchernoMax,jdbcType=VARCHAR} + 0 ]]>
        </if>
        <if test="vouchernoMin !=null and vouchernoMax!=null">
            and temp.VOUCHERNO between #{vouchernoMin,jdbcType=VARCHAR} + 0 and #{vouchernoMax,jdbcType=VARCHAR} + 0
        </if>
        <if test="preparedateMin !=null and preparedateMax == null">
            <![CDATA[ and temp.PREPAREDATE >= #{preparedateMin,jdbcType=VARCHAR} ]]>
        </if>
        <if test="preparedateMin == null and preparedateMax !=null">
            <![CDATA[ and temp.PREPAREDATE <= #{preparedateMax,jdbcType=VARCHAR} ]]>
        </if>
        <if test="preparedateMin !=null and preparedateMax !=null">
            and temp.PREPAREDATE between #{preparedateMin,jdbcType=VARCHAR} and #{preparedateMax,jdbcType=VARCHAR}
        </if>
        <if test="occDateMin !=null and occDateMax == null">
            <![CDATA[ and temp.OCC_DATE >= #{occDateMin,jdbcType=VARCHAR} ]]>
        </if>
        <if test="occDateMin == null and occDateMax !=null">
            <![CDATA[ and temp.OCC_DATE <= #{occDateMax,jdbcType=VARCHAR} ]]>
        </if>
        <if test="occDateMin !=null and occDateMax !=null">
            and temp.OCC_DATE between #{occDateMin,jdbcType=VARCHAR} and #{occDateMax,jdbcType=VARCHAR}
        </if>
        <if test="totaldebitMin !=null and totaldebitMax == null">
            <![CDATA[ and temp.TOTALDEBIT >= #{totaldebitMin,jdbcType=VARCHAR} + 0 ]]>
        </if>
        <if test="totaldebitMin == null and totaldebitMax !=null">
            <![CDATA[ and temp.TOTALDEBIT <= #{totaldebitMax,jdbcType=VARCHAR} + 0  ]]>
        </if>
        <if test="totaldebitMin !=null and totaldebitMax !=null">
            and temp.TOTALDEBIT between #{totaldebitMin,jdbcType=VARCHAR} + 0 and #{totaldebitMax,jdbcType=VARCHAR} + 0
        </if>
        order by temp.PREPAREDATE desc, temp.CREATE_TIME desc
    </select>
    <!--   查询记账信息 -->
    <select id="selectForBookingByLike" parameterType="com.dhcc.finance.main.model.CwGlVoucherAndLike"
            resultMap="BaseResultMap1">
        select PK_VOUCHER,PK_GLORGBOOK,
        (select name from CW_BD_GLORGBOOK b where b.PK_GLORGBOOK=temp.PK_GLORGBOOK) as NAME, FQMJBH,
        PK_VOUCHERTY, PK_SYSTEM, VOUCHERTYPE,ABSTRACTS,PK_PREPARED,
        (select USER_NAME from sys_user_info b where b.USER_ID = temp.PK_PREPARED ) as PK_PREPAREDUSER,
        PREPAREDATE,
        ISAUDIT, PK_AUDIT,
        (select USER_NAME from sys_user_info b where b.USER_ID = temp.PK_AUDIT ) as PK_AUDITUSER,
        AUDITDATE, ISSIGN, PK_SIGN,
        (select USER_NAME from sys_user_info b where b.USER_ID = temp.PK_SIGN ) as PK_SIGNUSER,
        SIGNDATE, VOUCHERNO, ISMODIFY, YEAR,
        PERIOD, TEMPSAVE, TOTALDEBIT, TOTALCREDIT, OCC_DATE,USE_STATE, CREATE_USER, CREATE_TIME, UPDATE_USER,
        UPDATE_TIME, REMARK
        from CW_GL_VOUCHER temp
        where temp.USE_STATE='1' and temp.VOUCHERTYPE ='2'
        <if test="pkGlorgbook !=null">
            and temp.PK_GLORGBOOK = #{pkGlorgbook,jdbcType=VARCHAR}
        </if>
        <if test="fqmjbh !=null">
            and temp.FQMJBH = #{fqmjbh,jdbcType=VARCHAR}
        </if>
        <if test="period !=null">
            and temp.PERIOD = #{period,jdbcType=VARCHAR}
        </if>
        <if test="pkPrepared !=null">
            and temp.PK_PREPARED = #{pkPrepared,jdbcType=VARCHAR}
        </if>
        <if test="pkAudit !=null">
            and temp.PK_AUDIT = #{pkAudit,jdbcType=VARCHAR}
        </if>
        <if test="pkSystem !=null">
            and temp.PK_SYSTEM = #{pkSystem,jdbcType=VARCHAR}
        </if>
        <if test="pkSign !=null">
            and temp.PK_SIGN = #{pkSign,jdbcType=VARCHAR}
        </if>
        <if test="vouchertype !=null">
            and temp.VOUCHERTYPE = #{vouchertype,jdbcType=VARCHAR}
        </if>
        <if test="abstracts !=null">
            and temp.ABSTRACTS LIKE "%"#{abstracts,jdbcType=VARCHAR}"%"
        </if>
        <if test="vouchernoMin !=null and vouchernoMax == null">
            <![CDATA[ and temp.VOUCHERNO >= #{vouchernoMin,jdbcType=VARCHAR} + 0 ]]>
        </if>
        <if test="vouchernoMin == null and vouchernoMax !=null">
            <![CDATA[ and temp.VOUCHERNO <= #{vouchernoMax,jdbcType=VARCHAR} + 0 ]]>
        </if>
        <if test="vouchernoMin !=null and vouchernoMax!=null">
            and temp.VOUCHERNO between #{vouchernoMin,jdbcType=VARCHAR} + 0 and #{vouchernoMax,jdbcType=VARCHAR} + 0
        </if>
        <if test="preparedateMin !=null and preparedateMax == null">
            <![CDATA[ and temp.PREPAREDATE >= #{preparedateMin,jdbcType=VARCHAR} ]]>
        </if>
        <if test="preparedateMin == null and preparedateMax !=null">
            <![CDATA[ and temp.PREPAREDATE <= #{preparedateMax,jdbcType=VARCHAR} ]]>
        </if>
        <if test="preparedateMin !=null and preparedateMax !=null">
            and temp.PREPAREDATE between #{preparedateMin,jdbcType=VARCHAR} and #{preparedateMax,jdbcType=VARCHAR}
        </if>
        <if test="occDateMin !=null and occDateMax == null">
            <![CDATA[ and temp.OCC_DATE >= #{occDateMin,jdbcType=VARCHAR} ]]>
        </if>
        <if test="occDateMin == null and occDateMax !=null">
            <![CDATA[ and temp.OCC_DATE <= #{occDateMax,jdbcType=VARCHAR} ]]>
        </if>
        <if test="occDateMin !=null and occDateMax !=null">
            and temp.OCC_DATE between #{occDateMin,jdbcType=VARCHAR} and #{occDateMax,jdbcType=VARCHAR}
        </if>
        <if test="totaldebitMin !=null and totaldebitMax == null">
            <![CDATA[ and temp.TOTALDEBIT >= #{totaldebitMin,jdbcType=VARCHAR} + 0 ]]>
        </if>
        <if test="totaldebitMin == null and totaldebitMax !=null">
            <![CDATA[ and temp.TOTALDEBIT <= #{totaldebitMax,jdbcType=VARCHAR} + 0  ]]>
        </if>
        <if test="totaldebitMin !=null and totaldebitMax !=null">
            and temp.TOTALDEBIT between #{totaldebitMin,jdbcType=VARCHAR} + 0 and #{totaldebitMax,jdbcType=VARCHAR} + 0
        </if>
        order by temp.AUDITDATE desc, temp.CREATE_TIME desc
    </select>
    <!-- 查询制单展示数据dml -->
    <select id="selectOrderMaking" parameterType="com.dhcc.finance.main.model.CwGlVoucherAndLike"
            resultMap="BaseResultMap1">
        select PK_VOUCHER,PK_GLORGBOOK,
        (select name from CW_BD_GLORGBOOK b where b.PK_GLORGBOOK=temp.PK_GLORGBOOK) as NAME, FQMJBH,
        PK_VOUCHERTY, PK_SYSTEM, VOUCHERTYPE,ABSTRACTS,
        (select USER_NAME from sys_user_info b where b.USER_ID = temp.PK_PREPARED ) as PK_PREPARED,
        PREPAREDATE,
        ISAUDIT, PK_AUDIT,
        AUDITDATE, ISSIGN, PK_SIGN,
        SIGNDATE, VOUCHERNO, ISMODIFY, YEAR,
        PERIOD, TEMPSAVE, TOTALDEBIT, TOTALCREDIT, OCC_DATE,USE_STATE, CREATE_USER, CREATE_TIME, UPDATE_USER,
        UPDATE_TIME, REMARK
        from CW_GL_VOUCHER temp
        where temp.USE_STATE= #{useState,jdbcType=VARCHAR}
        <if test="pkGlorgbook !=null">
            and temp.PK_GLORGBOOK = #{pkGlorgbook,jdbcType=VARCHAR}
        </if>
        <if test="fqmjbh !=null">
            and temp.FQMJBH = #{fqmjbh,jdbcType=VARCHAR}
        </if>
        <if test="period !=null">
            and temp.PERIOD = #{period,jdbcType=VARCHAR}
        </if>
        <if test="pkPrepared !=null">
            and temp.PK_PREPARED = #{pkPrepared,jdbcType=VARCHAR}
        </if>
        <if test="pkAudit !=null">
            and temp.PK_AUDIT = #{pkAudit,jdbcType=VARCHAR}
        </if>
        <if test="pkSign !=null">
            and temp.PK_SIGN = #{pkSign,jdbcType=VARCHAR}
        </if>
        <if test="pkSystem !=null">
            and temp.PK_SYSTEM = #{pkSystem,jdbcType=VARCHAR}
        </if>
        <if test="vouchertype !=null">
            and temp.VOUCHERTYPE = #{vouchertype,jdbcType=VARCHAR}
        </if>
        <if test="vouchernoMin !=null and vouchernoMax == null">
            <![CDATA[ and temp.VOUCHERNO >= #{vouchernoMin,jdbcType=VARCHAR} + 0 ]]>
        </if>
        <if test="vouchernoMin == null and vouchernoMax !=null">
            <![CDATA[ and temp.VOUCHERNO <= #{vouchernoMax,jdbcType=VARCHAR} + 0 ]]>
        </if>
        <if test="vouchernoMin !=null and vouchernoMax!=null">
            and temp.VOUCHERNO between #{vouchernoMin,jdbcType=VARCHAR} + 0 and #{vouchernoMax,jdbcType=VARCHAR} + 0
        </if>
        <if test="preparedateMin !=null and preparedateMax == null">
            <![CDATA[ and temp.PREPAREDATE >= #{preparedateMin,jdbcType=VARCHAR} ]]>
        </if>
        <if test="preparedateMin == null and preparedateMax !=null">
            <![CDATA[ and temp.PREPAREDATE <= #{preparedateMax,jdbcType=VARCHAR} ]]>
        </if>
        <if test="preparedateMin !=null and preparedateMax !=null">
            and temp.PREPAREDATE between #{preparedateMin,jdbcType=VARCHAR} and #{preparedateMax,jdbcType=VARCHAR}
        </if>
        <if test="occDateMin !=null and occDateMax == null">
            <![CDATA[ and temp.OCC_DATE >= #{occDateMin,jdbcType=VARCHAR} ]]>
        </if>
        <if test="occDateMin == null and occDateMax !=null">
            <![CDATA[ and temp.OCC_DATE <= #{occDateMax,jdbcType=VARCHAR} ]]>
        </if>
        <if test="occDateMin !=null and occDateMax !=null">
            and temp.OCC_DATE between #{occDateMin,jdbcType=VARCHAR} and #{occDateMax,jdbcType=VARCHAR}
        </if>
        <if test="totaldebitMin !=null and totaldebitMax == null">
            <![CDATA[ and temp.TOTALDEBIT >= #{totaldebitMin,jdbcType=VARCHAR} + 0 ]]>
        </if>
        <if test="totaldebitMin == null and totaldebitMax !=null">
            <![CDATA[ and temp.TOTALDEBIT <= #{totaldebitMax,jdbcType=VARCHAR} + 0  ]]>
        </if>
        <if test="totaldebitMin !=null and totaldebitMax !=null">
            and temp.TOTALDEBIT between #{totaldebitMin,jdbcType=VARCHAR} + 0 and #{totaldebitMax,jdbcType=VARCHAR} + 0
        </if>
        <if test="abstracts !=null">
            and temp.ABSTRACTS LIKE "%"#{abstracts,jdbcType=VARCHAR}"%"
        </if>
        order by temp.PREPAREDATE desc, temp.CREATE_TIME desc
    </select>
    <!--逻辑批量删除凭证信息(制单)-->
    <update id="deleteOrderMakingBatch" parameterType="java.util.Map">
        update CW_GL_VOUCHER
        set
        USE_STATE = '0',
        UPDATE_USER = #{updateUser,jdbcType=VARCHAR},
        UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP}
        where
        PK_VOUCHER in
        <foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
            #{item.pkVoucher,jdbcType=TIMESTAMP}
        </foreach>
    </update>
    <!--   获取反记账信息列表 -->
    <select id="selectForReverseBooking" parameterType="com.dhcc.finance.main.model.CwGlVoucherAndLike"
            resultMap="BaseResultMap1">
        select PK_VOUCHER,PK_GLORGBOOK,
        (select name from CW_BD_GLORGBOOK b where b.PK_GLORGBOOK=temp.PK_GLORGBOOK) as NAME, FQMJBH,
        PK_VOUCHERTY, PK_SYSTEM, VOUCHERTYPE,ABSTRACTS,PK_PREPARED,
        (select USER_NAME from sys_user_info b where b.USER_ID = temp.PK_PREPARED ) as PK_PREPAREDUSER,
        PREPAREDATE,
        ISAUDIT, PK_AUDIT,
        (select USER_NAME from sys_user_info b where b.USER_ID = temp.PK_AUDIT ) as PK_AUDITUSER,
        AUDITDATE, ISSIGN, PK_SIGN,
        (select USER_NAME from sys_user_info b where b.USER_ID = temp.PK_SIGN ) as PK_SIGNUSER,
        SIGNDATE, VOUCHERNO, ISMODIFY, YEAR,
        PERIOD, TEMPSAVE, TOTALDEBIT, TOTALCREDIT, OCC_DATE,USE_STATE, CREATE_USER, CREATE_TIME, UPDATE_USER,
        UPDATE_TIME, REMARK
        from CW_GL_VOUCHER temp
        where temp.USE_STATE='1' and temp.VOUCHERTYPE ='3'
        <if test="pkGlorgbook !=null">
            and temp.PK_GLORGBOOK = #{pkGlorgbook,jdbcType=VARCHAR}
        </if>
        <if test="fqmjbh !=null">
            and temp.FQMJBH = #{fqmjbh,jdbcType=VARCHAR}
        </if>
        <if test="period !=null">
            and temp.PERIOD = #{period,jdbcType=VARCHAR}
        </if>
        <if test="pkPrepared !=null">
            and temp.PK_PREPARED = #{pkPrepared,jdbcType=VARCHAR}
        </if>
        <if test="pkAudit !=null">
            and temp.PK_AUDIT = #{pkAudit,jdbcType=VARCHAR}
        </if>
        <if test="pkSign !=null">
            and temp.PK_SIGN = #{pkSign,jdbcType=VARCHAR}
        </if>
        <if test="pkSystem !=null">
            and temp.PK_SYSTEM = #{pkSystem,jdbcType=VARCHAR}
        </if>
        <if test="vouchertype !=null">
            and temp.VOUCHERTYPE = #{vouchertype,jdbcType=VARCHAR}
        </if>
        <if test="vouchernoMin !=null and vouchernoMax == null">
            <![CDATA[ and temp.VOUCHERNO >= #{vouchernoMin,jdbcType=VARCHAR} + 0 ]]>
        </if>
        <if test="vouchernoMin == null and vouchernoMax !=null">
            <![CDATA[ and temp.VOUCHERNO <= #{vouchernoMax,jdbcType=VARCHAR} + 0 ]]>
        </if>
        <if test="vouchernoMin !=null and vouchernoMax!=null">
            and temp.VOUCHERNO between #{vouchernoMin,jdbcType=VARCHAR} + 0 and #{vouchernoMax,jdbcType=VARCHAR} + 0
        </if>
        <if test="preparedateMin !=null and preparedateMax == null">
            <![CDATA[ and temp.PREPAREDATE >= #{preparedateMin,jdbcType=VARCHAR} ]]>
        </if>
        <if test="preparedateMin == null and preparedateMax !=null">
            <![CDATA[ and temp.PREPAREDATE <= #{preparedateMax,jdbcType=VARCHAR} ]]>
        </if>
        <if test="preparedateMin !=null and preparedateMax !=null">
            and temp.PREPAREDATE between #{preparedateMin,jdbcType=VARCHAR} and #{preparedateMax,jdbcType=VARCHAR}
        </if>
        <if test="occDateMin !=null and occDateMax == null">
            <![CDATA[ and temp.OCC_DATE >= #{occDateMin,jdbcType=VARCHAR} ]]>
        </if>
        <if test="occDateMin == null and occDateMax !=null">
            <![CDATA[ and temp.OCC_DATE <= #{occDateMax,jdbcType=VARCHAR} ]]>
        </if>
        <if test="occDateMin !=null and occDateMax !=null">
            and temp.OCC_DATE between #{occDateMin,jdbcType=VARCHAR} and #{occDateMax,jdbcType=VARCHAR}
        </if>
        <if test="totaldebitMin !=null and totaldebitMax == null">
            <![CDATA[ and temp.TOTALDEBIT >= #{totaldebitMin,jdbcType=VARCHAR} + 0 ]]>
        </if>
        <if test="totaldebitMin == null and totaldebitMax !=null">
            <![CDATA[ and temp.TOTALDEBIT <= #{totaldebitMax,jdbcType=VARCHAR} + 0  ]]>
        </if>
        <if test="totaldebitMin !=null and totaldebitMax !=null">
            and temp.TOTALDEBIT between #{totaldebitMin,jdbcType=VARCHAR} + 0 and #{totaldebitMax,jdbcType=VARCHAR} + 0
        </if>
        <if test="abstracts !=null">
            and temp.ABSTRACTS LIKE "%"#{abstracts,jdbcType=VARCHAR}"%"
        </if>
        order by temp.SIGNDATE desc, temp.CREATE_TIME desc
    </select>
    <!-- 反审核 -->
    <update id="updateByRerverseAudit" parameterType="com.dhcc.finance.main.model.CwGlVoucherForReverse">
        update cw_gl_voucher
        set VOUCHERTYPE = #{vouchertype,jdbcType=VARCHAR},
            ISAUDIT     = #{isaudit,jdbcType=VARCHAR},
            PK_AUDIT    = #{pkAudit,jdbcType=VARCHAR},
            AUDITDATE   = #{auditdate,jdbcType=DATE},
            UPDATE_USER = #{updateUser,jdbcType=VARCHAR},
            UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP}
        where PK_VOUCHER = #{pkVoucher,jdbcType=VARCHAR}
          and USE_STATE = '1'
    </update>
    <!-- 反记账 -->
    <update id="updateByRerverseBooking" parameterType="com.dhcc.finance.main.model.CwGlVoucherForReverse">
        update cw_gl_voucher
        set VOUCHERTYPE = #{vouchertype,jdbcType=VARCHAR},
            ISSIGN      = #{issign,jdbcType=VARCHAR},
            PK_SIGN     = #{pkSign,jdbcType=VARCHAR},
            SIGNDATE    = #{signdate,jdbcType=DATE},
            UPDATE_USER = #{updateUser,jdbcType=VARCHAR},
            UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP}
        where PK_VOUCHER = #{pkVoucher,jdbcType=VARCHAR}
          and USE_STATE = '1'
    </update>
    <!--统计某账套下未记账凭证记录数-->
    <select id="countNotBooking" parameterType="java.lang.String" resultType="java.lang.Long">
  <![CDATA[
        select count(*)
        from cw_gl_voucher
        where PK_GLORGBOOK = #{pkGlorgbook,jdbcType=VARCHAR}
          and PERIOD like #{lastPeriod,jdbcType=VARCHAR}"%"
          and (VOUCHERTYPE <> '3' or VOUCHERTYPE is null or VOUCHERTYPE = '')
          and USE_STATE = '1'
        ]]>
  </select>
    <select id="selectByKey" parameterType="java.lang.String" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from cw_gl_voucher
        where PK_VOUCHER = #{pkVoucher,jdbcType=VARCHAR} and USE_STATE='1'
    </select>
    <!-- 查询某账套某个期间所有凭证信息 -->
    <select id="selectForSettle" parameterType="java.lang.String" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from cw_gl_voucher
        where PK_GLORGBOOK = #{pkGlorgbook,jdbcType=VARCHAR} and PERIOD = #{period,jdbcType=VARCHAR} and USE_STATE='1'
    </select>
    <!-- 查询凭证号是否连续-->
    <select id="selectIsSeries" parameterType="java.lang.String" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from CW_GL_VOUCHER t1 where not exists(
        select 1 from CW_GL_VOUCHER t2 where t2.VOUCHERNO=t1.VOUCHERNO+1 and
        t2.PK_GLORGBOOK=#{pkGlorgbook,jdbcType=VARCHAR} and t2.PERIOD=#{period,jdbcType=VARCHAR} and USE_STATE='1'
        )
        and PK_GLORGBOOK = #{pkGlorgbook,jdbcType=VARCHAR} and PERIOD = #{period,jdbcType=VARCHAR} and USE_STATE='1'
    </select>
    <!--期初余额生成凭证信息-->
    <insert id="insertForInitbuild" parameterType="com.dhcc.finance.main.domain.CwGlVoucher">
        insert into cw_gl_voucher (PK_VOUCHER, PK_GLORGBOOK, PK_VOUCHERTY,
                                   VOUCHERTYPE, PK_PREPARED,
                                   PREPAREDATE, VOUCHERNO, PERIOD,
                                   TOTALDEBIT, TOTALCREDIT, USE_STATE, CREATE_USER, CREATE_TIME)
        select #{pkVoucher,jdbcType=VARCHAR}       as PK_VOUCHER,
               #{pkGlorgbook,jdbcType=VARCHAR}     as PK_GLORGBOOK,
               '1'                                 as PK_VOUCHERTY,
               '1'                                 as VOUCHERTYPE,
               #{pkPrepared,jdbcType=VARCHAR}      as PK_PREPARED,
               #{preparedate,jdbcType=DATE}        as PREPAREDATE,
               '1'                                 as VOUCHERNO,
               #{period,jdbcType=VARCHAR}          as PERIOD,
               IFNULL(sum(a.LOCALDEBITAMOUNT), 0)  as TOTALDEBIT,
               IFNULL(sum(a.LOCALCREDITAMOUNT), 0) as TOTALCREDIT,
               '1'                                 as USE_STATE,
               #{createUser,jdbcType=VARCHAR}      AS CREATE_USER,
               #{createTime,jdbcType=TIMESTAMP}    AS CREATE_TIME
        from CW_GL_INITBUILD a
        where a.PK_GLORGBOOK = #{pkGlorgbook,jdbcType=VARCHAR}
          and a.USE_STATE = '1'
    </insert>
    <!--   查询结转凭证信息 -->
    <select id="selectVoucherForTransfer" parameterType="java.lang.String" resultMap="BaseResultMap3">
        select a.PK_VOUCHER, (select name from CW_BD_GLORGBOOK b where b.PK_GLORGBOOK=a.PK_GLORGBOOK) PK_GLORGBOOK,
        FQMJBH,PK_VOUCHERTY, PK_SYSTEM, VOUCHERTYPE,a.ABSTRACTS,
        (select USER_NAME from sys_user_info C where C.USER_ID = a.PK_PREPARED )as PK_PREPARED,
        a.PREPAREDATE, ISAUDIT, PK_AUDIT, AUDITDATE, ISSIGN, PK_SIGN, SIGNDATE, VOUCHERNO, ISMODIFY, YEAR,
        PERIOD, TEMPSAVE, TOTALDEBIT, TOTALCREDIT, OCC_DATE,a.USE_STATE,
        a.CREATE_USER, a.CREATE_TIME, a.UPDATE_USER,a.UPDATE_TIME, a.REMARK,
        <include refid="Zdy_Column_List2"/>
        from CW_GL_VOUCHER a
        left join CW_GL_DETAIL b on a.PK_VOUCHER=b.PK_VOUCHER and b.USE_STATE= "1"
        where a.USE_STATE='1'
        <if test="pkGlorgbook !=null">
            and a.PK_GLORGBOOK = #{pkGlorgbook,jdbcType=VARCHAR}
        </if>
        <if test="period !=null">
            and a.PERIOD = #{period,jdbcType=VARCHAR}
        </if>
        <if test="pkVoucherty !=null">
            and a.PK_VOUCHERTY = #{pkVoucherty,jdbcType=VARCHAR}
        </if>
    </select>
    <!-- 查询当期分期募集编号 -->
    <select id="selectFqmjbh" parameterType="java.lang.String" resultType="java.lang.String">
        select distinct FQMJBH
        from cw_gl_voucher
        where PK_GLORGBOOK = #{pkGlorgbook,jdbcType=VARCHAR}
          and PERIOD = #{period,jdbcType=VARCHAR}
          and USE_STATE = '1'
          and FQMJBH != ''
          and FQMJBH is not null
    </select>
    <!-- 查询凭证数量 1=已制单 2=已审核 3=已记账-->
    <select id="searchCwGlVoucherCount" parameterType="java.lang.String" resultType="java.util.Map">
        select (select count(*) from cw_gl_voucher where
        <if test="useState !=null">
            USE_STATE=#{useState,jdbcType=VARCHAR}
        </if>
        <if test="pkGlorgbook !=null">
            and PK_GLORGBOOK = #{pkGlorgbook,jdbcType=VARCHAR}
        </if>
        <if test="period !=null">
            and PERIOD = #{period,jdbcType=VARCHAR}
        </if>
        <if test="fqmc !=null">
            and FQMJBH = #{fqmc,jdbcType=VARCHAR}
        </if>
        ) as allCount,
        (select count(*) from cw_gl_voucher where
        <if test="useState !=null">
            USE_STATE = #{useState,jdbcType=VARCHAR}
        </if>
        <if test="vouchertype !=null">
            and VOUCHERTYPE = #{vouchertype,jdbcType=VARCHAR}
        </if>
        <if test="falg==1">
            and PREPAREDATE = #{period,jdbcType=VARCHAR}
        </if>
        <if test="falg==2">
            and AUDITDATE= #{period,jdbcType=VARCHAR}
        </if>) as toCount
        from dual
    </select>
    <!-- 对外提供->查询今日新增凭证接口 -->
    <select id="searchCwGlVoucherTodayAdd" resultMap="BaseResultMap1">
        select PK_VOUCHER,
               PK_GLORGBOOK,
               (select CODE FROM cw_bd_glorgbook b WHERE b.PK_GLORGBOOK = a.PK_GLORGBOOK) CODE,
               (select NAME FROM cw_bd_glorgbook b WHERE b.PK_GLORGBOOK = a.PK_GLORGBOOK) NAME,
               PK_VOUCHERTY,
               VOUCHERTYPE,
               ABSTRACTS,
               VOUCHERNO,
               PERIOD,
               TOTALDEBIT,
               TOTALCREDIT,
               PREPAREDATE,
               OCC_DATE,
               USE_STATE
        from cw_gl_voucher a
        where a.PREPAREDATE = curdate()
          and a.USE_STATE = '1'
        order by a.CREATE_TIME desc
    </select>
    <!-- 根据流水号查询凭证信息 -->
    <select id="searchVoucherDetailForSerialNo" resultMap="BaseResultMap3">
        select a.PK_VOUCHER,
        (select name from cw_bd_glorgbook cbg where cbg.PK_GLORGBOOK = a.PK_GLORGBOOK) as PK_GLORGBOOK,
        FQMJBH,PK_VOUCHERTY, PK_SYSTEM, VOUCHERTYPE,a.ABSTRACTS,
        (select USER_NAME from sys_user_info C where C.USER_ID = a.PK_PREPARED )as PK_PREPARED,
        a.PREPAREDATE, ISAUDIT, PK_AUDIT, AUDITDATE, ISSIGN, PK_SIGN, SIGNDATE, VOUCHERNO, ISMODIFY, YEAR,
        PERIOD, TEMPSAVE, TOTALDEBIT, TOTALCREDIT, OCC_DATE,a.USE_STATE,
        a.CREATE_USER, a.CREATE_TIME, a.UPDATE_USER,a.UPDATE_TIME, a.REMARK,
        <include refid="Zdy_Column_List2"/>
        from CW_GL_VOUCHER a
        left join CW_GL_DETAIL b on a.PK_VOUCHER=b.PK_VOUCHER and b.USE_STATE= "1"
        where a.PK_VOUCHER in
        <foreach collection="list" open="(" item="item" separator="," close=")">
            #{item,jdbcType=VARCHAR}
        </foreach>
        and a.USE_STATE = "1"
        <if test="pkVoucherty !=null">
            and a.PK_VOUCHERTY = #{pkVoucherty,jdbcType=VARCHAR}
        </if>
        order by a.PREPAREDATE desc, a.CREATE_TIME desc
    </select>
    <!--     制单查询列表总和 -->
    <select id="searchDebitANdCredit" parameterType="com.dhcc.finance.main.model.CwGlVoucherAndLike"
            resultType="java.util.Map">
        SELECT SUM(TOTALDEBIT) AS SUMTOTALDEBIT ,SUM( TOTALCREDIT) AS SUMTOTALCREDIT FROM CW_GL_VOUCHER WHERE USE_STATE
        = '1'
        <if test="pkGlorgbook !=null">
            and PK_GLORGBOOK = #{pkGlorgbook,jdbcType=VARCHAR}
        </if>
        <if test="fqmjbh !=null">
            and FQMJBH = #{fqmjbh,jdbcType=VARCHAR}
        </if>
        <if test="period !=null">
            and PERIOD = #{period,jdbcType=VARCHAR}
        </if>
        <if test="pkPrepared !=null">
            and PK_PREPARED = #{pkPrepared,jdbcType=VARCHAR}
        </if>
        <if test="pkAudit !=null">
            and PK_AUDIT = #{pkAudit,jdbcType=VARCHAR}
        </if>
        <if test="pkSign !=null">
            and PK_SIGN = #{pkSign,jdbcType=VARCHAR}
        </if>
        <if test="pkSystem !=null">
            and PK_SYSTEM = #{pkSystem,jdbcType=VARCHAR}
        </if>
        <if test="vouchertype !=null">
            and VOUCHERTYPE = #{vouchertype,jdbcType=VARCHAR}
        </if>
        <if test="vouchernoMin !=null and vouchernoMax == null">
            <![CDATA[ and VOUCHERNO >= #{vouchernoMin,jdbcType=VARCHAR} + 0 ]]>
        </if>
        <if test="vouchernoMin == null and vouchernoMax !=null">
            <![CDATA[ and VOUCHERNO <= #{vouchernoMax,jdbcType=VARCHAR} + 0 ]]>
        </if>
        <if test="vouchernoMin !=null and vouchernoMax!=null">
            and VOUCHERNO between #{vouchernoMin,jdbcType=VARCHAR} + 0 and #{vouchernoMax,jdbcType=VARCHAR} + 0
        </if>
        <if test="preparedateMin !=null and preparedateMax == null">
            <![CDATA[ and PREPAREDATE >= #{preparedateMin,jdbcType=VARCHAR} ]]>
        </if>
        <if test="preparedateMin == null and preparedateMax !=null">
            <![CDATA[ and PREPAREDATE <= #{preparedateMax,jdbcType=VARCHAR} ]]>
        </if>
        <if test="preparedateMin !=null and preparedateMax !=null">
            and PREPAREDATE between #{preparedateMin,jdbcType=VARCHAR} and #{preparedateMax,jdbcType=VARCHAR}
        </if>
        <if test="occDateMin !=null and occDateMax == null">
            <![CDATA[ and OCC_DATE >= #{occDateMin,jdbcType=VARCHAR} ]]>
        </if>
        <if test="occDateMin == null and occDateMax !=null">
            <![CDATA[ and OCC_DATE <= #{occDateMax,jdbcType=VARCHAR} ]]>
        </if>
        <if test="occDateMin !=null and occDateMax !=null">
            and OCC_DATE between #{occDateMin,jdbcType=VARCHAR} and #{occDateMax,jdbcType=VARCHAR}
        </if>
        <if test="totaldebitMin !=null and totaldebitMax == null">
            <![CDATA[ and TOTALDEBIT >= #{totaldebitMin,jdbcType=VARCHAR} + 0 ]]>
        </if>
        <if test="totaldebitMin == null and totaldebitMax !=null">
            <![CDATA[ and TOTALDEBIT <= #{totaldebitMax,jdbcType=VARCHAR} + 0  ]]>
        </if>
        <if test="totaldebitMin !=null and totaldebitMax !=null">
            and TOTALDEBIT between #{totaldebitMin,jdbcType=VARCHAR} + 0 and #{totaldebitMax,jdbcType=VARCHAR} + 0
        </if>
        <if test="abstracts !=null">
            and ABSTRACTS LIKE "%"#{abstracts,jdbcType=VARCHAR}"%"
        </if>
    </select>
    <!--   审核查询金额合计 -->
    <select id="sumDebitANdCredit" parameterType="com.dhcc.finance.main.model.CwGlVoucherAndLike"
            resultType="java.util.Map">
        SELECT SUM(TOTALDEBIT) AS SUMTOTALDEBIT ,SUM( TOTALCREDIT) AS SUMTOTALCREDIT FROM CW_GL_VOUCHER WHERE USE_STATE
        = '1'and VOUCHERTYPE = '1'
        <if test="pkGlorgbook !=null">
            and PK_GLORGBOOK = #{pkGlorgbook,jdbcType=VARCHAR}
        </if>
        <if test="period !=null">
            and PERIOD = #{period,jdbcType=VARCHAR}
        </if>
        <if test="fqmjbh !=null">
            and FQMJBH = #{fqmjbh,jdbcType=VARCHAR}
        </if>
        <if test="pkPrepared !=null">
            and PK_PREPARED = #{pkPrepared,jdbcType=VARCHAR}
        </if>
        <if test="pkAudit !=null">
            and PK_AUDIT = #{pkAudit,jdbcType=VARCHAR}
        </if>
        <if test="pkSign !=null">
            and PK_SIGN = #{pkSign,jdbcType=VARCHAR}
        </if>
        <if test="pkSystem !=null">
            and PK_SYSTEM = #{pkSystem,jdbcType=VARCHAR}
        </if>
        <if test="vouchertype !=null">
            and VOUCHERTYPE = #{vouchertype,jdbcType=VARCHAR}
        </if>
        <if test="vouchernoMin !=null and vouchernoMax == null">
            <![CDATA[ and VOUCHERNO >= #{vouchernoMin,jdbcType=VARCHAR} + 0 ]]>
        </if>
        <if test="vouchernoMin == null and vouchernoMax !=null">
            <![CDATA[ and VOUCHERNO <= #{vouchernoMax,jdbcType=VARCHAR} + 0 ]]>
        </if>
        <if test="vouchernoMin !=null and vouchernoMax!=null">
            and VOUCHERNO between #{vouchernoMin,jdbcType=VARCHAR} + 0 and #{vouchernoMax,jdbcType=VARCHAR} + 0
        </if>
        <if test="preparedateMin !=null and preparedateMax == null">
            <![CDATA[ and PREPAREDATE >= #{preparedateMin,jdbcType=VARCHAR} ]]>
        </if>
        <if test="preparedateMin == null and preparedateMax !=null">
            <![CDATA[ and PREPAREDATE <= #{preparedateMax,jdbcType=VARCHAR} ]]>
        </if>
        <if test="preparedateMin !=null and preparedateMax !=null">
            and PREPAREDATE between #{preparedateMin,jdbcType=VARCHAR} and #{preparedateMax,jdbcType=VARCHAR}
        </if>
        <if test="occDateMin !=null and occDateMax == null">
            <![CDATA[ and OCC_DATE >= #{occDateMin,jdbcType=VARCHAR} ]]>
        </if>
        <if test="occDateMin == null and occDateMax !=null">
            <![CDATA[ and OCC_DATE <= #{occDateMax,jdbcType=VARCHAR} ]]>
        </if>
        <if test="occDateMin !=null and occDateMax !=null">
            and OCC_DATE between #{occDateMin,jdbcType=VARCHAR} and #{occDateMax,jdbcType=VARCHAR}
        </if>
        <if test="totaldebitMin !=null and totaldebitMax == null">
            <![CDATA[ and TOTALDEBIT >= #{totaldebitMin,jdbcType=VARCHAR} + 0 ]]>
        </if>
        <if test="totaldebitMin == null and totaldebitMax !=null">
            <![CDATA[ and TOTALDEBIT <= #{totaldebitMax,jdbcType=VARCHAR} + 0  ]]>
        </if>
        <if test="totaldebitMin !=null and totaldebitMax !=null">
            and TOTALDEBIT between #{totaldebitMin,jdbcType=VARCHAR} + 0 and #{totaldebitMax,jdbcType=VARCHAR} + 0
        </if>
        <if test="abstracts !=null">
            and ABSTRACTS LIKE "%"#{abstracts,jdbcType=VARCHAR}"%"
        </if>
    </select>
    <select id="sumDebitANdCreditByLike" parameterType="com.dhcc.finance.main.model.CwGlVoucherAndLike"
            resultType="java.util.Map">
        SELECT SUM(TOTALDEBIT) AS SUMTOTALDEBIT ,SUM( TOTALCREDIT) AS SUMTOTALCREDIT FROM CW_GL_VOUCHER WHERE USE_STATE
        = '1'and VOUCHERTYPE = '2'
        <if test="pkGlorgbook !=null">
            and PK_GLORGBOOK = #{pkGlorgbook,jdbcType=VARCHAR}
        </if>
        <if test="period !=null">
            and PERIOD = #{period,jdbcType=VARCHAR}
        </if>
        <if test="fqmjbh !=null">
            and FQMJBH = #{fqmjbh,jdbcType=VARCHAR}
        </if>
        <if test="pkPrepared !=null">
            and PK_PREPARED = #{pkPrepared,jdbcType=VARCHAR}
        </if>
        <if test="pkAudit !=null">
            and PK_AUDIT = #{pkAudit,jdbcType=VARCHAR}
        </if>
        <if test="pkSign !=null">
            and PK_SIGN = #{pkSign,jdbcType=VARCHAR}
        </if>
        <if test="pkSystem !=null">
            and PK_SYSTEM = #{pkSystem,jdbcType=VARCHAR}
        </if>
        <if test="vouchertype !=null">
            and VOUCHERTYPE = #{vouchertype,jdbcType=VARCHAR}
        </if>
        <if test="vouchernoMin !=null and vouchernoMax == null">
            <![CDATA[ and VOUCHERNO >= #{vouchernoMin,jdbcType=VARCHAR} + 0 ]]>
        </if>
        <if test="vouchernoMin == null and vouchernoMax !=null">
            <![CDATA[ and VOUCHERNO <= #{vouchernoMax,jdbcType=VARCHAR} + 0 ]]>
        </if>
        <if test="vouchernoMin !=null and vouchernoMax!=null">
            and VOUCHERNO between #{vouchernoMin,jdbcType=VARCHAR} + 0 and #{vouchernoMax,jdbcType=VARCHAR} + 0
        </if>
        <if test="preparedateMin !=null and preparedateMax == null">
            <![CDATA[ and PREPAREDATE >= #{preparedateMin,jdbcType=VARCHAR} ]]>
        </if>
        <if test="preparedateMin == null and preparedateMax !=null">
            <![CDATA[ and PREPAREDATE <= #{preparedateMax,jdbcType=VARCHAR} ]]>
        </if>
        <if test="preparedateMin !=null and preparedateMax !=null">
            and PREPAREDATE between #{preparedateMin,jdbcType=VARCHAR} and #{preparedateMax,jdbcType=VARCHAR}
        </if>
        <if test="occDateMin !=null and occDateMax == null">
            <![CDATA[ and OCC_DATE >= #{occDateMin,jdbcType=VARCHAR} ]]>
        </if>
        <if test="occDateMin == null and occDateMax !=null">
            <![CDATA[ and OCC_DATE <= #{occDateMax,jdbcType=VARCHAR} ]]>
        </if>
        <if test="occDateMin !=null and occDateMax !=null">
            and OCC_DATE between #{occDateMin,jdbcType=VARCHAR} and #{occDateMax,jdbcType=VARCHAR}
        </if>
        <if test="totaldebitMin !=null and totaldebitMax == null">
            <![CDATA[ and TOTALDEBIT >= #{totaldebitMin,jdbcType=VARCHAR} + 0 ]]>
        </if>
        <if test="totaldebitMin == null and totaldebitMax !=null">
            <![CDATA[ and TOTALDEBIT <= #{totaldebitMax,jdbcType=VARCHAR} + 0  ]]>
        </if>
        <if test="totaldebitMin !=null and totaldebitMax !=null">
            and TOTALDEBIT between #{totaldebitMin,jdbcType=VARCHAR} + 0 and #{totaldebitMax,jdbcType=VARCHAR} + 0
        </if>
        <if test="abstracts !=null">
            and ABSTRACTS LIKE "%"#{abstracts,jdbcType=VARCHAR}"%"
        </if>
    </select>
    <!-- 根据凭证主键查询分录表的信息 -->
    <select id="selectCwGlDetailInfoByPkVoucher" resultMap="BaseResultMap4" parameterType="java.lang.String">
        SELECT PK_DETAIL,
               PK_VOUCHER,
               DETAILINDEX,
               ABSTRACTS,
               PK_ACCSUBJ,
               CONCAT(SUBJCODE, '-', SUBJNAME) as SUBJNAME,
               PK_CURRTYPE,
               DEBITAMOUNT,
               CREDITAMOUNT,
               LOCALDEBITAMOUNT,
               LOCALCREDITAMOUNT,
               ASSID,
               QTY,
               USE_STATE,
               CREATE_USER,
               CREATE_TIME,
               UPDATE_USER,
               UPDATE_TIME,
               REMARK
        FROM CW_GL_DETAIL
        WHERE PK_VOUCHER = #{pkVoucher,jdbcType=VARCHAR}
          and USE_STATE = '1'
        order by DEBITAMOUNT desc, CREDITAMOUNT
    </select>
    <!--   删除凭证表数据 -->
    <update id="updateUserStateForTwo" parameterType="java.util.List">
        update cw_gl_voucher set USE_STATE = '2'
        where PK_VOUCHER in
        <foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
            #{item.pkVoucher,jdbcType=TIMESTAMP}
        </foreach>
    </update>
    <!--   查询账套下凭证的数量 -->
    <select id="selectIsExistsVoucherForGlorgbook" parameterType="java.lang.String" resultType="java.lang.Long">
        select count(1)
        from cw_gl_voucher
        where PK_GLORGBOOK = #{pkGlorgbook,jdbcType=VARCHAR}
          and USE_STATE = '1'
    </select>

    <select id="selectVoucherForBatch" parameterType="java.util.List" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from cw_gl_voucher
        <where>
            USE_STATE = '1'
            and PK_VOUCHER in
            <foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
                #{item,jdbcType=TIMESTAMP}
            </foreach>
        </where>
    </select>
    <!--   批量审核 -->
    <update id="updateCwGlVoucherForBatch" parameterType="java.util.Map">
        update cw_gl_voucher
        <set>
            <if test="vouchertype !=null">
                VOUCHERTYPE = #{vouchertype,jdbcType=VARCHAR},
            </if>
            <if test="isaudit !=null">
                ISAUDIT = #{isaudit,jdbcType=VARCHAR},
            </if>
            <if test="pkAudit !=null">
                PK_AUDIT = #{pkAudit,jdbcType=VARCHAR},
            </if>
            <if test="auditdate !=null">
                AUDITDATE = #{auditdate,jdbcType=DATE},
            </if>
            <if test="issign !=null">
                ISSIGN = #{issign,jdbcType=VARCHAR},
            </if>
            <if test="pkSign !=null">
                PK_SIGN = #{pkSign,jdbcType=VARCHAR},
            </if>
            <if test="signdate !=null">
                SIGNDATE = #{signdate,jdbcType=DATE},
            </if>
            <if test="updateUser !=null">
                UPDATE_USER = #{updateUser,jdbcType=VARCHAR},
            </if>
            <if test="updateTime !=null">
                UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP}
            </if>
        </set>
        <where>
            USE_STATE = '1'
            <if test="pkAudit !=null">
                <![CDATA[  and PK_PREPARED <> #{pkAudit,jdbcType=VARCHAR}]]>
            </if>
            and PK_VOUCHER in
            <foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
                #{item.pkVoucher,jdbcType=TIMESTAMP}
            </foreach>
        </where>
    </update>

    <select id="searchVoucherPkByFlowId" parameterType="java.lang.String" resultType="java.lang.String">
        select distinct cbrs.PK_VOUCHER
        from pm_wflow_rel pwr
        <if test='bxlx=="1"'>
            join pm_expense_apply pea on pwr.DXBH = pea.BXDH and pea.SYZT ='1'
            join pm_costflow_info pci on pea.BXDH = pci.OBJ_ID and pci.USE_STATE ='1'
        </if>
        <if test='bxlx=="2"'>
            join pm_expense_claim pec on pwr.DXBH = pec.BXDH and pec.SYZT ='1'
            join pm_costflow_info pci on pec.BXDH = pci.OBJ_ID and pci.USE_STATE ='1'
        </if>
        <if test='bxlx=="3"'>
            join pm_expense_claim pec on pwr.DXBH = pec.ID and pec.SYZT ='1'
            join pm_costflow_info pci on pec.BXDH = pci.OBJ_ID and pci.USE_STATE ='1'
        </if>
        join cw_bd_record_serial cbrs on pci.BATCH_ID = cbrs.BATCH_NO
        join cw_gl_voucher cgv on cbrs.PK_VOUCHER = cgv.PK_VOUCHER and cgv.USE_STATE='1'
        where cbrs.PK_VOUCHER is not null
        and pwr.LCSLYWBH = #{lcslywbh,jdbcType=VARCHAR}
    </select>

    <insert id="insertVoucherBatch" parameterType="com.dhcc.finance.main.domain.CwGlVoucher" >
        insert into cw_gl_voucher (PK_VOUCHER, PK_GLORGBOOK, FQMJBH, PK_VOUCHERTY, PK_SYSTEM, TRADECODE, VOUCHERTYPE,
                                   ABSTRACTS, PK_PREPARED, PREPAREDATE, ISAUDIT, PK_AUDIT, AUDITDATE, ISSIGN, PK_SIGN,
                                   SIGNDATE, VOUCHERNO, ISMODIFY, YEAR, PERIOD, TEMPSAVE, TOTALDEBIT, TOTALCREDIT,
                                   OCC_DATE, USE_STATE, CREATE_USER, CREATE_TIME, UPDATE_USER, UPDATE_TIME, REMARK)
                                   values
        <foreach collection="list" separator="," item="item">
            (#{item.pkVoucher,jdbcType=VARCHAR}, #{item.pkGlorgbook,jdbcType=VARCHAR}, #{item.fqmjbh,jdbcType=VARCHAR},
            #{item.pkVoucherty,jdbcType=VARCHAR}, #{item.pkSystem,jdbcType=VARCHAR}, #{item.tradecode,jdbcType=VARCHAR},
            #{item.vouchertype,jdbcType=VARCHAR}, #{item.abstracts,jdbcType=VARCHAR}, #{item.pkPrepared,jdbcType=VARCHAR},
            #{item.preparedate,jdbcType=DATE}, #{item.isaudit,jdbcType=VARCHAR}, #{item.pkAudit,jdbcType=VARCHAR},
            #{item.auditdate,jdbcType=DATE}, #{item.issign,jdbcType=VARCHAR}, #{item.pkSign,jdbcType=VARCHAR},
            #{item.signdate,jdbcType=DATE}, #{item.voucherno,jdbcType=VARCHAR}, #{item.ismodify,jdbcType=VARCHAR},
            #{item.year,jdbcType=VARCHAR}, #{item.period,jdbcType=VARCHAR}, #{item.tempsave,jdbcType=VARCHAR},
            #{item.totaldebit,jdbcType=DECIMAL}, #{item.totalcredit,jdbcType=DECIMAL}, #{item.occDate,jdbcType=TIMESTAMP},
            #{item.useState,jdbcType=VARCHAR}, #{item.createUser,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP},
            #{item.updateUser,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=TIMESTAMP}, #{item.remark,jdbcType=VARCHAR})
        </foreach>
    </insert>
    <select id="searchVoucherByBatchNo" resultMap="BaseResultMap">
        select MD5(uuid()) PK_VOUCHER,b.PK_GLORGBOOK, null FQMJBH,'2' PK_VOUCHERTY,#{cwGlVoucherTempRequest.pkSystem,jdbcType=VARCHAR} PK_SYSTEM,'CJ1033' TRADECODE,'1' VOUCHERTYPE,
               #{cwBdVouchtemp.abstracts,jdbcType=VARCHAR} ABSTRACTS,a.CREATE_USER PK_PREPARED,  IF(b.PK_CURRPERIOD> DATE_FORMAT( a.CREATE_TIME,'%Y-%m'),
                   STR_TO_DATE(CONCAT(b.PK_CURRPERIOD,'-01'),'YYYY/MM/DD HH24:mi:ss'),IF(b.PK_CURRPERIOD = DATE_FORMAT( a.CREATE_TIME,'%Y-%m'),a.CREATE_TIME,
                       last_day(str_to_date('2020-02','%Y-%m')))) PREPAREDATE,cast(cast(getVoucherMaxno(b.PK_GLORGBOOK,b.PK_CURRPERIOD)+1 as signed) as char) VOUCHERNO,LEFT(b.PK_CURRPERIOD,4) YEAR,b.PK_CURRPERIOD PERIOD,
               a.VOUCHER_AMOUNT TOTALDEBIT,a.VOUCHER_AMOUNT TOTALCREDIT,a.CREATE_TIME OCC_DATE,'1' USE_STATE,a.CREATE_USER,a.CREATE_TIME,a.ID REMARK
        from cw_bd_manual_serial a
        left join cw_bd_glorgbook b on a.SUB_PROJECT_CODE=b.XTZXMBH
        where a.BATCH_NO = #{cwGlVoucherTempRequest.batchNo,jdbcType=VARCHAR} and a.USE_STATE ='1' and b.USE_STATE ='1'
            and a.VOUCHER_TYPE = #{cwGlVoucherTempRequest.voucherType,jdbcType=VARCHAR}
    </select>
    <!-- 根据子项目编号和制单日期查询凭证详情(每日计提) -->
    <select id="searchVoucherDetailForXtzxmbh" resultMap="BaseResultMap3">
        select a.PK_VOUCHER,
        (select name from cw_bd_glorgbook cbg where cbg.PK_GLORGBOOK = a.PK_GLORGBOOK) as PK_GLORGBOOK,
        a.FQMJBH,PK_VOUCHERTY, PK_SYSTEM, VOUCHERTYPE,a.ABSTRACTS,
        (select USER_NAME from sys_user_info C where C.USER_ID = a.PK_PREPARED )as PK_PREPARED,
        a.PREPAREDATE, ISAUDIT, PK_AUDIT, AUDITDATE, ISSIGN, PK_SIGN, SIGNDATE, VOUCHERNO, ISMODIFY, YEAR,
        PERIOD, TEMPSAVE, TOTALDEBIT, TOTALCREDIT, OCC_DATE,a.USE_STATE,
        a.CREATE_USER, a.CREATE_TIME, a.UPDATE_USER,a.UPDATE_TIME, a.REMARK,
        <include refid="Zdy_Column_List2"/>
        from CW_GL_VOUCHER a
        left join cw_bd_glorgbook c on a.PK_GLORGBOOK=c.PK_GLORGBOOK
        left join CW_GL_DETAIL b on a.PK_VOUCHER=b.PK_VOUCHER
        where a.PK_SYSTEM = "04" and a.USE_STATE = "1" and b.USE_STATE= "1" and c.USE_STATE= "1"
        <if test="xtzxmbh !=null">
            and c.XTZXMBH = #{xtzxmbh,jdbcType=VARCHAR}
        </if>
        <if test="dateTime !=null">
            and a.PREPAREDATE = #{dateTime,jdbcType=VARCHAR}
        </if>
        order by a.PREPAREDATE desc, a.CREATE_TIME desc
    </select>
    <select id="searchFinVoucherPk" resultType="java.lang.String">
        select distinct PK_VOUCHER
        from cw_bd_record_ncpush where PUSH_TYPE = '1' and PK_VOUCHER in
        <foreach collection="list" item="pk" open="(" close=")" separator=",">
            #{pk,jdbcType=VARCHAR}
        </foreach>
    </select>
</mapper>