feat: 还原
This commit is contained in:
+147
@@ -0,0 +1,147 @@
|
||||
package com.yida.data.school.transaction.controller;
|
||||
|
||||
import cc.mrbird.febs.common.redis.service.RedisService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.yida.data.common.core.annotation.ControllerLog;
|
||||
import com.yida.data.common.core.common.ResultBean;
|
||||
import com.yida.data.common.core.entity.apply.EduApply;
|
||||
import com.yida.data.common.core.entity.apply.EduStudentApply;
|
||||
import com.yida.data.common.core.entity.constant.CachePrefixConstant;
|
||||
import com.yida.data.common.core.entity.constant.FebsConstant;
|
||||
import com.yida.data.common.core.utils.FebsUtil;
|
||||
import com.yida.data.school.transaction.service.EduStudentApplyService;
|
||||
import com.yida.data.school.vo.transcation.EduApplyVO;
|
||||
import com.yida.data.school.vo.transcation.StudentApplyImportProgressVO;
|
||||
import com.yida.data.school.vo.transcation.StudentApplyStatusVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import java.util.UUID;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Api(tags = "交易-学生应用关系")
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/transaction/studentApply")
|
||||
@RestController
|
||||
public class EduStudentApplyController {
|
||||
|
||||
private final EduStudentApplyService eduStudentApplyService;
|
||||
|
||||
private final RedisService redisService;
|
||||
|
||||
|
||||
@ApiOperation("分页查询学生开通应用")
|
||||
@GetMapping("/listStudentApply")
|
||||
@ControllerLog(operation = "分页查询学生开通应用")
|
||||
public ResultBean<IPage<EduStudentApply>> listApply(
|
||||
@ApiParam("学生名字") @RequestParam(required = false) String studentName,
|
||||
@ApiParam("学号") @RequestParam(required = false) String studentNumber,
|
||||
@ApiParam("学校ID") @RequestParam(required = false) Long schoolId,
|
||||
@ApiParam("校区ID") @RequestParam(required = false) Long campusId,
|
||||
@ApiParam("学段ID") @RequestParam(required = false) Long sectionId,
|
||||
@ApiParam("年级ID") @RequestParam(required = false) Long gradeId,
|
||||
@ApiParam("班级ID") @RequestParam(required = false) Long classId,
|
||||
@ApiParam("当前页码") @RequestParam(defaultValue = "1") Integer pageNum,
|
||||
@ApiParam("页面大小") @RequestParam(defaultValue = "10") Integer pageSize) {
|
||||
Page<EduStudentApply> page = new Page<>();
|
||||
page.setCurrent(pageNum);
|
||||
page.setSize(pageSize);
|
||||
|
||||
return ResultBean.buildSuccess(
|
||||
eduStudentApplyService
|
||||
.listStudentApply(studentName, studentNumber, schoolId, sectionId, campusId, gradeId, classId, page));
|
||||
}
|
||||
|
||||
@ApiOperation("获取开通应用详情")
|
||||
@GetMapping("/getStudentApply")
|
||||
@ControllerLog(operation = "获取开通应用详情")
|
||||
public ResultBean<EduStudentApply> getStudentApply(@ApiParam("主键ID") Long id) {
|
||||
return ResultBean.buildSuccess(eduStudentApplyService.getById(id));
|
||||
}
|
||||
|
||||
@ApiOperation("删除开通应用")
|
||||
@GetMapping("/deleteStudentApply")
|
||||
@ControllerLog(operation = "删除学生开通应用")
|
||||
public ResultBean deleteStudentApply(@ApiParam("主键ID") Long id) {
|
||||
eduStudentApplyService.update(Wrappers.lambdaUpdate(new EduStudentApply())
|
||||
.eq(EduStudentApply::getId, id)
|
||||
.set(EduStudentApply::getDelFlag, 1));
|
||||
return ResultBean.buildSuccess();
|
||||
}
|
||||
|
||||
@ApiOperation("保存学生开通应用")
|
||||
@PostMapping("/saveStudentApply")
|
||||
@ControllerLog(operation = "保存学生开通应用")
|
||||
public ResultBean insertApply(@ApiParam("开通应用") @RequestBody EduStudentApply eduStudentApply) {
|
||||
eduStudentApplyService.save(eduStudentApply);
|
||||
return ResultBean.buildSuccess();
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("查询学生是否拥有该应用权限")
|
||||
@GetMapping("/hasApply")
|
||||
public ResultBean<Boolean> listApplyCode(@ApiParam("学生id") Long studentId,
|
||||
@ApiParam("应用编码") String applyCode) {
|
||||
return ResultBean.buildSuccess(eduStudentApplyService.count(Wrappers.lambdaQuery(new EduStudentApply())
|
||||
.eq(EduStudentApply::getStudentId, studentId)
|
||||
.eq(EduStudentApply::getApplyCode, applyCode)
|
||||
.ge(EduStudentApply::getEndTime, LocalDateTime.now())
|
||||
.le(EduStudentApply::getStartTime, LocalDateTime.now())) > 0);
|
||||
}
|
||||
|
||||
@ApiOperation("查询学生的应用状态")
|
||||
@GetMapping("/getApplyStatus")
|
||||
public ResultBean<StudentApplyStatusVO> getApplyStatus(@ApiParam("学生id") Long studentId,
|
||||
@ApiParam("应用编码") String applyCode) {
|
||||
return ResultBean.buildSuccess(eduStudentApplyService.getStudentApplyStatus(studentId, applyCode));
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("下载学生开通应用导入模板")
|
||||
@PostMapping("/downloadTemplate")
|
||||
public void downloadTemplate(HttpServletResponse response) throws Exception {
|
||||
eduStudentApplyService.downloadTemplate(response);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("导入学生开通应用信息")
|
||||
@PostMapping("/importStudentApplyInfo")
|
||||
public ResultBean<StudentApplyImportProgressVO> importStudentApplyInfo(@RequestParam(value = "file") MultipartFile file)
|
||||
throws Exception {
|
||||
String redisKey = UUID.randomUUID().toString();
|
||||
StudentApplyImportProgressVO progressVO = new StudentApplyImportProgressVO();
|
||||
progressVO.setRedisKey(redisKey);
|
||||
progressVO.setFinish(0);
|
||||
progressVO.setTotalNum(0);
|
||||
progressVO.setCurrentNum(0);
|
||||
redisService.hset(CachePrefixConstant.IMPORT_STUDENT_APPLY_PROGRESS, redisKey, progressVO);
|
||||
eduStudentApplyService.importStudentApplyInfo(file, redisKey);
|
||||
return ResultBean.buildSuccess(progressVO);
|
||||
}
|
||||
|
||||
@ApiOperation("获取导入学生开通应用信息进度")
|
||||
@GetMapping("/getImportStudentApplyInfoProgress")
|
||||
public ResultBean<StudentApplyImportProgressVO> getImportStudentApplyInfoProgress(@RequestParam("redisKey") String redisKey) {
|
||||
return ResultBean.buildSuccess(eduStudentApplyService.getImportStudentApplyInfoProgress(redisKey));
|
||||
}
|
||||
|
||||
@ApiOperation("删除缓存导入进度")
|
||||
@GetMapping("/deleteRedisStudentApplyImportProgress")
|
||||
public ResultBean deleteRedisStudentApplyImportProgress(@RequestParam("redisKey") String redisKey) {
|
||||
redisService.hdel(CachePrefixConstant.IMPORT_STUDENT_APPLY_PROGRESS, redisKey);
|
||||
return ResultBean.buildSuccess();
|
||||
}
|
||||
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package com.yida.data.school.transaction.controller;
|
||||
|
||||
import cc.mrbird.febs.common.redis.service.RedisService;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.yida.data.common.core.common.ResultBean;
|
||||
import com.yida.data.common.core.entity.apply.EduStudentApply;
|
||||
import com.yida.data.common.core.entity.constant.CachePrefixConstant;
|
||||
import com.yida.data.school.transaction.service.EduStudentApplyService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Api(tags = "交易-学生应用关系(不鉴权)")
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/in/transaction/studentApply")
|
||||
@RestController
|
||||
public class InEduStudentApplyController {
|
||||
|
||||
private final EduStudentApplyService eduStudentApplyService;
|
||||
private final RedisService redisService;
|
||||
|
||||
@ApiOperation("查询学生的应用编码列表")
|
||||
@GetMapping("/listApply")
|
||||
public ResultBean<Map<Long, List<String>>> listApplyCode(@RequestParam("studentIds") Long[] studentIds) {
|
||||
List<EduStudentApply> applyCodeList = eduStudentApplyService.list(Wrappers.lambdaQuery(new EduStudentApply())
|
||||
.in(EduStudentApply::getStudentId, studentIds)
|
||||
.ge(EduStudentApply::getEndTime, LocalDateTime.now())
|
||||
.le(EduStudentApply::getStartTime, LocalDateTime.now()));
|
||||
Map<Long, List<String>> res = new HashMap<>();
|
||||
if (CollUtil.isNotEmpty(applyCodeList)) {
|
||||
Map<Long, List<EduStudentApply>> collect = applyCodeList.stream().collect(Collectors.groupingBy(EduStudentApply::getStudentId));
|
||||
for (Map.Entry<Long, List<EduStudentApply>> entry : collect.entrySet()) {
|
||||
List<String> applyCode = entry.getValue().stream().map(x -> x.getApplyCode()).distinct().collect(Collectors.toList());
|
||||
res.put(entry.getKey(), applyCode);
|
||||
redisService.hset(CachePrefixConstant.STUDENT_APPLY, entry.getKey().toString(), applyCode);
|
||||
}
|
||||
}
|
||||
return ResultBean.buildSuccess(res);
|
||||
}
|
||||
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package com.yida.data.school.transaction.listener;
|
||||
|
||||
import cc.mrbird.febs.common.redis.service.RedisService;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.event.AnalysisEventListener;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.yida.data.common.core.entity.apply.EduStudentApply;
|
||||
import com.yida.data.common.service.CommonService;
|
||||
import com.yida.data.school.transaction.service.EduStudentApplyService;
|
||||
import com.yida.data.school.vo.transcation.StudentApplyImportVO;
|
||||
import com.yida.data.user.dto.ImportStudentDormDTO;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class importStudentApplyListener extends AnalysisEventListener<StudentApplyImportVO> {
|
||||
|
||||
|
||||
private EduStudentApplyService eduStudentApplyService;
|
||||
|
||||
|
||||
private List<StudentApplyImportVO> list = new ArrayList<>();
|
||||
|
||||
private String key;
|
||||
|
||||
|
||||
public importStudentApplyListener(EduStudentApplyService eduStudentApplyService, String key) {
|
||||
this.eduStudentApplyService = eduStudentApplyService;
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(StudentApplyImportVO data, AnalysisContext context) {
|
||||
if (null == data) {
|
||||
log.info("excel导入失败:{}", data.toString());
|
||||
}
|
||||
list.add(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAfterAllAnalysed(AnalysisContext context) {
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void saveData() {
|
||||
eduStudentApplyService.insertStudentApplyData(list, key);
|
||||
}
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.yida.data.school.transaction.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.yida.data.common.core.entity.apply.EduStudentApply;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface EduStudentApplyMapper extends BaseMapper<EduStudentApply> {
|
||||
|
||||
List<EduStudentApply> getStudentApplyStatus(@Param("studentId") Long studentId,
|
||||
@Param("applyCode") String applyCode);
|
||||
|
||||
IPage<EduStudentApply> listStudentApply(@Param("studentName") String studentName,
|
||||
@Param("studentNumber") String studentNumber,
|
||||
@Param("schoolId") Long schoolId, @Param("sectionId") Long sectionId,@Param("campusId") Long campusId,
|
||||
@Param("gradeId") Long gradeId, @Param("classId") Long classId, Page page);
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.yida.data.school.transaction.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yida.data.common.core.common.ResultBean;
|
||||
import com.yida.data.common.core.entity.apply.EduStudentApply;
|
||||
import com.yida.data.school.vo.transcation.StudentApplyImportErrorVO;
|
||||
import com.yida.data.school.vo.transcation.StudentApplyImportProgressVO;
|
||||
import com.yida.data.school.vo.transcation.StudentApplyImportVO;
|
||||
import com.yida.data.school.vo.transcation.StudentApplyStatusVO;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
public interface EduStudentApplyService extends IService<EduStudentApply> {
|
||||
|
||||
StudentApplyStatusVO getStudentApplyStatus(Long studentId, String applyCode);
|
||||
|
||||
IPage<EduStudentApply> listStudentApply(String studentName,
|
||||
String studentNumber,
|
||||
Long schoolId,
|
||||
Long sectionId,
|
||||
Long campusId,
|
||||
Long gradeId,
|
||||
Long classId,
|
||||
Page<EduStudentApply> page);
|
||||
|
||||
/**
|
||||
* 下载学生开通应用模板
|
||||
*
|
||||
* @param response
|
||||
* @throws Exception
|
||||
*/
|
||||
void downloadTemplate(HttpServletResponse response) throws Exception;
|
||||
|
||||
@Async
|
||||
void importStudentApplyInfo(MultipartFile file, String redisKey) throws IOException;
|
||||
|
||||
void insertStudentApplyData(List<StudentApplyImportVO> studentApplyImportVOList, String redisKey);
|
||||
|
||||
StudentApplyImportProgressVO getImportStudentApplyInfoProgress( String redisKey);
|
||||
|
||||
}
|
||||
+245
@@ -0,0 +1,245 @@
|
||||
package com.yida.data.school.transaction.service.impl;
|
||||
|
||||
import cc.mrbird.febs.common.redis.service.RedisService;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yida.data.common.core.common.ResultBean;
|
||||
import com.yida.data.common.core.common.ResultMsgType;
|
||||
import com.yida.data.common.core.entity.CurrentUser;
|
||||
import com.yida.data.common.core.entity.apply.EduStudentApply;
|
||||
import com.yida.data.common.core.entity.constant.CachePrefixConstant;
|
||||
import com.yida.data.common.core.entity.system.Dept;
|
||||
import com.yida.data.common.core.entity.user.EduStudent;
|
||||
import com.yida.data.common.core.enums.ImportTemplateTypeEnum;
|
||||
import com.yida.data.common.core.utils.FebsUtil;
|
||||
import com.yida.data.common.core.utils.FileUtil;
|
||||
import com.yida.data.common.service.CommonService;
|
||||
import com.yida.data.school.transaction.listener.importStudentApplyListener;
|
||||
import com.yida.data.school.transaction.mapper.EduStudentApplyMapper;
|
||||
import com.yida.data.school.transaction.service.EduStudentApplyService;
|
||||
import com.yida.data.school.vo.transcation.StudentApplyImportErrorVO;
|
||||
import com.yida.data.school.vo.transcation.StudentApplyImportProgressVO;
|
||||
import com.yida.data.school.vo.transcation.StudentApplyImportVO;
|
||||
import com.yida.data.school.vo.transcation.StudentApplyStatusVO;
|
||||
import com.yida.data.user.dto.ListStudentDTO;
|
||||
import com.yida.data.user.dto.StudentErrorExportDTO;
|
||||
import com.yida.data.user.dto.WelcomeInviteImportDTO;
|
||||
import com.yida.data.user.feign.RemoteStudentService;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import org.springframework.util.StopWatch;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class EduStudentApplyServiceImpl extends ServiceImpl<EduStudentApplyMapper, EduStudentApply> implements
|
||||
EduStudentApplyService {
|
||||
|
||||
private final CommonService commonService;
|
||||
|
||||
private final RedisService redisService;
|
||||
|
||||
private final RemoteStudentService remoteStudentService;
|
||||
|
||||
@Value("${febs.uploadUrl}")
|
||||
private String uploadUrl;
|
||||
|
||||
@Override
|
||||
public StudentApplyStatusVO getStudentApplyStatus(Long studentId, String applyCode) {
|
||||
StudentApplyStatusVO applyStatus = new StudentApplyStatusVO();
|
||||
List<EduStudentApply> list = list(Wrappers.lambdaQuery(new EduStudentApply()).eq(EduStudentApply::getStudentId,
|
||||
studentId)
|
||||
.eq(EduStudentApply::getApplyCode, applyCode)
|
||||
.ge(EduStudentApply::getEndTime, LocalDateTime.now())
|
||||
.le(EduStudentApply::getStartTime, LocalDateTime.now()));
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
List<EduStudentApply> applyList = baseMapper.getStudentApplyStatus(studentId, applyCode);
|
||||
if (CollUtil.isNotEmpty(applyList)) {
|
||||
applyStatus.setStatus(2);
|
||||
applyStatus.setDeadLine(applyList.get(0).getEndTime().toLocalDate().plusDays(1L));
|
||||
} else {
|
||||
applyStatus.setStatus(0);
|
||||
}
|
||||
} else {
|
||||
applyStatus.setStatus(1);
|
||||
}
|
||||
return applyStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<EduStudentApply> listStudentApply(String studentName, String studentNumber, Long schoolId, Long sectionId,
|
||||
Long campusId,
|
||||
Long gradeId, Long classId, Page<EduStudentApply> page) {
|
||||
IPage<EduStudentApply> eduStudentApplyIPage = this.baseMapper
|
||||
.listStudentApply(studentName, studentNumber, schoolId, sectionId, campusId, gradeId, classId, page);
|
||||
return eduStudentApplyIPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadTemplate(HttpServletResponse response) throws Exception {
|
||||
|
||||
String fileName = "学生开通应用导入模板.xls";
|
||||
// 获取导入文件模板
|
||||
ClassPathResource classPathResource = new ClassPathResource("template/" + fileName);
|
||||
InputStream inputStream = classPathResource.getInputStream();
|
||||
FileUtil.download(FileUtil.inputStreamToFile(inputStream), fileName, false, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importStudentApplyInfo(MultipartFile file, String redisKey) throws IOException {
|
||||
log.info("开始导入学生开通应用数据");
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
EasyExcel.read(file.getInputStream(), StudentApplyImportVO.class,
|
||||
new importStudentApplyListener(this, redisKey))
|
||||
.sheet(0).headRowNumber(1).doRead();
|
||||
stopWatch.stop();
|
||||
log.info("导入学生开通应用数据总共耗时: {}", stopWatch.getTotalTimeSeconds() + "秒");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertStudentApplyData(List<StudentApplyImportVO> studentApplyImportVOList, String redisKey) {
|
||||
StudentApplyImportProgressVO progressVO = new StudentApplyImportProgressVO();
|
||||
progressVO.setFinish(0);
|
||||
progressVO.setTotalNum(studentApplyImportVOList.size());
|
||||
progressVO.setCurrentNum(0);
|
||||
progressVO.setRedisKey(redisKey);
|
||||
redisService.hset(CachePrefixConstant.IMPORT_STUDENT_APPLY_PROGRESS, redisKey, progressVO);
|
||||
|
||||
List<StudentApplyImportErrorVO> errorVOList = new ArrayList<>();
|
||||
List<EduStudentApply> saveData = new ArrayList<>();
|
||||
Integer index = 1;
|
||||
|
||||
for (StudentApplyImportVO studentApplyImportVO : studentApplyImportVOList) {
|
||||
index++;
|
||||
String baseMag = "第" + index + "行,";
|
||||
StudentApplyImportErrorVO studentApplyImportErrorVO = checkImportDataIsNull(index, studentApplyImportVO);
|
||||
if (studentApplyImportErrorVO != null) {
|
||||
errorVOList.add(studentApplyImportErrorVO);
|
||||
continue;
|
||||
}
|
||||
Dept dept = commonService.getSchoolByName(studentApplyImportVO.getSchoolName());
|
||||
if (ObjectUtil.isNull(dept)) {
|
||||
StudentApplyImportErrorVO errorVO = new StudentApplyImportErrorVO();
|
||||
errorVO.setErrorMsg(baseMag + "学校名称不匹配");
|
||||
errorVOList.add(errorVO);
|
||||
continue;
|
||||
}
|
||||
// 根据学校ID、学号查询学生信息 检测学号与学生姓名是否匹配
|
||||
EduStudent student = new EduStudent();
|
||||
student.setSchoolId(dept.getDeptId());
|
||||
student.setStuNumber(studentApplyImportVO.getStudentNumber());
|
||||
List<EduStudent> currentStudentList = remoteStudentService.listBaseStudentNoJoin(student).getData();
|
||||
if (CollUtil.isEmpty(currentStudentList)) {
|
||||
StudentApplyImportErrorVO errorVO = new StudentApplyImportErrorVO();
|
||||
errorVO.setErrorMsg(baseMag + "学生学号有误");
|
||||
errorVOList.add(errorVO);
|
||||
continue;
|
||||
}
|
||||
if (!ObjectUtil.equal(studentApplyImportVO.getStudentName(), currentStudentList.get(0).getStuName())) {
|
||||
StudentApplyImportErrorVO errorVO = new StudentApplyImportErrorVO();
|
||||
errorVO.setErrorMsg(baseMag + "学生姓名与学号不匹配");
|
||||
errorVOList.add(errorVO);
|
||||
continue;
|
||||
}
|
||||
EduStudentApply eduStudentApply = new EduStudentApply();
|
||||
eduStudentApply.setStudentId(currentStudentList.get(0).getId());
|
||||
eduStudentApply.setApplyCode(studentApplyImportVO.getApplyCode());
|
||||
eduStudentApply
|
||||
.setStartTime(LocalDateTimeUtil
|
||||
.parse(studentApplyImportVO.getStartTime() + " 00:00:00", "yyyy-MM-dd HH:mm:ss"));
|
||||
eduStudentApply
|
||||
.setEndTime(LocalDateTimeUtil
|
||||
.parse(studentApplyImportVO.getEndTime() + " 00:00:00", "yyyy-MM-dd HH:mm:ss"));
|
||||
saveData.add(eduStudentApply);
|
||||
|
||||
progressVO.setCurrentNum(index - 1);
|
||||
redisService.hset(CachePrefixConstant.IMPORT_STUDENT_APPLY_PROGRESS, redisKey, progressVO);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(saveData)) {
|
||||
super.saveBatch(saveData);
|
||||
}
|
||||
|
||||
productErrorExcel(errorVOList, progressVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StudentApplyImportProgressVO getImportStudentApplyInfoProgress(String redisKey) {
|
||||
return (StudentApplyImportProgressVO) redisService
|
||||
.hget(CachePrefixConstant.IMPORT_STUDENT_APPLY_PROGRESS, redisKey);
|
||||
}
|
||||
|
||||
|
||||
public void productErrorExcel(List<StudentApplyImportErrorVO> errorVOList, StudentApplyImportProgressVO progressVO) {
|
||||
// 错误信息文件名称
|
||||
if (CollUtil.isNotEmpty(errorVOList)) {
|
||||
String fileName = FileUtil.getLocalUploadAddress() + UUID.randomUUID().toString() + ".xlsx";
|
||||
EasyExcel.write(fileName, StudentApplyImportErrorVO.class)
|
||||
.sheet("错误信息")
|
||||
.doWrite(errorVOList);
|
||||
// 上传到媒资
|
||||
String url = FileUtil.uploadFileToMediaServer(uploadUrl, new File(fileName));
|
||||
progressVO.setErrorPageUrl(url);
|
||||
}
|
||||
progressVO.setFinish(1);
|
||||
redisService.hset(CachePrefixConstant.IMPORT_STUDENT_APPLY_PROGRESS, progressVO.getRedisKey(), progressVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测插入数据是否为空
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public StudentApplyImportErrorVO checkImportDataIsNull(Integer index, StudentApplyImportVO studentApplyImportVO) {
|
||||
StudentApplyImportErrorVO studentApplyImportErrorVO = null;
|
||||
String baseMag = "第" + index + "行,";
|
||||
if (ObjectUtil.isNull(studentApplyImportVO.getSchoolName())) {
|
||||
studentApplyImportErrorVO = new StudentApplyImportErrorVO();
|
||||
studentApplyImportErrorVO.setErrorMsg(baseMag + "学校名称为空");
|
||||
}
|
||||
if (ObjectUtil.isNull(studentApplyImportVO.getStudentName())) {
|
||||
studentApplyImportErrorVO = new StudentApplyImportErrorVO();
|
||||
studentApplyImportErrorVO.setErrorMsg(baseMag + "学生姓名为空");
|
||||
}
|
||||
if (ObjectUtil.isNull(studentApplyImportVO.getStudentNumber())) {
|
||||
studentApplyImportErrorVO = new StudentApplyImportErrorVO();
|
||||
studentApplyImportErrorVO.setErrorMsg(baseMag + "学生学号为空");
|
||||
}
|
||||
if (ObjectUtil.isNull(studentApplyImportVO.getApplyCode())) {
|
||||
studentApplyImportErrorVO = new StudentApplyImportErrorVO();
|
||||
studentApplyImportErrorVO.setErrorMsg(baseMag + "开通应用为空");
|
||||
}
|
||||
if (ObjectUtil.isNull(studentApplyImportVO.getStartTime())) {
|
||||
studentApplyImportErrorVO = new StudentApplyImportErrorVO();
|
||||
studentApplyImportErrorVO.setErrorMsg(baseMag + "有效开始时间为空");
|
||||
}
|
||||
if (ObjectUtil.isNull(studentApplyImportVO.getStartTime())) {
|
||||
studentApplyImportErrorVO = new StudentApplyImportErrorVO();
|
||||
studentApplyImportErrorVO.setErrorMsg(baseMag + "有效结束时间为空");
|
||||
}
|
||||
return studentApplyImportErrorVO;
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.yida.data.school.transaction.mapper.EduStudentApplyMapper">
|
||||
<select id="getStudentApplyStatus"
|
||||
resultType="com.yida.data.common.core.entity.apply.EduStudentApply">
|
||||
select *
|
||||
from edu_student_apply
|
||||
where student_id = #{studentId}
|
||||
and apply_code = #{applyCode}
|
||||
order by end_time desc
|
||||
</select>
|
||||
<select id="listStudentApply" resultType="com.yida.data.common.core.entity.apply.EduStudentApply">
|
||||
SELECT esa.*,
|
||||
CONCAT(
|
||||
school.DEPT_NAME,
|
||||
'/',
|
||||
section.DEPT_NAME,
|
||||
'/',
|
||||
campus.DEPT_NAME,
|
||||
'/',
|
||||
grade.DEPT_NAME,
|
||||
'/',
|
||||
class.DEPT_NAME
|
||||
) deptName,es.stu_name studentName
|
||||
from edu_student_apply esa
|
||||
LEFT JOIN edu_student es ON esa.student_id = es.id
|
||||
LEFT JOIN t_dept school ON es.school_id = school.DEPT_ID
|
||||
LEFT JOIN edu_user_dept section ON es.section_id = section.DEPT_ID
|
||||
LEFT JOIN edu_user_dept campus ON es.campus_id = campus.DEPT_ID
|
||||
LEFT JOIN edu_user_dept grade ON es.grade_id = grade.DEPT_ID
|
||||
LEFT JOIN edu_user_dept class ON es.class_id = class.DEPT_ID
|
||||
WHERE esa.del_flag = 0
|
||||
<if test="studentName!=null and studentName!=''">
|
||||
and es.stu_name LIKE CONCAT('%',#{studentName},'%')
|
||||
</if>
|
||||
<if test="studentNumber!=null and studentNumber!=''">
|
||||
and es.stu_number LIKE CONCAT('%',#{studentNumber},'%')
|
||||
</if>
|
||||
<if test="schoolId!=null">
|
||||
and es.school_id LIKE CONCAT('%',#{schoolId},'%')
|
||||
</if>
|
||||
<if test="sectionId!=null">
|
||||
and es.section_id LIKE CONCAT('%',#{sectionId},'%')
|
||||
</if>
|
||||
<if test="campusId!=null">
|
||||
and es.campus_id LIKE CONCAT('%',#{campusId},'%')
|
||||
</if>
|
||||
<if test="gradeId!=null">
|
||||
and es.grade_id LIKE CONCAT('%',#{gradeId},'%')
|
||||
</if>
|
||||
<if test="classId!=null">
|
||||
and es.class_id LIKE CONCAT('%',#{classId},'%')
|
||||
</if>
|
||||
order by create_date desc
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user