<?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="cn.cecep.talroad.mapper.FactoryReportingManifestMapper">

    <resultMap type="cn.cecep.talroad.domain.FactoryReportingManifest" id="FactoryReportingManifestResult">
        <result property="factoryName"    column="factory_name"    />
        <result property="uscCode"    column="usc_code"    />
        <result property="industryCategory"    column="industry_category"    />
        <result property="contact"    column="contact"    />
        <result property="contactPhone"    column="contact_phone"    />
        <result property="fmId"    column="fm_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="frId"    column="fr_id"    />
    </resultMap>


    <sql id="selectFactoryReportingManifestVo">
        select factory_name, usc_code, industry_category, contact, contact_phone, fm_id, create_time, fr_id from factory_reporting_manifest
    </sql>

    <select id="selectFactoryReportingManifestList" parameterType="cn.cecep.talroad.domain.FactoryReportingManifest" resultMap="FactoryReportingManifestResult">
        <include refid="selectFactoryReportingManifestVo"/>
        <where>
            <if test="factoryName != null  and factoryName != ''"> and factory_name like concat('%', #{factoryName}, '%')</if>
            <if test="uscCode != null  and uscCode != ''"> and usc_code = #{uscCode}</if>
            <if test="industryCategory != null  and industryCategory != ''"> and industry_category = #{industryCategory}</if>
            <if test="contact != null  and contact != ''"> and contact = #{contact}</if>
            <if test="contactPhone != null  and contactPhone != ''"> and contact_phone = #{contactPhone}</if>
            <if test="fmId != null  and fmId != ''"> and fm_id = #{fmId}</if>
            <if test="frId != null  and frId != ''"> and fr_id = #{frId}</if>
        </where>
    </select>

    <insert id="insertBatch">
        INSERT INTO factory_reporting_manifest (fm_id,factory_name,usc_code,industry_category,contact,contact_phone,fr_id,create_time) VALUES
        <foreach collection="addList" separator="," item="item">
            (#{item.fmId}, #{item.factoryName}, #{item.uscCode}, #{item.industryCategory}, #{item.contact}, #{item.contactPhone}, #{item.frId}, #{item.createTime})
        </foreach>
    </insert>
</mapper>
