package com.hdkj.lt.bf.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.hdkj.lt.bf.entity.vo.FhzgOppositeLineCarryCapacityVO;
import com.hdkj.lt.core.bizms.modle.po.plan.FhzgPlanOppositeLineCarryCapacity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 计划停电对侧线路承载能力信息表 Mapper接口
 *
 * @author zhousc
 * @since 2025-05-07
 */
@Mapper
public interface FhzgPlanOppositeLineCarryCapacityMapper extends BaseMapper<FhzgPlanOppositeLineCarryCapacity> {

    @Select("select olcc.id, olcc.plan_id, olcc.rated_capacity, olcc.rated_current, olcc.max_current, olcc.max_load_factor, olcc.deliverable_capacity,\n" +
            "   olcc.line_id, olcc.line_name, GROUP_CONCAT(distinct concat_psr_id) switch_id, GROUP_CONCAT(distinct concat_psr_name) switch_name\n" +
            "from fhzg_plan_opposite_line_carry_capacity olcc left join fhzg_plan_transfer_scheme pts on olcc.plan_id = pts.plan_id\n" +
            "left join fhzg_plan_transfer_scheme_opposite_line_load_factor ollf on ollf.scheme_id=pts.id and ollf.opposite_line_id=olcc.line_id\n" +
            "LEFT JOIN fhzg_plan_opposite_line_concat_switch lcs on lcs.capacity_id = ollf.id ${ew.customSqlSegment} " +
            "GROUP BY olcc.id,olcc.plan_id,olcc.rated_capacity,olcc.rated_current,olcc.max_load_factor,olcc.deliverable_capacity,olcc.line_id,olcc.line_name")
    List<FhzgOppositeLineCarryCapacityVO> selectOppositeLineCarryCapacityList(IPage<FhzgOppositeLineCarryCapacityVO> page, @Param(Constants.WRAPPER) QueryWrapper<Object> wrapper);
}
