<?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.plugin.lets.dao.impl.SoSaleDaoImpl">

    <resultMap id="get-SoSaleEntity-result" type="com.hzya.frame.plugin.lets.entity.SoSaleEntity" >
       <result property="alrconfincomny" column="alrconfincomny" jdbcType="VARCHAR"/>
           <result property="bcooptopo" column="bcooptopo" jdbcType="VARCHAR"/>
           <result property="bfreecustflag" column="bfreecustflag" jdbcType="VARCHAR"/>
           <result property="binitflag" column="binitflag" jdbcType="VARCHAR"/>
           <result property="binvoicendflag" column="binvoicendflag" jdbcType="VARCHAR"/>
           <result property="boutendflag" column="boutendflag" jdbcType="VARCHAR"/>
           <result property="boverdate" column="boverdate" jdbcType="VARCHAR"/>
           <result property="bpayendflag" column="bpayendflag" jdbcType="VARCHAR"/>
           <result property="bpocooptome" column="bpocooptome" jdbcType="VARCHAR"/>
           <result property="breceiptendflag" column="breceiptendflag" jdbcType="VARCHAR"/>
           <result property="bretinvflag" column="bretinvflag" jdbcType="VARCHAR"/>
           <result property="btransendflag" column="btransendflag" jdbcType="VARCHAR"/>
           <result property="capproveid" column="capproveid" jdbcType="VARCHAR"/>
           <result property="cbaltypeid" column="cbaltypeid" jdbcType="VARCHAR"/>
           <result property="cbiztype" column="cbiztype" jdbcType="VARCHAR"/>
           <result property="ccalbodyid" column="ccalbodyid" jdbcType="VARCHAR"/>
           <result property="ccooppohid" column="ccooppohid" jdbcType="VARCHAR"/>
           <result property="ccreditnum" column="ccreditnum" jdbcType="VARCHAR"/>
           <result property="ccustbankid" column="ccustbankid" jdbcType="VARCHAR"/>
           <result property="ccustomerid" column="ccustomerid" jdbcType="VARCHAR"/>
           <result property="cdeptid" column="cdeptid" jdbcType="VARCHAR"/>
           <result property="cemployeeid" column="cemployeeid" jdbcType="VARCHAR"/>
           <result property="cfreecustid" column="cfreecustid" jdbcType="VARCHAR"/>
           <result property="coperatorid" column="coperatorid" jdbcType="VARCHAR"/>
           <result property="creceiptareaid" column="creceiptareaid" jdbcType="VARCHAR"/>
           <result property="creceiptcorpid" column="creceiptcorpid" jdbcType="VARCHAR"/>
           <result property="creceiptcustomerid" column="creceiptcustomerid" jdbcType="VARCHAR"/>
           <result property="creceipttype" column="creceipttype" jdbcType="VARCHAR"/>
           <result property="csalecorpid" column="csalecorpid" jdbcType="VARCHAR"/>
           <result property="csaleid" column="csaleid" jdbcType="VARCHAR"/>
           <result property="ctermprotocolid" column="ctermprotocolid" jdbcType="VARCHAR"/>
           <result property="ctransmodeid" column="ctransmodeid" jdbcType="VARCHAR"/>
           <result property="cwarehouseid" column="cwarehouseid" jdbcType="VARCHAR"/>
           <result property="dapprovedate" column="dapprovedate" jdbcType="VARCHAR"/>
           <result property="daudittime" column="daudittime" jdbcType="VARCHAR"/>
           <result property="dbilldate" column="dbilldate" jdbcType="VARCHAR"/>
           <result property="dbilltime" column="dbilltime" jdbcType="VARCHAR"/>
           <result property="dmakedate" column="dmakedate" jdbcType="VARCHAR"/>
           <result property="dmoditime" column="dmoditime" jdbcType="VARCHAR"/>
           <result property="dr" column="dr" jdbcType="INTEGER"/>
           <result property="editauthor" column="editauthor" jdbcType="VARCHAR"/>
           <result property="editdate" column="editdate" jdbcType="VARCHAR"/>
           <result property="editionnum" column="editionnum" jdbcType="VARCHAR"/>
           <result property="finvoiceclass" column="finvoiceclass" jdbcType="INTEGER"/>
           <result property="finvoicetype" column="finvoicetype" jdbcType="INTEGER"/>
           <result property="fstatus" column="fstatus" jdbcType="INTEGER"/>
           <result property="ibalanceflag" column="ibalanceflag" jdbcType="INTEGER"/>
           <result property="iprintcount" column="iprintcount" jdbcType="INTEGER"/>
           <result property="naccountperiod" column="naccountperiod" jdbcType="VARCHAR"/>
           <result property="ndiscountrate" column="ndiscountrate" jdbcType="VARCHAR"/>
           <result property="nevaluatecarriage" column="nevaluatecarriage" jdbcType="VARCHAR"/>
           <result property="nheadsummny" column="nheadsummny" jdbcType="VARCHAR"/>
           <result property="npreceivemny" column="npreceivemny" jdbcType="VARCHAR"/>
           <result property="npreceiverate" column="npreceiverate" jdbcType="VARCHAR"/>
           <result property="nsubscription" column="nsubscription" jdbcType="VARCHAR"/>
           <result property="ntotalnum" column="ntotalnum" jdbcType="VARCHAR"/>
           <result property="pkCorp" column="pk_corp" jdbcType="VARCHAR"/>
           <result property="pkDefdoc1" column="pk_defdoc1" jdbcType="VARCHAR"/>
           <result property="pkDefdoc10" column="pk_defdoc10" jdbcType="VARCHAR"/>
           <result property="pkDefdoc11" column="pk_defdoc11" jdbcType="VARCHAR"/>
           <result property="pkDefdoc12" column="pk_defdoc12" jdbcType="VARCHAR"/>
           <result property="pkDefdoc13" column="pk_defdoc13" jdbcType="VARCHAR"/>
           <result property="pkDefdoc14" column="pk_defdoc14" jdbcType="VARCHAR"/>
           <result property="pkDefdoc15" column="pk_defdoc15" jdbcType="VARCHAR"/>
           <result property="pkDefdoc16" column="pk_defdoc16" jdbcType="VARCHAR"/>
           <result property="pkDefdoc17" column="pk_defdoc17" jdbcType="VARCHAR"/>
           <result property="pkDefdoc18" column="pk_defdoc18" jdbcType="VARCHAR"/>
           <result property="pkDefdoc19" column="pk_defdoc19" jdbcType="VARCHAR"/>
           <result property="pkDefdoc2" column="pk_defdoc2" jdbcType="VARCHAR"/>
           <result property="pkDefdoc20" column="pk_defdoc20" jdbcType="VARCHAR"/>
           <result property="pkDefdoc3" column="pk_defdoc3" jdbcType="VARCHAR"/>
           <result property="pkDefdoc4" column="pk_defdoc4" jdbcType="VARCHAR"/>
           <result property="pkDefdoc5" column="pk_defdoc5" jdbcType="VARCHAR"/>
           <result property="pkDefdoc6" column="pk_defdoc6" jdbcType="VARCHAR"/>
           <result property="pkDefdoc7" column="pk_defdoc7" jdbcType="VARCHAR"/>
           <result property="pkDefdoc8" column="pk_defdoc8" jdbcType="VARCHAR"/>
           <result property="pkDefdoc9" column="pk_defdoc9" jdbcType="VARCHAR"/>
           <result property="srcoutsysflag" column="srcoutsysflag" jdbcType="INTEGER"/>
           <result property="transactionprice" column="transactionprice" jdbcType="VARCHAR"/>
           <result property="ts" column="ts" jdbcType="VARCHAR"/>
           <result property="vaccountyear" column="vaccountyear" jdbcType="VARCHAR"/>
           <result property="vdef1" column="vdef1" jdbcType="VARCHAR"/>
           <result property="vdef10" column="vdef10" jdbcType="VARCHAR"/>
           <result property="vdef11" column="vdef11" jdbcType="VARCHAR"/>
           <result property="vdef12" column="vdef12" jdbcType="VARCHAR"/>
           <result property="vdef13" column="vdef13" jdbcType="VARCHAR"/>
           <result property="vdef14" column="vdef14" jdbcType="VARCHAR"/>
           <result property="vdef15" column="vdef15" jdbcType="VARCHAR"/>
           <result property="vdef16" column="vdef16" jdbcType="VARCHAR"/>
           <result property="vdef17" column="vdef17" jdbcType="VARCHAR"/>
           <result property="vdef18" column="vdef18" jdbcType="VARCHAR"/>
           <result property="vdef19" column="vdef19" jdbcType="VARCHAR"/>
           <result property="vdef2" column="vdef2" jdbcType="VARCHAR"/>
           <result property="vdef20" column="vdef20" jdbcType="VARCHAR"/>
           <result property="vdef3" column="vdef3" jdbcType="VARCHAR"/>
           <result property="vdef4" column="vdef4" jdbcType="VARCHAR"/>
           <result property="vdef5" column="vdef5" jdbcType="VARCHAR"/>
           <result property="vdef6" column="vdef6" jdbcType="VARCHAR"/>
           <result property="vdef7" column="vdef7" jdbcType="VARCHAR"/>
           <result property="vdef8" column="vdef8" jdbcType="VARCHAR"/>
           <result property="vdef9" column="vdef9" jdbcType="VARCHAR"/>
           <result property="veditreason" column="veditreason" jdbcType="VARCHAR"/>
           <result property="vnote" column="vnote" jdbcType="VARCHAR"/>
           <result property="vreceiptcode" column="vreceiptcode" jdbcType="VARCHAR"/>
           <result property="vreceiveaddress" column="vreceiveaddress" jdbcType="VARCHAR"/>
        </resultMap>
    <!-- 查询的字段-->
    <sql id = "SoSaleEntity_Base_Column_List">
        alrconfincomny
       ,bcooptopo 
        ,bfreecustflag 
        ,binitflag 
        ,binvoicendflag 
        ,boutendflag 
        ,boverdate 
        ,bpayendflag 
        ,bpocooptome 
        ,breceiptendflag 
        ,bretinvflag 
        ,btransendflag 
        ,capproveid 
        ,cbaltypeid 
        ,cbiztype 
        ,ccalbodyid 
        ,ccooppohid 
        ,ccreditnum 
        ,ccustbankid 
        ,ccustomerid 
        ,cdeptid 
        ,cemployeeid 
        ,cfreecustid 
        ,coperatorid 
        ,creceiptareaid 
        ,creceiptcorpid 
        ,creceiptcustomerid 
        ,creceipttype 
        ,csalecorpid 
        ,csaleid 
        ,ctermprotocolid 
        ,ctransmodeid 
        ,cwarehouseid 
        ,dapprovedate 
        ,daudittime 
        ,dbilldate 
        ,dbilltime 
        ,dmakedate 
        ,dmoditime 
        ,dr 
        ,editauthor 
        ,editdate 
        ,editionnum 
        ,finvoiceclass 
        ,finvoicetype 
        ,fstatus 
        ,ibalanceflag 
        ,iprintcount 
        ,naccountperiod 
        ,ndiscountrate 
        ,nevaluatecarriage 
        ,nheadsummny 
        ,npreceivemny 
        ,npreceiverate 
        ,nsubscription 
        ,ntotalnum 
        ,pk_corp 
        ,pk_defdoc1 
        ,pk_defdoc10 
        ,pk_defdoc11 
        ,pk_defdoc12 
        ,pk_defdoc13 
        ,pk_defdoc14 
        ,pk_defdoc15 
        ,pk_defdoc16 
        ,pk_defdoc17 
        ,pk_defdoc18 
        ,pk_defdoc19 
        ,pk_defdoc2 
        ,pk_defdoc20 
        ,pk_defdoc3 
        ,pk_defdoc4 
        ,pk_defdoc5 
        ,pk_defdoc6 
        ,pk_defdoc7 
        ,pk_defdoc8 
        ,pk_defdoc9 
        ,srcoutsysflag 
        ,transactionprice 
        ,ts 
        ,vaccountyear 
        ,vdef1 
        ,vdef10 
        ,vdef11 
        ,vdef12 
        ,vdef13 
        ,vdef14 
        ,vdef15 
        ,vdef16 
        ,vdef17 
        ,vdef18 
        ,vdef19 
        ,vdef2 
        ,vdef20 
        ,vdef3 
        ,vdef4 
        ,vdef5 
        ,vdef6 
        ,vdef7 
        ,vdef8 
        ,vdef9 
        ,veditreason 
        ,vnote 
        ,vreceiptcode 
        ,vreceiveaddress 
     </sql>
 <!-- 查询 采用==查询 -->
 <select id="entity_list_base" resultMap="get-SoSaleEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.SoSaleEntity">
    select
    <include refid="SoSaleEntity_Base_Column_List" />
    from so_sale
    <trim prefix="where" prefixOverrides="and"> 
        <if test="alrconfincomny != null and alrconfincomny != ''"> and alrconfincomny = #{alrconfincomny} </if>
            <if test="bcooptopo != null and bcooptopo != ''"> and bcooptopo = #{bcooptopo} </if>
            <if test="bfreecustflag != null and bfreecustflag != ''"> and bfreecustflag = #{bfreecustflag} </if>
            <if test="binitflag != null and binitflag != ''"> and binitflag = #{binitflag} </if>
            <if test="binvoicendflag != null and binvoicendflag != ''"> and binvoicendflag = #{binvoicendflag} </if>
            <if test="boutendflag != null and boutendflag != ''"> and boutendflag = #{boutendflag} </if>
            <if test="boverdate != null and boverdate != ''"> and boverdate = #{boverdate} </if>
            <if test="bpayendflag != null and bpayendflag != ''"> and bpayendflag = #{bpayendflag} </if>
            <if test="bpocooptome != null and bpocooptome != ''"> and bpocooptome = #{bpocooptome} </if>
            <if test="breceiptendflag != null and breceiptendflag != ''"> and breceiptendflag = #{breceiptendflag} </if>
            <if test="bretinvflag != null and bretinvflag != ''"> and bretinvflag = #{bretinvflag} </if>
            <if test="btransendflag != null and btransendflag != ''"> and btransendflag = #{btransendflag} </if>
            <if test="capproveid != null and capproveid != ''"> and capproveid = #{capproveid} </if>
            <if test="cbaltypeid != null and cbaltypeid != ''"> and cbaltypeid = #{cbaltypeid} </if>
            <if test="cbiztype != null and cbiztype != ''"> and cbiztype = #{cbiztype} </if>
            <if test="ccalbodyid != null and ccalbodyid != ''"> and ccalbodyid = #{ccalbodyid} </if>
            <if test="ccooppohid != null and ccooppohid != ''"> and ccooppohid = #{ccooppohid} </if>
            <if test="ccreditnum != null and ccreditnum != ''"> and ccreditnum = #{ccreditnum} </if>
            <if test="ccustbankid != null and ccustbankid != ''"> and ccustbankid = #{ccustbankid} </if>
            <if test="ccustomerid != null and ccustomerid != ''"> and ccustomerid = #{ccustomerid} </if>
            <if test="cdeptid != null and cdeptid != ''"> and cdeptid = #{cdeptid} </if>
            <if test="cemployeeid != null and cemployeeid != ''"> and cemployeeid = #{cemployeeid} </if>
            <if test="cfreecustid != null and cfreecustid != ''"> and cfreecustid = #{cfreecustid} </if>
            <if test="coperatorid != null and coperatorid != ''"> and coperatorid = #{coperatorid} </if>
            <if test="creceiptareaid != null and creceiptareaid != ''"> and creceiptareaid = #{creceiptareaid} </if>
            <if test="creceiptcorpid != null and creceiptcorpid != ''"> and creceiptcorpid = #{creceiptcorpid} </if>
            <if test="creceiptcustomerid != null and creceiptcustomerid != ''"> and creceiptcustomerid = #{creceiptcustomerid} </if>
            <if test="creceipttype != null and creceipttype != ''"> and creceipttype = #{creceipttype} </if>
            <if test="csalecorpid != null and csalecorpid != ''"> and csalecorpid = #{csalecorpid} </if>
            <if test="csaleid != null and csaleid != ''"> and csaleid = #{csaleid} </if>
            <if test="ctermprotocolid != null and ctermprotocolid != ''"> and ctermprotocolid = #{ctermprotocolid} </if>
            <if test="ctransmodeid != null and ctransmodeid != ''"> and ctransmodeid = #{ctransmodeid} </if>
            <if test="cwarehouseid != null and cwarehouseid != ''"> and cwarehouseid = #{cwarehouseid} </if>
            <if test="dapprovedate != null and dapprovedate != ''"> and dapprovedate = #{dapprovedate} </if>
            <if test="daudittime != null and daudittime != ''"> and daudittime = #{daudittime} </if>
            <if test="dbilldate != null and dbilldate != ''"> and dbilldate = #{dbilldate} </if>
            <if test="dbilltime != null and dbilltime != ''"> and dbilltime = #{dbilltime} </if>
            <if test="dmakedate != null and dmakedate != ''"> and dmakedate = #{dmakedate} </if>
            <if test="dmoditime != null and dmoditime != ''"> and dmoditime = #{dmoditime} </if>
            <if test="dr != null"> and dr = #{dr} </if>
            <if test="editauthor != null and editauthor != ''"> and editauthor = #{editauthor} </if>
            <if test="editdate != null and editdate != ''"> and editdate = #{editdate} </if>
            <if test="editionnum != null and editionnum != ''"> and editionnum = #{editionnum} </if>
            <if test="finvoiceclass != null"> and finvoiceclass = #{finvoiceclass} </if>
            <if test="finvoicetype != null"> and finvoicetype = #{finvoicetype} </if>
            <if test="fstatus != null"> and fstatus = #{fstatus} </if>
            <if test="ibalanceflag != null"> and ibalanceflag = #{ibalanceflag} </if>
            <if test="iprintcount != null"> and iprintcount = #{iprintcount} </if>
            <if test="naccountperiod != null and naccountperiod != ''"> and naccountperiod = #{naccountperiod} </if>
            <if test="ndiscountrate != null and ndiscountrate != ''"> and ndiscountrate = #{ndiscountrate} </if>
            <if test="nevaluatecarriage != null and nevaluatecarriage != ''"> and nevaluatecarriage = #{nevaluatecarriage} </if>
            <if test="nheadsummny != null and nheadsummny != ''"> and nheadsummny = #{nheadsummny} </if>
            <if test="npreceivemny != null and npreceivemny != ''"> and npreceivemny = #{npreceivemny} </if>
            <if test="npreceiverate != null and npreceiverate != ''"> and npreceiverate = #{npreceiverate} </if>
            <if test="nsubscription != null and nsubscription != ''"> and nsubscription = #{nsubscription} </if>
            <if test="ntotalnum != null and ntotalnum != ''"> and ntotalnum = #{ntotalnum} </if>
            <if test="pkCorp != null and pkCorp != ''"> and pk_corp = #{pkCorp} </if>
            <if test="pkDefdoc1 != null and pkDefdoc1 != ''"> and pk_defdoc1 = #{pkDefdoc1} </if>
            <if test="pkDefdoc10 != null and pkDefdoc10 != ''"> and pk_defdoc10 = #{pkDefdoc10} </if>
            <if test="pkDefdoc11 != null and pkDefdoc11 != ''"> and pk_defdoc11 = #{pkDefdoc11} </if>
            <if test="pkDefdoc12 != null and pkDefdoc12 != ''"> and pk_defdoc12 = #{pkDefdoc12} </if>
            <if test="pkDefdoc13 != null and pkDefdoc13 != ''"> and pk_defdoc13 = #{pkDefdoc13} </if>
            <if test="pkDefdoc14 != null and pkDefdoc14 != ''"> and pk_defdoc14 = #{pkDefdoc14} </if>
            <if test="pkDefdoc15 != null and pkDefdoc15 != ''"> and pk_defdoc15 = #{pkDefdoc15} </if>
            <if test="pkDefdoc16 != null and pkDefdoc16 != ''"> and pk_defdoc16 = #{pkDefdoc16} </if>
            <if test="pkDefdoc17 != null and pkDefdoc17 != ''"> and pk_defdoc17 = #{pkDefdoc17} </if>
            <if test="pkDefdoc18 != null and pkDefdoc18 != ''"> and pk_defdoc18 = #{pkDefdoc18} </if>
            <if test="pkDefdoc19 != null and pkDefdoc19 != ''"> and pk_defdoc19 = #{pkDefdoc19} </if>
            <if test="pkDefdoc2 != null and pkDefdoc2 != ''"> and pk_defdoc2 = #{pkDefdoc2} </if>
            <if test="pkDefdoc20 != null and pkDefdoc20 != ''"> and pk_defdoc20 = #{pkDefdoc20} </if>
            <if test="pkDefdoc3 != null and pkDefdoc3 != ''"> and pk_defdoc3 = #{pkDefdoc3} </if>
            <if test="pkDefdoc4 != null and pkDefdoc4 != ''"> and pk_defdoc4 = #{pkDefdoc4} </if>
            <if test="pkDefdoc5 != null and pkDefdoc5 != ''"> and pk_defdoc5 = #{pkDefdoc5} </if>
            <if test="pkDefdoc6 != null and pkDefdoc6 != ''"> and pk_defdoc6 = #{pkDefdoc6} </if>
            <if test="pkDefdoc7 != null and pkDefdoc7 != ''"> and pk_defdoc7 = #{pkDefdoc7} </if>
            <if test="pkDefdoc8 != null and pkDefdoc8 != ''"> and pk_defdoc8 = #{pkDefdoc8} </if>
            <if test="pkDefdoc9 != null and pkDefdoc9 != ''"> and pk_defdoc9 = #{pkDefdoc9} </if>
            <if test="srcoutsysflag != null"> and srcoutsysflag = #{srcoutsysflag} </if>
            <if test="transactionprice != null and transactionprice != ''"> and transactionprice = #{transactionprice} </if>
            <if test="ts != null and ts != ''"> and ts = #{ts} </if>
            <if test="vaccountyear != null and vaccountyear != ''"> and vaccountyear = #{vaccountyear} </if>
            <if test="vdef1 != null and vdef1 != ''"> and vdef1 = #{vdef1} </if>
            <if test="vdef10 != null and vdef10 != ''"> and vdef10 = #{vdef10} </if>
            <if test="vdef11 != null and vdef11 != ''"> and vdef11 = #{vdef11} </if>
            <if test="vdef12 != null and vdef12 != ''"> and vdef12 = #{vdef12} </if>
            <if test="vdef13 != null and vdef13 != ''"> and vdef13 = #{vdef13} </if>
            <if test="vdef14 != null and vdef14 != ''"> and vdef14 = #{vdef14} </if>
            <if test="vdef15 != null and vdef15 != ''"> and vdef15 = #{vdef15} </if>
            <if test="vdef16 != null and vdef16 != ''"> and vdef16 = #{vdef16} </if>
            <if test="vdef17 != null and vdef17 != ''"> and vdef17 = #{vdef17} </if>
            <if test="vdef18 != null and vdef18 != ''"> and vdef18 = #{vdef18} </if>
            <if test="vdef19 != null and vdef19 != ''"> and vdef19 = #{vdef19} </if>
            <if test="vdef2 != null and vdef2 != ''"> and vdef2 = #{vdef2} </if>
            <if test="vdef20 != null and vdef20 != ''"> and vdef20 = #{vdef20} </if>
            <if test="vdef3 != null and vdef3 != ''"> and vdef3 = #{vdef3} </if>
            <if test="vdef4 != null and vdef4 != ''"> and vdef4 = #{vdef4} </if>
            <if test="vdef5 != null and vdef5 != ''"> and vdef5 = #{vdef5} </if>
            <if test="vdef6 != null and vdef6 != ''"> and vdef6 = #{vdef6} </if>
            <if test="vdef7 != null and vdef7 != ''"> and vdef7 = #{vdef7} </if>
            <if test="vdef8 != null and vdef8 != ''"> and vdef8 = #{vdef8} </if>
            <if test="vdef9 != null and vdef9 != ''"> and vdef9 = #{vdef9} </if>
            <if test="veditreason != null and veditreason != ''"> and veditreason = #{veditreason} </if>
            <if test="vnote != null and vnote != ''"> and vnote = #{vnote} </if>
            <if test="vreceiptcode != null and vreceiptcode != ''"> and vreceiptcode = #{vreceiptcode} </if>
            <if test="vreceiveaddress != null and vreceiveaddress != ''"> and vreceiveaddress = #{vreceiveaddress} </if>
            <if test="tid!=null and tid!=''">and vreceiptcode + '_' + RIGHT ( csaleid, 5 )  = #{tid}</if>
    </trim>
    <if test=" sort == ''.toString() "> order by sorts asc</if>
    <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>
    
<!-- 查询符合条件的数量 -->
<select id="entity_count" resultType="Integer" parameterType = "com.hzya.frame.plugin.lets.entity.SoSaleEntity">
        select  count(1)   from so_sale
    <trim prefix="where" prefixOverrides="and"> 
        <if test="alrconfincomny != null and alrconfincomny != ''"> and alrconfincomny = #{alrconfincomny} </if>
            <if test="bcooptopo != null and bcooptopo != ''"> and bcooptopo = #{bcooptopo} </if>
            <if test="bfreecustflag != null and bfreecustflag != ''"> and bfreecustflag = #{bfreecustflag} </if>
            <if test="binitflag != null and binitflag != ''"> and binitflag = #{binitflag} </if>
            <if test="binvoicendflag != null and binvoicendflag != ''"> and binvoicendflag = #{binvoicendflag} </if>
            <if test="boutendflag != null and boutendflag != ''"> and boutendflag = #{boutendflag} </if>
            <if test="boverdate != null and boverdate != ''"> and boverdate = #{boverdate} </if>
            <if test="bpayendflag != null and bpayendflag != ''"> and bpayendflag = #{bpayendflag} </if>
            <if test="bpocooptome != null and bpocooptome != ''"> and bpocooptome = #{bpocooptome} </if>
            <if test="breceiptendflag != null and breceiptendflag != ''"> and breceiptendflag = #{breceiptendflag} </if>
            <if test="bretinvflag != null and bretinvflag != ''"> and bretinvflag = #{bretinvflag} </if>
            <if test="btransendflag != null and btransendflag != ''"> and btransendflag = #{btransendflag} </if>
            <if test="capproveid != null and capproveid != ''"> and capproveid = #{capproveid} </if>
            <if test="cbaltypeid != null and cbaltypeid != ''"> and cbaltypeid = #{cbaltypeid} </if>
            <if test="cbiztype != null and cbiztype != ''"> and cbiztype = #{cbiztype} </if>
            <if test="ccalbodyid != null and ccalbodyid != ''"> and ccalbodyid = #{ccalbodyid} </if>
            <if test="ccooppohid != null and ccooppohid != ''"> and ccooppohid = #{ccooppohid} </if>
            <if test="ccreditnum != null and ccreditnum != ''"> and ccreditnum = #{ccreditnum} </if>
            <if test="ccustbankid != null and ccustbankid != ''"> and ccustbankid = #{ccustbankid} </if>
            <if test="ccustomerid != null and ccustomerid != ''"> and ccustomerid = #{ccustomerid} </if>
            <if test="cdeptid != null and cdeptid != ''"> and cdeptid = #{cdeptid} </if>
            <if test="cemployeeid != null and cemployeeid != ''"> and cemployeeid = #{cemployeeid} </if>
            <if test="cfreecustid != null and cfreecustid != ''"> and cfreecustid = #{cfreecustid} </if>
            <if test="coperatorid != null and coperatorid != ''"> and coperatorid = #{coperatorid} </if>
            <if test="creceiptareaid != null and creceiptareaid != ''"> and creceiptareaid = #{creceiptareaid} </if>
            <if test="creceiptcorpid != null and creceiptcorpid != ''"> and creceiptcorpid = #{creceiptcorpid} </if>
            <if test="creceiptcustomerid != null and creceiptcustomerid != ''"> and creceiptcustomerid = #{creceiptcustomerid} </if>
            <if test="creceipttype != null and creceipttype != ''"> and creceipttype = #{creceipttype} </if>
            <if test="csalecorpid != null and csalecorpid != ''"> and csalecorpid = #{csalecorpid} </if>
            <if test="csaleid != null and csaleid != ''"> and csaleid = #{csaleid} </if>
            <if test="ctermprotocolid != null and ctermprotocolid != ''"> and ctermprotocolid = #{ctermprotocolid} </if>
            <if test="ctransmodeid != null and ctransmodeid != ''"> and ctransmodeid = #{ctransmodeid} </if>
            <if test="cwarehouseid != null and cwarehouseid != ''"> and cwarehouseid = #{cwarehouseid} </if>
            <if test="dapprovedate != null and dapprovedate != ''"> and dapprovedate = #{dapprovedate} </if>
            <if test="daudittime != null and daudittime != ''"> and daudittime = #{daudittime} </if>
            <if test="dbilldate != null and dbilldate != ''"> and dbilldate = #{dbilldate} </if>
            <if test="dbilltime != null and dbilltime != ''"> and dbilltime = #{dbilltime} </if>
            <if test="dmakedate != null and dmakedate != ''"> and dmakedate = #{dmakedate} </if>
            <if test="dmoditime != null and dmoditime != ''"> and dmoditime = #{dmoditime} </if>
            <if test="dr != null"> and dr = #{dr} </if>
            <if test="editauthor != null and editauthor != ''"> and editauthor = #{editauthor} </if>
            <if test="editdate != null and editdate != ''"> and editdate = #{editdate} </if>
            <if test="editionnum != null and editionnum != ''"> and editionnum = #{editionnum} </if>
            <if test="finvoiceclass != null"> and finvoiceclass = #{finvoiceclass} </if>
            <if test="finvoicetype != null"> and finvoicetype = #{finvoicetype} </if>
            <if test="fstatus != null"> and fstatus = #{fstatus} </if>
            <if test="ibalanceflag != null"> and ibalanceflag = #{ibalanceflag} </if>
            <if test="iprintcount != null"> and iprintcount = #{iprintcount} </if>
            <if test="naccountperiod != null and naccountperiod != ''"> and naccountperiod = #{naccountperiod} </if>
            <if test="ndiscountrate != null and ndiscountrate != ''"> and ndiscountrate = #{ndiscountrate} </if>
            <if test="nevaluatecarriage != null and nevaluatecarriage != ''"> and nevaluatecarriage = #{nevaluatecarriage} </if>
            <if test="nheadsummny != null and nheadsummny != ''"> and nheadsummny = #{nheadsummny} </if>
            <if test="npreceivemny != null and npreceivemny != ''"> and npreceivemny = #{npreceivemny} </if>
            <if test="npreceiverate != null and npreceiverate != ''"> and npreceiverate = #{npreceiverate} </if>
            <if test="nsubscription != null and nsubscription != ''"> and nsubscription = #{nsubscription} </if>
            <if test="ntotalnum != null and ntotalnum != ''"> and ntotalnum = #{ntotalnum} </if>
            <if test="pkCorp != null and pkCorp != ''"> and pk_corp = #{pkCorp} </if>
            <if test="pkDefdoc1 != null and pkDefdoc1 != ''"> and pk_defdoc1 = #{pkDefdoc1} </if>
            <if test="pkDefdoc10 != null and pkDefdoc10 != ''"> and pk_defdoc10 = #{pkDefdoc10} </if>
            <if test="pkDefdoc11 != null and pkDefdoc11 != ''"> and pk_defdoc11 = #{pkDefdoc11} </if>
            <if test="pkDefdoc12 != null and pkDefdoc12 != ''"> and pk_defdoc12 = #{pkDefdoc12} </if>
            <if test="pkDefdoc13 != null and pkDefdoc13 != ''"> and pk_defdoc13 = #{pkDefdoc13} </if>
            <if test="pkDefdoc14 != null and pkDefdoc14 != ''"> and pk_defdoc14 = #{pkDefdoc14} </if>
            <if test="pkDefdoc15 != null and pkDefdoc15 != ''"> and pk_defdoc15 = #{pkDefdoc15} </if>
            <if test="pkDefdoc16 != null and pkDefdoc16 != ''"> and pk_defdoc16 = #{pkDefdoc16} </if>
            <if test="pkDefdoc17 != null and pkDefdoc17 != ''"> and pk_defdoc17 = #{pkDefdoc17} </if>
            <if test="pkDefdoc18 != null and pkDefdoc18 != ''"> and pk_defdoc18 = #{pkDefdoc18} </if>
            <if test="pkDefdoc19 != null and pkDefdoc19 != ''"> and pk_defdoc19 = #{pkDefdoc19} </if>
            <if test="pkDefdoc2 != null and pkDefdoc2 != ''"> and pk_defdoc2 = #{pkDefdoc2} </if>
            <if test="pkDefdoc20 != null and pkDefdoc20 != ''"> and pk_defdoc20 = #{pkDefdoc20} </if>
            <if test="pkDefdoc3 != null and pkDefdoc3 != ''"> and pk_defdoc3 = #{pkDefdoc3} </if>
            <if test="pkDefdoc4 != null and pkDefdoc4 != ''"> and pk_defdoc4 = #{pkDefdoc4} </if>
            <if test="pkDefdoc5 != null and pkDefdoc5 != ''"> and pk_defdoc5 = #{pkDefdoc5} </if>
            <if test="pkDefdoc6 != null and pkDefdoc6 != ''"> and pk_defdoc6 = #{pkDefdoc6} </if>
            <if test="pkDefdoc7 != null and pkDefdoc7 != ''"> and pk_defdoc7 = #{pkDefdoc7} </if>
            <if test="pkDefdoc8 != null and pkDefdoc8 != ''"> and pk_defdoc8 = #{pkDefdoc8} </if>
            <if test="pkDefdoc9 != null and pkDefdoc9 != ''"> and pk_defdoc9 = #{pkDefdoc9} </if>
            <if test="srcoutsysflag != null"> and srcoutsysflag = #{srcoutsysflag} </if>
            <if test="transactionprice != null and transactionprice != ''"> and transactionprice = #{transactionprice} </if>
            <if test="ts != null and ts != ''"> and ts = #{ts} </if>
            <if test="vaccountyear != null and vaccountyear != ''"> and vaccountyear = #{vaccountyear} </if>
            <if test="vdef1 != null and vdef1 != ''"> and vdef1 = #{vdef1} </if>
            <if test="vdef10 != null and vdef10 != ''"> and vdef10 = #{vdef10} </if>
            <if test="vdef11 != null and vdef11 != ''"> and vdef11 = #{vdef11} </if>
            <if test="vdef12 != null and vdef12 != ''"> and vdef12 = #{vdef12} </if>
            <if test="vdef13 != null and vdef13 != ''"> and vdef13 = #{vdef13} </if>
            <if test="vdef14 != null and vdef14 != ''"> and vdef14 = #{vdef14} </if>
            <if test="vdef15 != null and vdef15 != ''"> and vdef15 = #{vdef15} </if>
            <if test="vdef16 != null and vdef16 != ''"> and vdef16 = #{vdef16} </if>
            <if test="vdef17 != null and vdef17 != ''"> and vdef17 = #{vdef17} </if>
            <if test="vdef18 != null and vdef18 != ''"> and vdef18 = #{vdef18} </if>
            <if test="vdef19 != null and vdef19 != ''"> and vdef19 = #{vdef19} </if>
            <if test="vdef2 != null and vdef2 != ''"> and vdef2 = #{vdef2} </if>
            <if test="vdef20 != null and vdef20 != ''"> and vdef20 = #{vdef20} </if>
            <if test="vdef3 != null and vdef3 != ''"> and vdef3 = #{vdef3} </if>
            <if test="vdef4 != null and vdef4 != ''"> and vdef4 = #{vdef4} </if>
            <if test="vdef5 != null and vdef5 != ''"> and vdef5 = #{vdef5} </if>
            <if test="vdef6 != null and vdef6 != ''"> and vdef6 = #{vdef6} </if>
            <if test="vdef7 != null and vdef7 != ''"> and vdef7 = #{vdef7} </if>
            <if test="vdef8 != null and vdef8 != ''"> and vdef8 = #{vdef8} </if>
            <if test="vdef9 != null and vdef9 != ''"> and vdef9 = #{vdef9} </if>
            <if test="veditreason != null and veditreason != ''"> and veditreason = #{veditreason} </if>
            <if test="vnote != null and vnote != ''"> and vnote = #{vnote} </if>
            <if test="vreceiptcode != null and vreceiptcode != ''"> and vreceiptcode = #{vreceiptcode} </if>
            <if test="vreceiveaddress != null and vreceiveaddress != ''"> and vreceiveaddress = #{vreceiveaddress} </if>
    </trim>
    <if test=" sort ==''.toString() "> order by sorts asc</if>
    <if test=" sort !='' and sort!=null and order !='' and order!=null "> order by ${sort} ${order}</if>
    </select>

    <!-- 分页查询列表 采用like格式 -->
<select id="entity_list_like" resultMap="get-SoSaleEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.SoSaleEntity">
    select
    <include refid="SoSaleEntity_Base_Column_List" />
    from so_sale
    <trim prefix="where" prefixOverrides="and"> 
        <if test="alrconfincomny != null and alrconfincomny != ''"> and alrconfincomny like concat('%',#{alrconfincomny},'%') </if>
            <if test="bcooptopo != null and bcooptopo != ''"> and bcooptopo like concat('%',#{bcooptopo},'%') </if>
            <if test="bfreecustflag != null and bfreecustflag != ''"> and bfreecustflag like concat('%',#{bfreecustflag},'%') </if>
            <if test="binitflag != null and binitflag != ''"> and binitflag like concat('%',#{binitflag},'%') </if>
            <if test="binvoicendflag != null and binvoicendflag != ''"> and binvoicendflag like concat('%',#{binvoicendflag},'%') </if>
            <if test="boutendflag != null and boutendflag != ''"> and boutendflag like concat('%',#{boutendflag},'%') </if>
            <if test="boverdate != null and boverdate != ''"> and boverdate like concat('%',#{boverdate},'%') </if>
            <if test="bpayendflag != null and bpayendflag != ''"> and bpayendflag like concat('%',#{bpayendflag},'%') </if>
            <if test="bpocooptome != null and bpocooptome != ''"> and bpocooptome like concat('%',#{bpocooptome},'%') </if>
            <if test="breceiptendflag != null and breceiptendflag != ''"> and breceiptendflag like concat('%',#{breceiptendflag},'%') </if>
            <if test="bretinvflag != null and bretinvflag != ''"> and bretinvflag like concat('%',#{bretinvflag},'%') </if>
            <if test="btransendflag != null and btransendflag != ''"> and btransendflag like concat('%',#{btransendflag},'%') </if>
            <if test="capproveid != null and capproveid != ''"> and capproveid like concat('%',#{capproveid},'%') </if>
            <if test="cbaltypeid != null and cbaltypeid != ''"> and cbaltypeid like concat('%',#{cbaltypeid},'%') </if>
            <if test="cbiztype != null and cbiztype != ''"> and cbiztype like concat('%',#{cbiztype},'%') </if>
            <if test="ccalbodyid != null and ccalbodyid != ''"> and ccalbodyid like concat('%',#{ccalbodyid},'%') </if>
            <if test="ccooppohid != null and ccooppohid != ''"> and ccooppohid like concat('%',#{ccooppohid},'%') </if>
            <if test="ccreditnum != null and ccreditnum != ''"> and ccreditnum like concat('%',#{ccreditnum},'%') </if>
            <if test="ccustbankid != null and ccustbankid != ''"> and ccustbankid like concat('%',#{ccustbankid},'%') </if>
            <if test="ccustomerid != null and ccustomerid != ''"> and ccustomerid like concat('%',#{ccustomerid},'%') </if>
            <if test="cdeptid != null and cdeptid != ''"> and cdeptid like concat('%',#{cdeptid},'%') </if>
            <if test="cemployeeid != null and cemployeeid != ''"> and cemployeeid like concat('%',#{cemployeeid},'%') </if>
            <if test="cfreecustid != null and cfreecustid != ''"> and cfreecustid like concat('%',#{cfreecustid},'%') </if>
            <if test="coperatorid != null and coperatorid != ''"> and coperatorid like concat('%',#{coperatorid},'%') </if>
            <if test="creceiptareaid != null and creceiptareaid != ''"> and creceiptareaid like concat('%',#{creceiptareaid},'%') </if>
            <if test="creceiptcorpid != null and creceiptcorpid != ''"> and creceiptcorpid like concat('%',#{creceiptcorpid},'%') </if>
            <if test="creceiptcustomerid != null and creceiptcustomerid != ''"> and creceiptcustomerid like concat('%',#{creceiptcustomerid},'%') </if>
            <if test="creceipttype != null and creceipttype != ''"> and creceipttype like concat('%',#{creceipttype},'%') </if>
            <if test="csalecorpid != null and csalecorpid != ''"> and csalecorpid like concat('%',#{csalecorpid},'%') </if>
            <if test="csaleid != null and csaleid != ''"> and csaleid like concat('%',#{csaleid},'%') </if>
            <if test="ctermprotocolid != null and ctermprotocolid != ''"> and ctermprotocolid like concat('%',#{ctermprotocolid},'%') </if>
            <if test="ctransmodeid != null and ctransmodeid != ''"> and ctransmodeid like concat('%',#{ctransmodeid},'%') </if>
            <if test="cwarehouseid != null and cwarehouseid != ''"> and cwarehouseid like concat('%',#{cwarehouseid},'%') </if>
            <if test="dapprovedate != null and dapprovedate != ''"> and dapprovedate like concat('%',#{dapprovedate},'%') </if>
            <if test="daudittime != null and daudittime != ''"> and daudittime like concat('%',#{daudittime},'%') </if>
            <if test="dbilldate != null and dbilldate != ''"> and dbilldate like concat('%',#{dbilldate},'%') </if>
            <if test="dbilltime != null and dbilltime != ''"> and dbilltime like concat('%',#{dbilltime},'%') </if>
            <if test="dmakedate != null and dmakedate != ''"> and dmakedate like concat('%',#{dmakedate},'%') </if>
            <if test="dmoditime != null and dmoditime != ''"> and dmoditime like concat('%',#{dmoditime},'%') </if>
            <if test="dr != null"> and dr like concat('%',#{dr},'%') </if>
            <if test="editauthor != null and editauthor != ''"> and editauthor like concat('%',#{editauthor},'%') </if>
            <if test="editdate != null and editdate != ''"> and editdate like concat('%',#{editdate},'%') </if>
            <if test="editionnum != null and editionnum != ''"> and editionnum like concat('%',#{editionnum},'%') </if>
            <if test="finvoiceclass != null"> and finvoiceclass like concat('%',#{finvoiceclass},'%') </if>
            <if test="finvoicetype != null"> and finvoicetype like concat('%',#{finvoicetype},'%') </if>
            <if test="fstatus != null"> and fstatus like concat('%',#{fstatus},'%') </if>
            <if test="ibalanceflag != null"> and ibalanceflag like concat('%',#{ibalanceflag},'%') </if>
            <if test="iprintcount != null"> and iprintcount like concat('%',#{iprintcount},'%') </if>
            <if test="naccountperiod != null and naccountperiod != ''"> and naccountperiod like concat('%',#{naccountperiod},'%') </if>
            <if test="ndiscountrate != null and ndiscountrate != ''"> and ndiscountrate like concat('%',#{ndiscountrate},'%') </if>
            <if test="nevaluatecarriage != null and nevaluatecarriage != ''"> and nevaluatecarriage like concat('%',#{nevaluatecarriage},'%') </if>
            <if test="nheadsummny != null and nheadsummny != ''"> and nheadsummny like concat('%',#{nheadsummny},'%') </if>
            <if test="npreceivemny != null and npreceivemny != ''"> and npreceivemny like concat('%',#{npreceivemny},'%') </if>
            <if test="npreceiverate != null and npreceiverate != ''"> and npreceiverate like concat('%',#{npreceiverate},'%') </if>
            <if test="nsubscription != null and nsubscription != ''"> and nsubscription like concat('%',#{nsubscription},'%') </if>
            <if test="ntotalnum != null and ntotalnum != ''"> and ntotalnum like concat('%',#{ntotalnum},'%') </if>
            <if test="pkCorp != null and pkCorp != ''"> and pk_corp like concat('%',#{pkCorp},'%') </if>
            <if test="pkDefdoc1 != null and pkDefdoc1 != ''"> and pk_defdoc1 like concat('%',#{pkDefdoc1},'%') </if>
            <if test="pkDefdoc10 != null and pkDefdoc10 != ''"> and pk_defdoc10 like concat('%',#{pkDefdoc10},'%') </if>
            <if test="pkDefdoc11 != null and pkDefdoc11 != ''"> and pk_defdoc11 like concat('%',#{pkDefdoc11},'%') </if>
            <if test="pkDefdoc12 != null and pkDefdoc12 != ''"> and pk_defdoc12 like concat('%',#{pkDefdoc12},'%') </if>
            <if test="pkDefdoc13 != null and pkDefdoc13 != ''"> and pk_defdoc13 like concat('%',#{pkDefdoc13},'%') </if>
            <if test="pkDefdoc14 != null and pkDefdoc14 != ''"> and pk_defdoc14 like concat('%',#{pkDefdoc14},'%') </if>
            <if test="pkDefdoc15 != null and pkDefdoc15 != ''"> and pk_defdoc15 like concat('%',#{pkDefdoc15},'%') </if>
            <if test="pkDefdoc16 != null and pkDefdoc16 != ''"> and pk_defdoc16 like concat('%',#{pkDefdoc16},'%') </if>
            <if test="pkDefdoc17 != null and pkDefdoc17 != ''"> and pk_defdoc17 like concat('%',#{pkDefdoc17},'%') </if>
            <if test="pkDefdoc18 != null and pkDefdoc18 != ''"> and pk_defdoc18 like concat('%',#{pkDefdoc18},'%') </if>
            <if test="pkDefdoc19 != null and pkDefdoc19 != ''"> and pk_defdoc19 like concat('%',#{pkDefdoc19},'%') </if>
            <if test="pkDefdoc2 != null and pkDefdoc2 != ''"> and pk_defdoc2 like concat('%',#{pkDefdoc2},'%') </if>
            <if test="pkDefdoc20 != null and pkDefdoc20 != ''"> and pk_defdoc20 like concat('%',#{pkDefdoc20},'%') </if>
            <if test="pkDefdoc3 != null and pkDefdoc3 != ''"> and pk_defdoc3 like concat('%',#{pkDefdoc3},'%') </if>
            <if test="pkDefdoc4 != null and pkDefdoc4 != ''"> and pk_defdoc4 like concat('%',#{pkDefdoc4},'%') </if>
            <if test="pkDefdoc5 != null and pkDefdoc5 != ''"> and pk_defdoc5 like concat('%',#{pkDefdoc5},'%') </if>
            <if test="pkDefdoc6 != null and pkDefdoc6 != ''"> and pk_defdoc6 like concat('%',#{pkDefdoc6},'%') </if>
            <if test="pkDefdoc7 != null and pkDefdoc7 != ''"> and pk_defdoc7 like concat('%',#{pkDefdoc7},'%') </if>
            <if test="pkDefdoc8 != null and pkDefdoc8 != ''"> and pk_defdoc8 like concat('%',#{pkDefdoc8},'%') </if>
            <if test="pkDefdoc9 != null and pkDefdoc9 != ''"> and pk_defdoc9 like concat('%',#{pkDefdoc9},'%') </if>
            <if test="srcoutsysflag != null"> and srcoutsysflag like concat('%',#{srcoutsysflag},'%') </if>
            <if test="transactionprice != null and transactionprice != ''"> and transactionprice like concat('%',#{transactionprice},'%') </if>
            <if test="ts != null and ts != ''"> and ts like concat('%',#{ts},'%') </if>
            <if test="vaccountyear != null and vaccountyear != ''"> and vaccountyear like concat('%',#{vaccountyear},'%') </if>
            <if test="vdef1 != null and vdef1 != ''"> and vdef1 like concat('%',#{vdef1},'%') </if>
            <if test="vdef10 != null and vdef10 != ''"> and vdef10 like concat('%',#{vdef10},'%') </if>
            <if test="vdef11 != null and vdef11 != ''"> and vdef11 like concat('%',#{vdef11},'%') </if>
            <if test="vdef12 != null and vdef12 != ''"> and vdef12 like concat('%',#{vdef12},'%') </if>
            <if test="vdef13 != null and vdef13 != ''"> and vdef13 like concat('%',#{vdef13},'%') </if>
            <if test="vdef14 != null and vdef14 != ''"> and vdef14 like concat('%',#{vdef14},'%') </if>
            <if test="vdef15 != null and vdef15 != ''"> and vdef15 like concat('%',#{vdef15},'%') </if>
            <if test="vdef16 != null and vdef16 != ''"> and vdef16 like concat('%',#{vdef16},'%') </if>
            <if test="vdef17 != null and vdef17 != ''"> and vdef17 like concat('%',#{vdef17},'%') </if>
            <if test="vdef18 != null and vdef18 != ''"> and vdef18 like concat('%',#{vdef18},'%') </if>
            <if test="vdef19 != null and vdef19 != ''"> and vdef19 like concat('%',#{vdef19},'%') </if>
            <if test="vdef2 != null and vdef2 != ''"> and vdef2 like concat('%',#{vdef2},'%') </if>
            <if test="vdef20 != null and vdef20 != ''"> and vdef20 like concat('%',#{vdef20},'%') </if>
            <if test="vdef3 != null and vdef3 != ''"> and vdef3 like concat('%',#{vdef3},'%') </if>
            <if test="vdef4 != null and vdef4 != ''"> and vdef4 like concat('%',#{vdef4},'%') </if>
            <if test="vdef5 != null and vdef5 != ''"> and vdef5 like concat('%',#{vdef5},'%') </if>
            <if test="vdef6 != null and vdef6 != ''"> and vdef6 like concat('%',#{vdef6},'%') </if>
            <if test="vdef7 != null and vdef7 != ''"> and vdef7 like concat('%',#{vdef7},'%') </if>
            <if test="vdef8 != null and vdef8 != ''"> and vdef8 like concat('%',#{vdef8},'%') </if>
            <if test="vdef9 != null and vdef9 != ''"> and vdef9 like concat('%',#{vdef9},'%') </if>
            <if test="veditreason != null and veditreason != ''"> and veditreason like concat('%',#{veditreason},'%') </if>
            <if test="vnote != null and vnote != ''"> and vnote like concat('%',#{vnote},'%') </if>
            <if test="vreceiptcode != null and vreceiptcode != ''"> and vreceiptcode like concat('%',#{vreceiptcode},'%') </if>
            <if test="vreceiveaddress != null and vreceiveaddress != ''"> and vreceiveaddress like concat('%',#{vreceiveaddress},'%') </if>
    </trim>
    <if test=" sort == ''.toString() "> order by sorts asc</if>
    <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>

<!-- 查询列表 字段采用or格式 -->
<select id="SoSaleentity_list_or" resultMap="get-SoSaleEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.SoSaleEntity">
    select
    <include refid="SoSaleEntity_Base_Column_List" />
    from so_sale
    <trim prefix="where" prefixOverrides="and"> 
         <if test="alrconfincomny != null and alrconfincomny != ''"> or alrconfincomny = #{alrconfincomny} </if>
             <if test="bcooptopo != null and bcooptopo != ''"> or bcooptopo = #{bcooptopo} </if>
             <if test="bfreecustflag != null and bfreecustflag != ''"> or bfreecustflag = #{bfreecustflag} </if>
             <if test="binitflag != null and binitflag != ''"> or binitflag = #{binitflag} </if>
             <if test="binvoicendflag != null and binvoicendflag != ''"> or binvoicendflag = #{binvoicendflag} </if>
             <if test="boutendflag != null and boutendflag != ''"> or boutendflag = #{boutendflag} </if>
             <if test="boverdate != null and boverdate != ''"> or boverdate = #{boverdate} </if>
             <if test="bpayendflag != null and bpayendflag != ''"> or bpayendflag = #{bpayendflag} </if>
             <if test="bpocooptome != null and bpocooptome != ''"> or bpocooptome = #{bpocooptome} </if>
             <if test="breceiptendflag != null and breceiptendflag != ''"> or breceiptendflag = #{breceiptendflag} </if>
             <if test="bretinvflag != null and bretinvflag != ''"> or bretinvflag = #{bretinvflag} </if>
             <if test="btransendflag != null and btransendflag != ''"> or btransendflag = #{btransendflag} </if>
             <if test="capproveid != null and capproveid != ''"> or capproveid = #{capproveid} </if>
             <if test="cbaltypeid != null and cbaltypeid != ''"> or cbaltypeid = #{cbaltypeid} </if>
             <if test="cbiztype != null and cbiztype != ''"> or cbiztype = #{cbiztype} </if>
             <if test="ccalbodyid != null and ccalbodyid != ''"> or ccalbodyid = #{ccalbodyid} </if>
             <if test="ccooppohid != null and ccooppohid != ''"> or ccooppohid = #{ccooppohid} </if>
             <if test="ccreditnum != null and ccreditnum != ''"> or ccreditnum = #{ccreditnum} </if>
             <if test="ccustbankid != null and ccustbankid != ''"> or ccustbankid = #{ccustbankid} </if>
             <if test="ccustomerid != null and ccustomerid != ''"> or ccustomerid = #{ccustomerid} </if>
             <if test="cdeptid != null and cdeptid != ''"> or cdeptid = #{cdeptid} </if>
             <if test="cemployeeid != null and cemployeeid != ''"> or cemployeeid = #{cemployeeid} </if>
             <if test="cfreecustid != null and cfreecustid != ''"> or cfreecustid = #{cfreecustid} </if>
             <if test="coperatorid != null and coperatorid != ''"> or coperatorid = #{coperatorid} </if>
             <if test="creceiptareaid != null and creceiptareaid != ''"> or creceiptareaid = #{creceiptareaid} </if>
             <if test="creceiptcorpid != null and creceiptcorpid != ''"> or creceiptcorpid = #{creceiptcorpid} </if>
             <if test="creceiptcustomerid != null and creceiptcustomerid != ''"> or creceiptcustomerid = #{creceiptcustomerid} </if>
             <if test="creceipttype != null and creceipttype != ''"> or creceipttype = #{creceipttype} </if>
             <if test="csalecorpid != null and csalecorpid != ''"> or csalecorpid = #{csalecorpid} </if>
             <if test="csaleid != null and csaleid != ''"> or csaleid = #{csaleid} </if>
             <if test="ctermprotocolid != null and ctermprotocolid != ''"> or ctermprotocolid = #{ctermprotocolid} </if>
             <if test="ctransmodeid != null and ctransmodeid != ''"> or ctransmodeid = #{ctransmodeid} </if>
             <if test="cwarehouseid != null and cwarehouseid != ''"> or cwarehouseid = #{cwarehouseid} </if>
             <if test="dapprovedate != null and dapprovedate != ''"> or dapprovedate = #{dapprovedate} </if>
             <if test="daudittime != null and daudittime != ''"> or daudittime = #{daudittime} </if>
             <if test="dbilldate != null and dbilldate != ''"> or dbilldate = #{dbilldate} </if>
             <if test="dbilltime != null and dbilltime != ''"> or dbilltime = #{dbilltime} </if>
             <if test="dmakedate != null and dmakedate != ''"> or dmakedate = #{dmakedate} </if>
             <if test="dmoditime != null and dmoditime != ''"> or dmoditime = #{dmoditime} </if>
             <if test="dr != null"> or dr = #{dr} </if>
             <if test="editauthor != null and editauthor != ''"> or editauthor = #{editauthor} </if>
             <if test="editdate != null and editdate != ''"> or editdate = #{editdate} </if>
             <if test="editionnum != null and editionnum != ''"> or editionnum = #{editionnum} </if>
             <if test="finvoiceclass != null"> or finvoiceclass = #{finvoiceclass} </if>
             <if test="finvoicetype != null"> or finvoicetype = #{finvoicetype} </if>
             <if test="fstatus != null"> or fstatus = #{fstatus} </if>
             <if test="ibalanceflag != null"> or ibalanceflag = #{ibalanceflag} </if>
             <if test="iprintcount != null"> or iprintcount = #{iprintcount} </if>
             <if test="naccountperiod != null and naccountperiod != ''"> or naccountperiod = #{naccountperiod} </if>
             <if test="ndiscountrate != null and ndiscountrate != ''"> or ndiscountrate = #{ndiscountrate} </if>
             <if test="nevaluatecarriage != null and nevaluatecarriage != ''"> or nevaluatecarriage = #{nevaluatecarriage} </if>
             <if test="nheadsummny != null and nheadsummny != ''"> or nheadsummny = #{nheadsummny} </if>
             <if test="npreceivemny != null and npreceivemny != ''"> or npreceivemny = #{npreceivemny} </if>
             <if test="npreceiverate != null and npreceiverate != ''"> or npreceiverate = #{npreceiverate} </if>
             <if test="nsubscription != null and nsubscription != ''"> or nsubscription = #{nsubscription} </if>
             <if test="ntotalnum != null and ntotalnum != ''"> or ntotalnum = #{ntotalnum} </if>
             <if test="pkCorp != null and pkCorp != ''"> or pk_corp = #{pkCorp} </if>
             <if test="pkDefdoc1 != null and pkDefdoc1 != ''"> or pk_defdoc1 = #{pkDefdoc1} </if>
             <if test="pkDefdoc10 != null and pkDefdoc10 != ''"> or pk_defdoc10 = #{pkDefdoc10} </if>
             <if test="pkDefdoc11 != null and pkDefdoc11 != ''"> or pk_defdoc11 = #{pkDefdoc11} </if>
             <if test="pkDefdoc12 != null and pkDefdoc12 != ''"> or pk_defdoc12 = #{pkDefdoc12} </if>
             <if test="pkDefdoc13 != null and pkDefdoc13 != ''"> or pk_defdoc13 = #{pkDefdoc13} </if>
             <if test="pkDefdoc14 != null and pkDefdoc14 != ''"> or pk_defdoc14 = #{pkDefdoc14} </if>
             <if test="pkDefdoc15 != null and pkDefdoc15 != ''"> or pk_defdoc15 = #{pkDefdoc15} </if>
             <if test="pkDefdoc16 != null and pkDefdoc16 != ''"> or pk_defdoc16 = #{pkDefdoc16} </if>
             <if test="pkDefdoc17 != null and pkDefdoc17 != ''"> or pk_defdoc17 = #{pkDefdoc17} </if>
             <if test="pkDefdoc18 != null and pkDefdoc18 != ''"> or pk_defdoc18 = #{pkDefdoc18} </if>
             <if test="pkDefdoc19 != null and pkDefdoc19 != ''"> or pk_defdoc19 = #{pkDefdoc19} </if>
             <if test="pkDefdoc2 != null and pkDefdoc2 != ''"> or pk_defdoc2 = #{pkDefdoc2} </if>
             <if test="pkDefdoc20 != null and pkDefdoc20 != ''"> or pk_defdoc20 = #{pkDefdoc20} </if>
             <if test="pkDefdoc3 != null and pkDefdoc3 != ''"> or pk_defdoc3 = #{pkDefdoc3} </if>
             <if test="pkDefdoc4 != null and pkDefdoc4 != ''"> or pk_defdoc4 = #{pkDefdoc4} </if>
             <if test="pkDefdoc5 != null and pkDefdoc5 != ''"> or pk_defdoc5 = #{pkDefdoc5} </if>
             <if test="pkDefdoc6 != null and pkDefdoc6 != ''"> or pk_defdoc6 = #{pkDefdoc6} </if>
             <if test="pkDefdoc7 != null and pkDefdoc7 != ''"> or pk_defdoc7 = #{pkDefdoc7} </if>
             <if test="pkDefdoc8 != null and pkDefdoc8 != ''"> or pk_defdoc8 = #{pkDefdoc8} </if>
             <if test="pkDefdoc9 != null and pkDefdoc9 != ''"> or pk_defdoc9 = #{pkDefdoc9} </if>
             <if test="srcoutsysflag != null"> or srcoutsysflag = #{srcoutsysflag} </if>
             <if test="transactionprice != null and transactionprice != ''"> or transactionprice = #{transactionprice} </if>
             <if test="ts != null and ts != ''"> or ts = #{ts} </if>
             <if test="vaccountyear != null and vaccountyear != ''"> or vaccountyear = #{vaccountyear} </if>
             <if test="vdef1 != null and vdef1 != ''"> or vdef1 = #{vdef1} </if>
             <if test="vdef10 != null and vdef10 != ''"> or vdef10 = #{vdef10} </if>
             <if test="vdef11 != null and vdef11 != ''"> or vdef11 = #{vdef11} </if>
             <if test="vdef12 != null and vdef12 != ''"> or vdef12 = #{vdef12} </if>
             <if test="vdef13 != null and vdef13 != ''"> or vdef13 = #{vdef13} </if>
             <if test="vdef14 != null and vdef14 != ''"> or vdef14 = #{vdef14} </if>
             <if test="vdef15 != null and vdef15 != ''"> or vdef15 = #{vdef15} </if>
             <if test="vdef16 != null and vdef16 != ''"> or vdef16 = #{vdef16} </if>
             <if test="vdef17 != null and vdef17 != ''"> or vdef17 = #{vdef17} </if>
             <if test="vdef18 != null and vdef18 != ''"> or vdef18 = #{vdef18} </if>
             <if test="vdef19 != null and vdef19 != ''"> or vdef19 = #{vdef19} </if>
             <if test="vdef2 != null and vdef2 != ''"> or vdef2 = #{vdef2} </if>
             <if test="vdef20 != null and vdef20 != ''"> or vdef20 = #{vdef20} </if>
             <if test="vdef3 != null and vdef3 != ''"> or vdef3 = #{vdef3} </if>
             <if test="vdef4 != null and vdef4 != ''"> or vdef4 = #{vdef4} </if>
             <if test="vdef5 != null and vdef5 != ''"> or vdef5 = #{vdef5} </if>
             <if test="vdef6 != null and vdef6 != ''"> or vdef6 = #{vdef6} </if>
             <if test="vdef7 != null and vdef7 != ''"> or vdef7 = #{vdef7} </if>
             <if test="vdef8 != null and vdef8 != ''"> or vdef8 = #{vdef8} </if>
             <if test="vdef9 != null and vdef9 != ''"> or vdef9 = #{vdef9} </if>
             <if test="veditreason != null and veditreason != ''"> or veditreason = #{veditreason} </if>
             <if test="vnote != null and vnote != ''"> or vnote = #{vnote} </if>
             <if test="vreceiptcode != null and vreceiptcode != ''"> or vreceiptcode = #{vreceiptcode} </if>
             <if test="vreceiveaddress != null and vreceiveaddress != ''"> or vreceiveaddress = #{vreceiveaddress} </if>
    </trim>
    <if test=" sort == ''.toString() "> order by sorts asc</if>
    <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>

<!--新增所有列-->
<insert id="entity_insert" parameterType = "com.hzya.frame.plugin.lets.entity.SoSaleEntity" keyProperty="csaleid" useGeneratedKeys="true">
    insert into so_sale(
  <trim suffix="" suffixOverrides=",">
       <if test="alrconfincomny != null and alrconfincomny != ''"> alrconfincomny , </if>
            <if test="bcooptopo != null and bcooptopo != ''"> bcooptopo , </if>
            <if test="bfreecustflag != null and bfreecustflag != ''"> bfreecustflag , </if>
            <if test="binitflag != null and binitflag != ''"> binitflag , </if>
            <if test="binvoicendflag != null and binvoicendflag != ''"> binvoicendflag , </if>
            <if test="boutendflag != null and boutendflag != ''"> boutendflag , </if>
            <if test="boverdate != null and boverdate != ''"> boverdate , </if>
            <if test="bpayendflag != null and bpayendflag != ''"> bpayendflag , </if>
            <if test="bpocooptome != null and bpocooptome != ''"> bpocooptome , </if>
            <if test="breceiptendflag != null and breceiptendflag != ''"> breceiptendflag , </if>
            <if test="bretinvflag != null and bretinvflag != ''"> bretinvflag , </if>
            <if test="btransendflag != null and btransendflag != ''"> btransendflag , </if>
            <if test="capproveid != null and capproveid != ''"> capproveid , </if>
            <if test="cbaltypeid != null and cbaltypeid != ''"> cbaltypeid , </if>
            <if test="cbiztype != null and cbiztype != ''"> cbiztype , </if>
            <if test="ccalbodyid != null and ccalbodyid != ''"> ccalbodyid , </if>
            <if test="ccooppohid != null and ccooppohid != ''"> ccooppohid , </if>
            <if test="ccreditnum != null and ccreditnum != ''"> ccreditnum , </if>
            <if test="ccustbankid != null and ccustbankid != ''"> ccustbankid , </if>
            <if test="ccustomerid != null and ccustomerid != ''"> ccustomerid , </if>
            <if test="cdeptid != null and cdeptid != ''"> cdeptid , </if>
            <if test="cemployeeid != null and cemployeeid != ''"> cemployeeid , </if>
            <if test="cfreecustid != null and cfreecustid != ''"> cfreecustid , </if>
            <if test="coperatorid != null and coperatorid != ''"> coperatorid , </if>
            <if test="creceiptareaid != null and creceiptareaid != ''"> creceiptareaid , </if>
            <if test="creceiptcorpid != null and creceiptcorpid != ''"> creceiptcorpid , </if>
            <if test="creceiptcustomerid != null and creceiptcustomerid != ''"> creceiptcustomerid , </if>
            <if test="creceipttype != null and creceipttype != ''"> creceipttype , </if>
            <if test="csalecorpid != null and csalecorpid != ''"> csalecorpid , </if>
            <if test="csaleid != null and csaleid != ''"> csaleid , </if>
            <if test="ctermprotocolid != null and ctermprotocolid != ''"> ctermprotocolid , </if>
            <if test="ctransmodeid != null and ctransmodeid != ''"> ctransmodeid , </if>
            <if test="cwarehouseid != null and cwarehouseid != ''"> cwarehouseid , </if>
            <if test="dapprovedate != null and dapprovedate != ''"> dapprovedate , </if>
            <if test="daudittime != null and daudittime != ''"> daudittime , </if>
            <if test="dbilldate != null and dbilldate != ''"> dbilldate , </if>
            <if test="dbilltime != null and dbilltime != ''"> dbilltime , </if>
            <if test="dmakedate != null and dmakedate != ''"> dmakedate , </if>
            <if test="dmoditime != null and dmoditime != ''"> dmoditime , </if>
            <if test="dr != null"> dr , </if>
            <if test="editauthor != null and editauthor != ''"> editauthor , </if>
            <if test="editdate != null and editdate != ''"> editdate , </if>
            <if test="editionnum != null and editionnum != ''"> editionnum , </if>
            <if test="finvoiceclass != null"> finvoiceclass , </if>
            <if test="finvoicetype != null"> finvoicetype , </if>
            <if test="fstatus != null"> fstatus , </if>
            <if test="ibalanceflag != null"> ibalanceflag , </if>
            <if test="iprintcount != null"> iprintcount , </if>
            <if test="naccountperiod != null and naccountperiod != ''"> naccountperiod , </if>
            <if test="ndiscountrate != null and ndiscountrate != ''"> ndiscountrate , </if>
            <if test="nevaluatecarriage != null and nevaluatecarriage != ''"> nevaluatecarriage , </if>
            <if test="nheadsummny != null and nheadsummny != ''"> nheadsummny , </if>
            <if test="npreceivemny != null and npreceivemny != ''"> npreceivemny , </if>
            <if test="npreceiverate != null and npreceiverate != ''"> npreceiverate , </if>
            <if test="nsubscription != null and nsubscription != ''"> nsubscription , </if>
            <if test="ntotalnum != null and ntotalnum != ''"> ntotalnum , </if>
            <if test="pkCorp != null and pkCorp != ''"> pk_corp , </if>
            <if test="pkDefdoc1 != null and pkDefdoc1 != ''"> pk_defdoc1 , </if>
            <if test="pkDefdoc10 != null and pkDefdoc10 != ''"> pk_defdoc10 , </if>
            <if test="pkDefdoc11 != null and pkDefdoc11 != ''"> pk_defdoc11 , </if>
            <if test="pkDefdoc12 != null and pkDefdoc12 != ''"> pk_defdoc12 , </if>
            <if test="pkDefdoc13 != null and pkDefdoc13 != ''"> pk_defdoc13 , </if>
            <if test="pkDefdoc14 != null and pkDefdoc14 != ''"> pk_defdoc14 , </if>
            <if test="pkDefdoc15 != null and pkDefdoc15 != ''"> pk_defdoc15 , </if>
            <if test="pkDefdoc16 != null and pkDefdoc16 != ''"> pk_defdoc16 , </if>
            <if test="pkDefdoc17 != null and pkDefdoc17 != ''"> pk_defdoc17 , </if>
            <if test="pkDefdoc18 != null and pkDefdoc18 != ''"> pk_defdoc18 , </if>
            <if test="pkDefdoc19 != null and pkDefdoc19 != ''"> pk_defdoc19 , </if>
            <if test="pkDefdoc2 != null and pkDefdoc2 != ''"> pk_defdoc2 , </if>
            <if test="pkDefdoc20 != null and pkDefdoc20 != ''"> pk_defdoc20 , </if>
            <if test="pkDefdoc3 != null and pkDefdoc3 != ''"> pk_defdoc3 , </if>
            <if test="pkDefdoc4 != null and pkDefdoc4 != ''"> pk_defdoc4 , </if>
            <if test="pkDefdoc5 != null and pkDefdoc5 != ''"> pk_defdoc5 , </if>
            <if test="pkDefdoc6 != null and pkDefdoc6 != ''"> pk_defdoc6 , </if>
            <if test="pkDefdoc7 != null and pkDefdoc7 != ''"> pk_defdoc7 , </if>
            <if test="pkDefdoc8 != null and pkDefdoc8 != ''"> pk_defdoc8 , </if>
            <if test="pkDefdoc9 != null and pkDefdoc9 != ''"> pk_defdoc9 , </if>
            <if test="srcoutsysflag != null"> srcoutsysflag , </if>
            <if test="transactionprice != null and transactionprice != ''"> transactionprice , </if>
            <if test="ts != null and ts != ''"> ts , </if>
            <if test="vaccountyear != null and vaccountyear != ''"> vaccountyear , </if>
            <if test="vdef1 != null and vdef1 != ''"> vdef1 , </if>
            <if test="vdef10 != null and vdef10 != ''"> vdef10 , </if>
            <if test="vdef11 != null and vdef11 != ''"> vdef11 , </if>
            <if test="vdef12 != null and vdef12 != ''"> vdef12 , </if>
            <if test="vdef13 != null and vdef13 != ''"> vdef13 , </if>
            <if test="vdef14 != null and vdef14 != ''"> vdef14 , </if>
            <if test="vdef15 != null and vdef15 != ''"> vdef15 , </if>
            <if test="vdef16 != null and vdef16 != ''"> vdef16 , </if>
            <if test="vdef17 != null and vdef17 != ''"> vdef17 , </if>
            <if test="vdef18 != null and vdef18 != ''"> vdef18 , </if>
            <if test="vdef19 != null and vdef19 != ''"> vdef19 , </if>
            <if test="vdef2 != null and vdef2 != ''"> vdef2 , </if>
            <if test="vdef20 != null and vdef20 != ''"> vdef20 , </if>
            <if test="vdef3 != null and vdef3 != ''"> vdef3 , </if>
            <if test="vdef4 != null and vdef4 != ''"> vdef4 , </if>
            <if test="vdef5 != null and vdef5 != ''"> vdef5 , </if>
            <if test="vdef6 != null and vdef6 != ''"> vdef6 , </if>
            <if test="vdef7 != null and vdef7 != ''"> vdef7 , </if>
            <if test="vdef8 != null and vdef8 != ''"> vdef8 , </if>
            <if test="vdef9 != null and vdef9 != ''"> vdef9 , </if>
            <if test="veditreason != null and veditreason != ''"> veditreason , </if>
            <if test="vnote != null and vnote != ''"> vnote , </if>
            <if test="vreceiptcode != null and vreceiptcode != ''"> vreceiptcode , </if>
            <if test="vreceiveaddress != null and vreceiveaddress != ''"> vreceiveaddress , </if>
            <if test="sorts == null ">sorts,</if>
    <if test="sts == null ">sts,</if>
  </trim>
  )values(
 <trim suffix="" suffixOverrides=",">
       <if test="alrconfincomny != null and alrconfincomny != ''"> #{alrconfincomny} ,</if>
            <if test="bcooptopo != null and bcooptopo != ''"> #{bcooptopo} ,</if>
            <if test="bfreecustflag != null and bfreecustflag != ''"> #{bfreecustflag} ,</if>
            <if test="binitflag != null and binitflag != ''"> #{binitflag} ,</if>
            <if test="binvoicendflag != null and binvoicendflag != ''"> #{binvoicendflag} ,</if>
            <if test="boutendflag != null and boutendflag != ''"> #{boutendflag} ,</if>
            <if test="boverdate != null and boverdate != ''"> #{boverdate} ,</if>
            <if test="bpayendflag != null and bpayendflag != ''"> #{bpayendflag} ,</if>
            <if test="bpocooptome != null and bpocooptome != ''"> #{bpocooptome} ,</if>
            <if test="breceiptendflag != null and breceiptendflag != ''"> #{breceiptendflag} ,</if>
            <if test="bretinvflag != null and bretinvflag != ''"> #{bretinvflag} ,</if>
            <if test="btransendflag != null and btransendflag != ''"> #{btransendflag} ,</if>
            <if test="capproveid != null and capproveid != ''"> #{capproveid} ,</if>
            <if test="cbaltypeid != null and cbaltypeid != ''"> #{cbaltypeid} ,</if>
            <if test="cbiztype != null and cbiztype != ''"> #{cbiztype} ,</if>
            <if test="ccalbodyid != null and ccalbodyid != ''"> #{ccalbodyid} ,</if>
            <if test="ccooppohid != null and ccooppohid != ''"> #{ccooppohid} ,</if>
            <if test="ccreditnum != null and ccreditnum != ''"> #{ccreditnum} ,</if>
            <if test="ccustbankid != null and ccustbankid != ''"> #{ccustbankid} ,</if>
            <if test="ccustomerid != null and ccustomerid != ''"> #{ccustomerid} ,</if>
            <if test="cdeptid != null and cdeptid != ''"> #{cdeptid} ,</if>
            <if test="cemployeeid != null and cemployeeid != ''"> #{cemployeeid} ,</if>
            <if test="cfreecustid != null and cfreecustid != ''"> #{cfreecustid} ,</if>
            <if test="coperatorid != null and coperatorid != ''"> #{coperatorid} ,</if>
            <if test="creceiptareaid != null and creceiptareaid != ''"> #{creceiptareaid} ,</if>
            <if test="creceiptcorpid != null and creceiptcorpid != ''"> #{creceiptcorpid} ,</if>
            <if test="creceiptcustomerid != null and creceiptcustomerid != ''"> #{creceiptcustomerid} ,</if>
            <if test="creceipttype != null and creceipttype != ''"> #{creceipttype} ,</if>
            <if test="csalecorpid != null and csalecorpid != ''"> #{csalecorpid} ,</if>
            <if test="csaleid != null and csaleid != ''"> #{csaleid} ,</if>
            <if test="ctermprotocolid != null and ctermprotocolid != ''"> #{ctermprotocolid} ,</if>
            <if test="ctransmodeid != null and ctransmodeid != ''"> #{ctransmodeid} ,</if>
            <if test="cwarehouseid != null and cwarehouseid != ''"> #{cwarehouseid} ,</if>
            <if test="dapprovedate != null and dapprovedate != ''"> #{dapprovedate} ,</if>
            <if test="daudittime != null and daudittime != ''"> #{daudittime} ,</if>
            <if test="dbilldate != null and dbilldate != ''"> #{dbilldate} ,</if>
            <if test="dbilltime != null and dbilltime != ''"> #{dbilltime} ,</if>
            <if test="dmakedate != null and dmakedate != ''"> #{dmakedate} ,</if>
            <if test="dmoditime != null and dmoditime != ''"> #{dmoditime} ,</if>
            <if test="dr != null"> #{dr} ,</if>
            <if test="editauthor != null and editauthor != ''"> #{editauthor} ,</if>
            <if test="editdate != null and editdate != ''"> #{editdate} ,</if>
            <if test="editionnum != null and editionnum != ''"> #{editionnum} ,</if>
            <if test="finvoiceclass != null"> #{finvoiceclass} ,</if>
            <if test="finvoicetype != null"> #{finvoicetype} ,</if>
            <if test="fstatus != null"> #{fstatus} ,</if>
            <if test="ibalanceflag != null"> #{ibalanceflag} ,</if>
            <if test="iprintcount != null"> #{iprintcount} ,</if>
            <if test="naccountperiod != null and naccountperiod != ''"> #{naccountperiod} ,</if>
            <if test="ndiscountrate != null and ndiscountrate != ''"> #{ndiscountrate} ,</if>
            <if test="nevaluatecarriage != null and nevaluatecarriage != ''"> #{nevaluatecarriage} ,</if>
            <if test="nheadsummny != null and nheadsummny != ''"> #{nheadsummny} ,</if>
            <if test="npreceivemny != null and npreceivemny != ''"> #{npreceivemny} ,</if>
            <if test="npreceiverate != null and npreceiverate != ''"> #{npreceiverate} ,</if>
            <if test="nsubscription != null and nsubscription != ''"> #{nsubscription} ,</if>
            <if test="ntotalnum != null and ntotalnum != ''"> #{ntotalnum} ,</if>
            <if test="pkCorp != null and pkCorp != ''"> #{pkCorp} ,</if>
            <if test="pkDefdoc1 != null and pkDefdoc1 != ''"> #{pkDefdoc1} ,</if>
            <if test="pkDefdoc10 != null and pkDefdoc10 != ''"> #{pkDefdoc10} ,</if>
            <if test="pkDefdoc11 != null and pkDefdoc11 != ''"> #{pkDefdoc11} ,</if>
            <if test="pkDefdoc12 != null and pkDefdoc12 != ''"> #{pkDefdoc12} ,</if>
            <if test="pkDefdoc13 != null and pkDefdoc13 != ''"> #{pkDefdoc13} ,</if>
            <if test="pkDefdoc14 != null and pkDefdoc14 != ''"> #{pkDefdoc14} ,</if>
            <if test="pkDefdoc15 != null and pkDefdoc15 != ''"> #{pkDefdoc15} ,</if>
            <if test="pkDefdoc16 != null and pkDefdoc16 != ''"> #{pkDefdoc16} ,</if>
            <if test="pkDefdoc17 != null and pkDefdoc17 != ''"> #{pkDefdoc17} ,</if>
            <if test="pkDefdoc18 != null and pkDefdoc18 != ''"> #{pkDefdoc18} ,</if>
            <if test="pkDefdoc19 != null and pkDefdoc19 != ''"> #{pkDefdoc19} ,</if>
            <if test="pkDefdoc2 != null and pkDefdoc2 != ''"> #{pkDefdoc2} ,</if>
            <if test="pkDefdoc20 != null and pkDefdoc20 != ''"> #{pkDefdoc20} ,</if>
            <if test="pkDefdoc3 != null and pkDefdoc3 != ''"> #{pkDefdoc3} ,</if>
            <if test="pkDefdoc4 != null and pkDefdoc4 != ''"> #{pkDefdoc4} ,</if>
            <if test="pkDefdoc5 != null and pkDefdoc5 != ''"> #{pkDefdoc5} ,</if>
            <if test="pkDefdoc6 != null and pkDefdoc6 != ''"> #{pkDefdoc6} ,</if>
            <if test="pkDefdoc7 != null and pkDefdoc7 != ''"> #{pkDefdoc7} ,</if>
            <if test="pkDefdoc8 != null and pkDefdoc8 != ''"> #{pkDefdoc8} ,</if>
            <if test="pkDefdoc9 != null and pkDefdoc9 != ''"> #{pkDefdoc9} ,</if>
            <if test="srcoutsysflag != null"> #{srcoutsysflag} ,</if>
            <if test="transactionprice != null and transactionprice != ''"> #{transactionprice} ,</if>
            <if test="ts != null and ts != ''"> #{ts} ,</if>
            <if test="vaccountyear != null and vaccountyear != ''"> #{vaccountyear} ,</if>
            <if test="vdef1 != null and vdef1 != ''"> #{vdef1} ,</if>
            <if test="vdef10 != null and vdef10 != ''"> #{vdef10} ,</if>
            <if test="vdef11 != null and vdef11 != ''"> #{vdef11} ,</if>
            <if test="vdef12 != null and vdef12 != ''"> #{vdef12} ,</if>
            <if test="vdef13 != null and vdef13 != ''"> #{vdef13} ,</if>
            <if test="vdef14 != null and vdef14 != ''"> #{vdef14} ,</if>
            <if test="vdef15 != null and vdef15 != ''"> #{vdef15} ,</if>
            <if test="vdef16 != null and vdef16 != ''"> #{vdef16} ,</if>
            <if test="vdef17 != null and vdef17 != ''"> #{vdef17} ,</if>
            <if test="vdef18 != null and vdef18 != ''"> #{vdef18} ,</if>
            <if test="vdef19 != null and vdef19 != ''"> #{vdef19} ,</if>
            <if test="vdef2 != null and vdef2 != ''"> #{vdef2} ,</if>
            <if test="vdef20 != null and vdef20 != ''"> #{vdef20} ,</if>
            <if test="vdef3 != null and vdef3 != ''"> #{vdef3} ,</if>
            <if test="vdef4 != null and vdef4 != ''"> #{vdef4} ,</if>
            <if test="vdef5 != null and vdef5 != ''"> #{vdef5} ,</if>
            <if test="vdef6 != null and vdef6 != ''"> #{vdef6} ,</if>
            <if test="vdef7 != null and vdef7 != ''"> #{vdef7} ,</if>
            <if test="vdef8 != null and vdef8 != ''"> #{vdef8} ,</if>
            <if test="vdef9 != null and vdef9 != ''"> #{vdef9} ,</if>
            <if test="veditreason != null and veditreason != ''"> #{veditreason} ,</if>
            <if test="vnote != null and vnote != ''"> #{vnote} ,</if>
            <if test="vreceiptcode != null and vreceiptcode != ''"> #{vreceiptcode} ,</if>
            <if test="vreceiveaddress != null and vreceiveaddress != ''"> #{vreceiveaddress} ,</if>
            <if test="sorts == null ">(select (max(IFNULL( a.sorts, 0 )) + 1) as sort from so_sale a WHERE a.sts = 'Y' ),</if>
    <if test="sts == null ">'Y',</if>
  </trim>
  )  
</insert>
<!-- 批量新增 -->
<insert id="entityInsertBatch" keyProperty="csaleid" useGeneratedKeys="true">
  insert into so_sale(alrconfincomny, bcooptopo, bfreecustflag, binitflag, binvoicendflag, boutendflag, boverdate, bpayendflag, bpocooptome, breceiptendflag, bretinvflag, btransendflag, capproveid, cbaltypeid, cbiztype, ccalbodyid, ccooppohid, ccreditnum, ccustbankid, ccustomerid, cdeptid, cemployeeid, cfreecustid, coperatorid, creceiptareaid, creceiptcorpid, creceiptcustomerid, creceipttype, csalecorpid, ctermprotocolid, ctransmodeid, cwarehouseid, dapprovedate, daudittime, dbilldate, dbilltime, dmakedate, dmoditime, dr, editauthor, editdate, editionnum, finvoiceclass, finvoicetype, fstatus, ibalanceflag, iprintcount, naccountperiod, ndiscountrate, nevaluatecarriage, nheadsummny, npreceivemny, npreceiverate, nsubscription, ntotalnum, pk_corp, pk_defdoc1, pk_defdoc10, pk_defdoc11, pk_defdoc12, pk_defdoc13, pk_defdoc14, pk_defdoc15, pk_defdoc16, pk_defdoc17, pk_defdoc18, pk_defdoc19, pk_defdoc2, pk_defdoc20, pk_defdoc3, pk_defdoc4, pk_defdoc5, pk_defdoc6, pk_defdoc7, pk_defdoc8, pk_defdoc9, srcoutsysflag, transactionprice, ts, vaccountyear, vdef1, vdef10, vdef11, vdef12, vdef13, vdef14, vdef15, vdef16, vdef17, vdef18, vdef19, vdef2, vdef20, vdef3, vdef4, vdef5, vdef6, vdef7, vdef8, vdef9, veditreason, vnote, vreceiptcode, vreceiveaddress,  sts) 
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.alrconfincomny},#{entity.bcooptopo},#{entity.bfreecustflag},#{entity.binitflag},#{entity.binvoicendflag},#{entity.boutendflag},#{entity.boverdate},#{entity.bpayendflag},#{entity.bpocooptome},#{entity.breceiptendflag},#{entity.bretinvflag},#{entity.btransendflag},#{entity.capproveid},#{entity.cbaltypeid},#{entity.cbiztype},#{entity.ccalbodyid},#{entity.ccooppohid},#{entity.ccreditnum},#{entity.ccustbankid},#{entity.ccustomerid},#{entity.cdeptid},#{entity.cemployeeid},#{entity.cfreecustid},#{entity.coperatorid},#{entity.creceiptareaid},#{entity.creceiptcorpid},#{entity.creceiptcustomerid},#{entity.creceipttype},#{entity.csalecorpid},#{entity.ctermprotocolid},#{entity.ctransmodeid},#{entity.cwarehouseid},#{entity.dapprovedate},#{entity.daudittime},#{entity.dbilldate},#{entity.dbilltime},#{entity.dmakedate},#{entity.dmoditime},#{entity.dr},#{entity.editauthor},#{entity.editdate},#{entity.editionnum},#{entity.finvoiceclass},#{entity.finvoicetype},#{entity.fstatus},#{entity.ibalanceflag},#{entity.iprintcount},#{entity.naccountperiod},#{entity.ndiscountrate},#{entity.nevaluatecarriage},#{entity.nheadsummny},#{entity.npreceivemny},#{entity.npreceiverate},#{entity.nsubscription},#{entity.ntotalnum},#{entity.pkCorp},#{entity.pkDefdoc1},#{entity.pkDefdoc10},#{entity.pkDefdoc11},#{entity.pkDefdoc12},#{entity.pkDefdoc13},#{entity.pkDefdoc14},#{entity.pkDefdoc15},#{entity.pkDefdoc16},#{entity.pkDefdoc17},#{entity.pkDefdoc18},#{entity.pkDefdoc19},#{entity.pkDefdoc2},#{entity.pkDefdoc20},#{entity.pkDefdoc3},#{entity.pkDefdoc4},#{entity.pkDefdoc5},#{entity.pkDefdoc6},#{entity.pkDefdoc7},#{entity.pkDefdoc8},#{entity.pkDefdoc9},#{entity.srcoutsysflag},#{entity.transactionprice},#{entity.ts},#{entity.vaccountyear},#{entity.vdef1},#{entity.vdef10},#{entity.vdef11},#{entity.vdef12},#{entity.vdef13},#{entity.vdef14},#{entity.vdef15},#{entity.vdef16},#{entity.vdef17},#{entity.vdef18},#{entity.vdef19},#{entity.vdef2},#{entity.vdef20},#{entity.vdef3},#{entity.vdef4},#{entity.vdef5},#{entity.vdef6},#{entity.vdef7},#{entity.vdef8},#{entity.vdef9},#{entity.veditreason},#{entity.vnote},#{entity.vreceiptcode},#{entity.vreceiveaddress}, 'Y')
    </foreach>
</insert>
<!-- 批量新增或者修改-->
<insert id="entityInsertOrUpdateBatch" keyProperty="csaleid" useGeneratedKeys="true">
    insert into so_sale(alrconfincomny, bcooptopo, bfreecustflag, binitflag, binvoicendflag, boutendflag, boverdate, bpayendflag, bpocooptome, breceiptendflag, bretinvflag, btransendflag, capproveid, cbaltypeid, cbiztype, ccalbodyid, ccooppohid, ccreditnum, ccustbankid, ccustomerid, cdeptid, cemployeeid, cfreecustid, coperatorid, creceiptareaid, creceiptcorpid, creceiptcustomerid, creceipttype, csalecorpid, ctermprotocolid, ctransmodeid, cwarehouseid, dapprovedate, daudittime, dbilldate, dbilltime, dmakedate, dmoditime, dr, editauthor, editdate, editionnum, finvoiceclass, finvoicetype, fstatus, ibalanceflag, iprintcount, naccountperiod, ndiscountrate, nevaluatecarriage, nheadsummny, npreceivemny, npreceiverate, nsubscription, ntotalnum, pk_corp, pk_defdoc1, pk_defdoc10, pk_defdoc11, pk_defdoc12, pk_defdoc13, pk_defdoc14, pk_defdoc15, pk_defdoc16, pk_defdoc17, pk_defdoc18, pk_defdoc19, pk_defdoc2, pk_defdoc20, pk_defdoc3, pk_defdoc4, pk_defdoc5, pk_defdoc6, pk_defdoc7, pk_defdoc8, pk_defdoc9, srcoutsysflag, transactionprice, ts, vaccountyear, vdef1, vdef10, vdef11, vdef12, vdef13, vdef14, vdef15, vdef16, vdef17, vdef18, vdef19, vdef2, vdef20, vdef3, vdef4, vdef5, vdef6, vdef7, vdef8, vdef9, veditreason, vnote, vreceiptcode, vreceiveaddress)
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.alrconfincomny},#{entity.bcooptopo},#{entity.bfreecustflag},#{entity.binitflag},#{entity.binvoicendflag},#{entity.boutendflag},#{entity.boverdate},#{entity.bpayendflag},#{entity.bpocooptome},#{entity.breceiptendflag},#{entity.bretinvflag},#{entity.btransendflag},#{entity.capproveid},#{entity.cbaltypeid},#{entity.cbiztype},#{entity.ccalbodyid},#{entity.ccooppohid},#{entity.ccreditnum},#{entity.ccustbankid},#{entity.ccustomerid},#{entity.cdeptid},#{entity.cemployeeid},#{entity.cfreecustid},#{entity.coperatorid},#{entity.creceiptareaid},#{entity.creceiptcorpid},#{entity.creceiptcustomerid},#{entity.creceipttype},#{entity.csalecorpid},#{entity.ctermprotocolid},#{entity.ctransmodeid},#{entity.cwarehouseid},#{entity.dapprovedate},#{entity.daudittime},#{entity.dbilldate},#{entity.dbilltime},#{entity.dmakedate},#{entity.dmoditime},#{entity.dr},#{entity.editauthor},#{entity.editdate},#{entity.editionnum},#{entity.finvoiceclass},#{entity.finvoicetype},#{entity.fstatus},#{entity.ibalanceflag},#{entity.iprintcount},#{entity.naccountperiod},#{entity.ndiscountrate},#{entity.nevaluatecarriage},#{entity.nheadsummny},#{entity.npreceivemny},#{entity.npreceiverate},#{entity.nsubscription},#{entity.ntotalnum},#{entity.pkCorp},#{entity.pkDefdoc1},#{entity.pkDefdoc10},#{entity.pkDefdoc11},#{entity.pkDefdoc12},#{entity.pkDefdoc13},#{entity.pkDefdoc14},#{entity.pkDefdoc15},#{entity.pkDefdoc16},#{entity.pkDefdoc17},#{entity.pkDefdoc18},#{entity.pkDefdoc19},#{entity.pkDefdoc2},#{entity.pkDefdoc20},#{entity.pkDefdoc3},#{entity.pkDefdoc4},#{entity.pkDefdoc5},#{entity.pkDefdoc6},#{entity.pkDefdoc7},#{entity.pkDefdoc8},#{entity.pkDefdoc9},#{entity.srcoutsysflag},#{entity.transactionprice},#{entity.ts},#{entity.vaccountyear},#{entity.vdef1},#{entity.vdef10},#{entity.vdef11},#{entity.vdef12},#{entity.vdef13},#{entity.vdef14},#{entity.vdef15},#{entity.vdef16},#{entity.vdef17},#{entity.vdef18},#{entity.vdef19},#{entity.vdef2},#{entity.vdef20},#{entity.vdef3},#{entity.vdef4},#{entity.vdef5},#{entity.vdef6},#{entity.vdef7},#{entity.vdef8},#{entity.vdef9},#{entity.veditreason},#{entity.vnote},#{entity.vreceiptcode},#{entity.vreceiveaddress})
    </foreach>
    on duplicate key update
    alrconfincomny = values(alrconfincomny),
    bcooptopo = values(bcooptopo),
    bfreecustflag = values(bfreecustflag),
    binitflag = values(binitflag),
    binvoicendflag = values(binvoicendflag),
    boutendflag = values(boutendflag),
    boverdate = values(boverdate),
    bpayendflag = values(bpayendflag),
    bpocooptome = values(bpocooptome),
    breceiptendflag = values(breceiptendflag),
    bretinvflag = values(bretinvflag),
    btransendflag = values(btransendflag),
    capproveid = values(capproveid),
    cbaltypeid = values(cbaltypeid),
    cbiztype = values(cbiztype),
    ccalbodyid = values(ccalbodyid),
    ccooppohid = values(ccooppohid),
    ccreditnum = values(ccreditnum),
    ccustbankid = values(ccustbankid),
    ccustomerid = values(ccustomerid),
    cdeptid = values(cdeptid),
    cemployeeid = values(cemployeeid),
    cfreecustid = values(cfreecustid),
    coperatorid = values(coperatorid),
    creceiptareaid = values(creceiptareaid),
    creceiptcorpid = values(creceiptcorpid),
    creceiptcustomerid = values(creceiptcustomerid),
    creceipttype = values(creceipttype),
    csalecorpid = values(csalecorpid),
    ctermprotocolid = values(ctermprotocolid),
    ctransmodeid = values(ctransmodeid),
    cwarehouseid = values(cwarehouseid),
    dapprovedate = values(dapprovedate),
    daudittime = values(daudittime),
    dbilldate = values(dbilldate),
    dbilltime = values(dbilltime),
    dmakedate = values(dmakedate),
    dmoditime = values(dmoditime),
    dr = values(dr),
    editauthor = values(editauthor),
    editdate = values(editdate),
    editionnum = values(editionnum),
    finvoiceclass = values(finvoiceclass),
    finvoicetype = values(finvoicetype),
    fstatus = values(fstatus),
    ibalanceflag = values(ibalanceflag),
    iprintcount = values(iprintcount),
    naccountperiod = values(naccountperiod),
    ndiscountrate = values(ndiscountrate),
    nevaluatecarriage = values(nevaluatecarriage),
    nheadsummny = values(nheadsummny),
    npreceivemny = values(npreceivemny),
    npreceiverate = values(npreceiverate),
    nsubscription = values(nsubscription),
    ntotalnum = values(ntotalnum),
    pk_corp = values(pk_corp),
    pk_defdoc1 = values(pk_defdoc1),
    pk_defdoc10 = values(pk_defdoc10),
    pk_defdoc11 = values(pk_defdoc11),
    pk_defdoc12 = values(pk_defdoc12),
    pk_defdoc13 = values(pk_defdoc13),
    pk_defdoc14 = values(pk_defdoc14),
    pk_defdoc15 = values(pk_defdoc15),
    pk_defdoc16 = values(pk_defdoc16),
    pk_defdoc17 = values(pk_defdoc17),
    pk_defdoc18 = values(pk_defdoc18),
    pk_defdoc19 = values(pk_defdoc19),
    pk_defdoc2 = values(pk_defdoc2),
    pk_defdoc20 = values(pk_defdoc20),
    pk_defdoc3 = values(pk_defdoc3),
    pk_defdoc4 = values(pk_defdoc4),
    pk_defdoc5 = values(pk_defdoc5),
    pk_defdoc6 = values(pk_defdoc6),
    pk_defdoc7 = values(pk_defdoc7),
    pk_defdoc8 = values(pk_defdoc8),
    pk_defdoc9 = values(pk_defdoc9),
    srcoutsysflag = values(srcoutsysflag),
    transactionprice = values(transactionprice),
    ts = values(ts),
    vaccountyear = values(vaccountyear),
    vdef1 = values(vdef1),
    vdef10 = values(vdef10),
    vdef11 = values(vdef11),
    vdef12 = values(vdef12),
    vdef13 = values(vdef13),
    vdef14 = values(vdef14),
    vdef15 = values(vdef15),
    vdef16 = values(vdef16),
    vdef17 = values(vdef17),
    vdef18 = values(vdef18),
    vdef19 = values(vdef19),
    vdef2 = values(vdef2),
    vdef20 = values(vdef20),
    vdef3 = values(vdef3),
    vdef4 = values(vdef4),
    vdef5 = values(vdef5),
    vdef6 = values(vdef6),
    vdef7 = values(vdef7),
    vdef8 = values(vdef8),
    vdef9 = values(vdef9),
    veditreason = values(veditreason),
    vnote = values(vnote),
    vreceiptcode = values(vreceiptcode),
    vreceiveaddress = values(vreceiveaddress)</insert>
<!--通过主键修改方法-->
<update id="entity_update" parameterType = "com.hzya.frame.plugin.lets.entity.SoSaleEntity" >
update so_sale  set
<trim suffix="" suffixOverrides=",">
  <if test="alrconfincomny != null and alrconfincomny != ''"> alrconfincomny = #{alrconfincomny},</if>
  <if test="bcooptopo != null and bcooptopo != ''"> bcooptopo = #{bcooptopo},</if>
  <if test="bfreecustflag != null and bfreecustflag != ''"> bfreecustflag = #{bfreecustflag},</if>
  <if test="binitflag != null and binitflag != ''"> binitflag = #{binitflag},</if>
  <if test="binvoicendflag != null and binvoicendflag != ''"> binvoicendflag = #{binvoicendflag},</if>
  <if test="boutendflag != null and boutendflag != ''"> boutendflag = #{boutendflag},</if>
  <if test="boverdate != null and boverdate != ''"> boverdate = #{boverdate},</if>
  <if test="bpayendflag != null and bpayendflag != ''"> bpayendflag = #{bpayendflag},</if>
  <if test="bpocooptome != null and bpocooptome != ''"> bpocooptome = #{bpocooptome},</if>
  <if test="breceiptendflag != null and breceiptendflag != ''"> breceiptendflag = #{breceiptendflag},</if>
  <if test="bretinvflag != null and bretinvflag != ''"> bretinvflag = #{bretinvflag},</if>
  <if test="btransendflag != null and btransendflag != ''"> btransendflag = #{btransendflag},</if>
  <if test="capproveid != null and capproveid != ''"> capproveid = #{capproveid},</if>
  <if test="cbaltypeid != null and cbaltypeid != ''"> cbaltypeid = #{cbaltypeid},</if>
  <if test="cbiztype != null and cbiztype != ''"> cbiztype = #{cbiztype},</if>
  <if test="ccalbodyid != null and ccalbodyid != ''"> ccalbodyid = #{ccalbodyid},</if>
  <if test="ccooppohid != null and ccooppohid != ''"> ccooppohid = #{ccooppohid},</if>
  <if test="ccreditnum != null and ccreditnum != ''"> ccreditnum = #{ccreditnum},</if>
  <if test="ccustbankid != null and ccustbankid != ''"> ccustbankid = #{ccustbankid},</if>
  <if test="ccustomerid != null and ccustomerid != ''"> ccustomerid = #{ccustomerid},</if>
  <if test="cdeptid != null and cdeptid != ''"> cdeptid = #{cdeptid},</if>
  <if test="cemployeeid != null and cemployeeid != ''"> cemployeeid = #{cemployeeid},</if>
  <if test="cfreecustid != null and cfreecustid != ''"> cfreecustid = #{cfreecustid},</if>
  <if test="coperatorid != null and coperatorid != ''"> coperatorid = #{coperatorid},</if>
  <if test="creceiptareaid != null and creceiptareaid != ''"> creceiptareaid = #{creceiptareaid},</if>
  <if test="creceiptcorpid != null and creceiptcorpid != ''"> creceiptcorpid = #{creceiptcorpid},</if>
  <if test="creceiptcustomerid != null and creceiptcustomerid != ''"> creceiptcustomerid = #{creceiptcustomerid},</if>
  <if test="creceipttype != null and creceipttype != ''"> creceipttype = #{creceipttype},</if>
  <if test="csalecorpid != null and csalecorpid != ''"> csalecorpid = #{csalecorpid},</if>
  <if test="ctermprotocolid != null and ctermprotocolid != ''"> ctermprotocolid = #{ctermprotocolid},</if>
  <if test="ctransmodeid != null and ctransmodeid != ''"> ctransmodeid = #{ctransmodeid},</if>
  <if test="cwarehouseid != null and cwarehouseid != ''"> cwarehouseid = #{cwarehouseid},</if>
  <if test="dapprovedate != null and dapprovedate != ''"> dapprovedate = #{dapprovedate},</if>
  <if test="daudittime != null and daudittime != ''"> daudittime = #{daudittime},</if>
  <if test="dbilldate != null and dbilldate != ''"> dbilldate = #{dbilldate},</if>
  <if test="dbilltime != null and dbilltime != ''"> dbilltime = #{dbilltime},</if>
  <if test="dmakedate != null and dmakedate != ''"> dmakedate = #{dmakedate},</if>
  <if test="dmoditime != null and dmoditime != ''"> dmoditime = #{dmoditime},</if>
  <if test="dr != null"> dr = #{dr},</if>
  <if test="editauthor != null and editauthor != ''"> editauthor = #{editauthor},</if>
  <if test="editdate != null and editdate != ''"> editdate = #{editdate},</if>
  <if test="editionnum != null and editionnum != ''"> editionnum = #{editionnum},</if>
  <if test="finvoiceclass != null"> finvoiceclass = #{finvoiceclass},</if>
  <if test="finvoicetype != null"> finvoicetype = #{finvoicetype},</if>
  <if test="fstatus != null"> fstatus = #{fstatus},</if>
  <if test="ibalanceflag != null"> ibalanceflag = #{ibalanceflag},</if>
  <if test="iprintcount != null"> iprintcount = #{iprintcount},</if>
  <if test="naccountperiod != null and naccountperiod != ''"> naccountperiod = #{naccountperiod},</if>
  <if test="ndiscountrate != null and ndiscountrate != ''"> ndiscountrate = #{ndiscountrate},</if>
  <if test="nevaluatecarriage != null and nevaluatecarriage != ''"> nevaluatecarriage = #{nevaluatecarriage},</if>
  <if test="nheadsummny != null and nheadsummny != ''"> nheadsummny = #{nheadsummny},</if>
  <if test="npreceivemny != null and npreceivemny != ''"> npreceivemny = #{npreceivemny},</if>
  <if test="npreceiverate != null and npreceiverate != ''"> npreceiverate = #{npreceiverate},</if>
  <if test="nsubscription != null and nsubscription != ''"> nsubscription = #{nsubscription},</if>
  <if test="ntotalnum != null and ntotalnum != ''"> ntotalnum = #{ntotalnum},</if>
  <if test="pkCorp != null and pkCorp != ''"> pk_corp = #{pkCorp},</if>
  <if test="pkDefdoc1 != null and pkDefdoc1 != ''"> pk_defdoc1 = #{pkDefdoc1},</if>
  <if test="pkDefdoc10 != null and pkDefdoc10 != ''"> pk_defdoc10 = #{pkDefdoc10},</if>
  <if test="pkDefdoc11 != null and pkDefdoc11 != ''"> pk_defdoc11 = #{pkDefdoc11},</if>
  <if test="pkDefdoc12 != null and pkDefdoc12 != ''"> pk_defdoc12 = #{pkDefdoc12},</if>
  <if test="pkDefdoc13 != null and pkDefdoc13 != ''"> pk_defdoc13 = #{pkDefdoc13},</if>
  <if test="pkDefdoc14 != null and pkDefdoc14 != ''"> pk_defdoc14 = #{pkDefdoc14},</if>
  <if test="pkDefdoc15 != null and pkDefdoc15 != ''"> pk_defdoc15 = #{pkDefdoc15},</if>
  <if test="pkDefdoc16 != null and pkDefdoc16 != ''"> pk_defdoc16 = #{pkDefdoc16},</if>
  <if test="pkDefdoc17 != null and pkDefdoc17 != ''"> pk_defdoc17 = #{pkDefdoc17},</if>
  <if test="pkDefdoc18 != null and pkDefdoc18 != ''"> pk_defdoc18 = #{pkDefdoc18},</if>
  <if test="pkDefdoc19 != null and pkDefdoc19 != ''"> pk_defdoc19 = #{pkDefdoc19},</if>
  <if test="pkDefdoc2 != null and pkDefdoc2 != ''"> pk_defdoc2 = #{pkDefdoc2},</if>
  <if test="pkDefdoc20 != null and pkDefdoc20 != ''"> pk_defdoc20 = #{pkDefdoc20},</if>
  <if test="pkDefdoc3 != null and pkDefdoc3 != ''"> pk_defdoc3 = #{pkDefdoc3},</if>
  <if test="pkDefdoc4 != null and pkDefdoc4 != ''"> pk_defdoc4 = #{pkDefdoc4},</if>
  <if test="pkDefdoc5 != null and pkDefdoc5 != ''"> pk_defdoc5 = #{pkDefdoc5},</if>
  <if test="pkDefdoc6 != null and pkDefdoc6 != ''"> pk_defdoc6 = #{pkDefdoc6},</if>
  <if test="pkDefdoc7 != null and pkDefdoc7 != ''"> pk_defdoc7 = #{pkDefdoc7},</if>
  <if test="pkDefdoc8 != null and pkDefdoc8 != ''"> pk_defdoc8 = #{pkDefdoc8},</if>
  <if test="pkDefdoc9 != null and pkDefdoc9 != ''"> pk_defdoc9 = #{pkDefdoc9},</if>
  <if test="srcoutsysflag != null"> srcoutsysflag = #{srcoutsysflag},</if>
  <if test="transactionprice != null and transactionprice != ''"> transactionprice = #{transactionprice},</if>
  <if test="ts != null and ts != ''"> ts = #{ts},</if>
  <if test="vaccountyear != null and vaccountyear != ''"> vaccountyear = #{vaccountyear},</if>
  <if test="vdef1 != null and vdef1 != ''"> vdef1 = #{vdef1},</if>
  <if test="vdef10 != null and vdef10 != ''"> vdef10 = #{vdef10},</if>
  <if test="vdef11 != null and vdef11 != ''"> vdef11 = #{vdef11},</if>
  <if test="vdef12 != null and vdef12 != ''"> vdef12 = #{vdef12},</if>
  <if test="vdef13 != null and vdef13 != ''"> vdef13 = #{vdef13},</if>
  <if test="vdef14 != null and vdef14 != ''"> vdef14 = #{vdef14},</if>
  <if test="vdef15 != null and vdef15 != ''"> vdef15 = #{vdef15},</if>
  <if test="vdef16 != null and vdef16 != ''"> vdef16 = #{vdef16},</if>
  <if test="vdef17 != null and vdef17 != ''"> vdef17 = #{vdef17},</if>
  <if test="vdef18 != null and vdef18 != ''"> vdef18 = #{vdef18},</if>
  <if test="vdef19 != null and vdef19 != ''"> vdef19 = #{vdef19},</if>
  <if test="vdef2 != null and vdef2 != ''"> vdef2 = #{vdef2},</if>
  <if test="vdef20 != null and vdef20 != ''"> vdef20 = #{vdef20},</if>
  <if test="vdef3 != null and vdef3 != ''"> vdef3 = #{vdef3},</if>
  <if test="vdef4 != null and vdef4 != ''"> vdef4 = #{vdef4},</if>
  <if test="vdef5 != null and vdef5 != ''"> vdef5 = #{vdef5},</if>
  <if test="vdef6 != null and vdef6 != ''"> vdef6 = #{vdef6},</if>
  <if test="vdef7 != null and vdef7 != ''"> vdef7 = #{vdef7},</if>
  <if test="vdef8 != null and vdef8 != ''"> vdef8 = #{vdef8},</if>
  <if test="vdef9 != null and vdef9 != ''"> vdef9 = #{vdef9},</if>
  <if test="veditreason != null and veditreason != ''"> veditreason = #{veditreason},</if>
  <if test="vnote != null and vnote != ''"> vnote = #{vnote},</if>
  <if test="vreceiptcode != null and vreceiptcode != ''"> vreceiptcode = #{vreceiptcode},</if>
  <if test="vreceiveaddress != null and vreceiveaddress != ''"> vreceiveaddress = #{vreceiveaddress},</if>
</trim>
where csaleid = #{csaleid}
</update>
<!-- 逻辑删除 -->
<update id="entity_logicDelete" parameterType = "com.hzya.frame.plugin.lets.entity.SoSaleEntity" >
update so_sale  set sts= 'N'
where csaleid = #{csaleid}
</update>
<!-- 多条件逻辑删除 -->
<update id="entity_logicDelete_Multi_Condition" parameterType = "com.hzya.frame.plugin.lets.entity.SoSaleEntity" >
update so_sale  set sts= 'N' 
 <trim prefix="where" prefixOverrides="and"> 
        <if test="alrconfincomny != null and alrconfincomny != ''"> and alrconfincomny = #{alrconfincomny} </if>
            <if test="bcooptopo != null and bcooptopo != ''"> and bcooptopo = #{bcooptopo} </if>
            <if test="bfreecustflag != null and bfreecustflag != ''"> and bfreecustflag = #{bfreecustflag} </if>
            <if test="binitflag != null and binitflag != ''"> and binitflag = #{binitflag} </if>
            <if test="binvoicendflag != null and binvoicendflag != ''"> and binvoicendflag = #{binvoicendflag} </if>
            <if test="boutendflag != null and boutendflag != ''"> and boutendflag = #{boutendflag} </if>
            <if test="boverdate != null and boverdate != ''"> and boverdate = #{boverdate} </if>
            <if test="bpayendflag != null and bpayendflag != ''"> and bpayendflag = #{bpayendflag} </if>
            <if test="bpocooptome != null and bpocooptome != ''"> and bpocooptome = #{bpocooptome} </if>
            <if test="breceiptendflag != null and breceiptendflag != ''"> and breceiptendflag = #{breceiptendflag} </if>
            <if test="bretinvflag != null and bretinvflag != ''"> and bretinvflag = #{bretinvflag} </if>
            <if test="btransendflag != null and btransendflag != ''"> and btransendflag = #{btransendflag} </if>
            <if test="capproveid != null and capproveid != ''"> and capproveid = #{capproveid} </if>
            <if test="cbaltypeid != null and cbaltypeid != ''"> and cbaltypeid = #{cbaltypeid} </if>
            <if test="cbiztype != null and cbiztype != ''"> and cbiztype = #{cbiztype} </if>
            <if test="ccalbodyid != null and ccalbodyid != ''"> and ccalbodyid = #{ccalbodyid} </if>
            <if test="ccooppohid != null and ccooppohid != ''"> and ccooppohid = #{ccooppohid} </if>
            <if test="ccreditnum != null and ccreditnum != ''"> and ccreditnum = #{ccreditnum} </if>
            <if test="ccustbankid != null and ccustbankid != ''"> and ccustbankid = #{ccustbankid} </if>
            <if test="ccustomerid != null and ccustomerid != ''"> and ccustomerid = #{ccustomerid} </if>
            <if test="cdeptid != null and cdeptid != ''"> and cdeptid = #{cdeptid} </if>
            <if test="cemployeeid != null and cemployeeid != ''"> and cemployeeid = #{cemployeeid} </if>
            <if test="cfreecustid != null and cfreecustid != ''"> and cfreecustid = #{cfreecustid} </if>
            <if test="coperatorid != null and coperatorid != ''"> and coperatorid = #{coperatorid} </if>
            <if test="creceiptareaid != null and creceiptareaid != ''"> and creceiptareaid = #{creceiptareaid} </if>
            <if test="creceiptcorpid != null and creceiptcorpid != ''"> and creceiptcorpid = #{creceiptcorpid} </if>
            <if test="creceiptcustomerid != null and creceiptcustomerid != ''"> and creceiptcustomerid = #{creceiptcustomerid} </if>
            <if test="creceipttype != null and creceipttype != ''"> and creceipttype = #{creceipttype} </if>
            <if test="csalecorpid != null and csalecorpid != ''"> and csalecorpid = #{csalecorpid} </if>
            <if test="csaleid != null and csaleid != ''"> and csaleid = #{csaleid} </if>
            <if test="ctermprotocolid != null and ctermprotocolid != ''"> and ctermprotocolid = #{ctermprotocolid} </if>
            <if test="ctransmodeid != null and ctransmodeid != ''"> and ctransmodeid = #{ctransmodeid} </if>
            <if test="cwarehouseid != null and cwarehouseid != ''"> and cwarehouseid = #{cwarehouseid} </if>
            <if test="dapprovedate != null and dapprovedate != ''"> and dapprovedate = #{dapprovedate} </if>
            <if test="daudittime != null and daudittime != ''"> and daudittime = #{daudittime} </if>
            <if test="dbilldate != null and dbilldate != ''"> and dbilldate = #{dbilldate} </if>
            <if test="dbilltime != null and dbilltime != ''"> and dbilltime = #{dbilltime} </if>
            <if test="dmakedate != null and dmakedate != ''"> and dmakedate = #{dmakedate} </if>
            <if test="dmoditime != null and dmoditime != ''"> and dmoditime = #{dmoditime} </if>
            <if test="dr != null"> and dr = #{dr} </if>
            <if test="editauthor != null and editauthor != ''"> and editauthor = #{editauthor} </if>
            <if test="editdate != null and editdate != ''"> and editdate = #{editdate} </if>
            <if test="editionnum != null and editionnum != ''"> and editionnum = #{editionnum} </if>
            <if test="finvoiceclass != null"> and finvoiceclass = #{finvoiceclass} </if>
            <if test="finvoicetype != null"> and finvoicetype = #{finvoicetype} </if>
            <if test="fstatus != null"> and fstatus = #{fstatus} </if>
            <if test="ibalanceflag != null"> and ibalanceflag = #{ibalanceflag} </if>
            <if test="iprintcount != null"> and iprintcount = #{iprintcount} </if>
            <if test="naccountperiod != null and naccountperiod != ''"> and naccountperiod = #{naccountperiod} </if>
            <if test="ndiscountrate != null and ndiscountrate != ''"> and ndiscountrate = #{ndiscountrate} </if>
            <if test="nevaluatecarriage != null and nevaluatecarriage != ''"> and nevaluatecarriage = #{nevaluatecarriage} </if>
            <if test="nheadsummny != null and nheadsummny != ''"> and nheadsummny = #{nheadsummny} </if>
            <if test="npreceivemny != null and npreceivemny != ''"> and npreceivemny = #{npreceivemny} </if>
            <if test="npreceiverate != null and npreceiverate != ''"> and npreceiverate = #{npreceiverate} </if>
            <if test="nsubscription != null and nsubscription != ''"> and nsubscription = #{nsubscription} </if>
            <if test="ntotalnum != null and ntotalnum != ''"> and ntotalnum = #{ntotalnum} </if>
            <if test="pkCorp != null and pkCorp != ''"> and pk_corp = #{pkCorp} </if>
            <if test="pkDefdoc1 != null and pkDefdoc1 != ''"> and pk_defdoc1 = #{pkDefdoc1} </if>
            <if test="pkDefdoc10 != null and pkDefdoc10 != ''"> and pk_defdoc10 = #{pkDefdoc10} </if>
            <if test="pkDefdoc11 != null and pkDefdoc11 != ''"> and pk_defdoc11 = #{pkDefdoc11} </if>
            <if test="pkDefdoc12 != null and pkDefdoc12 != ''"> and pk_defdoc12 = #{pkDefdoc12} </if>
            <if test="pkDefdoc13 != null and pkDefdoc13 != ''"> and pk_defdoc13 = #{pkDefdoc13} </if>
            <if test="pkDefdoc14 != null and pkDefdoc14 != ''"> and pk_defdoc14 = #{pkDefdoc14} </if>
            <if test="pkDefdoc15 != null and pkDefdoc15 != ''"> and pk_defdoc15 = #{pkDefdoc15} </if>
            <if test="pkDefdoc16 != null and pkDefdoc16 != ''"> and pk_defdoc16 = #{pkDefdoc16} </if>
            <if test="pkDefdoc17 != null and pkDefdoc17 != ''"> and pk_defdoc17 = #{pkDefdoc17} </if>
            <if test="pkDefdoc18 != null and pkDefdoc18 != ''"> and pk_defdoc18 = #{pkDefdoc18} </if>
            <if test="pkDefdoc19 != null and pkDefdoc19 != ''"> and pk_defdoc19 = #{pkDefdoc19} </if>
            <if test="pkDefdoc2 != null and pkDefdoc2 != ''"> and pk_defdoc2 = #{pkDefdoc2} </if>
            <if test="pkDefdoc20 != null and pkDefdoc20 != ''"> and pk_defdoc20 = #{pkDefdoc20} </if>
            <if test="pkDefdoc3 != null and pkDefdoc3 != ''"> and pk_defdoc3 = #{pkDefdoc3} </if>
            <if test="pkDefdoc4 != null and pkDefdoc4 != ''"> and pk_defdoc4 = #{pkDefdoc4} </if>
            <if test="pkDefdoc5 != null and pkDefdoc5 != ''"> and pk_defdoc5 = #{pkDefdoc5} </if>
            <if test="pkDefdoc6 != null and pkDefdoc6 != ''"> and pk_defdoc6 = #{pkDefdoc6} </if>
            <if test="pkDefdoc7 != null and pkDefdoc7 != ''"> and pk_defdoc7 = #{pkDefdoc7} </if>
            <if test="pkDefdoc8 != null and pkDefdoc8 != ''"> and pk_defdoc8 = #{pkDefdoc8} </if>
            <if test="pkDefdoc9 != null and pkDefdoc9 != ''"> and pk_defdoc9 = #{pkDefdoc9} </if>
            <if test="srcoutsysflag != null"> and srcoutsysflag = #{srcoutsysflag} </if>
            <if test="transactionprice != null and transactionprice != ''"> and transactionprice = #{transactionprice} </if>
            <if test="ts != null and ts != ''"> and ts = #{ts} </if>
            <if test="vaccountyear != null and vaccountyear != ''"> and vaccountyear = #{vaccountyear} </if>
            <if test="vdef1 != null and vdef1 != ''"> and vdef1 = #{vdef1} </if>
            <if test="vdef10 != null and vdef10 != ''"> and vdef10 = #{vdef10} </if>
            <if test="vdef11 != null and vdef11 != ''"> and vdef11 = #{vdef11} </if>
            <if test="vdef12 != null and vdef12 != ''"> and vdef12 = #{vdef12} </if>
            <if test="vdef13 != null and vdef13 != ''"> and vdef13 = #{vdef13} </if>
            <if test="vdef14 != null and vdef14 != ''"> and vdef14 = #{vdef14} </if>
            <if test="vdef15 != null and vdef15 != ''"> and vdef15 = #{vdef15} </if>
            <if test="vdef16 != null and vdef16 != ''"> and vdef16 = #{vdef16} </if>
            <if test="vdef17 != null and vdef17 != ''"> and vdef17 = #{vdef17} </if>
            <if test="vdef18 != null and vdef18 != ''"> and vdef18 = #{vdef18} </if>
            <if test="vdef19 != null and vdef19 != ''"> and vdef19 = #{vdef19} </if>
            <if test="vdef2 != null and vdef2 != ''"> and vdef2 = #{vdef2} </if>
            <if test="vdef20 != null and vdef20 != ''"> and vdef20 = #{vdef20} </if>
            <if test="vdef3 != null and vdef3 != ''"> and vdef3 = #{vdef3} </if>
            <if test="vdef4 != null and vdef4 != ''"> and vdef4 = #{vdef4} </if>
            <if test="vdef5 != null and vdef5 != ''"> and vdef5 = #{vdef5} </if>
            <if test="vdef6 != null and vdef6 != ''"> and vdef6 = #{vdef6} </if>
            <if test="vdef7 != null and vdef7 != ''"> and vdef7 = #{vdef7} </if>
            <if test="vdef8 != null and vdef8 != ''"> and vdef8 = #{vdef8} </if>
            <if test="vdef9 != null and vdef9 != ''"> and vdef9 = #{vdef9} </if>
            <if test="veditreason != null and veditreason != ''"> and veditreason = #{veditreason} </if>
            <if test="vnote != null and vnote != ''"> and vnote = #{vnote} </if>
            <if test="vreceiptcode != null and vreceiptcode != ''"> and vreceiptcode = #{vreceiptcode} </if>
            <if test="vreceiveaddress != null and vreceiveaddress != ''"> and vreceiveaddress = #{vreceiveaddress} </if>
            and sts='Y'
    </trim>
</update>
<!--通过主键删除-->
<delete id="entity_delete">
    delete from so_sale where csaleid = #{csaleid}
</delete>

<!--    查询U8C销售订单-->
    <select id="querySoSaleEntity" parameterType="com.hzya.frame.plugin.lets.entity.SoSaleEntity" resultMap="get-SoSaleEntity-result">
        select <include refid="SoSaleEntity_Base_Column_List" /> from so_sale where dr = 0
        <if test="fstatus!=null and fstatus!=''">
            and fstatus = #{fstatus}
        </if>
        <if test="start_daudittime!=null and start_daudittime!=''">
            and daudittime >= #{start_daudittime}
        </if>
        <if test="end_daudittime!=null and end_daudittime!=''">
            and daudittime &lt;= #{end_daudittime}
        </if>
        <if test="daudittime!=null and daudittime!=''">
            and SUBSTRING(daudittime,1,10) = #{daudittime}
        </if>
        <if test="vreceiptcode!=null and vreceiptcode!=''">
            and vreceiptcode = #{vreceiptcode}
        </if>
        <if test="csaleid!=null and csaleid!=''">
            and csaleid = #{csaleid}
        </if>
        <if test="cbiztypes!=null and cbiztypes!=''">
            and cbiztype in (${cbiztypes})
        </if>
        <if test="bretinvflag!=null and bretinvflag!=''">
            and bretinvflag = #{bretinvflag}
        </if>
    </select>


    <resultMap id="queryQuantityHandResultMap" type="com.hzya.frame.plugin.lets.u8cdto.QuantityHandResultDto">
        <result column="cfreezeid" property="cfreezeid" jdbcType="VARCHAR" />
        <result column="pk_corp" property="pk_corp" jdbcType="VARCHAR" />
        <result column="ccalbodyid" property="ccalbodyid" jdbcType="VARCHAR" />
        <result column="cwarehouseid" property="cwarehouseid" jdbcType="VARCHAR" />
        <result column="cinventoryid" property="cinventoryid" jdbcType="VARCHAR" />
        <result column="pk_invbasdoc" property="pk_invbasdoc" jdbcType="VARCHAR" />
        <result column="num" property="num" jdbcType="DECIMAL" />
        <result column="freezenum" property="freezenum" jdbcType="VARCHAR" />
        <result column="ngrossnum" property="ngrossnum" jdbcType="DECIMAL" />
        <result column="nfreezegrossnum" property="nfreezegrossnum" jdbcType="VARCHAR" />
    </resultMap>
    
    <select id="queryQuantityHand" parameterType="com.hzya.frame.plugin.lets.u8cdto.QuantityHandDto" resultMap="queryQuantityHandResultMap">
        SELECT
        *
        FROM
        (
        SELECT
        cfreezeid,
        a.pk_corp ,
        a.ccalbodyid ,
        a.cwarehouseid ,
        a.cinventoryid ,
        a.cinvbasid AS pk_invbasdoc,
        a.num ,
        b.freezenum ,
        a.ngrossnum ,
        b.ngrossnum AS nfreezegrossnum
        FROM
        (
        SELECT
        kp.pk_corp ,
        kp.ccalbodyid ,
        kp.cwarehouseid ,
        kp.cinventoryid ,
        kp.cinvbasid ,
        SUM ( COALESCE ( ninspacenum, 0.0 ) ) - SUM ( COALESCE ( noutspacenum, 0.0 ) ) AS num,
        SUM ( COALESCE ( ningrossnum, 0.0 ) - COALESCE ( noutgrossnum, 0.0 ) ) AS ngrossnum
        FROM
        v_ic_onhandnum6 kp
        INNER JOIN bd_stordoc st ON kp.cwarehouseid = st.pk_stordoc
        AND st.isdirectstore = 'N'
        LEFT OUTER JOIN bd_stordoc wh1 ON kp.cwarehouseid = wh1.pk_stordoc
        INNER JOIN bd_invmandoc man ON kp.cinventoryid = man.pk_invmandoc
        INNER JOIN bd_invbasdoc inv ON man.pk_invbasdoc = inv.pk_invbasdoc
        WHERE
        ( kp.ccalbodyid = #{ccalbodyid} )
        AND ( wh1.storcode = #{storcode} )
        AND ( 0 = 0 )
        AND ( inv.invcode = #{invcode} )
        AND ( 0 = 0 )
        AND ( 0 = 0 )
        AND ( 0 = 0 )
        AND ( 0 = 0 )
        AND ( 0 = 0 )
        AND ( 0 = 0 )
        AND ( 0 = 0 )
        AND ( kp.pk_corp = #{pk_corp} )
        GROUP BY
        kp.pk_corp ,
        kp.ccalbodyid ,
        kp.cwarehouseid ,
        kp.cinventoryid ,
        kp.cinvbasid
        ) a
        LEFT OUTER JOIN (
        SELECT
        kp.cfreezeid ,
        kp.pk_corp ,
        kp.ccalbodyid ,
        kp.cwarehouseid ,
        kp.cinventoryid ,
        kp.cinvbasid ,
        SUM ( isnull( nfreezenum, 0 ) ) AS freezenum,
        SUM ( isnull( ngrossnum, 0 ) ) AS ngrossnum
        FROM
        ic_freeze kp
        LEFT OUTER JOIN bd_stordoc wh1 ON kp.cwarehouseid = wh1.pk_stordoc
        INNER JOIN bd_invmandoc man ON kp.cinventoryid = man.pk_invmandoc
        INNER JOIN bd_invbasdoc inv ON man.pk_invbasdoc = inv.pk_invbasdoc
        WHERE
        cthawpersonid IS NULL
        AND ( kp.ccalbodyid = #{ccalbodyid} )
        AND ( wh1.storcode = #{storcode} )
        AND ( 0 = 0 )
        AND ( inv.invcode = #{invcode} )
        AND ( 0 = 0 )
        AND ( 0 = 0 )
        AND ( 0 = 0 )
        AND ( 0 = 0 )
        AND ( 0 = 0 )
        AND ( 0 = 0 )
        AND ( 0 = 0 )
        AND ( kp.pk_corp = #{pk_corp} )
        GROUP BY
        kp.cfreezeid ,
        kp.pk_corp ,
        kp.ccalbodyid ,
        kp.cwarehouseid ,
        kp.cinventoryid ,
        kp.cinvbasid
        ) b ON a.pk_corp = b.pk_corp
        AND a.ccalbodyid = b.ccalbodyid
        AND a.cwarehouseid = b.cwarehouseid
        AND a.cinventoryid = b.cinventoryid
        ) ss
        WHERE
        ss.num &lt;> 0
    </select>

    <!--查询结存数量(发货库存组织、仓库、公司、货位)-->
    <select id="queryQuantityHandV2" parameterType="com.hzya.frame.plugin.lets.u8cdto.QuantityHandDto" resultMap="queryQuantityHandResultMap">
        SELECT
        *
        FROM
        (
        SELECT
        cfreezeid,
        a.pk_corp ,
        a.ccalbodyid ,
        a.cwarehouseid ,
        a.cinventoryid ,
        a.cinvbasid AS pk_invbasdoc,
        a.cspaceid ,
        a.num ,
        b.freezenum ,
        a.ngrossnum ,
        b.ngrossnum AS nfreezegrossnum
        FROM
        (
        SELECT
        kp.pk_corp ,
        kp.ccalbodyid ,
        kp.cwarehouseid ,
        kp.cinventoryid ,
        kp.cinvbasid ,
        kp.cspaceid ,
        SUM ( COALESCE ( ninspacenum, 0.0 ) ) - SUM ( COALESCE ( noutspacenum, 0.0 ) ) AS num,
        SUM ( COALESCE ( ningrossnum, 0.0 ) - COALESCE ( noutgrossnum, 0.0 ) ) AS ngrossnum
        FROM
        v_ic_onhandnum6 kp
        INNER JOIN bd_stordoc st ON kp.cwarehouseid = st.pk_stordoc
        AND st.isdirectstore = 'N'
        LEFT OUTER JOIN bd_stordoc wh1 ON kp.cwarehouseid = wh1.pk_stordoc
        LEFT OUTER JOIN bd_cargdoc cargdoc ON kp.cspaceid = cargdoc.pk_cargdoc
        INNER JOIN bd_invmandoc man ON kp.cinventoryid = man.pk_invmandoc
        INNER JOIN bd_invbasdoc inv ON man.pk_invbasdoc = inv.pk_invbasdoc
        WHERE
        ( kp.ccalbodyid = #{ccalbodyid} )
        AND ( wh1.storcode = #{storcode} )
        AND ( cargdoc.cscode = #{cscode} )
        AND ( 0 = 0 )
        AND ( inv.invcode = #{invcode} )
        AND ( 0 = 0 )
        AND ( 0 = 0 )
        AND ( 0 = 0 )
        AND ( 0 = 0 )
        AND ( 0 = 0 )
        AND ( 0 = 0 )
        AND ( 0 = 0 )
        AND ( kp.pk_corp = #{pk_corp} )
        GROUP BY
        kp.pk_corp ,
        kp.ccalbodyid ,
        kp.cwarehouseid ,
        kp.cinventoryid ,
        kp.cinvbasid ,
        kp.cspaceid
        ) a
        LEFT OUTER JOIN (
        SELECT
        kp.cfreezeid ,
        kp.pk_corp ,
        kp.ccalbodyid ,
        kp.cwarehouseid ,
        kp.cinventoryid ,
        kp.cinvbasid ,
        kp.cspaceid ,
        SUM ( isnull( nfreezenum, 0 ) ) AS freezenum,
        SUM ( isnull( ngrossnum, 0 ) ) AS ngrossnum
        FROM
        ic_freeze kp
        LEFT OUTER JOIN bd_stordoc wh1 ON kp.cwarehouseid = wh1.pk_stordoc
        LEFT OUTER JOIN bd_cargdoc cargdoc ON kp.cspaceid = cargdoc.pk_cargdoc
        INNER JOIN bd_invmandoc man ON kp.cinventoryid = man.pk_invmandoc
        INNER JOIN bd_invbasdoc inv ON man.pk_invbasdoc = inv.pk_invbasdoc
        WHERE
        cthawpersonid IS NULL
        AND ( kp.ccalbodyid = #{ccalbodyid} )
        AND ( wh1.storcode = #{storcode} )
        AND ( cargdoc.cscode = #{cscode} )
        AND ( 0 = 0 )
        AND ( inv.invcode = #{invcode} )
        AND ( 0 = 0 )
        AND ( 0 = 0 )
        AND ( 0 = 0 )
        AND ( 0 = 0 )
        AND ( 0 = 0 )
        AND ( 0 = 0 )
        AND ( 0 = 0 )
        AND ( kp.pk_corp = #{pk_corp} )
        GROUP BY
        kp.cfreezeid ,
        kp.pk_corp ,
        kp.ccalbodyid ,
        kp.cwarehouseid ,
        kp.cinventoryid ,
        kp.cinvbasid ,
        kp.cspaceid
        ) b ON a.pk_corp = b.pk_corp
        AND a.ccalbodyid = b.ccalbodyid
        AND a.cwarehouseid = b.cwarehouseid
        AND a.cinventoryid = b.cinventoryid
        AND isnull( a.cspaceid , ' ' ) = isnull( b.cspaceid , ' ' )
        ) ss
        WHERE
        ss.num &lt;> 0
    </select>

    <update id="updateSoSaleByCsaleid" parameterType="com.hzya.frame.plugin.lets.entity.SoSaleEntity">
        update so_sale set vdef20 = #{vdef20} where csaleid = #{csaleid} and dr = 0
    </update>
</mapper>

