ShipmentHeaderMapper.xml 15.2 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>

    <select id="selectModel"
            resultType="com.huaheng.api.U8.domain.ICSShipmentHeader">
        SELECT cCode, ID, dPODate, cVenCode, cVenName, cBusType, cDepCode, cDepName, cPersonCode, cPersonName, cMemo, cMaker, type, cVerifier, CompanyCode, cModifyDate,cTVCode, dDate, cRDName, cWHCode, cWHName,oWHCode, oWHName, MoId, MoCode, DLID, cDLCode, cCusCode, cCusName, cSTName
        from icsshipment_header
        <where>
            <if test="cCode != null">
                AND cCode = #{cCode}
            </if>
            <if test="ID != null">
                AND ID = #{ID}
            </if>
            <if test="dPODate != null">
                AND dPODate = #{dPODate}
            </if>
            <if test="cVenCode != null">
                AND cVenCode = #{cVenCode}
            </if>
            <if test="cVenName != null">
                AND cVenName = #{cVenName}
            </if>
            <if test="cBusType != null">
                AND cBusType = #{cBusType}
            </if>
            <if test="cDepCode != null">
                AND cDepCode = #{cDepCode}
            </if>
            <if test="cDepName != null">
                AND cDepName = #{cDepName}
            </if>
            <if test="cPersonCode != null">
                AND cPersonCode = #{cPersonCode}
            </if>
            <if test="cPersonName != null">
                AND cPersonName = #{cPersonName}
            </if>
            <if test="cMemo != null">
                AND cMemo = #{cMemo}
            </if>
            <if test="cMaker != null">
                AND cMaker = #{cMaker}
            </if>
            <if test="cVerifier != null">
                AND cVerifier = #{cVerifier}
            </if>
            <if test="CompanyCode != null">
                AND CompanyCode = #{CompanyCode}
            </if>
            <if test="cModifyDate != null">
                AND cModifyDate = #{cModifyDate}
            </if>
            <if test="dDate != null">
                AND dDate = #{dDate}
            </if>
            <if test="cRDName != null">
                AND cRDName = #{cRDName}
            </if>
            <if test="cWHCode != null">
                AND cWHCode = #{cWHCode}
            </if>
            <if test="cWHName != null">
                AND cWHName = #{cWHName}
            </if>
            <if test="oWHCode != null">
                AND oWHCode = #{oWHCode}
            </if>
            <if test="oWHName != null">
                AND oWHName = #{oWHName}
            </if>
            <if test="cTVCode != null">
                AND cTVCode = #{cTVCode}
            </if>
            <if test="MoId != null">
                AND MoId = #{MoId}
            </if>
            <if test="MoCode != null">
                AND MoCode = #{MoCode}
            </if>
            <if test="DLID != null">
                AND DLID = #{DLID}
            </if>
            <if test="cDLCode != null">
                AND cDLCode = #{cDLCode}
            </if>
            <if test="cCusCode != null">
                AND cCusCode = #{cCusCode}
            </if>
            <if test="cCusName != null">
                AND cCusName = #{cCusName}
            </if>
            <if test="cSTName != null">
                AND cSTName = #{cSTName}
            </if>
            <if test="type != null">
                AND type = #{type}
            </if>
        </where>
    </select>


    <select id="selectLastOne" resultType="com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader">
        SELECT * FROM shipment_header order by id DESC LIMIT 1;
    </select>
    <select id="getShipment" resultType="com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader">
        SELECT id, code, warehouseId, warehouseCode,uWarehouseCode, companyId, companyCode, sourceCode, sourcePlatform, type, shipTo, priority, station, totalQty, totalLines, remark, uploadremark, uploadTime, appointmentTime, firstStatus, lastStatus, uploadStatus, created, createdBy, lastUpdated, lastUpdatedBy, enable, deleted, scanId, userDef1, userDef2, userDef3
        FROM shipment_header
        where sourceCode &lt;&gt; '' and type &lt;&gt; "TO"  AND lastStatus = #{lastStatus}
        LIMIT 1
    </select>


    <insert id="insertModel">
        INSERT INTO icsshipment_header
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="cCode != null and cCode != ''">
                cCode,
            </if>
            <if test="ID != null">
                ID,
            </if>
            <if test="dPODate != null and dPODate != ''">
                dPODate,
            </if>
            <if test="cVenCode != null and cVenCode != ''">
                cVenCode,
            </if>
            <if test="cVenName != null and cVenName != ''">
                cVenName,
            </if>
            <if test="cBusType != null and cBusType != ''">
                cBusType,
            </if>
            <if test="cDepCode != null and cDepCode != ''">
                cDepCode,
            </if>
            <if test="cDepName != null and cDepName != ''">
                cDepName,
            </if>
            <if test="cPersonCode != null and cPersonCode != ''">
                cPersonCode,
            </if>
            <if test="cPersonName != null and cPersonName != ''">
                cPersonName,
            </if>
            <if test="cMemo != null and cMemo != ''">
                cMemo,
            </if>
            <if test="cMaker != null and cMaker != ''">
                cMaker,
            </if>
            <if test="cVerifier != null and cVerifier != ''">
                cVerifier,
            </if>
            <if test="CompanyCode != null and CompanyCode != ''">
                CompanyCode,
            </if>
            <if test="cModifyDate != null and cModifyDate != ''">
                cModifyDate,
            </if>
            <if test="dDate != null and dDate != ''">
                dDate,
            </if>
            <if test="cRDName != null and cRDName != ''">
                cRDName,
            </if>
            <if test="cWHCode != null and cWHCode != ''">
                cWHCode,
            </if>
            <if test="cWHName != null and cWHName != ''">
                cWHName,
            </if>
            <if test="oWHCode != null and oWHCode != ''">
                oWHCode,
            </if>
            <if test="oWHName != null and oWHName != ''">
                oWHName,
            </if>
            <if test="cTVCode != null and cTVCode != ''">
                cTVCode,
            </if>
            <if test="MoId != null">
                MoId,
            </if>
            <if test="MoCode != null and MoCode != ''">
                MoCode,
            </if>
            <if test="DLID != null">
                DLID,
            </if>
            <if test="cDLCode != null and cDLCode != ''">
                cDLCode,
            </if>
            <if test="cCusCode != null and cCusCode != ''">
                cCusCode,
            </if>
            <if test="cCusName != null and cCusName != ''">
                cCusName,
            </if>
            <if test="cSTName != null and cSTName != ''">
                cSTName,
            </if>
            <if test="type != null and type != ''">
                type,
            </if>
        </trim>
        <trim prefix=" values (" suffix=")" suffixOverrides=",">
            <if test="cCode != null and cCode != ''">
                #{cCode, jdbcType=VARCHAR},
            </if>
            <if test="ID != null">
                #{ID, jdbcType=INTEGER},
            </if>
            <if test="dPODate != null and dPODate != ''">
                #{dPODate, jdbcType=TIMESTAMP},
            </if>
            <if test="cVenCode != null and cVenCode != ''">
                #{cVenCode, jdbcType=VARCHAR},
            </if>
            <if test="cVenName != null and cVenName != ''">
                #{cVenName, jdbcType=VARCHAR},
            </if>
            <if test="cBusType != null and cBusType != ''">
                #{cBusType, jdbcType=VARCHAR},
            </if>
            <if test="cDepCode != null and cDepCode != ''">
                #{cDepCode, jdbcType=VARCHAR},
            </if>
            <if test="cDepName != null and cDepName != ''">
                #{cDepName, jdbcType=VARCHAR},
            </if>
            <if test="cPersonCode != null and cPersonCode != ''">
                #{cPersonCode, jdbcType=VARCHAR},
            </if>
            <if test="cPersonName != null and cPersonName != ''">
                #{cPersonName, jdbcType=VARCHAR},
            </if>
            <if test="cMemo != null and cMemo != ''">
                #{cMemo, jdbcType=VARCHAR},
            </if>
            <if test="cMaker != null and cMaker != ''">
                #{cMaker, jdbcType=VARCHAR},
            </if>
            <if test="cVerifier != null and cVerifier != ''">
                #{cVerifier, jdbcType=VARCHAR},
            </if>
            <if test="CompanyCode != null and CompanyCode != ''">
                #{CompanyCode, jdbcType=VARCHAR},
            </if>
            <if test="cModifyDate != null and cModifyDate != ''">
                #{cModifyDate, jdbcType=TIMESTAMP},
            </if>
            <if test="dDate != null and dDate != ''">
                #{dDate, jdbcType=TIMESTAMP},
            </if>
            <if test="cRDName != null and cRDName != ''">
                #{cRDName, jdbcType=VARCHAR},
            </if>
            <if test="cWHCode != null and cWHCode != ''">
                #{cWHCode, jdbcType=VARCHAR},
            </if>
            <if test="cWHName != null and cWHName != ''">
                #{cWHName, jdbcType=VARCHAR},
            </if>
            <if test="oWHCode != null and oWHCode != ''">
                #{oWHCode, jdbcType=VARCHAR},
            </if>
            <if test="oWHName != null and oWHName != ''">
                #{oWHName, jdbcType=VARCHAR},
            </if>
            <if test="cTVCode != null and cTVCode != ''">
                #{cTVCode, jdbcType=VARCHAR},
            </if>
            <if test="MoId != null">
                #{MoId, jdbcType=INTEGER},
            </if>
            <if test="MoCode != null and MoCode != ''">
                #{MoCode, jdbcType=VARCHAR},
            </if>
            <if test="DLID != null">
                #{DLID, jdbcType=INTEGER},
            </if>
            <if test="cDLCode != null and cDLCode != ''">
                #{cDLCode, jdbcType=VARCHAR},
            </if>
            <if test="cCusCode != null and cCusCode != ''">
                #{cCusCode, jdbcType=VARCHAR},
            </if>
            <if test="cCusName != null and cCusName != ''">
                #{cCusName, jdbcType=VARCHAR},
            </if>
            <if test="cSTName != null and cSTName != ''">
                #{cSTName, jdbcType=VARCHAR},
            </if>
            <if test="type != null and type != ''">
                #{type, jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>

    <select id="selectNosScanSSP" resultType="com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader">
        select * from shipment_header where code = #{code} AND scanid  LIKE '0%' and  lastStatus &lt; 100 LIMIT 1
    </select>

    <select id="selectListByCreated" resultType="com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader">
    SELECT  s.* from shipment_header s
    inner join task_detail t on t.billCode=s.code and
    t.status=40 and DATEDIFF(NOW(), t.endTime)=0 GROUP BY s.code
    </select>

</mapper>