package com.njcn.harmonic.pojo.vo;

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

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 类的介绍：
 *
 * @author xuyang
 * @version 1.0.0
 * @createTime 2022/2/21 18:10
 */
@Data
public class PollutionVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("id")
    private String id;

    @ApiModelProperty("父级id")
    private String pid;

    @ApiModelProperty("名称")
    private String name;

    @ApiModelProperty("电网标志")
    private Integer powerFlag;

    @ApiModelProperty("污染指标")
    private Double data = 3.14159;

    @ApiModelProperty("子级")
    private List<PollutionVO> children;

    public void setChildren(List<PollutionVO> children) {
        List<PollutionVO> listSort = children.stream().filter(x -> x.getData() != 3.14159).sorted(Comparator.comparing(PollutionVO::getData).reversed().thenComparing(PollutionVO::getName)).collect(Collectors.toList());
        listSort.addAll(children.stream().filter(x -> x.getData() == 3.14159).collect(Collectors.toList()));
        this.children = listSort;
    }
}
