package com.ecep.contract.task;

import com.ecep.contract.MessageHolder;
import com.ecep.contract.SpringApp;
import com.ecep.contract.WebSocketClientTasker;
import com.ecep.contract.service.ContractService;
import com.ecep.contract.vo.ContractVo;

import lombok.Getter;
import lombok.Setter;

/**
 * 合同修复任务
 */
public class ContractRepairTask extends Tasker<Object> implements WebSocketClientTasker {
    @Getter
    @Setter
    private ContractVo contract;

    @Getter
    @Setter
    private boolean repaired = false;
    @Getter
    @Setter
    protected boolean filesUpdated = false;
    @Getter
    @Setter
    protected boolean itemsUpdated = false;
    @Getter
    @Setter
    protected boolean playPlanUpdated = false;
    @Getter
    @Setter
    protected boolean saleOrderUpdated = false;

    public ContractRepairTask() {
    }

    @Override
    public String getTaskName() {
        return "ContractRepairTask";
    }

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

    @Override
    protected Object execute(MessageHolder holder) throws Exception {
        ContractService contractService = SpringApp.getBean(ContractService.class);
        updateTitle("修复合同 " + contractService.getStringConverter().toString(contract));
        return callRemoteTask(holder, getLocale(), contract.getId());
    }

}
