package cn.wisenergy.model.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * @description: 项目的工时和工时成本统计
 * @author: nh
 * @create: 2021-01-22 11:57
 **/
@Data
@ApiModel(value = "WorkTimeAndCostCollect", description = "项目的工时和工时成本统计")
public class WorkTimeAndCostCollect implements Serializable, Comparable {
    private static final long serialVersionUID = 7207732278277982917L;

    // 工单类型展示顺序，存储为类型id
    private final static Integer[] TYPE_ORDER = {1, 2, 5, 6, 7, 3, 4};

    @ApiModelProperty(name = "type", value = "工时类型主键")
    private Integer type;

    /**
     *  工时类型
     */
    @ApiModelProperty(name = "typeName", value = "工时类型")
    private String typeName;

    /**
     * 部门工时统计
     */
    @ApiModelProperty(name = "deptProjectWorkTimeAndCosts", value = "部门工时统计")
    private List<DeptProjectWorkTimeAndCost> deptProjectWorkTimeAndCosts;

    /**
     * 工时总计
     */
    @ApiModelProperty(name = "workTime", value = "工时总计")
    private BigDecimal workTime;

    @Override
    public int compareTo(Object o) {
        WorkTimeAndCostCollect workTimeAndCostCollect = (WorkTimeAndCostCollect) o;
        int thisI = 0;
        int oI = 0;
        for (int i = 0; i < TYPE_ORDER.length; i++) {
            if (type == TYPE_ORDER[i]) {
                thisI = i;
            }
            if (workTimeAndCostCollect.getType() == TYPE_ORDER[i]) {
                oI = i;
            }
        }
        return thisI - oI;
    }
}
