using System.Collections.Generic;
using CncModels.Entity;
using CncModels.Dto;
using CncModels.Dto.Machine;

namespace CncRepository.Interface
{
    /// <summary>
    /// 机床仓储接口
    /// </summary>
    public interface IMachineRepository
    {
        Machine GetById(int id);
        MachineDetailResponse GetDetailById(int id);
        PagedResult<MachineListItem> GetList(MachineQuery query);
        int Create(Machine entity);
        bool Update(Machine entity);
        bool Delete(int id);
        int BatchDelete(List<int> ids);
        bool ToggleEnabled(int id);
        Machine GetByDeviceCode(string deviceCode);
        List<Machine> GetEnabledByAddressId(int collectAddressId);
        List<Machine> GetEnabledOnline();
        void UpdateLastCollect(int id, Machine entity);
        /// <summary>设置机床所属的采集地址</summary>
        void SetCollectAddress(int machineId, int? collectAddressId);
        /// <summary>获取机床最新一条采集记录（实时状态）</summary>
        MachineCollectRecordItem GetLatestCollectRecord(int machineId);
        /// <summary>获取机床今日产量按程序名分组</summary>
        List<MachineTodayProdItem> GetTodayProduction(int machineId);
        /// <summary>获取机床近N天产量趋势</summary>
        List<MachineTrendItem> GetProductionTrend(int machineId, int days = 7);
        /// <summary>获取机床最近N条采集记录</summary>
        List<MachineCollectRecordItem> GetRecentCollectRecords(int machineId, int limit = 20);
    }
}
