|
@@ -46,15 +46,19 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<IndexBaseDto> getIndexBaseData(String dataTypesStr, String organIdsStr, String startMonth, String endMonth) {
|
|
|
+ public List<IndexBaseDto> getIndexBaseData(String dataTypesStr, String organIdsStr, Integer year) {
|
|
|
List<IndexBaseDto> result = new ArrayList<>();
|
|
|
|
|
|
- LocalDate nowDateTime = LocalDate.now();
|
|
|
- nowDateTime.withDayOfMonth(1);
|
|
|
- if(StringUtils.isBlank(startMonth)){
|
|
|
- startMonth = nowDateTime.getYear() + "-01";
|
|
|
- endMonth = null;
|
|
|
+ DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM");
|
|
|
+ LocalDate startDate = LocalDate.now();
|
|
|
+ if(Objects.nonNull(year)){
|
|
|
+ startDate = startDate.withYear(year);
|
|
|
}
|
|
|
+ startDate = startDate.withMonth(1);
|
|
|
+ startDate = startDate.withDayOfMonth(1);
|
|
|
+
|
|
|
+ LocalDate endDate = startDate.withMonth(12);
|
|
|
+
|
|
|
Set<Integer> organIds = null;
|
|
|
if(StringUtils.isNotBlank(organIdsStr)){
|
|
|
organIds = Arrays.stream(organIdsStr.split(",")).map(Integer::new).collect(Collectors.toSet());
|
|
@@ -64,18 +68,16 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
|
|
|
dataTypes = Arrays.stream(dataTypesStr.split(",")).collect(Collectors.toSet());
|
|
|
}
|
|
|
|
|
|
- List<IndexBaseMonthData> indexBaseDatas = indexBaseMonthDataDao.getIndexBaseData(organIds, dataTypes, startMonth, endMonth);
|
|
|
+ List<IndexBaseMonthData> indexBaseDatas = indexBaseMonthDataDao.getIndexBaseData(organIds, dataTypes, df.format(startDate), df.format(endDate));
|
|
|
if(CollectionUtils.isEmpty(indexBaseDatas)){
|
|
|
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(), "yyyy-MM-dd")).collect(Collectors.toSet());
|
|
|
- LocalDate currentMonthDate = startMonthDate;
|
|
|
- while (currentMonthDate.compareTo(nowDateTime)<=0){
|
|
|
+ LocalDate currentMonthDate = startDate;
|
|
|
+ while (currentMonthDate.compareTo(endDate)<=0){
|
|
|
if(hasMonths.contains(currentMonthDate.toString())){
|
|
|
currentMonthDate = currentMonthDate.plusMonths(1);
|
|
|
continue;
|