ReceiptContainerDetailMapper.xml 2.89 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.receipt.receiptContainerDetail.mapper.ReceiptContainerDetailMapper">
    <select id="ListEntityByLike"  resultType="com.huaheng.pc.receipt.receiptContainerDetail.domain.ReceiptContainerDetail">
        SELECT H.id, H.headerId, H.receiptDetailId, D.materialCode,M.Name as 'materialName',M.specification as 'materialSpec',
        D.batch,D.lot, H.qty, H.created, H.createdBy
        FROM receipt_container_detail H left join receipt_detail D ON H.receiptDetailId=D.Id
        INNER JOIN material M ON m.`code`=D.materialCode and m.`enable`=TRUE and m.deleted=FALSE
        <where>
            <if test="id != null ">
                AND H.id = #{id}
            </if>
            <if test="headerId != null ">
                AND H.headerId = #{headerId}
            </if>
            <if test="receiptId != null ">
                AND H.receiptId = #{receiptId}
            </if>
            <if test="receiptDetailId != null ">
                AND H.receiptDetailId = #{receiptDetailId}
            </if>
            <if test="materialCode != null and materialCode != ''">
                <bind name="materialCodePattern" value="'%' + materialCode + '%'" />
                AND D.materialCode like #{materialCodePattern}
            </if>
            <if test="qty != null ">
                AND H.qty = #{qty}
            </if>
            <if test="params != null and params.createdBegin != null and params.createdBegin != ''">
                AND H.created &gt;= #{params.createdBegin}
            </if>
            <if test="params != null and params.createdEnd != null and params.createdEnd != ''">
                AND H.created &lt;= #{params.createdEnd}
            </if>
            <if test="createdBy != null and createdBy != ''">
                <bind name="createdByPattern" value="'%' + createdBy + '%'" />
                AND H.createdBy like #{createdByPattern}
            </if>
        </where>
    </select>

    <select id="countByHeaderId" resultType="java.lang.Integer">
        select count(1) from receipt_container_detail where  headerId =#{headerId}
    </select>

    <select id="countByReceiptId" resultType="java.lang.Integer">
        select count(1) from receipt_container_detail where  receiptId =#{receiptId}
    </select>

    <delete id="batchDelete">
        DELETE FROM receipt_container_detail WHERE id in
        <foreach collection="array" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <update id="updateReceiptDetailQty">
        UPDATE receipt_detail  SET qtyCompleted = qtyCompleted - #{qty} WHERE id = #{id}
    </update>

    <update id="updateReceiptDetailStatus">
        UPDATE receipt_detail SET `status` = 0 WHERE qtyCompleted = 0 AND id = #{id}
    </update>

</mapper>