浏览代码

feat:云教练首页数据统计

Joburgess 3 年之前
父节点
当前提交
919ed9d5c9

+ 22 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/EduOrganStudentDataDto.java

@@ -22,6 +22,9 @@ public class EduOrganStudentDataDto {
     @ApiModelProperty("试用会员数")
     private int eVipStudentNum;
 
+    @ApiModelProperty("新增会员数")
+    private int newMemberStudentNum;
+
     @ApiModelProperty("付费会员占比")
     private float vipStudentDuty;
 
@@ -34,6 +37,9 @@ public class EduOrganStudentDataDto {
     @ApiModelProperty("活跃人数")
     private int cloudStudyLivelyStudentNum;
 
+    @ApiModelProperty("活跃人数占比")
+    private float cloudStudyLivelyStudentDuty;
+
     @ApiModelProperty("云教练新增人数")
     private int newCloudStudyStudentNum;
 
@@ -116,4 +122,20 @@ public class EduOrganStudentDataDto {
     public void setNewCloudStudyStudentNum(int newCloudStudyStudentNum) {
         this.newCloudStudyStudentNum = newCloudStudyStudentNum;
     }
+
+    public int getNewMemberStudentNum() {
+        return newMemberStudentNum;
+    }
+
+    public void setNewMemberStudentNum(int newMemberStudentNum) {
+        this.newMemberStudentNum = newMemberStudentNum;
+    }
+
+    public float getCloudStudyLivelyStudentDuty() {
+        return cloudStudyLivelyStudentDuty;
+    }
+
+    public void setCloudStudyLivelyStudentDuty(float cloudStudyLivelyStudentDuty) {
+        this.cloudStudyLivelyStudentDuty = cloudStudyLivelyStudentDuty;
+    }
 }

+ 83 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/OrganCloudStudyStudentDataQueryInfo.java

@@ -0,0 +1,83 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.ApiModelProperty;
+
+public class OrganCloudStudyStudentDataQueryInfo extends QueryInfo {
+
+    private String date;
+
+    @ApiModelProperty("付费会员数")
+    private String vipStudentNum;
+
+    @ApiModelProperty("试用会员数")
+    private String eVipStudentNum;
+
+    @ApiModelProperty("新增会员数")
+    private String newMemberStudentNum;
+
+    @ApiModelProperty("活跃人数")
+    private String cloudStudyLivelyStudentNum;
+
+    @ApiModelProperty("活跃人数占比")
+    private String cloudStudyLivelyStudentDuty;
+
+    @ApiModelProperty("排序信息:vipStudentNum:ASC(付费会员数正序),eVipStudentNum:DESC(试用会员数倒序),newMemberStudentNum(新增会员数),cloudStudyLivelyStudentNum(活跃人数),cloudStudyLivelyStudentDuty(活跃人数占比)")
+    private String sortInfo;
+
+    public String getDate() {
+        return date;
+    }
+
+    public void setDate(String date) {
+        this.date = date;
+    }
+
+    public String getVipStudentNum() {
+        return vipStudentNum;
+    }
+
+    public void setVipStudentNum(String vipStudentNum) {
+        this.vipStudentNum = vipStudentNum;
+    }
+
+    public String geteVipStudentNum() {
+        return eVipStudentNum;
+    }
+
+    public void seteVipStudentNum(String eVipStudentNum) {
+        this.eVipStudentNum = eVipStudentNum;
+    }
+
+    public String getNewMemberStudentNum() {
+        return newMemberStudentNum;
+    }
+
+    public void setNewMemberStudentNum(String newMemberStudentNum) {
+        this.newMemberStudentNum = newMemberStudentNum;
+    }
+
+    public String getCloudStudyLivelyStudentNum() {
+        return cloudStudyLivelyStudentNum;
+    }
+
+    public void setCloudStudyLivelyStudentNum(String cloudStudyLivelyStudentNum) {
+        this.cloudStudyLivelyStudentNum = cloudStudyLivelyStudentNum;
+    }
+
+    public String getCloudStudyLivelyStudentDuty() {
+        return cloudStudyLivelyStudentDuty;
+    }
+
+    public void setCloudStudyLivelyStudentDuty(String cloudStudyLivelyStudentDuty) {
+        this.cloudStudyLivelyStudentDuty = cloudStudyLivelyStudentDuty;
+    }
+
+    public String getSortInfo() {
+        return sortInfo;
+    }
+
+    public void setSortInfo(String sortInfo) {
+        this.sortInfo = sortInfo;
+    }
+}

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

@@ -4,6 +4,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import com.ym.mec.biz.dal.dto.EduOrganStudentDataDto;
 import com.ym.mec.biz.dal.dto.IndexBaseDto;
 import com.ym.mec.biz.dal.dto.IndexErrorDataExportDto;
 import com.ym.mec.biz.dal.entity.IndexBaseMonthData;
@@ -11,6 +12,9 @@ import com.ym.mec.biz.dal.entity.IndexErrInfoDto;
 import com.ym.mec.biz.dal.enums.IndexDataType;
 import com.ym.mec.biz.dal.enums.IndexErrorType;
 import com.ym.mec.biz.dal.page.IndexDataQueryInfo;
+import com.ym.mec.biz.dal.page.OrganCloudStudyStudentDataQueryInfo;
+import com.ym.mec.biz.dal.page.OrganizationQueryInfo;
+import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
 
 public interface IndexBaseMonthDataService extends BaseService<Long, IndexBaseMonthData> {
@@ -36,4 +40,6 @@ public interface IndexBaseMonthDataService extends BaseService<Long, IndexBaseMo
      * @return
      */
     Map<String,Boolean> hasIndexErrData(String organIds);
+
+    PageInfo<EduOrganStudentDataDto> organStudentOverView(List<Integer> organIds, OrganCloudStudyStudentDataQueryInfo queryInfo);
 }

+ 103 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/IndexBaseMonthDataServiceImpl.java

@@ -5,19 +5,19 @@ import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.auth.api.entity.SysUserRole;
 import com.ym.mec.biz.dal.dao.*;
-import com.ym.mec.biz.dal.dto.IndexBaseDto;
-import com.ym.mec.biz.dal.dto.IndexErrorDataExportDto;
-import com.ym.mec.biz.dal.dto.OrganVipGroupCategoryCourseNumDto;
-import com.ym.mec.biz.dal.dto.SimpleUserDto;
+import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.dal.page.IndexDataQueryInfo;
+import com.ym.mec.biz.dal.page.OrganCloudStudyStudentDataQueryInfo;
+import com.ym.mec.biz.dal.page.OrganizationQueryInfo;
 import com.ym.mec.biz.service.EmployeeService;
 import com.ym.mec.biz.service.StudentExtracurricularExercisesSituationService;
 import com.ym.mec.biz.service.SysConfigService;
 import com.ym.mec.common.constant.CommonConstants;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
+import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
@@ -1221,4 +1221,103 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 
 		return resultMap;
 	}
+
+	@Override
+	public PageInfo<EduOrganStudentDataDto> organStudentOverView(List<Integer> organIds, OrganCloudStudyStudentDataQueryInfo queryInfo) {
+		PageInfo<EduOrganStudentDataDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+		List<Organization> organs = organizationDao.getOrgans(organIds);
+		pageInfo.setTotal(organs.size());
+
+		if(CollectionUtils.isEmpty(organs)){
+			return pageInfo;
+		}
+		Set<String> dataTypes = new HashSet<String>(){{
+			add(CLOUD_STUDY_LIVELY_STUDENT_NUM.getCode());add(MEMBER_STUDENT_NUM.getCode());add(EXPERIENCE_MEMBER_STUDENT_NUM.getCode());
+			add(NEW_MEMBER_STUDENT_NUM.getCode());add(ORGAN_TOTAL_STUDENT_NUM.getCode());}};
+
+
+		List<IndexBaseMonthData> indexBaseDatas = indexBaseMonthDataDao.getIndexBaseData(new HashSet<>(organIds), dataTypes, queryInfo.getDate(), queryInfo.getDate());
+
+		Map<Integer, Integer> organsStudentNumMap = indexBaseDatas.stream().filter(i->ORGAN_TOTAL_STUDENT_NUM.equals(i.getDataType())).collect(Collectors.toMap(IndexBaseMonthData::getOrganId, i->i.getActivateNum().intValue(), (i1, i2)->i1));
+
+		Map<Integer, Integer> organsVipStudentNumMap = indexBaseDatas.stream().filter(i->MEMBER_STUDENT_NUM.equals(i.getDataType())).collect(Collectors.toMap(IndexBaseMonthData::getOrganId, i->i.getActivateNum().intValue(), (i1, i2)->i1));
+
+		Map<Integer, Integer> organsEVipStudentNumMap = indexBaseDatas.stream().filter(i->EXPERIENCE_MEMBER_STUDENT_NUM.equals(i.getDataType())).collect(Collectors.toMap(IndexBaseMonthData::getOrganId, i->i.getActivateNum().intValue(), (i1, i2)->i1));
+
+		Map<Integer, Integer> organCloudStudyLivelyStudentNumMap =indexBaseDatas.stream().filter(i->CLOUD_STUDY_LIVELY_STUDENT_NUM.equals(i.getDataType())).collect(Collectors.toMap(IndexBaseMonthData::getOrganId, i->i.getActivateNum().intValue(), (i1, i2)->i1));
+
+		Map<Integer, Integer> organsNewMemberStudentNumMap = indexBaseDatas.stream().filter(i->NEW_MEMBER_STUDENT_NUM.equals(i.getDataType())).collect(Collectors.toMap(IndexBaseMonthData::getOrganId, i->i.getActivateNum().intValue(), (i1, i2)->i1));
+
+		List<EduOrganStudentDataDto> result = new ArrayList<>();
+
+		for (Organization organ : organs) {
+			EduOrganStudentDataDto organStudentVipData = new EduOrganStudentDataDto();
+			organStudentVipData.setOrganId(organ.getId());
+			organStudentVipData.setOrganName(organ.getName());
+			if(organsStudentNumMap.containsKey(organ.getId())){
+				organStudentVipData.setTotalStudentNum(organsStudentNumMap.get(organ.getId()));
+			}
+			if(organsVipStudentNumMap.containsKey(organ.getId())){
+				organStudentVipData.setVipStudentNum(organsVipStudentNumMap.get(organ.getId()));
+			}
+			if(organsEVipStudentNumMap.containsKey(organ.getId())){
+				organStudentVipData.seteVipStudentNum(organsEVipStudentNumMap.get(organ.getId()));
+			}
+			if(organCloudStudyLivelyStudentNumMap.containsKey(organ.getId())){
+				organStudentVipData.setCloudStudyLivelyStudentNum(organCloudStudyLivelyStudentNumMap.get(organ.getId()));
+			}
+			if(organsNewMemberStudentNumMap.containsKey(organ.getId())){
+				organStudentVipData.setCloudStudyLivelyStudentNum(organsNewMemberStudentNumMap.get(organ.getId()));
+			}
+			if(organStudentVipData.getCloudStudyLivelyStudentNum()>0&&organStudentVipData.getTotalStudentNum()>0){
+				organStudentVipData.setCloudStudyLivelyStudentDuty(new BigDecimal(organStudentVipData.getCloudStudyLivelyStudentNum()).divide(new BigDecimal(organStudentVipData.getTotalStudentNum()), 4, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).floatValue());
+			}
+			result.add(organStudentVipData);
+		}
+
+		Comparator<EduOrganStudentDataDto> comparing = null;
+		if(StringUtils.isNotBlank(queryInfo.getCloudStudyLivelyStudentNum())){
+			if(Objects.isNull(comparing)){
+				comparing = Comparator.comparing(EduOrganStudentDataDto::getCloudStudyLivelyStudentNum, "ASC".equals(queryInfo.getCloudStudyLivelyStudentNum())?Comparator.naturalOrder():Comparator.reverseOrder());
+			}else{
+				comparing.thenComparing(EduOrganStudentDataDto::getCloudStudyLivelyStudentNum, "ASC".equals(queryInfo.getCloudStudyLivelyStudentNum())?Comparator.naturalOrder():Comparator.reverseOrder());
+			}
+		}
+		if(StringUtils.isNotBlank(queryInfo.getVipStudentNum())){
+			if(Objects.isNull(comparing)){
+				comparing = Comparator.comparing(EduOrganStudentDataDto::getVipStudentNum, "ASC".equals(queryInfo.getVipStudentNum())?Comparator.naturalOrder():Comparator.reverseOrder());
+			}else{
+				comparing.thenComparing(EduOrganStudentDataDto::getVipStudentNum, "ASC".equals(queryInfo.getVipStudentNum())?Comparator.naturalOrder():Comparator.reverseOrder());
+			}
+		}
+		if(StringUtils.isNotBlank(queryInfo.geteVipStudentNum())){
+			if(Objects.isNull(comparing)){
+				comparing = Comparator.comparing(EduOrganStudentDataDto::geteVipStudentNum, "ASC".equals(queryInfo.geteVipStudentNum())?Comparator.naturalOrder():Comparator.reverseOrder());
+			}else{
+				comparing.thenComparing(EduOrganStudentDataDto::geteVipStudentNum, "ASC".equals(queryInfo.geteVipStudentNum())?Comparator.naturalOrder():Comparator.reverseOrder());
+			}
+		}
+		if(StringUtils.isNotBlank(queryInfo.getNewMemberStudentNum())){
+			if(Objects.isNull(comparing)){
+				comparing = Comparator.comparing(EduOrganStudentDataDto::getNewMemberStudentNum, "ASC".equals(queryInfo.getNewMemberStudentNum())?Comparator.naturalOrder():Comparator.reverseOrder());
+			}else{
+				comparing.thenComparing(EduOrganStudentDataDto::getNewMemberStudentNum, "ASC".equals(queryInfo.getNewMemberStudentNum())?Comparator.naturalOrder():Comparator.reverseOrder());
+			}
+		}
+		if(StringUtils.isNotBlank(queryInfo.getCloudStudyLivelyStudentDuty())){
+			if(Objects.isNull(comparing)){
+				comparing = Comparator.comparing(EduOrganStudentDataDto::getCloudStudyLivelyStudentDuty, "ASC".equals(queryInfo.getCloudStudyLivelyStudentDuty())?Comparator.naturalOrder():Comparator.reverseOrder());
+			}else{
+				comparing.thenComparing(EduOrganStudentDataDto::getCloudStudyLivelyStudentDuty, "ASC".equals(queryInfo.getCloudStudyLivelyStudentDuty())?Comparator.naturalOrder():Comparator.reverseOrder());
+			}
+		}
+
+		if(Objects.isNull(comparing)){
+			comparing = Comparator.comparing(EduOrganStudentDataDto::getOrganId);
+		}
+
+		result = result.stream().skip(pageInfo.getOffset()).limit(pageInfo.getLimit()).sorted(comparing).collect(Collectors.toList());
+		pageInfo.setRows(result);
+		return pageInfo;
+	}
 }

+ 16 - 0
mec-web/src/main/java/com/ym/mec/web/controller/IndexController.java

@@ -3,13 +3,16 @@ package com.ym.mec.web.controller;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.dto.EduOrganStudentDataDto;
 import com.ym.mec.biz.dal.entity.Employee;
 import com.ym.mec.biz.dal.enums.IndexErrorType;
 import com.ym.mec.biz.dal.page.IndexDataQueryInfo;
+import com.ym.mec.biz.dal.page.OrganCloudStudyStudentDataQueryInfo;
 import com.ym.mec.biz.service.EmployeeService;
 import com.ym.mec.biz.service.IndexBaseMonthDataService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.page.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
@@ -23,6 +26,7 @@ import org.springframework.web.bind.annotation.RestController;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 @Api(tags = "首页")
 @RequestMapping()
@@ -212,4 +216,16 @@ public class IndexController extends BaseController {
 			}
 		return succeed(indexService.getRemindMatterData(organId));
 	}
+
+	@ApiOperation("查询分部云教练学员汇总数据")
+	@GetMapping("/organStudentOverView")
+	public HttpResponseResult<PageInfo<EduOrganStudentDataDto>> organStudentOverView(OrganCloudStudyStudentDataQueryInfo queryInfo){
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
+		if (sysUser == null) {
+			return failed("用户信息获取失败");
+		}
+		Employee employee = employeeService.get(sysUser.getId());
+		List<Integer> organIds = Arrays.stream(employee.getOrganIdList().split(",")).map(id -> Integer.valueOf(id)).collect(Collectors.toList());
+		return succeed(indexService.organStudentOverView(organIds, queryInfo));
+	}
 }