|
@@ -20,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.DateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
@@ -50,8 +51,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 +71,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(), "yyyy-MM-dd")).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())){
|
|
@@ -88,7 +109,7 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public Map<String, List<IndexBaseDto>> indexBaseDataTask(String startMonth, String endMonth) {
|
|
|
+ public Map<String, List<IndexBaseDto>> indexBaseDataTask(String month) {
|
|
|
Map<String, List<IndexBaseDto>> result = new HashMap<>();
|
|
|
|
|
|
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM");
|
|
@@ -100,42 +121,42 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
|
|
|
this.organIds.get().addAll(allOrgans.stream().map(Organization::getId).collect(Collectors.toSet()));
|
|
|
}
|
|
|
|
|
|
- startMonth = df.format(nowDate);
|
|
|
+ month = df.format(nowDate);
|
|
|
|
|
|
//运营数据
|
|
|
- saveData(indexBaseMonthDataDao.getSchoolData(), startMonth, IndexDataType.SCHOOL);
|
|
|
- saveData(indexBaseMonthDataDao.getMusicData(), startMonth, IndexDataType.MUSIC_GROUP_NUM);
|
|
|
- saveData(indexBaseMonthDataDao.getMusicStudentData(null), startMonth, IndexDataType.MUSIC_GROUP_STUDENT);
|
|
|
- saveData(indexBaseMonthDataDao.getOtherStudentData(), startMonth, IndexDataType.OTHER_STUDENT);
|
|
|
+ saveData(indexBaseMonthDataDao.getSchoolData(month), month, IndexDataType.SCHOOL);
|
|
|
+ saveData(indexBaseMonthDataDao.getMusicData(), month, IndexDataType.MUSIC_GROUP_NUM);
|
|
|
+ saveData(indexBaseMonthDataDao.getMusicStudentData(null), month, IndexDataType.MUSIC_GROUP_STUDENT);
|
|
|
+ saveData(indexBaseMonthDataDao.getOtherStudentData(), month, IndexDataType.OTHER_STUDENT);
|
|
|
|
|
|
//业务数据
|
|
|
- saveData(indexBaseMonthDataDao.getStudentSignUpData(), startMonth, IndexDataType.ACTIVATION_RATE);
|
|
|
- saveData(indexBaseMonthDataDao.getHomeworkData(null), startMonth, IndexDataType.HOMEWORK_CREATE_RATE);
|
|
|
- saveData(indexBaseMonthDataDao.getHomeworkData("submit"), startMonth, IndexDataType.HOMEWORK_SUBMIT_RATE);
|
|
|
- saveData(indexBaseMonthDataDao.getHomeworkData("comment"), startMonth, IndexDataType.HOMEWORK_COMMENT_RATE);
|
|
|
+ saveData(indexBaseMonthDataDao.getStudentSignUpData(), month, IndexDataType.ACTIVATION_RATE);
|
|
|
+ saveData(indexBaseMonthDataDao.getHomeworkData(null), month, IndexDataType.HOMEWORK_CREATE_RATE);
|
|
|
+ saveData(indexBaseMonthDataDao.getHomeworkData("submit"), month, IndexDataType.HOMEWORK_SUBMIT_RATE);
|
|
|
+ saveData(indexBaseMonthDataDao.getHomeworkData("comment"), month, IndexDataType.HOMEWORK_COMMENT_RATE);
|
|
|
|
|
|
//经营数据
|
|
|
- saveData(null, startMonth, IndexDataType.SHOULD_INCOME_MONEY);
|
|
|
- saveData(null, startMonth, IndexDataType.ANTICIPATED_INCOME_MONEY);
|
|
|
- saveData(null, startMonth, IndexDataType.SHOULD_EXPEND_MONEY);
|
|
|
- saveData(null, startMonth, IndexDataType.ANTICIPATED_EXPEND_MONEY);
|
|
|
- saveData(null, startMonth, IndexDataType.REVENUE_MONEY);
|
|
|
+ saveData(null, month, IndexDataType.SHOULD_INCOME_MONEY);
|
|
|
+ saveData(null, month, IndexDataType.ANTICIPATED_INCOME_MONEY);
|
|
|
+ saveData(null, month, IndexDataType.SHOULD_EXPEND_MONEY);
|
|
|
+ saveData(null, month, IndexDataType.ANTICIPATED_EXPEND_MONEY);
|
|
|
+ saveData(null, month, IndexDataType.REVENUE_MONEY);
|
|
|
|
|
|
//人事数据
|
|
|
- saveData(indexBaseMonthDataDao.getTeacherData(null, null), startMonth, IndexDataType.TEACHER_NUM);
|
|
|
- saveData(indexBaseMonthDataDao.getTeacherData(JobNatureEnum.FULL_TIME, null), startMonth, IndexDataType.FULL_TIME_NUM);
|
|
|
- saveData(indexBaseMonthDataDao.getTeacherData(JobNatureEnum.PART_TIME, null), startMonth, IndexDataType.PART_TIME_NUM);
|
|
|
- saveData(indexBaseMonthDataDao.getTeacherData(null, true), startMonth, IndexDataType.DIMISSION_NUM);
|
|
|
+ saveData(indexBaseMonthDataDao.getTeacherData(null, null), month, IndexDataType.TEACHER_NUM);
|
|
|
+ saveData(indexBaseMonthDataDao.getTeacherData(JobNatureEnum.FULL_TIME, null), month, IndexDataType.FULL_TIME_NUM);
|
|
|
+ saveData(indexBaseMonthDataDao.getTeacherData(JobNatureEnum.PART_TIME, null), month, IndexDataType.PART_TIME_NUM);
|
|
|
+ saveData(indexBaseMonthDataDao.getTeacherData(null, true), month, IndexDataType.DIMISSION_NUM);
|
|
|
|
|
|
//学员变动
|
|
|
- saveData(indexBaseMonthDataDao.getMusicStudentData("ALL"), startMonth, IndexDataType.NEWLY_STUDENT_NUM);
|
|
|
- saveData(indexBaseMonthDataDao.getMusicStudentData("QUIT"), startMonth, IndexDataType.QUIT_MUSIC_GROUP_STUDENT_NUM);
|
|
|
- saveData(indexBaseMonthDataDao.getStudentConversionData(), startMonth, IndexDataType.STUDENT_CONVERSION);
|
|
|
+ saveData(indexBaseMonthDataDao.getMusicStudentData("ALL"), month, IndexDataType.NEWLY_STUDENT_NUM);
|
|
|
+ saveData(indexBaseMonthDataDao.getMusicStudentData("QUIT"), month, IndexDataType.QUIT_MUSIC_GROUP_STUDENT_NUM);
|
|
|
+ saveData(indexBaseMonthDataDao.getStudentConversionData(), month, IndexDataType.STUDENT_CONVERSION);
|
|
|
|
|
|
//课程数据
|
|
|
- saveData(indexBaseMonthDataDao.getGroupCourseData(GroupType.MUSIC), startMonth, IndexDataType.MUSIC_GROUP_COURSE);
|
|
|
- saveData(indexBaseMonthDataDao.getGroupCourseData(GroupType.VIP), startMonth, IndexDataType.VIP_GROUP_COURSE);
|
|
|
- saveData(indexBaseMonthDataDao.getGroupCourseData(GroupType.PRACTICE), startMonth, IndexDataType.PRACTICE_GROUP_COURSE);
|
|
|
+ saveData(indexBaseMonthDataDao.getGroupCourseData(GroupType.MUSIC), month, IndexDataType.MUSIC_GROUP_COURSE);
|
|
|
+ saveData(indexBaseMonthDataDao.getGroupCourseData(GroupType.VIP), month, IndexDataType.VIP_GROUP_COURSE);
|
|
|
+ saveData(indexBaseMonthDataDao.getGroupCourseData(GroupType.PRACTICE), month, IndexDataType.PRACTICE_GROUP_COURSE);
|
|
|
|
|
|
return result;
|
|
|
}
|