|
@@ -2,45 +2,74 @@ package com.zhongzheng.modules.exam.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.github.pagehelper.Page;
|
|
|
import com.zhongzheng.common.core.page.TableDataInfo;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
+import com.zhongzheng.common.type.EncryptHandler;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
+import com.zhongzheng.common.utils.JavaMailUtils;
|
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
|
+import com.zhongzheng.common.utils.file.FileUtils;
|
|
|
+import com.zhongzheng.common.utils.poi.EasyPoiUtil;
|
|
|
+import com.zhongzheng.common.utils.poi.ExcelUtil;
|
|
|
import com.zhongzheng.modules.activity.domain.ActivityRecommend;
|
|
|
-import com.zhongzheng.modules.activity.domain.ActivityRecommendGoods;
|
|
|
import com.zhongzheng.modules.activity.service.IActivityRecommendGoodsService;
|
|
|
import com.zhongzheng.modules.activity.service.IActivityRecommendService;
|
|
|
-import com.zhongzheng.modules.activity.vo.ActivityRecommendGoodsVo;
|
|
|
+import com.zhongzheng.modules.alioss.bo.OssRequest;
|
|
|
+import com.zhongzheng.modules.alioss.service.OssService;
|
|
|
import com.zhongzheng.modules.bank.domain.Exam;
|
|
|
import com.zhongzheng.modules.bank.domain.QuestionBusiness;
|
|
|
import com.zhongzheng.modules.bank.service.IExamService;
|
|
|
import com.zhongzheng.modules.bank.service.IQuestionBusinessService;
|
|
|
-import com.zhongzheng.modules.course.domain.Course;
|
|
|
import com.zhongzheng.modules.exam.bo.*;
|
|
|
-import com.zhongzheng.modules.exam.domain.ExamBefore;
|
|
|
+import com.zhongzheng.modules.exam.domain.ExamApply;
|
|
|
+import com.zhongzheng.modules.exam.domain.ExamApplySite;
|
|
|
+import com.zhongzheng.modules.exam.domain.ExamApplySiteTime;
|
|
|
+import com.zhongzheng.modules.exam.domain.ExamApplyUser;
|
|
|
+import com.zhongzheng.modules.exam.mapper.ExamApplyMapper;
|
|
|
+import com.zhongzheng.modules.exam.service.IExamApplyService;
|
|
|
+import com.zhongzheng.modules.exam.service.IExamApplySiteService;
|
|
|
+import com.zhongzheng.modules.exam.service.IExamApplySiteTimeService;
|
|
|
+import com.zhongzheng.modules.exam.service.IExamApplyUserService;
|
|
|
import com.zhongzheng.modules.exam.vo.*;
|
|
|
-import com.zhongzheng.modules.goods.domain.Goods;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
|
-import com.zhongzheng.modules.user.vo.CalendarStudyVo;
|
|
|
-import io.swagger.annotations.ApiModelProperty;
|
|
|
+import com.zhongzheng.modules.system.domain.SysConfig;
|
|
|
+import com.zhongzheng.modules.system.domain.SysTenant;
|
|
|
+import com.zhongzheng.modules.system.service.ISysConfigService;
|
|
|
+import com.zhongzheng.modules.system.service.ISysTenantService;
|
|
|
+import com.zhongzheng.modules.user.domain.User;
|
|
|
+import com.zhongzheng.modules.user.domain.UserSubscribe;
|
|
|
+import com.zhongzheng.modules.user.service.IUserService;
|
|
|
+import com.zhongzheng.modules.user.service.IUserSubscribeService;
|
|
|
+import com.zhongzheng.modules.user.vo.UserStudyRecordExport;
|
|
|
+import org.apache.commons.io.IOUtils;
|
|
|
+import org.apache.http.entity.ContentType;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.mock.web.MockMultipartFile;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import com.github.pagehelper.Page;
|
|
|
-import com.zhongzheng.modules.exam.domain.ExamApply;
|
|
|
-import com.zhongzheng.modules.exam.mapper.ExamApplyMapper;
|
|
|
-import com.zhongzheng.modules.exam.service.IExamApplyService;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.activation.DataHandler;
|
|
|
+import javax.mail.*;
|
|
|
+import javax.mail.internet.*;
|
|
|
+import javax.mail.util.ByteArrayDataSource;
|
|
|
+import java.io.*;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Path;
|
|
|
+import java.nio.file.Paths;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* 考试安排Service业务层处理
|
|
@@ -61,17 +90,33 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
private IActivityRecommendGoodsService iActivityRecommendGoodsService;
|
|
|
@Autowired
|
|
|
private IGoodsService iGoodsService;
|
|
|
+ @Autowired
|
|
|
+ private IUserService iUserService;
|
|
|
+ @Autowired
|
|
|
+ private ISysTenantService sysTenantService;
|
|
|
+ @Autowired
|
|
|
+ private IExamApplyUserService iExamApplyUserService;
|
|
|
+ @Autowired
|
|
|
+ private IExamApplySiteService iExamApplySiteService;
|
|
|
+ @Autowired
|
|
|
+ private IUserSubscribeService iUserSubscribeService;
|
|
|
+ @Autowired
|
|
|
+ private IExamApplySiteTimeService iExamApplySiteTimeService;
|
|
|
+ @Autowired
|
|
|
+ private OssService ossService;
|
|
|
+ @Autowired
|
|
|
+ private ISysConfigService iSysConfigService;
|
|
|
|
|
|
@Override
|
|
|
- public ExamApplyVo queryById(Long applyId){
|
|
|
+ public ExamApplyVo queryById(Long applyId) {
|
|
|
ExamApplyVo examApplyVo = baseMapper.selectByApply(applyId);
|
|
|
List<ExamNumberGoodsVo> examNumberGoodsVos = baseMapper.examNumberGoodsVos(applyId);
|
|
|
- List<ExamApplySiteVo> examApplySite = baseMapper.addressExam(applyId,1L);
|
|
|
+ List<ExamApplySiteVo> examApplySite = baseMapper.addressExam(applyId, 1L);
|
|
|
for (ExamApplySiteVo examApplySiteVo : examApplySite) {
|
|
|
List<ExamApplySiteTimeVo> examApplySiteTime = baseMapper.addressTimeExam(examApplySiteVo.getId());
|
|
|
examApplySiteVo.setExamApplySiteTime(examApplySiteTime);
|
|
|
}
|
|
|
- List<ExamApplySiteVo> examApplySiteTrain = baseMapper.addressExam(applyId,2L);
|
|
|
+ List<ExamApplySiteVo> examApplySiteTrain = baseMapper.addressExam(applyId, 2L);
|
|
|
for (ExamApplySiteVo examApplySiteVo : examApplySiteTrain) {
|
|
|
List<ExamApplySiteTimeVo> examApplySiteTime = baseMapper.addressTimeExam(examApplySiteVo.getId());
|
|
|
examApplySiteVo.setExamApplySiteTime(examApplySiteTime);
|
|
@@ -79,6 +124,17 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
examApplyVo.setExamNumberGoods(examNumberGoodsVos);
|
|
|
examApplyVo.setExamApplySite(examApplySite);
|
|
|
examApplyVo.setExamApplySiteTrain(examApplySiteTrain);
|
|
|
+ List<ExamApplyUser> applyUsers = iExamApplyUserService.list(new LambdaQueryWrapper<ExamApplyUser>().eq(ExamApplyUser::getApplyId, applyId));
|
|
|
+ if (CollectionUtils.isNotEmpty(applyUsers)) {
|
|
|
+ List<ExamApplyUserImportBo> collect = applyUsers.stream().map(item -> {
|
|
|
+ User user = iUserService.getById(item.getUserId());
|
|
|
+ ExamApplyUserImportBo bo = new ExamApplyUserImportBo();
|
|
|
+ bo.setUserName(user.getRealname());
|
|
|
+ bo.setIdCard(EncryptHandler.decrypt(user.getIdCard()));
|
|
|
+ return bo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ examApplyVo.setApplyUsers(collect);
|
|
|
+ }
|
|
|
return examApplyVo;
|
|
|
}
|
|
|
|
|
@@ -90,7 +146,7 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
|
|
|
calendar.setTimeInMillis(System.currentTimeMillis());
|
|
|
- if ((examApplyVo.getApplyEndTime()) < calendar.getTimeInMillis()/1000){
|
|
|
+ if ((examApplyVo.getApplyEndTime()) < calendar.getTimeInMillis() / 1000) {
|
|
|
ExamApply update = new ExamApply();
|
|
|
update.setApplyId(examApplyVo.getApplyId());
|
|
|
update.setStatus(2);
|
|
@@ -103,19 +159,19 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 实体类转化成视图对象
|
|
|
- *
|
|
|
- * @param collection 实体类集合
|
|
|
- * @return
|
|
|
- */
|
|
|
+ * 实体类转化成视图对象
|
|
|
+ *
|
|
|
+ * @param collection 实体类集合
|
|
|
+ * @return
|
|
|
+ */
|
|
|
private List<ExamApplyVo> entity2Vo(Collection<ExamApply> collection) {
|
|
|
List<ExamApplyVo> voList = collection.stream()
|
|
|
.map(any -> BeanUtil.toBean(any, ExamApplyVo.class))
|
|
|
.collect(Collectors.toList());
|
|
|
if (collection instanceof Page) {
|
|
|
- Page<ExamApply> page = (Page<ExamApply>)collection;
|
|
|
+ Page<ExamApply> page = (Page<ExamApply>) collection;
|
|
|
Page<ExamApplyVo> pageVo = new Page<>();
|
|
|
- BeanUtil.copyProperties(page,pageVo);
|
|
|
+ BeanUtil.copyProperties(page, pageVo);
|
|
|
pageVo.addAll(voList);
|
|
|
voList = pageVo;
|
|
|
}
|
|
@@ -129,21 +185,72 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
add.setCode(ServletUtils.getEncoded("KSAP"));
|
|
|
add.setCreateTime(DateUtils.getNowTime());
|
|
|
add.setUpdateTime(DateUtils.getNowTime());
|
|
|
- return this.save(add);
|
|
|
+ this.save(add);
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(bo.getNatureUrl())) {
|
|
|
+ try {
|
|
|
+ InputStream inputStream = ossService.getStreamByObject(bo.getNatureUrl());
|
|
|
+ //学员资料解析
|
|
|
+ List<ExamApplyUserImportBo> applyUsers = EasyPoiUtil.importExcel(createMultipartFile(inputStream), 0, 1, ExamApplyUserImportBo.class);
|
|
|
+ //专场预约学员
|
|
|
+ List<ExamApplyUser> applyUserList = applyUsers.stream().filter(x -> {
|
|
|
+ int count = iUserService.count(new LambdaQueryWrapper<User>()
|
|
|
+ .eq(User::getIdCard, EncryptHandler.encrypt(x.getIdCard())));
|
|
|
+ return count > 0;
|
|
|
+ }).map(item -> {
|
|
|
+ User user = iUserService.getOne(new LambdaQueryWrapper<User>()
|
|
|
+ .eq(User::getIdCard, EncryptHandler.encrypt(item.getIdCard())));
|
|
|
+ ExamApplyUser applyUser = new ExamApplyUser();
|
|
|
+ applyUser.setApplyId(add.getApplyId());
|
|
|
+ applyUser.setUserId(user.getUserId());
|
|
|
+ applyUser.setCreateTime(DateUtils.getNowTime());
|
|
|
+ applyUser.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ return applyUser;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ iExamApplyUserService.saveBatch(applyUserList);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private MultipartFile createMultipartFile(InputStream inputStream) throws IOException {
|
|
|
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
+ byte[] buffer = new byte[1024];
|
|
|
+ int len;
|
|
|
+ byte[] dataBytes;
|
|
|
+ while ((len = inputStream.read(buffer)) != -1) {
|
|
|
+ baos.write(buffer, 0, len);
|
|
|
+ }
|
|
|
+ baos.flush();
|
|
|
+ byte[] bytes = baos.toByteArray();
|
|
|
+
|
|
|
+ MultipartFile multipartFile = new MockMultipartFile(
|
|
|
+ "file",
|
|
|
+ "filename",
|
|
|
+ ContentType.APPLICATION_OCTET_STREAM.toString(),
|
|
|
+ new ByteArrayInputStream(bytes)
|
|
|
+ );
|
|
|
+
|
|
|
+ return multipartFile;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Boolean updateByEditBo(ExamApplyEditBo bo) {
|
|
|
ExamApply update = BeanUtil.toBean(bo, ExamApply.class);
|
|
|
- if (bo.getStatus() == 1){
|
|
|
+ if (bo.getStatus() == 1) {
|
|
|
//判断是否有设置商品
|
|
|
Long contGoodsId = baseMapper.countGoods(bo.getApplyId());
|
|
|
- if (contGoodsId < 1){
|
|
|
+ if (contGoodsId < 1) {
|
|
|
throw new CustomException("请先设置适用商品");
|
|
|
}
|
|
|
//判断是否有设置考试地点和时间
|
|
|
- List<ExamApplySiteVo> examApplySite = baseMapper.addressExam(bo.getApplyId(),1L);
|
|
|
- if (CollectionUtils.isEmpty(examApplySite)){
|
|
|
+ List<ExamApplySiteVo> examApplySite = baseMapper.addressExam(bo.getApplyId(), 1L);
|
|
|
+ if (CollectionUtils.isEmpty(examApplySite)) {
|
|
|
throw new CustomException("请先设置考试地点和时间");
|
|
|
}
|
|
|
//考试计划内的商品是否被其他计划使用
|
|
@@ -161,16 +268,48 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
throw new RuntimeException(goodsName+"已被其他进行中的考试计划使用,请修改,再启用");
|
|
|
}*/
|
|
|
}
|
|
|
- if(bo.getStatus()==-1){
|
|
|
+ if (bo.getStatus() == -1) {
|
|
|
ExamApplyQueryBo queryBo = new ExamApplyQueryBo();
|
|
|
queryBo.setApplyId(bo.getApplyId());
|
|
|
- if(countApplySubscribe(queryBo)>0){
|
|
|
+ if (countApplySubscribe(queryBo) > 0) {
|
|
|
throw new RuntimeException("该考试计划存在预约数据,无法删除");
|
|
|
}
|
|
|
}
|
|
|
validEntityBeforeSave(update);
|
|
|
update.setUpdateTime(DateUtils.getNowTime());
|
|
|
- return this.updateById(update);
|
|
|
+ this.updateById(update);
|
|
|
+
|
|
|
+ if (update.getApplyNature() == 2) {
|
|
|
+ //专场预约学员
|
|
|
+ iExamApplyUserService.remove(new LambdaQueryWrapper<ExamApplyUser>().eq(ExamApplyUser::getApplyId, update.getApplyId()));
|
|
|
+ if (StringUtils.isNotBlank(bo.getNatureUrl())) {
|
|
|
+ try {
|
|
|
+ InputStream inputStream = ossService.getStreamByObject(bo.getNatureUrl());
|
|
|
+ //学员资料解析
|
|
|
+ List<ExamApplyUserImportBo> applyUsers = EasyPoiUtil.importExcel(createMultipartFile(inputStream), 0, 1, ExamApplyUserImportBo.class);
|
|
|
+ //专场预约学员
|
|
|
+ List<ExamApplyUser> applyUserList = applyUsers.stream().filter(x -> {
|
|
|
+ int count = iUserService.count(new LambdaQueryWrapper<User>()
|
|
|
+ .eq(User::getIdCard, EncryptHandler.encrypt(x.getIdCard())));
|
|
|
+ return count > 0;
|
|
|
+ }).map(item -> {
|
|
|
+ User user = iUserService.getOne(new LambdaQueryWrapper<User>()
|
|
|
+ .eq(User::getIdCard, EncryptHandler.encrypt(item.getIdCard())));
|
|
|
+ ExamApplyUser applyUser = new ExamApplyUser();
|
|
|
+ applyUser.setApplyId(update.getApplyId());
|
|
|
+ applyUser.setUserId(user.getUserId());
|
|
|
+ applyUser.setCreateTime(DateUtils.getNowTime());
|
|
|
+ applyUser.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ return applyUser;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ iExamApplyUserService.saveBatch(applyUserList);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -178,16 +317,16 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
*
|
|
|
* @param entity 实体类数据
|
|
|
*/
|
|
|
- private void validEntityBeforeSave(ExamApply entity){
|
|
|
+ private void validEntityBeforeSave(ExamApply entity) {
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
- if(checkNameUnique(entity)){
|
|
|
+ if (checkNameUnique(entity)) {
|
|
|
throw new CustomException("名称重复");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
- if(isValid){
|
|
|
+ if (isValid) {
|
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
|
}
|
|
|
return this.removeByIds(ids);
|
|
@@ -201,7 +340,7 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
|
|
|
@Override
|
|
|
public List<ExamApplySiteVo> getSiteInfo(ExamApplyQueryBo bo) {
|
|
|
- List<ExamApplySiteVo> examApplySite = baseMapper.addressExam(bo.getApplyId(),bo.getAddressStatus());
|
|
|
+ List<ExamApplySiteVo> examApplySite = baseMapper.addressExam(bo.getApplyId(), bo.getAddressStatus());
|
|
|
for (ExamApplySiteVo examApplySiteVo : examApplySite) {
|
|
|
List<ExamApplySiteTimeVo> examApplySiteTime = baseMapper.addressTimeExam(examApplySiteVo.getId());
|
|
|
examApplySiteVo.setExamApplySiteTime(examApplySiteTime);
|
|
@@ -218,7 +357,7 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
//初始化需要得到的数组
|
|
|
Long[] array = new Long[examNumberGoodsVos.size()];
|
|
|
//使用for循环得到数组
|
|
|
- for(int i = 0; i < examNumberGoodsVos.size();i++){
|
|
|
+ for (int i = 0; i < examNumberGoodsVos.size(); i++) {
|
|
|
array[i] = examNumberGoodsVos.get(i).getGoodsId();
|
|
|
}
|
|
|
examApplyVo.setExamNumberGoods(examNumberGoodsVos);
|
|
@@ -230,22 +369,22 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
public ExamUserApplyVo subscribe(ExamApplyQueryBo bo) {
|
|
|
//查询学时通过情况
|
|
|
Integer countGradePeriod = baseMapper.countGradePeriod(bo);
|
|
|
- if (countGradePeriod < 1){
|
|
|
+ if (countGradePeriod < 1) {
|
|
|
throw new CustomException("学时审核未通过,不可以报名参加考试");
|
|
|
}
|
|
|
//查询考试通过情况
|
|
|
Integer countSubscribe = baseMapper.countSubscribe(bo);
|
|
|
- if (countSubscribe > 0){
|
|
|
+ if (countSubscribe > 0) {
|
|
|
throw new CustomException("考试已通过,不需要重考");
|
|
|
}
|
|
|
//查询是否已预约考试
|
|
|
Integer countHaveSubscribe = baseMapper.countHaveSubscribe(bo);
|
|
|
- if (countHaveSubscribe > 0){
|
|
|
+ if (countHaveSubscribe > 0) {
|
|
|
throw new CustomException("您所报考的专业,已经预约成功,您可在“我的-我的考试预约”中查询详情");
|
|
|
}
|
|
|
//查询是否有考试计划
|
|
|
ExamUserApplyVo examUserApplyVo = baseMapper.selectExamUserApplyVo(bo);
|
|
|
- if (examUserApplyVo == null){
|
|
|
+ if (examUserApplyVo == null) {
|
|
|
throw new CustomException("商品无考试计划,无需预约考试");
|
|
|
}
|
|
|
return examUserApplyVo;
|
|
@@ -255,20 +394,20 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
public Long subscribeNext(ExamApplyQueryBo bo) {
|
|
|
//查看是否有无考试记录
|
|
|
Integer countHaveSubscribeNext = baseMapper.countHaveSubscribeNext(bo);
|
|
|
- if (bo.getApplyStatus().equals(2) && countHaveSubscribeNext < 1){
|
|
|
+ if (bo.getApplyStatus().equals(2) && countHaveSubscribeNext < 1) {
|
|
|
throw new CustomException("系统检索到您不符合【补考学员】的报名条件,请重新选择!");
|
|
|
}
|
|
|
- if (bo.getApplyStatus().equals(1) && countHaveSubscribeNext > 0){
|
|
|
+ if (bo.getApplyStatus().equals(1) && countHaveSubscribeNext > 0) {
|
|
|
throw new CustomException("系统检索到您不符合【非补考学员】的报名条件,请重新选择!");
|
|
|
}
|
|
|
//查询剩余考试次数
|
|
|
Integer residueSubscribeNext = baseMapper.residueSubscribeNext(bo);
|
|
|
- if (residueSubscribeNext == null || residueSubscribeNext < 1){
|
|
|
+ if (residueSubscribeNext == null || residueSubscribeNext < 1) {
|
|
|
return 3L;
|
|
|
}
|
|
|
//查询有无考培
|
|
|
Integer beforeSubscribeNext = baseMapper.beforeSubscribeNext(bo);
|
|
|
- if (beforeSubscribeNext > 0){
|
|
|
+ if (beforeSubscribeNext > 0) {
|
|
|
return 1L;
|
|
|
}
|
|
|
return 2L;
|
|
@@ -277,7 +416,7 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
@Override
|
|
|
public List<ExamUserApplySiteVo> subscribeApplySite(ExamApplyQueryBo bo) {
|
|
|
//查看地址
|
|
|
- List<ExamUserApplySiteVo> examUserApplySiteVos= baseMapper.subscribeApplySite(bo);
|
|
|
+ List<ExamUserApplySiteVo> examUserApplySiteVos = baseMapper.subscribeApplySite(bo);
|
|
|
//获得详细地址查看是否满员
|
|
|
for (ExamUserApplySiteVo examUserApplySiteVo : examUserApplySiteVos) {
|
|
|
List<ExamUserApplySiteTimeVo> examApplySiteTime = baseMapper.subscribeApplySiteTime(examUserApplySiteVo.getId());
|
|
@@ -285,8 +424,8 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
List<ExamApplySiteTimeTwoVo> examApplySiteTimeTwoVos = JSONObject.parseArray(examUserApplySiteTimeVo.getSiteTime(), ExamApplySiteTimeTwoVo.class);
|
|
|
for (ExamApplySiteTimeTwoVo examApplySiteTimeTwoVo : examApplySiteTimeTwoVos) {
|
|
|
examApplySiteTimeTwoVo.setRegistration(baseMapper.registration(examUserApplySiteVo.getApplyId(), examUserApplySiteTimeVo.getExamTime()
|
|
|
- ,examUserApplySiteVo.getSiteAddress(),examApplySiteTimeTwoVo.getStartTime(),examApplySiteTimeTwoVo.getEndTime()));
|
|
|
- examApplySiteTimeTwoVo.setStatus(baseMapper.userStatus(bo.getUserId(),examUserApplySiteTimeVo.getExamTime(),examApplySiteTimeTwoVo.getStartTime(),examApplySiteTimeTwoVo.getEndTime()));
|
|
|
+ , examUserApplySiteVo.getSiteAddress(), examApplySiteTimeTwoVo.getStartTime(), examApplySiteTimeTwoVo.getEndTime()));
|
|
|
+ examApplySiteTimeTwoVo.setStatus(baseMapper.userStatus(bo.getUserId(), examUserApplySiteTimeVo.getExamTime(), examApplySiteTimeTwoVo.getStartTime(), examApplySiteTimeTwoVo.getEndTime()));
|
|
|
}
|
|
|
examUserApplySiteTimeVo.setExamApplySiteTimeTwoVo(examApplySiteTimeTwoVos);
|
|
|
}
|
|
@@ -298,7 +437,7 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
@Override
|
|
|
public List<ExamUserApplySiteVo> subscribeApplySiteTrain(ExamApplyQueryBo bo) {
|
|
|
//查看地址
|
|
|
- List<ExamUserApplySiteVo> examUserApplySiteVos= baseMapper.subscribeApplySiteTrain(bo);
|
|
|
+ List<ExamUserApplySiteVo> examUserApplySiteVos = baseMapper.subscribeApplySiteTrain(bo);
|
|
|
//获得详细地址查看是否满员
|
|
|
for (ExamUserApplySiteVo examUserApplySiteVo : examUserApplySiteVos) {
|
|
|
List<ExamUserApplySiteTimeVo> examApplySiteTime = baseMapper.subscribeApplySiteTime(examUserApplySiteVo.getId());
|
|
@@ -306,8 +445,8 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
List<ExamApplySiteTimeTwoVo> examApplySiteTimeTwoVos = JSONObject.parseArray(examUserApplySiteTimeVo.getSiteTime(), ExamApplySiteTimeTwoVo.class);
|
|
|
for (ExamApplySiteTimeTwoVo examApplySiteTimeTwoVo : examApplySiteTimeTwoVos) {
|
|
|
examApplySiteTimeTwoVo.setRegistration(baseMapper.registrationTrain(examUserApplySiteVo.getApplyId(), examUserApplySiteTimeVo.getExamTime()
|
|
|
- ,examUserApplySiteVo.getSiteAddress(),examApplySiteTimeTwoVo.getStartTime(),examApplySiteTimeTwoVo.getEndTime()));
|
|
|
- examApplySiteTimeTwoVo.setStatus(baseMapper.userStatusTrain(bo.getUserId(),examUserApplySiteTimeVo.getExamTime(),examApplySiteTimeTwoVo.getStartTime(),examApplySiteTimeTwoVo.getEndTime()));
|
|
|
+ , examUserApplySiteVo.getSiteAddress(), examApplySiteTimeTwoVo.getStartTime(), examApplySiteTimeTwoVo.getEndTime()));
|
|
|
+ examApplySiteTimeTwoVo.setStatus(baseMapper.userStatusTrain(bo.getUserId(), examUserApplySiteTimeVo.getExamTime(), examApplySiteTimeTwoVo.getStartTime(), examApplySiteTimeTwoVo.getEndTime()));
|
|
|
}
|
|
|
examUserApplySiteTimeVo.setExamApplySiteTimeTwoVo(examApplySiteTimeTwoVos);
|
|
|
}
|
|
@@ -325,7 +464,7 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
public TableDataInfo<GoodsVo> getRecommendGoodsList(ExamRecommendGoodsQueryBo bo) {
|
|
|
TableDataInfo tableDataInfo = new TableDataInfo();
|
|
|
Exam exam = iExamService.getById(bo.getExamId());
|
|
|
- if (ObjectUtils.isNull(exam)){
|
|
|
+ if (ObjectUtils.isNull(exam)) {
|
|
|
// throw new CustomException("获取试卷信息失败");
|
|
|
return new TableDataInfo<>();
|
|
|
}
|
|
@@ -333,23 +472,23 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
QuestionBusiness business = iQuestionBusinessService.getOne(new LambdaQueryWrapper<QuestionBusiness>()
|
|
|
.eq(QuestionBusiness::getMajorId, bo.getExamId())
|
|
|
.eq(QuestionBusiness::getType, 2));
|
|
|
- if (ObjectUtils.isNull(business)){
|
|
|
+ if (ObjectUtils.isNull(business)) {
|
|
|
throw new CustomException("获取试卷业务层次信息失败");
|
|
|
}
|
|
|
- Integer platform = ObjectUtils.isNull(bo.getPlatform())?1:bo.getPlatform();
|
|
|
+ Integer platform = ObjectUtils.isNull(bo.getPlatform()) ? 1 : bo.getPlatform();
|
|
|
//获取推荐位信息
|
|
|
List<ActivityRecommend> list = iActivityRecommendService.list(new LambdaQueryWrapper<ActivityRecommend>()
|
|
|
.eq(ActivityRecommend::getEducationTypeId, business.getEducationTypeId())
|
|
|
.eq(ActivityRecommend::getBusinessId, business.getBusinessId())
|
|
|
- .eq(ActivityRecommend::getPlatform,platform)
|
|
|
+ .eq(ActivityRecommend::getPlatform, platform)
|
|
|
.eq(ActivityRecommend::getType, 1)
|
|
|
- .eq(ActivityRecommend::getStatus,1));
|
|
|
- if (CollectionUtils.isEmpty(list)){
|
|
|
+ .eq(ActivityRecommend::getStatus, 1));
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
return tableDataInfo;
|
|
|
}
|
|
|
ActivityRecommend activityRecommend = list.stream().findFirst().get();
|
|
|
com.baomidou.mybatisplus.extension.plugins.pagination.Page<GoodsVo> page =
|
|
|
- iActivityRecommendGoodsService.getGoodsListByPage(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(bo.getPageNum(), bo.getPageSize()),activityRecommend.getRecommendId());
|
|
|
+ iActivityRecommendGoodsService.getGoodsListByPage(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(bo.getPageNum(), bo.getPageSize()), activityRecommend.getRecommendId());
|
|
|
|
|
|
// if (CollectionUtils.isEmpty(page.getRecords())){
|
|
|
// return tableDataInfo;
|
|
@@ -361,15 +500,364 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
return tableDataInfo;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public boolean saveExamApply(ExamApplyAddBo bo) {
|
|
|
+ ExamApply add = BeanUtil.toBean(bo, ExamApply.class);
|
|
|
+ validEntityBeforeSave(add);
|
|
|
+ add.setCode(ServletUtils.getEncoded("KSAP"));
|
|
|
+ add.setCreateTime(DateUtils.getNowTime());
|
|
|
+ add.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ this.save(add);
|
|
|
+ if (CollectionUtils.isNotEmpty(bo.getApplyUsers())) {
|
|
|
+ //专场预约学员
|
|
|
+ List<ExamApplyUser> applyUserList = bo.getApplyUsers().stream().filter(x -> {
|
|
|
+ int count = iUserService.count(new LambdaQueryWrapper<User>()
|
|
|
+ .eq(User::getIdCard, EncryptHandler.encrypt(x.getIdCard())));
|
|
|
+ return count > 0;
|
|
|
+ }).map(item -> {
|
|
|
+ User user = iUserService.getOne(new LambdaQueryWrapper<User>()
|
|
|
+ .eq(User::getIdCard, EncryptHandler.encrypt(item.getIdCard())));
|
|
|
+ ExamApplyUser applyUser = new ExamApplyUser();
|
|
|
+ applyUser.setApplyId(add.getApplyId());
|
|
|
+ applyUser.setUserId(user.getUserId());
|
|
|
+ applyUser.setCreateTime(DateUtils.getNowTime());
|
|
|
+ applyUser.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ return applyUser;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ iExamApplyUserService.saveBatch(applyUserList);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public boolean editExamApply(ExamApplyEditBo bo) {
|
|
|
+ ExamApply update = BeanUtil.toBean(bo, ExamApply.class);
|
|
|
+ if (bo.getStatus() == 1) {
|
|
|
+ //判断是否有设置商品
|
|
|
+ Long contGoodsId = baseMapper.countGoods(bo.getApplyId());
|
|
|
+ if (contGoodsId < 1) {
|
|
|
+ throw new CustomException("请先设置适用商品");
|
|
|
+ }
|
|
|
+ //判断是否有设置考试地点和时间
|
|
|
+ List<ExamApplySiteVo> examApplySite = baseMapper.addressExam(bo.getApplyId(), 1L);
|
|
|
+ if (CollectionUtils.isEmpty(examApplySite)) {
|
|
|
+ throw new CustomException("请先设置考试地点和时间");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (bo.getStatus() == -1) {
|
|
|
+ ExamApplyQueryBo queryBo = new ExamApplyQueryBo();
|
|
|
+ queryBo.setApplyId(bo.getApplyId());
|
|
|
+ if (countApplySubscribe(queryBo) > 0) {
|
|
|
+ throw new RuntimeException("该考试计划存在预约数据,无法删除");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ validEntityBeforeSave(update);
|
|
|
+ update.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ this.updateById(update);
|
|
|
+
|
|
|
+ if (update.getApplyNature() == 2) {
|
|
|
+ //专场预约学员
|
|
|
+ iExamApplyUserService.remove(new LambdaQueryWrapper<ExamApplyUser>().eq(ExamApplyUser::getApplyId, update.getApplyId()));
|
|
|
+ if (CollectionUtils.isNotEmpty(bo.getApplyUsers())) {
|
|
|
+ //专场预约学员
|
|
|
+ List<ExamApplyUser> applyUserList = bo.getApplyUsers().stream().filter(x -> {
|
|
|
+ int count = iUserService.count(new LambdaQueryWrapper<User>()
|
|
|
+ .eq(User::getIdCard, EncryptHandler.encrypt(x.getIdCard())));
|
|
|
+ return count > 0;
|
|
|
+ }).map(item -> {
|
|
|
+ User user = iUserService.getOne(new LambdaQueryWrapper<User>()
|
|
|
+ .eq(User::getIdCard, EncryptHandler.encrypt(item.getIdCard())));
|
|
|
+ ExamApplyUser applyUser = new ExamApplyUser();
|
|
|
+ applyUser.setApplyId(update.getApplyId());
|
|
|
+ applyUser.setUserId(user.getUserId());
|
|
|
+ applyUser.setCreateTime(DateUtils.getNowTime());
|
|
|
+ applyUser.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ return applyUser;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ iExamApplyUserService.saveBatch(applyUserList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<ExamApplyPlaceVo> getPlaceList(ExamApplyQueryBo bo) {
|
|
|
+ List<ExamApplyPlaceVo> voList = baseMapper.getPlaceList(bo);
|
|
|
+ if (CollectionUtils.isEmpty(voList)) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ voList.forEach(item -> {
|
|
|
+ List<ExamApplySiteTimeTwoVo> examApplySiteTimeTwoVos = JSONArray.parseArray(item.getSiteTime(), ExamApplySiteTimeTwoVo.class);
|
|
|
+ if (ObjectUtils.isNotNull(examApplySiteTimeTwoVos)) {
|
|
|
+ ExamApplySiteTimeTwoVo timeTwoVo = examApplySiteTimeTwoVos.stream().findFirst().orElse(null);
|
|
|
+ //预约人数
|
|
|
+ int count = iUserSubscribeService.count(new LambdaQueryWrapper<UserSubscribe>()
|
|
|
+ .eq(UserSubscribe::getApplyId, item.getApplyId())
|
|
|
+ .eq(UserSubscribe::getSiteId, item.getApplySiteId())
|
|
|
+ .eq(UserSubscribe::getApplySiteStartTime, timeTwoVo.getStartTime())
|
|
|
+ .eq(UserSubscribe::getApplySiteEndTime, timeTwoVo.getEndTime()));
|
|
|
+ item.setPeople(count);
|
|
|
+ item.setMayNum(timeTwoVo.getNum());
|
|
|
+ if (ObjectUtils.isNotNull(item.getApplyDate())) {
|
|
|
+ String time = DateUtils.timestampToDateFormatMonth(item.getApplyDate());
|
|
|
+ String format = String.format("%s(%s-%s)", time, timeTwoVo.getStartTime(), timeTwoVo.getEndTime());
|
|
|
+ item.setApplyTime(format);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return voList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getSendmailUrl(List<Long> ids) {
|
|
|
+ List<ExamApplySiteTime> siteTimes = iExamApplySiteTimeService.listByIds(ids);
|
|
|
+ if (CollectionUtils.isEmpty(siteTimes)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ Map<Long, List<ExamApplySiteTime>> map = siteTimes.stream().collect(Collectors.groupingBy(ExamApplySiteTime::getExamTime));
|
|
|
+ String zhiyuan = System.getProperty("user.dir");
|
|
|
+ String path = zhiyuan + "/zhongzheng-admin/src/main/resources/学习记录";
|
|
|
+ File file = new File(path);
|
|
|
+ if (file.exists()) {
|
|
|
+ file.mkdirs();
|
|
|
+ }
|
|
|
+ map.forEach((k, v) -> {
|
|
|
+ if (CollectionUtils.isEmpty(v)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //月份文件夹
|
|
|
+ String month = DateUtils.timestampToDateFormatMonthTwo(k);
|
|
|
+ String secondPath = path + "/" + month;
|
|
|
+ File secondFile = new File(secondPath);
|
|
|
+ if (secondFile.exists()) {
|
|
|
+ secondFile.mkdirs();
|
|
|
+ }
|
|
|
+ //时间文件夹
|
|
|
+ Map<String, List<ExamApplySiteTime>> timeMap = v.stream().filter(x -> StringUtils.isNotBlank(x.getSiteTime())).collect(Collectors.groupingBy(item -> {
|
|
|
+ List<ExamApplySiteTimeTwoVo> examApplySiteTimeTwoVos = JSONArray.parseArray(item.getSiteTime(), ExamApplySiteTimeTwoVo.class);
|
|
|
+ ExamApplySiteTimeTwoVo timeTwoVo = examApplySiteTimeTwoVos.stream().findFirst().orElse(null);
|
|
|
+ return timeTwoVo.getStartTime();
|
|
|
+ }));
|
|
|
+ timeMap.forEach((x, y) -> {
|
|
|
+ if (CollectionUtils.isEmpty(y)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String timePath = secondPath + "/" + x.replace(":", ".");
|
|
|
+ File timeFile = new File(timePath);
|
|
|
+ if (timeFile.exists()) {
|
|
|
+ timeFile.mkdirs();
|
|
|
+ }
|
|
|
+ Set<Long> applyIds = new HashSet<>();
|
|
|
+ Set<Long> siteIds = new HashSet<>();
|
|
|
+ Set<String> startTimeList = new HashSet<>();
|
|
|
+ Set<String> endTimeList = new HashSet<>();
|
|
|
+ for (ExamApplySiteTime itme : y) {
|
|
|
+ applyIds.add(itme.getApplyId());
|
|
|
+ ExamApplySite site = iExamApplySiteService.getById(itme.getApplySiteId());
|
|
|
+ siteIds.add(site.getSiteId());
|
|
|
+ List<ExamApplySiteTimeTwoVo> examApplySiteTimeTwoVos = JSONArray.parseArray(itme.getSiteTime(), ExamApplySiteTimeTwoVo.class);
|
|
|
+ ExamApplySiteTimeTwoVo timeTwoVo = examApplySiteTimeTwoVos.stream().findFirst().orElse(null);
|
|
|
+ startTimeList.add(timeTwoVo.getStartTime());
|
|
|
+ endTimeList.add(timeTwoVo.getEndTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询预约学员
|
|
|
+ List<UserSubscribe> userSubscribeList = iUserSubscribeService
|
|
|
+ .list(new LambdaQueryWrapper<UserSubscribe>()
|
|
|
+ .in(UserSubscribe::getApplyId, applyIds)
|
|
|
+ .in(UserSubscribe::getSiteId, siteIds)
|
|
|
+ .in(UserSubscribe::getApplySiteStartTime, startTimeList)
|
|
|
+ .in(UserSubscribe::getApplySiteEndTime, endTimeList)
|
|
|
+ .eq(UserSubscribe::getSubscribeStatus, 1));
|
|
|
+ if (CollectionUtils.isEmpty(userSubscribeList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<Integer, List<UserSubscribe>> userMap = userSubscribeList.stream().collect(Collectors.groupingBy(UserSubscribe::getStudentType));
|
|
|
+ userMap.forEach((m, i) -> {
|
|
|
+ switch (m) {
|
|
|
+ case 1://新考人员
|
|
|
+ String userPath = timePath + "/新考";
|
|
|
+ File userFile = new File(userPath);
|
|
|
+ if (userFile.exists()) {
|
|
|
+ userFile.mkdirs();
|
|
|
+ }
|
|
|
+ //查询学员学时记录
|
|
|
+ userStudyRecord(userPath, i);
|
|
|
+ break;
|
|
|
+ case 2://补考人员
|
|
|
+ String userPathTwo = timePath + "/补考";
|
|
|
+ File userTwoFile = new File(userPathTwo);
|
|
|
+ if (userTwoFile.exists()) {
|
|
|
+ userTwoFile.mkdirs();
|
|
|
+ }
|
|
|
+ //查询学员学时记录
|
|
|
+ userStudyRecord(userPathTwo, i);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+ String zipPath = zhiyuan + "/zhongzheng-admin/src/main/resources/xuexizip" + "/" + DateUtils.getNowTime() + ".zip";
|
|
|
+ File desc = new File(zipPath);
|
|
|
+ if (!desc.getParentFile().exists()) {
|
|
|
+ desc.getParentFile().mkdirs();
|
|
|
+ }
|
|
|
+ if (FileUtils.toZip(zipPath, path, true)) {
|
|
|
+ //压缩成功删除文件
|
|
|
+ Path pathStr = Paths.get(path);
|
|
|
+ try (Stream<Path> walk = Files.walk(pathStr)) {
|
|
|
+ walk.sorted(Comparator.reverseOrder())
|
|
|
+ .forEach(FileUtils::deleteDirectoryStream);
|
|
|
+
|
|
|
+ //上传oss
|
|
|
+ OssRequest ossRequest = new OssRequest();
|
|
|
+ ossRequest.setGradeId(0L);
|
|
|
+ ossRequest.setUserId(0L);
|
|
|
+ ossRequest.setImageStatus(6);
|
|
|
+ File file1 = new File(zipPath);
|
|
|
+ ossRequest.setFile(FileUtils.getMultipartFile(file1));
|
|
|
+ String upload = ossService.upload(ossRequest);
|
|
|
+
|
|
|
+ //删除压缩包
|
|
|
+ Path zipPathStr = Paths.get(zipPath);
|
|
|
+ Stream<Path> zipWalk = Files.walk(zipPathStr);
|
|
|
+ zipWalk.sorted(Comparator.reverseOrder())
|
|
|
+ .forEach(FileUtils::deleteDirectoryStream);
|
|
|
+ return upload;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error("学员学习资料上传oss失败:" + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean sendmail(ExamApplySendmailBo bo) {
|
|
|
+ if (CollectionUtils.isEmpty(bo.getMailAttrList())) {
|
|
|
+ throw new CustomException("收件箱地址为空!");
|
|
|
+ }
|
|
|
+ String tenantId = ServletUtils.getRequest().getHeader("TenantId");
|
|
|
+ SysConfig mailConfig = iSysConfigService.getSysConfigByKeyTenant("home.mail", Long.valueOf(tenantId));
|
|
|
+ if (ObjectUtils.isNull(mailConfig)) {
|
|
|
+ throw new CustomException("请先完成邮箱配置!");
|
|
|
+ }
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(mailConfig.getConfigValue());
|
|
|
+ String postAccount = jsonObject.get("postAccount").toString();
|
|
|
+ String postPassword = jsonObject.get("postPassword").toString();
|
|
|
+ String STMPserver = jsonObject.get("STMPserver").toString();
|
|
|
+ String post = jsonObject.get("post").toString();
|
|
|
+
|
|
|
+ List<String> mailAttrsList = bo.getMailAttrList();
|
|
|
+ try {
|
|
|
+ // 1.创建Session
|
|
|
+ Session session = JavaMailUtils.createsession(postAccount, postPassword, STMPserver, post);
|
|
|
+ // 2.创建邮件对象(Message抽象类的子类对象)
|
|
|
+ MimeMessage msg = new MimeMessage(session); // 传入session
|
|
|
+ msg.setFrom(new InternetAddress(postAccount)); // 发件人
|
|
|
+ msg.setRecipient(Message.RecipientType.TO, new InternetAddress(mailAttrsList.get(0))); // 收件人
|
|
|
+ if (mailAttrsList.size() > 1){
|
|
|
+ InternetAddress[] addresses = new InternetAddress[mailAttrsList.size() - 1];
|
|
|
+ for (int i = 0; i < mailAttrsList.size(); i++) {
|
|
|
+ if (i == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ addresses[i-1] = new InternetAddress(mailAttrsList.get(i));
|
|
|
+ }
|
|
|
+ msg.setRecipients(Message.RecipientType.CC,addresses); //抄送人
|
|
|
+ }
|
|
|
+ msg.setSubject(bo.getMailName(),"utf-8"); // 标题
|
|
|
+
|
|
|
+ // 3.邮件内容"复合"对象
|
|
|
+ Multipart multipart = new MimeMultipart();
|
|
|
+ // 正文
|
|
|
+ BodyPart textPart = new MimeBodyPart();
|
|
|
+ // 参数1:正文内容
|
|
|
+ // 参数2:内容类型;字符编码集
|
|
|
+ textPart.setContent(bo.getMailText(), "text/html;charset=utf-8");
|
|
|
+
|
|
|
+ // 附件
|
|
|
+ BodyPart imagePart = new MimeBodyPart();
|
|
|
+ String filename = bo.getMailUrlName();
|
|
|
+ String fileNameNew= MimeUtility.encodeText(filename,"utf-8",null);
|
|
|
+ imagePart.setFileName(fileNameNew); // 设置附件文件的显示名称
|
|
|
+ InputStream in = ossService.getStreamByObject(bo.getMailUrl());
|
|
|
+
|
|
|
+ imagePart.setDataHandler(
|
|
|
+ new DataHandler(
|
|
|
+ new ByteArrayDataSource(
|
|
|
+ IOUtils.toByteArray(in),
|
|
|
+ "application/octet-stream")));
|
|
|
+
|
|
|
+ // 添加至邮件内容
|
|
|
+ multipart.addBodyPart(textPart); // 添加正文
|
|
|
+ multipart.addBodyPart(imagePart); // 添加附件
|
|
|
+ // 设置邮件内容
|
|
|
+ msg.setContent(multipart);
|
|
|
+ // 3.发送
|
|
|
+ Transport.send(msg);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return iExamApplySiteTimeService.update(new LambdaUpdateWrapper<ExamApplySiteTime>()
|
|
|
+ .in(ExamApplySiteTime::getId, bo.getIds())
|
|
|
+ .set(ExamApplySiteTime::getSendmail, 1));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void userStudyRecord(String userPath, List<UserSubscribe> list) {
|
|
|
+ Map<Long, List<UserSubscribe>> map = list.stream().collect(Collectors.groupingBy(UserSubscribe::getUserId));
|
|
|
+ map.forEach((k, v) -> {
|
|
|
+ User user = iUserService.getById(k);
|
|
|
+ if (ObjectUtils.isNull(user)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ SysTenant tenant = sysTenantService.getById(user.getTenantId());
|
|
|
+ Set<Long> orderGoodsIds = v.stream().map(UserSubscribe::getOrderGoodsId).collect(Collectors.toSet());
|
|
|
+ List<UserStudyRecordExport> recordExports = new ArrayList<>();
|
|
|
+ for (Long orderGoodsId : orderGoodsIds) {
|
|
|
+ //学习记录
|
|
|
+ recordExports = baseMapper.getUserStudyRecord(orderGoodsId, k);
|
|
|
+ if (CollectionUtils.isEmpty(recordExports)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ recordExports.forEach(item -> {
|
|
|
+ item.setUserName(user.getRealname());
|
|
|
+ item.setIdCard(EncryptHandler.decrypt(user.getIdCard()));
|
|
|
+ item.setCompanyName(tenant.getTenantName());
|
|
|
+ item.setSectionTime(String.format("%s分钟", item.getDurationTime() / 60));
|
|
|
+ if (item.getStatus() == 1) {
|
|
|
+ //已学完
|
|
|
+ item.setStudyTime(String.format("%s分钟", item.getDurationTime() / 60));
|
|
|
+ item.setFinish("已完成");
|
|
|
+ } else {
|
|
|
+ item.setFinish("未完成");
|
|
|
+ }
|
|
|
+ item.setStudyStartTime(DateUtils.timestampToDateFormat(item.getStartTime(), "yyyy/MM/dd HH:mm:ss"));
|
|
|
+ item.setStudyEndTime(DateUtils.timestampToDateFormat(item.getEndTime(), "yyyy/MM/dd HH:mm:ss"));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ ExcelUtil<UserStudyRecordExport> util = new ExcelUtil<UserStudyRecordExport>(UserStudyRecordExport.class);
|
|
|
+ String path = userPath + "/" + user.getRealname() + ".xlsx";
|
|
|
+ util.exportEasyExcelStudy(util.exportEasyData(recordExports), path);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
private boolean checkNameUnique(ExamApply entity) {
|
|
|
ExamApply info = getOne(new LambdaQueryWrapper<ExamApply>()
|
|
|
- .eq(ExamApply::getApplyName,entity.getApplyName()).ne(ExamApply::getStatus,-1).last("limit 1"));
|
|
|
+ .eq(ExamApply::getApplyName, entity.getApplyName()).ne(ExamApply::getStatus, -1).last("limit 1"));
|
|
|
if (Validator.isNotNull(info)) {
|
|
|
- if(Validator.isNotEmpty(entity.getApplyId())){
|
|
|
- if(entity.getApplyId().longValue() != info.getApplyId().longValue()){
|
|
|
+ if (Validator.isNotEmpty(entity.getApplyId())) {
|
|
|
+ if (entity.getApplyId().longValue() != info.getApplyId().longValue()) {
|
|
|
return true;
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return true;
|
|
|
}
|
|
|
}
|