|
@@ -6,8 +6,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import com.microsvc.toolkit.common.webportal.exception.BizException;
|
|
|
-import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
|
import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
import com.yonge.cooleshow.biz.dal.dao.StudentDao;
|
|
|
import com.yonge.cooleshow.biz.dal.dao.SubjectDao;
|
|
@@ -15,10 +15,20 @@ import com.yonge.cooleshow.biz.dal.dao.TeacherDao;
|
|
|
import com.yonge.cooleshow.biz.dal.dao.UserBindingTeacherDao;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.search.QueryMyFollowSearch;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.search.StudentSearch;
|
|
|
-import com.yonge.cooleshow.biz.dal.entity.*;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.Student;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.StudentTotal;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.Subject;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.UserBindingTeacher;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.UserTenantAlbumRecord;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.mapper.SysUserMapper;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.*;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.ImUserFriendService;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.StudentService;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.StudentTotalService;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.SysConfigService;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.UserTenantAlbumRecordService;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.MyFollow;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.StudentHomeVo;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.StudentVo;
|
|
@@ -30,7 +40,9 @@ import com.yonge.cooleshow.common.enums.CacheNameEnum;
|
|
|
import com.yonge.cooleshow.common.enums.UserLockFlag;
|
|
|
import com.yonge.cooleshow.common.enums.YesOrNoEnum;
|
|
|
import com.yonge.toolset.base.util.StringUtil;
|
|
|
+import com.yonge.toolset.mybatis.support.PageUtil;
|
|
|
import com.yonge.toolset.utils.date.DateUtil;
|
|
|
+import com.yonge.toolset.utils.easyexcel.ExcelDataReaderProperty;
|
|
|
import com.yonge.toolset.utils.string.ValueUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.redisson.api.RMap;
|
|
@@ -46,6 +58,7 @@ import java.text.MessageFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@Service
|
|
@@ -120,12 +133,15 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
|
|
|
studentHomeVo.setMusicSheetNum(null == total.getMusicSheetNum() ? 0 : total.getMusicSheetNum());
|
|
|
|
|
|
// IM聊天用户ID
|
|
|
- studentHomeVo.setImUserId(MessageFormat.format("{0}:{1}", String.valueOf(detail.getUserId()), ClientEnum.STUDENT.name()));
|
|
|
+ studentHomeVo.setImUserId(MessageFormat.format("{0}:{1}", String.valueOf(detail.getUserId()),
|
|
|
+ ClientEnum.STUDENT.name()));
|
|
|
|
|
|
// 判断是否是机构学生 机构学生 检测机构专辑购买记录
|
|
|
TenantInfo tenantInfo = tenantInfoService.detail(detail.getTenantId());
|
|
|
if (tenantInfo != null) {
|
|
|
- UserTenantAlbumRecord record = userTenantAlbumRecordService.getNewestByTenantIdAndUserId(tenantInfo.getId(), detail.getUserId(), ClientEnum.STUDENT);
|
|
|
+ UserTenantAlbumRecord record =
|
|
|
+ userTenantAlbumRecordService.getNewestByTenantIdAndUserId(tenantInfo.getId(), detail.getUserId(),
|
|
|
+ ClientEnum.STUDENT);
|
|
|
if (record == null || record.getEndTime().getTime() < System.currentTimeMillis()) {
|
|
|
studentHomeVo.setTenantAlbumFlag(YesOrNoEnum.NO);
|
|
|
} else {
|
|
@@ -353,6 +369,57 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public void importStudentExcel(List<ExcelDataReaderProperty<StudentWrapper.StudentExport>> dataList, Long id) {
|
|
|
+ if (dataList.isEmpty()) {
|
|
|
+ throw new BizException("导入数据不能为空");
|
|
|
+ }
|
|
|
+ dataList.sort(Comparator.comparingInt(ExcelDataReaderProperty::getRowIndex));
|
|
|
+
|
|
|
+ // 校验数据的完整性
|
|
|
+ List<String> errMsg = new ArrayList<>();
|
|
|
+ Map<String, Integer> phoneMap = new HashMap<>();
|
|
|
+ for (ExcelDataReaderProperty<StudentWrapper.StudentExport> next : dataList) {
|
|
|
+ Integer rowIndex = next.getRowIndex();
|
|
|
+ StudentWrapper.StudentExport student = next.getClazz();
|
|
|
+
|
|
|
+ student.checkValid().forEach(err -> errMsg.add(String.format("第%s行%s", rowIndex, err)));
|
|
|
+
|
|
|
+ if (phoneMap.containsKey(student.getPhone().trim())) {
|
|
|
+ errMsg.add(String.format("第%s行手机号重复", rowIndex));
|
|
|
+ } else {
|
|
|
+ phoneMap.put(student.getPhone().trim(), rowIndex);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (errMsg.size() > 100) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ int row = 100;
|
|
|
+ int page = 1;
|
|
|
+ List<List<String>> phonePartition = Lists.partition(new ArrayList<>(phoneMap.keySet()), row);
|
|
|
+
|
|
|
+ StudentSearch studentSearch = new StudentSearch();
|
|
|
+ studentSearch.setRows(row);
|
|
|
+ studentSearch.setPage(page);
|
|
|
+ for (List<String> phones : phonePartition) {
|
|
|
+ studentSearch.setPhoneList(phones);
|
|
|
+ List<StudentVo> studentVos = baseMapper.selectPage(PageUtil.getPage(studentSearch), studentSearch);
|
|
|
+ page++;
|
|
|
+
|
|
|
+ if (!studentVos.isEmpty()) {
|
|
|
+ List<String> existPhoneList = studentVos.stream().map(StudentVo::getPhone).collect(Collectors.toList());
|
|
|
+ existPhoneList.forEach(phone -> errMsg.add(String.format("第%s行手机号已经注册学生", phoneMap.get(phone))));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!errMsg.isEmpty()) {
|
|
|
+ throw new BizException(String.join(",", errMsg));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private Boolean updateStudent(StudentWrapper.Student studentInfo) {
|
|
|
StudentVo student = detail(studentInfo.getId());
|
|
|
if (student == null) {
|