<?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.ruoyi.business.mapper.TBaseGoodsMapper">
    
    <resultMap type="TBaseGoods" id="TBaseGoodsResult">
        <result property="goodsId"    column="GOODS_ID"    />
        <result property="goodsName"    column="GOODS_NAME"    />
        <result property="goodsShortName"    column="GOODS_SHORT_NAME"    />
        <result property="pyName"    column="PY_NAME"    />
        <result property="goodsTypeId"    column="GOODS_TYPE_ID"    />
        <result property="specification"    column="SPECIFICATION"    />
        <result property="model"    column="MODEL"    />
        <result property="price"    column="PRICE"    />
        <result property="barcode"    column="BARCODE"    />
        <result property="glength"    column="GLENGTH"    />
        <result property="gwidth"    column="GWIDTH"    />
        <result property="gheight"    column="GHEIGHT"    />
        <result property="gvolume"    column="GVOLUME"    />
        <result property="scaleUnit"    column="SCALE_UNIT"    />
        <result property="unit"    column="UNIT"    />
        <result property="warnUp"    column="WARN_UP"    />
        <result property="warnDown"    column="WARN_DOWN"    />
        <result property="produceArea"    column="PRODUCE_AREA"    />
        <result property="grossWeight"    column="GROSS_WEIGHT"    />
        <result property="netWeight"    column="NET_WEIGHT"    />
        <result property="providerId"    column="PROVIDER_ID"    />
        <result property="hsnumber"    column="HSNUMBER"    />
        <result property="abc"    column="ABC"    />
        <result property="hazardous"    column="HAZARDOUS"    />
        <result property="storageConditions"    column="STORAGE_CONDITIONS"    />
        <result property="period"    column="PERIOD"    />
        <result property="periodunit"    column="PERIODUNIT"    />
        <result property="addtax"    column="ADDTAX"    />
        <result property="season"    column="SEASON"    />
        <result property="tariffrate"    column="TARIFFRATE"    />
        <result property="remark"    column="REMARK"    />
        <result property="status"    column="STATUS"    />
        <result property="version"    column="VERSION"    />
        <result property="img"    column="IMG"    />
        <result property="createMan"    column="CREATE_MAN"    />
        <result property="createDate"    column="CREATE_DATE"    />
        <result property="updateMan"    column="UPDATE_MAN"    />
        <result property="updateDate"    column="UPDATE_DATE"    />
        <result property="scFlag"    column="SC_FLAG"    />
        <result property="costPrice"    column="COST_PRICE"    />
        <result property="customerId"    column="CUSTOMER_ID"    />
        <result property="sts1"    column="STS1"    />
        <result property="isOpen"    column="IS_OPEN"    />
        <result property="storageAreaId"    column="STORAGE_AREA_ID"    />
        <result property="zhFlag"    column="ZH_FLAG"    />
        <result property="semists"    column="SEMISTS"    />
        <result property="updateBy"    column="UPDATE_BY"    />
        <result property="materialCharacteristics"    column="MATERIAL_CHARACTERISTICS"    />
        <result property="recheckdays"    column="RECHECKDAYS"    />
    </resultMap>

    <sql id="selectTBaseGoodsVo">
        select GOODS_ID, GOODS_NAME, GOODS_SHORT_NAME, PY_NAME, GOODS_TYPE_ID, SPECIFICATION, MODEL, PRICE, BARCODE, GLENGTH, GWIDTH, GHEIGHT, GVOLUME, SCALE_UNIT, UNIT, WARN_UP, WARN_DOWN, PRODUCE_AREA, GROSS_WEIGHT, NET_WEIGHT, PROVIDER_ID, HSNUMBER, ABC, HAZARDOUS, STORAGE_CONDITIONS, PERIOD, PERIODUNIT, ADDTAX, SEASON, TARIFFRATE, REMARK, STATUS, VERSION, IMG, CREATE_MAN, CREATE_DATE, UPDATE_MAN, UPDATE_DATE, SC_FLAG, COST_PRICE, CUSTOMER_ID, STS1, IS_OPEN, STORAGE_AREA_ID, ZH_FLAG, SEMISTS, UPDATE_BY, MATERIAL_CHARACTERISTICS, RECHECKDAYS from t_base_goods
    </sql>

    <select id="selectTBaseGoodsList" parameterType="TBaseGoods" resultMap="TBaseGoodsResult">
        <include refid="selectTBaseGoodsVo"/>
        <where>  
            <if test="goodsId != null  and goodsId != ''"> and GOODS_ID = #{goodsId}</if>
            <if test="goodsName != null  and goodsName != ''"> and GOODS_NAME like concat('%', #{goodsName}, '%')</if>
            <if test="goodsShortName != null  and goodsShortName != ''"> and GOODS_SHORT_NAME like concat('%', #{goodsShortName}, '%')</if>
            <if test="pyName != null  and pyName != ''"> and PY_NAME like concat('%', #{pyName}, '%')</if>
            <if test="goodsTypeId != null  and goodsTypeId != ''"> and GOODS_TYPE_ID = #{goodsTypeId}</if>
            <if test="specification != null  and specification != ''"> and SPECIFICATION = #{specification}</if>
            <if test="model != null  and model != ''"> and MODEL = #{model}</if>
            <if test="price != null "> and PRICE = #{price}</if>
            <if test="barcode != null  and barcode != ''"> and BARCODE = #{barcode}</if>
            <if test="glength != null "> and GLENGTH = #{glength}</if>
            <if test="gwidth != null "> and GWIDTH = #{gwidth}</if>
            <if test="gheight != null "> and GHEIGHT = #{gheight}</if>
            <if test="gvolume != null "> and GVOLUME = #{gvolume}</if>
            <if test="scaleUnit != null  and scaleUnit != ''"> and SCALE_UNIT = #{scaleUnit}</if>
            <if test="unit != null  and unit != ''"> and UNIT = #{unit}</if>
            <if test="warnUp != null "> and WARN_UP = #{warnUp}</if>
            <if test="warnDown != null "> and WARN_DOWN = #{warnDown}</if>
            <if test="produceArea != null  and produceArea != ''"> and PRODUCE_AREA = #{produceArea}</if>
            <if test="grossWeight != null "> and GROSS_WEIGHT = #{grossWeight}</if>
            <if test="netWeight != null "> and NET_WEIGHT = #{netWeight}</if>
            <if test="providerId != null  and providerId != ''"> and PROVIDER_ID = #{providerId}</if>
            <if test="hsnumber != null  and hsnumber != ''"> and HSNUMBER = #{hsnumber}</if>
            <if test="abc != null  and abc != ''"> and ABC = #{abc}</if>
            <if test="hazardous != null  and hazardous != ''"> and HAZARDOUS = #{hazardous}</if>
            <if test="storageConditions != null  and storageConditions != ''"> and STORAGE_CONDITIONS = #{storageConditions}</if>
            <if test="period != null "> and PERIOD = #{period}</if>
            <if test="periodunit != null  and periodunit != ''"> and PERIODUNIT = #{periodunit}</if>
            <if test="addtax != null "> and ADDTAX = #{addtax}</if>
            <if test="season != null  and season != ''"> and SEASON = #{season}</if>
            <if test="tariffrate != null "> and TARIFFRATE = #{tariffrate}</if>
            <if test="remark != null  and remark != ''"> and REMARK = #{remark}</if>
            <if test="status != null  and status != ''"> and STATUS = #{status}</if>
            <if test="version != null  and version != ''"> and VERSION = #{version}</if>
            <if test="img != null  and img != ''"> and IMG = #{img}</if>
            <if test="createMan != null  and createMan != ''"> and CREATE_MAN = #{createMan}</if>
            <if test="createDate != null "> and CREATE_DATE = #{createDate}</if>
            <if test="updateMan != null  and updateMan != ''"> and UPDATE_MAN = #{updateMan}</if>
            <if test="updateDate != null "> and UPDATE_DATE = #{updateDate}</if>
            <if test="scFlag != null  and scFlag != ''"> and SC_FLAG = #{scFlag}</if>
            <if test="costPrice != null "> and COST_PRICE = #{costPrice}</if>
            <if test="customerId != null  and customerId != ''"> and CUSTOMER_ID = #{customerId}</if>
            <if test="sts1 != null  and sts1 != ''"> and STS1 = #{sts1}</if>
            <if test="isOpen != null  and isOpen != ''"> and IS_OPEN = #{isOpen}</if>
            <if test="storageAreaId != null  and storageAreaId != ''"> and STORAGE_AREA_ID = #{storageAreaId}</if>
            <if test="zhFlag != null  and zhFlag != ''"> and ZH_FLAG = #{zhFlag}</if>
            <if test="semists != null  and semists != ''"> and SEMISTS = #{semists}</if>
            <if test="updateBy != null  and updateBy != ''"> and UPDATE_BY = #{updateBy}</if>
            <if test="materialCharacteristics != null  and materialCharacteristics != ''"> and MATERIAL_CHARACTERISTICS = #{materialCharacteristics}</if>
            <if test="recheckdays != null "> and RECHECKDAYS = #{recheckdays}</if>
        </where>
    </select>
    
    <select id="selectTBaseGoodsByGoodsId" parameterType="String" resultMap="TBaseGoodsResult">
        <include refid="selectTBaseGoodsVo"/>
        where GOODS_ID = #{goodsId}
    </select>
        
    <insert id="insertTBaseGoods" parameterType="TBaseGoods">
        insert into t_base_goods
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="goodsId != null and goodsId != ''">GOODS_ID,</if>
            <if test="goodsName != null">GOODS_NAME,</if>
            <if test="goodsShortName != null">GOODS_SHORT_NAME,</if>
            <if test="pyName != null">PY_NAME,</if>
            <if test="goodsTypeId != null">GOODS_TYPE_ID,</if>
            <if test="specification != null">SPECIFICATION,</if>
            <if test="model != null">MODEL,</if>
            <if test="price != null">PRICE,</if>
            <if test="barcode != null">BARCODE,</if>
            <if test="glength != null">GLENGTH,</if>
            <if test="gwidth != null">GWIDTH,</if>
            <if test="gheight != null">GHEIGHT,</if>
            <if test="gvolume != null">GVOLUME,</if>
            <if test="scaleUnit != null">SCALE_UNIT,</if>
            <if test="unit != null">UNIT,</if>
            <if test="warnUp != null">WARN_UP,</if>
            <if test="warnDown != null">WARN_DOWN,</if>
            <if test="produceArea != null">PRODUCE_AREA,</if>
            <if test="grossWeight != null">GROSS_WEIGHT,</if>
            <if test="netWeight != null">NET_WEIGHT,</if>
            <if test="providerId != null">PROVIDER_ID,</if>
            <if test="hsnumber != null">HSNUMBER,</if>
            <if test="abc != null">ABC,</if>
            <if test="hazardous != null">HAZARDOUS,</if>
            <if test="storageConditions != null">STORAGE_CONDITIONS,</if>
            <if test="period != null">PERIOD,</if>
            <if test="periodunit != null">PERIODUNIT,</if>
            <if test="addtax != null">ADDTAX,</if>
            <if test="season != null">SEASON,</if>
            <if test="tariffrate != null">TARIFFRATE,</if>
            <if test="remark != null">REMARK,</if>
            <if test="status != null">STATUS,</if>
            <if test="version != null">VERSION,</if>
            <if test="img != null">IMG,</if>
            <if test="createMan != null">CREATE_MAN,</if>
            <if test="createDate != null">CREATE_DATE,</if>
            <if test="updateMan != null">UPDATE_MAN,</if>
            <if test="updateDate != null">UPDATE_DATE,</if>
            <if test="scFlag != null">SC_FLAG,</if>
            <if test="costPrice != null">COST_PRICE,</if>
            <if test="customerId != null">CUSTOMER_ID,</if>
            <if test="sts1 != null">STS1,</if>
            <if test="isOpen != null">IS_OPEN,</if>
            <if test="storageAreaId != null">STORAGE_AREA_ID,</if>
            <if test="zhFlag != null">ZH_FLAG,</if>
            <if test="semists != null">SEMISTS,</if>
            <if test="updateBy != null">UPDATE_BY,</if>
            <if test="materialCharacteristics != null">MATERIAL_CHARACTERISTICS,</if>
            <if test="recheckdays != null">RECHECKDAYS,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="goodsId != null and goodsId != ''">#{goodsId},</if>
            <if test="goodsName != null">#{goodsName},</if>
            <if test="goodsShortName != null">#{goodsShortName},</if>
            <if test="pyName != null">#{pyName},</if>
            <if test="goodsTypeId != null">#{goodsTypeId},</if>
            <if test="specification != null">#{specification},</if>
            <if test="model != null">#{model},</if>
            <if test="price != null">#{price},</if>
            <if test="barcode != null">#{barcode},</if>
            <if test="glength != null">#{glength},</if>
            <if test="gwidth != null">#{gwidth},</if>
            <if test="gheight != null">#{gheight},</if>
            <if test="gvolume != null">#{gvolume},</if>
            <if test="scaleUnit != null">#{scaleUnit},</if>
            <if test="unit != null">#{unit},</if>
            <if test="warnUp != null">#{warnUp},</if>
            <if test="warnDown != null">#{warnDown},</if>
            <if test="produceArea != null">#{produceArea},</if>
            <if test="grossWeight != null">#{grossWeight},</if>
            <if test="netWeight != null">#{netWeight},</if>
            <if test="providerId != null">#{providerId},</if>
            <if test="hsnumber != null">#{hsnumber},</if>
            <if test="abc != null">#{abc},</if>
            <if test="hazardous != null">#{hazardous},</if>
            <if test="storageConditions != null">#{storageConditions},</if>
            <if test="period != null">#{period},</if>
            <if test="periodunit != null">#{periodunit},</if>
            <if test="addtax != null">#{addtax},</if>
            <if test="season != null">#{season},</if>
            <if test="tariffrate != null">#{tariffrate},</if>
            <if test="remark != null">#{remark},</if>
            <if test="status != null">#{status},</if>
            <if test="version != null">#{version},</if>
            <if test="img != null">#{img},</if>
            <if test="createMan != null">#{createMan},</if>
            <if test="createDate != null">#{createDate},</if>
            <if test="updateMan != null">#{updateMan},</if>
            <if test="updateDate != null">#{updateDate},</if>
            <if test="scFlag != null">#{scFlag},</if>
            <if test="costPrice != null">#{costPrice},</if>
            <if test="customerId != null">#{customerId},</if>
            <if test="sts1 != null">#{sts1},</if>
            <if test="isOpen != null">#{isOpen},</if>
            <if test="storageAreaId != null">#{storageAreaId},</if>
            <if test="zhFlag != null">#{zhFlag},</if>
            <if test="semists != null">#{semists},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="materialCharacteristics != null">#{materialCharacteristics},</if>
            <if test="recheckdays != null">#{recheckdays},</if>
         </trim>
    </insert>

    <update id="updateTBaseGoods" parameterType="TBaseGoods">
        update t_base_goods
        <trim prefix="SET" suffixOverrides=",">
            <if test="goodsName != null">GOODS_NAME = #{goodsName},</if>
            <if test="goodsShortName != null">GOODS_SHORT_NAME = #{goodsShortName},</if>
            <if test="pyName != null">PY_NAME = #{pyName},</if>
            <if test="goodsTypeId != null">GOODS_TYPE_ID = #{goodsTypeId},</if>
            <if test="specification != null">SPECIFICATION = #{specification},</if>
            <if test="model != null">MODEL = #{model},</if>
            <if test="price != null">PRICE = #{price},</if>
            <if test="barcode != null">BARCODE = #{barcode},</if>
            <if test="glength != null">GLENGTH = #{glength},</if>
            <if test="gwidth != null">GWIDTH = #{gwidth},</if>
            <if test="gheight != null">GHEIGHT = #{gheight},</if>
            <if test="gvolume != null">GVOLUME = #{gvolume},</if>
            <if test="scaleUnit != null">SCALE_UNIT = #{scaleUnit},</if>
            <if test="unit != null">UNIT = #{unit},</if>
            <if test="warnUp != null">WARN_UP = #{warnUp},</if>
            <if test="warnDown != null">WARN_DOWN = #{warnDown},</if>
            <if test="produceArea != null">PRODUCE_AREA = #{produceArea},</if>
            <if test="grossWeight != null">GROSS_WEIGHT = #{grossWeight},</if>
            <if test="netWeight != null">NET_WEIGHT = #{netWeight},</if>
            <if test="providerId != null">PROVIDER_ID = #{providerId},</if>
            <if test="hsnumber != null">HSNUMBER = #{hsnumber},</if>
            <if test="abc != null">ABC = #{abc},</if>
            <if test="hazardous != null">HAZARDOUS = #{hazardous},</if>
            <if test="storageConditions != null">STORAGE_CONDITIONS = #{storageConditions},</if>
            <if test="period != null">PERIOD = #{period},</if>
            <if test="periodunit != null">PERIODUNIT = #{periodunit},</if>
            <if test="addtax != null">ADDTAX = #{addtax},</if>
            <if test="season != null">SEASON = #{season},</if>
            <if test="tariffrate != null">TARIFFRATE = #{tariffrate},</if>
            <if test="remark != null">REMARK = #{remark},</if>
            <if test="status != null">STATUS = #{status},</if>
            <if test="version != null">VERSION = #{version},</if>
            <if test="img != null">IMG = #{img},</if>
            <if test="createMan != null">CREATE_MAN = #{createMan},</if>
            <if test="createDate != null">CREATE_DATE = #{createDate},</if>
            <if test="updateMan != null">UPDATE_MAN = #{updateMan},</if>
            <if test="updateDate != null">UPDATE_DATE = #{updateDate},</if>
            <if test="scFlag != null">SC_FLAG = #{scFlag},</if>
            <if test="costPrice != null">COST_PRICE = #{costPrice},</if>
            <if test="customerId != null">CUSTOMER_ID = #{customerId},</if>
            <if test="sts1 != null">STS1 = #{sts1},</if>
            <if test="isOpen != null">IS_OPEN = #{isOpen},</if>
            <if test="storageAreaId != null">STORAGE_AREA_ID = #{storageAreaId},</if>
            <if test="zhFlag != null">ZH_FLAG = #{zhFlag},</if>
            <if test="semists != null">SEMISTS = #{semists},</if>
            <if test="updateBy != null">UPDATE_BY = #{updateBy},</if>
            <if test="materialCharacteristics != null">MATERIAL_CHARACTERISTICS = #{materialCharacteristics},</if>
            <if test="recheckdays != null">RECHECKDAYS = #{recheckdays},</if>
        </trim>
        where GOODS_ID = #{goodsId}
    </update>

    <delete id="deleteTBaseGoodsByGoodsId" parameterType="String">
        delete from t_base_goods where GOODS_ID = #{goodsId}
    </delete>

    <delete id="deleteTBaseGoodsByGoodsIds" parameterType="String">
        delete from t_base_goods where GOODS_ID in 
        <foreach item="goodsId" collection="array" open="(" separator="," close=")">
            #{goodsId}
        </foreach>
    </delete>

</mapper>