|
@@ -0,0 +1,128 @@
|
|
|
+package com.ym.mec.biz.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.ym.mec.biz.dal.dao.LessonExaminationDao;
|
|
|
+import com.ym.mec.biz.dal.dao.SysConfigDao;
|
|
|
+import com.ym.mec.biz.dal.dto.*;
|
|
|
+import com.ym.mec.biz.dal.entity.LessonExamination;
|
|
|
+import com.ym.mec.biz.dal.entity.StudentLessonExamination;
|
|
|
+import com.ym.mec.biz.dal.page.LessonExaminationQueryInfo;
|
|
|
+import com.ym.mec.biz.dal.page.LessonExaminationQueryInfo1;
|
|
|
+import com.ym.mec.biz.dal.page.LessonExaminationQueryInfo2;
|
|
|
+import com.ym.mec.biz.service.LessonExaminationService;
|
|
|
+import com.ym.mec.biz.service.StudentLessonExaminationDetailService;
|
|
|
+import com.ym.mec.biz.service.StudentLessonExaminationService;
|
|
|
+import com.ym.mec.common.exception.BizException;
|
|
|
+import com.ym.mec.common.page.PageInfo;
|
|
|
+import com.ym.mec.common.page.QueryInfo;
|
|
|
+import com.ym.mec.common.service.IdGeneratorService;
|
|
|
+import com.ym.mec.util.collection.MapUtil;
|
|
|
+import com.ym.mec.util.date.DateUtil;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
+import org.springframework.validation.BindException;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 进度评测表(LessonExamination)表服务实现类
|
|
|
+ *
|
|
|
+ * @author zx
|
|
|
+ * @since 2023-04-03 18:20:44
|
|
|
+ */
|
|
|
+@Service("lessonExaminationService")
|
|
|
+public class LessonExaminationServiceImpl extends ServiceImpl<LessonExaminationDao, LessonExamination> implements LessonExaminationService {
|
|
|
+
|
|
|
+ private final static Logger log = LoggerFactory.getLogger(LessonExaminationServiceImpl.class);
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysConfigDao sysConfigDao;
|
|
|
+ @Autowired
|
|
|
+ private StudentLessonExaminationService studentLessonExaminationService;
|
|
|
+ @Autowired
|
|
|
+ private StudentLessonExaminationDetailService studentLessonExaminationDetailService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public LessonExaminationDao getDao() {
|
|
|
+ return this.baseMapper;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void publish(LessonExaminationSaveDto param) {
|
|
|
+ String studentIds = param.getStudentIds();
|
|
|
+ if(StringUtils.isEmpty(studentIds)){
|
|
|
+ throw new BizException("请选择学员");
|
|
|
+ }
|
|
|
+ List<LessonExaminationDetailDto> examinationDetailDtos = param.getExaminationDetailDtos();
|
|
|
+ if(CollectionUtils.isEmpty(examinationDetailDtos)){
|
|
|
+ throw new BizException("请选择练习内容");
|
|
|
+ }
|
|
|
+ String expireTime = sysConfigDao.findConfigValue("homework_expire_time");
|
|
|
+ if(org.apache.commons.lang3.StringUtils.isEmpty(expireTime)){
|
|
|
+ expireTime = "7";
|
|
|
+ }
|
|
|
+ String expireDate = DateUtil.dateToString(DateUtil.addDays(new Date(), Integer.parseInt(expireTime)),DateUtil.ISO_EXPANDED_DATE_FORMAT);
|
|
|
+ String[] split = studentIds.split(",");
|
|
|
+ LessonExamination lessonExamination = new LessonExamination();
|
|
|
+ lessonExamination.setExpectNum(split.length);
|
|
|
+ lessonExamination.setClassGroupId(param.getClassGroupId());
|
|
|
+ lessonExamination.setCourseScheduleId(param.getCourseScheduleId());
|
|
|
+ lessonExamination.setExpireDate(expireDate);
|
|
|
+ lessonExamination.setTeacherId(param.getTeacherId());
|
|
|
+ baseMapper.insert(lessonExamination);
|
|
|
+ studentLessonExaminationService.save(lessonExamination.getId(),split);
|
|
|
+ studentLessonExaminationDetailService.save(lessonExamination.getId(),split,examinationDetailDtos);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageInfo<LessonExaminationResultDto> queryPage(LessonExaminationQueryInfo queryInfo) {
|
|
|
+ PageInfo<LessonExaminationResultDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
+ MapUtil.populateMap(params, queryInfo);
|
|
|
+ List<LessonExaminationResultDto> dataList = null;
|
|
|
+ int count = baseMapper.findCount(params);
|
|
|
+ if (count > 0) {
|
|
|
+ pageInfo.setTotal(count);
|
|
|
+ params.put("offset", pageInfo.getOffset());
|
|
|
+ dataList = baseMapper.queryPage(params);
|
|
|
+ }
|
|
|
+ if (count == 0) {
|
|
|
+ dataList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ pageInfo.setRows(dataList);
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageInfo<LessonExaminationResultDto1> queryPageByStudent(LessonExaminationQueryInfo1 queryInfo) {
|
|
|
+ PageInfo<LessonExaminationResultDto1> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ MapUtil.populateMap(params, queryInfo);
|
|
|
+ List<LessonExaminationResultDto1> dataList = null;
|
|
|
+ int count = baseMapper.findCountByStudent(params);
|
|
|
+ if (count > 0) {
|
|
|
+ pageInfo.setTotal(count);
|
|
|
+ params.put("offset", pageInfo.getOffset());
|
|
|
+ dataList = baseMapper.queryPageByStudent(params);
|
|
|
+ }
|
|
|
+ if (count == 0) {
|
|
|
+ dataList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ pageInfo.setRows(dataList);
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageInfo<LessonExaminationResultDto2> queryPageByWeb(LessonExaminationQueryInfo2 queryInfo) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|