<?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.fjhx.mapper.water.WaterTagMapper">

    <select id="getPage" resultType="java.util.LinkedHashMap">
        select wt.id,
               wt.number,
               m.name materialName,
               m.code materialCode,
               m.width,
               m.unit_weight,
               wt.quantity,
               wt.create_time,
               wt.rfid_code,
               wt.qr_code,
               wt.create_time,
               wt.had_printer
        from water_tag wt
                 left join material m on wt.material_id = m.id
            ${ew.customSqlSegment}
    </select>

    <select id="getDetailsByQrCode" resultType="java.util.Map">
        select wt.id,
               wt.number,
               wb.contract_code,
               wb.contract_details_code,
               m.code materialCode,
               m.name materialName,
               m.Spec materialSpec,
               wt.quantity,
               m.unit materialUnit
        from water_tag wt
                 left join water_batch wb on wt.water_batch_id = wb.id
                 left join material m on wb.material_id = m.id
        where wt.use_status = 1
          and wt.qr_code = #{qrCode}
    </select>

    <select id="getDetailsByRfid" resultType="java.util.Map">
        select wt.id,
               wt.rfid_code,
               wt.water_batch_id,
               m.id   materialId,
               m.code materialCode,
               m.name materialName,
               m.Spec materialSpec,
               wt.quantity,
               m.unit materialUnit,
               wt.in_house,
               wt.stock_house_id
        from water_tag wt
                 left join material m on wt.material_id = m.id
        where wt.use_status = 1
          and wt.rfid_code = #{rfidCode}
    </select>

</mapper>
