package com.engine.salary.entity.salaryacct.bo;

import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldListDTO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO;
import com.engine.salary.entity.salaryformula.ExpressFormula;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO;
import com.engine.salary.entity.salarysob.po.SalarySobAdjustRulePO;
import com.engine.salary.entity.salarysob.po.SalarySobItemPO;
import com.engine.salary.entity.salarysob.po.SalarySobPO;
import com.engine.salary.sys.enums.TaxDeclarationFunctionEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.CountDownLatch;

/**
 * 薪资核算
 * <p>Copyright: Copyright (c) 2022</p>
 * <p>Company: 泛微软件</p>
 *
 * @author qiantao
 * @version 1.0
 **/
@Data
@Accessors(chain = true)
public class SalaryAcctCalculateBO {

    /**
     * 当前薪资核算记录
     */
    private SalaryAcctRecordPO salaryAcctRecordPO;

    /**
     * 账套
     */
    private SalarySobPO salarySobPO;

    /**
     * 当前薪资核算记录的薪资周期、考勤周期……
     */
    private SalarySobCycleDTO salarySobCycleDTO;

    /**
     * 核算锁定值
     */
    private Map<String, SalaryAcctResultPO> salaryAcctLockResultPOS;
    private List<Long> lockSalaryItemIds;


    /**
     * 相同税款所属期内其他薪资核算记录（薪资类型为工资薪金的账套的）
     */
    private List<SalaryAcctRecordPO> otherSalaryAcctRecordPOS;

    /**
     * 当前薪资核算记录所用的薪资账套下的薪资项目
     */
    private List<SalarySobItemPO> salarySobItemPOS;

    /**
     * 本次运算的薪资项目（已排好运算优先级）
     */
    private List<List<Long>> salaryItemIdWithPriorityList;

    /**
     * 本次运算涉及的所有公式
     */
    private List<ExpressFormula> expressFormulas;

    /**
     * 租户下所有的薪资项目
     */
    private List<SalaryItemPO> salaryItemPOS;

    /**
     * 当前薪资核算所用账套设置的调薪计薪规则
     */
    private List<SalarySobAdjustRulePO> salarySobAdjustRulePOS;

    /**
     * 社保福利字段
     */
    private Map<String, String> welfareColumns;

    /**
     * 考勤引用字段
     */
    private List<AttendQuoteFieldListDTO> attendQuoteFieldListDTOS;

    /**
     * 本次运算的薪资核算人员
     */
    private List<SalaryAcctEmployeePO> salaryAcctEmployeePOS;

    /**
     * 本次运算的回算薪资项目所涉及的变量
     */
    private Set<String> issuedFieldIds;

    /**
     * 核算结果临时表中的key
     */
    private String calculateKey;

    /**
     * 监视子线程运算结果
     */
    private CountDownLatch childMonitor;

    /**
     * 所有子线程的运算结果
     */
    private BlockingDeque<Result> results;

    /**
     * 系统算税启用状态
     */
    private TaxDeclarationFunctionEnum taxDeclarationFunction;

    @Data
    @AllArgsConstructor
    public static class Result {

        /**
         * 子线程是否运算成功
         */
        private boolean status;

        /**
         * 子线程元算失败的错误信息
         */
        private String errMsg;
    }
}
