package com.ecep.contract.task;

import com.ecep.contract.MessageHolder;
import com.ecep.contract.WebSocketClientTasker;

import lombok.Getter;
import lombok.Setter;

import java.util.logging.Level;

/**
 * 客户文件移动到公司目录任务器
 * 用于将客户相关文件从客户目录移动到公司目录
 */
public class CustomerFileMoveTasker extends Tasker<Object> implements WebSocketClientTasker {
    private static final String TASK_NAME = "CustomerFileMoveTasker";
    @Setter
    @Getter
    private boolean filesUpdated;
    private Integer fileId;

    public void setFileId(Integer fileId) {
        this.fileId = fileId;
    }

    @Override
    public String getTaskName() {
        return TASK_NAME;
    }

    @Override
    public void updateProgress(long current, long total) {
        super.updateProgress(current, total);
    }

    @Override
    protected Object execute(MessageHolder holder) throws Exception {
        try {
            updateTitle("移动文件到公司目录");
            updateMessage("开始执行文件移动任务...");

            // 调用远程WebSocket任务，传递客户ID和文件ID
            callRemoteTask(holder, getLocale(),  fileId);

            updateMessage("文件移动任务已提交到服务器，等待执行完成...");
            return true;
        } catch (Exception e) {
            updateMessage(Level.SEVERE, "文件移动失败: " + e.getMessage());
            throw e;
        }
    }
}