package com.hdkj.lt.bf.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.FhzgPlanPowerCut;
import com.hdkj.lt.bf.entity.vo.FhzgPlanPowerCutVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 计划停电转供方案信息表 Mapper接口
 *
 * @author zhousc
 * @since 2025-05-07
 */
@Mapper
public interface FhzgPlanPowerCutMapper extends BaseMapper<FhzgPlanPowerCut> {

    @Select("select id,plan_no,plan_start_time,plan_end_time,plan_source," +
            "line_id,line_name,line_content,work_content,strategy_id,feeder_name," +
            "city_code,city_name,plan_state,scheme_state,power_on_success,creator," +
            "create_time,last_editor,last_time,is_delete,valid_flag,is_newest,county_code,county_name from fhzg_plan_power_cut ${ew.customSqlSegment}")
    List<FhzgPlanPowerCutVO> selectSchemeList(Page<FhzgPlanPowerCutVO> page, @Param(Constants.WRAPPER) LambdaQueryWrapper<FhzgPlanPowerCutVO> wrapper);

    @Select("select id,plan_no,plan_start_time,plan_end_time,plan_source," +
            " line_id,line_name,line_content,work_content,strategy_id,feeder_name," +
            " city_code,city_name,plan_state,scheme_state,power_on_success,creator," +
            " create_time,last_editor,last_time,is_delete,valid_flag,is_newest,county_code,county_name from fhzg_plan_power_cut where id=#{planId}  ")
    FhzgPlanPowerCutVO getSchemeByPlanId(@Param("planId")Long planId);


    @Update("update fhzg_plan_power_cut t set t.scheme_state=#{obj.schemeState} where t.id = #{obj.id}")
    Integer updateSchemeState(@Param("obj") FhzgPlanPowerCut obj);


    List<FhzgPlanPowerCut> queryHistListBatch(@Param("planNoList") List<String> planNoList);

    LocalDateTime getPlanCreateTimeByPlanId(@Param("id") Long id);
}
