ソースを参照

Merge branch 'saas' into master_saas

yonge 3 年 前
コミット
2585a9cf95

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleStudentPaymentDao.java

@@ -6,6 +6,7 @@ import com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment;
 import com.ym.mec.biz.dal.entity.CourseScheduleStudentPaymentDto;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.common.dal.BaseDAO;
+
 import org.apache.ibatis.annotations.Param;
 
 import java.math.BigDecimal;
@@ -599,4 +600,11 @@ public interface CourseScheduleStudentPaymentDao extends BaseDAO<Long, CourseSch
     List<BaseNameDto> queryFirstNotStartTeacher(@Param("studentIds") List<Integer> studentIds, @Param("groupType") String groupType);
 
     List<ExportVipStudentCourseManageDto> queryVipStudentCourseManage(@Param("organId") String organId, @Param("tenantId") Integer tenantId);
+    
+    /**
+     * 查询有剩余课程学生列表
+     * @param organIds
+     * @return
+     */
+    List<StudentOrganDto> queryRemainCourseStudent(@Param("organIds") List<Integer> organIds);
 }

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentRegistrationDao.java

@@ -21,6 +21,7 @@ import com.ym.mec.biz.dal.dto.StudentFeeDetailDto;
 import com.ym.mec.biz.dal.dto.StudentInfo;
 import com.ym.mec.biz.dal.dto.StudentMusicDetailDto;
 import com.ym.mec.biz.dal.dto.StudentMusicGroupDto;
+import com.ym.mec.biz.dal.dto.StudentOrganDto;
 import com.ym.mec.biz.dal.dto.StudentRegisterInstrumentsDetailDto;
 import com.ym.mec.biz.dal.dto.StudentRegisterPerDto;
 import com.ym.mec.biz.dal.dto.SubjectApplyDetailDto;
@@ -769,4 +770,6 @@ public interface StudentRegistrationDao extends BaseDAO<Long, StudentRegistratio
     List<Map<Integer,String>> getLastMusicGroupName(@Param("userIds") List<Integer> userIds);
     
     List<StudentRegistration> queryServiceStudentByMusicGroupStatus(@Param("nextMonday") String nextMonday,@Param("tenantId") Integer tenantId);
+    
+    List<StudentOrganDto> queryEffectiveStudent(@Param("organIds") List<Integer> organIds);
 }

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentStatisticsDao.java

@@ -1,13 +1,16 @@
 package com.ym.mec.biz.dal.dao;
 
+import com.ym.mec.biz.dal.dto.StudentOrganDto;
 import com.ym.mec.biz.dal.dto.StudentStatisticsDto;
 import com.ym.mec.biz.dal.dto.StudentStatisticsSumDto;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.biz.dal.entity.StudentStatistics;
+
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 public interface StudentStatisticsDao extends BaseDAO<Integer, StudentStatistics> {
 
@@ -63,4 +66,6 @@ public interface StudentStatisticsDao extends BaseDAO<Integer, StudentStatistics
     void clean();
 
     void batchUpdate(@Param("statisticsList") List<StudentStatistics> statisticsList);
+    
+    List<StudentOrganDto> queryNoScheduleNumStudent(@Param("organIds") List<Integer> organIds);
 }

+ 18 - 7
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CloudStudyStudentDataDto.java

@@ -13,15 +13,18 @@ public class CloudStudyStudentDataDto {
     @ApiModelProperty("分部名称")
     private String organName;
 
-    @ApiModelProperty("学员总数")
+    @ApiModelProperty("注册学员总数")
     private int totalStudentNum;
+    
+    @ApiModelProperty("有效学员总数")
+    private int effectiveStudentNum; 
 
     @ApiModelProperty("付费会员数")
     private int vipStudentNum;
     
-	private Integer effectiveVipStudentNum;
+	private int effectiveVipStudentNum;
 	
-	private Integer waitActivateVipStudentNum;
+	private int waitActivateVipStudentNum;
 
     @ApiModelProperty("试用会员数")
     private int eVipStudentNum;
@@ -132,19 +135,27 @@ public class CloudStudyStudentDataDto {
         this.newCloudStudyStudentNum = newCloudStudyStudentNum;
     }
 
-	public Integer getEffectiveVipStudentNum() {
+	public int getEffectiveVipStudentNum() {
 		return effectiveVipStudentNum;
 	}
 
-	public void setEffectiveVipStudentNum(Integer effectiveVipStudentNum) {
+	public void setEffectiveVipStudentNum(int effectiveVipStudentNum) {
 		this.effectiveVipStudentNum = effectiveVipStudentNum;
 	}
 
-	public Integer getWaitActivateVipStudentNum() {
+	public int getWaitActivateVipStudentNum() {
 		return waitActivateVipStudentNum;
 	}
 
-	public void setWaitActivateVipStudentNum(Integer waitActivateVipStudentNum) {
+	public void setWaitActivateVipStudentNum(int waitActivateVipStudentNum) {
 		this.waitActivateVipStudentNum = waitActivateVipStudentNum;
 	}
+
+	public int getEffectiveStudentNum() {
+		return effectiveStudentNum;
+	}
+
+	public void setEffectiveStudentNum(int effectiveStudentNum) {
+		this.effectiveStudentNum = effectiveStudentNum;
+	}
 }

+ 36 - 15
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/IndexCloudStudyListDto.java

@@ -6,15 +6,19 @@ public class IndexCloudStudyListDto {
 	
 	private String organName;
 	
-	private Integer totalStudentNum;
+	private int totalStudentNum;
 	
-	private Integer vipStudentNum;
+	private int effectiveStudentNum;
 	
-	private Integer effectiveVipStudentNum;
+	private int vipStudentNum;
 	
-	private Integer waitActivateVipStudentNum;
+	private double vipStudentRate;
 	
-	private Integer activeStudentNum;
+	private int effectiveVipStudentNum;
+	
+	private int waitActivateVipStudentNum;
+	
+	private int activeStudentNum;
 
 	public Integer getOrganId() {
 		return organId;
@@ -32,43 +36,60 @@ public class IndexCloudStudyListDto {
 		this.organName = organName;
 	}
 
-	public Integer getTotalStudentNum() {
+	public int getTotalStudentNum() {
 		return totalStudentNum;
 	}
 
-	public void setTotalStudentNum(Integer totalStudentNum) {
+	public void setTotalStudentNum(int totalStudentNum) {
 		this.totalStudentNum = totalStudentNum;
 	}
 
-	public Integer getVipStudentNum() {
+	public int getEffectiveStudentNum() {
+		return effectiveStudentNum;
+	}
+
+	public void setEffectiveStudentNum(int effectiveStudentNum) {
+		this.effectiveStudentNum = effectiveStudentNum;
+	}
+
+	public int getVipStudentNum() {
 		return vipStudentNum;
 	}
 
-	public void setVipStudentNum(Integer vipStudentNum) {
+	public void setVipStudentNum(int vipStudentNum) {
 		this.vipStudentNum = vipStudentNum;
 	}
 
-	public Integer getEffectiveVipStudentNum() {
+	public double getVipStudentRate() {
+		return vipStudentRate;
+	}
+
+	public void setVipStudentRate(double vipStudentRate) {
+		this.vipStudentRate = vipStudentRate;
+	}
+
+	public int getEffectiveVipStudentNum() {
 		return effectiveVipStudentNum;
 	}
 
-	public void setEffectiveVipStudentNum(Integer effectiveVipStudentNum) {
+	public void setEffectiveVipStudentNum(int effectiveVipStudentNum) {
 		this.effectiveVipStudentNum = effectiveVipStudentNum;
 	}
 
-	public Integer getWaitActivateVipStudentNum() {
+	public int getWaitActivateVipStudentNum() {
 		return waitActivateVipStudentNum;
 	}
 
-	public void setWaitActivateVipStudentNum(Integer waitActivateVipStudentNum) {
+	public void setWaitActivateVipStudentNum(int waitActivateVipStudentNum) {
 		this.waitActivateVipStudentNum = waitActivateVipStudentNum;
 	}
 
-	public Integer getActiveStudentNum() {
+	public int getActiveStudentNum() {
 		return activeStudentNum;
 	}
 
-	public void setActiveStudentNum(Integer activeStudentNum) {
+	public void setActiveStudentNum(int activeStudentNum) {
 		this.activeStudentNum = activeStudentNum;
 	}
+
 }

+ 24 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentOrganDto.java

@@ -0,0 +1,24 @@
+package com.ym.mec.biz.dal.dto;
+
+public class StudentOrganDto {
+
+	private Integer userId;
+	
+	private Integer organId;
+
+	public Integer getUserId() {
+		return userId;
+	}
+
+	public void setUserId(Integer userId) {
+		this.userId = userId;
+	}
+
+	public Integer getOrganId() {
+		return organId;
+	}
+
+	public void setOrganId(Integer organId) {
+		this.organId = organId;
+	}
+}

+ 44 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentServiceImpl.java

@@ -13,6 +13,7 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -41,6 +42,7 @@ import com.ym.mec.biz.dal.dao.OrganizationDao;
 import com.ym.mec.biz.dal.dao.PracticeGroupDao;
 import com.ym.mec.biz.dal.dao.StudentDao;
 import com.ym.mec.biz.dal.dao.StudentRegistrationDao;
+import com.ym.mec.biz.dal.dao.StudentStatisticsDao;
 import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dao.SysMusicCompareRecordDao;
 import com.ym.mec.biz.dal.dao.SysUserCashAccountDao;
@@ -56,6 +58,7 @@ import com.ym.mec.biz.dal.dto.Mapper;
 import com.ym.mec.biz.dal.dto.StatDto;
 import com.ym.mec.biz.dal.dto.StudentClassInfoDto;
 import com.ym.mec.biz.dal.dto.StudentCourseTimesDto;
+import com.ym.mec.biz.dal.dto.StudentOrganDto;
 import com.ym.mec.biz.dal.dto.StudentTeacherCourseDto;
 import com.ym.mec.biz.dal.entity.BaseStudentDto;
 import com.ym.mec.biz.dal.entity.CloudTeacherOrder;
@@ -105,6 +108,8 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
     @Autowired
     private StudentRegistrationDao studentRegistrationDao;
     @Autowired
+    private StudentStatisticsDao studentStatisticsDao;
+    @Autowired
     private MusicGroupDao musicGroupDao;
     @Autowired
     private PracticeGroupDao practiceGroupDao;
@@ -1036,14 +1041,15 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
     public CloudStudyStudentDataDto getCloudStudyStudentOverView(List<Integer> organIds) {
         CloudStudyStudentDataDto result = new CloudStudyStudentDataDto();
         
-        IndexCloudStudyListDto dto = studentDao.getOrgansCloudTeacherStudent(organIds);
+        /*IndexCloudStudyListDto dto = studentDao.getOrgansCloudTeacherStudent(organIds);
         result.setTotalStudentNum(dto.getTotalStudentNum());
         result.setEffectiveVipStudentNum(dto.getEffectiveVipStudentNum());
         result.setWaitActivateVipStudentNum(dto.getWaitActivateVipStudentNum());
-        result.setVipStudentNum(cloudTeacherDao.getOrgansTotalVipStudentNum(organIds));
+        
+        result.setVipStudentNum(cloudTeacherDao.getOrgansTotalVipStudentNum(organIds));*/
 //        result.seteVipStudentNum(studentDao.getOrgansTotalEVipStudentNum(organIds));
         result.setCloudStudyUseStudentNum(studentDao.getOrgansTotalCloudStudyStudentNum(organIds));
-        //result.setCloudStudyTodayUseStudentNum(studentDao.getOrgansTodayTotalCloudStudyStudentNum(organIds));
+        result.setCloudStudyTodayUseStudentNum(studentDao.getOrgansTodayTotalCloudStudyStudentNum(organIds));
         
         Calendar cal = Calendar.getInstance();    
         cal.setTime(new Date());    
@@ -1092,10 +1098,43 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
         for(Mapper mapper : organCloudTeacherStudentNum){
         	organCloudTeacherStudentNumMap.put(Integer.parseInt(mapper.getKey().toString()), Integer.parseInt(mapper.getValue().toString()));
         }
+
+        List<StudentOrganDto> set1 = studentRegistrationDao.queryEffectiveStudent(organIds);
+        List<StudentOrganDto> set2 = courseScheduleStudentPaymentDao.queryRemainCourseStudent(organIds);
+        List<StudentOrganDto> set3 = studentStatisticsDao.queryNoScheduleNumStudent(organIds);
+        
+        Map<Integer,Set<Integer>> map1= set1.stream().collect(Collectors.groupingBy(StudentOrganDto :: getOrganId, Collectors.mapping(StudentOrganDto :: getUserId, Collectors.toSet())));
+        Map<Integer,Set<Integer>> map2= set2.stream().collect(Collectors.groupingBy(StudentOrganDto :: getOrganId, Collectors.mapping(StudentOrganDto :: getUserId, Collectors.toSet())));
+        Map<Integer,Set<Integer>> map3= set3.stream().collect(Collectors.groupingBy(StudentOrganDto :: getOrganId, Collectors.mapping(StudentOrganDto :: getUserId, Collectors.toSet())));
+        
+        Map<Integer,Set<Integer>> organStudentMap = new HashMap<Integer, Set<Integer>>(map1);
+        Set<Integer> temp = null;
+        for(Entry<Integer, Set<Integer>> entry : map2.entrySet()){
+        	temp = organStudentMap.get(entry.getKey());
+        	if(temp == null){
+        		organStudentMap.put(entry.getKey(), entry.getValue());
+        	}else{
+        		temp.addAll(entry.getValue());
+        		organStudentMap.put(entry.getKey(), temp);
+        	}
+        }
+        for(Entry<Integer, Set<Integer>> entry : map3.entrySet()){
+        	temp = organStudentMap.get(entry.getKey());
+        	if(temp == null){
+        		organStudentMap.put(entry.getKey(), entry.getValue());
+        	}else{
+        		temp.addAll(entry.getValue());
+        		organStudentMap.put(entry.getKey(), temp);
+        	}
+        }
         
         for(IndexCloudStudyListDto ics : list){
-        	ics.setActiveStudentNum(organActiveNum.get(ics.getOrganId()));
-        	ics.setVipStudentNum(organCloudTeacherStudentNumMap.get(ics.getOrganId()));
+        	ics.setActiveStudentNum(organActiveNum.get(ics.getOrganId()) == null ? 0 : organActiveNum.get(ics.getOrganId()));
+        	ics.setVipStudentNum(organCloudTeacherStudentNumMap.get(ics.getOrganId()) == null ? 0 : organCloudTeacherStudentNumMap.get(ics.getOrganId()));
+        	ics.setEffectiveStudentNum(organStudentMap.get(ics.getOrganId()) == null ? 0 : organStudentMap.get(ics.getOrganId()).size());
+        	if(ics.getEffectiveStudentNum() > 0){
+        		ics.setVipStudentRate(ics.getVipStudentNum() * 100d / ics.getEffectiveStudentNum());
+        	}
         }
         
 		return list;

+ 11 - 0
mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml

@@ -1071,4 +1071,15 @@
 		GROUP BY cssp.`user_id_` ,vg.`vip_group_category_id_`
 		) d on b.user_id_ = d.user_id_ and a.vip_group_category_id_ = d.vip_group_category_id_
 	</select>
+	
+	<select id="queryRemainCourseStudent" resultType="com.ym.mec.biz.dal.dto.StudentOrganDto">
+		SELECT cssp.user_id_ userId, u.organ_id_ organId FROM `course_schedule_student_payment` cssp LEFT JOIN `course_schedule` cs on cssp.`course_schedule_id_` = cs.`id_`
+		LEFT JOIN `sys_user` u on u.`id_` = cssp.`user_id_`
+		WHERE cs.`status_` = 'NOT_START'
+		AND u.organ_id_ IN
+        <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
+            #{organId}
+        </foreach>
+        group by cssp.user_id_ , u.organ_id_
+	</select>
 </mapper>

+ 11 - 0
mec-biz/src/main/resources/config/mybatis/StudentRegistrationMapper.xml

@@ -1822,4 +1822,15 @@
     	where s.service_tag_ = 1 AND (s.service_tag_update_time_ IS NULL OR s.service_tag_update_time_&lt;#{nextMonday})
     	and sr.music_group_status_ = 'NORMAL' AND mg.status_ = 'PROGRESS' and sr.tenant_id_ = #{tenantId}
     </select>
+    
+    <select id="queryEffectiveStudent" resultType="com.ym.mec.biz.dal.dto.StudentOrganDto">
+    	SELECT sr.user_id_ userId, u.organ_id_ organId FROM `student_registration` sr LEFT JOIN `music_group` mg on sr.`music_group_id_` = mg.`id_`
+		LEFT JOIN `sys_user` u on u.`id_` = sr.`user_id_`
+		WHERE mg.`status_` = 'PROGRESS' AND sr.`music_group_status_` = 'NORMAL'
+		AND u.organ_id_ IN
+        <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
+            #{organId}
+        </foreach>
+        group by sr.user_id_ , u.organ_id_
+    </select>
 </mapper>

+ 11 - 0
mec-biz/src/main/resources/config/mybatis/StudentStatisticsMapper.xml

@@ -676,4 +676,15 @@
 			'STUDENT_PRACTICE_ORDER_NUM'
 		</if>
 	</sql>
+	
+	<select id="queryNoScheduleNumStudent" resultType="com.ym.mec.biz.dal.dto.StudentOrganDto">
+		SELECT ss.`user_id_` userId,u.organ_id_ organId FROM `student_statistics` ss 
+		LEFT JOIN `sys_user` u on u.`id_` = ss.`user_id_`
+		WHERE ss.`no_schedule_num_` > 0
+		AND u.organ_id_ IN
+        <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
+            #{organId}
+        </foreach>
+        group by ss.user_id_ , u.organ_id_
+	</select>
 </mapper>

+ 41 - 2
mec-web/src/main/java/com/ym/mec/web/controller/StudentManageController.java

@@ -8,7 +8,10 @@ import io.swagger.annotations.ApiParam;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -404,7 +407,7 @@ public class StudentManageController extends BaseController {
     @ApiOperation(value = "云教练学员数据预览")
     @GetMapping("/getCloudStudyStudentOverView")
     @PreAuthorize("@pcs.hasPermissions('studentManage/getCloudStudyStudentOverView')")
-    public HttpResponseResult<CloudStudyStudentDataDto> getCloudStudyStudentOverView(String organIds) throws Exception {
+    public HttpResponseResult<Object> getCloudStudyStudentOverView(String organIds) throws Exception {
         List<Integer> organIdsList;
         if(StringUtils.isNotBlank(organIds)){
             organIdsList = Arrays.stream(organIds.split(",")).map(id->Integer.valueOf(id)).collect(Collectors.toList());
@@ -415,7 +418,42 @@ public class StudentManageController extends BaseController {
             }
             organIdsList = organizations.stream().map(Organization::getId).collect(Collectors.toList());
         }
-        return succeed(studentService.getCloudStudyStudentOverView(organIdsList));
+        
+        List<Integer> ingnoreOrganIdList = Arrays.asList(36,39,41,42,43,44,45,46,47,48,49,50,52,54,56);
+        
+        organIdsList.removeAll(ingnoreOrganIdList);
+        
+        Map<String,Object> result = new HashMap<String, Object>();
+        
+        List<IndexCloudStudyListDto> list = studentService.getCloudStudyStudentOverViewList(organIdsList);
+        Collections.sort(list, new Comparator<IndexCloudStudyListDto>() {
+
+			@Override
+			public int compare(IndexCloudStudyListDto o1, IndexCloudStudyListDto o2) {
+				if(o1.getVipStudentRate() == o2.getVipStudentRate()){
+					return 0;
+				}
+				if(o1.getVipStudentRate() > o2.getVipStudentRate()){
+					return -1;
+				}
+				return 1;
+			}
+        	
+		});
+        
+        result.put("list", list);
+        
+        CloudStudyStudentDataDto cloudStudyStudentDataDto = studentService.getCloudStudyStudentOverView(organIdsList);
+
+        cloudStudyStudentDataDto.setTotalStudentNum(list.stream().collect(Collectors.summingInt(IndexCloudStudyListDto :: getTotalStudentNum)));
+        cloudStudyStudentDataDto.setEffectiveVipStudentNum(list.stream().collect(Collectors.summingInt(IndexCloudStudyListDto :: getEffectiveVipStudentNum)));
+        cloudStudyStudentDataDto.setWaitActivateVipStudentNum(list.stream().collect(Collectors.summingInt(IndexCloudStudyListDto :: getWaitActivateVipStudentNum)));
+        cloudStudyStudentDataDto.setEffectiveStudentNum(list.stream().collect(Collectors.summingInt(IndexCloudStudyListDto :: getEffectiveStudentNum)));
+        cloudStudyStudentDataDto.setVipStudentNum(list.stream().collect(Collectors.summingInt(IndexCloudStudyListDto :: getVipStudentNum)));
+
+        result.put("overView", cloudStudyStudentDataDto);
+        
+        return succeed(result);
     }
 
     @ApiOperation(value = "云教练学员数据预览列表")
@@ -432,6 +470,7 @@ public class StudentManageController extends BaseController {
             }
             organIdsList = organizations.stream().map(Organization::getId).collect(Collectors.toList());
         }
+        
         return succeed(studentService.getCloudStudyStudentOverViewList(organIdsList));
     }