package com.xzzn.ems.mapper;

import com.xzzn.ems.domain.EmsPointMatch;
import com.xzzn.ems.domain.vo.DevicePointMatchExportVo;
import com.xzzn.ems.domain.vo.DeviceUpdateRequest;
import com.xzzn.ems.domain.vo.GeneralQueryDataVo;
import com.xzzn.ems.domain.vo.PointQueryResponse;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

/**
 * 点位匹配Mapper接口
 *
 * @author xzzn
 * @date 2025-09-02
 */
public interface EmsPointMatchMapper
{
    /**
     * 查询点位匹配
     *
     * @param id 点位匹配主键
     * @return 点位匹配
     */
    public EmsPointMatch selectEmsPointMatchById(Long id);

    /**
     * 查询点位匹配列表
     *
     * @param emsPointMatch 点位匹配
     * @return 点位匹配集合
     */
    public List<EmsPointMatch> selectEmsPointMatchList(EmsPointMatch emsPointMatch);

    /**
     * 新增点位匹配
     *
     * @param emsPointMatch 点位匹配
     * @return 结果
     */
    public int insertEmsPointMatch(EmsPointMatch emsPointMatch);

    /**
     * 修改点位匹配
     *
     * @param emsPointMatch 点位匹配
     * @return 结果
     */
    public int updateEmsPointMatch(EmsPointMatch emsPointMatch);

    /**
     * 删除点位匹配
     *
     * @param id 点位匹配主键
     * @return 结果
     */
    public int deleteEmsPointMatchById(Long id);

    /**
     * 批量删除点位匹配
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteEmsPointMatchByIds(Long[] ids);

    // 模糊查询所有点位
    public List<String> getPointNameList(@Param("siteIds") List<String> siteIds,
                                         @Param("deviceCategory")String deviceCategory,
                                         @Param("pointName") String pointName);

    // 获取匹配信息
    public List<EmsPointMatch> getMatchInfo(@Param("siteIds") List<String> siteIds,
                                            @Param("deviceId") String deviceId,
                                            @Param("deviceCategory") String deviceCategory,
                                            @Param("pointName") String pointName);
    // 根据条件查询数据-按分钟-单体电池特殊处理
    public List<GeneralQueryDataVo> getBatteryPointDataByMinutes(@Param("siteIds")List<String> siteIds,
                                                              @Param("tableName")String tableName,
                                                              @Param("tableField")String tableField,
                                                              @Param("startDate")Date startDate,
                                                              @Param("endDate")Date endDate,
                                                              @Param("params") Map<String, List<String>> params,
                                                              @Param("clusterDeviceId")String clusterDeviceId);
    // 根据条件查询数据-按小时-单体电池特殊处理
    public List<GeneralQueryDataVo> getBatteryPointDataByHours(@Param("siteIds")List<String> siteIds,
                                                            @Param("tableName")String tableName,
                                                            @Param("tableField")String tableField,
                                                            @Param("startDate") Date startDate,
                                                            @Param("endDate")Date endDate,
                                                            @Param("params") Map<String, List<String>> params,
                                                            @Param("clusterDeviceId")String clusterDeviceId);
    // 根据条件查询数据-按天-单体电池特殊处理
    public List<GeneralQueryDataVo> getBatteryPointDataByDays(@Param("siteIds")List<String> siteIds,
                                                           @Param("tableName")String tableName,
                                                           @Param("tableField")String tableField,
                                                           @Param("startDate")Date startDate,
                                                           @Param("endDate")Date endDate,
                                                           @Param("params") Map<String, List<String>> params,
                                                           @Param("clusterDeviceId")String clusterDeviceId);

    // 根据条件查询箱线图数据-按天-单体电池特殊处理
    public List<GeneralQueryDataVo> getBatteryPointDataForBoxPlot(@Param("siteIds")List<String> siteIds,
                                                              @Param("tableName")String tableName,
                                                              @Param("tableField")String tableField,
                                                              @Param("startDate")Date startDate,
                                                              @Param("endDate")Date endDate,
                                                              @Param("params") Map<String, List<String>> params,
                                                              @Param("clusterDeviceId")String clusterDeviceId);

    // 根据条件查询数据-按分钟-其他设备
    public List<GeneralQueryDataVo> getCommonPointDataByMinutes(@Param("siteIds")List<String> siteIds,
                                                                 @Param("tableName")String tableName,
                                                                 @Param("tableField")String tableField,
                                                                 @Param("startDate")Date startDate,
                                                                 @Param("endDate")Date endDate,
                                                                 @Param("deviceId")String deviceId);
    // 根据条件查询数据-按小时-其他设备
    public List<GeneralQueryDataVo> getCommonPointDataByHours(@Param("siteIds")List<String> siteIds,
                                                               @Param("tableName")String tableName,
                                                               @Param("tableField")String tableField,
                                                               @Param("startDate") Date startDate,
                                                               @Param("endDate")Date endDate,
                                                               @Param("deviceId")String deviceId);
    // 根据条件查询数据-按天-其他设备
    public List<GeneralQueryDataVo> getCommonPointDataByDays(@Param("siteIds")List<String> siteIds,
                                                              @Param("tableName")String tableName,
                                                              @Param("tableField")String tableField,
                                                              @Param("startDate")Date startDate,
                                                              @Param("endDate")Date endDate,
                                                              @Param("deviceId")String deviceId);
    // 根据条件查询箱线图数据-按天-其他设备
    public List<GeneralQueryDataVo> getCommonPointDataForBoxPlot(@Param("siteIds")List<String> siteIds,
                                                             @Param("tableName")String tableName,
                                                             @Param("tableField")String tableField,
                                                             @Param("startDate")Date startDate,
                                                             @Param("endDate")Date endDate,
                                                             @Param("deviceId")String deviceId);

    // 单个站点单个设备点位查询-除了电池簇其他设备使用
    public List<PointQueryResponse> getSingleSiteDevicePoints(@Param("siteId")String siteId,
                                                              @Param("deviceId")String deviceId,
                                                              @Param("deviceCategory")String deviceCategory,
                                                              @Param("pointName")String pointName,
                                                              @Param("dataPoint")String dataPoint,
                                                              @Param("ipAddress")String ipAddress,
                                                              @Param("ipPort")Integer ipPort,
                                                              @Param("isAlarm")Integer isAlarm);
    // 单个站点单个设备点位查询-电池簇使用
    public List<PointQueryResponse> getClusterDevicePoints(@Param("siteId")String siteId,
                                                           @Param("deviceId")String deviceId,
                                                           @Param("parentDeviceId")String parentDeviceId,
                                                           @Param("deviceCategory")String deviceCategory,
                                                           @Param("pointName")String pointName,
                                                           @Param("dataPoint")String dataPoint,
                                                           @Param("ipAddress")String ipAddress,
                                                           @Param("ipPort")Integer ipPort,
                                                           @Param("isAlarm")Integer isAlarm);

    // 根据站点，设备类别，点位，获取唯一数据
    public EmsPointMatch getUniquePoint(@Param("siteId")String siteId, @Param("deviceCategory")String deviceCategory, @Param("dataPoint")String dataPoint);

    EmsPointMatch getOnePointMatch(@Param("siteId") String siteId, @Param("deviceId") String deviceId, @Param("deviceCategory") String deviceCategory, @Param("dataPoint") String dataPoint);

    List<EmsPointMatch> getDevicePointMatchList(@Param("siteId") String siteId, @Param("deviceId") String deviceId, @Param("deviceCategory") String deviceCategory);

    List<DevicePointMatchExportVo> selectEmsPointMatchExportList(EmsPointMatch emsPointMatch);

    int getDevicePointAlarmNum(@Param("siteId") String siteId, @Param("deviceId") String deviceId, @Param("deviceCategory") String deviceCategory);

    List<EmsPointMatch> selectDeviceStatusPoint(@Param("request") DeviceUpdateRequest request);

    int countBySiteId(@Param("siteId") String siteId);

    int deleteBySiteId(@Param("siteId") String siteId);

    int copyTemplateToSite(@Param("templateSiteId") String templateSiteId,
                           @Param("targetSiteId") String targetSiteId,
                           @Param("operName") String operName);

    List<EmsPointMatch> selectBySiteId(@Param("siteId") String siteId);
}
