ReceiptHeaderMapper.xml 2.71 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.receiptHeader.mapper.ReceiptHeaderMapper">

    <select id="createCode" resultType="java.lang.String">
        SELECT code FROM receipt_header WHERE type = #{receiptType,jdbcType=VARCHAR} ORDER BY id DESC LIMIT 1
    </select>

    <insert id="headerToHistory">
        INSERT INTO receipt_header_history (
                code, warehouseCode, companyId, type, sourceCode, sourcePlatform, companyCode, totalQty,
                totalLines, remark, uploadStatus, uploadremark, uploadTime, appointmentTime, firstStatus, lastStatus,
                created, createdBy, lastUpdated, lastUpdatedBy, ENABLE, userDef1, userDef2, userDef3, deleted)
        SELECT
                code, warehouseCode, companyId, type, sourceCode, sourcePlatform, companyCode, totalQty,
                totalLines, remark,  uploadStatus, uploadremark, uploadTime, appointmentTime, firstStatus,
                lastStatus, created, createdBy, lastUpdated, lastUpdatedBy, ENABLE, userDef1, userDef2, userDef3, 1
        FROM receipt_header WHERE code = #{code,jdbcType=VARCHAR}
    </insert>

    <insert id="detailToHistory">
        INSERT INTO receipt_detail_history (
                id,sourceLine,receiptCode,materialCode,batch,lot,project,manufactureDate,expirationDate,inventoryStatus,qty,
                price,uploadTime,created,createdBy,lastUpdated,lastUpdatedBy,enable,deleted,userDef1,userDef2,userDef3)
        SELECT
                id,sourceLine,receiptCode,materialCode,batch,lot,project,manufactureDate,expirationDate,inventoryStatus,qty,
                price,uploadTime,created,createdBy,lastUpdated,lastUpdatedBy,enable,1,userDef1,userDef2,userDef3
        FROM receipt_detail WHERE receiptCode = #{code,jdbcType=VARCHAR}
    </insert>


    <select id="getDetail" resultType="java.util.HashMap">
        SELECT receipt_detail.id, receipt_detail.receiptId, receipt_detail.receiptCode, receipt_detail.materialCode, receipt_detail.sysQty,
        receipt_detail.qty, material.name, config_detail.description inventoryStatus, '个' unit
        FROM receipt_detail
        INNER JOIN material ON receipt_detail.materialId = material.id and material.deleted = FALSE AND receipt_detail.receiptCode = #{code,jdbcType=VARCHAR}
        INNER JOIN config_detail ON receipt_detail.inventoryStatus = config_detail.code AND config_detail.enable = TRUE AND config_detail.deleted = FALSE
        INNER JOIN config_header ON config_detail.headerId = config_header.id AND config_header.identifier = 'inventoryStatus' AND config_header.enable = TRUE AND config_header.deleted = FALSE
    </select>
    
</mapper>