<?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.jeeplus.modules.sg.overheadline.mapper.OverheadLineMapper">

	<select id="getList" parameterType="String" resultType="com.jeeplus.modules.sg.overheadline.entity.JkxlDetailFee">
        SELECT
         a.simple_describe as 'describe',
         a.short_id as wbsCode,
         a.parent_node as parentNode,
         a.fee_type as feeType,
         b.id,
         b.original_total_cost as originalTotalCost,
         b.original_rg_cost as originalRgCost,
         b.original_cbr_cost as originalCbrCost,
         b.original_fbr_cost as originalFbrCost,
         b.original_jx_cost as originalJxCost,
         b.rg_cost as rgCost,
         b.cbr_cost as cbrCost,
         b.fbr_cost as fbrCost,
         b.jx_cost as jxCost,
         b.measures_fee1 as measuresFee1,
         b.measures_fee2 as measuresFee2,
         b.other_cost as otherCost,
         b.tex as tex,
         b.fees as fees,
         b.zjgc_fee as zjgcFee,
         b.total_fee as totalFee,
         b.original_rate as originalRate,
         b.rg_fee_ft as rgFtFee,
         b.cbr_fee_ft as cbrFtFee,
         b.fbr_fee_ft as fbrFtFee,
         b.jx_fee_ft as jxFtFee,
         b.gx_fee as gxFee
         FROM sg_wbs_elements a LEFT JOIN sg_fee_detail_jkxl b on a.short_id = b.wbs_code
         and b.id = #{id}
         <where>
			 a.state = '1' and project_type = '1'
		 </where>
	</select>

	<select id="getData"  resultType="com.jeeplus.modules.sg.overheadline.entity.JkxlDetailFee">
        SELECT
         a.simple_describe as 'describe',
         a.short_id as wbsCode,
         a.parent_node as parentNode,
		 a.fee_type as feeType,
         b.id,
         b.original_total_cost as originalTotalCost,
         b.original_rg_cost as originalRgCost,
         b.original_cbr_cost as originalCbrCost,
         b.original_fbr_cost as originalFbrCost,
         b.original_jx_cost as originalJxCost,
         b.rg_cost as rgCost,
         b.cbr_cost as cbrCost,
         b.fbr_cost as fbrCost,
         b.jx_cost as jxCost,
         b.measures_fee1 as measuresFee1,
         b.measures_fee2 as measuresFee2,
		 b.measures_fee3 as measuresFee3,
         b.other_cost as otherCost,
         b.tex as tex,
         b.fees as fees,
         b.zjgc_fee as zjgcFee,
         b.total_fee as totalFee,
         b.original_rate as originalRate,
         b.rg_fee_ft   as rgFtFee,
         b.cbr_fee_ft  as cbrFtFee,
         b.fbr_fee_ft  as fbrFtFee,
         b.jx_fee_ft as jxFtFee
         FROM sg_wbs_elements a LEFT JOIN sg_fee_detail_jkxl b on a.short_id = b.wbs_code
         <where>
         b.id = #{id}  and a.short_id = #{wbsCode}
		 </where>
	</select>


	<select id="findList" parameterType="String" resultType="com.jeeplus.modules.sg.overheadline.entity.JkxlDetailFee">
		 SELECT
		 a.id as wbsId,
         a.project_id as projectId,
         a.describe,
         a.short_id as wbsCode,
         a.subject_allocate as subjectAllocate,
         a.mount_matter as mountMatter,
         a.mount_server as mountServer,
         b.original_total_cost as originalTotalCost,
         b.total_fee as totalFee
         FROM sg_wbs_elements a LEFT JOIN sg_fee_detail_jkxl b on a.short_id = b.wbs_code
         and b.id = #{id}
         <where>
			 project_type = '1'
		 </where>
         order by a.id
	</select>


	<insert id="save" parameterType="com.jeeplus.modules.sg.overheadline.entity.JkxlDetailFee">
		insert into sg_fee_detail_jkxl
		(id,
		 wbs_code,
		 original_total_cost,
		 original_rate,
		 original_rg_cost,
		 original_cbr_cost,
		 original_fbr_cost,
		 original_jx_cost,
		 rg_cost,
		 cbr_cost,
		 fbr_cost,
		 jx_cost,
		 measures_fee1,
		 measures_fee2,
		 measures_fee3,
		 other_cost,
		 fees,
		 tex,
		 total_fee,
		 zjgc_fee,
		 rg_fee_ft,
		 cbr_fee_ft,
		 fbr_fee_ft,
		 jx_fee_ft,
		 gx_fee
		) values (
		 #{id},
		 #{wbsCode},
		 #{originalTotalCost},
		 #{originalRate},
		 #{originalRgCost},
		 #{originalCbrCost},
		 #{originalFbrCost},
		 #{originalJxCost},
		 #{rgCost},
		 #{cbrCost},
		 #{fbrCost},
		 #{jxCost},
		 #{measuresFee1},
		 #{measuresFee2},
		 #{measuresFee3},
		 #{otherCost},
		 #{fees},
		 #{tex},
		 #{totalFee},
		 #{zjgcFee},
		 #{rgFtFee},
		 #{cbrFtFee},
		 #{fbrFtFee},
		 #{jxFtFee},
		 #{gxFee}
		)
	</insert>



    <update id="updateDate" parameterType="com.jeeplus.modules.sg.overheadline.entity.JkxlDetailFee">
          update sg_fee_detail_jkxl set
             <if test="rgFtFee != null and rgFtFee != ''">
				 rg_fee_ft = #{rgFtFee},
			 </if>
		     <if test="cbrFtFee != null and cbrFtFee != ''">
				 cbr_fee_ft = #{cbrFtFee},
		     </if>
		     <if test="fbrFtFee != null and fbrFtFee != ''">
				 fbr_fee_ft =  #{fbrFtFee},
		     </if>
		      <if test="jxFtFee != null and jxFtFee != ''">
				  jx_fee_ft =  #{jxFtFee},
			  </if>
		      <if test="measuresFee1 != null and measuresFee1 != ''">
				  measures_fee1 = #{measuresFee1},
		     </if>
		      <if test="measuresFee2 != null and measuresFee2 != ''">
				  measures_fee2 = #{measuresFee2},
		     </if>
		     <if test="measuresFee3 != null and measuresFee3 != ''">
			       measures_fee3 = #{measuresFee3},
		     </if>
		     <if test="otherCost != null and otherCost != ''">
				 other_cost = #{otherCost},
		     </if>
		     <if test="fees != null and fees != ''">
				 fees = #{fees},
		     </if>
		     <if test="tex != null and tex != ''">
				 tex = #{tex},
		    </if>
		    <if test="totalFee != null and totalFee != ''">
				total_fee = #{totalFee},
		    </if>
		    id = #{id}
          <where>
              id = #{id} and wbs_code = #{wbsCode}
          </where>
    </update>





	<insert id="saveProject" parameterType="com.jeeplus.modules.sg.overheadline.entity.WbsProject">
		insert into sg_wbs_project
		(id,
		 project_name,
		 create_date
		) values (
		 #{id},
		 #{name},
		 #{createDate}
		)
	</insert>



	
</mapper>