package com.qmth.distributed.print.business.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qmth.distributed.print.business.bean.dto.*;
import com.qmth.distributed.print.business.bean.params.DeleteParams;
import com.qmth.distributed.print.business.bean.params.PrintPlanParams;
import com.qmth.distributed.print.business.bean.params.SyncDataParam;
import com.qmth.distributed.print.business.bean.result.PrintPlanBrief;
import com.qmth.distributed.print.business.bean.result.PrintPlanResult;
import com.qmth.distributed.print.business.entity.ExamPrintPlan;
import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
import com.qmth.teachcloud.common.entity.SysUser;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 印刷计划管理 服务类
 * </p>
 *
 * @author xf
 * @since 2021-03-23
 */
public interface ExamPrintPlanService extends IService<ExamPrintPlan> {
    /**
     * 印刷计划分页查询
     *
     * @param schoolId        学校id
     * @param semesterId      校区id
     * @param examId          考试id
     * @param printPlanIdList 印刷计划id集合
     * @param status          印刷计划状态
     * @param startTime       印刷计划创建时间开始
     * @param endTime         印刷计划创建时间结束
     * @param pageNumber      分页页数
     * @param pageSize        分页容量
     * @return 分页查询结果
     */
    IPage<PrintPlanResult> printPlanPage(Long schoolId, Long semesterId, Long examId, List<Long> printPlanIdList, PrintPlanStatusEnum status, Long startTime, Long endTime, int pageNumber, int pageSize);

    IPage<PrintPlanResult> printPlanSyncPage(Long schoolId, Long semesterId, Long examId, Long printPlanId, Long startTime, Long endTime, int pageNumber, int pageSize);

    /**
     * 印刷计划模糊名称
     *
     * @param source
     * @param module
     * @return 印刷计划id和名称
     */
    List<PrintPlanBrief> printPlanBriefQuery(String source, String module);


    /**
     * 查询登录用户所属机构下变量印品和普通印品模板数据源
     *
     * @param schoolId 学校id
     * @param userId   登录用户id
     * @return 模板数据源
     */
    Map<String, Object> printPlanTemplateDatasource(Long schoolId, Long userId);

    /**
     * 保存印刷计划
     *
     * @param printPlanParams 印刷计划参数
     * @return 是否成功
     */
    Boolean savePrintPlan(PrintPlanParams printPlanParams);

    /**
     * 删除印刷计划
     *
     * @param deleteParams 删除参数
     * @return 是否成功
     */
    Boolean removePrintPlan(DeleteParams deleteParams);

    List<Map<String, String>> tempalteView(Long printPlanId);

    IPage<ClientPrintTaskDto> listClientPrintTask(Page<ClientPrintTaskDto> page, Long schoolId, String machineCode, String printPlanId, String status, String courseCode, String paperNumber, String examPlace, String examRoom, Long examStartTime, Long examEndTime, Boolean isDownload, Boolean validate, Long orgId);

    List<ClientPrintTaskDto> listClientPrintTask(Long schoolId, String machineCode, String printPlanId, String status, String courseCode, String paperNumber, String examPlace, String examRoom, Long examStartTime, Long examEndTime, Boolean isDownload, Boolean validate, Long orgId);

    ClientPrintTaskTotalDto clientTaskTotalData(String printPlanId, Long orgId, String status, String courseCode, String paperNumber, String examPlace, String examRoom, Long examStartTime, Long examEndTime, Boolean isDownload, Boolean validate, String machineCode);

    IPage<ClientPrintStatisticsDto> listClientPrintStatistics(Page<ClientPrintStatisticsDto> page, Long schoolId, String printPlanId, String examPlace, Long examStartTime, Long examEndTime, String courseCode, String paperNumber, Long orgId);

    ClientPrintStatisticsTotalDto clientStatisticsTotalData(Long orgId, String printPlanId, String examPlace, Long examStartTime, Long examEndTime, String courseCode, String paperNumber);

    List<ThirdObjectDto> printSyncPlan(Long schoolId, Long semesterId, Long examId);

    void syncDataCloud(Long printPlanId, Long thirdRelateId);

    void syncDataCloudBatch(SyncDataParam syncDataParam);

    void syncDataMerge(SyncDataParam syncDataParam);

    /**
     * 根据考场详情表查找印刷计划
     *
     * @param examDetailId 考场详情表id
     * @return 印刷计划
     */
    ExamPrintPlan findByExamDetailId(Long examDetailId);

    void sendNoticeUploadStructure(Long id, SysUser sysUser);

    /**
     * 根据学校id和试卷编号查询印刷计划
     * @param schoolId 学校id
     * @param paperNumber 试卷编号
     * @return 印刷计划
     */
    List<ExamPrintPlan> findByPaperNumber(Long schoolId,String paperNumber);
}
