<?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.FhzgPlanTransferSchemeStrategyScoreMapper">

    <select id="getTransferSchemeStrategyScoreByPlanId"
            resultType="com.hdkj.lt.bf.entity.dto.FhzgPlanTransferSchemeStrategyScoreDTO">
        SELECT
            sss.id id,
            ts.scheme_name schemeName,
            ts.scheme_state schemeState,
            ts.evaluation_score evaluationScore,
            sss.scheme_id schemeId,
            sss.strategy_id strategyId,
            sss.evaluation_index_id evaluationIndexId,
            sss.loss_users lossUsers,
            sss.transfer_load_ratio transferLoadRatio,
            sss.non_auto_switch_operation_times nonAutoSwitchOperationTimes,
            sss.opposite_line_max_load_rate oppositeLineMaxLoadRate,
            sss.distribution_transformer_voltage distributionTransformerVoltage,
            sss.switch_operation_times switchOperationTimes,
            sss.loss_power_secured_users lossPowerSecuredUsers
        FROM
            fhzg_plan_transfer_scheme ts
                LEFT JOIN fhzg_plan_transfer_scheme_strategy_score sss ON ts.id = sss.scheme_id
        WHERE
            ts.plan_id = #{planId}
    </select>

    <insert id="batchInsert">
        insert into fhzg_plan_transfer_scheme_strategy_score
        (scheme_id,strategy_id,evaluation_index_id,loss_users,transfer_load_ratio,
        non_auto_switch_operation_times,opposite_line_max_load_rate,distribution_transformer_voltage,
        switch_operation_times)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{schemeId},#{item.strategyId},#{item.evaluationIndexId},#{item.lossUsers},#{item.transferLoadRatio},
            #{item.nonAutoSwitchOperationTimes},#{item.oppositeLineMaxLoadRate},#{item.distributionTransformerVoltage},
            #{item.switchOperationTimes})
        </foreach>
    </insert>
</mapper>
