|
|
@@ -4,18 +4,25 @@ import cn.dev33.satoken.stp.StpUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
+import com.xjrsoft.common.enums.DeleteMark;
|
|
|
import com.xjrsoft.common.mybatis.SqlRunnerAdapter;
|
|
|
+import com.xjrsoft.module.base.entity.BaseClass;
|
|
|
+import com.xjrsoft.module.base.mapper.BaseClassMapper;
|
|
|
import com.xjrsoft.module.internship.dto.AddInternshipPlanManageParticipantDto;
|
|
|
import com.xjrsoft.module.internship.dto.InternshipPlanManageParticipantPageDto;
|
|
|
import com.xjrsoft.module.internship.entity.InternshipPlanClass;
|
|
|
import com.xjrsoft.module.internship.entity.InternshipPlanManage;
|
|
|
import com.xjrsoft.module.internship.entity.InternshipPlanManageParticipant;
|
|
|
+import com.xjrsoft.module.internship.entity.InternshipPlanTeacher;
|
|
|
import com.xjrsoft.module.internship.mapper.InternshipPlanClassMapper;
|
|
|
import com.xjrsoft.module.internship.mapper.InternshipPlanManageMapper;
|
|
|
import com.xjrsoft.module.internship.mapper.InternshipPlanManageParticipantMapper;
|
|
|
+import com.xjrsoft.module.internship.mapper.InternshipPlanTeacherMapper;
|
|
|
import com.xjrsoft.module.internship.service.IInternshipPlanManageParticipantService;
|
|
|
import com.xjrsoft.module.student.dto.BaseStudentInfoPageDto;
|
|
|
import com.xjrsoft.module.student.dto.BaseStudentUserPageDto;
|
|
|
+import com.xjrsoft.module.student.mapper.BaseStudentSchoolRollMapper;
|
|
|
import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService;
|
|
|
import com.xjrsoft.module.student.service.IBaseStudentService;
|
|
|
import com.xjrsoft.module.student.vo.BaseStudentInfoPageVo;
|
|
|
@@ -40,32 +47,39 @@ import java.util.stream.Collectors;
|
|
|
public class InternshipPlanManageParticipantServiceImpl extends MPJBaseServiceImpl<InternshipPlanManageParticipantMapper, InternshipPlanManageParticipant> implements IInternshipPlanManageParticipantService {
|
|
|
private final InternshipPlanManageMapper internshipPlanManageMapper;
|
|
|
private final InternshipPlanClassMapper internshipPlanClassMapper;
|
|
|
-
|
|
|
+ private final InternshipPlanTeacherMapper internshipPlanTeacherMapper;
|
|
|
private final IBaseStudentSchoolRollService baseStudentSchoolRollService;
|
|
|
private final IBaseStudentService baseStudentService;
|
|
|
+ private final BaseStudentSchoolRollMapper baseStudentSchoolRollMapper;
|
|
|
+ private final BaseClassMapper baseClassMapper;
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public Boolean add(AddInternshipPlanManageParticipantDto dto) {
|
|
|
InternshipPlanManage planManage = internshipPlanManageMapper.selectById(dto.getInternshipPlanManageId());
|
|
|
- InternshipPlanClass planClass = internshipPlanClassMapper.selectOne(
|
|
|
- new QueryWrapper<InternshipPlanClass>().lambda()
|
|
|
- .eq(InternshipPlanClass::getInternshipPlanManageId, dto.getInternshipPlanManageId())
|
|
|
- .eq(InternshipPlanClass::getClassId, dto.getClassId())
|
|
|
- );
|
|
|
-
|
|
|
|
|
|
List<InternshipPlanManageParticipant> insertList = new ArrayList<>();
|
|
|
|
|
|
List<BaseStudentUserPageVo> studentList = baseStudentService.getStudentList(new BaseStudentUserPageDto() {{
|
|
|
setUserIds(dto.getStudentUserIds());
|
|
|
}});
|
|
|
+ List<Long> classIds = studentList.stream().map(BaseStudentUserPageVo::getClassId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<InternshipPlanClass> planClassList = internshipPlanClassMapper.selectList(
|
|
|
+ new QueryWrapper<InternshipPlanClass>().lambda()
|
|
|
+ .eq(InternshipPlanClass::getInternshipPlanManageId, dto.getInternshipPlanManageId())
|
|
|
+ .in(InternshipPlanClass::getClassId, classIds)
|
|
|
+ );
|
|
|
|
|
|
+ Map<Long, Long> classTeacherIdMaps = planClassList.stream().collect(Collectors.toMap(InternshipPlanClass::getClassId, InternshipPlanClass::getInternshipPlanTeacherId));
|
|
|
+ List<Long> internshipPlanTeacherIds = planClassList.stream().map(InternshipPlanClass::getInternshipPlanTeacherId).collect(Collectors.toList());
|
|
|
+ List<InternshipPlanTeacher> internshipPlanTeachers = internshipPlanTeacherMapper.selectBatchIds(internshipPlanTeacherIds);
|
|
|
+ Map<Long, Long> teacherMap = internshipPlanTeachers.stream().collect(Collectors.toMap(InternshipPlanTeacher::getId, InternshipPlanTeacher::getUserId));
|
|
|
for (BaseStudentUserPageVo student : studentList) {
|
|
|
insertList.add(new InternshipPlanManageParticipant(){{
|
|
|
setClassId(student.getClassId());
|
|
|
setParticipantUserId(Long.parseLong(student.getId()));
|
|
|
setInternshipPlanManageId(planManage.getId());
|
|
|
- setTeacherId(planClass.getInternshipPlanTeacherId());
|
|
|
+ setTeacherId(teacherMap.get(classTeacherIdMaps.get(student.getClassId())));
|
|
|
setParticipantUserStudentId(student.getStudentId());
|
|
|
setParticipantUserName(student.getName());
|
|
|
setBaseMajorName(student.getMajorSetName());
|
|
|
@@ -112,7 +126,30 @@ public class InternshipPlanManageParticipantServiceImpl extends MPJBaseServiceIm
|
|
|
|
|
|
BaseStudentInfoPageDto studentInfoPageDto = new BaseStudentInfoPageDto();
|
|
|
studentInfoPageDto.setNotInIds(notInIds);
|
|
|
- return baseStudentSchoolRollService.getMobilePage(page, studentInfoPageDto);
|
|
|
+
|
|
|
+ List<String> roleList = StpUtil.getRoleList();
|
|
|
+
|
|
|
+ long teacherId = StpUtil.getLoginIdAsLong();
|
|
|
+ List<BaseClass> classList = baseClassMapper.selectList(
|
|
|
+ new MPJLambdaWrapper<BaseClass>()
|
|
|
+ .select(BaseClass::getId)
|
|
|
+ .innerJoin(InternshipPlanClass.class, InternshipPlanClass::getClassId, BaseClass::getId)
|
|
|
+ .eq(BaseClass::getTeacherId, teacherId)
|
|
|
+ .eq(InternshipPlanClass::getInternshipPlanManageId, dto.getInternshipPlanManageId())
|
|
|
+ .eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ );
|
|
|
+ if(classList.isEmpty()){
|
|
|
+ return new Page<>();
|
|
|
+ }
|
|
|
+ if (roleList.size() == 2 && roleList.contains("CLASSTE")) {
|
|
|
+ studentInfoPageDto.setTeacherId(teacherId);
|
|
|
+ } else {
|
|
|
+ if (studentInfoPageDto.getClassId() == null) {
|
|
|
+ studentInfoPageDto.setClassId(classList.get(0).getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return baseStudentSchoolRollMapper.getMobilePage(page, studentInfoPageDto);
|
|
|
}
|
|
|
|
|
|
/**
|