浏览代码

feat:首页数据调整

Joburgess 4 年之前
父节点
当前提交
7217e08d4a

+ 35 - 5
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/IndexBaseMonthDataDao.java

@@ -1,10 +1,7 @@
 package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.biz.dal.entity.IndexBaseMonthData;
-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.biz.dal.enums.*;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 import org.apache.poi.ss.formula.functions.Index;
@@ -39,6 +36,33 @@ public interface IndexBaseMonthDataDao extends BaseDAO<Long, IndexBaseMonthData>
                                               @Param("startMonth") String startMonth,
                                               @Param("endMonth") String endMonth);
 
+	/**
+	 * @describe 统计学员注册数据
+	 * @author Joburgess
+	 * @date 2021/2/24 0024
+	 * @param dayStr:
+	 * @return java.util.List<com.ym.mec.biz.dal.entity.IndexBaseMonthData>
+	 */
+	List<IndexBaseMonthData> getStudentRegistrationData(@Param("dayStr") String dayStr);
+
+	/**
+	 * @describe 统计新增学员注册数据
+	 * @author Joburgess
+	 * @date 2021/2/24 0024
+	 * @param dayStr:
+	 * @return java.util.List<com.ym.mec.biz.dal.entity.IndexBaseMonthData>
+	 */
+	List<IndexBaseMonthData> getAddStudentRegistrationData(@Param("dayStr") String dayStr);
+
+	/**
+	 * @describe 付费转化率
+	 * @author Joburgess
+	 * @date 2021/2/24 0024
+	 * @param dayStr:
+	 * @return java.util.List<com.ym.mec.biz.dal.entity.IndexBaseMonthData>
+	 */
+	List<IndexBaseMonthData> getChargeStudentChangeData(@Param("dayStr") String dayStr);
+
     /**
      * @describe 统计系统中指定时间段的学员注册数据
      * @author Joburgess
@@ -94,13 +118,19 @@ public interface IndexBaseMonthDataDao extends BaseDAO<Long, IndexBaseMonthData>
 
     List<IndexBaseMonthData> getOtherStudentData(@Param("dayStr") String dayStr);
 
+    List<IndexBaseMonthData> getVipPracticeAddStudentData(@Param("dayStr") String dayStr);
+
     List<IndexBaseMonthData> getTeacherData(@Param("dayStr") String dayStr,
                                             @Param("jobNature") JobNatureEnum jobNature,
                                             @Param("isDemission") Boolean isDemission);
 
     List<IndexBaseMonthData> getGroupCourseData(@Param("dayStr") String dayStr,
-                                                @Param("groupType")GroupType groupType);
+                                                @Param("groupType")GroupType groupType,
+                                                @Param("courseStatus") CourseStatusEnum courseStatus);
 
+    List<IndexBaseMonthData> getGroupSurplusCourseData(@Param("dayStr") String dayStr,
+                                                @Param("groupType")GroupType groupType,
+                                                @Param("courseStatus") CourseStatusEnum courseStatus);
 
     int countLessThenThreeClassGroupNum(@Param("organIds") Set<Integer> organIds);
     List<String> getLessThenThreeMusicGroup(@Param("organIds") Set<Integer> organIds);

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/IndexBaseDto.java

@@ -75,7 +75,7 @@ public class IndexBaseDto {
         this.indexMonthData = indexMonthData;
         if(!CollectionUtils.isEmpty(indexMonthData)){
             BigDecimal total = indexMonthData.stream().map(IndexBaseMonthData::getTotalNum).reduce(BigDecimal.ZERO, BigDecimal::add);
-            if(IndexDataType.ACTIVATION_RATE.equals(dataType)){
+            if(dataType.getCollect()){
                 if(total.compareTo(BigDecimal.ZERO)==0){
                     this.percent = BigDecimal.ZERO;
                 }else{

+ 63 - 37
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/IndexDataType.java

@@ -7,50 +7,68 @@ import com.ym.mec.common.enums.BaseEnum;
  * @Date 2021/1/8 0008
  **/
 public enum IndexDataType implements BaseEnum<String, IndexDataType> {
-    SCHOOL("SCHOOL","合作单位"),
-    MUSIC_GROUP_NUM("MUSIC_GROUP_NUM","乐团数量"),
-    MUSIC_GROUP_STUDENT("MUSIC_GROUP_STUDENT","乐团学员"),
-    OTHER_STUDENT("OTHER_STUDENT","其他学员"),
-
-    ACTIVATION_RATE("ACTIVATION_RATE","激活率"),
-    HOMEWORK_CREATE_RATE("HOMEWORK_CREATE_RATE","作业布置率"),
-    HOMEWORK_SUBMIT_RATE("HOMEWORK_SUBMIT_RATE","作业提交率"),
-    HOMEWORK_COMMENT_RATE("HOMEWORK_COMMENT_RATE","作业点评率"),
-
-    SHOULD_INCOME_MONEY("SHOULD_INCOME_MONEY","应收金额"),
-    ANTICIPATED_INCOME_MONEY("ANTICIPATED_INCOME_MONEY","预收金额"),
-    SHOULD_EXPEND_MONEY("SHOULD_EXPEND_MONEY","预付金额"),
-    ANTICIPATED_EXPEND_MONEY("ANTICIPATED_EXPEND_MONEY","应付金额"),
-    REVENUE_MONEY("REVENUE_MONEY","营收金额"),
-
-    TEACHER_NUM("TEACHER_NUM","老师总数"),
-    FULL_TIME_NUM("FULL_TIME_NUM","全职人数"),
-    PART_TIME_NUM("PART_TIME_NUM","兼职人数"),
-    DIMISSION_NUM("DIMISSION_NUM","离职人数"),
-
-    NEWLY_STUDENT_NUM("NEWLY_STUDENT_NUM","乐团新增学员"),
-    QUIT_MUSIC_GROUP_STUDENT_NUM("QUIT_MUSIC_GROUP_STUDENT_NUM","退团学员"),
-    STUDENT_CONVERSION("STUDENT_CONVERSION","学员转化"),
-    STUDENT_CONVERSION_PRE_STUDENT_NUM("STUDENT_CONVERSION_PRE_STUDENT_NUM","预报名人数"),
-    STUDENT_CONVERSION_STUDENT_NUM("STUDENT_CONVERSION_STUDENT_NUM","报名人数"),
-    STUDENT_CONVERSION_PAYMENT_STUDENT_NUM("STUDENT_CONVERSION_PAYMENT_STUDENT_NUM","报名缴费"),
-    STUDENT_CONVERSION_VIP_PRACTICE_STUDENT_NUM("STUDENT_CONVERSION_VIP_PRACTICE_STUDENT_NUM","VIP/网管课购买"),
-
-    MUSIC_GROUP_COURSE("MUSIC_GROUP_COURSE","乐团课"),
-    VIP_GROUP_COURSE("VIP_GROUP_COURSE","VIP课"),
-    PRACTICE_GROUP_COURSE("PRACTICE_GROUP_COURSE","网管课"),
-
-    FINANCE_PAY("FINANCE_PAY","财务支出"),
-    FINANCE_BALANCE_AMOUNT("FINANCE_BALANCE_AMOUNT","余额收入"),
-    FINANCE_AMOUNT("FINANCE_AMOUNT","现金收入");
+    //学员数据类型
+    STUDENT_REGISTRATION_NUM("STUDENT_REGISTRATION_NUM", "注册学员", false),
+    CHARGE_STUDENT_CHANGE_RATE("CHARGE_STUDENT_CHANGE_RATE", "付费转化率", false),
+    ACTIVATION_RATE("ACTIVATION_RATE","激活率", true),
+
+    //运营数据类型
+    SCHOOL("SCHOOL","合作单位", false),
+    PROGRESS_MUSIC_GROUP_NUM("PROGRESS_MUSIC_GROUP_NUM","进行中乐团", false),
+
+    //人事数据
+    TEACHER_NUM("TEACHER_NUM","老师总数", false),
+    FULL_TIME_NUM("FULL_TIME_NUM","全职人数", false),
+    PART_TIME_NUM("PART_TIME_NUM","兼职人数", false),
+
+    DIMISSION_NUM("DIMISSION_NUM","离职人数", false),
+
+    //剩余课时
+    SURPLUS_COURSE_NUM("SURPLUS_COURSE_NUM", "剩余课时总数", false),
+    SURPLUS_MUSIC_COURSE_NUM("SURPLUS_MUSIC_COURSE_NUM", "剩余乐团课时", false),
+    SURPLUS_VIP_COURSE_NUM("SURPLUS_VIP_COURSE_NUM", "剩余VIP课时", false),
+    SURPLUS_PRACTICE_COURSE_NUM("SURPLUS_PRACTICE_COURSE_NUM", "剩余网管课时", false),
+
+    //已消耗课时
+    OVER_COURSE_NUM("OVER_COURSE_NUM", "已消耗课时总数", false),
+    OVER_MUSIC_COURSE_NUM("OVER_MUSIC_COURSE_NUM", "已消耗乐团课时", false),
+    OVER_VIP_COURSE_NUM("OVER_VIP_COURSE_NUM", "已消耗VIP课时", false),
+    OVER_PRACTICE_COURSE_NUM("OVER_PRACTICE_COURSE_NUM", "已消耗网管课时", false),
+
+    //经营数据
+    FINANCE_PAY("FINANCE_PAY","财务支出", false),
+    FINANCE_BALANCE_AMOUNT("FINANCE_BALANCE_AMOUNT","余额收入", false),
+    FINANCE_AMOUNT("FINANCE_AMOUNT","现金收入", false),
+
+    //业务数据
+    HOMEWORK_CREATE_RATE("HOMEWORK_CREATE_RATE","作业布置率", true),
+    HOMEWORK_SUBMIT_RATE("HOMEWORK_SUBMIT_RATE","作业提交率", true),
+    HOMEWORK_COMMENT_RATE("HOMEWORK_COMMENT_RATE","作业点评率", true),
+
+    //课程数据
+    MUSIC_GROUP_COURSE("MUSIC_GROUP_COURSE","乐团课", false),
+    VIP_GROUP_COURSE("VIP_GROUP_COURSE","VIP课", false),
+    PRACTICE_GROUP_COURSE("PRACTICE_GROUP_COURSE","网管课", false),
+
+    //学员变动
+    ADD_STUDENT_REGISTRATION_NUM("ADD_STUDENT_REGISTRATION_NUM", "新增注册学员", false),
+    MUSIC_GROUP_STUDENT("MUSIC_GROUP_STUDENT","乐团在读学员", false),
+    NEWLY_STUDENT_NUM("NEWLY_STUDENT_NUM","乐团新增学员", false),
+    QUIT_MUSIC_GROUP_STUDENT_NUM("QUIT_MUSIC_GROUP_STUDENT_NUM","退团学员", false),
+    VIP_PRACTICE_STUDENT_NUM("VIP_PRACTICE_STUDENT_NUM", "VIP/网管在读", false),
+    VIP_PRACTICE_ADD_STUDENT_NUM("VIP_PRACTICE_ADD_STUDENT_NUM", "VIP/网管新增", false),
+    ;
 
     private String code;
 
     private String msg;
 
-    IndexDataType(String code, String msg) {
+    private Boolean collect;
+
+    IndexDataType(String code, String msg, Boolean collect) {
         this.code = code;
         this.msg = msg;
+        this.collect = collect;
     }
 
     @Override
@@ -69,4 +87,12 @@ public enum IndexDataType implements BaseEnum<String, IndexDataType> {
     public void setMsg(String msg) {
         this.msg = msg;
     }
+
+    public Boolean getCollect() {
+        return collect;
+    }
+
+    public void setCollect(Boolean collect) {
+        this.collect = collect;
+    }
 }

+ 48 - 0
mec-biz/src/main/java/com/ym/mec/biz/event/MusicGroupStatusChangeEvent.java

@@ -0,0 +1,48 @@
+package com.ym.mec.biz.event;
+
+import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
+import org.springframework.context.ApplicationEvent;
+
+/**
+ * @Author Joburgess
+ * @Date 2021/2/24 0024
+ */
+public class MusicGroupStatusChangeEvent extends ApplicationEvent {
+
+    private String musicGroupId;
+
+    private MusicGroupStatusEnum oldStatus;
+
+    private MusicGroupStatusEnum currentStatus;
+
+    public MusicGroupStatusChangeEvent(Object source, String musicGroupId, MusicGroupStatusEnum oldStatus, MusicGroupStatusEnum currentStatus) {
+        super(source);
+        this.musicGroupId = musicGroupId;
+        this.oldStatus = oldStatus;
+        this.currentStatus = currentStatus;
+    }
+
+    public String getMusicGroupId() {
+        return musicGroupId;
+    }
+
+    public void setMusicGroupId(String musicGroupId) {
+        this.musicGroupId = musicGroupId;
+    }
+
+    public MusicGroupStatusEnum getOldStatus() {
+        return oldStatus;
+    }
+
+    public void setOldStatus(MusicGroupStatusEnum oldStatus) {
+        this.oldStatus = oldStatus;
+    }
+
+    public MusicGroupStatusEnum getCurrentStatus() {
+        return currentStatus;
+    }
+
+    public void setCurrentStatus(MusicGroupStatusEnum currentStatus) {
+        this.currentStatus = currentStatus;
+    }
+}

+ 23 - 0
mec-biz/src/main/java/com/ym/mec/biz/event/listener/GroupEventListener.java

@@ -0,0 +1,23 @@
+package com.ym.mec.biz.event.listener;
+
+import com.ym.mec.biz.event.MusicGroupStatusChangeEvent;
+import org.springframework.context.event.EventListener;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Author Joburgess
+ * @Date 2021/2/24 0024
+ */
+@Component
+public class GroupEventListener {
+
+
+
+    @Async
+    @EventListener
+    public void musicGroupStatusChangeMonitor(MusicGroupStatusChangeEvent musicGroupStatusChangeEvent){
+
+    }
+
+}

+ 29 - 0
mec-biz/src/main/java/com/ym/mec/biz/event/source/GroupEventSource.java

@@ -0,0 +1,29 @@
+package com.ym.mec.biz.event.source;
+
+import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
+import com.ym.mec.biz.event.MusicGroupStatusChangeEvent;
+import org.springframework.context.ApplicationContext;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+/**
+ * @Author Joburgess
+ * @Date 2021/2/24 0024
+ */
+@Service
+public class GroupEventSource {
+
+    @Resource
+    private ApplicationContext applicationContext;
+
+    /**
+     * @describe
+     * @author Joburgess
+     * @date 2020.09.24
+     * @return void
+     */
+    public void musicGroupStatusChange(String musicGroupId, MusicGroupStatusEnum oldStatus, MusicGroupStatusEnum currentStatus) {
+        applicationContext.publishEvent(new MusicGroupStatusChangeEvent(this, musicGroupId, oldStatus, currentStatus));
+    }
+}

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/IndexBaseMonthDataService.java

@@ -14,7 +14,7 @@ public interface IndexBaseMonthDataService extends BaseService<Long, IndexBaseMo
 
     List<IndexBaseDto> getIndexBaseData(IndexDataQueryInfo indexDataQueryInfo);
 
-    Map<String, List<IndexBaseDto>> indexBaseDataTask(String month);
+    void indexBaseDataTask(String month);
 
     Map<String, Object> getIndexErrData(String organIds, IndexErrorType errorType);
 

+ 40 - 134
mec-biz/src/main/java/com/ym/mec/biz/service/impl/IndexBaseMonthDataServiceImpl.java

@@ -23,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
+import java.time.DayOfWeek;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
@@ -95,7 +96,7 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 			indexBaseDatas = new ArrayList<>();
 		}
 
-		Map<IndexDataType, List<IndexBaseMonthData>> typeDateMap = indexBaseDatas.stream().collect(Collectors.groupingBy(IndexBaseMonthData::getDataType));
+		Map<IndexDataType, List<IndexBaseMonthData>> typeDateMap = indexBaseDatas.stream().filter(d->Objects.nonNull(d.getDataType())).collect(Collectors.groupingBy(IndexBaseMonthData::getDataType));
 
 		for (IndexDataType dataType : IndexDataType.values()) {
 			if(typeDateMap.containsKey(dataType)){
@@ -129,9 +130,7 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 				currentMonthDate = currentMonthDate.plusDays(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_COMMENT_RATE.equals(typeDateMapEntry.getKey())
-					||IndexDataType.STUDENT_CONVERSION.equals(typeDateMapEntry.getKey())){
+			if(typeDateMapEntry.getKey().getCollect()){
 				for (IndexBaseMonthData indexBaseMonthData : typeDateMapEntry.getValue()) {
 					if(indexBaseMonthData.getTotalNum().compareTo(BigDecimal.ZERO)==0){
 						indexBaseMonthData.setPercent(BigDecimal.ZERO);
@@ -150,15 +149,12 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 			}
 			result.add(indexBaseData);
 		}
-		countStudentConvertData(result, currentMonth);
 		return result;
 	}
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public Map<String, List<IndexBaseDto>> indexBaseDataTask(String dayStr) {
-		Map<String, List<IndexBaseDto>> result = new HashMap<>();
-
+	public void indexBaseDataTask(String dayStr) {
 		LocalDate nowDate = LocalDate.now();
 
 		List<Organization> allOrgans = organizationDao.findAllOrgans();
@@ -171,149 +167,59 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 			dayStr = nowDate.plusDays(-1).toString();
 		}
 
-		//运营数据
-		saveData(indexBaseMonthDataDao.getSchoolData(dayStr), dayStr, IndexDataType.SCHOOL);
-		saveData(indexBaseMonthDataDao.getMusicData(dayStr), dayStr, IndexDataType.MUSIC_GROUP_NUM);
-		saveData(indexBaseMonthDataDao.getMusicStudentData(dayStr, null), dayStr, IndexDataType.MUSIC_GROUP_STUDENT);
-		saveData(indexBaseMonthDataDao.getOtherStudentData(dayStr), dayStr, IndexDataType.OTHER_STUDENT);
+		LocalDate day = LocalDate.parse(dayStr, DateUtil.dateFormatter);
+		LocalDate monday = day.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.MONDAY.getValue());
 
-		//业务数据
+		//学员数据
+		saveData(indexBaseMonthDataDao.getStudentRegistrationData(dayStr), dayStr, IndexDataType.STUDENT_REGISTRATION_NUM);
+		saveData(indexBaseMonthDataDao.getChargeStudentChangeData(dayStr), dayStr, IndexDataType.CHARGE_STUDENT_CHANGE_RATE);
 		saveData(indexBaseMonthDataDao.getStudentSignUpData(dayStr), dayStr, IndexDataType.ACTIVATION_RATE);
-		saveData(indexBaseMonthDataDao.getHomeworkData(dayStr, null), dayStr, IndexDataType.HOMEWORK_CREATE_RATE);
-		saveData(indexBaseMonthDataDao.getHomeworkData(dayStr, "submit"), dayStr, IndexDataType.HOMEWORK_SUBMIT_RATE);
-		saveData(indexBaseMonthDataDao.getHomeworkData(dayStr, "comment"), dayStr, IndexDataType.HOMEWORK_COMMENT_RATE);
 
-		//经营数据
-		saveData(null, dayStr, IndexDataType.SHOULD_INCOME_MONEY);
-		saveData(null, dayStr, IndexDataType.ANTICIPATED_INCOME_MONEY);
-		saveData(null, dayStr, IndexDataType.SHOULD_EXPEND_MONEY);
-		saveData(null, dayStr, IndexDataType.ANTICIPATED_EXPEND_MONEY);
-		saveData(null, dayStr, IndexDataType.REVENUE_MONEY);
+		//运营数据
+		saveData(indexBaseMonthDataDao.getSchoolData(dayStr), dayStr, IndexDataType.SCHOOL);
+		saveData(indexBaseMonthDataDao.getMusicData(dayStr), dayStr, IndexDataType.PROGRESS_MUSIC_GROUP_NUM);
 
 		//人事数据
 		saveData(indexBaseMonthDataDao.getTeacherData(dayStr, null, null), dayStr, IndexDataType.TEACHER_NUM);
 		saveData(indexBaseMonthDataDao.getTeacherData(dayStr, JobNatureEnum.FULL_TIME, null), dayStr, IndexDataType.FULL_TIME_NUM);
 		saveData(indexBaseMonthDataDao.getTeacherData(dayStr, JobNatureEnum.PART_TIME, null), dayStr, IndexDataType.PART_TIME_NUM);
-		saveData(indexBaseMonthDataDao.getTeacherData(dayStr, null, true), dayStr, IndexDataType.DIMISSION_NUM);
+//		saveData(indexBaseMonthDataDao.getTeacherData(dayStr, null, true), dayStr, IndexDataType.DIMISSION_NUM);
 
-		//学员变动
-		saveData(indexBaseMonthDataDao.getMusicStudentData(dayStr, "ADD"), dayStr, IndexDataType.NEWLY_STUDENT_NUM);
-		saveData(indexBaseMonthDataDao.getMusicStudentData(dayStr, "QUIT"), dayStr, IndexDataType.QUIT_MUSIC_GROUP_STUDENT_NUM);
-		saveData(indexBaseMonthDataDao.getMusicGroupPreRegistrationStudentData(dayStr), dayStr, IndexDataType.STUDENT_CONVERSION_PRE_STUDENT_NUM);
-		saveData(indexBaseMonthDataDao.getMusicGroupStudentFromPreData(dayStr, null), dayStr, IndexDataType.STUDENT_CONVERSION_STUDENT_NUM);
-		saveData(indexBaseMonthDataDao.getMusicGroupStudentFromPreData(dayStr, PaymentStatusEnum.YES), dayStr, IndexDataType.STUDENT_CONVERSION_PAYMENT_STUDENT_NUM);
-		List<Integer> studentIds = indexBaseMonthDataDao.getMusicGroupStudentIdFromPre(dayStr, PaymentStatusEnum.YES);
-		List<IndexBaseMonthData> convertStudentNum = new ArrayList<>();
-		if(!CollectionUtils.isEmpty(studentIds)){
-			convertStudentNum = indexBaseMonthDataDao.getStudentConversionData(dayStr, studentIds);
-		}
-		saveData(convertStudentNum, dayStr, IndexDataType.STUDENT_CONVERSION_VIP_PRACTICE_STUDENT_NUM);
+		//剩余课时
+		saveData(indexBaseMonthDataDao.getGroupCourseData(dayStr, null, CourseStatusEnum.OVER), dayStr, IndexDataType.SURPLUS_COURSE_NUM);
+		saveData(indexBaseMonthDataDao.getGroupCourseData(dayStr, GroupType.MUSIC, CourseStatusEnum.OVER), dayStr, IndexDataType.SURPLUS_MUSIC_COURSE_NUM);
+		saveData(indexBaseMonthDataDao.getGroupCourseData(dayStr, GroupType.VIP, CourseStatusEnum.OVER), dayStr, IndexDataType.SURPLUS_VIP_COURSE_NUM);
+		saveData(indexBaseMonthDataDao.getGroupCourseData(dayStr, GroupType.PRACTICE, CourseStatusEnum.OVER), dayStr, IndexDataType.SURPLUS_PRACTICE_COURSE_NUM);
 
-		//课程数据
-		saveData(indexBaseMonthDataDao.getGroupCourseData(dayStr, GroupType.MUSIC), dayStr, IndexDataType.MUSIC_GROUP_COURSE);
-		saveData(indexBaseMonthDataDao.getGroupCourseData(dayStr, GroupType.VIP), dayStr, IndexDataType.VIP_GROUP_COURSE);
-		saveData(indexBaseMonthDataDao.getGroupCourseData(dayStr, GroupType.PRACTICE), dayStr, IndexDataType.PRACTICE_GROUP_COURSE);
+		//已消耗课时
+		saveData(indexBaseMonthDataDao.getGroupSurplusCourseData(dayStr, null, CourseStatusEnum.OVER), dayStr, IndexDataType.OVER_COURSE_NUM);
+		saveData(indexBaseMonthDataDao.getGroupSurplusCourseData(dayStr, GroupType.MUSIC, CourseStatusEnum.OVER), dayStr, IndexDataType.OVER_MUSIC_COURSE_NUM);
+		saveData(indexBaseMonthDataDao.getGroupSurplusCourseData(dayStr, GroupType.VIP, CourseStatusEnum.OVER), dayStr, IndexDataType.OVER_VIP_COURSE_NUM);
+		saveData(indexBaseMonthDataDao.getGroupSurplusCourseData(dayStr, GroupType.PRACTICE, CourseStatusEnum.OVER), dayStr, IndexDataType.OVER_PRACTICE_COURSE_NUM);
 
-		//财务数据
+		//经营数据
 		saveData(indexBaseMonthDataDao.getFinancePayData(dayStr),dayStr,IndexDataType.FINANCE_PAY);
 		saveData(indexBaseMonthDataDao.getFinanceBalanceData(dayStr),dayStr,IndexDataType.FINANCE_BALANCE_AMOUNT);
 		saveData(indexBaseMonthDataDao.getFinanceActualData(dayStr),dayStr,IndexDataType.FINANCE_AMOUNT);
 
-		return result;
-	}
+		//业务数据
+		saveData(indexBaseMonthDataDao.getHomeworkData(dayStr, null), monday.toString(), IndexDataType.HOMEWORK_CREATE_RATE);
+		saveData(indexBaseMonthDataDao.getHomeworkData(dayStr, "submit"), monday.toString(), IndexDataType.HOMEWORK_SUBMIT_RATE);
+		saveData(indexBaseMonthDataDao.getHomeworkData(dayStr, "comment"), monday.toString(), IndexDataType.HOMEWORK_COMMENT_RATE);
 
-	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 = new ArrayList<>();
-		if(typeDataMap.containsKey(IndexDataType.STUDENT_CONVERSION_PRE_STUDENT_NUM)){
-			preStudentNum = typeDataMap.get(IndexDataType.STUDENT_CONVERSION_PRE_STUDENT_NUM).getIndexMonthData();
-		}
-
-		IndexBaseMonthData preStudentNumData = new IndexBaseMonthData();
-		preStudentNumData = preStudentNum.stream().max(Comparator.comparing(IndexBaseMonthData::getMonth)).get();
-//		preStudentNumData.setMonth(currentMonth);
-		preStudentNumData.setDataType(IndexDataType.STUDENT_CONVERSION_PRE_STUDENT_NUM);
-		preStudentNumData.setTitle(IndexDataType.STUDENT_CONVERSION_PRE_STUDENT_NUM.getMsg());
-//		preStudentNumData.setTotalNum(preStudentNum.stream().map(IndexBaseMonthData::getTotalNum).reduce(BigDecimal.ZERO, BigDecimal::add));
-//		preStudentNumData.setActivateNum(preStudentNum.stream().map(IndexBaseMonthData::getActivateNum).reduce(BigDecimal.ZERO, BigDecimal::add));
-//		preStudentNumData.setPercent(preStudentNumData.getActivateNum());
-
-		List<IndexBaseMonthData> studentNum = new ArrayList<>();
-		if(typeDataMap.containsKey(IndexDataType.STUDENT_CONVERSION_STUDENT_NUM)){
-			studentNum = typeDataMap.get(IndexDataType.STUDENT_CONVERSION_STUDENT_NUM).getIndexMonthData();
-		}
-
-		IndexBaseMonthData studentNumData = new IndexBaseMonthData();
-		studentNumData = studentNum.stream().max(Comparator.comparing(IndexBaseMonthData::getMonth)).get();
-//		studentNumData.setMonth(currentMonth);
-		studentNumData.setDataType(IndexDataType.STUDENT_CONVERSION_STUDENT_NUM);
-		studentNumData.setTitle(IndexDataType.STUDENT_CONVERSION_STUDENT_NUM.getMsg());
-//		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 = new ArrayList<>();
-		if(typeDataMap.containsKey(IndexDataType.STUDENT_CONVERSION_PAYMENT_STUDENT_NUM)){
-			paymentStudentNum = typeDataMap.get(IndexDataType.STUDENT_CONVERSION_PAYMENT_STUDENT_NUM).getIndexMonthData();
-		}
-
-		IndexBaseMonthData paymentStudentNumData = new IndexBaseMonthData();
-		paymentStudentNumData = paymentStudentNum.stream().max(Comparator.comparing(IndexBaseMonthData::getMonth)).get();
-//		paymentStudentNumData.setMonth(currentMonth);
-		paymentStudentNumData.setDataType(IndexDataType.STUDENT_CONVERSION_PAYMENT_STUDENT_NUM);
-		paymentStudentNumData.setTitle(IndexDataType.STUDENT_CONVERSION_PAYMENT_STUDENT_NUM.getMsg());
-//		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 = new ArrayList<>();
-		if(typeDataMap.containsKey(IndexDataType.STUDENT_CONVERSION_VIP_PRACTICE_STUDENT_NUM)){
-			convertStudentNum = typeDataMap.get(IndexDataType.STUDENT_CONVERSION_VIP_PRACTICE_STUDENT_NUM).getIndexMonthData();
-		}
-
-		IndexBaseMonthData convertStudentNumData = new IndexBaseMonthData();
-		convertStudentNumData = convertStudentNum.stream().max(Comparator.comparing(IndexBaseMonthData::getMonth)).get();
-//		convertStudentNumData.setMonth(currentMonth);
-		convertStudentNumData.setDataType(IndexDataType.STUDENT_CONVERSION_VIP_PRACTICE_STUDENT_NUM);
-		convertStudentNumData.setTitle(IndexDataType.STUDENT_CONVERSION_VIP_PRACTICE_STUDENT_NUM.getMsg());
-//		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(true){
-			studentNumData.setPercent(studentNumData.getActivateNum());
-			paymentStudentNumData.setPercent(paymentStudentNumData.getActivateNum());
-			convertStudentNumData.setPercent(convertStudentNumData.getActivateNum());
-		}else 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(), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).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(), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).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(), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN));
-				}
-			}
-		}
+		//课程数据
+		saveData(indexBaseMonthDataDao.getGroupCourseData(dayStr, GroupType.MUSIC, CourseStatusEnum.OVER), dayStr, IndexDataType.MUSIC_GROUP_COURSE);
+		saveData(indexBaseMonthDataDao.getGroupCourseData(dayStr, GroupType.VIP, CourseStatusEnum.OVER), dayStr, IndexDataType.VIP_GROUP_COURSE);
+		saveData(indexBaseMonthDataDao.getGroupCourseData(dayStr, GroupType.PRACTICE, CourseStatusEnum.OVER), dayStr, IndexDataType.PRACTICE_GROUP_COURSE);
+
+		//学员变动
+		saveData(indexBaseMonthDataDao.getAddStudentRegistrationData(dayStr), dayStr, IndexDataType.ADD_STUDENT_REGISTRATION_NUM);
+		saveData(indexBaseMonthDataDao.getMusicStudentData(dayStr, null), dayStr, IndexDataType.MUSIC_GROUP_STUDENT);
+		saveData(null, dayStr, IndexDataType.NEWLY_STUDENT_NUM);
+		saveData(null, dayStr, IndexDataType.QUIT_MUSIC_GROUP_STUDENT_NUM);
+		saveData(indexBaseMonthDataDao.getOtherStudentData(dayStr), dayStr, IndexDataType.VIP_PRACTICE_STUDENT_NUM);
+		saveData(indexBaseMonthDataDao.getVipPracticeAddStudentData(dayStr), dayStr, IndexDataType.VIP_PRACTICE_ADD_STUDENT_NUM);
 
-		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);
-		if(paymentStudentNumData.getActivateNum().compareTo(BigDecimal.ZERO)==0){
-			indexBaseData.setPercent(convertStudentNumData.getPercent());
-		}else{
-			indexBaseData.setPercent(convertStudentNumData.getActivateNum().divide(paymentStudentNumData.getActivateNum(), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN));
-		}
-		result.add(indexBaseData);
 	}
 
 	/**

+ 113 - 5
mec-biz/src/main/resources/config/mybatis/IndexBaseMonthDataMapper.xml

@@ -179,10 +179,67 @@
 		ORDER BY organ_id_;
 	</select>
 
-	<select id="getHomeworkData" resultMap="IndexBaseMonthData">
+	<select id="getStudentRegistrationData" resultMap="IndexBaseMonthData">
+		SELECT
+			su.organ_id_,
+			#{dayStr} month_,
+			COUNT( DISTINCT stu.user_id_ ) total_num_,
+			COUNT( DISTINCT stu.user_id_ ) activate_num_,
+			COUNT( DISTINCT stu.user_id_ ) percent_
+		FROM
+			student stu
+			LEFT JOIN sys_user su ON stu.user_id_=su.id_
+		WHERE
+			su.del_flag_=0
+		  AND su.organ_id_ IS NOT NULL
+		  AND su.user_type_ LIKE '%STUDENT%'
+		  AND DATE_FORMAT(stu.create_time_, '%Y-%m-%d')&lt;=#{dayStr}
+		GROUP BY organ_id_
+		ORDER BY organ_id_;
+	</select>
+
+	<select id="getAddStudentRegistrationData" resultMap="IndexBaseMonthData">
+		SELECT
+			su.organ_id_,
+			#{dayStr} month_,
+			COUNT( DISTINCT stu.user_id_ ) total_num_,
+			COUNT( DISTINCT stu.user_id_ ) activate_num_,
+			COUNT( DISTINCT stu.user_id_ ) percent_
+		FROM
+			student stu
+				LEFT JOIN sys_user su ON stu.user_id_=su.id_
+		WHERE
+			su.del_flag_=0
+		  AND su.organ_id_ IS NOT NULL
+		  AND su.user_type_ LIKE '%STUDENT%'
+		  AND DATE_FORMAT(stu.create_time_, '%Y-%m-%d')=#{dayStr}
+		GROUP BY organ_id_
+		ORDER BY organ_id_;
+	</select>
+
+	<select id="getChargeStudentChangeData" resultMap="IndexBaseMonthData">
 		SELECT
 			su.organ_id_,
 			#{dayStr} month_,
+			COUNT( DISTINCT stu.user_id_ ) total_num_,
+			COUNT( DISTINCT spo.user_id_ ) activate_num_,
+			TRUNCATE(COUNT(DISTINCT spo.user_id_)/COUNT(DISTINCT stu.user_id_)*100, 2) percent_
+		FROM
+			student stu
+			LEFT JOIN sys_user su ON stu.user_id_=su.id_
+			LEFT JOIN student_payment_order spo ON stu.user_id_=spo.user_id_ AND status_='SUCCESS' AND actual_amount_>0
+		WHERE
+			su.del_flag_=0
+		  AND su.organ_id_ IS NOT NULL
+		  AND su.user_type_ LIKE '%STUDENT%'
+		GROUP BY organ_id_
+		ORDER BY organ_id_;
+	</select>
+
+	<select id="getHomeworkData" resultMap="IndexBaseMonthData">
+		SELECT
+			su.organ_id_,
+			sees.monday_ month_,
 			<choose>
 				<when test="type == 'submit'">
 					SUM(sees.actual_exercises_num_) total_num_,
@@ -204,8 +261,8 @@
 		LEFT JOIN sys_user su ON sees.student_id_=su.id_
 		WHERE su.del_flag_=0
 			AND su.organ_id_ IS NOT NULL
-			AND (DATE_FORMAT(sees.monday_, '%Y-%m')=DATE_FORMAT(#{dayStr}, '%Y-%m')
-			        OR DATE_FORMAT(sees.sunday_, '%Y-%m')=DATE_FORMAT(#{dayStr}, '%Y-%m'))
+			AND DATE_FORMAT(sees.monday_, '%Y-%m-%d')&lt;=#{dayStr}
+			AND DATE_FORMAT(sees.sunday_, '%Y-%m-%d')&gt;=#{dayStr}
 		GROUP BY su.organ_id_
 		ORDER BY su.organ_id_
 	</select>
@@ -326,11 +383,11 @@
 		WHERE
 			m.del_flag_ = 0
 			AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
-		  	AND m.status_ = 'OVER'
+		  	AND m.status_ = #{courseStatus, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 			AND (m.new_course_id_ IS NULL OR m.new_course_id_=m.id_)
 			AND m.organ_id_ IS NOT NULL
 			<if test="groupType!=null">
-				AND m.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+				AND m.group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 			</if>
 			<if test="dayStr!=null and dayStr!=''">
 				AND DATE_FORMAT(m.class_date_, '%Y-%m-%d') = #{dayStr}
@@ -341,6 +398,31 @@
 			m.organ_id_;
 	</select>
 
+	<select id="getGroupSurplusCourseData" resultMap="IndexBaseMonthData">
+		SELECT
+			m.organ_id_,
+			#{dayStr} month_,
+			COUNT( m.id_ ) total_num_,
+			COUNT( m.id_ ) activate_num_,
+			COUNT( m.id_ ) percent_
+		FROM
+			course_schedule m
+		WHERE
+			m.del_flag_ = 0
+			AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
+			AND m.status_ = #{courseStatus, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+			AND (m.new_course_id_ IS NULL OR m.new_course_id_=m.id_)
+			AND m.organ_id_ IS NOT NULL
+			<if test="groupType!=null">
+				AND m.group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+			</if>
+			<if test="dayStr!=null and dayStr!=''">
+				AND DATE_FORMAT(m.create_time_, '%Y-%m-%d') = #{dayStr}
+			</if>
+		GROUP BY m.organ_id_
+		ORDER BY m.organ_id_;
+	</select>
+
 	<select id="getOtherStudentData" resultMap="IndexBaseMonthData">
 		SELECT
 			su.organ_id_,
@@ -367,6 +449,32 @@
 			su.organ_id_;
 	</select>
 
+	<select id="getVipPracticeAddStudentData" resultMap="IndexBaseMonthData">
+		SELECT
+			su.organ_id_,
+			#{dayStr} month_,
+			COUNT( DISTINCT s.user_id_ ) total_num_,
+			COUNT( DISTINCT s.user_id_ ) activate_num_,
+			COUNT( DISTINCT s.user_id_ ) percent_
+		FROM
+			sys_user su
+			LEFT JOIN course_schedule_student_payment s ON su.id_=s.user_id_
+			LEFT JOIN course_schedule_student_payment cssp1 ON s.user_id_=cssp1.user_id_ AND cssp1.create_time_&lt;#{dayStr}
+			LEFT JOIN course_schedule m ON s.course_schedule_id_=m.id_
+		WHERE
+			m.del_flag_ = 0
+			AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
+			AND cssp1.id_ IS NULL
+			AND su.organ_id_ IS NOT NULL
+			AND m.group_type_ IN ('VIP', 'PRACTICE')
+			AND m.status_ = 'NOT_START'
+			<if test="dayStr!=null and dayStr!=''">
+				AND DATE_FORMAT(s.create_time_, '%Y-%m-%d') = #{dayStr}
+			</if>
+		GROUP BY su.organ_id_
+		ORDER BY su.organ_id_;
+	</select>
+
 	<select id="getStudentConversionData" resultMap="IndexBaseMonthData">
 		SELECT
 			cs.organ_id_,

+ 2 - 2
mec-web/src/main/resources/bootstrap-test.properties

@@ -1,9 +1,9 @@
 #\u6307\u5b9a\u5f00\u53d1\u73af\u5883
 #spring.profiles.active=dev
 #\u670d\u52a1\u5668\u5730\u5740
-spring.cloud.nacos.config.server-addr=47.96.85.100:8848
+spring.cloud.nacos.config.server-addr=47.114.1.200
 #\u9ed8\u8ba4\u4e3aPublic\u547d\u540d\u7a7a\u95f4,\u53ef\u4ee5\u7701\u7565\u4e0d\u5199
-spring.cloud.nacos.config.namespace=02105743-16b8-46ab-87df-2aca0f3dbca3
+spring.cloud.nacos.config.namespace=f753d9d9-4bb2-4df6-a483-da9e169617c4
 #\u6307\u5b9a\u914d\u7f6e\u7fa4\u7ec4 --\u5982\u679c\u662fPublic\u547d\u540d\u7a7a\u95f4 \u5219\u53ef\u4ee5\u7701\u7565\u7fa4\u7ec4\u914d\u7f6e
 spring.cloud.nacos.config.group=DEFAULT_GROUP
 #\u6587\u4ef6\u540d -- \u5982\u679c\u6ca1\u6709\u914d\u7f6e\u5219\u9ed8\u8ba4\u4e3a ${spring.appliction.name}