using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using NPP.SmartSchedue.Api.Contracts.Services.Integration.Input;
using NPP.SmartSchedue.Api.Contracts.Services.Integration.Output;

namespace NPP.SmartSchedue.Api.Contracts.Services.Integration
{
    /// <summary>
    /// 整合记录服务接口
    /// </summary>
    public interface IIntegrationRecordService
    {
        /// <summary>
        /// 生成整合记录
        /// </summary>
        Task<IntegrationRecord> GenerateIntegrationRecordAsync(IntegrationRecordInput input);

        /// <summary>
        /// 根据记录ID查询整合记录信息并附加任务集
        /// </summary>
        /// <param name="recordId">整合记录ID</param>
        /// <returns>包含任务集的整合记录信息</returns>
        Task<IntegrationRecordWithTasksOutput> GetIntegrationRecordWithTasksAsync(long recordId);

        /// <summary>
        /// 查询所有整合记录列表
        /// </summary>
        /// <param name="input">查询条件</param>
        /// <returns>整合记录列表</returns>
        Task<List<IntegrationRecordListOutput>> GetIntegrationRecordsAsync(IntegrationRecordGetListInput input);

        #region 发布管理接口

        /// <summary>
        /// 发布整合记录
        /// 将草稿状态的整合记录发布生效，更新任务分配状态
        /// </summary>
        /// <param name="input">发布输入参数</param>
        /// <returns>发布结果</returns>
        Task<PublishIntegrationRecordResult> PublishIntegrationRecordAsync(PublishIntegrationRecordInput input);

        /// <summary>
        /// 更新整合记录状态
        /// 支持状态转换：草稿->已发布->已完成->已撤销
        /// </summary>
        /// <param name="recordId">整合记录ID</param>
        /// <param name="newStatus">新状态</param>
        /// <param name="operatorUserId">操作员用户ID</param>
        /// <param name="operatorName">操作员姓名</param>
        /// <param name="remarks">状态更新说明</param>
        /// <returns>更新结果</returns>
        Task<bool> UpdateIntegrationRecordStatusAsync(long recordId, string newStatus, long operatorUserId, string operatorName, string remarks = "");

        /// <summary>
        /// 发布修改后的任务
        /// 将任务的修改内容发布到生产系统
        /// </summary>
        /// <param name="recordId">整合记录ID</param>
        /// <param name="modifiedTaskIds">修改的任务ID列表</param>
        /// <param name="operatorUserId">操作员用户ID</param>
        /// <param name="operatorName">操作员姓名</param>
        /// <param name="publishRemarks">发布说明</param>
        /// <returns>发布结果</returns>
        Task<PublishIntegrationRecordResult> PublishTaskModificationsAsync(long recordId, List<long> modifiedTaskIds, long operatorUserId, string operatorName, string publishRemarks = "");

        #endregion

        #region 任务修改接口

        /// <summary>
        /// 修改整合记录中的任务分配
        /// 根据选中的人员修改任务的指定人员ID和姓名，并更新整合记录
        /// </summary>
        /// <param name="input">任务修改输入参数</param>
        /// <returns>修改结果</returns>
        Task<bool> ModifyIntegrationRecordTaskAsync(IntegrationRecordTaskModifyInput input);

        #endregion

        #region 通知管理接口（预留）

        /// <summary>
        /// 发送发布通知（预留接口）
        /// 向相关人员发送整合记录发布的通知信息
        /// </summary>
        /// <param name="recordId">整合记录ID</param>
        /// <param name="notificationType">通知类型</param>
        /// <param name="targetPersonnelIds">目标人员ID列表</param>
        /// <param name="customMessage">自定义消息</param>
        /// <returns>通知发送结果</returns>
        Task<IntegrationNotificationResult> SendPublishNotificationAsync(long recordId, string notificationType, List<long> targetPersonnelIds, string customMessage = "");

        /// <summary>
        /// 创建待办任务（预留接口）
        /// 为相关人员创建与发布记录相关的待办任务
        /// </summary>
        /// <param name="recordId">整合记录ID</param>
        /// <param name="todoType">待办类型</param>
        /// <param name="assigneeIds">负责人ID列表</param>
        /// <param name="title">待办标题</param>
        /// <param name="description">待办描述</param>
        /// <param name="dueDate">截止时间</param>
        /// <returns>创建结果</returns>
        Task<CreateTodoResult> CreatePublishRelatedTodoAsync(long recordId, string todoType, List<long> assigneeIds, string title, string description, DateTime? dueDate = null);

        #endregion
    }
}