|
@@ -6,6 +6,7 @@ import com.ym.mec.biz.dal.entity.Organization;
|
|
|
import com.ym.mec.biz.dal.enums.GroupType;
|
|
|
import com.ym.mec.biz.dal.enums.IndexDataType;
|
|
|
import com.ym.mec.biz.dal.enums.JobNatureEnum;
|
|
|
+import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
|
|
|
import com.ym.mec.common.constant.CommonConstants;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
@@ -19,6 +20,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
+import javax.xml.crypto.Data;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
@@ -111,7 +113,7 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
|
|
|
indexBaseData.setIndexMonthData(typeDateMapEntry.getValue(), currentMonth);
|
|
|
result.add(indexBaseData);
|
|
|
}
|
|
|
-
|
|
|
+ countStudentConvertData(result, currentMonth);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -161,7 +163,15 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
|
|
|
//学员变动
|
|
|
saveData(indexBaseMonthDataDao.getMusicStudentData(month, "ALL"), month, IndexDataType.NEWLY_STUDENT_NUM);
|
|
|
saveData(indexBaseMonthDataDao.getMusicStudentData(month, "QUIT"), month, IndexDataType.QUIT_MUSIC_GROUP_STUDENT_NUM);
|
|
|
- saveData(indexBaseMonthDataDao.getStudentConversionData(month), month, IndexDataType.STUDENT_CONVERSION);
|
|
|
+ saveData(indexBaseMonthDataDao.getMusicGroupPreRegistrationStudentData(month), month, IndexDataType.STUDENT_CONVERSION_PRE_STUDENT_NUM);
|
|
|
+ saveData(indexBaseMonthDataDao.getMusicGroupStudentFromPreData(month, null), month, IndexDataType.STUDENT_CONVERSION_STUDENT_NUM);
|
|
|
+ saveData(indexBaseMonthDataDao.getMusicGroupStudentFromPreData(month, PaymentStatusEnum.YES), month, IndexDataType.STUDENT_CONVERSION_PAYMENT_STUDENT_NUM);
|
|
|
+ List<Integer> studentIds = indexBaseMonthDataDao.getMusicGroupStudentIdFromPre(month, PaymentStatusEnum.YES);
|
|
|
+ List<IndexBaseMonthData> convertStudentNum = new ArrayList<>();
|
|
|
+ if(!CollectionUtils.isEmpty(studentIds)){
|
|
|
+ convertStudentNum = indexBaseMonthDataDao.getStudentConversionData(month, studentIds);
|
|
|
+ }
|
|
|
+ saveData(convertStudentNum, month, IndexDataType.STUDENT_CONVERSION_VIP_PRACTICE_STUDENT_NUM);
|
|
|
|
|
|
//课程数据
|
|
|
saveData(indexBaseMonthDataDao.getGroupCourseData(month, GroupType.MUSIC), month, IndexDataType.MUSIC_GROUP_COURSE);
|
|
@@ -171,6 +181,85 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ private void countStudentConvertData(List<IndexBaseDto> result, Date currentMonth){
|
|
|
+ List<IndexBaseMonthData> convertData = new ArrayList<>();
|
|
|
+
|
|
|
+ Map<IndexDataType, IndexBaseDto> typeDataMap = result.stream().collect(Collectors.toMap(IndexBaseDto::getDataType, i -> i, (i1, i2) -> i1));
|
|
|
+ List<IndexBaseMonthData> preStudentNum = typeDataMap.get(IndexDataType.STUDENT_CONVERSION_PRE_STUDENT_NUM).getIndexMonthData();
|
|
|
+
|
|
|
+ IndexBaseMonthData preStudentNumData = new IndexBaseMonthData();
|
|
|
+ preStudentNumData.setMonth(currentMonth);
|
|
|
+ preStudentNumData.setDataType(IndexDataType.STUDENT_CONVERSION_PRE_STUDENT_NUM);
|
|
|
+ preStudentNumData.setTotalNum(preStudentNum.stream().map(IndexBaseMonthData::getTotalNum).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ preStudentNumData.setActivateNum(preStudentNum.stream().map(IndexBaseMonthData::getActivateNum).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+
|
|
|
+ List<IndexBaseMonthData> studentNum = typeDataMap.get(IndexDataType.STUDENT_CONVERSION_STUDENT_NUM).getIndexMonthData();
|
|
|
+
|
|
|
+ IndexBaseMonthData studentNumData = new IndexBaseMonthData();
|
|
|
+ studentNumData.setMonth(currentMonth);
|
|
|
+ studentNumData.setDataType(IndexDataType.STUDENT_CONVERSION_STUDENT_NUM);
|
|
|
+ studentNumData.setTotalNum(studentNum.stream().map(IndexBaseMonthData::getTotalNum).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ studentNumData.setActivateNum(studentNum.stream().map(IndexBaseMonthData::getActivateNum).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+
|
|
|
+ List<IndexBaseMonthData> paymentStudentNum = typeDataMap.get(IndexDataType.STUDENT_CONVERSION_PAYMENT_STUDENT_NUM).getIndexMonthData();
|
|
|
+
|
|
|
+ IndexBaseMonthData paymentStudentNumData = new IndexBaseMonthData();
|
|
|
+ paymentStudentNumData.setMonth(currentMonth);
|
|
|
+ paymentStudentNumData.setDataType(IndexDataType.STUDENT_CONVERSION_PAYMENT_STUDENT_NUM);
|
|
|
+ paymentStudentNumData.setTotalNum(paymentStudentNum.stream().map(IndexBaseMonthData::getTotalNum).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ paymentStudentNumData.setActivateNum(paymentStudentNum.stream().map(IndexBaseMonthData::getActivateNum).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+
|
|
|
+ List<IndexBaseMonthData> convertStudentNum = typeDataMap.get(IndexDataType.STUDENT_CONVERSION_VIP_PRACTICE_STUDENT_NUM).getIndexMonthData();
|
|
|
+
|
|
|
+ IndexBaseMonthData convertStudentNumData = new IndexBaseMonthData();
|
|
|
+ convertStudentNumData.setMonth(currentMonth);
|
|
|
+ convertStudentNumData.setDataType(IndexDataType.STUDENT_CONVERSION_VIP_PRACTICE_STUDENT_NUM);
|
|
|
+ convertStudentNumData.setTotalNum(convertStudentNum.stream().map(IndexBaseMonthData::getTotalNum).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ convertStudentNumData.setActivateNum(convertStudentNum.stream().map(IndexBaseMonthData::getActivateNum).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+
|
|
|
+ if(preStudentNumData.getActivateNum().compareTo(BigDecimal.ZERO)==0){
|
|
|
+ studentNumData.setPercent(BigDecimal.ZERO);
|
|
|
+ paymentStudentNumData.setPercent(BigDecimal.ZERO);
|
|
|
+ convertStudentNumData.setPercent(BigDecimal.ZERO);
|
|
|
+ }else{
|
|
|
+ studentNumData.setPercent(studentNumData.getActivateNum().divide(preStudentNumData.getActivateNum()).multiply(new BigDecimal(100)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN));
|
|
|
+ if(studentNumData.getActivateNum().compareTo(BigDecimal.ZERO)==0){
|
|
|
+ paymentStudentNumData.setPercent(BigDecimal.ZERO);
|
|
|
+ convertStudentNumData.setPercent(BigDecimal.ZERO);
|
|
|
+ }else{
|
|
|
+ paymentStudentNumData.setPercent(paymentStudentNumData.getActivateNum().divide(studentNumData.getActivateNum()).multiply(new BigDecimal(100)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN));
|
|
|
+ if(paymentStudentNumData.getActivateNum().compareTo(BigDecimal.ZERO)==0){
|
|
|
+ convertStudentNumData.setPercent(BigDecimal.ZERO);
|
|
|
+ }else{
|
|
|
+ convertStudentNumData.setPercent(convertStudentNumData.getActivateNum().divide(paymentStudentNumData.getActivateNum()).multiply(new BigDecimal(100)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ convertData.add(preStudentNumData);
|
|
|
+ convertData.add(studentNumData);
|
|
|
+ convertData.add(paymentStudentNumData);
|
|
|
+ convertData.add(convertStudentNumData);
|
|
|
+ IndexBaseDto indexBaseData = new IndexBaseDto(IndexDataType.STUDENT_CONVERSION, IndexDataType.STUDENT_CONVERSION.getMsg());
|
|
|
+ indexBaseData.setIndexMonthData(convertData, currentMonth);
|
|
|
+ result.add(indexBaseData);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void fillEmptyOrganData(List<IndexBaseMonthData> dataList, String startMonth){
|
|
|
+ startMonth = startMonth+"-01";
|
|
|
+ Date date = DateUtil.stringToDate(startMonth, "yyyy-MM-dd");
|
|
|
+ if(Objects.isNull(dataList)){
|
|
|
+ dataList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ Set<Integer> hasOrganIds = dataList.stream().map(IndexBaseMonthData::getOrganId).collect(Collectors.toSet());
|
|
|
+ for (Integer organId : this.organIds.get()) {
|
|
|
+ if(hasOrganIds.contains(organId)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ dataList.add(new IndexBaseMonthData(date, organId));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @describe 处理并保存每月数据
|
|
|
* @author Joburgess
|