zxl
2026-03-25 8819762ad58f77e606431fca4072c19e542e6055
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
package com.tievd.jyz.entity.vo;
 
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;
 
import java.io.Serializable;
import java.time.temporal.ChronoField;
import java.util.function.Function;
 
/**
 * <p>
 * 加油记录表
 * </p>
 *
 * @author
 * @since 2023-02-24
 */
@Data
@Accessors(chain = true)
@Schema(name = "加油量")
public class DataStatisReqVo implements Serializable {
 
    private static final long serialVersionUID = 1L;
 
    @Schema(description = "开始时间")
    private String startTime;
 
    @Schema(description = "结束时间")
    private String endTime;
 
    @Schema(description = "活动前开始时间")
    private String beforeStartTime;
 
    @Schema(description = "活动前结束时间")
    private String beforeEndTime;
 
    @Schema(description = "活动后开始时间")
    private String afterStartTime;
 
    @Schema(description = "活动后结束时间")
    private String afterEndTime;
    
    public void setOrgCodeIfnull(String orgCode) {
        if (this.orgCode == null || this.orgCode.equals("")){
            this.orgCode = orgCode;
        }
    }
    
    @Schema(description = "所属机构")
    private String orgCode;
    
    @Schema(description = "扇形图类型 1按车型/加油数(折线车流量) 2按车位/加油数(折线销量) 3车型/销量  4车位/销量 ")
    private int type = 1;
    
    @Schema(description = "趋势分析类型 0车流量 1加油数 2销量  3通过率 4客户 5流失率 ")
    private TrendType trendType;
    
    @Schema(description = "HOURS, DAYS, MONTHS")
    private StatUnit timeUnit = StatUnit.HOURS;
 
    @Schema(description = "趋势图点位时间")
    private String statTime;
 
    @Schema(description = "趋势图系列名称")
    private String seriesName;
    
    private DataStatisReqVo setTimeUnit(String timeUnit){
        this.timeUnit = StatUnit.valueOf(timeUnit);
        return this;
    }
    
    public enum StatUnit {
        
        HOURS("HOURS", 12, "HH:mm", ChronoField.MINUTE_OF_HOUR),
        
        DAYS("DAYS", 14, "YYYY-MM-dd", ChronoField.HOUR_OF_DAY),
    
        MONTHS("MONTHS", 12, "YYYY-MM", ChronoField.DAY_OF_MONTH);
    
        String name;
        
        int value;
    
        String statFormat;
    
        ChronoField initField;
        
        StatUnit(String name, int value, String statFormat, ChronoField initField){
            this.name = name;
            this.value = value;
            this.statFormat = statFormat;
            this.initField = initField;
        }
        
        public Integer value() {
            return this.value;
        }
    
        public String statFormat() {
            return this.statFormat;
        }
        
        public ChronoField initField() {
            return this.initField;
        }
    
    }
    
    public enum TrendType {
        TRAFFIC(0, StatDataTableVo::getCarCount, StatDataTableVo::getEntryRate, "车流量", "拐入率"),
        OIL(1, StatDataTableVo::getOilCount, StatDataTableVo::getOilVolume, "加油数", "油品销量"),
        OIL_vOLUME(2, StatDataTableVo::getOilVolume, t -> 100 * (t.getOilVolume() - t.getPreStatVo().getOilVolume()) / (t.getPreStatVo().getOilVolume() + 1), "油品销量", "环比"),
        SPAND_AVG(3, StatDataTableVo::getSpandAvg, t -> 100 * (t.getSpandAvg() - t.getPreStatVo().getSpandAvg()) / (t.getPreStatVo().getSpandAvg() + 1), "通过率", "环比"),
        CLIENT(4, null),
        LOSE_CLIENT(5, null),
        SALES_AMOUNT(6, StatDataTableVo::getTotalAmount, t -> {
            java.math.BigDecimal current = t.getTotalAmount();
            java.math.BigDecimal previous = t.getPreStatVo().getTotalAmount();
            if (previous.compareTo(java.math.BigDecimal.ZERO) == 0) {
                return java.math.BigDecimal.ZERO;
            }
            return current.subtract(previous).multiply(new java.math.BigDecimal(100)).divide(previous, 2, java.math.RoundingMode.HALF_UP);
        }, "销售金额", "环比");
        
        int val;
        
        Function<?, ?> barFunc;
        
        Function<?, ?> lineFunc;
        
        String barName;
        
        String lineName;
    
        TrendType(int val, Function<StatDataTableVo, ?> barFunc, Function<StatDataTableVo, ?> lineFunc, String barName, String lineName) {
            this.val = val;
            this.barFunc = barFunc;
            this.lineFunc = lineFunc;
            this.barName = barName;
            this.lineName = lineName;
        }
    
        TrendType(int val, Function<OilStatisVo, ?> barFunc) {
            this.val = val;
            this.barFunc = barFunc;
        }
    
        public Function<?, ?> getBarFunc() {
            return barFunc;
        }
    
        public Function<?, ?> getLineFunc() {
            return lineFunc;
        }
    
        public String getBarName() {
            return barName;
        }
    
        public String getLineName() {
            return lineName;
        }
    }
}