<?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.bailuntec.mapper.DcBaseStockMapper">
    <resultMap id="BaseResultMap" type="com.bailuntec.domain.entity.DcBaseStock">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="bailun_sku" jdbcType="VARCHAR" property="bailunSku"/>
        <result column="warehouse_code" jdbcType="VARCHAR" property="warehouseCode"/>
        <result column="owner_code" jdbcType="VARCHAR" property="ownerCode"/>
        <result column="quantity_reservation" jdbcType="INTEGER" property="quantityReservation"/>
        <result column="quantity_transport" jdbcType="INTEGER" property="quantityTransport"/>
        <result column="quantity_transfer" jdbcType="INTEGER" property="quantityTransfer"/>
        <result column="quantity_freeze" jdbcType="INTEGER" property="quantityFreeze"/>
        <result column="quantity_supplier" jdbcType="INTEGER" property="quantitySupplier"/>
        <result column="quantity_presell" jdbcType="INTEGER" property="quantityPresell"/>
        <result column="quantity_defective" jdbcType="INTEGER" property="quantityDefective"/>
        <result column="quantity_transit" jdbcType="INTEGER" property="quantityTransit"/>
        <result column="wait_check" jdbcType="INTEGER" property="waitCheck"/>
        <result column="wait_putaway" jdbcType="INTEGER" property="waitPutaway"/>
        <result column="usable_stock" jdbcType="INTEGER" property="usableStock"/>
        <result column="usable_sales" jdbcType="INTEGER" property="usableSales"/>
        <result column="usable_sales_private" jdbcType="INTEGER" property="usableSalesPrivate"/>
        <result column="usable_sales_share" jdbcType="INTEGER" property="usableSalesShare"/>
        <result column="in_warehouse_share" jdbcType="INTEGER" property="inWarehouseShare"/>
        <result column="in_warehouse_private" jdbcType="INTEGER" property="inWarehousePrivate"/>
        <result column="in_warehouse" jdbcType="INTEGER" property="inWarehouse"/>
        <result column="occupy_stock_share" jdbcType="INTEGER" property="occupyStockShare"/>
        <result column="occupy_stock_private" jdbcType="INTEGER" property="occupyStockPrivate"/>
        <result column="occupy_stock" jdbcType="INTEGER" property="occupyStock"/>
        <result column="occupy_activity" jdbcType="INTEGER" property="occupyActivity"/>
        <result column="occupy_order_private" jdbcType="INTEGER" property="occupyOrderPrivate"/>
        <result column="occupy_order_share" jdbcType="INTEGER" property="occupyOrderShare"/>
        <result column="occupy_order" jdbcType="INTEGER" property="occupyOrder"/>
        <result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate"/>
        <result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="shipped_stock" jdbcType="INTEGER" property="shippedStock"/>
    </resultMap>
    <sql id="Example_Where_Clause">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <where>
            <foreach collection="oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
                                             separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Update_By_Example_Where_Clause">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <where>
            <foreach collection="example.oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
                                             separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Base_Column_List">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        id, bailun_sku, warehouse_code, owner_code, quantity_reservation, quantity_transport,
        quantity_transfer, quantity_freeze, quantity_supplier, quantity_presell, quantity_defective,
        quantity_transit, wait_check, wait_putaway, usable_stock, usable_sales, usable_sales_private,
        usable_sales_share, in_warehouse_share, in_warehouse_private, in_warehouse, occupy_stock_share,
        occupy_stock_private, occupy_stock, occupy_activity, occupy_order_private, occupy_order_share,
        occupy_order, gmt_create, gmt_modified, create_time, update_time, shipped_stock
    </sql>
    <select id="selectByExample" parameterType="com.bailuntec.domain.example.DcBaseStockExample"
            resultMap="BaseResultMap">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        select
        <if test="distinct">
            distinct
        </if>
        <include refid="Base_Column_List"/>
        from dc_base_stock
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
        <if test="rows != null">
            <if test="offset != null">
                limit ${offset}, ${rows}
            </if>
            <if test="offset == null">
                limit ${rows}
            </if>
        </if>
    </select>
    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        select
        <include refid="Base_Column_List"/>
        from dc_base_stock
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        delete from dc_base_stock
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <delete id="deleteByExample" parameterType="com.bailuntec.domain.example.DcBaseStockExample">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        delete from dc_base_stock
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </delete>
    <insert id="insert" parameterType="com.bailuntec.domain.entity.DcBaseStock">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        insert into dc_base_stock (id, bailun_sku, warehouse_code,
        owner_code, quantity_reservation, quantity_transport,
        quantity_transfer, quantity_freeze, quantity_supplier,
        quantity_presell, quantity_defective, quantity_transit,
        wait_check, wait_putaway, usable_stock,
        usable_sales, usable_sales_private, usable_sales_share,
        in_warehouse_share, in_warehouse_private, in_warehouse,
        occupy_stock_share, occupy_stock_private, occupy_stock,
        occupy_activity, occupy_order_private, occupy_order_share,
        occupy_order, gmt_create, gmt_modified,
        create_time, update_time, shipped_stock
        )
        values (#{id,jdbcType=INTEGER}, #{bailunSku,jdbcType=VARCHAR}, #{warehouseCode,jdbcType=VARCHAR},
        #{ownerCode,jdbcType=VARCHAR}, #{quantityReservation,jdbcType=INTEGER}, #{quantityTransport,jdbcType=INTEGER},
        #{quantityTransfer,jdbcType=INTEGER}, #{quantityFreeze,jdbcType=INTEGER}, #{quantitySupplier,jdbcType=INTEGER},
        #{quantityPresell,jdbcType=INTEGER}, #{quantityDefective,jdbcType=INTEGER}, #{quantityTransit,jdbcType=INTEGER},
        #{waitCheck,jdbcType=INTEGER}, #{waitPutaway,jdbcType=INTEGER}, #{usableStock,jdbcType=INTEGER},
        #{usableSales,jdbcType=INTEGER}, #{usableSalesPrivate,jdbcType=INTEGER}, #{usableSalesShare,jdbcType=INTEGER},
        #{inWarehouseShare,jdbcType=INTEGER}, #{inWarehousePrivate,jdbcType=INTEGER}, #{inWarehouse,jdbcType=INTEGER},
        #{occupyStockShare,jdbcType=INTEGER}, #{occupyStockPrivate,jdbcType=INTEGER}, #{occupyStock,jdbcType=INTEGER},
        #{occupyActivity,jdbcType=INTEGER}, #{occupyOrderPrivate,jdbcType=INTEGER},
        #{occupyOrderShare,jdbcType=INTEGER},
        #{occupyOrder,jdbcType=INTEGER}, #{gmtCreate,jdbcType=TIMESTAMP}, #{gmtModified,jdbcType=TIMESTAMP},
        #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{shippedStock,jdbcType=INTEGER}
        )
    </insert>
    <insert id="insertSelective" parameterType="com.bailuntec.domain.entity.DcBaseStock">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        insert into dc_base_stock
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="bailunSku != null">
                bailun_sku,
            </if>
            <if test="warehouseCode != null">
                warehouse_code,
            </if>
            <if test="ownerCode != null">
                owner_code,
            </if>
            <if test="quantityReservation != null">
                quantity_reservation,
            </if>
            <if test="quantityTransport != null">
                quantity_transport,
            </if>
            <if test="quantityTransfer != null">
                quantity_transfer,
            </if>
            <if test="quantityFreeze != null">
                quantity_freeze,
            </if>
            <if test="quantitySupplier != null">
                quantity_supplier,
            </if>
            <if test="quantityPresell != null">
                quantity_presell,
            </if>
            <if test="quantityDefective != null">
                quantity_defective,
            </if>
            <if test="quantityTransit != null">
                quantity_transit,
            </if>
            <if test="waitCheck != null">
                wait_check,
            </if>
            <if test="waitPutaway != null">
                wait_putaway,
            </if>
            <if test="usableStock != null">
                usable_stock,
            </if>
            <if test="usableSales != null">
                usable_sales,
            </if>
            <if test="usableSalesPrivate != null">
                usable_sales_private,
            </if>
            <if test="usableSalesShare != null">
                usable_sales_share,
            </if>
            <if test="inWarehouseShare != null">
                in_warehouse_share,
            </if>
            <if test="inWarehousePrivate != null">
                in_warehouse_private,
            </if>
            <if test="inWarehouse != null">
                in_warehouse,
            </if>
            <if test="occupyStockShare != null">
                occupy_stock_share,
            </if>
            <if test="occupyStockPrivate != null">
                occupy_stock_private,
            </if>
            <if test="occupyStock != null">
                occupy_stock,
            </if>
            <if test="occupyActivity != null">
                occupy_activity,
            </if>
            <if test="occupyOrderPrivate != null">
                occupy_order_private,
            </if>
            <if test="occupyOrderShare != null">
                occupy_order_share,
            </if>
            <if test="occupyOrder != null">
                occupy_order,
            </if>
            <if test="gmtCreate != null">
                gmt_create,
            </if>
            <if test="gmtModified != null">
                gmt_modified,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="updateTime != null">
                update_time,
            </if>
            <if test="shippedStock != null">
                shipped_stock,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="bailunSku != null">
                #{bailunSku,jdbcType=VARCHAR},
            </if>
            <if test="warehouseCode != null">
                #{warehouseCode,jdbcType=VARCHAR},
            </if>
            <if test="ownerCode != null">
                #{ownerCode,jdbcType=VARCHAR},
            </if>
            <if test="quantityReservation != null">
                #{quantityReservation,jdbcType=INTEGER},
            </if>
            <if test="quantityTransport != null">
                #{quantityTransport,jdbcType=INTEGER},
            </if>
            <if test="quantityTransfer != null">
                #{quantityTransfer,jdbcType=INTEGER},
            </if>
            <if test="quantityFreeze != null">
                #{quantityFreeze,jdbcType=INTEGER},
            </if>
            <if test="quantitySupplier != null">
                #{quantitySupplier,jdbcType=INTEGER},
            </if>
            <if test="quantityPresell != null">
                #{quantityPresell,jdbcType=INTEGER},
            </if>
            <if test="quantityDefective != null">
                #{quantityDefective,jdbcType=INTEGER},
            </if>
            <if test="quantityTransit != null">
                #{quantityTransit,jdbcType=INTEGER},
            </if>
            <if test="waitCheck != null">
                #{waitCheck,jdbcType=INTEGER},
            </if>
            <if test="waitPutaway != null">
                #{waitPutaway,jdbcType=INTEGER},
            </if>
            <if test="usableStock != null">
                #{usableStock,jdbcType=INTEGER},
            </if>
            <if test="usableSales != null">
                #{usableSales,jdbcType=INTEGER},
            </if>
            <if test="usableSalesPrivate != null">
                #{usableSalesPrivate,jdbcType=INTEGER},
            </if>
            <if test="usableSalesShare != null">
                #{usableSalesShare,jdbcType=INTEGER},
            </if>
            <if test="inWarehouseShare != null">
                #{inWarehouseShare,jdbcType=INTEGER},
            </if>
            <if test="inWarehousePrivate != null">
                #{inWarehousePrivate,jdbcType=INTEGER},
            </if>
            <if test="inWarehouse != null">
                #{inWarehouse,jdbcType=INTEGER},
            </if>
            <if test="occupyStockShare != null">
                #{occupyStockShare,jdbcType=INTEGER},
            </if>
            <if test="occupyStockPrivate != null">
                #{occupyStockPrivate,jdbcType=INTEGER},
            </if>
            <if test="occupyStock != null">
                #{occupyStock,jdbcType=INTEGER},
            </if>
            <if test="occupyActivity != null">
                #{occupyActivity,jdbcType=INTEGER},
            </if>
            <if test="occupyOrderPrivate != null">
                #{occupyOrderPrivate,jdbcType=INTEGER},
            </if>
            <if test="occupyOrderShare != null">
                #{occupyOrderShare,jdbcType=INTEGER},
            </if>
            <if test="occupyOrder != null">
                #{occupyOrder,jdbcType=INTEGER},
            </if>
            <if test="gmtCreate != null">
                #{gmtCreate,jdbcType=TIMESTAMP},
            </if>
            <if test="gmtModified != null">
                #{gmtModified,jdbcType=TIMESTAMP},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="shippedStock != null">
                #{shippedStock,jdbcType=INTEGER},
            </if>
        </trim>
    </insert>
    <select id="countByExample" parameterType="com.bailuntec.domain.example.DcBaseStockExample"
            resultType="java.lang.Long">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        select count(*) from dc_base_stock
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </select>
    <update id="updateByExampleSelective" parameterType="map">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update dc_base_stock
        <set>
            <if test="record.id != null">
                id = #{record.id,jdbcType=INTEGER},
            </if>
            <if test="record.bailunSku != null">
                bailun_sku = #{record.bailunSku,jdbcType=VARCHAR},
            </if>
            <if test="record.warehouseCode != null">
                warehouse_code = #{record.warehouseCode,jdbcType=VARCHAR},
            </if>
            <if test="record.ownerCode != null">
                owner_code = #{record.ownerCode,jdbcType=VARCHAR},
            </if>
            <if test="record.quantityReservation != null">
                quantity_reservation = #{record.quantityReservation,jdbcType=INTEGER},
            </if>
            <if test="record.quantityTransport != null">
                quantity_transport = #{record.quantityTransport,jdbcType=INTEGER},
            </if>
            <if test="record.quantityTransfer != null">
                quantity_transfer = #{record.quantityTransfer,jdbcType=INTEGER},
            </if>
            <if test="record.quantityFreeze != null">
                quantity_freeze = #{record.quantityFreeze,jdbcType=INTEGER},
            </if>
            <if test="record.quantitySupplier != null">
                quantity_supplier = #{record.quantitySupplier,jdbcType=INTEGER},
            </if>
            <if test="record.quantityPresell != null">
                quantity_presell = #{record.quantityPresell,jdbcType=INTEGER},
            </if>
            <if test="record.quantityDefective != null">
                quantity_defective = #{record.quantityDefective,jdbcType=INTEGER},
            </if>
            <if test="record.quantityTransit != null">
                quantity_transit = #{record.quantityTransit,jdbcType=INTEGER},
            </if>
            <if test="record.waitCheck != null">
                wait_check = #{record.waitCheck,jdbcType=INTEGER},
            </if>
            <if test="record.waitPutaway != null">
                wait_putaway = #{record.waitPutaway,jdbcType=INTEGER},
            </if>
            <if test="record.usableStock != null">
                usable_stock = #{record.usableStock,jdbcType=INTEGER},
            </if>
            <if test="record.usableSales != null">
                usable_sales = #{record.usableSales,jdbcType=INTEGER},
            </if>
            <if test="record.usableSalesPrivate != null">
                usable_sales_private = #{record.usableSalesPrivate,jdbcType=INTEGER},
            </if>
            <if test="record.usableSalesShare != null">
                usable_sales_share = #{record.usableSalesShare,jdbcType=INTEGER},
            </if>
            <if test="record.inWarehouseShare != null">
                in_warehouse_share = #{record.inWarehouseShare,jdbcType=INTEGER},
            </if>
            <if test="record.inWarehousePrivate != null">
                in_warehouse_private = #{record.inWarehousePrivate,jdbcType=INTEGER},
            </if>
            <if test="record.inWarehouse != null">
                in_warehouse = #{record.inWarehouse,jdbcType=INTEGER},
            </if>
            <if test="record.occupyStockShare != null">
                occupy_stock_share = #{record.occupyStockShare,jdbcType=INTEGER},
            </if>
            <if test="record.occupyStockPrivate != null">
                occupy_stock_private = #{record.occupyStockPrivate,jdbcType=INTEGER},
            </if>
            <if test="record.occupyStock != null">
                occupy_stock = #{record.occupyStock,jdbcType=INTEGER},
            </if>
            <if test="record.occupyActivity != null">
                occupy_activity = #{record.occupyActivity,jdbcType=INTEGER},
            </if>
            <if test="record.occupyOrderPrivate != null">
                occupy_order_private = #{record.occupyOrderPrivate,jdbcType=INTEGER},
            </if>
            <if test="record.occupyOrderShare != null">
                occupy_order_share = #{record.occupyOrderShare,jdbcType=INTEGER},
            </if>
            <if test="record.occupyOrder != null">
                occupy_order = #{record.occupyOrder,jdbcType=INTEGER},
            </if>
            <if test="record.gmtCreate != null">
                gmt_create = #{record.gmtCreate,jdbcType=TIMESTAMP},
            </if>
            <if test="record.gmtModified != null">
                gmt_modified = #{record.gmtModified,jdbcType=TIMESTAMP},
            </if>
            <if test="record.createTime != null">
                create_time = #{record.createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="record.updateTime != null">
                update_time = #{record.updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="record.shippedStock != null">
                shipped_stock = #{record.shippedStock,jdbcType=INTEGER},
            </if>
        </set>
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByExample" parameterType="map">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update dc_base_stock
        set id = #{record.id,jdbcType=INTEGER},
        bailun_sku = #{record.bailunSku,jdbcType=VARCHAR},
        warehouse_code = #{record.warehouseCode,jdbcType=VARCHAR},
        owner_code = #{record.ownerCode,jdbcType=VARCHAR},
        quantity_reservation = #{record.quantityReservation,jdbcType=INTEGER},
        quantity_transport = #{record.quantityTransport,jdbcType=INTEGER},
        quantity_transfer = #{record.quantityTransfer,jdbcType=INTEGER},
        quantity_freeze = #{record.quantityFreeze,jdbcType=INTEGER},
        quantity_supplier = #{record.quantitySupplier,jdbcType=INTEGER},
        quantity_presell = #{record.quantityPresell,jdbcType=INTEGER},
        quantity_defective = #{record.quantityDefective,jdbcType=INTEGER},
        quantity_transit = #{record.quantityTransit,jdbcType=INTEGER},
        wait_check = #{record.waitCheck,jdbcType=INTEGER},
        wait_putaway = #{record.waitPutaway,jdbcType=INTEGER},
        usable_stock = #{record.usableStock,jdbcType=INTEGER},
        usable_sales = #{record.usableSales,jdbcType=INTEGER},
        usable_sales_private = #{record.usableSalesPrivate,jdbcType=INTEGER},
        usable_sales_share = #{record.usableSalesShare,jdbcType=INTEGER},
        in_warehouse_share = #{record.inWarehouseShare,jdbcType=INTEGER},
        in_warehouse_private = #{record.inWarehousePrivate,jdbcType=INTEGER},
        in_warehouse = #{record.inWarehouse,jdbcType=INTEGER},
        occupy_stock_share = #{record.occupyStockShare,jdbcType=INTEGER},
        occupy_stock_private = #{record.occupyStockPrivate,jdbcType=INTEGER},
        occupy_stock = #{record.occupyStock,jdbcType=INTEGER},
        occupy_activity = #{record.occupyActivity,jdbcType=INTEGER},
        occupy_order_private = #{record.occupyOrderPrivate,jdbcType=INTEGER},
        occupy_order_share = #{record.occupyOrderShare,jdbcType=INTEGER},
        occupy_order = #{record.occupyOrder,jdbcType=INTEGER},
        gmt_create = #{record.gmtCreate,jdbcType=TIMESTAMP},
        gmt_modified = #{record.gmtModified,jdbcType=TIMESTAMP},
        create_time = #{record.createTime,jdbcType=TIMESTAMP},
        update_time = #{record.updateTime,jdbcType=TIMESTAMP},
        shipped_stock = #{record.shippedStock,jdbcType=INTEGER}
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.bailuntec.domain.entity.DcBaseStock">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update dc_base_stock
        <set>
            <if test="bailunSku != null">
                bailun_sku = #{bailunSku,jdbcType=VARCHAR},
            </if>
            <if test="warehouseCode != null">
                warehouse_code = #{warehouseCode,jdbcType=VARCHAR},
            </if>
            <if test="ownerCode != null">
                owner_code = #{ownerCode,jdbcType=VARCHAR},
            </if>
            <if test="quantityReservation != null">
                quantity_reservation = #{quantityReservation,jdbcType=INTEGER},
            </if>
            <if test="quantityTransport != null">
                quantity_transport = #{quantityTransport,jdbcType=INTEGER},
            </if>
            <if test="quantityTransfer != null">
                quantity_transfer = #{quantityTransfer,jdbcType=INTEGER},
            </if>
            <if test="quantityFreeze != null">
                quantity_freeze = #{quantityFreeze,jdbcType=INTEGER},
            </if>
            <if test="quantitySupplier != null">
                quantity_supplier = #{quantitySupplier,jdbcType=INTEGER},
            </if>
            <if test="quantityPresell != null">
                quantity_presell = #{quantityPresell,jdbcType=INTEGER},
            </if>
            <if test="quantityDefective != null">
                quantity_defective = #{quantityDefective,jdbcType=INTEGER},
            </if>
            <if test="quantityTransit != null">
                quantity_transit = #{quantityTransit,jdbcType=INTEGER},
            </if>
            <if test="waitCheck != null">
                wait_check = #{waitCheck,jdbcType=INTEGER},
            </if>
            <if test="waitPutaway != null">
                wait_putaway = #{waitPutaway,jdbcType=INTEGER},
            </if>
            <if test="usableStock != null">
                usable_stock = #{usableStock,jdbcType=INTEGER},
            </if>
            <if test="usableSales != null">
                usable_sales = #{usableSales,jdbcType=INTEGER},
            </if>
            <if test="usableSalesPrivate != null">
                usable_sales_private = #{usableSalesPrivate,jdbcType=INTEGER},
            </if>
            <if test="usableSalesShare != null">
                usable_sales_share = #{usableSalesShare,jdbcType=INTEGER},
            </if>
            <if test="inWarehouseShare != null">
                in_warehouse_share = #{inWarehouseShare,jdbcType=INTEGER},
            </if>
            <if test="inWarehousePrivate != null">
                in_warehouse_private = #{inWarehousePrivate,jdbcType=INTEGER},
            </if>
            <if test="inWarehouse != null">
                in_warehouse = #{inWarehouse,jdbcType=INTEGER},
            </if>
            <if test="occupyStockShare != null">
                occupy_stock_share = #{occupyStockShare,jdbcType=INTEGER},
            </if>
            <if test="occupyStockPrivate != null">
                occupy_stock_private = #{occupyStockPrivate,jdbcType=INTEGER},
            </if>
            <if test="occupyStock != null">
                occupy_stock = #{occupyStock,jdbcType=INTEGER},
            </if>
            <if test="occupyActivity != null">
                occupy_activity = #{occupyActivity,jdbcType=INTEGER},
            </if>
            <if test="occupyOrderPrivate != null">
                occupy_order_private = #{occupyOrderPrivate,jdbcType=INTEGER},
            </if>
            <if test="occupyOrderShare != null">
                occupy_order_share = #{occupyOrderShare,jdbcType=INTEGER},
            </if>
            <if test="occupyOrder != null">
                occupy_order = #{occupyOrder,jdbcType=INTEGER},
            </if>
            <if test="gmtCreate != null">
                gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
            </if>
            <if test="gmtModified != null">
                gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
            </if>
            <if test="createTime != null">
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                update_time = #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="shippedStock != null">
                shipped_stock = #{shippedStock,jdbcType=INTEGER},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.bailuntec.domain.entity.DcBaseStock">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update dc_base_stock
        set bailun_sku = #{bailunSku,jdbcType=VARCHAR},
        warehouse_code = #{warehouseCode,jdbcType=VARCHAR},
        owner_code = #{ownerCode,jdbcType=VARCHAR},
        quantity_reservation = #{quantityReservation,jdbcType=INTEGER},
        quantity_transport = #{quantityTransport,jdbcType=INTEGER},
        quantity_transfer = #{quantityTransfer,jdbcType=INTEGER},
        quantity_freeze = #{quantityFreeze,jdbcType=INTEGER},
        quantity_supplier = #{quantitySupplier,jdbcType=INTEGER},
        quantity_presell = #{quantityPresell,jdbcType=INTEGER},
        quantity_defective = #{quantityDefective,jdbcType=INTEGER},
        quantity_transit = #{quantityTransit,jdbcType=INTEGER},
        wait_check = #{waitCheck,jdbcType=INTEGER},
        wait_putaway = #{waitPutaway,jdbcType=INTEGER},
        usable_stock = #{usableStock,jdbcType=INTEGER},
        usable_sales = #{usableSales,jdbcType=INTEGER},
        usable_sales_private = #{usableSalesPrivate,jdbcType=INTEGER},
        usable_sales_share = #{usableSalesShare,jdbcType=INTEGER},
        in_warehouse_share = #{inWarehouseShare,jdbcType=INTEGER},
        in_warehouse_private = #{inWarehousePrivate,jdbcType=INTEGER},
        in_warehouse = #{inWarehouse,jdbcType=INTEGER},
        occupy_stock_share = #{occupyStockShare,jdbcType=INTEGER},
        occupy_stock_private = #{occupyStockPrivate,jdbcType=INTEGER},
        occupy_stock = #{occupyStock,jdbcType=INTEGER},
        occupy_activity = #{occupyActivity,jdbcType=INTEGER},
        occupy_order_private = #{occupyOrderPrivate,jdbcType=INTEGER},
        occupy_order_share = #{occupyOrderShare,jdbcType=INTEGER},
        occupy_order = #{occupyOrder,jdbcType=INTEGER},
        gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
        gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
        create_time = #{createTime,jdbcType=TIMESTAMP},
        update_time = #{updateTime,jdbcType=TIMESTAMP},
        shipped_stock = #{shippedStock,jdbcType=INTEGER}
        where id = #{id,jdbcType=INTEGER}
    </update>
    <insert id="upsertSelective" parameterType="com.bailuntec.domain.entity.DcBaseStock">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          @project https://github.com/itfsw/mybatis-generator-plugin
        -->
        insert into dc_base_stock
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="bailunSku != null">
                bailun_sku,
            </if>
            <if test="warehouseCode != null">
                warehouse_code,
            </if>
            <if test="ownerCode != null">
                owner_code,
            </if>
            <if test="quantityReservation != null">
                quantity_reservation,
            </if>
            <if test="quantityTransport != null">
                quantity_transport,
            </if>
            <if test="quantityTransfer != null">
                quantity_transfer,
            </if>
            <if test="quantityFreeze != null">
                quantity_freeze,
            </if>
            <if test="quantitySupplier != null">
                quantity_supplier,
            </if>
            <if test="quantityPresell != null">
                quantity_presell,
            </if>
            <if test="quantityDefective != null">
                quantity_defective,
            </if>
            <if test="quantityTransit != null">
                quantity_transit,
            </if>
            <if test="waitCheck != null">
                wait_check,
            </if>
            <if test="waitPutaway != null">
                wait_putaway,
            </if>
            <if test="usableStock != null">
                usable_stock,
            </if>
            <if test="usableSales != null">
                usable_sales,
            </if>
            <if test="usableSalesPrivate != null">
                usable_sales_private,
            </if>
            <if test="usableSalesShare != null">
                usable_sales_share,
            </if>
            <if test="inWarehouseShare != null">
                in_warehouse_share,
            </if>
            <if test="inWarehousePrivate != null">
                in_warehouse_private,
            </if>
            <if test="inWarehouse != null">
                in_warehouse,
            </if>
            <if test="occupyStockShare != null">
                occupy_stock_share,
            </if>
            <if test="occupyStockPrivate != null">
                occupy_stock_private,
            </if>
            <if test="occupyStock != null">
                occupy_stock,
            </if>
            <if test="occupyActivity != null">
                occupy_activity,
            </if>
            <if test="occupyOrderPrivate != null">
                occupy_order_private,
            </if>
            <if test="occupyOrderShare != null">
                occupy_order_share,
            </if>
            <if test="occupyOrder != null">
                occupy_order,
            </if>
            <if test="gmtCreate != null">
                gmt_create,
            </if>
            <if test="gmtModified != null">
                gmt_modified,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="updateTime != null">
                update_time,
            </if>
            <if test="shippedStock != null">
                shipped_stock,
            </if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="bailunSku != null">
                #{bailunSku,jdbcType=VARCHAR},
            </if>
            <if test="warehouseCode != null">
                #{warehouseCode,jdbcType=VARCHAR},
            </if>
            <if test="ownerCode != null">
                #{ownerCode,jdbcType=VARCHAR},
            </if>
            <if test="quantityReservation != null">
                #{quantityReservation,jdbcType=INTEGER},
            </if>
            <if test="quantityTransport != null">
                #{quantityTransport,jdbcType=INTEGER},
            </if>
            <if test="quantityTransfer != null">
                #{quantityTransfer,jdbcType=INTEGER},
            </if>
            <if test="quantityFreeze != null">
                #{quantityFreeze,jdbcType=INTEGER},
            </if>
            <if test="quantitySupplier != null">
                #{quantitySupplier,jdbcType=INTEGER},
            </if>
            <if test="quantityPresell != null">
                #{quantityPresell,jdbcType=INTEGER},
            </if>
            <if test="quantityDefective != null">
                #{quantityDefective,jdbcType=INTEGER},
            </if>
            <if test="quantityTransit != null">
                #{quantityTransit,jdbcType=INTEGER},
            </if>
            <if test="waitCheck != null">
                #{waitCheck,jdbcType=INTEGER},
            </if>
            <if test="waitPutaway != null">
                #{waitPutaway,jdbcType=INTEGER},
            </if>
            <if test="usableStock != null">
                #{usableStock,jdbcType=INTEGER},
            </if>
            <if test="usableSales != null">
                #{usableSales,jdbcType=INTEGER},
            </if>
            <if test="usableSalesPrivate != null">
                #{usableSalesPrivate,jdbcType=INTEGER},
            </if>
            <if test="usableSalesShare != null">
                #{usableSalesShare,jdbcType=INTEGER},
            </if>
            <if test="inWarehouseShare != null">
                #{inWarehouseShare,jdbcType=INTEGER},
            </if>
            <if test="inWarehousePrivate != null">
                #{inWarehousePrivate,jdbcType=INTEGER},
            </if>
            <if test="inWarehouse != null">
                #{inWarehouse,jdbcType=INTEGER},
            </if>
            <if test="occupyStockShare != null">
                #{occupyStockShare,jdbcType=INTEGER},
            </if>
            <if test="occupyStockPrivate != null">
                #{occupyStockPrivate,jdbcType=INTEGER},
            </if>
            <if test="occupyStock != null">
                #{occupyStock,jdbcType=INTEGER},
            </if>
            <if test="occupyActivity != null">
                #{occupyActivity,jdbcType=INTEGER},
            </if>
            <if test="occupyOrderPrivate != null">
                #{occupyOrderPrivate,jdbcType=INTEGER},
            </if>
            <if test="occupyOrderShare != null">
                #{occupyOrderShare,jdbcType=INTEGER},
            </if>
            <if test="occupyOrder != null">
                #{occupyOrder,jdbcType=INTEGER},
            </if>
            <if test="gmtCreate != null">
                #{gmtCreate,jdbcType=TIMESTAMP},
            </if>
            <if test="gmtModified != null">
                #{gmtModified,jdbcType=TIMESTAMP},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="shippedStock != null">
                #{shippedStock,jdbcType=INTEGER},
            </if>
        </trim>
        on duplicate key update
        <trim suffixOverrides=",">
            <if test="id != null">
                id = #{id,jdbcType=INTEGER},
            </if>
            <if test="bailunSku != null">
                bailun_sku = #{bailunSku,jdbcType=VARCHAR},
            </if>
            <if test="warehouseCode != null">
                warehouse_code = #{warehouseCode,jdbcType=VARCHAR},
            </if>
            <if test="ownerCode != null">
                owner_code = #{ownerCode,jdbcType=VARCHAR},
            </if>
            <if test="quantityReservation != null">
                quantity_reservation = #{quantityReservation,jdbcType=INTEGER},
            </if>
            <if test="quantityTransport != null">
                quantity_transport = #{quantityTransport,jdbcType=INTEGER},
            </if>
            <if test="quantityTransfer != null">
                quantity_transfer = #{quantityTransfer,jdbcType=INTEGER},
            </if>
            <if test="quantityFreeze != null">
                quantity_freeze = #{quantityFreeze,jdbcType=INTEGER},
            </if>
            <if test="quantitySupplier != null">
                quantity_supplier = #{quantitySupplier,jdbcType=INTEGER},
            </if>
            <if test="quantityPresell != null">
                quantity_presell = #{quantityPresell,jdbcType=INTEGER},
            </if>
            <if test="quantityDefective != null">
                quantity_defective = #{quantityDefective,jdbcType=INTEGER},
            </if>
            <if test="quantityTransit != null">
                quantity_transit = #{quantityTransit,jdbcType=INTEGER},
            </if>
            <if test="waitCheck != null">
                wait_check = #{waitCheck,jdbcType=INTEGER},
            </if>
            <if test="waitPutaway != null">
                wait_putaway = #{waitPutaway,jdbcType=INTEGER},
            </if>
            <if test="usableStock != null">
                usable_stock = #{usableStock,jdbcType=INTEGER},
            </if>
            <if test="usableSales != null">
                usable_sales = #{usableSales,jdbcType=INTEGER},
            </if>
            <if test="usableSalesPrivate != null">
                usable_sales_private = #{usableSalesPrivate,jdbcType=INTEGER},
            </if>
            <if test="usableSalesShare != null">
                usable_sales_share = #{usableSalesShare,jdbcType=INTEGER},
            </if>
            <if test="inWarehouseShare != null">
                in_warehouse_share = #{inWarehouseShare,jdbcType=INTEGER},
            </if>
            <if test="inWarehousePrivate != null">
                in_warehouse_private = #{inWarehousePrivate,jdbcType=INTEGER},
            </if>
            <if test="inWarehouse != null">
                in_warehouse = #{inWarehouse,jdbcType=INTEGER},
            </if>
            <if test="occupyStockShare != null">
                occupy_stock_share = #{occupyStockShare,jdbcType=INTEGER},
            </if>
            <if test="occupyStockPrivate != null">
                occupy_stock_private = #{occupyStockPrivate,jdbcType=INTEGER},
            </if>
            <if test="occupyStock != null">
                occupy_stock = #{occupyStock,jdbcType=INTEGER},
            </if>
            <if test="occupyActivity != null">
                occupy_activity = #{occupyActivity,jdbcType=INTEGER},
            </if>
            <if test="occupyOrderPrivate != null">
                occupy_order_private = #{occupyOrderPrivate,jdbcType=INTEGER},
            </if>
            <if test="occupyOrderShare != null">
                occupy_order_share = #{occupyOrderShare,jdbcType=INTEGER},
            </if>
            <if test="occupyOrder != null">
                occupy_order = #{occupyOrder,jdbcType=INTEGER},
            </if>
            <if test="gmtCreate != null">
                gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
            </if>
            <if test="gmtModified != null">
                gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
            </if>
            <if test="createTime != null">
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                update_time = #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="shippedStock != null">
                shipped_stock = #{shippedStock,jdbcType=INTEGER},
            </if>
        </trim>
    </insert>
    <insert id="upsert" parameterType="com.bailuntec.domain.entity.DcBaseStock">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          @project https://github.com/itfsw/mybatis-generator-plugin
        -->
        insert into dc_base_stock
        (id, bailun_sku, warehouse_code, owner_code, quantity_reservation, quantity_transport,
        quantity_transfer, quantity_freeze, quantity_supplier, quantity_presell, quantity_defective,
        quantity_transit, wait_check, wait_putaway, usable_stock, usable_sales, usable_sales_private,
        usable_sales_share, in_warehouse_share, in_warehouse_private, in_warehouse, occupy_stock_share,
        occupy_stock_private, occupy_stock, occupy_activity, occupy_order_private, occupy_order_share,
        occupy_order, gmt_create, gmt_modified, create_time, update_time, shipped_stock
        )
        values
        (#{id,jdbcType=INTEGER}, #{bailunSku,jdbcType=VARCHAR}, #{warehouseCode,jdbcType=VARCHAR},
        #{ownerCode,jdbcType=VARCHAR}, #{quantityReservation,jdbcType=INTEGER}, #{quantityTransport,jdbcType=INTEGER},
        #{quantityTransfer,jdbcType=INTEGER}, #{quantityFreeze,jdbcType=INTEGER}, #{quantitySupplier,jdbcType=INTEGER},
        #{quantityPresell,jdbcType=INTEGER}, #{quantityDefective,jdbcType=INTEGER}, #{quantityTransit,jdbcType=INTEGER},
        #{waitCheck,jdbcType=INTEGER}, #{waitPutaway,jdbcType=INTEGER}, #{usableStock,jdbcType=INTEGER},
        #{usableSales,jdbcType=INTEGER}, #{usableSalesPrivate,jdbcType=INTEGER}, #{usableSalesShare,jdbcType=INTEGER},
        #{inWarehouseShare,jdbcType=INTEGER}, #{inWarehousePrivate,jdbcType=INTEGER}, #{inWarehouse,jdbcType=INTEGER},
        #{occupyStockShare,jdbcType=INTEGER}, #{occupyStockPrivate,jdbcType=INTEGER}, #{occupyStock,jdbcType=INTEGER},
        #{occupyActivity,jdbcType=INTEGER}, #{occupyOrderPrivate,jdbcType=INTEGER},
        #{occupyOrderShare,jdbcType=INTEGER},
        #{occupyOrder,jdbcType=INTEGER}, #{gmtCreate,jdbcType=TIMESTAMP}, #{gmtModified,jdbcType=TIMESTAMP},
        #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{shippedStock,jdbcType=INTEGER}
        )
        on duplicate key update
        id = #{id,jdbcType=INTEGER},
        bailun_sku = #{bailunSku,jdbcType=VARCHAR},
        warehouse_code = #{warehouseCode,jdbcType=VARCHAR},
        owner_code = #{ownerCode,jdbcType=VARCHAR},
        quantity_reservation = #{quantityReservation,jdbcType=INTEGER},
        quantity_transport = #{quantityTransport,jdbcType=INTEGER},
        quantity_transfer = #{quantityTransfer,jdbcType=INTEGER},
        quantity_freeze = #{quantityFreeze,jdbcType=INTEGER},
        quantity_supplier = #{quantitySupplier,jdbcType=INTEGER},
        quantity_presell = #{quantityPresell,jdbcType=INTEGER},
        quantity_defective = #{quantityDefective,jdbcType=INTEGER},
        quantity_transit = #{quantityTransit,jdbcType=INTEGER},
        wait_check = #{waitCheck,jdbcType=INTEGER},
        wait_putaway = #{waitPutaway,jdbcType=INTEGER},
        usable_stock = #{usableStock,jdbcType=INTEGER},
        usable_sales = #{usableSales,jdbcType=INTEGER},
        usable_sales_private = #{usableSalesPrivate,jdbcType=INTEGER},
        usable_sales_share = #{usableSalesShare,jdbcType=INTEGER},
        in_warehouse_share = #{inWarehouseShare,jdbcType=INTEGER},
        in_warehouse_private = #{inWarehousePrivate,jdbcType=INTEGER},
        in_warehouse = #{inWarehouse,jdbcType=INTEGER},
        occupy_stock_share = #{occupyStockShare,jdbcType=INTEGER},
        occupy_stock_private = #{occupyStockPrivate,jdbcType=INTEGER},
        occupy_stock = #{occupyStock,jdbcType=INTEGER},
        occupy_activity = #{occupyActivity,jdbcType=INTEGER},
        occupy_order_private = #{occupyOrderPrivate,jdbcType=INTEGER},
        occupy_order_share = #{occupyOrderShare,jdbcType=INTEGER},
        occupy_order = #{occupyOrder,jdbcType=INTEGER},
        gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
        gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
        create_time = #{createTime,jdbcType=TIMESTAMP},
        update_time = #{updateTime,jdbcType=TIMESTAMP},
        shipped_stock = #{shippedStock,jdbcType=INTEGER}
    </insert>
    <select id="selectOneByExample" parameterType="com.bailuntec.domain.example.DcBaseStockExample"
            resultMap="BaseResultMap">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          @project https://github.com/itfsw/mybatis-generator-plugin
        -->
        select
        <include refid="Base_Column_List"/>
        from dc_base_stock
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
        limit 1
    </select>

    <insert id="supplementOrderSku">
        insert into dc_base_stock (bailun_sku, warehouse_code, sku_title_cn, product_inner_code, suppliers_name,
                                   source_from)
        SELECT tbo.bailun_sku,
               tbo.warehouse_code,
               tbsku.sku_title_cn,
               tbsku.product_inner_code,
               tbsku.suppliers_name,
               1 as source_from
        FROM (SELECT bailun_sku, warehouse_code
              FROM dc_base_oms_sku
              WHERE paid_time >= DATE_SUB(curdate(), INTERVAL 10 DAY)
                and warehouse_code != ''
                and bailun_sku != ''
              GROUP BY bailun_sku, warehouse_code) tbo
                 LEFT JOIN dc_base_stock tbs ON tbs.bailun_sku = tbo.bailun_sku
            AND tbs.warehouse_code = tbo.warehouse_code
                 LEFT JOIN dc_base_sku tbsku on tbsku.bailun_sku = tbo.bailun_sku
        WHERE tbs.bailun_sku IS NULL;
    </insert>

    <insert id="supplementPurchaseSku">
        insert into dc_base_stock (bailun_sku, warehouse_code, sku_title_cn, product_inner_code, suppliers_name,
                                   source_from)
        SELECT tbo.bailun_sku,
               tbo.warehouse_code,
               tbsku.sku_title_cn,
               tbsku.product_inner_code,
               tbsku.suppliers_name,
               2 as source_from
        FROM (SELECT bailun_sku, warehouse_code
              FROM dc_base_purchase
              WHERE create_time >= DATE_SUB(curdate(), INTERVAL 10 DAY)
                and warehouse_code != ''
                and bailun_sku != ''
              GROUP BY bailun_sku, warehouse_code) tbo
                 LEFT JOIN dc_base_stock tbs ON tbs.bailun_sku = tbo.bailun_sku
            AND tbs.warehouse_code = tbo.warehouse_code
                 LEFT JOIN dc_base_sku tbsku on tbsku.bailun_sku = tbo.bailun_sku
        WHERE tbs.bailun_sku IS NULL;
    </insert>

    <insert id="supplementTransitSku">
        insert into dc_base_stock (bailun_sku, warehouse_code, sku_title_cn, product_inner_code, suppliers_name,
                                   source_from)
        SELECT tbo.bailun_sku,
               tbo.warehouse_code,
               tbsku.sku_title_cn,
               tbsku.product_inner_code,
               tbsku.suppliers_name,
               3 as source_from
        FROM (SELECT bailun_sku, warehouse_code FROM dc_mid_transit WHERE warehouse_code != '' and bailun_sku != '') tbo
                 LEFT JOIN dc_base_stock tbs ON tbs.bailun_sku = tbo.bailun_sku
            AND tbs.warehouse_code = tbo.warehouse_code
                 LEFT JOIN dc_base_sku tbsku on tbsku.bailun_sku = tbo.bailun_sku
        WHERE tbs.bailun_sku IS NULL;
    </insert>


    <insert id="insertDailyStock">
        INSERT INTO dc_daily_stock (`bailun_sku`,
                                    `warehouse_code`,
                                    `owner_code`,
                                    `quantity_reservation`,
                                    `quantity_transport`,
                                    `quantity_transfer`,
                                    `quantity_freeze`,
                                    `quantity_supplier`,
                                    `quantity_presell`,
                                    `quantity_defective`,
                                    `quantity_transit`,
                                    `wait_check`,
                                    `wait_putaway`,
                                    `usable_stock`,
                                    `usable_sales`,
                                    `usable_sales_private`,
                                    `usable_sales_share`,
                                    `in_warehouse_share`,
                                    `in_warehouse_private`,
                                    `in_warehouse`,
                                    `occupy_stock_share`,
                                    `occupy_stock_private`,
                                    `occupy_stock`,
                                    `occupy_activity`,
                                    `occupy_order_private`,
                                    `occupy_order_share`,
                                    `occupy_order`,
                                    `gmt_create`,
                                    `gmt_modified`,
                                    `record_time`,
                                    `create_time`,
                                    `update_time`,
                                    unit_price)
        SELECT dc0.bailun_sku,
               dc0.warehouse_code,
               dc0.owner_code,
               dc0.quantity_reservation,
               dc0.quantity_transport,
               dc0.quantity_transfer,
               dc0.quantity_freeze,
               dc0.quantity_supplier,
               dc0.quantity_presell,
               dc0.quantity_defective,
               dc0.quantity_transit,
               dc0.wait_check,
               dc0.wait_putaway,
               dc0.usable_stock,
               dc0.usable_sales,
               dc0.usable_sales_private,
               dc0.usable_sales_share,
               dc0.in_warehouse_share,
               dc0.in_warehouse_private,
               dc0.in_warehouse,
               dc0.occupy_stock_share,
               dc0.occupy_stock_private,
               dc0.occupy_stock,
               dc0.occupy_activity,
               dc0.occupy_order_private,
               dc0.occupy_order_share,
               dc0.occupy_order,
               dc0.gmt_create,
               dc0.gmt_modified,
               DATE_SUB(CURDATE(), INTERVAL 1 DAY),
               dc0.create_time,
               dc0.update_time,
               ifnull(dc1.unit_price, 0)
        FROM dc_base_stock dc0
                 left join dc_base_sku dc1 on dc0.bailun_sku = dc1.bailun_sku
        where dc0.usable_stock > 0
           or dc0.occupy_stock > 0
    </insert>

    <update id="updateSkuUnitPrice">
        update dc_daily_stock t1, dc_base_sku t2
        set t1.unit_price = t2.unit_price
        WHERE t1.record_time = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
          and t1.bailun_sku = t2.bailun_sku
    </update>


    <select id="listNoChinaWarehouse" resultType="com.bailuntec.domain.entity.DcBaseStock">
        SELECT *
        FROM dc_base_stock tb1
                 inner join dc_base_warehouse tb2
                            on tb1.warehouse_code = tb2.warehouse_code and tb2.hq_type in ('FBA仓', '海外仓', '第三方仓库')
        order by type_id desc
        limit #{v1}, #{v2}
    </select>

    <select id="listStockById" resultType="com.bailuntec.domain.entity.DcBaseStock">
        SELECT *
        FROM dc_base_stock
        order by id asc
        limit #{v1}, #{v2}
    </select>

    <select id="listStockByIdPart" resultType="com.bailuntec.domain.entity.DcBaseStock">
        SELECT *
        FROM dc_base_stock tb1
        where tb1.id % #{shardingContext.shardingTotalCount} = #{shardingContext.shardingItem}
        limit #{v1}, #{v2}
    </select>

    <select id="listStockWarehouseById" resultType="com.bailuntec.domain.entity.DcBaseStock">
        SELECT *
        FROM dc_base_stock
        where warehouse_code = #{warehouseCode}
        order by id asc
        limit #{v1}, #{v2}
    </select>

    <select id="listParameterStockById" resultType="com.bailuntec.domain.entity.DcBaseStock">
        select *
        from dc_base_stock tb1
                 left join (select warehouse_code, hq_type from dc_base_warehouse where hq_type = #{jobParameter}) tb2
                           on tb1.warehouse_code = tb2.warehouse_code
                 LEFT JOIN dc_auto_turnover tb3
                           ON tb1.bailun_sku = tb3.bailun_sku and tb1.warehouse_code = tb3.warehouse_code
        where tb2.warehouse_code is not null
          and tb1.id % #{shardingContext.shardingTotalCount} = #{shardingContext.shardingItem}
        order by tb1.id asc
        limit #{v1}, #{v2}
    </select>

    <select id="listAllStock" resultType="com.bailuntec.domain.entity.DcBaseStock">
        select *
        from dc_base_stock tb1
                 LEFT JOIN dc_auto_turnover tb3
                           ON tb1.bailun_sku = tb3.bailun_sku and tb1.warehouse_code = tb3.warehouse_code
        where tb3.bailun_sku is null
          and tb1.id % #{shardingContext.shardingTotalCount} = #{shardingContext.shardingItem}
        order by tb1.id asc
        limit #{v1}, #{v2}
    </select>


    <select id="listWarehouseStockById" resultType="com.bailuntec.domain.entity.DcBaseStock">
        select *
        from dc_base_stock tb1
                 LEFT JOIN dc_auto_turnover tb3
                           ON tb1.bailun_sku = tb3.bailun_sku and tb1.warehouse_code = tb3.warehouse_code
        where tb1.warehouse_code = #{warehouseCode}
          and tb3.bailun_sku is null
          and tb1.id % #{shardingContext.shardingTotalCount} = #{shardingContext.shardingItem}
        order by tb1.id
        limit #{v1}, #{v2}
    </select>

    <select id="listInStockNotInAutoTurnover" resultType="com.bailuntec.domain.entity.DcBaseStock">
        SELECT tb1.*
        FROM dc_base_stock tb1
                 LEFT JOIN dc_auto_turnover tb2
                           ON tb1.bailun_sku = tb2.bailun_sku and tb1.warehouse_code = tb2.warehouse_code
                 left join dc_base_sku tb3 on tb1.bailun_sku = tb3.bailun_sku
        WHERE tb2.bailun_sku is null
          and tb1.warehouse_code = 'GZBLWH'
          and tb3.buyer_name in ('黎艳漫', '李志民')
          and tb3.push_time > '2019-08-01'
    </select>

    <select id="countByParam" resultType="long">
        select count(tb1.id)
        from dc_base_stock tb1
                 left join (select warehouse_code, hq_type from dc_base_warehouse where hq_type = #{jobParameter}) tb2
                           on tb1.warehouse_code = tb2.warehouse_code
                 LEFT JOIN dc_auto_turnover tb3
                           ON tb1.bailun_sku = tb3.bailun_sku and tb1.warehouse_code = tb3.warehouse_code
        where tb2.warehouse_code is not null
          and tb1.id % #{shardingContext.shardingTotalCount} = #{shardingContext.shardingItem}
    </select>

    <select id="countAll" resultType="long">
        select count(tb1.id)
        from dc_base_stock tb1
                 LEFT JOIN dc_auto_turnover tb3
                           ON tb1.bailun_sku = tb3.bailun_sku and tb1.warehouse_code = tb3.warehouse_code
        where tb3.bailun_sku is null
          and tb1.id % #{shardingContext.shardingTotalCount} = #{shardingContext.shardingItem}
    </select>

    <select id="countByWarehouseCode" resultType="long">
        select count(tb1.id)
        from dc_base_stock tb1
                 LEFT JOIN dc_auto_turnover tb3
                           ON tb1.bailun_sku = tb3.bailun_sku and tb1.warehouse_code = tb3.warehouse_code
        where tb1.warehouse_code = #{warehouseCode}
          and tb3.bailun_sku is null
          and tb1.id % #{shardingContext.shardingTotalCount} = #{shardingContext.shardingItem}
    </select>

    <select id="countNormal" resultType="java.lang.Long">
        select count(t1.id)
        from dc_base_stock as t1
                 left join dc_auto_config_sku_warehouse as t2
                           on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code
        where (t2.`status` = 0
            or t2.`status` is null)
          and t1.id % #{shardingContext.shardingTotalCount} = #{shardingContext.shardingItem}
    </select>

    <select id="listNormal" resultType="com.bailuntec.domain.entity.DcBaseStock">
        select t1.*
        from dc_base_stock as t1
                 left join dc_auto_config_sku_warehouse as t2
                           on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code
        where (t2.`status` = 0 or t2.`status` is null)
          and t1.id % #{shardingContext.shardingTotalCount} = #{shardingContext.shardingItem}
        order by t1.id
#         desc
        limit #{pageStart}, #{pageOffset};
    </select>

    <select id="countIncrement" resultType="java.lang.Long">
        SELECT count(id)
        from (SELECT t1.id, t1.bailun_sku, t1.warehouse_code
              from dc_base_oms_sku_30 t1
              where t1.gmt_create &gt;= #{v2}
                and t1.id % #{shardingContext.shardingTotalCount} = #{shardingContext.shardingItem}
              GROUP BY t1.bailun_sku, t1.warehouse_code) a
    </select>

    <select id="increment" resultType="com.bailuntec.domain.entity.DcBaseStock">
        SELECT t1.id, t1.bailun_sku, t1.warehouse_code
        from dc_base_oms_sku_30 t1
        where t1.gmt_create &gt;= #{v2}
          and t1.id % #{shardingContext.shardingTotalCount} = #{shardingContext.shardingItem}
        GROUP BY t1.bailun_sku, t1.warehouse_code
        limit #{pageStart},#{pageOffset};
    </select>

    <select id="listSpec" resultType="com.bailuntec.domain.entity.DcBaseStock">
        select t1.*
        from dc_base_stock as t1
                 left join dc_auto_config_sku_warehouse as t2
                           on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code
                 left join dc_base_sku as t3 on t1.bailun_sku = t3.bailun_sku
                 LEFT JOIN dc_auto_turnover t4
                           on t1.bailun_sku = t4.bailun_sku and t1.warehouse_code = t4.warehouse_code
        where (t2.`status` = 0
            or t2.`status` is null)
          and t3.buyer_name in ('李志民1', '李志民', '黎艳漫')
          and t1.warehouse_code = 'GZBLWH'
          and t1.id % #{shardingContext.shardingTotalCount} = #{shardingContext.shardingItem}
          and (t4.gmt_modified
                   &lt;
               '2020-09-08 09:00:00' or t4.id is null)
        limit #{pageStart}, #{pageOffset};
    </select>

    <select id="countSpec" resultType="java.lang.Long">
        SELECT count(t1.id)
        from dc_base_stock as t1
                 left join dc_auto_config_sku_warehouse as t2
                           on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code
                 left join dc_base_sku as t3 on t1.bailun_sku = t3.bailun_sku
                 LEFT JOIN dc_auto_turnover t4
                           on t1.bailun_sku = t4.bailun_sku and t1.warehouse_code = t4.warehouse_code
        where (t2.`status` = 0
            or t2.`status` is null)
          and t3.buyer_name in ('李志民1', '李志民', '黎艳漫')
          and t1.warehouse_code = 'GZBLWH'
          and (t4.gmt_modified
                   &lt;
               '2020-09-08 09:00:00' or t4.id is null)
          and t1.id % #{shardingContext.shardingTotalCount} = #{shardingContext.shardingItem}
    </select>

    <select id="listNeNormal" resultType="com.bailuntec.domain.entity.DcBaseStock">
        select t1.*
        from dc_base_stock as t1
                 left join dc_auto_config_sku_warehouse as t2
                           on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code
        where (t2.`status` != 0 and t2.`status` is not null)
          and t1.id % #{shardingContext.shardingTotalCount} = #{shardingContext.shardingItem}
        limit #{pageStart}, #{pageOffset};
    </select>

    <select id="countNeNormal" resultType="java.lang.Long">
        select count(t1.id)
        from dc_base_stock as t1
                 left join dc_auto_config_sku_warehouse as t2
                           on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code
        where (t2.`status` != 0 and t2.`status` is not null)
          and t1.id % #{shardingContext.shardingTotalCount} = #{shardingContext.shardingItem}
    </select>


</mapper>
