<?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.goafanti.common.dao.OrgFinanceMapper" >
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.OrgFinance" >
    <id column="id" property="id" jdbcType="VARCHAR" />
    <result column="uid" property="uid" jdbcType="VARCHAR" />
    <result column="main_business_income" property="mainBusinessIncome" jdbcType="DECIMAL" />
    <result column="management_cost" property="managementCost" jdbcType="DECIMAL" />
    <result column="operating_profit" property="operatingProfit" jdbcType="DECIMAL" />
    <result column="various_tax" property="variousTax" jdbcType="DECIMAL" />
    <result column="current_asset" property="currentAsset" jdbcType="DECIMAL" />
    <result column="net_fixed_asset" property="netFixedAsset" jdbcType="DECIMAL" />
    <result column="total_asset" property="totalAsset" jdbcType="DECIMAL" />
    <result column="net_asset" property="netAsset" jdbcType="DECIMAL" />
    <result column="gross_profit" property="grossProfit" jdbcType="DECIMAL" />
    <result column="net_profit" property="netProfit" jdbcType="DECIMAL" />
    <result column="sales_revenue" property="salesRevenue" jdbcType="DECIMAL" />
    <result column="year" property="year" jdbcType="INTEGER" />
    <result column="finance_url" property="financeUrl" jdbcType="VARCHAR" />
    <result column="research_cost" property="researchCost" jdbcType="DECIMAL" />
    <result column="deleted_sign" property="deletedSign" jdbcType="INTEGER" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, uid, main_business_income, management_cost, operating_profit, various_tax, current_asset, 
    net_fixed_asset, total_asset, net_asset, gross_profit, net_profit, sales_revenue, year,
    finance_url, research_cost, deleted_sign
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from org_finance
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
    delete from org_finance
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="com.goafanti.common.model.OrgFinance" >
    insert into org_finance (id, uid, main_business_income, 
      management_cost, operating_profit, various_tax, 
      current_asset, net_fixed_asset, total_asset, 
      net_asset, gross_profit, net_profit, 
      sales_revenue, year, finance_url, research_cost, deleted_sign)
    values (#{id,jdbcType=VARCHAR}, #{uid,jdbcType=VARCHAR}, #{mainBusinessIncome,jdbcType=DECIMAL}, 
      #{managementCost,jdbcType=DECIMAL}, #{operatingProfit,jdbcType=DECIMAL}, #{variousTax,jdbcType=DECIMAL}, 
      #{currentAsset,jdbcType=DECIMAL}, #{netFixedAsset,jdbcType=DECIMAL}, #{totalAsset,jdbcType=DECIMAL}, 
      #{netAsset,jdbcType=DECIMAL}, #{grossProfit,jdbcType=DECIMAL}, #{netProfit,jdbcType=DECIMAL}, 
      #{salesRevenue,jdbcType=DECIMAL}, #{year,jdbcType=INTEGER}, #{financeUrl,jdbcType=VARCHAR}, 
      #{researchCost,jdbcType=DECIMAL}, #{deletedSign,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.goafanti.common.model.OrgFinance" >
    insert into org_finance
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="uid != null" >
        uid,
      </if>
      <if test="mainBusinessIncome != null" >
        main_business_income,
      </if>
      <if test="managementCost != null" >
        management_cost,
      </if>
      <if test="operatingProfit != null" >
        operating_profit,
      </if>
      <if test="variousTax != null" >
        various_tax,
      </if>
      <if test="currentAsset != null" >
        current_asset,
      </if>
      <if test="netFixedAsset != null" >
        net_fixed_asset,
      </if>
      <if test="totalAsset != null" >
        total_asset,
      </if>
      <if test="netAsset != null" >
        net_asset,
      </if>
      <if test="grossProfit != null" >
        gross_profit,
      </if>
      <if test="netProfit != null" >
        net_profit,
      </if>
      <if test="salesRevenue != null" >
        sales_revenue,
      </if>
      <if test="year != null" >
        year,
      </if>
      <if test="financeUrl != null" >
        finance_url,
      </if>
       <if test="researchCost != null" >
        research_cost,
      </if>
      <if test="deletedSign != null" >
        deleted_sign,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="uid != null" >
        #{uid,jdbcType=VARCHAR},
      </if>
      <if test="mainBusinessIncome != null" >
        #{mainBusinessIncome,jdbcType=DECIMAL},
      </if>
      <if test="managementCost != null" >
        #{managementCost,jdbcType=DECIMAL},
      </if>
      <if test="operatingProfit != null" >
        #{operatingProfit,jdbcType=DECIMAL},
      </if>
      <if test="variousTax != null" >
        #{variousTax,jdbcType=DECIMAL},
      </if>
      <if test="currentAsset != null" >
        #{currentAsset,jdbcType=DECIMAL},
      </if>
      <if test="netFixedAsset != null" >
        #{netFixedAsset,jdbcType=DECIMAL},
      </if>
      <if test="totalAsset != null" >
        #{totalAsset,jdbcType=DECIMAL},
      </if>
      <if test="netAsset != null" >
        #{netAsset,jdbcType=DECIMAL},
      </if>
      <if test="grossProfit != null" >
        #{grossProfit,jdbcType=DECIMAL},
      </if>
      <if test="netProfit != null" >
        #{netProfit,jdbcType=DECIMAL},
      </if>
      <if test="salesRevenue != null" >
        #{salesRevenue,jdbcType=DECIMAL},
      </if>
      <if test="year != null" >
        #{year,jdbcType=INTEGER},
      </if>
      <if test="financeUrl != null" >
        #{financeUrl,jdbcType=VARCHAR},
      </if>
      <if test="researchCost != null" >
        #{researchCost,jdbcType=DECIMAL},
      </if>
      <if test="deletedSign != null" >
        #{deletedSign,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.OrgFinance" >
    update org_finance
    <set >
      <if test="uid != null" >
        uid = #{uid,jdbcType=VARCHAR},
      </if>
      <if test="mainBusinessIncome != null" >
        main_business_income = #{mainBusinessIncome,jdbcType=DECIMAL},
      </if>
      <if test="managementCost != null" >
        management_cost = #{managementCost,jdbcType=DECIMAL},
      </if>
      <if test="operatingProfit != null" >
        operating_profit = #{operatingProfit,jdbcType=DECIMAL},
      </if>
      <if test="variousTax != null" >
        various_tax = #{variousTax,jdbcType=DECIMAL},
      </if>
      <if test="currentAsset != null" >
        current_asset = #{currentAsset,jdbcType=DECIMAL},
      </if>
      <if test="netFixedAsset != null" >
        net_fixed_asset = #{netFixedAsset,jdbcType=DECIMAL},
      </if>
      <if test="totalAsset != null" >
        total_asset = #{totalAsset,jdbcType=DECIMAL},
      </if>
      <if test="netAsset != null" >
        net_asset = #{netAsset,jdbcType=DECIMAL},
      </if>
      <if test="grossProfit != null" >
        gross_profit = #{grossProfit,jdbcType=DECIMAL},
      </if>
      <if test="netProfit != null" >
        net_profit = #{netProfit,jdbcType=DECIMAL},
      </if>
      <if test="salesRevenue != null" >
        sales_revenue = #{salesRevenue,jdbcType=DECIMAL},
      </if>
      <if test="year != null" >
        year = #{year,jdbcType=INTEGER},
      </if>
      <if test="financeUrl != null" >
        finance_url = #{financeUrl,jdbcType=VARCHAR},
      </if>
       <if test="researchCost != null" >
        research_cost = #{researchCost,jdbcType=DECIMAL},
      </if>
       <if test="deletedSign != null" >
        deleted_sign = #{deletedSign,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.OrgFinance" >
    update org_finance
    set uid = #{uid,jdbcType=VARCHAR},
      main_business_income = #{mainBusinessIncome,jdbcType=INTEGER},
      management_cost = #{managementCost,jdbcType=DECIMAL},
      operating_profit = #{operatingProfit,jdbcType=DECIMAL},
      various_tax = #{variousTax,jdbcType=DECIMAL},
      current_asset = #{currentAsset,jdbcType=DECIMAL},
      net_fixed_asset = #{netFixedAsset,jdbcType=DECIMAL},
      total_asset = #{totalAsset,jdbcType=DECIMAL},
      net_asset = #{netAsset,jdbcType=DECIMAL},
      gross_profit = #{grossProfit,jdbcType=DECIMAL},
      net_profit = #{netProfit,jdbcType=DECIMAL},
      sales_revenue = #{salesRevenue,jdbcType=DECIMAL},
      year = #{year,jdbcType=INTEGER},
      finance_url = #{financeUrl,jdbcType=VARCHAR},
      research_cost = #{researchCost,jdbcType=DECIMAL},
      deleted_sign = #{deletedSign,jdbcType=INTEGER}
    where id = #{id,jdbcType=VARCHAR}
  </update>
  
   <select id="findOrgFinanceListByPage" parameterType="java.lang.String" resultMap="BaseResultMap">
  	 select 
    <include refid="Base_Column_List" />
    from org_finance
    where deleted_sign = 0
    <if test="uid != null">
	    and  uid = #{uid,jdbcType=VARCHAR}
	</if>
	<if test="year != null">
		and year = #{year,jdbcType=INTEGER}
	</if>
	order by year desc
    <if test="page_sql != null">
    	${page_sql}
    </if>
    
  </select>
  
  <select id="findOrgFinanceCount" resultType="java.lang.Integer" parameterType="String">
   	select count(1) 
	    from org_finance
    where deleted_sign = 0
	    <if test="uid != null">
		    and  uid = #{uid,jdbcType=VARCHAR}
		</if>
		<if test="year != null">
		and year = #{year,jdbcType=INTEGER}
	    </if>
    </select>
    
  <update id="batchDeleteByPrimaryKey" parameterType="java.util.List">
  	update org_finance set deleted_sign = 1
  	where  id in 
	<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
		#{item}
	</foreach>
  </update>
  
  
  <select id="selectFinanceByUidAndYear" resultMap="BaseResultMap"  >
    select 
    <include refid="Base_Column_List" />
    from org_finance
    where uid = #{0} and year = #{1} and deleted_sign = 0
  </select>
</mapper>