<?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.OrganizationAnnualReportMapper">
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.OrganizationAnnualReport">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Jul 27 15:10:52 CST 2018.
    -->
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="uid" jdbcType="VARCHAR" property="uid" />
    <result column="year" jdbcType="INTEGER" property="year" />
    <result column="sales_amount" jdbcType="VARCHAR" property="salesAmount" />
    <result column="research_amount" jdbcType="VARCHAR" property="researchAmount" />
    <result column="assets" jdbcType="VARCHAR" property="assets" />
    <result column="aid" jdbcType="VARCHAR" property="aid" />
    <result column="fixed_assets" jdbcType="VARCHAR" property="fixedAssets" />
  </resultMap>
  <resultMap id="YearProjectMap" type="com.goafanti.common.model.OrganizationYearProject">
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="uid" jdbcType="VARCHAR" property="uid" />
    <result column="year" jdbcType="INTEGER" property="year" />
    <result column="project_name" jdbcType="VARCHAR" property="projectName" />
    <result column="status" jdbcType="INTEGER" property="status" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="aid" jdbcType="VARCHAR" property="aid" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Jul 27 15:10:52 CST 2018.
    -->
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Jul 27 15:10:52 CST 2018.
    -->
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Jul 27 15:10:52 CST 2018.
    -->
    id, uid, year, sales_amount, research_amount, assets, aid, fixed_assets
  </sql>
  <sql id="Year_Project_List">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Jul 20 16:32:47 CST 2018.
    -->
    id, uid, year, project_name, status, remark, aid
  </sql>
  <select id="selectByExample" parameterType="com.goafanti.common.model.OrganizationAnnualReportExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Jul 27 15:10:52 CST 2018.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from organization_annual_report
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Jul 27 15:10:52 CST 2018.
    -->
    select 
    <include refid="Base_Column_List" />
    from organization_annual_report
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Jul 27 15:10:52 CST 2018.
    -->
    delete from organization_annual_report
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="com.goafanti.common.model.OrganizationAnnualReportExample">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Jul 27 15:10:52 CST 2018.
    -->
    delete from organization_annual_report
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.goafanti.common.model.OrganizationAnnualReport">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Jul 27 15:10:52 CST 2018.
    -->
    insert into organization_annual_report (id, uid, year, 
      sales_amount, research_amount, assets, 
      aid, fixed_assets)
    values (#{id,jdbcType=VARCHAR}, #{uid,jdbcType=VARCHAR}, #{year,jdbcType=INTEGER}, 
      #{salesAmount,jdbcType=VARCHAR}, #{researchAmount,jdbcType=VARCHAR}, #{assets,jdbcType=VARCHAR}, 
      #{aid,jdbcType=VARCHAR}, #{fixedAssets,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.goafanti.common.model.OrganizationAnnualReport">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Jul 27 15:10:52 CST 2018.
    -->
    insert into organization_annual_report
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="uid != null">
        uid,
      </if>
      <if test="year != null">
        year,
      </if>
      <if test="salesAmount != null">
        sales_amount,
      </if>
      <if test="researchAmount != null">
        research_amount,
      </if>
      <if test="assets != null">
        assets,
      </if>
      <if test="aid != null">
        aid,
      </if>
      <if test="fixedAssets != null">
        fixed_assets,
      </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="year != null">
        #{year,jdbcType=INTEGER},
      </if>
      <if test="salesAmount != null">
        #{salesAmount,jdbcType=VARCHAR},
      </if>
      <if test="researchAmount != null">
        #{researchAmount,jdbcType=VARCHAR},
      </if>
      <if test="assets != null">
        #{assets,jdbcType=VARCHAR},
      </if>
      <if test="aid != null">
        #{aid,jdbcType=VARCHAR},
      </if>
      <if test="fixedAssets != null">
        #{fixedAssets,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.goafanti.common.model.OrganizationAnnualReportExample" resultType="java.lang.Long">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Jul 27 15:10:52 CST 2018.
    -->
    select count(*) from organization_annual_report
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Jul 27 15:10:52 CST 2018.
    -->
    update organization_annual_report
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=VARCHAR},
      </if>
      <if test="record.uid != null">
        uid = #{record.uid,jdbcType=VARCHAR},
      </if>
      <if test="record.year != null">
        year = #{record.year,jdbcType=INTEGER},
      </if>
      <if test="record.salesAmount != null">
        sales_amount = #{record.salesAmount,jdbcType=VARCHAR},
      </if>
      <if test="record.researchAmount != null">
        research_amount = #{record.researchAmount,jdbcType=VARCHAR},
      </if>
      <if test="record.assets != null">
        assets = #{record.assets,jdbcType=VARCHAR},
      </if>
      <if test="record.aid != null">
        aid = #{record.aid,jdbcType=VARCHAR},
      </if>
      <if test="record.fixedAssets != null">
        fixed_assets = #{record.fixedAssets,jdbcType=VARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Jul 27 15:10:52 CST 2018.
    -->
    update organization_annual_report
    set id = #{record.id,jdbcType=VARCHAR},
      uid = #{record.uid,jdbcType=VARCHAR},
      year = #{record.year,jdbcType=INTEGER},
      sales_amount = #{record.salesAmount,jdbcType=VARCHAR},
      research_amount = #{record.researchAmount,jdbcType=VARCHAR},
      assets = #{record.assets,jdbcType=VARCHAR},
      aid = #{record.aid,jdbcType=VARCHAR},
      fixed_assets = #{record.fixedAssets,jdbcType=VARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.OrganizationAnnualReport">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Jul 27 15:10:52 CST 2018.
    -->
    update organization_annual_report
    <set>
      <if test="uid != null">
        uid = #{uid,jdbcType=VARCHAR},
      </if>
      <if test="year != null">
        year = #{year,jdbcType=INTEGER},
      </if>
      <if test="salesAmount != null">
        sales_amount = #{salesAmount,jdbcType=VARCHAR},
      </if>
      <if test="researchAmount != null">
        research_amount = #{researchAmount,jdbcType=VARCHAR},
      </if>
      <if test="assets != null">
        assets = #{assets,jdbcType=VARCHAR},
      </if>
      <if test="aid != null">
        aid = #{aid,jdbcType=VARCHAR},
      </if>
      <if test="fixedAssets != null">
        fixed_assets = #{fixedAssets,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.OrganizationAnnualReport">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Jul 27 15:10:52 CST 2018.
    -->
    update organization_annual_report
    set uid = #{uid,jdbcType=VARCHAR},
      year = #{year,jdbcType=INTEGER},
      sales_amount = #{salesAmount,jdbcType=VARCHAR},
      research_amount = #{researchAmount,jdbcType=VARCHAR},
      assets = #{assets,jdbcType=VARCHAR},
      aid = #{aid,jdbcType=VARCHAR},
      fixed_assets = #{fixedAssets,jdbcType=VARCHAR}
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <select id="checkYear" resultType="integer">
  	select count(*) from organization_annual_report where uid = #{uid,jdbcType=VARCHAR} and  year = #{year,jdbcType=INTEGER} 
  </select>
  <select id="checkAnnual" resultType="integer">
  	select count(*) from organization_annual_report where id!= #{id,jdbcType=VARCHAR} and uid = #{uid,jdbcType=VARCHAR} and year = #{year,jdbcType=INTEGER}  
  </select>
  <select id="selectOrgAnnualList" resultMap="BaseResultMap">
   select 
  <include refid="Base_Column_List" />
  from organization_annual_report
  where uid= #{uid,jdbcType=VARCHAR}
  order by `year`desc
  <if test="page_sql != null">
    		${page_sql}
   		</if>
	</select>
	<select id="selectOrgAnnualCount" resultType="java.lang.Integer">
		select 
			count(0)
			from organization_annual_report
		 where uid= #{uid,jdbcType=VARCHAR}
	</select>
	
	<select id="selectOrgYearProjectList" resultMap="YearProjectMap">
   select 
  <include refid="Year_Project_List" />
  from organization_year_project
  where uid= #{uid,jdbcType=VARCHAR}
  order by `year`desc
  <if test="page_sql != null">
    		${page_sql}
   		</if>
	</select>
	<select id="selectOrgYearProjectCount" resultType="java.lang.Integer">
		select 
			count(0)
			from organization_year_project
		 where uid= #{uid,jdbcType=VARCHAR}
	</select>
</mapper>