ShipmentContainerHeaderMapper.xml 8.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.shipment.shipmentContainerHeader.mapper.ShipmentContainerHeaderMapper">

    <select id="getShipmentContainerMaxAndMinStatusByShipmentID" resultType="java.util.Map">
        SELECT MAX(`status`) maxStatus , MIN(`status`) minStatus from shipment_container_header t join shipment_container_detail b on t.id = b.headerId
          WHERE  b.shipmentHeaderId = #{shipmentId}
    </select>

    <select id="getShipmentContainerHeaderByContainerCode"
            resultType="com.huaheng.pc.shipment.shipmentContainerHeader.domain.ShipmentContainerHeader">
        SELECT * from shipment_container_header where shipmentContainerCode = #{containerCode} and `status` &lt; 30 limit 1
    </select>

    <select id="listShipmentHeaders" resultType="com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader">
        SELECT id, code, warehouseId, warehouseCode, companyId, companyCode, sourceCode, sourcePlatform, type, shipTo,
        priority, station, totalQty, totalLines, remark, uploadremark, uploadTime, appointmentTime, firstStatus,
        lastStatus, uploadStatus, created, createdBy, lastUpdated, lastUpdatedBy, enable, userDef1, userDef2, userDef3
        FROM shipment_header
        <where>
            <if test="id != null">
                AND id = #{id}
            </if>
            <if test="code != null">
                AND code = #{code}
            </if>
            <if test="warehouseId != null">
                AND warehouseId = #{warehouseId}
            </if>
            <if test="warehouseCode != null">
                AND warehouseCode = #{warehouseCode}
            </if>
            <if test="companyId != null">
                AND companyId = #{companyId}
            </if>
            <if test="companyCode != null">
                AND companyCode = #{companyCode}
            </if>
            <if test="sourceCode != null">
                AND sourceCode = #{sourceCode}
            </if>
            <if test="sourcePlatform != null">
                AND sourcePlatform = #{sourcePlatform}
            </if>
            <if test="type != null">
                AND type = #{type}
            </if>
            <if test="shipTo != null">
                AND shipTo = #{shipTo}
            </if>
            <if test="priority != null">
                AND priority = #{priority}
            </if>
            <if test="station != null">
                AND station = #{station}
            </if>
            <if test="totalQty != null">
                AND totalQty = #{totalQty}
            </if>
            <if test="totalLines != null">
                AND totalLines = #{totalLines}
            </if>
            <if test="remark != null">
                AND remark = #{remark}
            </if>
            <if test="uploadremark != null">
                AND uploadremark = #{uploadremark}
            </if>
            <if test="uploadTime != null">
                AND uploadTime = #{uploadTime}
            </if>
            <if test="appointmentTime != null">
                AND appointmentTime = #{appointmentTime}
            </if>
            <if test="firstStatus != null">
                AND firstStatus &lt;= #{firstStatus}
            </if>
            <if test="lastStatus != null">
                AND lastStatus >= #{lastStatus}
            </if>
            <if test="uploadStatus != null">
                AND uploadStatus = #{uploadStatus}
            </if>
            <if test="created != null">
                AND created = #{created}
            </if>
            <if test="createdBy != null">
                AND createdBy = #{createdBy}
            </if>
            <if test="lastUpdated != null">
                AND lastUpdated = #{lastUpdated}
            </if>
            <if test="lastUpdatedBy != null">
                AND lastUpdatedBy = #{lastUpdatedBy}
            </if>
            <if test="enable != null">
                AND enable = #{enable}
            </if>
            <if test="userDef1 != null">
                AND userDef1 = #{userDef1}
            </if>
            <if test="userDef2 != null">
                AND userDef2 = #{userDef2}
            </if>
            <if test="userDef3 != null">
                AND userDef3 = #{userDef3}
            </if>
            <if test="sectionStartTime != null">
                AND created >= #{sectionStartTime}
            </if>
            <if test="sectionEndTime != null">
                AND created &lt;= #{sectionEndTime}
            </if>
        </where>
    </select>

    <select id="getShipmentContainerHeaders" resultType="com.huaheng.pc.shipment.shipmentContainerHeader.domain.ShipmentContainerHeader">
        SELECT h.id, h.shipmentContainerCode, h.locationCode, h.warehouseId, h.warehouseCode, h.taskType, h.taskTypeReal, h.status, h.created, h.createdBy
        FROM shipment_container_header h
        <if test="shipmentCode != null and shipmentCode != ''">
            INNER JOIN (SELECT DISTINCT headerId FROM shipment_container_detail WHERE shipmentCode = #{shipmentCode}) d
            ON h.id = d.headerId
        </if>
        <where>
            <if test="id != null ">
                AND h.id = #{id}
            </if>
            <if test="shipmentContainerCode != null and shipmentContainerCode != ''">
                AND h.shipmentContainerCode = #{shipmentContainerCode}
            </if>
            <if test="locationCode != null and locationCode != ''">
                AND h.locationCode = #{locationCode}
            </if>
            <if test="warehouseId != null ">
                AND h.warehouseId = #{warehouseId}
            </if>
            <if test="warehouseCode != null ">
                AND h.warehouseCode = #{warehouseCode}
            </if>
            <if test="taskType != null ">
                AND h.taskType = #{taskType}
            </if>
            <if test="taskTypeReal != null ">
                AND h.taskTypeReal = #{taskTypeReal}
            </if>
            <if test="status != null ">
                AND h.status = #{status}
            </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 != ''">
                AND h.createdBy = #{createdBy}
            </if>
        </where>
    </select>

    <select id="selectUnPickted"  resultType="com.huaheng.pc.shipment.shipmentContainerHeader.domain.ShipmentContainerHeader">
        SELECT id, shipmentContainerCode, warehouseId, warehouseCode, taskType, status, created, createdBy
        FROM shipment_container_header
        WHERE status &lt; 20 and status!=0
        <if test="id != null">
            AND id = #{id}
        </if>
        <if test="shipmentContainerCode != null and shipmentContainerCode != ''">
            AND shipmentContainerCode = #{shipmentContainerCode}
        </if>
        <if test="warehouseId != null ">
            AND warehouseId = #{warehouseId}
        </if>
        <if test="warehouseCode != null and warehouseCode != ''">
            AND warehouseCode = #{warehouseCode}
        </if>
    </select>

    <select id="selectUnPickteds"  resultType="com.huaheng.pc.shipment.shipmentContainerHeader.domain.ShipmentContainerHeader">
        SELECT id, shipmentContainerCode, warehouseId, warehouseCode, taskType, status, created, createdBy
        FROM shipment_container_header
        WHERE status=0
        <if test="id != null">
            AND id = #{id}
        </if>
        <if test="shipmentContainerCode != null and shipmentContainerCode != ''">
            AND shipmentContainerCode = #{shipmentContainerCode}
        </if>
        <if test="warehouseId != null ">
            AND warehouseId = #{warehouseId}
        </if>
        <if test="warehouseCode != null and warehouseCode != ''">
            AND warehouseCode = #{warehouseCode}
        </if>
    </select>

    <select id="selectAgvListByLike" resultType="com.huaheng.pc.shipment.shipmentContainerHeader.domain.ShipmentContainerHeader">
        select id from shipment_container_header where warehouseCode=#{warehouseCode} and status=0 and shipmentContainerCode like CONCAT(#{shelfNo},'%')
    </select>

    <update id="updateList">
        update shipment_container_header r inner join container c on r.warehouseCode=#{warehouseCode} and r.status=0 and r.shipmentContainerCode like CONCAT(#{shelfNo},'%')
        and r.shipmentContainerCode=c.code set r.locationCode=c.locationCode
    </update>

</mapper>