zj
2025-06-30 414555cfbb72c02ebc07ca164a7ff0d0f592de13
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
package project.data.model;
 
import java.text.DecimalFormat;
 
import javax.persistence.Column;
import javax.persistence.Table;
 
import kernel.bo.EntityObject;
import kernel.util.Arith;
import kernel.util.DateUtils;
 
/**
 * 实时价格
 */
@Table(name="T_REALTIME")
public class Realtime extends EntityObject implements Comparable<Realtime>, Cloneable {
    /**
     * UID
     */
    private static final long serialVersionUID = -4957441549674121537L;
    
    /**
     * 产品代码
     */
    @Column(name="SYMBOL")
    private String symbol;
    
    /**
     * 时间戳
     */
    @Column(name="TS")
    private Long ts;
    
    /**
     * 时间戳的"yyyy-MM-dd HH:mm:ss"格式
     */
    private String current_time;
    
    /**
     * 产品名称
     */
    @Column(name="NAME")
    private String name;
    
    /**
     * 开盘价
     */
    @Column(name="OPEN")
    private Double open;
 
    /**
     * 最新价
     */
    @Column(name="CLOSE")
    private Double close;
    
    /**
     * 最高价
     */
    @Column(name="HIGH")
    private Double high;
    
    /**
     * 最低价
     */
    @Column(name="LOW")
    private Double low;
    
    /**
     **
     * 成交额 金额
     */
    @Column(name="VOLUME")
    private Double volume;
    
    /**
     * 成交量 币个数
     */
    @Column(name="AMOUNT")
    private Double amount;
 
    /**
     * 涨跌幅
     */
    private double change_ratio;
 
    public Double getChange_ratio() {
        change_ratio = Arith.div(Arith.sub(close, open), open);
        change_ratio = Arith.mul(change_ratio, 100);
        DecimalFormat df = new DecimalFormat("#.##");
        return Double.valueOf(df.format(change_ratio));
    }
 
    /**
     * change_ratio,asc升序 desc 降序
     */
    public String order;
 
    public String getSymbol() {
        return symbol;
    }
 
    public void setSymbol(String symbol) {
        this.symbol = symbol;
    }
 
    public Long getTs() {
        return ts;
    }
 
    public void setTs(Long ts) {
        this.ts = ts;
        getCurrent_time();
    }
 
    public String getName() {
        return name;
    }
 
    public void setName(String name) {
        this.name = name;
    }
 
    public Double getOpen() {
        return open;
    }
 
    public void setOpen(Double open) {
        this.open = open;
    }
 
    public Double getHigh() {
        return high;
    }
 
    public void setHigh(Double high) {
        this.high = high;
    }
 
    public Double getLow() {
        return low;
    }
 
    public void setLow(Double low) {
        this.low = low;
    }
 
    public Double getVolume() {
        return volume;
    }
 
    public void setVolume(Double volume) {
        this.volume = volume;
    }
 
    public Double getAmount() {
        return amount;
    }
 
    public void setAmount(Double amount) {
        this.amount = amount;
    }
 
    public static long getSerialversionuid() {
        return serialVersionUID;
    }
 
    public String getCurrent_time() {
 
        current_time = DateUtils.timeStamp2Date(String.valueOf(ts));
        return current_time;
    }
 
    public Double getClose() {
        return close;
    }
 
    public void setClose(Double close) {
        this.close = close;
    }
 
    @Override
    public int compareTo(Realtime realtime) {
        if ("asc".equals(order)) {
            if (this.getChange_ratio() == realtime.getChange_ratio()) {
                return 0;
            } else if (this.getChange_ratio() > realtime.getChange_ratio()) {
                return 1;
            } else if (this.getChange_ratio() < realtime.getChange_ratio()) {
                return -1;
            }
            return 0;
        } else if ("desc".equals(order)) {
            if (this.getChange_ratio() == realtime.getChange_ratio()) {
                return 0;
            } else if (this.getChange_ratio() < realtime.getChange_ratio()) {
                return 1;
            } else if (this.getChange_ratio() > realtime.getChange_ratio()) {
                return -1;
            }
            return 0;
        }
 
        if (this.ts > realtime.getTs()) {
            return 1;
        } else if (this.ts < realtime.getTs()) {
            return -1;
        }
        return 0;
 
    }
 
    public void setOrder(String order) {
        this.order = order;
    }
 
    @Override
    public Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
 
}