using APT.Infrastructure.Core;
using APT.BaseData.Domain.ApiModel.EX;
using APT.BaseData.Domain.Entities.FM;
using APT.BaseData.Domain.Enums;
using System.Collections.Generic;
using APT.Infrastructure.Api;
using System;
using static APT.BaseData.Domain.ApiModel.SocketInfo;
using APT.BaseData.Domain.Entities;

namespace APT.BaseData.Domain.IServices.FM
{
    public interface IFMNotificationTaskService : ICommonService
    {
        /// <summary>
        /// 1.按照多用户生成通知消息
        /// </summary>
        /// <param name="name">消息标题</param>
        /// <param name="dataId">数据的ID</param>
        /// <param name="orgId">组织ID</param>
        /// <param name="userIds">用户ID集合</param>
        /// <param name="startTime">通知开始时间</param>
        /// <param name="endTime">通知结束时间</param>
        /// <param name="noticeType">通知类型</param>
        /// <param name="formCode">表单编码</param>
        /// <param name="action">执行方法</param>
        /// <returns></returns>
        bool SendNotificationTask(string name, Guid dataId, Guid? orgId, List<Guid> userIds, DateTime startTime,
            DateTime endTime, int noticeType, string formCode, Action action);

        bool SendNotificationTask(List<string> names, List<Guid> dataIds, Guid? orgId, List<Guid> userIds, List<string> userNames, DateTime startTime, List<DateTime> listEndTime, int noticeType, string formCode, Action action);
        bool SendNotificationTask(List<string> names, List<Guid> dataIds, Guid? orgId, List<Guid> userIds, List<string> userNames, List<DateTime> listStartTime, List<DateTime> listEndTime, int noticeType, string formCode, Action action);
        /// <summary>
        /// 2.按照单用户生成通知消息
        /// </summary>
        /// <param name="name">消息标题</param>
        /// <param name="dataId">数据的ID</param>
        /// <param name="orgId">组织ID</param>
        /// <param name="userId">用户ID集合</param>
        /// <param name="startTime">通知开始时间</param>
        /// <param name="endTime">通知结束时间</param>
        /// <param name="noticeType">通知类型</param>
        /// <param name="formCode">表单编码</param>
        /// <param name="action">执行方法</param>
        /// <returns></returns>
        bool SendNotificationTask(string name, Guid dataId, Guid? orgId, Guid userId, DateTime startTime,
            DateTime endTime, int noticeType, string formCode, Action action);
        /// <summary>
        /// 3.按照用户生成通知消息(wjn)
        /// </summary>
        /// <param name="names">消息标题集合</param>
        /// <param name="dataIds">数据的ID</param>
        /// <param name="orgId">组织ID</param>
        /// <param name="userIds">用户ID集合</param>
        /// <param name="startTime">通知开始时间</param>
        /// <param name="endTime">通知结束时间</param>
        /// <param name="noticeType">通知类型</param>
        /// <param name="formCode">表单编码</param>
        /// <param name="action">执行方法</param>
        /// <returns></returns>
        bool SendNotificationTask(List<string> names, List<Guid> dataIds, Guid? orgId, List<Guid> userIds, List<string>
 userNames, DateTime startTime, DateTime endTime, int noticeType, string formCode, Action action);
        /// <summary>
        /// 4.按照用户生成通知消息(wjn)
        /// </summary>
        /// <param name="name">消息标题集合</param>
        /// <param name="dataId">数据的ID</param>
        /// <param name="orgId">组织ID</param>
        /// <param name="userIds">用户ID集合</param>
        /// <param name="startTime">通知开始时间</param>
        /// <param name="endTime">通知结束时间</param>
        /// <param name="noticeType">通知类型</param>
        /// <param name="formCode">表单编码</param>
        /// <param name="action">执行方法</param>
        /// <returns></returns>
        bool SendNotificationTask(string name, Guid dataId, Guid? orgId, List<Guid> userIds, List<string>
 userNames, DateTime startTime, DateTime endTime, int noticeType, string formCode, Action action, string formCodeDone, Guid? UserIDDone = null);

        /// <summary>
        /// 4.按照用户生成通知消息(wjn)
        /// </summary>
        /// <param name="name">消息标题集合</param>
        /// <param name="dataId">数据的ID</param>
        /// <param name="orgId">组织ID</param>
        /// <param name="userIds">用户ID集合</param>
        /// <param name="startTime">通知开始时间</param>
        /// <param name="endTime">通知结束时间</param>
        /// <param name="noticeType">通知类型</param>
        /// <param name="formCode">表单编码</param>
        /// <param name="action">执行方法</param>
        /// <returns></returns>
        bool SendNotificationTask(string name, Guid dataId, Guid? orgId, List<Guid> userIds, List<string>
 userNames, DateTime startTime, DateTime endTime, int noticeType, string formCode, Action action, string formCodeDone, List<Guid> listUserIDDone);

        /// /// <summary>
        /// 5.按照单用户生成通知消息(wjn)增加用户名
        /// </summary>
        /// <param name="name">消息标题</param>
        /// <param name="dataId">数据的ID</param>
        /// <param name="orgId">组织ID</param>
        /// <param name="userId">用户ID</param>
        /// <param name="userName">用户名</param>
        /// <param name="startTime">通知开始时间</param>
        /// <param name="endTime">通知结束时间</param>
        /// <param name="noticeType">通知类型</param>
        /// <param name="formCode">表单编码</param>
        /// <param name="action">执行方法</param>
        /// <returns></returns>
        bool SendNotificationTask(string name, Guid dataId, Guid? orgId, Guid userId, string userName, DateTime startTime,
            DateTime endTime, int noticeType, string formCode, Action action);
        /// <summary>
        /// 4.按照用户生成通知消息2.修改旧消息的状态(wjn)
        /// </summary>
        /// <param name="name">消息标题</param>
        /// <param name="dataId">数据的ID</param>
        /// <param name="orgId">组织ID</param>
        /// <param name="userIds">用户ID集合</param>
        /// <param name="userNames">用户ID集合</param>
        /// <param name="startTime">通知开始时间</param>
        /// <param name="endTime">通知结束时间</param>
        /// <param name="noticeType">通知类型</param>
        /// <param name="formCode">表单编码</param>
        /// <param name="action">执行方法</param>
        /// <param name="finishTaskId">修改通知为结束状态</param>
        /// <param name="action">执行方法</param>
        /// <returns></returns>
        bool SendAndFinishNotificationTask(string name, Guid dataId, Guid? orgId, List<Guid> userIds, List<string> userNames, DateTime startTime,
          DateTime endTime, int noticeType, string formCode, Guid finishTaskId, Action action, string SOURCE_FORMCODE_Finish = "");
        bool SendAndFinishNotificationTask(List<string> ListName, List<Guid> ListDataId, Guid? orgId, List<Guid> userIds, List<string> userNames, DateTime startTime,
          DateTime endTime, int noticeType, string formCode, Guid? finishTaskId, Action action, string SOURCE_FORMCODE_Finish = "");

        /// <summary>
        /// 5.按照用户生成通知消息2.修改旧消息的状态(wjn)
        /// </summary>
        /// <param name="name">消息标题</param>
        /// <param name="dataId">数据的ID</param>
        /// <param name="orgId">组织ID</param>
        /// <param name="userId">用户ID</param>
        /// <param name="userName">用户名</param>
        /// <param name="startTime">通知开始时间</param>
        /// <param name="endTime">通知结束时间</param>
        /// <param name="noticeType">通知类型</param>
        /// <param name="formCode">表单编码</param>
        /// <param name="action">执行方法</param>
        /// <param name="finishTaskId">修改通知为结束状态</param>
        /// <param name="action">执行方法</param>
        /// <returns></returns>
        bool SendAndFinishNotificationTask(string name, Guid dataId, Guid? orgId, Guid userId, string userName, DateTime startTime,
          DateTime endTime, int noticeType, string formCode, Guid finishTaskId, Action action, string SOURCE_FORMCODE_Finish = "");
        /// <summary>
        /// 6.1按照用户生成通知消息2.修改旧消息的状态(wjn)
        /// </summary>
        /// <param name="names">消息标题集合</param>
        /// <param name="dataIds">数据的ID</param>
        /// <param name="orgId">组织ID</param>
        /// <param name="userIds">用户ID集合</param>
        /// <param name="startTime">通知开始时间</param>
        /// <param name="endTime">通知结束时间</param>
        /// <param name="noticeType">通知类型</param>
        /// <param name="formCode">表单编码</param>
        /// <param name="action">执行方法</param>
        /// <returns></returns>
        bool SendAndFinishNotificationTask(List<string> names, List<Guid> dataIds, Guid? orgId, List<Guid> userIds, List<string>
 userNames, DateTime startTime, DateTime endTime, int noticeType, string formCode, Guid finishTaskId, Action action);
        /// <summary>
        /// 6.2按照用户生成通知消息2.修改旧消息的状态(wjn)
        /// </summary>
        /// <param name="names">消息标题集合</param>
        /// <param name="dataIds">数据的ID</param>
        /// <param name="orgId">组织ID</param>
        /// <param name="userIds">用户ID集合</param>
        /// <param name="startTime">通知开始时间</param>
        /// <param name="endTime">通知结束时间</param>
        /// <param name="noticeType">通知类型</param>
        /// <param name="formCodes">表单编码</param>
        /// <param name="action">执行方法</param>
        /// <param name="Code">编码</param>
        /// <returns></returns>
        bool SendAndFinishNotificationTask(List<string> names, List<Guid> dataIds, Guid? orgId, List<Guid> userIds, List<string>
 userNames, DateTime startTime, DateTime endTime, int noticeType, List<string> formCodes, Guid finishTaskId, Action action);
        /// <summary>
        /// 修改旧消息的状态为已完成
        /// </summary>
        /// <param name="id">消息ID</param>
        /// <param name="action">执行方法</param>
        /// <returns></returns>
        bool NotificationTaskFinish(Guid id, Action action);


        /// <summary>
        /// 通过消息ID修改旧消息的状态为已完成
        /// </summary>
        /// <param name="id">消息ID</param>
        /// <returns></returns>
        T_FM_NOTIFICATION_TASK NotificationTaskFinishModel(Guid id);

        /// <summary>
        /// 修改旧消息的状态为已完成(wyw0513)
        /// </summary>
        /// <param name="id">消息ID</param>
        /// <returns></returns>
        T_FM_NOTIFICATION_TASK GetTaskFinishModel(Guid id, string sourceFormCode = "");
        /// <summary>
        /// FO修改旧消息的状态为已完成(wyw0513)
        /// </summary>
        /// <param name="id">消息ID</param>
        /// <returns></returns>
        T_FM_NOTIFICATION_TASK FOGetTaskFinishModel(Guid id, Guid dataSourceId, string sourceFormCode = "");


        /// <summary>
        /// 发送新消息返回实体
        /// </summary>
        /// <param name="Name"></param>
        /// <param name="DataId"></param>
        /// <param name="OrgId"></param>
        /// <param name="UserId"></param>
        /// <param name="userName"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <param name="noticeType">FMNoticeTypeEnum 0消息 1审批 2今日提醒</param>
        /// <param name="formCode"></param>
        /// <returns></returns>
        T_FM_NOTIFICATION_TASK InsertUserNoticeTaskModel(string Name, Guid DataId, Guid? OrgId, Guid UserId, string userName,
  DateTime startTime, DateTime endTime, int noticeType, string formCode);
        /// <summary>
        /// 发送新消息返回实体集合
        /// </summary>
        /// <param name="id">消息ID</param>
        /// <returns></returns>
        List<T_FM_NOTIFICATION_TASK> InsertUserNoticeTaskModels(string Name, Guid? DataId, Guid? OrgId, List<Guid> UserId, List<string> userName,
  DateTime startTime, DateTime endTime, int noticeType, string formCode, Guid? AutoDoneID = null);
        /// <summary>
        /// 发送新消息集合返回实体集合
        /// </summary>
        /// <param name="id">消息ID</param>
        /// <returns></returns>
        List<T_FM_NOTIFICATION_TASK> InsertUserNoticeTaskModels(List<string> Name, List<Guid> DataId, Guid? OrgId, List<Guid> UserId, List<string> userName,
  DateTime startTime, DateTime endTime, int noticeType, string formCode);
        /// <summary>
        /// 发送新消息集合返回实体集合
        /// </summary>
        /// <param name="id">消息ID</param>
        /// <returns></returns>
        List<T_FM_NOTIFICATION_TASK> InsertUserNoticeTaskModels(List<string> Name, List<Guid> DataId, Guid? OrgId, List<Guid> UserId, List<string> userName,
  DateTime startTime, DateTime endTime, int noticeType, List<string> formCode);
        /// <summary>
        /// 发送新消息集合返回实体集合
        /// </summary>
        /// <param name="id">消息ID</param>
        /// <returns></returns>
        List<T_FM_NOTIFICATION_TASK> InsertUserNoticeTaskModels(List<string> Name, List<Guid> DataId, Guid? OrgId, List<Guid> UserId, List<string> userName,
  DateTime startTime, List<DateTime> endTime, int noticeType, List<string> formCode);
        /// <summary>
        /// 发送新消息集合返回实体集合
        /// </summary>
        /// <param name="id">消息ID</param>
        /// <returns></returns>
        List<T_FM_NOTIFICATION_TASK> InsertUserNoticeTaskModels(string[] codeList, List<string> Name, List<Guid> DataId, Guid? OrgId, List<Guid> UserId, List<string> userName,
  DateTime startTime, DateTime endTime, int noticeType, string formCode);

        List<T_FM_NOTIFICATION_TASK> InsertUserNoticeTaskModels(string[] codeList, List<string> Name, List<Guid> DataId, Guid? OrgId, List<Guid> UserId, List<string> userName,
  DateTime startTime, List<DateTime> listEndTime, int noticeType, string formCode);

        /// <summary>
        /// 获取和修改Task信息
        /// </summary>
        /// <param name="TaskID"></param>
        /// <param name="SOURCE_FORMCODE">例：BS042_SHOWPRINT</param>
        /// <param name="NOTICE_STATUS">如果有参数 只能FMNoticeStatusEnum 对应的枚举值 </param>
        /// <returns></returns>
        T_FM_NOTIFICATION_TASK GetEntityTask(Guid TaskID, string SOURCE_FORMCODE = "", int NOTICE_STATUS = -1);


        T_FM_NOTIFICATION_TASK InsertUserNoticeTaskModel(string Name, Guid? DataId, Guid? OrgId, Guid UserId, string userName,
  DateTime startTime, int noticeType, string formCode, FMTASKTYPE TaskType, int? IFREQUENCYE = null, DateTime? DateTimeLastest = null, List<T_FM_NOTIFICATION_TASK_TIME_SET> listAllSet = null);
        List<T_FM_NOTIFICATION_TASK> InsertUserNoticeTaskModels(string Name, List<Guid> DataId, Guid? OrgId, List<Guid> UserId, List<string> userName, DateTime startTime, int noticeType, string formCode, FMTASKTYPE TaskType, int? IFREQUENCYE = null, DateTime? DateTimeLastest = null, List<T_FM_NOTIFICATION_TASK_TIME_SET> listAllSet = null);

        /// <summary>
        /// 插入新消息返回实体集合(wyw 0525)
        /// </summary>
        /// <param name="id">消息ID</param>
        /// <returns></returns>
        List<T_FM_NOTIFICATION_TASK> InsertUserNoticeTaskModels(string Name, Guid DataId, Guid? OrgId, List<Guid> UserIds, List<string> UserNames,
 DateTime startTime, int noticeType, string formCode, FMTASKTYPE TaskType, int? IFREQUENCYE = null, DateTime? DateTimeLastest = null, List<T_FM_NOTIFICATION_TASK_TIME_SET> listAllSet = null, Guid? AutoDoneID = null);

        List<T_FM_NOTIFICATION_TASK> InsertUserNoticeTaskModels(string Name, List<Guid> ListDataId, Guid? OrgId, Guid UserId, string UserName,
 DateTime startTime, int noticeType, string formCode, FMTASKTYPE TaskType, int? IFREQUENCYE = null, DateTime? DateTimeLastest = null, List<T_FM_NOTIFICATION_TASK_TIME_SET> listAllSet = null, Guid? AutoDoneID = null);



        /// <summary>
        /// 获取 待办期限
        /// </summary>
        /// <param name="TASK_TYPE">枚举待办类型</param>
        /// <param name="OrgId">必须要有值</param>
        /// <param name="dtNow">当前时间 默认当前时间</param>
        /// <param name="FREQUENCYE">BSPLANCHECKFREQUENCYEnum 触发频率</param>
        /// <param name="DateTimeLastest">业务表单最大限制时间 很多可能没有</param>
        /// <param name="listAllSet">待办限制时间配置信息外部调用不传</param>
        /// <returns></returns>
        DateTime GetTaskEndTime(FMTASKTYPE TASK_TYPE, Guid OrgId, DateTime? dtNow, int? FREQUENCYE, DateTime? DateTimeLastest, List<T_FM_NOTIFICATION_TASK_TIME_SET> listAllSet = null);
    }
}
