<?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.ruoyi.invest.mapper.TProjectScoringMapper">
    
    <resultMap type="TProjectScoring" id="TProjectScoringResult">
        <result property="id"    column="id"    />
        <result property="projectPoolId"    column="project_pool_id"    />
        <result property="investCommissioner"    column="invest_commissioner"    />
        <result property="meetingId"    column="meeting_id"    />
        <result property="scoringPerson"    column="scoring_person"    />
        <result property="type"    column="type"    />
        <result property="industryAdvantage"    column="industry_advantage"    />
        <result property="industryAdvantageNote"    column="industry_advantage_note"    />
        <result property="businessModel"    column="business_model"    />
        <result property="businessModelNote"    column="business_model_note"    />
        <result property="teamExperience"    column="team_experience"    />
        <result property="teamExperienceNote"    column="team_experience_note"    />
        <result property="teamBackground"    column="team_background"    />
        <result property="teamBackgroundNote"    column="team_background_note"    />
        <result property="teamHeart"    column="team_heart"    />
        <result property="teamHeartNote"    column="team_heart_note"    />
        <result property="teamFaith"    column="team_faith"    />
        <result property="teamFaithNote"    column="team_faith_note"    />
        <result property="productBase"    column="product_base"    />
        <result property="productBaseNote"    column="product_base_note"    />
        <result property="productProfit"    column="product_profit"    />
        <result property="productProfitNote"    column="product_profit_note"    />
        <result property="organInvest"    column="organ_invest"    />
        <result property="organInvestNote"    column="organ_invest_note"    />
        <result property="organValuation"    column="organ_valuation"    />
        <result property="organValuationNote"    column="organ_valuation_note"    />
        <result property="valuation"    column="valuation"    />
        <result property="valuationNote"    column="valuation_note"    />
        <result property="marketSpace"    column="market_space"    />
        <result property="marketSpaceNote"    column="market_space_note"    />
        <result property="developSpace"    column="develop_space"    />
        <result property="developSpaceNote"    column="develop_space_note"    />
        <result property="quitWay"    column="quit_way"    />
        <result property="quitWayNote"    column="quit_way_note"    />
        <result property="illustrate"    column="illustrate"    />
        <result property="examine"    column="examine"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <resultMap id="TProjectScoringResultToMap" type="java.util.HashMap">
        <result property="projectPoolId"    column="project_pool_id"    />
        <result property="investCommissioner"    column="invest_commissioner"    />
        <result property="meetingId"    column="meeting_id"    />
        <result property="scoringPerson"    column="scoring_person"    />
        <result property="type"    column="type"    />
        <result property="totalPerson"    column="total_person"    />
        <result property="industryAdvantageSum"    column="industry_advantage_sum"    />
        <result property="industryAdvantageAvg"    column="industry_advantage_avg"    />
        <result property="businessModelSum"    column="business_model_sum"    />
        <result property="businessModelAvg"    column="business_model_avg"    />
        <result property="teamExperienceSum"    column="team_experience_sum"    />
        <result property="teamExperienceAvg"    column="team_experience_avg"    />
        <result property="teamBackgroundSum"    column="team_background_sum"    />
        <result property="teamBackgroundAvg"    column="team_background_avg"    />
        <result property="teamHeartSum"    column="team_heart_sum"    />
        <result property="teamHeartAvg"    column="team_heart_avg"    />
        <result property="teamFaithSum"    column="team_faith_sum"    />
        <result property="teamFaithAvg"    column="team_faith_avg"    />
        <result property="productBaseSum"    column="product_base_sum"    />
        <result property="productBaseAvg"    column="product_base_avg"    />
        <result property="productProfitSum"    column="product_profit_sum"    />
        <result property="productProfitAvg"    column="product_profit_avg"    />
        <result property="organInvestSum"    column="organ_invest_sum"    />
        <result property="organInvestAvg"    column="organ_invest_avg"    />
        <result property="organValuationSum"    column="organ_valuation_sum"    />
        <result property="organValuationAvg"    column="organ_valuation_avg"    />
        <result property="valuationSum"    column="valuation_sum"    />
        <result property="valuationAvg"    column="valuation_avg"    />
        <result property="marketSpaceSum"    column="market_space_sum"    />
        <result property="marketSpaceAvg"    column="market_space_avg"    />
        <result property="developSpaceSum"    column="develop_space_sum"    />
        <result property="developSpaceAvg"    column="develop_space_avg"    />
        <result property="quitWaySum"    column="quit_way_sum"    />
        <result property="quitWayAvg"    column="quit_way_avg"    />
    </resultMap>

    <sql id="selectTProjectScoringVo">
        select id, project_pool_id, invest_commissioner, meeting_id, scoring_person, type, industry_advantage, industry_advantage_note, business_model, business_model_note, team_experience, team_experience_note, team_background, team_background_note, team_heart, team_heart_note, team_faith, team_faith_note, product_base, product_base_note, product_profit, product_profit_note, organ_invest, organ_invest_note, organ_valuation, organ_valuation_note, valuation, valuation_note, market_space, market_space_note, develop_space, develop_space_note, quit_way, quit_way_note, illustrate, examine, del_flag, create_by, create_time, update_by, update_time from t_project_scoring
    </sql>

    <sql id="selectMeetingIdVo">
        select project_pool_id,invest_commissioner, meeting_id, scoring_person, type, COUNT(scoring_person) total_person,
            SUM(industry_advantage)  industry_advantage_Sum, AVG(industry_advantage)  industry_advantage_Avg,
            SUM(business_model)   business_model_Sum, AVG(business_model)   business_model_Avg,
            SUM(team_experience)   team_experience_Sum, AVG( team_experience)   team_experience_Avg,
            SUM(team_background)   team_background_Sum, AVG( team_background)   team_background_Avg,
            SUM(team_heart)   team_heart_Sum, AVG( team_heart)   team_heart_Avg,
            SUM(team_faith)   team_faith_Sum, AVG( team_faith)   team_faith_Avg,
            SUM(product_base)   product_base_Sum, AVG( product_base)   product_base_Avg,
            SUM(product_profit)   product_profit_Sum, AVG( product_profit)   product_profit_Avg,
            SUM(organ_invest)   organ_invest_Sum, AVG( organ_invest)   organ_invest_Avg,
            SUM(organ_valuation)   organ_valuation_Sum, AVG( organ_valuation)   organ_valuation_Avg,
            SUM(valuation)   valuation_Sum, AVG( valuation)   valuation_Avg,
            SUM(market_space)   market_space_Sum, AVG( market_space)   market_space_Avg,
            SUM(develop_space)   develop_space_Sum, AVG( develop_space)   develop_space_Avg,
            SUM(quit_way)   quit_way_Sum, AVG( quit_way)   quit_way_Avg
        from t_project_scoring
    </sql>

    <select id="selectTProjectScoringList" parameterType="TProjectScoring" resultMap="TProjectScoringResult">
        <include refid="selectTProjectScoringVo"/>
        <where>
            del_flag = 0
            <if test="meetingId != null  and meetingId != ''"> and meeting_id = #{meetingId}</if>
            <if test="projectPoolId != null  and projectPoolId != ''"> and project_pool_id = #{projectPoolId}</if>
            <if test="investCommissioner != null  and investCommissioner != ''"> and invest_commissioner = #{investCommissioner}</if>
            <if test="scoringPerson != null  and scoringPerson != ''"> and scoring_person = #{scoringPerson}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
        </where>
    </select>
    
    <select id="selectTProjectScoringById" parameterType="String" resultMap="TProjectScoringResult">
        <include refid="selectTProjectScoringVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTProjectScoring" parameterType="TProjectScoring">
        insert into t_project_scoring
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="projectPoolId != null">project_pool_id,</if>
            <if test="investCommissioner != null">invest_commissioner,</if>
            <if test="meetingId != null">meeting_id,</if>
            <if test="scoringPerson != null">scoring_person,</if>
            <if test="type != null">type,</if>
            <if test="industryAdvantage != null">industry_advantage,</if>
            <if test="industryAdvantageNote != null">industry_advantage_note,</if>
            <if test="businessModel != null">business_model,</if>
            <if test="businessModelNote != null">business_model_note,</if>
            <if test="teamExperience != null">team_experience,</if>
            <if test="teamExperienceNote != null">team_experience_note,</if>
            <if test="teamBackground != null">team_background,</if>
            <if test="teamBackgroundNote != null">team_background_note,</if>
            <if test="teamHeart != null">team_heart,</if>
            <if test="teamHeartNote != null">team_heart_note,</if>
            <if test="teamFaith != null">team_faith,</if>
            <if test="teamFaithNote != null">team_faith_note,</if>
            <if test="productBase != null">product_base,</if>
            <if test="productBaseNote != null">product_base_note,</if>
            <if test="productProfit != null">product_profit,</if>
            <if test="productProfitNote != null">product_profit_note,</if>
            <if test="organInvest != null">organ_invest,</if>
            <if test="organInvestNote != null">organ_invest_note,</if>
            <if test="organValuation != null">organ_valuation,</if>
            <if test="organValuationNote != null">organ_valuation_note,</if>
            <if test="valuation != null">valuation,</if>
            <if test="valuationNote != null">valuation_note,</if>
            <if test="marketSpace != null">market_space,</if>
            <if test="marketSpaceNote != null">market_space_note,</if>
            <if test="developSpace != null">develop_space,</if>
            <if test="developSpaceNote != null">develop_space_note,</if>
            <if test="quitWay != null">quit_way,</if>
            <if test="quitWayNote != null">quit_way_note,</if>
            <if test="illustrate != null">illustrate,</if>
            <if test="examine != null">examine,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="projectPoolId != null">#{projectPoolId},</if>
            <if test="investCommissioner != null">#{investCommissioner},</if>
            <if test="meetingId != null">#{meetingId},</if>
            <if test="scoringPerson != null">#{scoringPerson},</if>
            <if test="type != null">#{type},</if>
            <if test="industryAdvantage != null">#{industryAdvantage},</if>
            <if test="industryAdvantageNote != null">#{industryAdvantageNote},</if>
            <if test="businessModel != null">#{businessModel},</if>
            <if test="businessModelNote != null">#{businessModelNote},</if>
            <if test="teamExperience != null">#{teamExperience},</if>
            <if test="teamExperienceNote != null">#{teamExperienceNote},</if>
            <if test="teamBackground != null">#{teamBackground},</if>
            <if test="teamBackgroundNote != null">#{teamBackgroundNote},</if>
            <if test="teamHeart != null">#{teamHeart},</if>
            <if test="teamHeartNote != null">#{teamHeartNote},</if>
            <if test="teamFaith != null">#{teamFaith},</if>
            <if test="teamFaithNote != null">#{teamFaithNote},</if>
            <if test="productBase != null">#{productBase},</if>
            <if test="productBaseNote != null">#{productBaseNote},</if>
            <if test="productProfit != null">#{productProfit},</if>
            <if test="productProfitNote != null">#{productProfitNote},</if>
            <if test="organInvest != null">#{organInvest},</if>
            <if test="organInvestNote != null">#{organInvestNote},</if>
            <if test="organValuation != null">#{organValuation},</if>
            <if test="organValuationNote != null">#{organValuationNote},</if>
            <if test="valuation != null">#{valuation},</if>
            <if test="valuationNote != null">#{valuationNote},</if>
            <if test="marketSpace != null">#{marketSpace},</if>
            <if test="marketSpaceNote != null">#{marketSpaceNote},</if>
            <if test="developSpace != null">#{developSpace},</if>
            <if test="developSpaceNote != null">#{developSpaceNote},</if>
            <if test="quitWay != null">#{quitWay},</if>
            <if test="quitWayNote != null">#{quitWayNote},</if>
            <if test="illustrate != null">#{illustrate},</if>
            <if test="examine != null">#{examine},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateTProjectScoring" parameterType="TProjectScoring">
        update t_project_scoring
        <trim prefix="SET" suffixOverrides=",">
            <if test="projectPoolId != null">project_pool_id = #{projectPoolId},</if>
            <if test="investCommissioner != null">invest_commissioner = #{investCommissioner},</if>
            <if test="meetingId != null">meeting_id = #{meetingId},</if>
            <if test="scoringPerson != null">scoring_person = #{scoringPerson},</if>
            <if test="type != null">type = #{type},</if>
            <if test="industryAdvantage != null">industry_advantage = #{industryAdvantage},</if>
            <if test="industryAdvantageNote != null">industry_advantage_note = #{industryAdvantageNote},</if>
            <if test="businessModel != null">business_model = #{businessModel},</if>
            <if test="businessModelNote != null">business_model_note = #{businessModelNote},</if>
            <if test="teamExperience != null">team_experience = #{teamExperience},</if>
            <if test="teamExperienceNote != null">team_experience_note = #{teamExperienceNote},</if>
            <if test="teamBackground != null">team_background = #{teamBackground},</if>
            <if test="teamBackgroundNote != null">team_background_note = #{teamBackgroundNote},</if>
            <if test="teamHeart != null">team_heart = #{teamHeart},</if>
            <if test="teamHeartNote != null">team_heart_note = #{teamHeartNote},</if>
            <if test="teamFaith != null">team_faith = #{teamFaith},</if>
            <if test="teamFaithNote != null">team_faith_note = #{teamFaithNote},</if>
            <if test="productBase != null">product_base = #{productBase},</if>
            <if test="productBaseNote != null">product_base_note = #{productBaseNote},</if>
            <if test="productProfit != null">product_profit = #{productProfit},</if>
            <if test="productProfitNote != null">product_profit_note = #{productProfitNote},</if>
            <if test="organInvest != null">organ_invest = #{organInvest},</if>
            <if test="organInvestNote != null">organ_invest_note = #{organInvestNote},</if>
            <if test="organValuation != null">organ_valuation = #{organValuation},</if>
            <if test="organValuationNote != null">organ_valuation_note = #{organValuationNote},</if>
            <if test="valuation != null">valuation = #{valuation},</if>
            <if test="valuationNote != null">valuation_note = #{valuationNote},</if>
            <if test="marketSpace != null">market_space = #{marketSpace},</if>
            <if test="marketSpaceNote != null">market_space_note = #{marketSpaceNote},</if>
            <if test="developSpace != null">develop_space = #{developSpace},</if>
            <if test="developSpaceNote != null">develop_space_note = #{developSpaceNote},</if>
            <if test="quitWay != null">quit_way = #{quitWay},</if>
            <if test="quitWayNote != null">quit_way_note = #{quitWayNote},</if>
            <if test="illustrate != null">illustrate = #{illustrate},</if>
            <if test="examine != null">examine = #{examine},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTProjectScoringById" parameterType="String">
        delete from t_project_scoring where id = #{id}
    </delete>

    <delete id="deleteTProjectScoringByIds" parameterType="String">
        delete from t_project_scoring where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <update id="updateTProjectScoringByIds" parameterType="String">
        update t_project_scoring
        set del_flag = 1
        where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>

    <select id="selectMeetingId" parameterType="String" resultMap="TProjectScoringResultToMap">
        <include refid="selectMeetingIdVo"/>
        where meeting_id = #{meetingId}
    </select>

    <select id="getCanScoringMeetingId" parameterType="TProjectScoring" resultMap="TProjectScoringResult">
        <include refid="selectTProjectScoringVo"/>
        where meeting_id = #{meetingId} and scoring_person = #{userId}
    </select>


</mapper>