PoolQueryDTO.java
4.95 KB
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
package cn.fw.dalaran.domain.dto;
import cn.fw.common.page.BasePageQuery;
import cn.fw.common.web.annotation.LoginContextField;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 查询条件
*
* @author kurisu
*/
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class PoolQueryDTO extends BasePageQuery {
/**
* 平台类型
*/
private Integer platform;
/**
* 账号
*/
private String account;
/**
* 门店id
*/
private String shopIds;
/**
* 门店
*/
private String shopName;
/**
* 用户id
*/
private Long userId;
/**
* 用户
*/
private String userName;
/**
* 时间(区间)
*/
private String dateStr;
private LocalDate endDate;
/**
* 1升序 2降序
*/
private Integer order;
private String orderAtt;
/**
* 是否有效
*/
private Boolean valid;
/**
* 主题id
*/
private Long themeId;
/**
* 主题名
*/
private String theme;
/**
* 日期类型
*/
private Integer dateType;
/**
* 最佳直播
*/
private Boolean bestLive;
/**
* 重写valid的get方法
*
* @return valid ? 1 : 0
*/
public List<Integer> getValid() {
if (Objects.isNull(this.valid))
return null;
return valid ? (Objects.nonNull(this.bestLive) && bestLive ? Collections.singletonList(11) : Arrays.asList(1, 11)) : Arrays.asList(0, -1, -2);
}
/**
* 3月16日访问视频池传参数
* &_s=1647361106415
* ¤t=1
* &pageSize=50
* &dateType=20
* &beginDate=1646064000000 2022-03-01 00:00:00
* &endDate=1647273600000 2022-03-15 00:00:00
* &shopIds=11,54,155,156,12,57,18,41,20,14,13,53,154,23,39,147,150,153,157
* &delay=false
* &reportType=Dalaran001M
* &reportDate=1647273600000 2022-03-15 00:00:00
* &startTime=1646064000000,1647273600000 2022-03-01 00:00:00 2022-03-15 00:00:00
* &dateStr=1646064000000,1647273600000 2022-03-01 00:00:00 2022-03-15 00:00:00
* &systemType=23
*/
/**
* 服务端自己处理的参数
*/
private String orderString;
@LoginContextField(LoginContextField.Name.GROUP_ID)
private Long groupId;
/**
* 关联发布时间/开播时间
*
* @return
*/
public LocalDate getDate1() {
if (StringUtils.isBlank(dateStr)) {
return null;
}
String[] times = dateStr.split(",");
if (StringUtils.isNotBlank(times[0]) && NumberUtils.isDigits(times[0])) {
return Instant.ofEpochMilli(NumberUtils.toLong(times[0])).atZone(ZoneId.systemDefault()).toLocalDate();
}
return null;
}
/**
* 关联发布时间/开播时间
*
* @return
*/
public LocalDate getDate2() {
if (StringUtils.isBlank(dateStr)) {
return null;
}
String[] times = dateStr.split(",");
if (times.length > 1 && StringUtils.isNotBlank(times[1]) && NumberUtils.isDigits(times[1])) {
final LocalDate date = Instant.ofEpochMilli(NumberUtils.toLong(times[1])).atZone(ZoneId.systemDefault()).toLocalDate();
if (Objects.equals(dateType, 10))
return date;
if (displayYesterday(date))
return date.minusDays(1);
else
return date;
}
return null;
}
public List<Long> getShopIds() {
if (StringUtils.isBlank(shopIds)) {
return null;
}
return Arrays.stream(shopIds.split(",")).filter(NumberUtils::isDigits).map(Long::valueOf).collect(Collectors.toList());
}
/**
* 关联创建时间
*
* @return
*/
public LocalDate getEndDate() {
if (Objects.isNull(endDate)) {
return null;
}
if (Objects.equals(dateType, 10))
return endDate.plusDays(1);
if (displayYesterday(endDate))
return endDate;
else
return endDate.plusDays(1);
}
/**
* 是否展示昨天数据
*
* @return
*/
public boolean displayYesterday(LocalDate date) {
final LocalDate now = LocalDate.now();
final boolean isSameMonth = Objects.equals(date.withDayOfMonth(1), now.withDayOfMonth(1));
if (isSameMonth) {
final LocalDateTime extraTime = LocalDateTime.of(now.getYear(), now.getMonth(), now.getDayOfMonth(), 13, 33, 0);
return LocalDateTime.now().compareTo(extraTime) <= 0;
}
return false;
}
}