<?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.tofly.water.mapper.BasePumpGroupMapper">

    <resultMap type="com.tofly.water.entity.BasePumpGroup" id="BasePumpGroupMap">
        <result property="id" column="ID" jdbcType="INTEGER"/>
        <result property="pumpId" column="PUMP_ID" jdbcType="INTEGER"/>
        <result property="name" column="NAME" jdbcType="VARCHAR"/>
        <result property="code" column="CODE" jdbcType="VARCHAR"/>
        <result property="grouping" column="GROUPING" jdbcType="VARCHAR"/>
        <result property="supplierSimple" column="SUPPLIER_SIMPLE" jdbcType="VARCHAR"/>
        <result property="supplierDetail" column="SUPPLIER_DETAIL" jdbcType="VARCHAR"/>
        <result property="purchaseAmount" column="PURCHASE_AMOUNT" jdbcType="NUMERIC"/>
        <result property="purchaseDate" column="PURCHASE_DATE" jdbcType="TIMESTAMP"/>
        <result property="investmentDate" column="INVESTMENT_DATE" jdbcType="TIMESTAMP"/>
        <result property="remark" column="REMARK" jdbcType="VARCHAR"/>
        <result property="inletPipeDiameter" column="INLET_PIPE_DIAMETER" jdbcType="VARCHAR"/>
        <result property="outletPipeDiameter" column="OUTLET_PIPE_DIAMETER" jdbcType="VARCHAR"/>
        <result property="annex" column="ANNEX" jdbcType="VARCHAR"/>
        <result property="productionSimple" column="PRODUCTION_SIMPLE" jdbcType="VARCHAR"/>
        <result property="productionDetail" column="PRODUCTION_DETAIL" jdbcType="VARCHAR"/>
        <result property="quantity" column="QUANTITY" jdbcType="VARCHAR"/>
        <result property="basePumpList" column="BASE_PUMP_LIST" jdbcType="VARCHAR"/>
        <result property="sort" column="SORT" jdbcType="INTEGER"/>
        <result property="deleted" column="DELETED" jdbcType="VARCHAR"/>
        <result property="createdUser" column="CREATED_USER" jdbcType="INTEGER"/>
        <result property="createdTime" column="CREATED_TIME" jdbcType="TIMESTAMP"/>
        <result property="updatedUser" column="UPDATED_USER" jdbcType="INTEGER"/>
        <result property="updatedTime" column="UPDATED_TIME" jdbcType="TIMESTAMP"/>
        <association property="createdUserName" column="CREATED_USER"
                     select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName"/>
        <association property="updatedUserName" column="UPDATED_USER"
                     select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName"/>
        <association property="pumpIdName" column="PUMP_ID"
                     select="com.tofly.water.mapper.BasePumpMapper.selectNameById"/>
    </resultMap>

    <!-- 批量插入 -->
    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
        insert into TF_BASE_PUMP_GROUP(PUMP_ID, NAME, CODE, GROUPING, SUPPLIER_SIMPLE, SUPPLIER_DETAIL,
        PURCHASE_AMOUNT, PURCHASE_DATE, INVESTMENT_DATE, REMARK, INLET_PIPE_DIAMETER, OUTLET_PIPE_DIAMETER, ANNEX,
        PRODUCTION_SIMPLE, PRODUCTION_DETAIL, QUANTITY, BASE_PUMP_LIST, SORT, DELETED, CREATED_USER, CREATED_TIME,
        UPDATED_USER, UPDATED_TIME)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.pumpId}, #{entity.name}, #{entity.code}, #{entity.grouping}, #{entity.supplierSimple},
            #{entity.supplierDetail}, #{entity.purchaseAmount}, #{entity.purchaseDate}, #{entity.investmentDate},
            #{entity.remark}, #{entity.inletPipeDiameter}, #{entity.outletPipeDiameter}, #{entity.annex},
            #{entity.productionSimple}, #{entity.productionDetail}, #{entity.quantity}, #{entity.basePumpList},
            #{entity.sort}, #{entity.deleted}, #{entity.createdUser}, #{entity.createdTime}, #{entity.updatedUser},
            #{entity.updatedTime})
        </foreach>
    </insert>
    <!-- 批量插入或按主键更新 -->
    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
        insert into TF_BASE_PUMP_GROUP(PUMP_ID, NAME, CODE, GROUPING, SUPPLIER_SIMPLE, SUPPLIER_DETAIL,
        PURCHASE_AMOUNT, PURCHASE_DATE, INVESTMENT_DATE, REMARK, INLET_PIPE_DIAMETER, OUTLET_PIPE_DIAMETER, ANNEX,
        PRODUCTION_SIMPLE, PRODUCTION_DETAIL, QUANTITY, BASE_PUMP_LIST, SORT, DELETED, CREATED_USER, CREATED_TIME,
        UPDATED_USER, UPDATED_TIME)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.pumpId}, #{entity.name}, #{entity.code}, #{entity.grouping}, #{entity.supplierSimple},
            #{entity.supplierDetail}, #{entity.purchaseAmount}, #{entity.purchaseDate}, #{entity.investmentDate},
            #{entity.remark}, #{entity.inletPipeDiameter}, #{entity.outletPipeDiameter}, #{entity.annex},
            #{entity.productionSimple}, #{entity.productionDetail}, #{entity.quantity}, #{entity.basePumpList},
            #{entity.sort}, #{entity.deleted}, #{entity.createdUser}, #{entity.createdTime}, #{entity.updatedUser},
            #{entity.updatedTime})
        </foreach>
        on duplicate key update
        PUMP_ID = values(PUMP_ID) , NAME = values(NAME) , CODE = values(CODE) , GROUPING = values(GROUPING) ,
        SUPPLIER_SIMPLE = values(SUPPLIER_SIMPLE) , SUPPLIER_DETAIL = values(SUPPLIER_DETAIL) , PURCHASE_AMOUNT =
        values(PURCHASE_AMOUNT) , PURCHASE_DATE = values(PURCHASE_DATE) , INVESTMENT_DATE = values(INVESTMENT_DATE) ,
        REMARK = values(REMARK) , INLET_PIPE_DIAMETER = values(INLET_PIPE_DIAMETER) , OUTLET_PIPE_DIAMETER =
        values(OUTLET_PIPE_DIAMETER) , ANNEX = values(ANNEX) , PRODUCTION_SIMPLE = values(PRODUCTION_SIMPLE) ,
        PRODUCTION_DETAIL = values(PRODUCTION_DETAIL) , QUANTITY = values(QUANTITY) , BASE_PUMP_LIST =
        values(BASE_PUMP_LIST) , SORT = values(SORT) , DELETED = values(DELETED) , CREATED_USER = values(CREATED_USER) ,
        CREATED_TIME = values(CREATED_TIME) , UPDATED_USER = values(UPDATED_USER) , UPDATED_TIME = values(UPDATED_TIME)
    </insert>

</mapper>

