<?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.hdkj.lt.bf.mapper.FhzgPlanTransferSchemeEvaluationIndexMapper">

    <select id="getTransferSchemeEvaluationIndexByPlanId"
            resultType="com.hdkj.lt.core.bizms.modle.dto.FhzgPlanTransferSchemeEvaluationIndexDTO">

        select
            sei.id id,
            sei.scheme_id schemeId,
            ts.scheme_name schemeName,
            ts.scheme_state schemeState,
            ts.evaluation_score evaluationScore,
            sei.transfer_load_ratio  transferLoadRatio,
            sei.opposite_line_max_load_rate  oppositeLineMaxLoadRate,
            sei.switch_operation_times  switchOperationTimes,
            sei.loss_users  lossUsers,
            sei.non_auto_switch_operation_times  nonAutoSwitchOperationTimes,
            sei.distribution_transformer_voltage  distributionTransformerVoltage,
            sei.to_be_transfer_load  toBeTransferLoad,
            sei.carried_load  carriedLoad,
            sei.auto_switch_operation_times  autoSwitchOperationTimes,
            sei.total_to_be_transfer_users  totalToBeTransferUsers,
            sei.loss_important_users  lossImportantUsers,
            sei.loss_sensitive_users  lossSensitiveUsers
        from
            fhzg_plan_transfer_scheme ts left join
            fhzg_plan_transfer_scheme_evaluation_index sei on ts.id = sei.scheme_id
        where ts.plan_id = #{planId}
        order by ts.scheme_state asc,ts.evaluation_score desc


    </select>

    <insert id="batchInsert">
        insert into fhzg_plan_transfer_scheme_evaluation_index
        (scheme_id,transfer_load_ratio,opposite_line_max_load_rate,switch_operation_times
        ,loss_users,non_auto_switch_operation_times,distribution_transformer_voltage,
        to_be_transfer_load,carried_load,auto_switch_operation_times,total_to_be_transfer_users,
        loss_important_users,loss_sensitive_users)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{schemeId},#{transferLoadRatio},#{oppositeLineMaxLoadRate},#{switchOperationTimes},
            #{lossUsers},#{nonAutoSwitchOperationTimes},#{distributionTransformerVoltage},#{toBeTransferLoad},
            #{carriedLoad},#{autoSwitchOperationTimes},#{totalToBeTransferUsers},#{lossImportantUsers},
            #{lossSensitiveUsers})
        </foreach>
    </insert>


</mapper>
