import type {IComposeTaskSearch} from "@/interface/page/stockTask/IComposeTaskSearch.ts";
import axiosInstance from "@/api/axios.ts";
import type {IComposeTaskTableData} from "@/model/table/IComposeTaskTableData.ts";
import type {ReporterTaskStatusReq} from "@/interface/page/stockTask/IReporterTaskStatusReq.ts";

export default class StockComposeTaskApi {

    // 条件模糊查询，主查询
    static query(query: IComposeTaskSearch, pageSize: number, pageIndex: number) {
        return axiosInstance.post("/app/stockComposeTask/query", query, {
            params: {
                pageSize: pageSize,
                pageIndex: pageIndex,
            }
        });
    };
    // 条件模糊查询，主查询 ---- 备份数据
    static queryBak(query: IComposeTaskSearch, pageSize: number, pageIndex: number) {
        return axiosInstance.post("/app/stockComposeTask/queryBak", query, {
            params: {
                pageSize: pageSize,
                pageIndex: pageIndex,
            },
            timeout: 30000
        });
    };
    // 添加
    static addTask(data: IComposeTaskTableData) {
        return axiosInstance.post("/app/stockComposeTask/addTask", data);
    };
    // 下载任务数据文件
    static downloadTask(query: IComposeTaskSearch) {
        return axiosInstance.post("/app/stockComposeTask/downLoadTask", query, {
            responseType: 'blob',
            timeout: 30000
        })
    };
    // 下载任务数据文件 ---- 历史数据
    static downloadTaskBak(query: IComposeTaskSearch) {
        return axiosInstance.post("/app/stockComposeTask/downLoadTaskBak", query, {
            responseType: 'blob',
            timeout: 30000
        })
    };
    // 取消任务
    static cancelTask(taskId: string) {
        return axiosInstance.put("/app/stockComposeTask/cancelTask", null, {
            params: {
                taskId: taskId
            }
        });
    };
    // 完成任务
    static completeTask(taskId: string) {
        return axiosInstance.put("/app/stockComposeTask/completeTask", null, {
            params: {
                taskId: taskId
            }
        });
    };
    // 重做任务
    static resetTask(taskId: string) {
        return axiosInstance.put("/app/stockComposeTask/resetTask", null, {
            params: {
                taskId: taskId
            }
        });
    };
    // 上报任务完成
    static reportTaskComplete(reportData: ReporterTaskStatusReq) {
        return axiosInstance.post("/app/stockComposeTask/reporterTaskCompleted", reportData);
    };
    // 上报任务取消
    static reportTaskCancel(reportData: ReporterTaskStatusReq) {
        return axiosInstance.post("/app/stockComposeTask/reporterTaskCancel", reportData);
    };
    // 上报任务完成 ---- 历史数据
    static reportTaskBakComplete(reportData: ReporterTaskStatusReq) {
        return axiosInstance.post("/app/stockComposeTask/reporterTaskBakCompleted", reportData, {
            timeout: 30000
        });
    }
    // 上报任务取消 ---- 历史数据
    static reportTaskBakCancel(reportData: ReporterTaskStatusReq) {
        return axiosInstance.post("/app/stockComposeTask/reporterTaskBakCancel", reportData, {
            timeout: 30000
        });
    };
    // 计算路线
    static calculateCourse(composeTaskId?: string) {
        return axiosInstance.get("/app/stockComposeTask/queryCourseResult", {
            params: {
                composeTaskId: composeTaskId
            }
        });
    }



}