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.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hdkj.lt.bf.entity.vo.FhzgFaultOppositeLineCarryCapacityVO;
import com.hdkj.lt.core.bizms.modle.po.fault.FaultOppositeLineCarryCapacity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 故障停电对侧线路承载能力信息表 Mapper 接口
 * </p>
 *
 * @author luorui
 * @since 2025-05-29
 */
@Mapper
public interface FaultOppositeLineCarryCapacityMapper extends BaseMapper<FaultOppositeLineCarryCapacity> {
    @Select("select olcc.id, olcc.fault_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_fault_opposite_line_carry_capacity olcc left join fhzg_fault_transfer_scheme pts on olcc.fault_id = pts.fault_id\n" +
            "left join fhzg_fault_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_fault_opposite_line_concat_switch lcs on lcs.capacity_id = ollf.id ${ew.customSqlSegment} " +
            "GROUP BY olcc.id,olcc.fault_id,olcc.rated_capacity,olcc.rated_current,olcc.max_load_factor,olcc.deliverable_capacity,olcc.line_id,olcc.line_name")
    List<FhzgFaultOppositeLineCarryCapacityVO> selectOppositeLineCarryCapacityList(Page<FhzgFaultOppositeLineCarryCapacityVO> page,@Param(Constants.WRAPPER) QueryWrapper<Object> wrapper);
}
