|
@@ -50,8 +50,9 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
|
|
|
public List<IndexBaseDto> getIndexBaseData(String dataTypesStr, String organIdsStr, String startMonth, String endMonth) {
|
|
|
List<IndexBaseDto> result = new ArrayList<>();
|
|
|
|
|
|
+ LocalDate nowDateTime = LocalDate.now();
|
|
|
+ nowDateTime.withDayOfMonth(1);
|
|
|
if(StringUtils.isBlank(startMonth)){
|
|
|
- LocalDateTime nowDateTime = LocalDateTime.now();
|
|
|
startMonth = nowDateTime.getYear() + "-01";
|
|
|
endMonth = null;
|
|
|
}
|
|
@@ -69,8 +70,27 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ LocalDate startMonthDate = LocalDate.parse(startMonth + "-01", DateUtil.dateFormatter);
|
|
|
+
|
|
|
Map<IndexDataType, List<IndexBaseMonthData>> typeDateMap = indexBaseDatas.stream().collect(Collectors.groupingBy(IndexBaseMonthData::getDataType));
|
|
|
for (Map.Entry<IndexDataType, List<IndexBaseMonthData>> typeDateMapEntry : typeDateMap.entrySet()) {
|
|
|
+ Set<String> hasMonths = typeDateMapEntry.getValue().stream().map(d -> DateUtil.dateToString(d.getMonth(), "%Y-%m-%d")).collect(Collectors.toSet());
|
|
|
+ LocalDate currentMonthDate = startMonthDate;
|
|
|
+ while (currentMonthDate.compareTo(nowDateTime)<=0){
|
|
|
+ if(hasMonths.contains(currentMonthDate.toString())){
|
|
|
+ currentMonthDate = currentMonthDate.plusMonths(1);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ IndexBaseMonthData indexBaseMonthData = new IndexBaseMonthData();
|
|
|
+ indexBaseMonthData.setMonth(Date.from(currentMonthDate.atStartOfDay(DateUtil.zoneId).toInstant()));
|
|
|
+ indexBaseMonthData.setTotalNum(BigDecimal.ONE);
|
|
|
+ indexBaseMonthData.setActivateNum(BigDecimal.ZERO);
|
|
|
+ indexBaseMonthData.setPercent(BigDecimal.ZERO);
|
|
|
+ indexBaseMonthData.setDataType(typeDateMapEntry.getKey());
|
|
|
+ typeDateMapEntry.getValue().add(indexBaseMonthData);
|
|
|
+ currentMonthDate = currentMonthDate.plusMonths(1);
|
|
|
+ }
|
|
|
+ typeDateMapEntry.getValue().sort(Comparator.comparing(IndexBaseMonthData::getMonth));
|
|
|
if(IndexDataType.ACTIVATION_RATE.equals(typeDateMapEntry.getKey())||IndexDataType.HOMEWORK_CREATE_RATE.equals(typeDateMapEntry.getKey())
|
|
|
||IndexDataType.HOMEWORK_SUBMIT_RATE.equals(typeDateMapEntry.getKey())||IndexDataType.HOMEWORK_SUBMIT_RATE.equals(typeDateMapEntry.getKey())
|
|
|
||IndexDataType.STUDENT_CONVERSION.equals(typeDateMapEntry.getKey())){
|