<?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.BdStordocDaoImpl">

    <resultMap id="get-BdStordocEntity-result" type="com.hzya.frame.plugin.lets.entity.BdStordocEntity" >
       <result property="csflag" column="csflag" jdbcType="VARCHAR"/>
           <result property="def1" column="def1" jdbcType="VARCHAR"/>
           <result property="def2" column="def2" jdbcType="VARCHAR"/>
           <result property="def3" column="def3" jdbcType="VARCHAR"/>
           <result property="def4" column="def4" jdbcType="VARCHAR"/>
           <result property="def5" column="def5" jdbcType="VARCHAR"/>
           <result property="dr" column="dr" jdbcType="INTEGER"/>
           <result property="gubflag" column="gubflag" jdbcType="VARCHAR"/>
           <result property="isatpaffected" column="isatpaffected" jdbcType="VARCHAR"/>
           <result property="iscalculatedinvcost" column="iscalculatedinvcost" jdbcType="VARCHAR"/>
           <result property="iscapitalstor" column="iscapitalstor" jdbcType="VARCHAR"/>
           <result property="isdirectstore" column="isdirectstore" jdbcType="VARCHAR"/>
           <result property="isdsstor" column="isdsstor" jdbcType="VARCHAR"/>
           <result property="isforeignstor" column="isforeignstor" jdbcType="VARCHAR"/>
           <result property="isgathersettle" column="isgathersettle" jdbcType="VARCHAR"/>
           <result property="isshopstor" column="isshopstor" jdbcType="VARCHAR"/>
           <result property="isstoreontheway" column="isstoreontheway" jdbcType="VARCHAR"/>
           <result property="isuseretail" column="isuseretail" jdbcType="VARCHAR"/>
           <result property="memo" column="memo" jdbcType="VARCHAR"/>
           <result property="mrpflag" column="mrpflag" jdbcType="VARCHAR"/>
           <result property="outsourceflag" column="outsourceflag" jdbcType="VARCHAR"/>
           <result property="phone" column="phone" jdbcType="VARCHAR"/>
           <result property="pkAddress" column="pk_address" jdbcType="VARCHAR"/>
           <result property="pkCalbody" column="pk_calbody" jdbcType="VARCHAR"/>
           <result property="pkCorp" column="pk_corp" jdbcType="VARCHAR"/>
           <result property="pkStordoc" column="pk_stordoc" jdbcType="VARCHAR"/>
           <result property="principalcode" column="principalcode" jdbcType="VARCHAR"/>
           <result property="processor" column="processor" jdbcType="VARCHAR"/>
           <result property="processorbasid" column="processorbasid" jdbcType="VARCHAR"/>
           <result property="processormanid" column="processormanid" jdbcType="VARCHAR"/>
           <result property="proflag" column="proflag" jdbcType="VARCHAR"/>
           <result property="sealflag" column="sealflag" jdbcType="VARCHAR"/>
           <result property="storaddr" column="storaddr" jdbcType="VARCHAR"/>
           <result property="storcode" column="storcode" jdbcType="VARCHAR"/>
           <result property="storname" column="storname" jdbcType="VARCHAR"/>
           <result property="ts" column="ts" jdbcType="VARCHAR"/>
        </resultMap>
    <!-- 查询的字段-->
    <sql id = "BdStordocEntity_Base_Column_List">
        csflag
       ,def1 
        ,def2 
        ,def3 
        ,def4 
        ,def5 
        ,dr 
        ,gubflag 
        ,isatpaffected 
        ,iscalculatedinvcost 
        ,iscapitalstor 
        ,isdirectstore 
        ,isdsstor 
        ,isforeignstor 
        ,isgathersettle 
        ,isshopstor 
        ,isstoreontheway 
        ,isuseretail 
        ,memo 
        ,mrpflag 
        ,outsourceflag 
        ,phone 
        ,pk_address 
        ,pk_calbody 
        ,pk_corp 
        ,pk_stordoc 
        ,principalcode 
        ,processor 
        ,processorbasid 
        ,processormanid 
        ,proflag 
        ,sealflag 
        ,storaddr 
        ,storcode 
        ,storname 
        ,ts 
     </sql>

 <!-- 查询 采用==查询 -->
 <select id="entity_list_base" resultMap="get-BdStordocEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.BdStordocEntity">
    select
    <include refid="BdStordocEntity_Base_Column_List" />
    from bd_stordoc
    <trim prefix="where" prefixOverrides="and">
        <if test="csflag != null and csflag != ''"> and csflag = #{csflag} </if>
            <if test="def1 != null and def1 != ''"> and def1 = #{def1} </if>
            <if test="def2 != null and def2 != ''"> and def2 = #{def2} </if>
            <if test="def3 != null and def3 != ''"> and def3 = #{def3} </if>
            <if test="def4 != null and def4 != ''"> and def4 = #{def4} </if>
            <if test="def5 != null and def5 != ''"> and def5 = #{def5} </if>
            <if test="dr != null"> and dr = #{dr} </if>
            <if test="gubflag != null and gubflag != ''"> and gubflag = #{gubflag} </if>
            <if test="isatpaffected != null and isatpaffected != ''"> and isatpaffected = #{isatpaffected} </if>
            <if test="iscalculatedinvcost != null and iscalculatedinvcost != ''"> and iscalculatedinvcost = #{iscalculatedinvcost} </if>
            <if test="iscapitalstor != null and iscapitalstor != ''"> and iscapitalstor = #{iscapitalstor} </if>
            <if test="isdirectstore != null and isdirectstore != ''"> and isdirectstore = #{isdirectstore} </if>
            <if test="isdsstor != null and isdsstor != ''"> and isdsstor = #{isdsstor} </if>
            <if test="isforeignstor != null and isforeignstor != ''"> and isforeignstor = #{isforeignstor} </if>
            <if test="isgathersettle != null and isgathersettle != ''"> and isgathersettle = #{isgathersettle} </if>
            <if test="isshopstor != null and isshopstor != ''"> and isshopstor = #{isshopstor} </if>
            <if test="isstoreontheway != null and isstoreontheway != ''"> and isstoreontheway = #{isstoreontheway} </if>
            <if test="isuseretail != null and isuseretail != ''"> and isuseretail = #{isuseretail} </if>
            <if test="memo != null and memo != ''"> and memo = #{memo} </if>
            <if test="mrpflag != null and mrpflag != ''"> and mrpflag = #{mrpflag} </if>
            <if test="outsourceflag != null and outsourceflag != ''"> and outsourceflag = #{outsourceflag} </if>
            <if test="phone != null and phone != ''"> and phone = #{phone} </if>
            <if test="pkAddress != null and pkAddress != ''"> and pk_address = #{pkAddress} </if>
            <if test="pkCalbody != null and pkCalbody != ''"> and pk_calbody = #{pkCalbody} </if>
            <if test="pkCorp != null and pkCorp != ''"> and pk_corp = #{pkCorp} </if>
            <if test="pkStordoc != null and pkStordoc != ''"> and pk_stordoc = #{pkStordoc} </if>
            <if test="principalcode != null and principalcode != ''"> and principalcode = #{principalcode} </if>
            <if test="processor != null and processor != ''"> and processor = #{processor} </if>
            <if test="processorbasid != null and processorbasid != ''"> and processorbasid = #{processorbasid} </if>
            <if test="processormanid != null and processormanid != ''"> and processormanid = #{processormanid} </if>
            <if test="proflag != null and proflag != ''"> and proflag = #{proflag} </if>
            <if test="sealflag != null and sealflag != ''"> and sealflag = #{sealflag} </if>
            <if test="storaddr != null and storaddr != ''"> and storaddr = #{storaddr} </if>
            <if test="storcode != null and storcode != ''"> and storcode = #{storcode} </if>
            <if test="storcodes != null and storcodes != ''"> and storcode in (${storcodes}) </if>
            <if test="storname != null and storname != ''"> and storname = #{storname} </if>
            <if test="ts != null and ts != ''"> and ts = #{ts} </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.BdStordocEntity">
        select  count(1)   from bd_stordoc
    <trim prefix="where" prefixOverrides="and"> 
        <if test="csflag != null and csflag != ''"> and csflag = #{csflag} </if>
            <if test="def1 != null and def1 != ''"> and def1 = #{def1} </if>
            <if test="def2 != null and def2 != ''"> and def2 = #{def2} </if>
            <if test="def3 != null and def3 != ''"> and def3 = #{def3} </if>
            <if test="def4 != null and def4 != ''"> and def4 = #{def4} </if>
            <if test="def5 != null and def5 != ''"> and def5 = #{def5} </if>
            <if test="dr != null"> and dr = #{dr} </if>
            <if test="gubflag != null and gubflag != ''"> and gubflag = #{gubflag} </if>
            <if test="isatpaffected != null and isatpaffected != ''"> and isatpaffected = #{isatpaffected} </if>
            <if test="iscalculatedinvcost != null and iscalculatedinvcost != ''"> and iscalculatedinvcost = #{iscalculatedinvcost} </if>
            <if test="iscapitalstor != null and iscapitalstor != ''"> and iscapitalstor = #{iscapitalstor} </if>
            <if test="isdirectstore != null and isdirectstore != ''"> and isdirectstore = #{isdirectstore} </if>
            <if test="isdsstor != null and isdsstor != ''"> and isdsstor = #{isdsstor} </if>
            <if test="isforeignstor != null and isforeignstor != ''"> and isforeignstor = #{isforeignstor} </if>
            <if test="isgathersettle != null and isgathersettle != ''"> and isgathersettle = #{isgathersettle} </if>
            <if test="isshopstor != null and isshopstor != ''"> and isshopstor = #{isshopstor} </if>
            <if test="isstoreontheway != null and isstoreontheway != ''"> and isstoreontheway = #{isstoreontheway} </if>
            <if test="isuseretail != null and isuseretail != ''"> and isuseretail = #{isuseretail} </if>
            <if test="memo != null and memo != ''"> and memo = #{memo} </if>
            <if test="mrpflag != null and mrpflag != ''"> and mrpflag = #{mrpflag} </if>
            <if test="outsourceflag != null and outsourceflag != ''"> and outsourceflag = #{outsourceflag} </if>
            <if test="phone != null and phone != ''"> and phone = #{phone} </if>
            <if test="pkAddress != null and pkAddress != ''"> and pk_address = #{pkAddress} </if>
            <if test="pkCalbody != null and pkCalbody != ''"> and pk_calbody = #{pkCalbody} </if>
            <if test="pkCorp != null and pkCorp != ''"> and pk_corp = #{pkCorp} </if>
            <if test="pkStordoc != null and pkStordoc != ''"> and pk_stordoc = #{pkStordoc} </if>
            <if test="principalcode != null and principalcode != ''"> and principalcode = #{principalcode} </if>
            <if test="processor != null and processor != ''"> and processor = #{processor} </if>
            <if test="processorbasid != null and processorbasid != ''"> and processorbasid = #{processorbasid} </if>
            <if test="processormanid != null and processormanid != ''"> and processormanid = #{processormanid} </if>
            <if test="proflag != null and proflag != ''"> and proflag = #{proflag} </if>
            <if test="sealflag != null and sealflag != ''"> and sealflag = #{sealflag} </if>
            <if test="storaddr != null and storaddr != ''"> and storaddr = #{storaddr} </if>
            <if test="storcode != null and storcode != ''"> and storcode = #{storcode} </if>
            <if test="storname != null and storname != ''"> and storname = #{storname} </if>
            <if test="ts != null and ts != ''"> and ts = #{ts} </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-BdStordocEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.BdStordocEntity">
    select
    <include refid="BdStordocEntity_Base_Column_List" />
    from bd_stordoc
    <trim prefix="where" prefixOverrides="and"> 
        <if test="csflag != null and csflag != ''"> and csflag like concat('%',#{csflag},'%') </if>
            <if test="def1 != null and def1 != ''"> and def1 like concat('%',#{def1},'%') </if>
            <if test="def2 != null and def2 != ''"> and def2 like concat('%',#{def2},'%') </if>
            <if test="def3 != null and def3 != ''"> and def3 like concat('%',#{def3},'%') </if>
            <if test="def4 != null and def4 != ''"> and def4 like concat('%',#{def4},'%') </if>
            <if test="def5 != null and def5 != ''"> and def5 like concat('%',#{def5},'%') </if>
            <if test="dr != null"> and dr like concat('%',#{dr},'%') </if>
            <if test="gubflag != null and gubflag != ''"> and gubflag like concat('%',#{gubflag},'%') </if>
            <if test="isatpaffected != null and isatpaffected != ''"> and isatpaffected like concat('%',#{isatpaffected},'%') </if>
            <if test="iscalculatedinvcost != null and iscalculatedinvcost != ''"> and iscalculatedinvcost like concat('%',#{iscalculatedinvcost},'%') </if>
            <if test="iscapitalstor != null and iscapitalstor != ''"> and iscapitalstor like concat('%',#{iscapitalstor},'%') </if>
            <if test="isdirectstore != null and isdirectstore != ''"> and isdirectstore like concat('%',#{isdirectstore},'%') </if>
            <if test="isdsstor != null and isdsstor != ''"> and isdsstor like concat('%',#{isdsstor},'%') </if>
            <if test="isforeignstor != null and isforeignstor != ''"> and isforeignstor like concat('%',#{isforeignstor},'%') </if>
            <if test="isgathersettle != null and isgathersettle != ''"> and isgathersettle like concat('%',#{isgathersettle},'%') </if>
            <if test="isshopstor != null and isshopstor != ''"> and isshopstor like concat('%',#{isshopstor},'%') </if>
            <if test="isstoreontheway != null and isstoreontheway != ''"> and isstoreontheway like concat('%',#{isstoreontheway},'%') </if>
            <if test="isuseretail != null and isuseretail != ''"> and isuseretail like concat('%',#{isuseretail},'%') </if>
            <if test="memo != null and memo != ''"> and memo like concat('%',#{memo},'%') </if>
            <if test="mrpflag != null and mrpflag != ''"> and mrpflag like concat('%',#{mrpflag},'%') </if>
            <if test="outsourceflag != null and outsourceflag != ''"> and outsourceflag like concat('%',#{outsourceflag},'%') </if>
            <if test="phone != null and phone != ''"> and phone like concat('%',#{phone},'%') </if>
            <if test="pkAddress != null and pkAddress != ''"> and pk_address like concat('%',#{pkAddress},'%') </if>
            <if test="pkCalbody != null and pkCalbody != ''"> and pk_calbody like concat('%',#{pkCalbody},'%') </if>
            <if test="pkCorp != null and pkCorp != ''"> and pk_corp like concat('%',#{pkCorp},'%') </if>
            <if test="pkStordoc != null and pkStordoc != ''"> and pk_stordoc like concat('%',#{pkStordoc},'%') </if>
            <if test="principalcode != null and principalcode != ''"> and principalcode like concat('%',#{principalcode},'%') </if>
            <if test="processor != null and processor != ''"> and processor like concat('%',#{processor},'%') </if>
            <if test="processorbasid != null and processorbasid != ''"> and processorbasid like concat('%',#{processorbasid},'%') </if>
            <if test="processormanid != null and processormanid != ''"> and processormanid like concat('%',#{processormanid},'%') </if>
            <if test="proflag != null and proflag != ''"> and proflag like concat('%',#{proflag},'%') </if>
            <if test="sealflag != null and sealflag != ''"> and sealflag like concat('%',#{sealflag},'%') </if>
            <if test="storaddr != null and storaddr != ''"> and storaddr like concat('%',#{storaddr},'%') </if>
            <if test="storcode != null and storcode != ''"> and storcode like concat('%',#{storcode},'%') </if>
            <if test="storname != null and storname != ''"> and storname like concat('%',#{storname},'%') </if>
            <if test="ts != null and ts != ''"> and ts like concat('%',#{ts},'%') </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="BdStordocentity_list_or" resultMap="get-BdStordocEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.BdStordocEntity">
    select
    <include refid="BdStordocEntity_Base_Column_List" />
    from bd_stordoc
    <trim prefix="where" prefixOverrides="and"> 
         <if test="csflag != null and csflag != ''"> or csflag = #{csflag} </if>
             <if test="def1 != null and def1 != ''"> or def1 = #{def1} </if>
             <if test="def2 != null and def2 != ''"> or def2 = #{def2} </if>
             <if test="def3 != null and def3 != ''"> or def3 = #{def3} </if>
             <if test="def4 != null and def4 != ''"> or def4 = #{def4} </if>
             <if test="def5 != null and def5 != ''"> or def5 = #{def5} </if>
             <if test="dr != null"> or dr = #{dr} </if>
             <if test="gubflag != null and gubflag != ''"> or gubflag = #{gubflag} </if>
             <if test="isatpaffected != null and isatpaffected != ''"> or isatpaffected = #{isatpaffected} </if>
             <if test="iscalculatedinvcost != null and iscalculatedinvcost != ''"> or iscalculatedinvcost = #{iscalculatedinvcost} </if>
             <if test="iscapitalstor != null and iscapitalstor != ''"> or iscapitalstor = #{iscapitalstor} </if>
             <if test="isdirectstore != null and isdirectstore != ''"> or isdirectstore = #{isdirectstore} </if>
             <if test="isdsstor != null and isdsstor != ''"> or isdsstor = #{isdsstor} </if>
             <if test="isforeignstor != null and isforeignstor != ''"> or isforeignstor = #{isforeignstor} </if>
             <if test="isgathersettle != null and isgathersettle != ''"> or isgathersettle = #{isgathersettle} </if>
             <if test="isshopstor != null and isshopstor != ''"> or isshopstor = #{isshopstor} </if>
             <if test="isstoreontheway != null and isstoreontheway != ''"> or isstoreontheway = #{isstoreontheway} </if>
             <if test="isuseretail != null and isuseretail != ''"> or isuseretail = #{isuseretail} </if>
             <if test="memo != null and memo != ''"> or memo = #{memo} </if>
             <if test="mrpflag != null and mrpflag != ''"> or mrpflag = #{mrpflag} </if>
             <if test="outsourceflag != null and outsourceflag != ''"> or outsourceflag = #{outsourceflag} </if>
             <if test="phone != null and phone != ''"> or phone = #{phone} </if>
             <if test="pkAddress != null and pkAddress != ''"> or pk_address = #{pkAddress} </if>
             <if test="pkCalbody != null and pkCalbody != ''"> or pk_calbody = #{pkCalbody} </if>
             <if test="pkCorp != null and pkCorp != ''"> or pk_corp = #{pkCorp} </if>
             <if test="pkStordoc != null and pkStordoc != ''"> or pk_stordoc = #{pkStordoc} </if>
             <if test="principalcode != null and principalcode != ''"> or principalcode = #{principalcode} </if>
             <if test="processor != null and processor != ''"> or processor = #{processor} </if>
             <if test="processorbasid != null and processorbasid != ''"> or processorbasid = #{processorbasid} </if>
             <if test="processormanid != null and processormanid != ''"> or processormanid = #{processormanid} </if>
             <if test="proflag != null and proflag != ''"> or proflag = #{proflag} </if>
             <if test="sealflag != null and sealflag != ''"> or sealflag = #{sealflag} </if>
             <if test="storaddr != null and storaddr != ''"> or storaddr = #{storaddr} </if>
             <if test="storcode != null and storcode != ''"> or storcode = #{storcode} </if>
             <if test="storname != null and storname != ''"> or storname = #{storname} </if>
             <if test="ts != null and ts != ''"> or ts = #{ts} </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.BdStordocEntity" keyProperty="pkStordoc" useGeneratedKeys="true">
    insert into bd_stordoc(
  <trim suffix="" suffixOverrides=",">
       <if test="csflag != null and csflag != ''"> csflag , </if>
            <if test="def1 != null and def1 != ''"> def1 , </if>
            <if test="def2 != null and def2 != ''"> def2 , </if>
            <if test="def3 != null and def3 != ''"> def3 , </if>
            <if test="def4 != null and def4 != ''"> def4 , </if>
            <if test="def5 != null and def5 != ''"> def5 , </if>
            <if test="dr != null"> dr , </if>
            <if test="gubflag != null and gubflag != ''"> gubflag , </if>
            <if test="isatpaffected != null and isatpaffected != ''"> isatpaffected , </if>
            <if test="iscalculatedinvcost != null and iscalculatedinvcost != ''"> iscalculatedinvcost , </if>
            <if test="iscapitalstor != null and iscapitalstor != ''"> iscapitalstor , </if>
            <if test="isdirectstore != null and isdirectstore != ''"> isdirectstore , </if>
            <if test="isdsstor != null and isdsstor != ''"> isdsstor , </if>
            <if test="isforeignstor != null and isforeignstor != ''"> isforeignstor , </if>
            <if test="isgathersettle != null and isgathersettle != ''"> isgathersettle , </if>
            <if test="isshopstor != null and isshopstor != ''"> isshopstor , </if>
            <if test="isstoreontheway != null and isstoreontheway != ''"> isstoreontheway , </if>
            <if test="isuseretail != null and isuseretail != ''"> isuseretail , </if>
            <if test="memo != null and memo != ''"> memo , </if>
            <if test="mrpflag != null and mrpflag != ''"> mrpflag , </if>
            <if test="outsourceflag != null and outsourceflag != ''"> outsourceflag , </if>
            <if test="phone != null and phone != ''"> phone , </if>
            <if test="pkAddress != null and pkAddress != ''"> pk_address , </if>
            <if test="pkCalbody != null and pkCalbody != ''"> pk_calbody , </if>
            <if test="pkCorp != null and pkCorp != ''"> pk_corp , </if>
            <if test="pkStordoc != null and pkStordoc != ''"> pk_stordoc , </if>
            <if test="principalcode != null and principalcode != ''"> principalcode , </if>
            <if test="processor != null and processor != ''"> processor , </if>
            <if test="processorbasid != null and processorbasid != ''"> processorbasid , </if>
            <if test="processormanid != null and processormanid != ''"> processormanid , </if>
            <if test="proflag != null and proflag != ''"> proflag , </if>
            <if test="sealflag != null and sealflag != ''"> sealflag , </if>
            <if test="storaddr != null and storaddr != ''"> storaddr , </if>
            <if test="storcode != null and storcode != ''"> storcode , </if>
            <if test="storname != null and storname != ''"> storname , </if>
            <if test="ts != null and ts != ''"> ts , </if>
            <if test="sorts == null ">sorts,</if>
    <if test="sts == null ">sts,</if>
  </trim>
  )values(
 <trim suffix="" suffixOverrides=",">
       <if test="csflag != null and csflag != ''"> #{csflag} ,</if>
            <if test="def1 != null and def1 != ''"> #{def1} ,</if>
            <if test="def2 != null and def2 != ''"> #{def2} ,</if>
            <if test="def3 != null and def3 != ''"> #{def3} ,</if>
            <if test="def4 != null and def4 != ''"> #{def4} ,</if>
            <if test="def5 != null and def5 != ''"> #{def5} ,</if>
            <if test="dr != null"> #{dr} ,</if>
            <if test="gubflag != null and gubflag != ''"> #{gubflag} ,</if>
            <if test="isatpaffected != null and isatpaffected != ''"> #{isatpaffected} ,</if>
            <if test="iscalculatedinvcost != null and iscalculatedinvcost != ''"> #{iscalculatedinvcost} ,</if>
            <if test="iscapitalstor != null and iscapitalstor != ''"> #{iscapitalstor} ,</if>
            <if test="isdirectstore != null and isdirectstore != ''"> #{isdirectstore} ,</if>
            <if test="isdsstor != null and isdsstor != ''"> #{isdsstor} ,</if>
            <if test="isforeignstor != null and isforeignstor != ''"> #{isforeignstor} ,</if>
            <if test="isgathersettle != null and isgathersettle != ''"> #{isgathersettle} ,</if>
            <if test="isshopstor != null and isshopstor != ''"> #{isshopstor} ,</if>
            <if test="isstoreontheway != null and isstoreontheway != ''"> #{isstoreontheway} ,</if>
            <if test="isuseretail != null and isuseretail != ''"> #{isuseretail} ,</if>
            <if test="memo != null and memo != ''"> #{memo} ,</if>
            <if test="mrpflag != null and mrpflag != ''"> #{mrpflag} ,</if>
            <if test="outsourceflag != null and outsourceflag != ''"> #{outsourceflag} ,</if>
            <if test="phone != null and phone != ''"> #{phone} ,</if>
            <if test="pkAddress != null and pkAddress != ''"> #{pkAddress} ,</if>
            <if test="pkCalbody != null and pkCalbody != ''"> #{pkCalbody} ,</if>
            <if test="pkCorp != null and pkCorp != ''"> #{pkCorp} ,</if>
            <if test="pkStordoc != null and pkStordoc != ''"> #{pkStordoc} ,</if>
            <if test="principalcode != null and principalcode != ''"> #{principalcode} ,</if>
            <if test="processor != null and processor != ''"> #{processor} ,</if>
            <if test="processorbasid != null and processorbasid != ''"> #{processorbasid} ,</if>
            <if test="processormanid != null and processormanid != ''"> #{processormanid} ,</if>
            <if test="proflag != null and proflag != ''"> #{proflag} ,</if>
            <if test="sealflag != null and sealflag != ''"> #{sealflag} ,</if>
            <if test="storaddr != null and storaddr != ''"> #{storaddr} ,</if>
            <if test="storcode != null and storcode != ''"> #{storcode} ,</if>
            <if test="storname != null and storname != ''"> #{storname} ,</if>
            <if test="ts != null and ts != ''"> #{ts} ,</if>
            <if test="sorts == null ">(select (max(IFNULL( a.sorts, 0 )) + 1) as sort from bd_stordoc a WHERE a.sts = 'Y' ),</if>
    <if test="sts == null ">'Y',</if>
  </trim>
  )  
</insert>
<!-- 批量新增 -->
<insert id="entityInsertBatch" keyProperty="pkStordoc" useGeneratedKeys="true">
  insert into bd_stordoc(csflag, def1, def2, def3, def4, def5, dr, gubflag, isatpaffected, iscalculatedinvcost, iscapitalstor, isdirectstore, isdsstor, isforeignstor, isgathersettle, isshopstor, isstoreontheway, isuseretail, memo, mrpflag, outsourceflag, phone, pk_address, pk_calbody, pk_corp, principalcode, processor, processorbasid, processormanid, proflag, sealflag, storaddr, storcode, storname, ts,  sts) 
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.csflag},#{entity.def1},#{entity.def2},#{entity.def3},#{entity.def4},#{entity.def5},#{entity.dr},#{entity.gubflag},#{entity.isatpaffected},#{entity.iscalculatedinvcost},#{entity.iscapitalstor},#{entity.isdirectstore},#{entity.isdsstor},#{entity.isforeignstor},#{entity.isgathersettle},#{entity.isshopstor},#{entity.isstoreontheway},#{entity.isuseretail},#{entity.memo},#{entity.mrpflag},#{entity.outsourceflag},#{entity.phone},#{entity.pkAddress},#{entity.pkCalbody},#{entity.pkCorp},#{entity.principalcode},#{entity.processor},#{entity.processorbasid},#{entity.processormanid},#{entity.proflag},#{entity.sealflag},#{entity.storaddr},#{entity.storcode},#{entity.storname},#{entity.ts}, 'Y')
    </foreach>
</insert>
<!-- 批量新增或者修改-->
<insert id="entityInsertOrUpdateBatch" keyProperty="pkStordoc" useGeneratedKeys="true">
    insert into bd_stordoc(csflag, def1, def2, def3, def4, def5, dr, gubflag, isatpaffected, iscalculatedinvcost, iscapitalstor, isdirectstore, isdsstor, isforeignstor, isgathersettle, isshopstor, isstoreontheway, isuseretail, memo, mrpflag, outsourceflag, phone, pk_address, pk_calbody, pk_corp, principalcode, processor, processorbasid, processormanid, proflag, sealflag, storaddr, storcode, storname, ts)
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.csflag},#{entity.def1},#{entity.def2},#{entity.def3},#{entity.def4},#{entity.def5},#{entity.dr},#{entity.gubflag},#{entity.isatpaffected},#{entity.iscalculatedinvcost},#{entity.iscapitalstor},#{entity.isdirectstore},#{entity.isdsstor},#{entity.isforeignstor},#{entity.isgathersettle},#{entity.isshopstor},#{entity.isstoreontheway},#{entity.isuseretail},#{entity.memo},#{entity.mrpflag},#{entity.outsourceflag},#{entity.phone},#{entity.pkAddress},#{entity.pkCalbody},#{entity.pkCorp},#{entity.principalcode},#{entity.processor},#{entity.processorbasid},#{entity.processormanid},#{entity.proflag},#{entity.sealflag},#{entity.storaddr},#{entity.storcode},#{entity.storname},#{entity.ts})
    </foreach>
    on duplicate key update
    csflag = values(csflag),
    def1 = values(def1),
    def2 = values(def2),
    def3 = values(def3),
    def4 = values(def4),
    def5 = values(def5),
    dr = values(dr),
    gubflag = values(gubflag),
    isatpaffected = values(isatpaffected),
    iscalculatedinvcost = values(iscalculatedinvcost),
    iscapitalstor = values(iscapitalstor),
    isdirectstore = values(isdirectstore),
    isdsstor = values(isdsstor),
    isforeignstor = values(isforeignstor),
    isgathersettle = values(isgathersettle),
    isshopstor = values(isshopstor),
    isstoreontheway = values(isstoreontheway),
    isuseretail = values(isuseretail),
    memo = values(memo),
    mrpflag = values(mrpflag),
    outsourceflag = values(outsourceflag),
    phone = values(phone),
    pk_address = values(pk_address),
    pk_calbody = values(pk_calbody),
    pk_corp = values(pk_corp),
    principalcode = values(principalcode),
    processor = values(processor),
    processorbasid = values(processorbasid),
    processormanid = values(processormanid),
    proflag = values(proflag),
    sealflag = values(sealflag),
    storaddr = values(storaddr),
    storcode = values(storcode),
    storname = values(storname),
    ts = values(ts)</insert>
<!--通过主键修改方法-->
<update id="entity_update" parameterType = "com.hzya.frame.plugin.lets.entity.BdStordocEntity" >
update bd_stordoc  set
<trim suffix="" suffixOverrides=",">
  <if test="csflag != null and csflag != ''"> csflag = #{csflag},</if>
  <if test="def1 != null and def1 != ''"> def1 = #{def1},</if>
  <if test="def2 != null and def2 != ''"> def2 = #{def2},</if>
  <if test="def3 != null and def3 != ''"> def3 = #{def3},</if>
  <if test="def4 != null and def4 != ''"> def4 = #{def4},</if>
  <if test="def5 != null and def5 != ''"> def5 = #{def5},</if>
  <if test="dr != null"> dr = #{dr},</if>
  <if test="gubflag != null and gubflag != ''"> gubflag = #{gubflag},</if>
  <if test="isatpaffected != null and isatpaffected != ''"> isatpaffected = #{isatpaffected},</if>
  <if test="iscalculatedinvcost != null and iscalculatedinvcost != ''"> iscalculatedinvcost = #{iscalculatedinvcost},</if>
  <if test="iscapitalstor != null and iscapitalstor != ''"> iscapitalstor = #{iscapitalstor},</if>
  <if test="isdirectstore != null and isdirectstore != ''"> isdirectstore = #{isdirectstore},</if>
  <if test="isdsstor != null and isdsstor != ''"> isdsstor = #{isdsstor},</if>
  <if test="isforeignstor != null and isforeignstor != ''"> isforeignstor = #{isforeignstor},</if>
  <if test="isgathersettle != null and isgathersettle != ''"> isgathersettle = #{isgathersettle},</if>
  <if test="isshopstor != null and isshopstor != ''"> isshopstor = #{isshopstor},</if>
  <if test="isstoreontheway != null and isstoreontheway != ''"> isstoreontheway = #{isstoreontheway},</if>
  <if test="isuseretail != null and isuseretail != ''"> isuseretail = #{isuseretail},</if>
  <if test="memo != null and memo != ''"> memo = #{memo},</if>
  <if test="mrpflag != null and mrpflag != ''"> mrpflag = #{mrpflag},</if>
  <if test="outsourceflag != null and outsourceflag != ''"> outsourceflag = #{outsourceflag},</if>
  <if test="phone != null and phone != ''"> phone = #{phone},</if>
  <if test="pkAddress != null and pkAddress != ''"> pk_address = #{pkAddress},</if>
  <if test="pkCalbody != null and pkCalbody != ''"> pk_calbody = #{pkCalbody},</if>
  <if test="pkCorp != null and pkCorp != ''"> pk_corp = #{pkCorp},</if>
  <if test="principalcode != null and principalcode != ''"> principalcode = #{principalcode},</if>
  <if test="processor != null and processor != ''"> processor = #{processor},</if>
  <if test="processorbasid != null and processorbasid != ''"> processorbasid = #{processorbasid},</if>
  <if test="processormanid != null and processormanid != ''"> processormanid = #{processormanid},</if>
  <if test="proflag != null and proflag != ''"> proflag = #{proflag},</if>
  <if test="sealflag != null and sealflag != ''"> sealflag = #{sealflag},</if>
  <if test="storaddr != null and storaddr != ''"> storaddr = #{storaddr},</if>
  <if test="storcode != null and storcode != ''"> storcode = #{storcode},</if>
  <if test="storname != null and storname != ''"> storname = #{storname},</if>
  <if test="ts != null and ts != ''"> ts = #{ts},</if>
</trim>
where pk_stordoc = #{pkStordoc}
</update>
<!-- 逻辑删除 -->
<update id="entity_logicDelete" parameterType = "com.hzya.frame.plugin.lets.entity.BdStordocEntity" >
update bd_stordoc  set sts= 'N'
where pk_stordoc = #{pkStordoc}
</update>
<!-- 多条件逻辑删除 -->
<update id="entity_logicDelete_Multi_Condition" parameterType = "com.hzya.frame.plugin.lets.entity.BdStordocEntity" >
update bd_stordoc  set sts= 'N' 
 <trim prefix="where" prefixOverrides="and"> 
        <if test="csflag != null and csflag != ''"> and csflag = #{csflag} </if>
            <if test="def1 != null and def1 != ''"> and def1 = #{def1} </if>
            <if test="def2 != null and def2 != ''"> and def2 = #{def2} </if>
            <if test="def3 != null and def3 != ''"> and def3 = #{def3} </if>
            <if test="def4 != null and def4 != ''"> and def4 = #{def4} </if>
            <if test="def5 != null and def5 != ''"> and def5 = #{def5} </if>
            <if test="dr != null"> and dr = #{dr} </if>
            <if test="gubflag != null and gubflag != ''"> and gubflag = #{gubflag} </if>
            <if test="isatpaffected != null and isatpaffected != ''"> and isatpaffected = #{isatpaffected} </if>
            <if test="iscalculatedinvcost != null and iscalculatedinvcost != ''"> and iscalculatedinvcost = #{iscalculatedinvcost} </if>
            <if test="iscapitalstor != null and iscapitalstor != ''"> and iscapitalstor = #{iscapitalstor} </if>
            <if test="isdirectstore != null and isdirectstore != ''"> and isdirectstore = #{isdirectstore} </if>
            <if test="isdsstor != null and isdsstor != ''"> and isdsstor = #{isdsstor} </if>
            <if test="isforeignstor != null and isforeignstor != ''"> and isforeignstor = #{isforeignstor} </if>
            <if test="isgathersettle != null and isgathersettle != ''"> and isgathersettle = #{isgathersettle} </if>
            <if test="isshopstor != null and isshopstor != ''"> and isshopstor = #{isshopstor} </if>
            <if test="isstoreontheway != null and isstoreontheway != ''"> and isstoreontheway = #{isstoreontheway} </if>
            <if test="isuseretail != null and isuseretail != ''"> and isuseretail = #{isuseretail} </if>
            <if test="memo != null and memo != ''"> and memo = #{memo} </if>
            <if test="mrpflag != null and mrpflag != ''"> and mrpflag = #{mrpflag} </if>
            <if test="outsourceflag != null and outsourceflag != ''"> and outsourceflag = #{outsourceflag} </if>
            <if test="phone != null and phone != ''"> and phone = #{phone} </if>
            <if test="pkAddress != null and pkAddress != ''"> and pk_address = #{pkAddress} </if>
            <if test="pkCalbody != null and pkCalbody != ''"> and pk_calbody = #{pkCalbody} </if>
            <if test="pkCorp != null and pkCorp != ''"> and pk_corp = #{pkCorp} </if>
            <if test="pkStordoc != null and pkStordoc != ''"> and pk_stordoc = #{pkStordoc} </if>
            <if test="principalcode != null and principalcode != ''"> and principalcode = #{principalcode} </if>
            <if test="processor != null and processor != ''"> and processor = #{processor} </if>
            <if test="processorbasid != null and processorbasid != ''"> and processorbasid = #{processorbasid} </if>
            <if test="processormanid != null and processormanid != ''"> and processormanid = #{processormanid} </if>
            <if test="proflag != null and proflag != ''"> and proflag = #{proflag} </if>
            <if test="sealflag != null and sealflag != ''"> and sealflag = #{sealflag} </if>
            <if test="storaddr != null and storaddr != ''"> and storaddr = #{storaddr} </if>
            <if test="storcode != null and storcode != ''"> and storcode = #{storcode} </if>
            <if test="storname != null and storname != ''"> and storname = #{storname} </if>
            <if test="ts != null and ts != ''"> and ts = #{ts} </if>
            and sts='Y'
    </trim>
</update>
<!--通过主键删除-->
<delete id="entity_delete">
    delete from bd_stordoc where pk_stordoc = #{pkStordoc}
</delete>

</mapper>

