<?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.sy.coinage.workshop.dao.BaseInfoDao">
    <resultMap id="BaseResultMap" type="com.sy.coinage.workshop.model.BaseInfo">
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="rfid" jdbcType="VARCHAR" property="rfid"/>
        <result column="res_dept_id" jdbcType="INTEGER" property="resDeptId"/>
        <result column="res_dept" jdbcType="VARCHAR" property="resDept"/>
        <result column="dept" jdbcType="VARCHAR" property="dept"/>
        <result column="dept_id" jdbcType="INTEGER" property="deptId"/>
        <result column="create_by" jdbcType="VARCHAR" property="createBy"/>
        <result column="create_id" jdbcType="INTEGER" property="createId"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="status" jdbcType="INTEGER" property="status"/>
        <result column="securities_id" jdbcType="INTEGER" property="securitiesId"/>
        <result column="securities" jdbcType="VARCHAR" property="securities"/>
        <result column="serial_number" jdbcType="VARCHAR" property="serialNumber"/>
        <result column="crown_prefix" jdbcType="VARCHAR" property="crownPrefix"/>
        <result column="tare_weight" jdbcType="DOUBLE" property="tareWeight"/>
        <result column="gross_weight" jdbcType="DOUBLE" property="grossWeight"/>
        <result column="weightor_id" jdbcType="INTEGER" property="weightorId"/>
        <result column="weightor" jdbcType="VARCHAR" property="weightor"/>
        <result column="weight_date" jdbcType="TIMESTAMP" property="weightDate"/>
        <result column="weight_time" jdbcType="VARCHAR" property="weightTime"/>
        <result column="print_status" jdbcType="INTEGER" property="printStatus"/>
        <result column="print_time" jdbcType="TIMESTAMP" property="printTime"/>
        <result column="printer_id" jdbcType="INTEGER" property="printerId"/>
        <result column="printer" jdbcType="VARCHAR" property="printer"/>
        <result column="check_status" jdbcType="INTEGER" property="checkStatus"/>
        <result column="check_time" jdbcType="TIMESTAMP" property="checkTime"/>
        <result column="workshop_check_in_time" jdbcType="TIMESTAMP" property="workshopCheckInTime"/>
        <result column="workshop_check_out_time" jdbcType="TIMESTAMP" property="workshopCheckOutTime"/>
        <result column="check_return_time" jdbcType="TIMESTAMP" property="checkReturnTime"/>
        <result column="unpackage_status" jdbcType="INTEGER" property="unpackageStatus"/>
        <result column="unpackage_time" jdbcType="TIMESTAMP" property="unpackageTime"/>
        <result column="return_check_status" jdbcType="INTEGER" property="returnCheckStatus"/>
        <result column="return_check_confirm_status" jdbcType="INTEGER" property="returnCheckConfirmStatus"/>
        <result column="return_check_confirm_time" jdbcType="TIMESTAMP" property="returnCheckConfirmTime"/>
        <result column="return_check_time" jdbcType="TIMESTAMP" property="returnCheckTime"/>
        <result column="quality_status" jdbcType="INTEGER" property="qualityStatus"/>
        <result column="quality_time" jdbcType="TIMESTAMP" property="qualityTime"/>
        <result column="delivery_time" jdbcType="TIMESTAMP" property="deliveryTime"/>
        <result column="address_id" jdbcType="VARCHAR" property="addressId"/>
        <result column="address_cn" jdbcType="VARCHAR" property="addressCn"/>
        <result column="origin_type" jdbcType="INTEGER" property="originType"/>
        <result column="seq_id" jdbcType="VARCHAR" property="seqId"/>
        <result column="qty" jdbcType="INTEGER" property="qty"/>
        <result column="crown_between" jdbcType="VARCHAR" property="crownBetween"/>
        <result column="crown_from" jdbcType="VARCHAR" property="crownFrom"/>
        <result column="crown_to" jdbcType="VARCHAR" property="crownTo"/>
        <result column="check_id" jdbcType="INTEGER" property="checkId"/>
        <result column="checker" jdbcType="VARCHAR" property="checker"/>
        <result column="loc_ware_id" jdbcType="INTEGER" property="locWareId"/>
        <result column="loc_area_id" jdbcType="INTEGER" property="locAreaId"/>
        <result column="warning_flag" jdbcType="INTEGER" property="warningFlag"/>
        <collection property="child" ofType="com.sy.coinage.workshop.model.BaseInfoSub" select="selectChild"
                    column="{base_info_id=id}"/>
    </resultMap>
    <sql id="Base_Column_List">
        id
        , rfid, res_dept_id, res_dept, dept_id, dept, create_by, create_id, create_time, status, securities_id, securities, serial_number, crown_prefix, tare_weight, gross_weight, weightor_id, weightor, weight_date, weight_time, print_status, print_time, printer_id, printer, check_status, check_time, workshop_check_in_time, workshop_check_out_time, check_return_time, unpackage_status, unpackage_time, return_check_status, return_check_confirm_status, return_check_confirm_time, return_check_time, quality_status, quality_time, delivery_time, address_id, address_cn, origin_type, seq_id, qty, crown_between, crown_from, crown_to, check_id, checker, loc_ware_id, loc_area_id, warning_flag
    </sql>

    <resultMap id="ChildMap" type="com.sy.coinage.workshop.model.BaseInfoSub">
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="base_info_id" jdbcType="INTEGER" property="baseInfoId"/>
        <result column="serial_number" jdbcType="VARCHAR" property="serialNumber"/>
        <result column="crown_prefix" jdbcType="VARCHAR" property="crownPrefix"/>
        <result column="crown_from" jdbcType="VARCHAR" property="crownFrom"/>
        <result column="crown_to" jdbcType="VARCHAR" property="crownTo"/>
    </resultMap>
    <select id="selectChild" resultMap="ChildMap">
        select id,
               base_info_id,
               serial_number,
               crown_prefix,
               crown_from,
               crown_to
        from rfid_base_info_sub
        where base_info_id = ${base_info_id}
    </select>

    <select id="queryPageList" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM
        rfid_base_info
        <if test="ew.emptyOfWhere == false">
            ${ew.customSqlSegment}
        </if>
    </select>
    <select id="queryOne" resultType="com.sy.coinage.workshop.model.BaseInfo">
        SELECT rfid_base_info.* FROM rfid_base_info
        LEFT JOIN rfid_base_info_sub on rfid_base_info.id = rfid_base_info_sub.base_info_id
        <if test="ew.emptyOfWhere == false">
            ${ew.customSqlSegment}
        </if>
    </select>


</mapper>

