using Masuit.Tools.Models;
using Masuit.Tools;
using PVDEMCS.Common.Constant;
using PVDEMCS.Common;
using PVDEMCS.Common.DI;
using PVDEMCS.Services.Models;
using PVDEMCS.Services.Repositories.Entities;
using Microsoft.EntityFrameworkCore;

namespace PVDEMCS.Services.Repositories
{
    /// <summary>
    /// 设备数据记录与统计 数据层 接口
    /// </summary>
    public interface IEquipmentRecordRepository : IDependency
    {
        #region 设备状态记录

        /// <summary>
        /// 获取设备状态记录分页列表
        /// </summary>
        /// <param name="equipmentId">设备Id</param>
        /// <param name="equipmentName">设备名称</param>
        /// <param name="equipmentCode">设备编号</param>
        /// <param name="equipmentType">设备类型</param>
        /// <param name="begTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <param name="page">当前页</param>
        /// <param name="size">页大小</param>
        /// <returns></returns>
        Result<PagedList<EquipmentRecord>> GetEquipmentRecordPageList(string equipmentId, string equipmentName, string equipmentCode, string equipmentType, DateTime? begTime, DateTime? endTime, int page, int size);

        /// <summary>
        /// 获取设备状态记录列表
        /// </summary>
        /// <param name="equipmentId">设备Id</param>
        /// <param name="equipmentName">设备名称</param>
        /// <param name="equipmentCode">设备编号</param>
        /// <param name="equipmentType">设备类型</param>
        /// <param name="begTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <returns></returns>
        Result<List<EquipmentRecord>> GetEquipmentRecordList(string equipmentId, string equipmentName, string equipmentCode, string equipmentType, DateTime? begTime, DateTime? endTime);

        /// <summary>
        /// 添加或更新设备状态记录
        /// 1.如果设备最新记录状态没有改变则更新结束时间
        /// 2.如果没有记录则添加记录
        /// </summary>
        /// <param name="equipmentId">设备Id</param>
        /// <param name="state">设备状态，运行:Run，待机:Stop，报警:Alarm</param>
        /// <param name="dateTime">记录时间</param>
        /// <returns></returns>
        Result AddUpdateEquipmentRecord(string equipmentId, string state, DateTime dateTime);

        /// <summary>
        /// 批量添加或更新设备状态记录
        /// 1.如果设备最新记录状态没有改变则更新结束时间
        /// 2.如果没有记录则添加记录
        /// </summary>
        /// <returns></returns>
        Result AddUpdateEquipmentRecordBatch(List<EquipmentRecordUpdateModel> items);

        /// <summary>
        /// 进行设备状态记录统计（日统计）
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        Result RunEquipmentRecordDayTotal(DateTime date);

        /// <summary>
        /// 进行设备状态记录统计
        /// </summary>
        /// <returns></returns>
        Result RunEquipmentRecordTotal();

        #endregion

        #region 设备记录统计

        /// <summary>
        /// 获取设备状态记录日统计分页列表
        /// </summary>
        /// <param name="equipmentName">设备名称</param>
        /// <param name="equipmentCode">设备编号</param>
        /// <param name="equipmentType">设备类型</param>
        /// <param name="begTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <param name="page">当前页</param>
        /// <param name="size">页大小</param>
        Result<PagedList<EquipmentRecordDayTotal>> GetEquipmentRecordDayTotalPageList(string equipmentName, string equipmentCode, string equipmentType, DateTime? begTime, DateTime? endTime, int page, int size);

        /// <summary>
        /// 获取设备状态记录日统计列表
        /// </summary>
        /// <param name="equipmentName">设备名称</param>
        /// <param name="equipmentCode">设备编号</param>
        /// <param name="equipmentType">设备类型</param>
        /// <param name="begTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        Result<List<EquipmentRecordDayTotal>> GetEquipmentRecordDayTotalList(string equipmentName, string equipmentCode, string equipmentType, DateTime? begTime, DateTime? endTime);

        /// <summary>
        /// 获取设备状态记录统计分页列表
        /// </summary>
        /// <param name="equipmentName">设备名称</param>
        /// <param name="equipmentCode">设备编号</param>
        /// <param name="equipmentType">设备类型</param>
        /// <param name="begTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <param name="page">当前页</param>
        /// <param name="size">页大小</param>
        Result<PagedList<EquipmentRecordTotal>> GetEquipmentRecordTotalPageList(string equipmentName, string equipmentCode, string equipmentType, DateTime? begTime, DateTime? endTime, int page, int size);

        /// <summary>
        /// 获取设备状态记录统计列表
        /// </summary>
        /// <param name="equipmentName">设备名称</param>
        /// <param name="equipmentCode">设备编号</param>
        /// <param name="equipmentType">设备类型</param>
        /// <param name="begTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        Result<List<EquipmentRecordTotal>> GetEquipmentRecordTotalList(string equipmentName, string equipmentCode, string equipmentType, DateTime? begTime, DateTime? endTime);

        /// <summary>
        /// 根据设备Id获取记录统计
        /// </summary>
        /// <param name="equipmentId">设备Id</param>
        /// <returns></returns>
        Result<EquipmentRecordTotalEntity> GetEquipmentRecordTotalDetail(string equipmentId);

        /// <summary>
        /// 获取设备状态记录月统计
        /// </summary>
        /// <returns></returns>
        Result<List<EquipmentRecordStateMonthTotal>> GetEquipmentRecordStateMonthTotal();

        /// <summary>
        /// 获取设备记录开炉次数月统计
        /// </summary>
        /// <returns></returns>
        Result<List<EquipmentRecordFurnaceMonthTotal>> GetEquipmentRecordFurnaceMonthTotal();

        /// <summary>
        /// 获取设备记录OEE月统计
        /// </summary>
        /// <returns></returns>
        Result<List<EquipmentOEEMonthTotal>> GetEquipmentRecordOEEMonthTotal();

        /// <summary>
        /// 获取设备OEE信息
        /// </summary>
        /// <param name="equipmentId">设备Id</param>
        /// <param name="begDate">开始时间</param>
        /// <param name="endDate">结束时间</param>
        /// <returns></returns>
        Result<EquipmentOEETotal> GetEquipmentOEEMonthTotal(string equipmentId, DateTime begDate, DateTime endDate);

        #endregion
    }
}

