InventoryMapper.xml 7.82 KB
<?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.huaheng.pc.inventory.inventory.mapper.InventoryMapper">

    <select id="getInventoryBySearchModel" resultType="com.huaheng.pc.inventory.inventory.domain.Inventory" >
        select * from inventory
        <where>
            <if test="companyCode != null">
                and  code = #{companyCode}
            </if>
            <if test="materialCode != 0">
                and  materialCode = #{materialCode}
            </if>
            <if test="locationCode != 0">
                and  locationCode = #{locationCode}
            </if>
            <if test="beginTime != 0">
                and  created > #{beginTime}
            </if>
            <if test="endTime != 0">
                and  created &lt; #{endTime}
            </if>
        </where>
    </select>
    <select id="getInventryMaterialCode" resultType="java.lang.String">
        select distinct materialCode from inventory where materialCode like #{code}
    </select>

    <select id="selectListEntityByLike" resultType="com.huaheng.pc.inventory.inventory.domain.Inventory">
        SELECT id, warehouseId, warehouseCode, locationId, locationCode, sourceCode, sourceLine, companyId, companyCode, materialId, materialCode, receiptId, receiptCode, receiptDetailId, batch, lot, project, manufactureDate, expirationDate, status, qty, taskQty, costPrice, listPrice, netPrice, created, createdBy, lastUpdated, lastUpdatedBy, userDef1, userDef2, userDef3, deleted
        FROM inventory
        <where>
            <if test="id != null ">
                AND id = #{id}
            </if>
            <if test="warehouseId != null ">
                AND warehouseId = #{warehouseId}
            </if>
            <if test="warehouseCode != null and warehouseCode != ''">
                <bind name="warehouseCodePattern" value="'%' + warehouseCode + '%'" />
                AND warehouseCode like #{warehouseCodePattern}
            </if>
            <if test="locationId != null ">
                AND locationId = #{locationId}
            </if>
            <if test="locationCode != null and locationCode != ''">
                <bind name="locationCodePattern" value="'%' + locationCode + '%'" />
                AND locationCode like #{locationCodePattern}
            </if>
            <if test="sourceCode != null and sourceCode != ''">
                <bind name="sourceCodePattern" value="'%' + sourceCode + '%'" />
                AND sourceCode like #{sourceCodePattern}
            </if>
            <if test="sourceLine != null and sourceLine != ''">
                <bind name="sourceLinePattern" value="'%' + sourceLine + '%'" />
                AND sourceLine like #{sourceLinePattern}
            </if>
            <if test="companyId != null ">
                AND companyId = #{companyId}
            </if>
            <if test="companyCode != null and companyCode != ''">
                <bind name="companyCodePattern" value="'%' + companyCode + '%'" />
                AND companyCode like #{companyCodePattern}
            </if>
            <if test="materialId != null ">
                AND materialId = #{materialId}
            </if>
            <if test="materialCode != null and materialCode != ''">
                <bind name="materialCodePattern" value="'%' + materialCode + '%'" />
                AND materialCode like #{materialCodePattern}
            </if>
            <if test="receiptId != null ">
                AND receiptId = #{receiptId}
            </if>
            <if test="receiptCode != null and receiptCode != ''">
                <bind name="receiptCodePattern" value="'%' + receiptCode + '%'" />
                AND receiptCode like #{receiptCodePattern}
            </if>
            <if test="receiptDetailId != null ">
                AND receiptDetailId = #{receiptDetailId}
            </if>
            <if test="batch != null and batch != ''">
                <bind name="batchPattern" value="'%' + batch + '%'" />
                AND batch like #{batchPattern}
            </if>
            <if test="lot != null and lot != ''">
                <bind name="lotPattern" value="'%' + lot + '%'" />
                AND lot like #{lotPattern}
            </if>
            <if test="project != null and project != ''">
                <bind name="projectPattern" value="'%' + project + '%'" />
                AND project like #{projectPattern}
            </if>
            <if test="params != null and params.manufactureDateBegin != null and params.manufactureDateBegin != ''">
                AND manufactureDate &gt;= #{params.manufactureDateBegin}
            </if>
            <if test="params != null and params.manufactureDateEnd != null and params.manufactureDateEnd != ''">
                AND manufactureDate &lt;= #{params.manufactureDateEnd}
            </if>
            <if test="params != null and params.expirationDateBegin != null and params.expirationDateBegin != ''">
                AND expirationDate &gt;= #{params.expirationDateBegin}
            </if>
            <if test="params != null and params.expirationDateEnd != null and params.expirationDateEnd != ''">
                AND expirationDate &lt;= #{params.expirationDateEnd}
            </if>
            <if test="status != null and status != ''">
                <bind name="statusPattern" value="'%' + status + '%'" />
                AND status like #{statusPattern}
            </if>
            <if test="qty != null ">
                AND qty = #{qty}
            </if>
            <if test="taskQty != null ">
                AND taskQty = #{taskQty}
            </if>
            <if test="costPrice != null ">
                AND costPrice = #{costPrice}
            </if>
            <if test="listPrice != null ">
                AND listPrice = #{listPrice}
            </if>
            <if test="netPrice != null ">
                AND netPrice = #{netPrice}
            </if>
            <if test="params != null and params.createdBegin != null and params.createdBegin != ''">
                AND created &gt;= #{params.createdBegin}
            </if>
            <if test="params != null and params.createdEnd != null and params.createdEnd != ''">
                AND created &lt;= #{params.createdEnd}
            </if>
            <if test="createdBy != null and createdBy != ''">
                <bind name="createdByPattern" value="'%' + createdBy + '%'" />
                AND createdBy like #{createdByPattern}
            </if>
            <if test="params != null and params.lastUpdatedBegin != null and params.lastUpdatedBegin != ''">
                AND lastUpdated &gt;= #{params.lastUpdatedBegin}
            </if>
            <if test="params != null and params.lastUpdatedEnd != null and params.lastUpdatedEnd != ''">
                AND lastUpdated &lt;= #{params.lastUpdatedEnd}
            </if>
            <if test="lastUpdatedBy != null and lastUpdatedBy != ''">
                <bind name="lastUpdatedByPattern" value="'%' + lastUpdatedBy + '%'" />
                AND lastUpdatedBy like #{lastUpdatedByPattern}
            </if>
            <if test="userDef1 != null and userDef1 != ''">
                <bind name="userDef1Pattern" value="'%' + userDef1 + '%'" />
                AND userDef1 like #{userDef1Pattern}
            </if>
            <if test="userDef2 != null and userDef2 != ''">
                <bind name="userDef2Pattern" value="'%' + userDef2 + '%'" />
                AND userDef2 like #{userDef2Pattern}
            </if>
            <if test="userDef3 != null and userDef3 != ''">
                <bind name="userDef3Pattern" value="'%' + userDef3 + '%'" />
                AND userDef3 like #{userDef3Pattern}
            </if>
            <if test="deleted != null ">
                AND deleted = #{deleted}
            </if>
        </where>
    </select>
</mapper>