package com.storlead.sales.pojo.entity.target;

import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.storlead.framework.mybatis.entity.SysBaseField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 * 目标配额表
 * </p>
 *
 * @author YPZ
 * @since 2024-12-11
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("target_quota")
@ApiModel(value="TargetQuotaEntity对象", description="目标配额表")
public class TargetQuotaEntity extends SysBaseField {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "目标配额主键")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "关联目标计划表主键")
    @TableField("target_plan_id")
    private Long targetPlanId;

    @ApiModelProperty(value = "组织类型（1集团、2公司、3部门、4个人）")
    @TableField("organizational_type")
    private Integer organizationalType;

    @ApiModelProperty(value = "组织id")
    @TableField("organizational_id")
    private Long organizationalId;

    @ApiModelProperty(value = "下级范围id，逗号隔开")
    @TableField("sub_scope_id")
    private String subScopeId;

    @ApiModelProperty(value = "下级范围名称，逗号隔开")
    @TableField("sub_scope_name")
    private String subScopeName;

    @ApiModelProperty(value = "父级目标配额id")
    @TableField("parent_id")
    private Long parentId;

    @ApiModelProperty(value = "1月份或者季度")
    @TableField("month_or_quarter1")
    private BigDecimal monthOrQuarter1;

    @ApiModelProperty(value = "2月份或者季度")
    @TableField("month_or_quarter2")
    private BigDecimal monthOrQuarter2;

    @ApiModelProperty(value = "3月份或者季度")
    @TableField("month_or_quarter3")
    private BigDecimal monthOrQuarter3;

    @ApiModelProperty(value = "4月份或者季度")
    @TableField("month_or_quarter4")
    private BigDecimal monthOrQuarter4;

    @ApiModelProperty(value = "5月份或者季度")
    @TableField("month_or_quarter5")
    private BigDecimal monthOrQuarter5;

    @ApiModelProperty(value = "6月份或者季度")
    @TableField("month_or_quarter6")
    private BigDecimal monthOrQuarter6;

    @ApiModelProperty(value = "7月份或者季度")
    @TableField("month_or_quarter7")
    private BigDecimal monthOrQuarter7;

    @ApiModelProperty(value = "8月份或者季度")
    @TableField("month_or_quarter8")
    private BigDecimal monthOrQuarter8;

    @ApiModelProperty(value = "9月份或者季度")
    @TableField("month_or_quarter9")
    private BigDecimal monthOrQuarter9;

    @ApiModelProperty(value = "10月份或者季度")
    @TableField("month_or_quarter10")
    private BigDecimal monthOrQuarter10;

    @ApiModelProperty(value = "11月份或者季度")
    @TableField("month_or_quarter11")
    private BigDecimal monthOrQuarter11;

    @ApiModelProperty(value = "12月份或者季度")
    @TableField("month_or_quarter12")
    private BigDecimal monthOrQuarter12;

    @ApiModelProperty(value = "总计")
    @TableField("total")
    private BigDecimal total;

    @TableField("former_owner_by")
    private Long formerOwnerBy;

    @ApiModelProperty(value = "认领状态（0未完成、1已完成）")
    @TableField("status")
    private Integer status;

    public BigDecimal addTotal() {
        BigDecimal total = BigDecimal.ZERO;
        if (this.monthOrQuarter1 != null){
            total = total.add(this.monthOrQuarter1);
        }
        if (this.monthOrQuarter2 != null){
            total = total.add(this.monthOrQuarter2);
        }
        if (this.monthOrQuarter3 != null){
            total = total.add(this.monthOrQuarter3);
        }
        if (this.monthOrQuarter4 != null){
            total =total.add(this.monthOrQuarter4);
        }
        if (this.monthOrQuarter5 != null){
            total = total.add(this.monthOrQuarter5);
        }
        if (this.monthOrQuarter6 != null){
            total = total.add(this.monthOrQuarter6);
        }
        if (this.monthOrQuarter7 != null){
            total = total.add(this.monthOrQuarter7);
        }
        if (this.monthOrQuarter8 != null){
            total = total.add(this.monthOrQuarter8);
        }
        if (this.monthOrQuarter9 != null){
            total = total.add(this.monthOrQuarter9);
        }
        if (this.monthOrQuarter10 != null){
            total = total.add(this.monthOrQuarter10);
        }
        if (this.monthOrQuarter11 != null){
            total = total.add(this.monthOrQuarter11);
        }
        if (this.monthOrQuarter12 != null){
            total = total.add(this.monthOrQuarter12);
        }
//        BigDecimal total = this.monthOrQuarter1.add(this.monthOrQuarter2).add(this.monthOrQuarter3).add(this.monthOrQuarter4).add(this.monthOrQuarter5).add(this.monthOrQuarter6).add(this.monthOrQuarter7).add(this.monthOrQuarter8).add(this.monthOrQuarter9).add(this.monthOrQuarter10).add(this.monthOrQuarter11).add(this.monthOrQuarter12);
        return total;
    }
}
