package com.qmth.teachcloud.common.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qmth.teachcloud.common.bean.params.ArraysParams;
import com.qmth.teachcloud.common.bean.result.TaskListResult;
import com.qmth.teachcloud.common.entity.BasicAttachment;
import com.qmth.teachcloud.common.entity.SysUser;
import com.qmth.teachcloud.common.entity.TBTask;
import com.qmth.teachcloud.common.enums.TaskResultEnum;
import com.qmth.teachcloud.common.enums.TaskStatusEnum;
import com.qmth.teachcloud.common.enums.TaskTypeEnum;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 导入导出任务表 服务类
 * </p>
 *
 * @author wangliang
 * @since 2021-03-19
 */
public interface TBTaskService extends IService<TBTask> {

    /**
     * 保存任务
     *
     * @param file
     * @param taskTypeEnum
     * @param objId
     * @return
     */
    public Map<String, Object> saveTask(MultipartFile file, TaskTypeEnum taskTypeEnum, Object objId);

    /**
     * 保存任务
     *
     * @param file
     * @param taskTypeEnum
     * @param orgId
     * @return
     */
    public Map<String, Object> saveTask(MultipartFile file, TaskTypeEnum taskTypeEnum, Long orgId);

    /**
     * 保存任务
     *
     * @param file
     * @param taskTypeEnum
     * @param objId
     * @param orgId
     * @return
     */
    public Map<String, Object> saveTask(MultipartFile file, TaskTypeEnum taskTypeEnum, Object objId, Long orgId);

    /**
     * 保存任务
     *
     * @param taskTypeEnum
     * @param printPlanId
     * @return
     */
    public Map<String, Object> saveTask(TaskTypeEnum taskTypeEnum, Long printPlanId);

    /**
     * 保存任务
     *
     * @param taskTypeEnum
     * @param printPlanId
     * @param sysUser
     * @param entityId
     * @return
     */
    public Map<String, Object> saveTask(TaskTypeEnum taskTypeEnum, Long printPlanId, SysUser sysUser, Long entityId);

    /**
     * 保存任务
     *
     * @param taskTypeEnum
     * @param arraysParams
     * @param sysUser
     * @return
     */
    public Map<String, Object> saveTask(TaskTypeEnum taskTypeEnum, ArraysParams arraysParams, SysUser sysUser);

    /**
     * 保存任务
     * @param taskTypeEnum 任务类型
     * @return 结果
     */
    public Map<String,Object> saveTask(TaskTypeEnum taskTypeEnum);

    /**
     * 查询任务列表
     *
     * @param iPage
     * @param schoolId
     * @param printPlanId
     * @param status
     * @param type
     * @param result
     * @return
     */
    public IPage<TaskListResult> query(IPage<Map> iPage,
                                       Long schoolId,
                                       Long printPlanId,
                                       TaskStatusEnum status,
                                       TaskTypeEnum type,
                                       TaskResultEnum result);

    /**
     * 获取任务是否完成
     *
     * @param schoolId
     * @param printPlanId
     * @param entityIds
     * @return
     */
    public boolean countByPrintPlanIdAndEntityId(Long schoolId, Long printPlanId, List<Long> entityIds);

    /**
     * 保存task
     *
     * @param basicAttachment
     * @param taskTypeEnum
     * @param map
     * @param sysUser
     * @return
     */
    public TBTask saveTaskCommon(BasicAttachment basicAttachment, TaskTypeEnum taskTypeEnum, Map map, SysUser sysUser);
}
