<?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.BStatTablePwxkBoilerFuelSolidLiquidMapper">
  <resultMap id="BaseResultMap" type="cn.cecep.talroad.domain.BStatTablePwxkBoilerFuelSolidLiquid">
    <!--@mbg.generated-->
    <!--@Table b_stat_table_pwxk_boiler_fuel_solid_liquid-->
    <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="water_content" jdbcType="NUMERIC" property="waterContent" />
    <result column="ash_content" jdbcType="NUMERIC" property="ashContent" />
    <result column="volatile_percentage" jdbcType="NUMERIC" property="volatilePercentage" />
    <result column="fixed_carbon" jdbcType="NUMERIC" property="fixedCarbon" />
    <result column="carbon" jdbcType="NUMERIC" property="carbon" />
    <result column="hydrogen" jdbcType="NUMERIC" property="hydrogen" />
    <result column="oxygen" jdbcType="NUMERIC" property="oxygen" />
    <result column="nitrogen" jdbcType="NUMERIC" property="nitrogen" />
    <result column="sulfur" jdbcType="NUMERIC" property="sulfur" />
    <result column="lower_heating" jdbcType="NUMERIC" property="lowerHeating" />
    <result column="mercury" jdbcType="NUMERIC" property="mercury" />
    <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, water_content, ash_content, "volatile_percentage", fixed_carbon, carbon, hydrogen,
    oxygen, nitrogen, sulfur, lower_heating, mercury, year_used, other_info, trade_secrets
  </sql>
  <update id="updateBatch" parameterType="java.util.List">
    <!--@mbg.generated-->
    update b_stat_table_pwxk_boiler_fuel_solid_liquid
    <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="water_content = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.waterContent,jdbcType=NUMERIC}
        </foreach>
      </trim>
      <trim prefix="ash_content = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.ashContent,jdbcType=NUMERIC}
        </foreach>
      </trim>
      <trim prefix="&quot;volatile_percentage&quot; = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.volatilePercentage,jdbcType=NUMERIC}
        </foreach>
      </trim>
      <trim prefix="fixed_carbon = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.fixedCarbon,jdbcType=NUMERIC}
        </foreach>
      </trim>
      <trim prefix="carbon = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.carbon,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="sulfur = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.sulfur,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="mercury = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.mercury,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_solid_liquid
    <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="water_content = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.waterContent != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.waterContent,jdbcType=NUMERIC}
          </if>
        </foreach>
      </trim>
      <trim prefix="ash_content = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.ashContent != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.ashContent,jdbcType=NUMERIC}
          </if>
        </foreach>
      </trim>
      <trim prefix="&quot;volatile_percentage&quot; = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.volatilePercentage != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.volatilePercentage,jdbcType=NUMERIC}
          </if>
        </foreach>
      </trim>
      <trim prefix="fixed_carbon = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.fixedCarbon != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.fixedCarbon,jdbcType=NUMERIC}
          </if>
        </foreach>
      </trim>
      <trim prefix="carbon = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.carbon != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.carbon,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="sulfur = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.sulfur != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.sulfur,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="mercury = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.mercury != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.mercury,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_solid_liquid
    (id, factory_id, production_unit_name, production_facilities_code, production_facilities_name, 
      fuel_name, water_content, ash_content, "volatile_percentage", fixed_carbon, carbon, hydrogen,
      oxygen, nitrogen, sulfur, lower_heating, mercury, 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.waterContent,jdbcType=NUMERIC}, #{item.ashContent,jdbcType=NUMERIC}, 
        #{item.volatilePercentage,jdbcType=NUMERIC}, #{item.fixedCarbon,jdbcType=NUMERIC}, #{item.carbon,jdbcType=NUMERIC},
        #{item.hydrogen,jdbcType=NUMERIC}, #{item.oxygen,jdbcType=NUMERIC}, #{item.nitrogen,jdbcType=NUMERIC}, 
        #{item.sulfur,jdbcType=NUMERIC}, #{item.lowerHeating,jdbcType=NUMERIC}, #{item.mercury,jdbcType=NUMERIC}, 
        #{item.yearUsed,jdbcType=NUMERIC}, #{item.otherInfo,jdbcType=VARCHAR}, #{item.tradeSecrets,jdbcType=VARCHAR}
        )
    </foreach>
  </insert>

  <select id="selectListAndFactory" resultType="cn.cecep.talroad.vo.BStatTablePwxkBoilerFuelSolidLiquidVo">
    SELECT
    bstpbfsl.*,
    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_solid_liquid bstpbfsl ON pf.ID = bstpbfsl.factory_id
        <if test="productionFacilitiesName != null and productionFacilitiesName != ''">
          AND bstpbfsl.production_facilities_name LIKE CONCAT ('%',#{productionFacilitiesName,jdbcType=VARCHAR},'%')
        </if>
        <if test="productionFacilitiesCode != null and productionFacilitiesCode != ''">
          AND bstpbfsl.production_facilities_code LIKE CONCAT ('%',#{productionFacilitiesCode,jdbcType=VARCHAR},'%')
        </if>
        <if test="fuelName != null and fuelName != ''">
          AND bstpbfsl.fuel_name LIKE CONCAT ('%',#{fuelName,jdbcType=VARCHAR},'%')
        </if>
    <where>
      <if test="factoryIdList != null and factoryIdList.size() != 0">
        pf.id
        <foreach close=")" collection="factoryIdList" item="item" open=" IN (" separator=",">
          #{item,jdbcType=VARCHAR}
        </foreach>
      </if>
    </where>
    ORDER BY pf.order_num, pf.id, bstpbfsl.production_unit_name, bstpbfsl.id
  </select>
</mapper>