|
|
@@ -1,9 +1,12 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.ym.mec.biz.dal.dao.*;
|
|
|
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.CloudTeacherActiveQueryInfo;
|
|
|
import com.ym.mec.biz.dal.page.OrganCloudStudyStudentDataQueryInfo;
|
|
|
import com.ym.mec.biz.dal.page.StudentQueryInfo;
|
|
|
import com.ym.mec.biz.service.StudentService;
|
|
|
@@ -13,18 +16,15 @@ 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.page.QueryInfo;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
-import sun.nio.cs.ext.Big5;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDate;
|
|
|
@@ -41,36 +41,28 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
|
|
|
private StudentDao studentDao;
|
|
|
@Autowired
|
|
|
private TeacherDao teacherDao;
|
|
|
-
|
|
|
@Autowired
|
|
|
private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
|
|
|
-
|
|
|
@Autowired
|
|
|
private StudentRegistrationDao studentRegistrationDao;
|
|
|
-
|
|
|
@Autowired
|
|
|
private MusicGroupDao musicGroupDao;
|
|
|
-
|
|
|
@Autowired
|
|
|
private PracticeGroupDao practiceGroupDao;
|
|
|
-
|
|
|
@Autowired
|
|
|
private MemberRankSettingDao memberRankSettingDao;
|
|
|
-
|
|
|
@Autowired
|
|
|
private SysConfigDao sysConfigDao;
|
|
|
@Autowired
|
|
|
private SysMessageService sysMessageService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private SysMusicCompareRecordDao sysMusicCompareRecordDao;
|
|
|
-
|
|
|
@Autowired
|
|
|
private CloudTeacherDao cloudTeacherDao;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private CloudTeacherOrderDao cloudTeacherOrderDao;
|
|
|
@Autowired
|
|
|
private OrganizationDao organizationDao;
|
|
|
-
|
|
|
@Autowired
|
|
|
private IndexBaseMonthDataDao indexBaseMonthDataDao;
|
|
|
|
|
|
@@ -654,23 +646,6 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
|
|
|
organsNewCloudStudyNumMap = MapUtil.convertIntegerMap(organsNewCloudStudyNumMapList);
|
|
|
}
|
|
|
|
|
|
- //获取新增人数占比(已上乐团课小于等于4)
|
|
|
- //获取有在读学员的乐团编号
|
|
|
- //获取有在读学员的学员编号
|
|
|
-// List<String> musicGroupIds = studentRegistrationDao.findMusicGroupIds();
|
|
|
-// List<Integer> studentIdList = studentRegistrationDao.findStudentIds();
|
|
|
-// List<BaseMapDto<Integer, Long>> studentMusicCourseNum = studentDao.getOrganCloudNewStudentNum(musicGroupIds,studentIdList);
|
|
|
-// //获取有乐团没排课的数据
|
|
|
-// List<Integer> noCourseStudentIdList = studentRegistrationDao.findNoCourseStudentIds();
|
|
|
-// List<Integer> userIdList = new ArrayList<>();
|
|
|
-// if(!CollectionUtils.isEmpty(studentMusicCourseNum)){
|
|
|
-// List<BaseMapDto<Integer, Long>> collect = studentMusicCourseNum.stream().filter(e -> e.getValue() < 5).collect(Collectors.toList());
|
|
|
-// userIdList = collect.stream().map(e -> e.getKey()).collect(Collectors.toList());
|
|
|
-// }
|
|
|
-// userIdList.addAll(noCourseStudentIdList);
|
|
|
-// List<Map<Long, Long>> organsNewCloudNewStudentNumMapList = studentDao.groupOrganId(organIds,userIdList);
|
|
|
-// Map<String, Long> organsNewCloudNewStudentNumMap = MapUtil.convertIntegerMap(organsNewCloudNewStudentNumMapList);
|
|
|
-
|
|
|
List<IndexBaseMonthData> withDayAndDataType = indexBaseMonthDataDao.getWithDayAndDataType(LocalDate.now().toString(), CLOUD_NEW_STUDENT_NUM);
|
|
|
Map<Integer, Integer> organsNewCloudNewStudentNumMap = withDayAndDataType.stream().collect(Collectors.toMap(IndexBaseMonthData::getOrganId, e -> e.getActivateNum().intValue(), (e1, e2) -> e1));
|
|
|
|
|
|
@@ -686,9 +661,6 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
|
|
|
if(organsVipStudentNumMap.containsKey(organ.getId().toString())){
|
|
|
organStudentVipData.setVipStudentNum(organsVipStudentNumMap.get(organ.getId().toString()).intValue());
|
|
|
}
|
|
|
-// if(organsEVipStudentNumMap.containsKey(organ.getId().toString())){
|
|
|
-// organStudentVipData.seteVipStudentNum(organsEVipStudentNumMap.get(organ.getId().toString()).intValue());
|
|
|
-// }
|
|
|
if(organCloudStudyStudentNumMap.containsKey(organ.getId().toString())){
|
|
|
organStudentVipData.setCloudStudyUseStudentNum(organCloudStudyStudentNumMap.get(organ.getId().toString()).intValue());
|
|
|
}
|
|
|
@@ -815,4 +787,170 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
|
|
|
public void cleanStudentCloudStudySequenceDays() {
|
|
|
studentDao.cleanStudentCloudStudySequenceDays();
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void remarkCountFlag() {
|
|
|
+ //清除标记
|
|
|
+ studentDao.cleanCountFlag();
|
|
|
+ //打标记
|
|
|
+ List<Integer> studentIds = new ArrayList<>();
|
|
|
+ //获取在会员团的学员
|
|
|
+ studentIds.addAll(studentRegistrationDao.queryHasMemberGroupStudent());
|
|
|
+ //获取购买过云教练(非活动)的学员
|
|
|
+ studentIds.addAll(cloudTeacherOrderDao.getStudentIds());
|
|
|
+ studentDao.remarkCountFlag(studentIds);
|
|
|
+ //更新目标学员、目标金额
|
|
|
+ SysConfig config = sysConfigDao.findByParamName("cloud_teacher_active_target");
|
|
|
+ config.setParanValue(JSON.toJSONString(studentRegistrationDao.queryOrganTarget()));
|
|
|
+ sysConfigDao.update(config);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String,Object> countCloudTeacherActive(List<Integer> organIdList, CloudTeacherActiveQueryInfo queryInfo) {
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
+ MapUtil.populateMap(params, queryInfo);
|
|
|
+ //获取分部目标
|
|
|
+ String cloudTeacherActiveTarget = sysConfigDao.findConfigValue(SysConfigService.CLOUD_TEACHER_ACTIVE_TARGET);
|
|
|
+ if(StringUtils.isEmpty(cloudTeacherActiveTarget)){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<CloudTeacherActiveTargetDto> targetDtoList = JSONArray.parseArray(cloudTeacherActiveTarget, CloudTeacherActiveTargetDto.class);
|
|
|
+ Map<Integer, List<CloudTeacherActiveTargetDto>> targetMap = targetDtoList.stream().collect(Collectors.groupingBy(e -> e.getOrganId()));
|
|
|
+ //获取各分部总人数
|
|
|
+ List<Map<String, Long>> maps = indexBaseMonthDataDao.countTotalStudentNum();
|
|
|
+ Map<String, Long> organStudentNumMap = new HashMap<>(20);
|
|
|
+ if(maps != null && maps.size() > 0){
|
|
|
+ organStudentNumMap = MapUtil.convertIntegerMap(maps);
|
|
|
+ }
|
|
|
+ params.put("organIdList",organIdList);
|
|
|
+ List<CloudTeacherActiveTargetDto> resultList = indexBaseMonthDataDao.countCloudTeacherActive(params);
|
|
|
+ for (CloudTeacherActiveTargetDto dto : resultList) {
|
|
|
+ Long aLong = organStudentNumMap.get(dto.getOrganId().toString());
|
|
|
+ dto.setTotalNum(aLong==null?0:aLong.intValue());
|
|
|
+ List<CloudTeacherActiveTargetDto> targetDtos = targetMap.get(dto.getOrganId());
|
|
|
+ if(targetDtos != null && targetDtos.size() > 0){
|
|
|
+ CloudTeacherActiveTargetDto target = targetDtos.get(0);
|
|
|
+ dto.setTargetNum(target.getTargetNum());
|
|
|
+ dto.setTargetAmount(target.getTargetAmount());
|
|
|
+ }
|
|
|
+ if(dto.getBuyAmount().doubleValue() > 0d && dto.getBuyNum() > 0){
|
|
|
+ BigDecimal avgBuyAmount = dto.getBuyAmount().divide(new BigDecimal(dto.getBuyNum()), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP);
|
|
|
+ dto.setAvgBuyAmount(avgBuyAmount);
|
|
|
+ }
|
|
|
+ if(dto.getTotalNum() > 0 && dto.getBuyNum() > 0){
|
|
|
+ BigDecimal buyScale = new BigDecimal(dto.getBuyNum()).divide(new BigDecimal(dto.getTotalNum()), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
|
|
|
+ dto.setBuyScale(buyScale);
|
|
|
+ }
|
|
|
+ if(dto.getTargetNum() > 0 && dto.getBuyNum() > 0){
|
|
|
+ BigDecimal targetFinishScale = new BigDecimal(dto.getBuyNum()).divide(new BigDecimal(dto.getTargetNum()), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
|
|
|
+ dto.setTargetFinishScale(targetFinishScale);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map<String,Object> resultMap = new HashMap<>(7);
|
|
|
+ BigDecimal targetAmount = resultList.stream().map(CloudTeacherActiveTargetDto::getTargetAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ resultMap.put("targetAmount",targetAmount);
|
|
|
+ BigDecimal buyAmount = resultList.stream().map(CloudTeacherActiveTargetDto::getBuyAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ resultMap.put("buyAmount",buyAmount);
|
|
|
+ Integer buyNum = resultList.stream().mapToInt(CloudTeacherActiveTargetDto::getBuyNum).sum();
|
|
|
+ resultMap.put("buyNum",buyNum);
|
|
|
+ Integer totalNum = resultList.stream().mapToInt(CloudTeacherActiveTargetDto::getTotalNum).sum();
|
|
|
+ resultMap.put("totalNum",totalNum);
|
|
|
+ Integer targetNum = resultList.stream().mapToInt(CloudTeacherActiveTargetDto::getTargetNum).sum();
|
|
|
+ resultMap.put("targetNum",targetNum);
|
|
|
+ resultMap.put("avgBuyAmount",0);
|
|
|
+ resultMap.put("buyScale",0);
|
|
|
+ resultMap.put("targetFinishScale",0);
|
|
|
+ if(buyAmount.doubleValue() > 0d && buyNum > 0){
|
|
|
+ BigDecimal avgBuyAmount = buyAmount.divide(new BigDecimal(buyNum), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP);
|
|
|
+ resultMap.put("avgBuyAmount",avgBuyAmount);
|
|
|
+ }
|
|
|
+ if(totalNum > 0 && buyNum > 0){
|
|
|
+ BigDecimal buyScale = new BigDecimal(buyNum).divide(new BigDecimal(totalNum), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
|
|
|
+ resultMap.put("buyScale",buyScale);
|
|
|
+ }
|
|
|
+ if(targetNum > 0 && buyNum > 0){
|
|
|
+ BigDecimal targetFinishScale = new BigDecimal(buyNum).divide(new BigDecimal(targetNum), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
|
|
|
+ resultMap.put("targetFinishScale",targetFinishScale);
|
|
|
+ }
|
|
|
+ Map<String,Object> result = new HashMap<>(2);
|
|
|
+ result.put("head",resultMap);
|
|
|
+ String sort = queryInfo.getSort();
|
|
|
+ if(StringUtils.isEmpty(sort)){
|
|
|
+ sort = "targetFinishScale";
|
|
|
+ }
|
|
|
+ String order = queryInfo.getOrder();
|
|
|
+ switch (sort){
|
|
|
+ case "buyAmount":
|
|
|
+ if("DESC".equalsIgnoreCase(order)){
|
|
|
+ resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getBuyAmount,Comparator.reverseOrder())).collect(Collectors.toList());
|
|
|
+ }else {
|
|
|
+ resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getBuyAmount)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "buyNum":
|
|
|
+ if("DESC".equalsIgnoreCase(order)){
|
|
|
+ resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getBuyNum,Comparator.reverseOrder())).collect(Collectors.toList());
|
|
|
+ }else {
|
|
|
+ resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getBuyNum)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "avgBuyAmount":
|
|
|
+ if("DESC".equalsIgnoreCase(order)){
|
|
|
+ resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getAvgBuyAmount,Comparator.reverseOrder())).collect(Collectors.toList());
|
|
|
+ }else {
|
|
|
+ resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getAvgBuyAmount)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "totalNum":
|
|
|
+ if("DESC".equalsIgnoreCase(order)){
|
|
|
+ resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getTotalNum,Comparator.reverseOrder())).collect(Collectors.toList());
|
|
|
+ }else {
|
|
|
+ resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getTotalNum)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "buyScale":
|
|
|
+ if("DESC".equalsIgnoreCase(order)){
|
|
|
+ resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getBuyScale,Comparator.reverseOrder())).collect(Collectors.toList());
|
|
|
+ }else {
|
|
|
+ resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getBuyScale)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "targetNum":
|
|
|
+ if("DESC".equalsIgnoreCase(order)){
|
|
|
+ resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getTargetNum,Comparator.reverseOrder())).collect(Collectors.toList());
|
|
|
+ }else {
|
|
|
+ resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getTargetNum)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "targetFinishScale":
|
|
|
+ if("DESC".equalsIgnoreCase(order)){
|
|
|
+ resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getTargetFinishScale,Comparator.reverseOrder())).collect(Collectors.toList());
|
|
|
+ }else {
|
|
|
+ resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getTargetFinishScale)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ result.put("resultList",resultList);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageInfo<CloudTeacherActiveTargetDetailDto> countCloudTeacherActiveDetail(CloudTeacherActiveQueryInfo queryInfo) {
|
|
|
+ PageInfo<CloudTeacherActiveTargetDetailDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
+ MapUtil.populateMap(params, queryInfo);
|
|
|
+
|
|
|
+ List<CloudTeacherActiveTargetDetailDto> dataList = null;
|
|
|
+ int count = cloudTeacherOrderDao.countCloudTeacherActiveDetail(params);
|
|
|
+ if (count > 0) {
|
|
|
+ pageInfo.setTotal(count);
|
|
|
+ params.put("offset", pageInfo.getOffset());
|
|
|
+ dataList = cloudTeacherOrderDao.queryCloudTeacherActiveDetail(params);
|
|
|
+ }
|
|
|
+ if (count == 0) {
|
|
|
+ dataList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ pageInfo.setRows(dataList);
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
}
|