|
@@ -2,23 +2,41 @@ package com.qmth.exam.reserve.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.qmth.boot.core.collection.PageResult;
|
|
import com.qmth.boot.core.exception.StatusException;
|
|
import com.qmth.boot.core.exception.StatusException;
|
|
|
|
+import com.qmth.boot.core.fss.store.FileStore;
|
|
import com.qmth.exam.reserve.bean.stdapply.CategoryVO;
|
|
import com.qmth.exam.reserve.bean.stdapply.CategoryVO;
|
|
import com.qmth.exam.reserve.bean.student.StudentInfo;
|
|
import com.qmth.exam.reserve.bean.student.StudentInfo;
|
|
|
|
+import com.qmth.exam.reserve.bean.student.StudentReq;
|
|
|
|
+import com.qmth.exam.reserve.bean.student.StudentVO;
|
|
import com.qmth.exam.reserve.bean.student.WechatBindReq;
|
|
import com.qmth.exam.reserve.bean.student.WechatBindReq;
|
|
import com.qmth.exam.reserve.cache.impl.CategoryCacheService;
|
|
import com.qmth.exam.reserve.cache.impl.CategoryCacheService;
|
|
import com.qmth.exam.reserve.dao.StudentDao;
|
|
import com.qmth.exam.reserve.dao.StudentDao;
|
|
|
|
+import com.qmth.exam.reserve.entity.ApplyTaskEntity;
|
|
|
|
+import com.qmth.exam.reserve.entity.StudentApplyEntity;
|
|
import com.qmth.exam.reserve.entity.StudentEntity;
|
|
import com.qmth.exam.reserve.entity.StudentEntity;
|
|
-import com.qmth.exam.reserve.service.StudentService;
|
|
+import com.qmth.exam.reserve.enums.AsyncTaskType;
|
|
|
|
+import com.qmth.exam.reserve.enums.EventType;
|
|
|
|
+import com.qmth.exam.reserve.service.*;
|
|
|
|
+import com.qmth.exam.reserve.template.execute.StudentPhotoUploadService;
|
|
|
|
+import com.qmth.exam.reserve.util.FileUtil;
|
|
|
|
+import com.qmth.exam.reserve.util.PageUtil;
|
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.io.IOException;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> implements StudentService {
|
|
public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> implements StudentService {
|
|
@@ -28,6 +46,24 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
|
|
@Autowired
|
|
@Autowired
|
|
private CategoryCacheService categoryCacheService;
|
|
private CategoryCacheService categoryCacheService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private StudentApplyService studentApplyService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private OperateLogService operateLogService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ApplyTaskService applyTaskService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private FileStore fileStore;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private AsyncTaskService asyncTaskService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private StudentPhotoUploadService studentPhotoUploadService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public StudentEntity findByStudentCode(Long applyTaskId, String studentCode) {
|
|
public StudentEntity findByStudentCode(Long applyTaskId, String studentCode) {
|
|
if (StringUtils.isEmpty(studentCode)) {
|
|
if (StringUtils.isEmpty(studentCode)) {
|
|
@@ -146,4 +182,76 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
|
|
return baseMapper.listNoFinishCategory(taskId, cancel);
|
|
return baseMapper.listNoFinishCategory(taskId, cancel);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public PageResult<StudentVO> pageStudent(StudentReq req) {
|
|
|
|
+ if(req.getTaskId() == null) {
|
|
|
|
+ return new PageResult<>();
|
|
|
|
+ }
|
|
|
|
+ IPage<StudentVO> iPage = baseMapper.pageStudent(new Page<>(req.getPageNumber(), req.getPageSize()), req);
|
|
|
|
+ return PageUtil.of(iPage);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void delete(Long studentId, Long operateId) {
|
|
|
|
+ List<StudentApplyEntity> studentApplyList = getStudentApplyList(studentId);
|
|
|
|
+ if (CollectionUtils.isNotEmpty(studentApplyList)) {
|
|
|
|
+ log.warn("[考生删除] 删除失败,存在预约信息,student_id:{}", studentId);
|
|
|
|
+ throw new StatusException("考生存在预约信息,无法删除");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.removeById(studentId);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ operateLogService.insertOperateLog(operateId, EventType.DELETE_STUDENT, studentId.toString());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<StudentApplyEntity> getStudentApplyList(Long studentId) {
|
|
|
|
+ LambdaQueryWrapper<StudentApplyEntity> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.eq(StudentApplyEntity::getStudentId, studentId);
|
|
|
|
+ wrapper.eq(StudentApplyEntity::getCancel, Boolean.FALSE);
|
|
|
|
+ return studentApplyService.list(wrapper);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void modifyApplyNumber(Long studentId, Long operateId, Integer applyNumber) {
|
|
|
|
+ if (applyNumber == null || applyNumber <= 0) {
|
|
|
|
+ throw new StatusException("考生的预约次数必须大于0");
|
|
|
|
+ }
|
|
|
|
+ List<StudentApplyEntity> studentApplyList = getStudentApplyList(studentId);
|
|
|
|
+ if (CollectionUtils.isNotEmpty(studentApplyList) && applyNumber < studentApplyList.size()) {
|
|
|
|
+ throw new StatusException("考生已预约了" + studentApplyList.size() + "次,不能小于已经预约的次数");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ LambdaUpdateWrapper<StudentEntity> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
|
+ updateWrapper.eq(StudentEntity::getId, studentId);
|
|
|
|
+ updateWrapper.set(StudentEntity::getApplyNumber, applyNumber);
|
|
|
|
+ this.update(updateWrapper);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ operateLogService.insertOperateLog(operateId, EventType.MODIFY_APPLY_NUMBER, studentId + "->" + applyNumber);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void uploadStudentPhoto(Long operateId, MultipartFile file) throws IOException {
|
|
|
|
+ ApplyTaskEntity applyTask = applyTaskService.findApplyTask();
|
|
|
|
+ if (applyTask == null) {
|
|
|
|
+ throw new StatusException("未开启预约任务,无法导入");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ File tempFile = FileUtil.getFileTemp(".zip");
|
|
|
|
+ if (tempFile != null) {
|
|
|
|
+ file.transferTo(tempFile);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Map<String, Object> taskMap = asyncTaskService.saveAsyncTask(AsyncTaskType.UPLOAD_STUDENT_PHOTO, operateId);
|
|
|
|
+ taskMap.computeIfAbsent("taskId", v -> applyTask.getId());
|
|
|
|
+ taskMap.computeIfAbsent("operateId", v -> operateId);
|
|
|
|
+ try {
|
|
|
|
+ studentPhotoUploadService.uploadTask(taskMap, tempFile);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new StatusException(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|