package com.ruoyi.system.domain.excel;

import com.ruoyi.common.annotation.Excel;

import java.io.Serializable;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author denis
 * @date 2022/10/19 15:31
 */
public class UserCostDetailForExcel implements Serializable {
    private static final long serialVersionUID = 1L;
    @Excel(name = "名称")
    private String name;
    @Excel(name = "岗位")
    private String postName;
    @Excel(name = "内容", autoSize = true)
    private String remark;
    @Excel(name = "时间")
    private String timeSpan;
    @Excel(name = "工时", isStatistics = true)
    private String cost;
    @Excel(name = "单价（元/月）")
    private String postCost;
    @Excel(name = "成本", isStatistics = true)
    private String postCostTotal;

    public String getName() {
        return name;
    }

    public String getPostName() {
        return postName;
    }

    public String getRemark() {
        return remark;
    }

    public String getTimeSpan() {
        return timeSpan;
    }

    public String getCost() {
        return cost;
    }

    public String getPostCostTotal() {
        return postCostTotal;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setPostName(String postName) {
        this.postName = postName;
    }

    public void setRemark(String remark) {
        if (remark == null) {
            return;
        }
        this.remark = remark.replaceAll("<BR>", String.valueOf((char) 10));
    }

    public void setTimeSpan(Date sd, Date ed) {
        if (sd == null || ed == null) {
            this.timeSpan = "-";
        } else {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            this.timeSpan = format.format(sd) + "~" + format.format(ed);
        }

    }

    public void setCost(BigDecimal cost) {
        if (cost == null || "".equals(cost)) {
            this.cost = "-";
            return;
        }
        if (new BigDecimal(cost.intValue()).compareTo(cost) == 0) {
            this.cost = String.valueOf(cost.intValue());
        } else {
            this.cost = String.format("%.2f", cost);
        }
    }
    public void setPostCostTotal(BigDecimal postCostTotal){
        if (postCostTotal == null || "".equals(postCostTotal)) {
            this.postCostTotal = "-";
            return;
        }
        if(new BigDecimal(postCostTotal.intValue()).compareTo(postCostTotal) == 0){
            this.postCostTotal = String.valueOf(postCostTotal.intValue());
        }else {
            this.postCostTotal = String.format("%.2f", postCostTotal);
        }
    }

    public void setPostCost(BigDecimal postCost) {
        if (postCost == null || "".equals(postCost)) {
            this.postCost = "-";
            return;
        }
        if(new BigDecimal(postCost.intValue()).compareTo(postCost) == 0){
            this.postCost = String.valueOf(postCost.intValue());
        }else {
            this.postCost = String.format("%.2f", postCost);
        }
    }
}
