|
...
|
...
|
@@ -108,18 +108,32 @@ public class ShipmentQuantityIndustryStatisticsServiceImpl implements ShipmentQu |
|
108
|
108
|
}
|
|
109
|
109
|
|
|
110
|
110
|
private List<ShipmentQuantityIndustryStatisticsDto> buildFilledList(QueryShipmentQuantityIndustryStatisticsVo vo) {
|
|
111
|
|
- ShipmentQuantityStatisticsDateRangeDto dateRange = shipmentQuantityIndustryStatisticsMapper.queryDateRange(vo);
|
|
112
|
|
- if (dateRange == null || dateRange.getStartDate() == null || dateRange.getEndDate() == null) {
|
|
113
|
|
- return new ArrayList<>();
|
|
114
|
|
- }
|
|
115
|
|
-
|
|
116
|
|
- LocalDate startDate = parseOrDefault(vo.getShipmentDateStart(), dateRange.getStartDate());
|
|
117
|
|
- LocalDate endDateDefault = dateRange.getEndDate();
|
|
|
111
|
+ LocalDate startDate = parse(vo.getShipmentDateStart());
|
|
|
112
|
+ LocalDate endDate = parse(vo.getShipmentDateEnd());
|
|
118
|
113
|
LocalDate today = LocalDate.now();
|
|
119
|
|
- if (endDateDefault.isBefore(today)) {
|
|
120
|
|
- endDateDefault = today;
|
|
|
114
|
+
|
|
|
115
|
+ if (startDate == null && endDate == null) {
|
|
|
116
|
+ ShipmentQuantityStatisticsDateRangeDto dateRange = queryDateRangeWithFallback(vo);
|
|
|
117
|
+ if (dateRange == null || dateRange.getStartDate() == null || dateRange.getEndDate() == null) {
|
|
|
118
|
+ startDate = today;
|
|
|
119
|
+ endDate = today;
|
|
|
120
|
+ } else {
|
|
|
121
|
+ startDate = dateRange.getStartDate();
|
|
|
122
|
+ LocalDate endDateDefault = dateRange.getEndDate();
|
|
|
123
|
+ if (endDateDefault.isBefore(today)) {
|
|
|
124
|
+ endDateDefault = today;
|
|
|
125
|
+ }
|
|
|
126
|
+ endDate = endDateDefault;
|
|
|
127
|
+ }
|
|
|
128
|
+ } else {
|
|
|
129
|
+ if (startDate == null) {
|
|
|
130
|
+ startDate = endDate;
|
|
|
131
|
+ }
|
|
|
132
|
+ if (endDate == null) {
|
|
|
133
|
+ endDate = startDate;
|
|
|
134
|
+ }
|
|
121
|
135
|
}
|
|
122
|
|
- LocalDate endDate = parseOrDefault(vo.getShipmentDateEnd(), endDateDefault);
|
|
|
136
|
+
|
|
123
|
137
|
if (startDate == null || endDate == null || endDate.isBefore(startDate)) {
|
|
124
|
138
|
return new ArrayList<>();
|
|
125
|
139
|
}
|
|
...
|
...
|
@@ -206,6 +220,48 @@ public class ShipmentQuantityIndustryStatisticsServiceImpl implements ShipmentQu |
|
206
|
220
|
return date + "|" + industry + "|" + workshopId;
|
|
207
|
221
|
}
|
|
208
|
222
|
|
|
|
223
|
+ private ShipmentQuantityStatisticsDateRangeDto queryDateRangeWithFallback(QueryShipmentQuantityIndustryStatisticsVo vo) {
|
|
|
224
|
+ ShipmentQuantityStatisticsDateRangeDto dateRange = shipmentQuantityIndustryStatisticsMapper.queryDateRange(vo);
|
|
|
225
|
+ if (dateRange != null && dateRange.getStartDate() != null && dateRange.getEndDate() != null) {
|
|
|
226
|
+ return dateRange;
|
|
|
227
|
+ }
|
|
|
228
|
+
|
|
|
229
|
+ String industry = vo.getIndustry();
|
|
|
230
|
+ String workshopId = vo.getWorkshopId();
|
|
|
231
|
+
|
|
|
232
|
+ if (StringUtils.isNotBlank(industry)) {
|
|
|
233
|
+ QueryShipmentQuantityIndustryStatisticsVo v = new QueryShipmentQuantityIndustryStatisticsVo();
|
|
|
234
|
+ v.setWorkshopId(workshopId);
|
|
|
235
|
+ dateRange = shipmentQuantityIndustryStatisticsMapper.queryDateRange(v);
|
|
|
236
|
+ if (dateRange != null && dateRange.getStartDate() != null && dateRange.getEndDate() != null) {
|
|
|
237
|
+ return dateRange;
|
|
|
238
|
+ }
|
|
|
239
|
+ }
|
|
|
240
|
+
|
|
|
241
|
+ if (StringUtils.isNotBlank(workshopId)) {
|
|
|
242
|
+ QueryShipmentQuantityIndustryStatisticsVo v = new QueryShipmentQuantityIndustryStatisticsVo();
|
|
|
243
|
+ v.setIndustry(industry);
|
|
|
244
|
+ dateRange = shipmentQuantityIndustryStatisticsMapper.queryDateRange(v);
|
|
|
245
|
+ if (dateRange != null && dateRange.getStartDate() != null && dateRange.getEndDate() != null) {
|
|
|
246
|
+ return dateRange;
|
|
|
247
|
+ }
|
|
|
248
|
+ }
|
|
|
249
|
+
|
|
|
250
|
+ QueryShipmentQuantityIndustryStatisticsVo v = new QueryShipmentQuantityIndustryStatisticsVo();
|
|
|
251
|
+ return shipmentQuantityIndustryStatisticsMapper.queryDateRange(v);
|
|
|
252
|
+ }
|
|
|
253
|
+
|
|
|
254
|
+ private static LocalDate parse(String dateStr) {
|
|
|
255
|
+ if (StringUtils.isBlank(dateStr)) {
|
|
|
256
|
+ return null;
|
|
|
257
|
+ }
|
|
|
258
|
+ try {
|
|
|
259
|
+ return LocalDate.parse(dateStr, DATE_FORMATTER);
|
|
|
260
|
+ } catch (Exception e) {
|
|
|
261
|
+ return null;
|
|
|
262
|
+ }
|
|
|
263
|
+ }
|
|
|
264
|
+
|
|
209
|
265
|
private static LocalDate parseOrDefault(String dateStr, LocalDate defaultValue) {
|
|
210
|
266
|
if (StringUtils.isBlank(dateStr)) {
|
|
211
|
267
|
return defaultValue;
|
...
|
...
|
|