using JiShe.CollectBus.IotSystems.MeterReadingRecords;
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;

namespace JiShe.CollectBus.Repository.MeterReadingRecord
{
    /// <summary>
    /// 抄读仓储接口
    /// </summary>
    public interface IMeterReadingRecordRepository : IRepository<MeterReadingRecords, Guid>
    {
        /// <summary>
        /// 批量插入
        /// </summary>
        /// <param name="entities"></param>
        /// <param name="dateTime"></param>
        /// <returns></returns>
        Task InsertManyAsync(List<MeterReadingRecords> entities,
            DateTime? dateTime);

        /// <summary>
        /// 单个插入
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="dateTime"></param>
        /// <returns></returns>
        Task<MeterReadingRecords> InsertAsync(MeterReadingRecords entity, DateTime? dateTime);

        /// <summary>
        /// 单条更新
        /// </summary>
        /// <param name="filter">过滤条件，示例：Builders<MeterReadingRecords>.Filter.Eq(x => x.Id, filter.Id)</param>
        /// <param name="update">包含待更新的内容，示例：Builders<MeterReadingRecords>.Update.Set(x => x.Processed, true).Set(x => x.ProcessedTime, Clock.Now)</param>
        /// <param name="entity">数据实体，用于获取对应的分片库</param>
        /// <returns></returns>
        Task<MeterReadingRecords> UpdateOneAsync(FilterDefinition<MeterReadingRecords> filter, UpdateDefinition<MeterReadingRecords> update, MeterReadingRecords entity);

        /// <summary>
        /// 单个获取
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="dateTime"></param>
        /// <returns></returns>
        Task<MeterReadingRecords> FirOrDefaultAsync(MeterReadingRecords entity, DateTime? dateTime);

        /// <summary>
        /// 多集合数据查询
        /// </summary>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        Task<List<MeterReadingRecords>> ParallelQueryAsync(DateTime startTime, DateTime endTime);
    }
}
