TaskMapper.xml 12.9 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.task.task.mapper.TaskMapper">

    <select id="getUncompleteTask" resultType="com.huaheng.pc.task.task.domain.Task">
       SELECT id, warehouseId, warehouseCode, uWarehouseCode, companyId, companyCode, priority, type, station, allocationHeadId, containerId, containerCode,
       roadway, sourceLocation, destinationLocation, firstStatus, lastStatus, zoneCode, created, createdBy, beginTime, endTime, lastUpdated, lastUpdatedBy,
       userDef1, userDef2, userDef3, deleted, isEmptyOut, isDoubleIn, secondDestinationLocation, sendAgain, bypass, port, weight, gateway
         from task where firstStatus &lt; 100 and containerCode = #{containerCode} AND warehouseCode=#{warehouseCode} limit 1;
    </select>

    <select id="getContainerMaterial" resultType="java.util.HashMap">
        SELECT  h.locationCode, d.id, d.receiptId, d.receiptDetailId, d.receiptCode, d.materialCode barcode, d.materialName name, d.materialSpec, d.qty,d.unit
        FROM receipt_container_header h
        INNER JOIN receipt_container_detail d ON d.headerId = h.id AND h.status=0 AND h.receiptContainerCode = #{containerCode,jdbcType=VARCHAR}
    </select>

    <select id="getReceiptTask" resultType="java.util.HashMap">
        SELECT  td.warehouseId, td.warehouseCode, td.id taskDetailId, td.destinationLocation, td.status,
                 td.containerCode, td.qty, td.billId, td.billDetailId, td.billCode, td.materialCode,
                 td.materialName, rd.sourceCode, rd.sourceLine, rd.batch, rd.lot, rd.project,
                 rd.manufactureDate, rd.expirationDate, rd.inventoryStatus, rd.price,td.unit
        FROM task_detail td
        INNER JOIN receipt_detail rd ON rd.id = td.billDetailId AND td.taskId = #{taskId,jdbcType=INTEGER}
    </select>

    <select id="getTasks" resultType="com.huaheng.pc.task.task.domain.Task">
        SELECT t.id, t.warehouseId, t.warehouseCode, t.companyId, t.companyCode, t.priority, t.type, t.station,
        t.allocationHeadId, t.containerId, t.containerCode, t.sourceLocation, t.destinationLocation, t.firstStatus,
        t.lastStatus, t.created, t.createdBy, t.beginTime, t.endTime, t.lastUpdated, t.lastUpdatedBy, t.userDef1, t.zoneCode,
        t.deleted, t.isEmptyOut, t.isDoubleIn, t.secondDestinationLocation, t.roadway,t.weight,t.userDef2,t.userDef3,
        t.isEmptyOut, t.isDoubleIn, t.secondDestinationLocation, t.sendAgain, t.bypass, t.port, t.weight, t.gateway
        FROM task t
        <if test="billCode != null and billCode != ''">
            INNER JOIN (SELECT DISTINCT taskId FROM task_detail WHERE billCode = #{billCode}) d
            ON t.id = d.taskId
        </if>
        <where>
            <if test="id != null ">
                AND t.id = #{id}
            </if>
            <if test="roadway != null ">
                AND t.roadway = #{roadway}
            </if>
            <if test="warehouseId != null ">
                AND t.warehouseId = #{warehouseId}
            </if>
            <if test="warehouseCode != null and warehouseCode != '' ">
                AND t.warehouseCode = #{warehouseCode}
            </if>
            <if test="companyIdList != null ">
                AND t.companyId in
                <foreach collection="companyIdList" item="companyIdItem" open="(" separator="," close=")">
                    #{companyIdItem}
                </foreach>
            </if>
            <if test="companyId != null ">
                AND t.companyId = #{companyId}
            </if>
            <if test="companyCodeList != null ">
                AND t.companyCode in
                <foreach collection="companyCodeList" item="companyCodeItem" open="(" separator="," close=")">
                    #{companyCodeItem}
                </foreach>
            </if>
            <if test="companyCode != null and companyCode != '' ">
                AND t.companyCode = #{companyCode}
            </if>
            <if test="priority != null ">
                AND t.priority = #{priority}
            </if>
            <if test="type != null and type != '' ">
                AND t.type = #{type}
            </if>
            <if test="station != null ">
                AND t.station = #{station}
            </if>
            <if test="allocationHeadId != null ">
                AND t.allocationHeadId = #{allocationHeadId}
            </if>
            <if test="containerId != null ">
                AND t.containerId = #{containerId}
            </if>
            <if test="containerCode != null and containerCode != '' ">
                AND t.containerCode = #{containerCode}
            </if>
            <if test="sourceLocation != null and sourceLocation != ''">
                <bind name="sourceLocationPattern" value="'%' + sourceLocation + '%'" />
                AND t.sourceLocation like #{sourceLocationPattern}
            </if>
            <if test="destinationLocation != null and destinationLocation != ''">
                <bind name="destinationLocationPattern" value="'%' + destinationLocation + '%'" />
                AND t.destinationLocation like #{destinationLocationPattern}
            </if>
            <if test="firstStatus != null ">
                AND t.firstStatus = #{firstStatus}
            </if>
            <if test="lastStatus != null ">
                AND t.lastStatus = #{lastStatus}
            </if>
            <if test="params != null and params.createdBegin != null and params.createdBegin != ''">
                AND t.created &gt;= #{params.createdBegin}
            </if>
            <if test="params != null and params.createdEnd != null and params.createdEnd != ''">
                AND t.created &lt;= #{params.createdEnd}
            </if>
            <if test="createdBy != null and createdBy != ''">
                <bind name="createdByPattern" value="'%' + createdBy + '%'" />
                AND t.createdBy like #{createdByPattern}
            </if>
            <if test="params != null and params.beginTimeBegin != null and params.beginTimeBegin != ''">
                AND t.beginTime &gt;= #{params.beginTimeBegin}
            </if>
            <if test="params != null and params.beginTimeEnd != null and params.beginTimeEnd != ''">
                AND t.beginTime &lt;= #{params.beginTimeEnd}
            </if>
            <if test="params != null and params.endTimeBegin != null and params.endTimeBegin != ''">
                AND t.endTime &gt;= #{params.endTimeBegin}
            </if>
            <if test="params != null and params.endTimeEnd != null and params.endTimeEnd != ''">
                AND t.endTime &lt;= #{params.endTimeEnd}
            </if>
            <if test="params != null and params.lastUpdatedBegin != null and params.lastUpdatedBegin != ''">
                AND t.lastUpdated &gt;= #{params.lastUpdatedBegin}
            </if>
            <if test="params != null and params.lastUpdatedEnd != null and params.lastUpdatedEnd != ''">
                AND t.lastUpdated &lt;= #{params.lastUpdatedEnd}
            </if>
            <if test="lastUpdatedBy != null and lastUpdatedBy != ''">
                <bind name="lastUpdatedByPattern" value="'%' + lastUpdatedBy + '%'" />
                AND t.lastUpdatedBy like #{lastUpdatedByPattern}
            </if>
            <if test="userDef1 != null and userDef1 != ''">
                <bind name="userDef1Pattern" value="'%' + userDef1 + '%'" />
                AND t.userDef1 like #{userDef1Pattern}
            </if>
            <if test="userDef2 != null and userDef2 != ''">
                AND t.userDef2 = #{userDef2}
            </if>
            <if test="userDef3 != null and userDef3 != ''">
                AND t.userDef3 = #{userDef3}
            </if>
            <if test="deleted != null ">
                AND t.deleted = #{deleted}
            </if>
            <if test="isEmptyOut != null ">
                AND t.isEmptyOut = #{isEmptyOut}
            </if>
            <if test="isDoubleIn != null ">
                AND t.isDoubleIn = #{isDoubleIn}
            </if>
            <if test="secondDestinationLocation != null and secondDestinationLocation != ''">
                AND t.secondDestinationLocation = #{secondDestinationLocationPattern}
            </if>
            <if test="zoneCode != null and zoneCode != '' ">
                AND t.zoneCode = #{zoneCode}
            </if>
        </where>
    </select>

    <select id="findUncompleteCyccountTask" resultType="java.lang.Integer">
        SELECT COUNT(id) from task WHERE type=700 AND `lastStatus` &lt; 100 and warehouseId = #{warehouseId} AND containerCode = #{containerCode}
    </select>

    <select id="UncompleteCount" resultType="java.lang.Integer">
        SELECT COUNT(id) AS count FROM task WHERE lastStatus &lt; 100 AND containerCode = #{containerCode} AND warehouseId=#{warehouseId}
    </select>

    <select id="selectAgvListByLike" resultType="com.huaheng.pc.task.task.domain.Task">
        select id, warehouseId, warehouseCode, uWarehouseCode, companyId, companyCode, priority, type, station, allocationHeadId, containerId, containerCode, roadway,
    sourceLocation, destinationLocation, firstStatus, lastStatus, zoneCode, created, createdBy, beginTime, endTime, lastUpdated, lastUpdatedBy,
    userDef1, userDef2, userDef3, deleted, isEmptyOut, isDoubleIn, secondDestinationLocation, sendAgain, weight
    from task where warehouseCode=#{warehouseCode} and firstStatus = 1 and lastStatus = 1 and containerCode like CONCAT(#{shelfNo},'%')
    </select>

    <select id="getTasksStatus" resultType="com.huaheng.pc.task.task.domain.Task">
    SELECT id, warehouseId, warehouseCode, uWarehouseCode, companyId, companyCode, priority, type, station, allocationHeadId, containerId, containerCode, roadway,
    sourceLocation, destinationLocation, firstStatus, lastStatus, zoneCode, created, createdBy, beginTime, endTime, lastUpdated, lastUpdatedBy,
    userDef1, userDef2, userDef3, deleted, isEmptyOut, isDoubleIn, secondDestinationLocation, sendAgain, weight
     FROM task
     where lastStatus &lt; 100
    </select>

    <update id="setWcsTask">
    UPDATE task
        <set>
            destinationLocation = #{destinationLocation,jdbcType=VARCHAR },
            userDef3 = #{userDef3, jdbcType=VARCHAR},
            weight = #{weight, jdbcType=FLOAT},
        </set>
            WHERE id = #{id,jdbcType=INTEGER}
    </update>

    <select id="selectReceiptConfirm" resultType="com.huaheng.pc.task.task.domain.Task">
     SELECT id, warehouseId, warehouseCode, uWarehouseCode, companyId, companyCode, priority, type, station, allocationHeadId, containerId, containerCode, roadway,
    sourceLocation, destinationLocation, firstStatus, lastStatus, zoneCode, created, createdBy, beginTime, endTime, lastUpdated, lastUpdatedBy,
    userDef1, userDef2, userDef3, deleted, isEmptyOut, isDoubleIn, secondDestinationLocation, sendAgain, weight
     FROM task
        WHERE lastStatus = 100 AND (type = 100 OR type = 200)
        LIMIT 1
    </select>

    <select id="selectShipmentConfirm" resultType="com.huaheng.pc.task.task.domain.Task">
    SELECT id, warehouseId, warehouseCode, uWarehouseCode, companyId, companyCode, priority, type, station, allocationHeadId, containerId, containerCode, roadway,
    sourceLocation, destinationLocation, firstStatus, lastStatus, zoneCode, created, createdBy, beginTime, endTime, lastUpdated, lastUpdatedBy,
    userDef1, userDef2, userDef3, deleted, isEmptyOut, isDoubleIn, secondDestinationLocation, sendAgain, weight,confirmStatus
     FROM task
        WHERE lastStatus = 100 AND (type = 300 OR type = 400)
        And confirmStatus = 0
        order by id desc
        LIMIT 1
    </select>

    <select id="selectShipmentConfirm4Retry" resultType="com.huaheng.pc.task.task.domain.Task">
    SELECT id, warehouseId, warehouseCode, uWarehouseCode, companyId, companyCode, priority, type, station, allocationHeadId, containerId, containerCode, roadway,
    sourceLocation, destinationLocation, firstStatus, lastStatus, zoneCode, created, createdBy, beginTime, endTime, lastUpdated, lastUpdatedBy,
    userDef1, userDef2, userDef3, deleted, isEmptyOut, isDoubleIn, secondDestinationLocation, sendAgain, weight,confirmStatus
     FROM task
        WHERE lastStatus = 100 AND (type = 300 OR type = 400)
        And 0 > confirmStatus
        order by confirmStatus desc, id desc
        LIMIT 1
    </select>

    <select id="getReceiptAGVTask" resultType="java.util.HashMap">
        SELECT  td.warehouseId, td.warehouseCode, td.id taskDetailId, td.destinationLocation, td.status,
                 td.containerCode, td.qty, td.billId, td.billDetailId, td.billCode, td.materialCode,
                 td.materialName, rd.sourceLine, rd.sourceLine, rd.batch, rd.lot, rd.project,
                 rd.manufactureDate, rd.expirationDate, rd.inventoryStatus, rd.price
        FROM task_detail td
        INNER JOIN receipt_detail rd ON rd.id = td.billDetailId AND td.taskId = #{taskId} and td.id=#{id}
    </select>
</mapper>