<?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.BStatTablePwxkBoilerFuelGasMapper">
  <resultMap id="BaseResultMap" type="cn.cecep.talroad.domain.BStatTablePwxkBoilerFuelGas">
    <!--@mbg.generated-->
    <!--@Table b_stat_table_pwxk_boiler_fuel_gas-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="factory_id" jdbcType="VARCHAR" property="factoryId" />
    <result column="production_unit_name" jdbcType="VARCHAR" property="productionUnitName" />
    <result column="production_facilities_code" jdbcType="VARCHAR" property="productionFacilitiesCode" />
    <result column="production_facilities_name" jdbcType="VARCHAR" property="productionFacilitiesName" />
    <result column="fuel_name" jdbcType="VARCHAR" property="fuelName" />
    <result column="methane" jdbcType="NUMERIC" property="methane" />
    <result column="ethane" jdbcType="NUMERIC" property="ethane" />
    <result column="propane" jdbcType="NUMERIC" property="propane" />
    <result column="butane" jdbcType="NUMERIC" property="butane" />
    <result column="pentane" jdbcType="NUMERIC" property="pentane" />
    <result column="hexane_and_heavier" jdbcType="NUMERIC" property="hexaneAndHeavier" />
    <result column="co" jdbcType="NUMERIC" property="co" />
    <result column="co2" jdbcType="NUMERIC" property="co2" />
    <result column="hydrogen" jdbcType="NUMERIC" property="hydrogen" />
    <result column="oxygen" jdbcType="NUMERIC" property="oxygen" />
    <result column="nitrogen" jdbcType="NUMERIC" property="nitrogen" />
    <result column="hydrogen_sulfide" jdbcType="NUMERIC" property="hydrogenSulfide" />
    <result column="other_components" jdbcType="NUMERIC" property="otherComponents" />
    <result column="total_sulfur" jdbcType="NUMERIC" property="totalSulfur" />
    <result column="lower_heating" jdbcType="NUMERIC" property="lowerHeating" />
    <result column="year_used" jdbcType="NUMERIC" property="yearUsed" />
    <result column="other_info" jdbcType="VARCHAR" property="otherInfo" />
    <result column="trade_secrets" jdbcType="VARCHAR" property="tradeSecrets" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, factory_id, production_unit_name, production_facilities_code, production_facilities_name, 
    fuel_name, methane, ethane, propane, butane, pentane, hexane_and_heavier, co, co2, 
    hydrogen, oxygen, nitrogen, hydrogen_sulfide, other_components, total_sulfur, lower_heating, 
    year_used, other_info, trade_secrets
  </sql>
  <update id="updateBatch" parameterType="java.util.List">
    <!--@mbg.generated-->
    update b_stat_table_pwxk_boiler_fuel_gas
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="factory_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.factoryId,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="production_unit_name = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.productionUnitName,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="production_facilities_code = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.productionFacilitiesCode,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="production_facilities_name = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.productionFacilitiesName,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="fuel_name = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.fuelName,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="methane = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.methane,jdbcType=NUMERIC}
        </foreach>
      </trim>
      <trim prefix="ethane = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.ethane,jdbcType=NUMERIC}
        </foreach>
      </trim>
      <trim prefix="propane = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.propane,jdbcType=NUMERIC}
        </foreach>
      </trim>
      <trim prefix="butane = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.butane,jdbcType=NUMERIC}
        </foreach>
      </trim>
      <trim prefix="pentane = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.pentane,jdbcType=NUMERIC}
        </foreach>
      </trim>
      <trim prefix="hexane_and_heavier = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.hexaneAndHeavier,jdbcType=NUMERIC}
        </foreach>
      </trim>
      <trim prefix="co = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.co,jdbcType=NUMERIC}
        </foreach>
      </trim>
      <trim prefix="co2 = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.co2,jdbcType=NUMERIC}
        </foreach>
      </trim>
      <trim prefix="hydrogen = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.hydrogen,jdbcType=NUMERIC}
        </foreach>
      </trim>
      <trim prefix="oxygen = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.oxygen,jdbcType=NUMERIC}
        </foreach>
      </trim>
      <trim prefix="nitrogen = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.nitrogen,jdbcType=NUMERIC}
        </foreach>
      </trim>
      <trim prefix="hydrogen_sulfide = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.hydrogenSulfide,jdbcType=NUMERIC}
        </foreach>
      </trim>
      <trim prefix="other_components = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.otherComponents,jdbcType=NUMERIC}
        </foreach>
      </trim>
      <trim prefix="total_sulfur = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.totalSulfur,jdbcType=NUMERIC}
        </foreach>
      </trim>
      <trim prefix="lower_heating = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.lowerHeating,jdbcType=NUMERIC}
        </foreach>
      </trim>
      <trim prefix="year_used = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.yearUsed,jdbcType=NUMERIC}
        </foreach>
      </trim>
      <trim prefix="other_info = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.otherInfo,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="trade_secrets = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.tradeSecrets,jdbcType=VARCHAR}
        </foreach>
      </trim>
    </trim>
    where id in
    <foreach close=")" collection="list" item="item" open="(" separator=", ">
      #{item.id,jdbcType=BIGINT}
    </foreach>
  </update>
  <update id="updateBatchSelective" parameterType="java.util.List">
    <!--@mbg.generated-->
    update b_stat_table_pwxk_boiler_fuel_gas
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="factory_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.factoryId != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.factoryId,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="production_unit_name = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.productionUnitName != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.productionUnitName,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="production_facilities_code = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.productionFacilitiesCode != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.productionFacilitiesCode,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="production_facilities_name = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.productionFacilitiesName != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.productionFacilitiesName,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="fuel_name = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.fuelName != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.fuelName,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="methane = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.methane != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.methane,jdbcType=NUMERIC}
          </if>
        </foreach>
      </trim>
      <trim prefix="ethane = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.ethane != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.ethane,jdbcType=NUMERIC}
          </if>
        </foreach>
      </trim>
      <trim prefix="propane = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.propane != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.propane,jdbcType=NUMERIC}
          </if>
        </foreach>
      </trim>
      <trim prefix="butane = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.butane != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.butane,jdbcType=NUMERIC}
          </if>
        </foreach>
      </trim>
      <trim prefix="pentane = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.pentane != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.pentane,jdbcType=NUMERIC}
          </if>
        </foreach>
      </trim>
      <trim prefix="hexane_and_heavier = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.hexaneAndHeavier != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.hexaneAndHeavier,jdbcType=NUMERIC}
          </if>
        </foreach>
      </trim>
      <trim prefix="co = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.co != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.co,jdbcType=NUMERIC}
          </if>
        </foreach>
      </trim>
      <trim prefix="co2 = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.co2 != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.co2,jdbcType=NUMERIC}
          </if>
        </foreach>
      </trim>
      <trim prefix="hydrogen = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.hydrogen != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.hydrogen,jdbcType=NUMERIC}
          </if>
        </foreach>
      </trim>
      <trim prefix="oxygen = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.oxygen != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.oxygen,jdbcType=NUMERIC}
          </if>
        </foreach>
      </trim>
      <trim prefix="nitrogen = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.nitrogen != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.nitrogen,jdbcType=NUMERIC}
          </if>
        </foreach>
      </trim>
      <trim prefix="hydrogen_sulfide = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.hydrogenSulfide != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.hydrogenSulfide,jdbcType=NUMERIC}
          </if>
        </foreach>
      </trim>
      <trim prefix="other_components = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.otherComponents != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.otherComponents,jdbcType=NUMERIC}
          </if>
        </foreach>
      </trim>
      <trim prefix="total_sulfur = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.totalSulfur != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.totalSulfur,jdbcType=NUMERIC}
          </if>
        </foreach>
      </trim>
      <trim prefix="lower_heating = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.lowerHeating != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.lowerHeating,jdbcType=NUMERIC}
          </if>
        </foreach>
      </trim>
      <trim prefix="year_used = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.yearUsed != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.yearUsed,jdbcType=NUMERIC}
          </if>
        </foreach>
      </trim>
      <trim prefix="other_info = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.otherInfo != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.otherInfo,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="trade_secrets = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.tradeSecrets != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.tradeSecrets,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
    </trim>
    where id in
    <foreach close=")" collection="list" item="item" open="(" separator=", ">
      #{item.id,jdbcType=BIGINT}
    </foreach>
  </update>
  <insert id="batchInsert" parameterType="map">
    <!--@mbg.generated-->
    insert into b_stat_table_pwxk_boiler_fuel_gas
    (id, factory_id, production_unit_name, production_facilities_code, production_facilities_name, 
      fuel_name, methane, ethane, propane, butane, pentane, hexane_and_heavier, co, co2, 
      hydrogen, oxygen, nitrogen, hydrogen_sulfide, other_components, total_sulfur, lower_heating, 
      year_used, other_info, trade_secrets)
    values
    <foreach collection="list" item="item" separator=",">
      (#{item.id,jdbcType=BIGINT}, #{item.factoryId,jdbcType=VARCHAR}, #{item.productionUnitName,jdbcType=VARCHAR}, 
        #{item.productionFacilitiesCode,jdbcType=VARCHAR}, #{item.productionFacilitiesName,jdbcType=VARCHAR}, 
        #{item.fuelName,jdbcType=VARCHAR}, #{item.methane,jdbcType=NUMERIC}, #{item.ethane,jdbcType=NUMERIC}, 
        #{item.propane,jdbcType=NUMERIC}, #{item.butane,jdbcType=NUMERIC}, #{item.pentane,jdbcType=NUMERIC}, 
        #{item.hexaneAndHeavier,jdbcType=NUMERIC}, #{item.co,jdbcType=NUMERIC}, #{item.co2,jdbcType=NUMERIC}, 
        #{item.hydrogen,jdbcType=NUMERIC}, #{item.oxygen,jdbcType=NUMERIC}, #{item.nitrogen,jdbcType=NUMERIC}, 
        #{item.hydrogenSulfide,jdbcType=NUMERIC}, #{item.otherComponents,jdbcType=NUMERIC}, 
        #{item.totalSulfur,jdbcType=NUMERIC}, #{item.lowerHeating,jdbcType=NUMERIC}, #{item.yearUsed,jdbcType=NUMERIC}, 
        #{item.otherInfo,jdbcType=VARCHAR}, #{item.tradeSecrets,jdbcType=VARCHAR})
    </foreach>
  </insert>

  <select id="selectListAndFactory" resultType="cn.cecep.talroad.vo.BStatTablePwxkBoilerFuelGasVo">
    SELECT
    bstpbfg.*,
    pf.factory_name,
    pf.poll_dis_license_code,
    pf.city_code,
    pf.city_name,
    pf.country_code,
    pf.country_name,
    pf.license_man_type,
    pf.usc_code,
    pf.ins_fram_code,
    pf.whether_local_park,
    pf.industrial_park_name,
    pf.industrial_park_code,
    pf.industry_permission_name,
    pf.river_basin
    FROM pc_factory pf
    LEFT JOIN  b_stat_table_pwxk_boiler_fuel_gas bstpbfg ON pf.ID = bstpbfg.factory_id
    <where>
        <if test="factoryIdList != null and factoryIdList.size() > 0">
          AND pf.id
          <foreach collection="factoryIdList" close=")" open=" IN (" separator="," item="item">
            #{item,jdbcType=VARCHAR}
          </foreach>
        </if>
        <if test="productionFacilitiesName != null and productionFacilitiesName != ''">
          AND bstpbfg.production_facilities_name LIKE CONCAT ('%',#{productionFacilitiesName,jdbcType=VARCHAR},'%')
        </if>
        <if test="productionFacilitiesCode != null and productionFacilitiesCode != ''">
          AND bstpbfg.production_facilities_code LIKE CONCAT ('%',#{productionFacilitiesCode,jdbcType=VARCHAR},'%')
        </if>
        <if test="fuelName != null and fuelName != ''">
          AND bstpbfg.fuel_name LIKE CONCAT ('%',#{fuelName,jdbcType=VARCHAR},'%')
        </if>
    </where>
    ORDER BY pf.order_num, pf.id, bstpbfg.production_unit_name, bstpbfg.id
  </select>
</mapper>