|
|
@@ -284,6 +284,75 @@ public final class HomeScreenSupport
|
|
284
|
284
|
return list;
|
|
285
|
285
|
}
|
|
286
|
286
|
|
|
|
287
|
+ /**
|
|
|
288
|
+ * 线下服务预约:最近 12 个月堆叠柱(按时间升序,含 {@code statYear}、{@code month})。
|
|
|
289
|
+ */
|
|
|
290
|
+ public static List<HomeScreenAppointmentMonthVo> buildRolling12MonthAppointmentStacked(
|
|
|
291
|
+ List<HomeScreenAppointmentStatDto> rows, YearMonth anchor)
|
|
|
292
|
+ {
|
|
|
293
|
+ Map<Integer, Map<Integer, Integer>> byYmAndType = new HashMap<>();
|
|
|
294
|
+ if (rows != null)
|
|
|
295
|
+ {
|
|
|
296
|
+ for (HomeScreenAppointmentStatDto row : rows)
|
|
|
297
|
+ {
|
|
|
298
|
+ if (row.getStatYear() != null && row.getStatMonth() != null && row.getProviderType() != null)
|
|
|
299
|
+ {
|
|
|
300
|
+ int key = yearMonthKey(YearMonth.of(row.getStatYear(), row.getStatMonth()));
|
|
|
301
|
+ byYmAndType.computeIfAbsent(key, k -> new HashMap<>())
|
|
|
302
|
+ .put(row.getProviderType(), row.getCount() != null ? row.getCount() : 0);
|
|
|
303
|
+ }
|
|
|
304
|
+ }
|
|
|
305
|
+ }
|
|
|
306
|
+ List<HomeScreenAppointmentMonthVo> stacked = new ArrayList<>();
|
|
|
307
|
+ YearMonth start = anchor.minusMonths(11);
|
|
|
308
|
+ for (int slot = 0; slot < 12; slot++)
|
|
|
309
|
+ {
|
|
|
310
|
+ YearMonth ym = start.plusMonths(slot);
|
|
|
311
|
+ Map<Integer, Integer> types = byYmAndType.getOrDefault(yearMonthKey(ym), Collections.emptyMap());
|
|
|
312
|
+ HomeScreenAppointmentMonthVo point = new HomeScreenAppointmentMonthVo();
|
|
|
313
|
+ point.setStatYear(ym.getYear());
|
|
|
314
|
+ point.setMonth(ym.getMonthValue());
|
|
|
315
|
+ point.setVetCount(types.getOrDefault(PROVIDER_VET, 0));
|
|
|
316
|
+ point.setExpertCount(types.getOrDefault(PROVIDER_EXPERT, 0));
|
|
|
317
|
+ point.setOrgCount(types.getOrDefault(PROVIDER_ORG, 0));
|
|
|
318
|
+ stacked.add(point);
|
|
|
319
|
+ }
|
|
|
320
|
+ return stacked;
|
|
|
321
|
+ }
|
|
|
322
|
+
|
|
|
323
|
+ /**
|
|
|
324
|
+ * 实战培训报名:最近 12 个月活动数/报名人数(按时间升序,含 {@code statYear}、{@code month})。
|
|
|
325
|
+ */
|
|
|
326
|
+ public static List<HomeScreenTrainingMonthVo> buildRolling12MonthTraining(
|
|
|
327
|
+ List<HomeScreenTrainingMonthDto> rows, YearMonth anchor)
|
|
|
328
|
+ {
|
|
|
329
|
+ Map<Integer, HomeScreenTrainingMonthDto> byYm = new HashMap<>();
|
|
|
330
|
+ if (rows != null)
|
|
|
331
|
+ {
|
|
|
332
|
+ for (HomeScreenTrainingMonthDto row : rows)
|
|
|
333
|
+ {
|
|
|
334
|
+ if (row.getStatYear() != null && row.getStatMonth() != null)
|
|
|
335
|
+ {
|
|
|
336
|
+ byYm.put(yearMonthKey(YearMonth.of(row.getStatYear(), row.getStatMonth())), row);
|
|
|
337
|
+ }
|
|
|
338
|
+ }
|
|
|
339
|
+ }
|
|
|
340
|
+ List<HomeScreenTrainingMonthVo> monthly = new ArrayList<>();
|
|
|
341
|
+ YearMonth start = anchor.minusMonths(11);
|
|
|
342
|
+ for (int slot = 0; slot < 12; slot++)
|
|
|
343
|
+ {
|
|
|
344
|
+ YearMonth ym = start.plusMonths(slot);
|
|
|
345
|
+ HomeScreenTrainingMonthDto src = byYm.get(yearMonthKey(ym));
|
|
|
346
|
+ HomeScreenTrainingMonthVo point = new HomeScreenTrainingMonthVo();
|
|
|
347
|
+ point.setStatYear(ym.getYear());
|
|
|
348
|
+ point.setMonth(ym.getMonthValue());
|
|
|
349
|
+ point.setActivityCount(src != null && src.getActivityCount() != null ? src.getActivityCount() : 0);
|
|
|
350
|
+ point.setEnrolledCount(src != null && src.getEnrolledCount() != null ? src.getEnrolledCount() : 0);
|
|
|
351
|
+ monthly.add(point);
|
|
|
352
|
+ }
|
|
|
353
|
+ return monthly;
|
|
|
354
|
+ }
|
|
|
355
|
+
|
|
287
|
356
|
/**
|
|
288
|
357
|
* 公母牛月度存栏趋势(存栏填报表 {@code bull_total}/{@code cow_total} 全县按月合计);当前年未来月份填 0。
|
|
289
|
358
|
*/
|
|
|
@@ -457,8 +526,8 @@ public final class HomeScreenSupport
|
|
457
|
526
|
|
|
458
|
527
|
public static HomeScreenAppointmentVo buildAppointment(
|
|
459
|
528
|
List<HomeScreenAppointmentStatDto> annualRows,
|
|
460
|
|
- List<HomeScreenAppointmentStatDto> monthlyRows,
|
|
461
|
|
- LocalDate statDate)
|
|
|
529
|
+ List<HomeScreenAppointmentStatDto> rollingMonthlyRows,
|
|
|
530
|
+ YearMonth anchor)
|
|
462
|
531
|
{
|
|
463
|
532
|
int vet = 0;
|
|
464
|
533
|
int expert = 0;
|
|
|
@@ -485,45 +554,11 @@ public final class HomeScreenSupport
|
|
485
|
554
|
}
|
|
486
|
555
|
}
|
|
487
|
556
|
}
|
|
488
|
|
- Map<String, Integer> monthlyMap = new HashMap<>();
|
|
489
|
|
- if (monthlyRows != null)
|
|
490
|
|
- {
|
|
491
|
|
- for (HomeScreenAppointmentStatDto row : monthlyRows)
|
|
492
|
|
- {
|
|
493
|
|
- if (row.getMonth() == null || row.getProviderType() == null || row.getCount() == null)
|
|
494
|
|
- {
|
|
495
|
|
- continue;
|
|
496
|
|
- }
|
|
497
|
|
- monthlyMap.put(row.getMonth() + ":" + row.getProviderType(), row.getCount());
|
|
498
|
|
- }
|
|
499
|
|
- }
|
|
500
|
|
- int futureAfter = statDate.getMonthValue();
|
|
501
|
|
- boolean currentYear = statDate.getYear()
|
|
502
|
|
- == LocalDate.now(ZoneId.of(BreedingIndustryRules.ZONE_SHANGHAI)).getYear();
|
|
503
|
|
- List<HomeScreenAppointmentMonthVo> stacked = new ArrayList<>();
|
|
504
|
|
- for (int month = 1; month <= 12; month++)
|
|
505
|
|
- {
|
|
506
|
|
- HomeScreenAppointmentMonthVo point = new HomeScreenAppointmentMonthVo();
|
|
507
|
|
- point.setMonth(month);
|
|
508
|
|
- if (currentYear && month > futureAfter)
|
|
509
|
|
- {
|
|
510
|
|
- point.setVetCount(0);
|
|
511
|
|
- point.setExpertCount(0);
|
|
512
|
|
- point.setOrgCount(0);
|
|
513
|
|
- }
|
|
514
|
|
- else
|
|
515
|
|
- {
|
|
516
|
|
- point.setVetCount(monthlyMap.getOrDefault(month + ":" + PROVIDER_VET, 0));
|
|
517
|
|
- point.setExpertCount(monthlyMap.getOrDefault(month + ":" + PROVIDER_EXPERT, 0));
|
|
518
|
|
- point.setOrgCount(monthlyMap.getOrDefault(month + ":" + PROVIDER_ORG, 0));
|
|
519
|
|
- }
|
|
520
|
|
- stacked.add(point);
|
|
521
|
|
- }
|
|
522
|
557
|
HomeScreenAppointmentVo vo = new HomeScreenAppointmentVo();
|
|
523
|
558
|
vo.setAnnualVetCount(vet);
|
|
524
|
559
|
vo.setAnnualExpertCount(expert);
|
|
525
|
560
|
vo.setAnnualOrgCount(org);
|
|
526
|
|
- vo.setMonthlyStacked(stacked);
|
|
|
561
|
+ vo.setMonthlyStacked(buildRolling12MonthAppointmentStacked(rollingMonthlyRows, anchor));
|
|
527
|
562
|
return vo;
|
|
528
|
563
|
}
|
|
529
|
564
|
|
|
|
@@ -571,44 +606,16 @@ public final class HomeScreenSupport
|
|
571
|
606
|
}
|
|
572
|
607
|
|
|
573
|
608
|
public static HomeScreenTrainingTrendVo buildTrainingTrend(
|
|
574
|
|
- List<HomeScreenTrainingMonthDto> rows, boolean hasTrainingData, LocalDate statDate)
|
|
|
609
|
+ List<HomeScreenTrainingMonthDto> rollingRows, boolean hasTrainingData, YearMonth anchor)
|
|
575
|
610
|
{
|
|
576
|
|
- Map<Integer, HomeScreenTrainingMonthDto> byMonth = new HashMap<>();
|
|
577
|
|
- if (rows != null)
|
|
|
611
|
+ List<HomeScreenTrainingMonthVo> monthly = buildRolling12MonthTraining(rollingRows, anchor);
|
|
|
612
|
+ if (!hasTrainingData)
|
|
578
|
613
|
{
|
|
579
|
|
- for (HomeScreenTrainingMonthDto row : rows)
|
|
580
|
|
- {
|
|
581
|
|
- if (row.getMonth() != null)
|
|
582
|
|
- {
|
|
583
|
|
- byMonth.put(row.getMonth(), row);
|
|
584
|
|
- }
|
|
585
|
|
- }
|
|
586
|
|
- }
|
|
587
|
|
- int futureAfter = statDate.getMonthValue();
|
|
588
|
|
- boolean currentYear = statDate.getYear()
|
|
589
|
|
- == LocalDate.now(ZoneId.of(BreedingIndustryRules.ZONE_SHANGHAI)).getYear();
|
|
590
|
|
- List<HomeScreenTrainingMonthVo> monthly = new ArrayList<>();
|
|
591
|
|
- for (int month = 1; month <= 12; month++)
|
|
592
|
|
- {
|
|
593
|
|
- HomeScreenTrainingMonthVo point = new HomeScreenTrainingMonthVo();
|
|
594
|
|
- point.setMonth(month);
|
|
595
|
|
- if (!hasTrainingData)
|
|
|
614
|
+ for (HomeScreenTrainingMonthVo point : monthly)
|
|
596
|
615
|
{
|
|
597
|
616
|
point.setActivityCount(0);
|
|
598
|
617
|
point.setEnrolledCount(0);
|
|
599
|
618
|
}
|
|
600
|
|
- else if (currentYear && month > futureAfter)
|
|
601
|
|
- {
|
|
602
|
|
- point.setActivityCount(0);
|
|
603
|
|
- point.setEnrolledCount(0);
|
|
604
|
|
- }
|
|
605
|
|
- else
|
|
606
|
|
- {
|
|
607
|
|
- HomeScreenTrainingMonthDto src = byMonth.get(month);
|
|
608
|
|
- point.setActivityCount(src != null && src.getActivityCount() != null ? src.getActivityCount() : 0);
|
|
609
|
|
- point.setEnrolledCount(src != null && src.getEnrolledCount() != null ? src.getEnrolledCount() : 0);
|
|
610
|
|
- }
|
|
611
|
|
- monthly.add(point);
|
|
612
|
619
|
}
|
|
613
|
620
|
HomeScreenTrainingTrendVo vo = new HomeScreenTrainingTrendVo();
|
|
614
|
621
|
vo.setHasTrainingData(hasTrainingData);
|