DYL0109
2025-04-18 940bdec33a4c2a6b52d1497e6eeffddb1b6b4585
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.zhitan.statisticalAnalysis.domain.vo;
 
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
 
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Collections;
import java.util.List;
 
/**
 * 能流图查询
 */
@Data
public class FlowChartsVO {
 
    // 总累积量
    @ApiModelProperty(value = "总累积量")
    private BigDecimal totalAccumulatedAmount;
 
    // 子节点累积量
    @ApiModelProperty(value = "子节点累积量")
    private BigDecimal childNodeAccumulatedAmount;
 
    // 差值
    @ApiModelProperty(value = "差值")
    private BigDecimal difference;
 
    // 能耗损失比例
    @ApiModelProperty(value = "能耗损失比例")
    private BigDecimal energyLossRatio;
 
    private List<FlowChartsItemVO> itemVOList;
 
    public BigDecimal getTotalAccumulatedAmount() {
        if (totalAccumulatedAmount == null){
            return BigDecimal.ZERO;
        }
        return totalAccumulatedAmount;
    }
 
    public BigDecimal getChildNodeAccumulatedAmount() {
        if (childNodeAccumulatedAmount == null){
            return BigDecimal.ZERO;
        }
        return childNodeAccumulatedAmount;
    }
 
    public BigDecimal getDifference() {
        return difference = totalAccumulatedAmount.subtract(childNodeAccumulatedAmount);
    }
 
    public BigDecimal getEnergyLossRatio() {
        if (BigDecimal.ZERO.compareTo(totalAccumulatedAmount) == 0
                || BigDecimal.ZERO.compareTo(difference) == 0) {
            return BigDecimal.ZERO;
        }
        // 先计算比例,再乘以 100 转换为百分数
        return energyLossRatio = difference.divide(totalAccumulatedAmount, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP);
    }
 
    public FlowChartsVO() {
        this.totalAccumulatedAmount = BigDecimal.ZERO;
        this.childNodeAccumulatedAmount = BigDecimal.ZERO;
        this.difference = BigDecimal.ZERO;
        this.energyLossRatio = BigDecimal.ZERO;
        this.itemVOList = Collections.emptyList();
    }
}