ShipmentHeaderMapper.xml 3.87 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.shipment.shipmentHeader.mapper.ShipmentHeaderMapper">

    <insert id="HeaderToHistory" parameterType="string">
        INSERT INTO shipment_header_history (
            code,warehouseCode,companyId,sourceCode,sourcePlatform,shipmentTypeId,shipTo,priority,station,totalQty,
            totalLines,remark,uploadremark,uploadTime,appointmentTime,firstStatus,lastStatus,uploadStatus,created,
            createdBy,lastUpdated,lastUpdatedBy,enable,deleted,userDef1,userDef2,userDef3)
        SELECT
            code,warehouseCode,companyId,sourceCode,sourcePlatform,shipmentTypeId,shipTo,priority,station,totalQty,
            totalLines,remark,uploadremark,uploadTime,appointmentTime,firstStatus,lastStatus,uploadStatus,created,
            createdBy,lastUpdated,lastUpdatedBy,enable,1,userDef1,userDef2,userDef3
        FROM shipment_header WHERE code = #{code,jdbcType=VARCHAR}
    </insert>

    <insert id="DetailToHistory" parameterType="string">
         INSERT INTO shipment_detail_history (
            sourceLine,shipmentCode,materialCode,batch,lot,project,manufactureDate,agingDate,inventoryStatus,qty,
            price,created,createdBy,lastUpdated,lastUpdatedBy,enable,deleted,userDef1,userDef2,userDef3)
         SELECT
            sourceLine,shipmentCode,materialCode,batch,lot,project,manufactureDate,agingDate,inventoryStatus,qty,
            price,created,createdBy,lastUpdated,lastUpdatedBy,enable,1,userDef1,userDef2,userDef3
         FROM shipment_detail WHERE shipmentCode = #{code,jdbcType=VARCHAR}
    </insert>


    <select id="list" resultType="com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader">
        select * from shipment_header
        <where>
            <if test="shipmentCode != null">
                and code = #{shipmentCode}
            </if>
            <if test="shipmentType != 0">
                and shipmentTypeId = #{shipmentType}
            </if>
            <if test="company != 0">
                and companyId = #{company}
            </if>
            <if test="firstStatus != null">
                and firstStatus = #{firstStatus}
            </if>
            <if test="lastStatus != null">
                and lastStatus = #{lastStatus}
            </if>
            <if test="beginTime != null">
                and created &gt;= #{beginTime}
            </if>
            <if test="endTime != null">
                and created &lt;= #{endTime}
            </if>
        </where>
    </select>
    <select id="getShipDetail" resultType="java.util.Map">
        SELECT detail.id, detail.shipmentId, detail.shipmentCode, detail.materialCode, detail.materialName,detail.qty, detail.qtyCompleted, m.name, i.locationCode,inventoryStatus, '个' unit
        FROM shipment_detail detail
        INNER JOIN material m ON detail.materialId = m.id and m.deleted = FALSE AND detail.shipmentCode = #{code}
        INNER JOIN sys_dict_data s ON s.dictType = 'inventoryStatus' AND detail.inventoryStatus = s.dictValue AND s.enable = TRUE AND s.deleted = FALSE
        INNER JOIN inventory i ON i.materialCode = detail.materialCode
    </select>
    <select id="getContainerMaterial" resultType="java.util.Map">
        SELECT  rch.locationCode, rcd.id, rd.receiptId, m.barcode, m.name, rd.qty
        FROM receipt_container_header rch
        INNER JOIN receipt_container_detail rcd ON rcd.headerId = rch.id AND rch.receiptContainerCode = #{containerCode,jdbcType=VARCHAR}
        INNER JOIN receipt_detail rd ON rd.id = rcd.receiptDetailId
        INNER JOIN material m ON rd.materialId = m.id AND m.deleted = FALSE
    </select>
    <select id="createCode" resultType="java.lang.String">
        SELECT code FROM shipment_header WHERE type = #{shipmentType,jdbcType=VARCHAR} ORDER BY id DESC LIMIT 1
    </select>
</mapper>