package com.fjhx.params.v3;

import cn.hutool.core.util.ObjectUtil;
import com.fjhx.entity.v3.V3PlanStatistics;
import com.fjhx.utils.BigDecimalUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;

/**
 * @author ${author}
 * @since 2022-10-31
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class V3PlanStatisticsEx extends V3PlanStatistics {

    private String userName;

    /**
     * 实际使用面积
     */
    public BigDecimal getActualUseArea() {
        return getPickingArea()
                .subtract(getBackArea())
                .subtract(getTransferOutArea())
                .add(getTransferInArea());
    }

    /**
     * 使用率
     */
    public BigDecimal getUseRate() {
        return BigDecimalUtil.init(getPlanArea()).multiply(100).divideTry(getActualUseArea(), 2).getValue();
    }

    @Override
    public BigDecimal getPlanArea() {
        return ObjectUtil.defaultIfNull(super.getPlanArea(), BigDecimal.ZERO);
    }

    @Override
    public BigDecimal getPickingArea() {
        return ObjectUtil.defaultIfNull(super.getPickingArea(), BigDecimal.ZERO);
    }

    @Override
    public Integer getPickingNum() {
        return ObjectUtil.defaultIfNull(super.getPickingNum(), 0);
    }

    @Override
    public BigDecimal getPickingMoney() {
        return ObjectUtil.defaultIfNull(super.getPickingMoney(), BigDecimal.ZERO);
    }

    @Override
    public BigDecimal getPickingMeters() {
        return ObjectUtil.defaultIfNull(super.getPickingMeters(), BigDecimal.ZERO);
    }

    @Override
    public BigDecimal getBackMoney() {
        return ObjectUtil.defaultIfNull(super.getBackMoney(), BigDecimal.ZERO);
    }

    @Override
    public Integer getBackNum() {
        return ObjectUtil.defaultIfNull(super.getBackNum(), 0);
    }

    @Override
    public BigDecimal getBackMeters() {
        return ObjectUtil.defaultIfNull(super.getBackMeters(), BigDecimal.ZERO);
    }

    @Override
    public BigDecimal getTransferInMoney() {
        return ObjectUtil.defaultIfNull(super.getTransferInMoney(), BigDecimal.ZERO);
    }

    @Override
    public BigDecimal getBackArea() {
        return ObjectUtil.defaultIfNull(super.getBackArea(), BigDecimal.ZERO);
    }

    @Override
    public Integer getTransferInNum() {
        return ObjectUtil.defaultIfNull(super.getTransferInNum(), 0);
    }

    @Override
    public BigDecimal getTransferInMeters() {
        return ObjectUtil.defaultIfNull(super.getTransferInMeters(), BigDecimal.ZERO);
    }

    @Override
    public BigDecimal getTransferInArea() {
        return ObjectUtil.defaultIfNull(super.getTransferInArea(), BigDecimal.ZERO);
    }

    @Override
    public BigDecimal getTransferOutMoney() {
        return ObjectUtil.defaultIfNull(super.getTransferOutMoney(), BigDecimal.ZERO);
    }

    @Override
    public Integer getTransferOutNum() {
        return ObjectUtil.defaultIfNull(super.getTransferOutNum(), 0);
    }

    @Override
    public BigDecimal getTransferOutMeters() {
        return ObjectUtil.defaultIfNull(super.getTransferOutMeters(), BigDecimal.ZERO);
    }

    @Override
    public BigDecimal getTransferOutArea() {
        return ObjectUtil.defaultIfNull(super.getTransferOutArea(), BigDecimal.ZERO);
    }

}
