|
@@ -15,6 +15,7 @@ import com.ym.mec.biz.service.SysMessageService;
|
|
|
import com.ym.mec.biz.service.SysMusicCompareRecordService;
|
|
|
import com.ym.mec.biz.service.SysMusicCompareWeekDataService;
|
|
|
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.thirdparty.message.MessageSenderPluginContext;
|
|
@@ -48,11 +49,16 @@ public class SysMusicCompareRecordServiceImpl extends BaseServiceImpl<Long, SysM
|
|
|
@Autowired
|
|
|
private StudentDao studentDao;
|
|
|
@Autowired
|
|
|
+ private StudentVisitDao studentVisitDao;
|
|
|
+ @Autowired
|
|
|
private SysMessageService sysMessageService;
|
|
|
|
|
|
@Autowired
|
|
|
private SysConfigDao sysConfigDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupDao musicGroupDao;
|
|
|
+
|
|
|
@Override
|
|
|
public BaseDAO<Long, SysMusicCompareRecord> getDAO() {
|
|
|
return sysMusicCompareRecordDao;
|
|
@@ -327,16 +333,65 @@ public class SysMusicCompareRecordServiceImpl extends BaseServiceImpl<Long, SysM
|
|
|
|
|
|
@Override
|
|
|
public PageInfo<CountStudentTrainDataDto> countStudentTrain(SysMusicCompareRecordQueryInfo queryInfo) {
|
|
|
+ if(queryInfo.getStartTime() == null || queryInfo.getEndTime() == null){
|
|
|
+ throw new BizException("请选择训练时间");
|
|
|
+ }
|
|
|
PageInfo<CountStudentTrainDataDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
+ String sort = queryInfo.getSort();
|
|
|
+ if(StringUtils.isNotEmpty(sort)){
|
|
|
+ queryInfo.setSort(sort.equals("trainNum")?"train_num_":sort.equals("totalPlayTime")?"total_play_time_":sort.equals("recordNum")?"record_num_":"train_day_");
|
|
|
+ }
|
|
|
MapUtil.populateMap(params, queryInfo);
|
|
|
-
|
|
|
+ Integer visitFlag = 0;
|
|
|
+ if(queryInfo.getVisitFlag() != null && queryInfo.getVisitFlag()){
|
|
|
+ //获取乐团在读,有vip网管课的学员列表
|
|
|
+ List<Integer> hasCourseUserIds = studentDao.getStudentByHasCourse(queryInfo.getTeacherId());
|
|
|
+ if(hasCourseUserIds == null || hasCourseUserIds.size() == 0){
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
+ params.put("hasCourseUserIds",hasCourseUserIds);
|
|
|
+ //获取所选时间段下一周的日期
|
|
|
+ Date addDays1 = DateUtil.addDays(DateUtil.toDate(queryInfo.getEndTime()), 1);
|
|
|
+ Date addDays3 = DateUtil.addDays(DateUtil.toDate(queryInfo.getEndTime()), 3);
|
|
|
+ //有回访过的学员列表
|
|
|
+ List<Integer> studentIds = studentVisitDao.queryRecordVisitStudentIds(queryInfo.getTeacherId(),addDays1,addDays3);
|
|
|
+ if(studentIds != null && studentIds.size() > 0){
|
|
|
+ params.put("visitStudents",studentIds);
|
|
|
+ }
|
|
|
+ Date date = DateUtil.toDate(DateUtil.format(new Date(),DateUtil.ISO_EXPANDED_DATE_FORMAT));
|
|
|
+ int daysBetween = DateUtil.daysBetween(addDays1, date);
|
|
|
+ //每周只有前三天可以回访
|
|
|
+ if(daysBetween >= 0 && daysBetween <= 2){
|
|
|
+ visitFlag = 1;
|
|
|
+ }
|
|
|
+ params.put("having",1);
|
|
|
+ }
|
|
|
+ String totalTime = sysConfigDao.findConfigValue(SysConfigService.STUDENT_CLOUD_TEACHER_TOTAL_PLAY_TIME);
|
|
|
+ if(StringUtils.isEmpty(totalTime)){
|
|
|
+ totalTime = "80";
|
|
|
+ }
|
|
|
+ params.put("totalTime",Integer.parseInt(totalTime));
|
|
|
+ String trainNum = sysConfigDao.findConfigValue(SysConfigService.STUDENT_CLOUD_TEACHER_TRAIN_NUM);
|
|
|
+ if(StringUtils.isEmpty(trainNum)){
|
|
|
+ trainNum = "4";
|
|
|
+ }
|
|
|
+ params.put("trainNum",Integer.parseInt(trainNum));
|
|
|
+ int count = sysMusicCompareRecordDao.queryStudentTrain(params).size();
|
|
|
List<CountStudentTrainDataDto> dataList = new ArrayList<>();
|
|
|
- int count = sysMusicCompareRecordDao.countStudentTrain(params);
|
|
|
- if (count > 0) {
|
|
|
- pageInfo.setTotal(count);
|
|
|
+ if(count > 0){
|
|
|
params.put("offset", pageInfo.getOffset());
|
|
|
- dataList =sysMusicCompareRecordDao.queryStudentTrain(params);
|
|
|
+ dataList = sysMusicCompareRecordDao.queryStudentTrain(params);
|
|
|
+ List<Integer> studentIds = dataList.stream().map(e -> e.getUserId()).collect(Collectors.toList());
|
|
|
+ //获取学员在读,进行中的乐团名称
|
|
|
+ Map<Integer,String> groupNameMap = MapUtil.convertMybatisMap(musicGroupDao.queryNormalGroupName(studentIds));
|
|
|
+ pageInfo.setTotal(count);
|
|
|
+ for (CountStudentTrainDataDto e : dataList) {
|
|
|
+ e.setMusicGroupName(groupNameMap.get(e.getUserId()));
|
|
|
+ if(visitFlag == 1){
|
|
|
+ e.setVisitFlag(visitFlag);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
pageInfo.setRows(dataList);
|
|
|
return pageInfo;
|