<?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.ruoyi.mesInfo.mapper.MesInfoMapper">
    
    <resultMap type="MesInfo" id="MesInfoResult">
        <result property="keyId"    column="key_id"    />
        <result property="taskno"    column="taskno"    />
        <result property="wo"    column="wo"    />
        <result property="mo"    column="mo"    />
        <result property="serialNumber"    column="serial_number"    />
        <result property="outNo"    column="out_no"    />
        <result property="productNumber"    column="product_number"    />
        <result property="id"    column="id"    />
        <result property="pnCode"    column="pn_code"    />
        <result property="pnName"    column="pn_name"    />
        <result property="batchNo"    column="batch_no"    />
        <result property="componentSn"    column="component_sn"    />
        <result property="supplier"    column="supplier"    />
        <result property="qualitygrate"    column="qualitygrate"    />
        <result property="pcbItem"    column="pcb_item"    />
        <result property="qty"    column="qty"    />
        <result property="validDate"    column="valid_date"    />
        <result property="filter"    column="filter"    />
        <result property="remarks"    column="remarks"    />
        <result property="updator"    column="updator"    />
        <result property="updateDate"    column="update_date"    />
        <result property="pcbItem2"    column="pcb_item2"    />
        <result property="pnSpec"    column="pn_spec"    />
        <result property="iqcSn"    column="iqc_sn"    />
        <result property="workMan"    column="work_man"    />
        <result property="workLocat"    column="work_locat"    />
        <result property="checkMan"    column="check_man"    />
        <result property="checkDate"    column="check_date"    />
        <result property="pcbItemS"    column="pcb_item_s"    />
        <result property="qtyS"    column="qty_s"    />
        <result property="pcbItemR"    column="pcb_item_r"    />
        <result property="qtyR"    column="qty_r"    />
        <result property="pcbItemShow"    column="pcb_item_show"    />
        <result property="pid"    column="pid"    />
        <result property="dpano"    column="dpano"    />
        <result property="technicalstandard"    column="technicalstandard"    />
        <result property="iqcIndex"    column="iqc_index"    />
        <result property="outStockNo"    column="out_stock_no"    />
        <result property="boardNo"    column="board_no"    />
        <result property="inbatchno"    column="inbatchno"    />
        <result property="purchaseprice"    column="purchaseprice"    />
        <result property="internalprice"    column="internalprice"    />
    </resultMap>

    <sql id="selectMesInfoVo">
        select key_id, taskno, wo, mo, serial_number, out_no, product_number, id, pn_code, pn_name, batch_no, component_sn, supplier, qualitygrate, pcb_item, qty, valid_date, filter, remarks, updator, update_date, pcb_item2, pn_spec, iqc_sn, work_man, work_locat, check_man, check_date, pcb_item_s, qty_s, pcb_item_r, qty_r, pcb_item_show, pid, dpano, technicalstandard, iqc_index, out_stock_no, board_no, inbatchno, purchaseprice, internalprice from mes_info
    </sql>

    <select id="selectMesInfoList" parameterType="MesInfo" resultMap="MesInfoResult">
        <include refid="selectMesInfoVo"/>
        <where>  
            <if test="taskno != null  and taskno != ''"> and taskno = #{taskno}</if>
            <if test="wo != null  and wo != ''"> and wo = #{wo}</if>
            <if test="mo != null  and mo != ''"> and mo = #{mo}</if>
            <if test="serialNumber != null  and serialNumber != ''"> and serial_number = #{serialNumber}</if>
            <if test="outNo != null  and outNo != ''"> and out_no = #{outNo}</if>
            <if test="productNumber != null  and productNumber != ''"> and product_number = #{productNumber}</if>
            <if test="pnCode != null  and pnCode != ''"> and pn_code = #{pnCode}</if>
            <if test="pnName != null  and pnName != ''"> and pn_name like concat('%', #{pnName}, '%')</if>
            <if test="batchNo != null  and batchNo != ''"> and batch_no = #{batchNo}</if>
            <if test="componentSn != null  and componentSn != ''"> and component_sn = #{componentSn}</if>
            <if test="supplier != null  and supplier != ''"> and supplier = #{supplier}</if>
            <if test="qualitygrate != null  and qualitygrate != ''"> and qualitygrate = #{qualitygrate}</if>
            <if test="pcbItem != null  and pcbItem != ''"> and pcb_item = #{pcbItem}</if>
            <if test="qty != null "> and qty = #{qty}</if>
            <if test="validDate != null "> and valid_date = #{validDate}</if>
            <if test="filter != null  and filter != ''"> and filter = #{filter}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
            <if test="updator != null  and updator != ''"> and updator = #{updator}</if>
            <if test="updateDate != null "> and update_date = #{updateDate}</if>
            <if test="pcbItem2 != null  and pcbItem2 != ''"> and pcb_item2 = #{pcbItem2}</if>
            <if test="pnSpec != null  and pnSpec != ''"> and pn_spec = #{pnSpec}</if>
            <if test="iqcSn != null  and iqcSn != ''"> and iqc_sn = #{iqcSn}</if>
            <if test="workMan != null  and workMan != ''"> and work_man = #{workMan}</if>
            <if test="workLocat != null  and workLocat != ''"> and work_locat = #{workLocat}</if>
            <if test="checkMan != null  and checkMan != ''"> and check_man = #{checkMan}</if>
            <if test="checkDate != null "> and check_date = #{checkDate}</if>
            <if test="pcbItemS != null  and pcbItemS != ''"> and pcb_item_s = #{pcbItemS}</if>
            <if test="qtyS != null "> and qty_s = #{qtyS}</if>
            <if test="pcbItemR != null  and pcbItemR != ''"> and pcb_item_r = #{pcbItemR}</if>
            <if test="qtyR != null "> and qty_r = #{qtyR}</if>
            <if test="pcbItemShow != null  and pcbItemShow != ''"> and pcb_item_show = #{pcbItemShow}</if>
            <if test="pid != null  and pid != ''"> and pid = #{pid}</if>
            <if test="dpano != null  and dpano != ''"> and dpano = #{dpano}</if>
            <if test="technicalstandard != null  and technicalstandard != ''"> and technicalstandard = #{technicalstandard}</if>
            <if test="iqcIndex != null  and iqcIndex != ''"> and iqc_index = #{iqcIndex}</if>
            <if test="outStockNo != null  and outStockNo != ''"> and out_stock_no = #{outStockNo}</if>
            <if test="boardNo != null  and boardNo != ''"> and board_no = #{boardNo}</if>
            <if test="inbatchno != null  and inbatchno != ''"> and inbatchno = #{inbatchno}</if>
            <if test="purchaseprice != null "> and purchaseprice = #{purchaseprice}</if>
            <if test="internalprice != null "> and internalprice = #{internalprice}</if>
        </where>
    </select>
    
    <select id="selectMesInfoByKeyId" parameterType="Long" resultMap="MesInfoResult">
        <include refid="selectMesInfoVo"/>
        where key_id = #{keyId}
    </select>
    <select id="selectCheckPoint" resultType="java.lang.Long">
        select checkPoint from mes_info_checkpoint where id = 1;
    </select>
    <select id="getMesInfoMaxKeyId" resultType="java.lang.Long">
        select max(key_id) from mes_info
    </select>
    <select id="selectMesInfoByKeyIdRange" resultType="com.ruoyi.mesInfo.domain.MesInfo">
        select key_id, taskno, qty, purchaseprice, internalprice
        from mes_info
        where key_id &gt; #{startId}
          and key_id &lt; #{endId}
    </select>

    <insert id="insertMesInfo" parameterType="MesInfo" useGeneratedKeys="true" keyProperty="keyId">
        insert into mes_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskno != null">taskno,</if>
            <if test="wo != null">wo,</if>
            <if test="mo != null">mo,</if>
            <if test="serialNumber != null">serial_number,</if>
            <if test="outNo != null">out_no,</if>
            <if test="productNumber != null">product_number,</if>
            <if test="id != null">id,</if>
            <if test="pnCode != null">pn_code,</if>
            <if test="pnName != null">pn_name,</if>
            <if test="batchNo != null">batch_no,</if>
            <if test="componentSn != null">component_sn,</if>
            <if test="supplier != null">supplier,</if>
            <if test="qualitygrate != null">qualitygrate,</if>
            <if test="pcbItem != null">pcb_item,</if>
            <if test="qty != null">qty,</if>
            <if test="validDate != null">valid_date,</if>
            <if test="filter != null">filter,</if>
            <if test="remarks != null">remarks,</if>
            <if test="updator != null">updator,</if>
            <if test="updateDate != null">update_date,</if>
            <if test="pcbItem2 != null">pcb_item2,</if>
            <if test="pnSpec != null">pn_spec,</if>
            <if test="iqcSn != null">iqc_sn,</if>
            <if test="workMan != null">work_man,</if>
            <if test="workLocat != null">work_locat,</if>
            <if test="checkMan != null">check_man,</if>
            <if test="checkDate != null">check_date,</if>
            <if test="pcbItemS != null">pcb_item_s,</if>
            <if test="qtyS != null">qty_s,</if>
            <if test="pcbItemR != null">pcb_item_r,</if>
            <if test="qtyR != null">qty_r,</if>
            <if test="pcbItemShow != null">pcb_item_show,</if>
            <if test="pid != null">pid,</if>
            <if test="dpano != null">dpano,</if>
            <if test="technicalstandard != null">technicalstandard,</if>
            <if test="iqcIndex != null">iqc_index,</if>
            <if test="outStockNo != null">out_stock_no,</if>
            <if test="boardNo != null">board_no,</if>
            <if test="inbatchno != null">inbatchno,</if>
            <if test="purchaseprice != null">purchaseprice,</if>
            <if test="internalprice != null">internalprice,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskno != null">#{taskno},</if>
            <if test="wo != null">#{wo},</if>
            <if test="mo != null">#{mo},</if>
            <if test="serialNumber != null">#{serialNumber},</if>
            <if test="outNo != null">#{outNo},</if>
            <if test="productNumber != null">#{productNumber},</if>
            <if test="id != null">#{id},</if>
            <if test="pnCode != null">#{pnCode},</if>
            <if test="pnName != null">#{pnName},</if>
            <if test="batchNo != null">#{batchNo},</if>
            <if test="componentSn != null">#{componentSn},</if>
            <if test="supplier != null">#{supplier},</if>
            <if test="qualitygrate != null">#{qualitygrate},</if>
            <if test="pcbItem != null">#{pcbItem},</if>
            <if test="qty != null">#{qty},</if>
            <if test="validDate != null">#{validDate},</if>
            <if test="filter != null">#{filter},</if>
            <if test="remarks != null">#{remarks},</if>
            <if test="updator != null">#{updator},</if>
            <if test="updateDate != null">#{updateDate},</if>
            <if test="pcbItem2 != null">#{pcbItem2},</if>
            <if test="pnSpec != null">#{pnSpec},</if>
            <if test="iqcSn != null">#{iqcSn},</if>
            <if test="workMan != null">#{workMan},</if>
            <if test="workLocat != null">#{workLocat},</if>
            <if test="checkMan != null">#{checkMan},</if>
            <if test="checkDate != null">#{checkDate},</if>
            <if test="pcbItemS != null">#{pcbItemS},</if>
            <if test="qtyS != null">#{qtyS},</if>
            <if test="pcbItemR != null">#{pcbItemR},</if>
            <if test="qtyR != null">#{qtyR},</if>
            <if test="pcbItemShow != null">#{pcbItemShow},</if>
            <if test="pid != null">#{pid},</if>
            <if test="dpano != null">#{dpano},</if>
            <if test="technicalstandard != null">#{technicalstandard},</if>
            <if test="iqcIndex != null">#{iqcIndex},</if>
            <if test="outStockNo != null">#{outStockNo},</if>
            <if test="boardNo != null">#{boardNo},</if>
            <if test="inbatchno != null">#{inbatchno},</if>
            <if test="purchaseprice != null">#{purchaseprice},</if>
            <if test="internalprice != null">#{internalprice},</if>
         </trim>
    </insert>

    <update id="updateMesInfo" parameterType="MesInfo">
        update mes_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskno != null">taskno = #{taskno},</if>
            <if test="wo != null">wo = #{wo},</if>
            <if test="mo != null">mo = #{mo},</if>
            <if test="serialNumber != null">serial_number = #{serialNumber},</if>
            <if test="outNo != null">out_no = #{outNo},</if>
            <if test="productNumber != null">product_number = #{productNumber},</if>
            <if test="id != null">id = #{id},</if>
            <if test="pnCode != null">pn_code = #{pnCode},</if>
            <if test="pnName != null">pn_name = #{pnName},</if>
            <if test="batchNo != null">batch_no = #{batchNo},</if>
            <if test="componentSn != null">component_sn = #{componentSn},</if>
            <if test="supplier != null">supplier = #{supplier},</if>
            <if test="qualitygrate != null">qualitygrate = #{qualitygrate},</if>
            <if test="pcbItem != null">pcb_item = #{pcbItem},</if>
            <if test="qty != null">qty = #{qty},</if>
            <if test="validDate != null">valid_date = #{validDate},</if>
            <if test="filter != null">filter = #{filter},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
            <if test="updator != null">updator = #{updator},</if>
            <if test="updateDate != null">update_date = #{updateDate},</if>
            <if test="pcbItem2 != null">pcb_item2 = #{pcbItem2},</if>
            <if test="pnSpec != null">pn_spec = #{pnSpec},</if>
            <if test="iqcSn != null">iqc_sn = #{iqcSn},</if>
            <if test="workMan != null">work_man = #{workMan},</if>
            <if test="workLocat != null">work_locat = #{workLocat},</if>
            <if test="checkMan != null">check_man = #{checkMan},</if>
            <if test="checkDate != null">check_date = #{checkDate},</if>
            <if test="pcbItemS != null">pcb_item_s = #{pcbItemS},</if>
            <if test="qtyS != null">qty_s = #{qtyS},</if>
            <if test="pcbItemR != null">pcb_item_r = #{pcbItemR},</if>
            <if test="qtyR != null">qty_r = #{qtyR},</if>
            <if test="pcbItemShow != null">pcb_item_show = #{pcbItemShow},</if>
            <if test="pid != null">pid = #{pid},</if>
            <if test="dpano != null">dpano = #{dpano},</if>
            <if test="technicalstandard != null">technicalstandard = #{technicalstandard},</if>
            <if test="iqcIndex != null">iqc_index = #{iqcIndex},</if>
            <if test="outStockNo != null">out_stock_no = #{outStockNo},</if>
            <if test="boardNo != null">board_no = #{boardNo},</if>
            <if test="inbatchno != null">inbatchno = #{inbatchno},</if>
            <if test="purchaseprice != null">purchaseprice = #{purchaseprice},</if>
            <if test="internalprice != null">internalprice = #{internalprice},</if>
        </trim>
        where key_id = #{keyId}
    </update>
    <update id="recordCheckPoint">
        update mes_info_checkpoint set checkPoint = #{checkPointId} where id = 1
    </update>

    <delete id="deleteMesInfoByKeyId" parameterType="Long">
        delete from mes_info where key_id = #{keyId}
    </delete>

    <delete id="deleteMesInfoByKeyIds" parameterType="String">
        delete from mes_info where key_id in 
        <foreach item="keyId" collection="array" open="(" separator="," close=")">
            #{keyId}
        </foreach>
    </delete>
</mapper>