|
@@ -2,14 +2,30 @@ package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
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.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
+import com.ym.mec.biz.dal.entity.*;
|
|
|
+import com.ym.mec.biz.dal.enums.CourseStatusEnum;
|
|
|
+import com.ym.mec.biz.dal.enums.EEvaluateStatus;
|
|
|
+import com.ym.mec.biz.service.*;
|
|
|
+import com.ym.mec.common.exception.BizException;
|
|
|
+import com.ym.mec.util.date.DateUtil;
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import com.ym.mec.biz.dal.entity.CoursePatrolEvaluation;
|
|
|
import com.ym.mec.biz.dal.wrapper.CoursePatrolEvaluationWrapper;
|
|
|
import com.ym.mec.biz.dal.mapper.CoursePatrolEvaluationMapper;
|
|
|
-import com.ym.mec.biz.service.CoursePatrolEvaluationService;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 巡堂详情
|
|
@@ -19,15 +35,37 @@ import com.ym.mec.biz.service.CoursePatrolEvaluationService;
|
|
|
@Service
|
|
|
public class CoursePatrolEvaluationServiceImpl extends ServiceImpl<CoursePatrolEvaluationMapper, CoursePatrolEvaluation> implements CoursePatrolEvaluationService {
|
|
|
|
|
|
- /**
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OrganizationService organizationService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CooperationOrganService cooperationOrganService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CourseScheduleService courseScheduleService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysUserFeignService sysUserFeignService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TeacherService teacherService;
|
|
|
+
|
|
|
+ /**
|
|
|
* 查询详情
|
|
|
* @param id 详情ID
|
|
|
* @return CoursePatrolEvaluation
|
|
|
*/
|
|
|
- @Override
|
|
|
+ @Override
|
|
|
public CoursePatrolEvaluationWrapper.CoursePatrolEvaluationInfo detail(Long id) {
|
|
|
|
|
|
- return null;
|
|
|
+ IPage<CoursePatrolEvaluationWrapper.CoursePatrolEvaluationInfo> coursePatrolEvaluationInfoIPage = selectPage(new Page<>(1, 1),
|
|
|
+ CoursePatrolEvaluationWrapper.CoursePatrolEvaluationQuery.builder().id(id.intValue()).build());
|
|
|
+ if (CollectionUtils.isEmpty(coursePatrolEvaluationInfoIPage.getRecords())) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return coursePatrolEvaluationInfoIPage.getRecords().get(0);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -39,19 +77,89 @@ public class CoursePatrolEvaluationServiceImpl extends ServiceImpl<CoursePatrolE
|
|
|
@Override
|
|
|
public IPage<CoursePatrolEvaluationWrapper.CoursePatrolEvaluationInfo> selectPage(IPage<CoursePatrolEvaluationWrapper.CoursePatrolEvaluationInfo> page,
|
|
|
CoursePatrolEvaluationWrapper.CoursePatrolEvaluationQuery query) {
|
|
|
-
|
|
|
- return page.setRecords(baseMapper.selectPage(page, query));
|
|
|
+ List<CoursePatrolEvaluationWrapper.CoursePatrolEvaluationInfo> coursePatrolEvaluationInfos = baseMapper.selectPage(page, query);
|
|
|
+
|
|
|
+ if (CollectionUtils.isEmpty(coursePatrolEvaluationInfos)) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+ // 设置分部名称
|
|
|
+ // 分部ID集合
|
|
|
+ List<Integer> organIds = coursePatrolEvaluationInfos.stream()
|
|
|
+ .map(CoursePatrolEvaluationWrapper.CoursePatrolEvaluationInfo::getOrganId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ Map<Integer, Organization> organizationMap = organizationService.getMapByIds(organIds);
|
|
|
+ // 设置合作单位名称
|
|
|
+
|
|
|
+ // 合作单位ID集合
|
|
|
+ List<Integer> cooperationIds = coursePatrolEvaluationInfos.stream()
|
|
|
+ .map(CoursePatrolEvaluationWrapper.CoursePatrolEvaluationInfo::getCooperationOrganId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ Map<Integer, CooperationOrgan> cooperationOrganMap = cooperationOrganService.getMapByIds(cooperationIds);
|
|
|
+
|
|
|
+ // 设置老师信息
|
|
|
+
|
|
|
+ // 老师ID集合
|
|
|
+ List<Integer> teacherIds = coursePatrolEvaluationInfos.stream()
|
|
|
+ .map(CoursePatrolEvaluationWrapper.CoursePatrolEvaluationInfo::getTeacherId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ Map<Integer, Teacher> teacherMap = teacherService.getMapByIds(teacherIds);
|
|
|
+
|
|
|
+
|
|
|
+ for (CoursePatrolEvaluationWrapper.CoursePatrolEvaluationInfo coursePatrolEvaluationInfo : coursePatrolEvaluationInfos) {
|
|
|
+ Organization organization = organizationMap.get(coursePatrolEvaluationInfo.getOrganId());
|
|
|
+ if (organization != null) {
|
|
|
+ coursePatrolEvaluationInfo.setOrganName(organization.getName());
|
|
|
+ }
|
|
|
+ CooperationOrgan cooperationOrgan = cooperationOrganMap.get(coursePatrolEvaluationInfo.getCooperationOrganId());
|
|
|
+ if (cooperationOrgan != null) {
|
|
|
+ coursePatrolEvaluationInfo.setCooperationOrganName(cooperationOrgan.getName());
|
|
|
+ }
|
|
|
+ Teacher teacher = teacherMap.get(coursePatrolEvaluationInfo.getTeacherId());
|
|
|
+ if (teacher != null) {
|
|
|
+ coursePatrolEvaluationInfo.setTeacherName(teacher.getRealName());
|
|
|
+ coursePatrolEvaluationInfo.setTeacherAvatar(teacher.getAvatar());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置上课时间
|
|
|
+ coursePatrolEvaluationInfo.setStartClassTime(DateUtil.startDateAndEndTime(coursePatrolEvaluationInfo.getCourseDate(), coursePatrolEvaluationInfo.getStartClassTime()));
|
|
|
+ coursePatrolEvaluationInfo.setEndClassTime(DateUtil.startDateAndEndTime(coursePatrolEvaluationInfo.getCourseDate(), coursePatrolEvaluationInfo.getEndClassTime()));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return page.setRecords(coursePatrolEvaluationInfos);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 添加
|
|
|
* @param coursePatrolEvaluation CoursePatrolEvaluationWrapper.CoursePatrolEvaluation
|
|
|
* @return Boolean
|
|
|
*/
|
|
|
@Override
|
|
|
- public Boolean add(CoursePatrolEvaluationWrapper.CoursePatrolEvaluation coursePatrolEvaluation) {
|
|
|
-
|
|
|
- return this.save(JSON.parseObject(coursePatrolEvaluation.jsonString(), CoursePatrolEvaluation.class));
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean add(CoursePatrolEvaluationWrapper.CoursePatrolEvaluation coursePatrolEvaluation) {
|
|
|
+
|
|
|
+ // 未开始的可成不允许做巡堂评价
|
|
|
+ CourseSchedule courseSchedule = courseScheduleService.get(coursePatrolEvaluation.getCourseScheduleId().longValue());
|
|
|
+ if (courseSchedule == null) {
|
|
|
+ throw new BizException("课程不存在");
|
|
|
+ }
|
|
|
+ if (courseSchedule.getStatus().equals(CourseStatusEnum.NOT_START)) {
|
|
|
+ throw new BizException("课程未开始,不允许做巡堂评价");
|
|
|
+ }
|
|
|
+
|
|
|
+ CoursePatrolEvaluation evaluation = JSON.parseObject(coursePatrolEvaluation.jsonString(), CoursePatrolEvaluation.class);
|
|
|
+ evaluation.setCreateTime(new Date());
|
|
|
+ evaluation.setUpdateTime(new Date());
|
|
|
+ evaluation.setHandleStatus(false);
|
|
|
+ evaluation.setUserId(sysUserFeignService.queryUserInfo().getId());
|
|
|
+ return this.save(evaluation);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -60,8 +168,56 @@ public class CoursePatrolEvaluationServiceImpl extends ServiceImpl<CoursePatrolE
|
|
|
* @return Boolean
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean update(CoursePatrolEvaluationWrapper.CoursePatrolEvaluation coursePatrolEvaluation){
|
|
|
+ // 查询是否存在
|
|
|
+ CoursePatrolEvaluation evaluation = this.getById(coursePatrolEvaluation.getId());
|
|
|
+ if (evaluation == null) {
|
|
|
+ throw new BizException("巡堂评价不存在");
|
|
|
+ }
|
|
|
+ // 处理建议
|
|
|
+ if(StringUtils.isBlank(coursePatrolEvaluation.getSuggestion())) {
|
|
|
+ evaluation.setSuggestion(coursePatrolEvaluation.getSuggestion());
|
|
|
+ evaluation.setHandleStatus(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ evaluation.setUpdateTime(new Date());
|
|
|
+ // 评价为合格以上 描述设置为空
|
|
|
+ if (coursePatrolEvaluation.getEvaluateStatus() != null) {
|
|
|
+ evaluation.setEvaluateStatus(coursePatrolEvaluation.getEvaluateStatus());
|
|
|
+ evaluation.setAttachmentUrl(coursePatrolEvaluation.getAttachmentUrl());
|
|
|
+ if(coursePatrolEvaluation.getEvaluateStatus().equals(EEvaluateStatus.UNQUALIFIED)) {
|
|
|
+ evaluation.setProblemType(coursePatrolEvaluation.getProblemType());
|
|
|
+ evaluation.setProblemDesc(coursePatrolEvaluation.getProblemDesc());
|
|
|
+ } else {
|
|
|
+ evaluation.setProblemType(null);
|
|
|
+ evaluation.setProblemDesc(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ this.lambdaUpdate()
|
|
|
+ .eq(CoursePatrolEvaluation::getId, evaluation.getId())
|
|
|
+ .set(CoursePatrolEvaluation::getSuggestion, evaluation.getSuggestion())
|
|
|
+ .set(CoursePatrolEvaluation::getHandleStatus, evaluation.getHandleStatus())
|
|
|
+ .set(CoursePatrolEvaluation::getEvaluateStatus, evaluation.getEvaluateStatus())
|
|
|
+ .set(CoursePatrolEvaluation::getAttachmentUrl, evaluation.getAttachmentUrl())
|
|
|
+ .set(CoursePatrolEvaluation::getProblemType, evaluation.getProblemType())
|
|
|
+ .set(CoursePatrolEvaluation::getProblemDesc, evaluation.getProblemDesc())
|
|
|
+ .update();
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 巡堂课统计列表
|
|
|
+ *
|
|
|
+ * @param page
|
|
|
+ * @param query
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public IPage<CoursePatrolEvaluationWrapper.CoursePatrolEvaluationStat> pageStat(IPage<Object> page, CoursePatrolEvaluationWrapper.CoursePatrolEvaluationQuery query) {
|
|
|
+ // 根据日期分页
|
|
|
+ return baseMapper.pageStat(page, query);
|
|
|
|
|
|
- return this.updateById(JSON.parseObject(coursePatrolEvaluation.jsonString(), CoursePatrolEvaluation.class));
|
|
|
}
|
|
|
}
|