|  | @@ -0,0 +1,104 @@
 | 
											
												
													
														|  | 
 |  | +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.LessonExaminationDetailDto;
 | 
											
												
													
														|  | 
 |  | +import com.ym.mec.biz.dal.dto.LessonExaminationResultDto;
 | 
											
												
													
														|  | 
 |  | +import com.ym.mec.biz.dal.dto.LessonExaminationSaveDto;
 | 
											
												
													
														|  | 
 |  | +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.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;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +
 |