|
|
@@ -1,11 +1,35 @@
|
|
|
package com.xjrsoft.module.internship.service.impl;
|
|
|
|
|
|
+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.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.mapper.InternshipPlanClassMapper;
|
|
|
+import com.xjrsoft.module.internship.mapper.InternshipPlanManageMapper;
|
|
|
import com.xjrsoft.module.internship.mapper.InternshipPlanManageParticipantMapper;
|
|
|
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.service.IBaseStudentSchoolRollService;
|
|
|
+import com.xjrsoft.module.student.service.IBaseStudentService;
|
|
|
+import com.xjrsoft.module.student.vo.BaseStudentInfoPageVo;
|
|
|
+import com.xjrsoft.module.student.vo.BaseStudentUserPageVo;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @title: 实习计划参与人表
|
|
|
@@ -16,4 +40,102 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
public class InternshipPlanManageParticipantServiceImpl extends MPJBaseServiceImpl<InternshipPlanManageParticipantMapper, InternshipPlanManageParticipant> implements IInternshipPlanManageParticipantService {
|
|
|
+ private final InternshipPlanManageMapper internshipPlanManageMapper;
|
|
|
+ private final InternshipPlanClassMapper internshipPlanClassMapper;
|
|
|
+
|
|
|
+ private final IBaseStudentSchoolRollService baseStudentSchoolRollService;
|
|
|
+ private final IBaseStudentService baseStudentService;
|
|
|
+ private final BaseClassMapper classMapper;
|
|
|
+ @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())
|
|
|
+ );
|
|
|
+
|
|
|
+ BaseClass baseClass = classMapper.selectById(planClass.getClassId());
|
|
|
+
|
|
|
+ List<InternshipPlanManageParticipant> insertList = new ArrayList<>();
|
|
|
+
|
|
|
+ List<BaseStudentUserPageVo> studentList = baseStudentService.getStudentList(new BaseStudentUserPageDto() {{
|
|
|
+ setUserIds(dto.getStudentUserIds());
|
|
|
+ }});
|
|
|
+
|
|
|
+ for (BaseStudentUserPageVo student : studentList) {
|
|
|
+ insertList.add(new InternshipPlanManageParticipant(){{
|
|
|
+ setClassId(dto.getClassId());
|
|
|
+ setParticipantUserId(Long.parseLong(student.getId()));
|
|
|
+ setInternshipPlanManageId(planManage.getId());
|
|
|
+ setTeacherId(planClass.getInternshipPlanTeacherId());
|
|
|
+ setParticipantUserStudentId(student.getStudentId());
|
|
|
+ setParticipantUserName(student.getName());
|
|
|
+ setBaseMajorName(student.getMajorSetName());
|
|
|
+ setBaseMajorId(student.getMajorSetId());
|
|
|
+ setClassName(baseClass.getName());
|
|
|
+ }});
|
|
|
+ }
|
|
|
+ if(!insertList.isEmpty()){
|
|
|
+ this.saveBatch(insertList);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public Boolean removeStudent(AddInternshipPlanManageParticipantDto dto) {
|
|
|
+ this.baseMapper.delete(
|
|
|
+ new QueryWrapper<InternshipPlanManageParticipant>().lambda()
|
|
|
+ .eq(InternshipPlanManageParticipant::getInternshipPlanManageId, dto.getInternshipPlanManageId())
|
|
|
+ .in(InternshipPlanManageParticipant::getParticipantUserId, dto.getStudentUserIds())
|
|
|
+ );
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<BaseStudentInfoPageVo> getChooseStudentPage(Page<BaseStudentInfoPageVo> page, InternshipPlanManageParticipantPageDto dto) {
|
|
|
+ //查询自主实习和特异体质的学生
|
|
|
+ String sql = "SELECT t1.* FROM student_internship_alone_apply t1" +
|
|
|
+ " INNER JOIN xjr_workflow_form_relation t2 ON t1.id = CAST(t2.form_key_value AS SIGNED)" +
|
|
|
+ " WHERE t1.delete_mark = 0 AND t1.enabled_mark = 1 AND t2.current_state = 'COMPLETED'";
|
|
|
+ List<Map<String, Object>> internshipAloneApplyList = SqlRunnerAdapter.db().selectList(sql);
|
|
|
+ List<Long> notInIds = new ArrayList<>();
|
|
|
+ for (Map<String, Object> objectMap : internshipAloneApplyList) {
|
|
|
+ notInIds.add(Long.parseLong(objectMap.get("id").toString()));
|
|
|
+ }
|
|
|
+
|
|
|
+ sql = "SELECT t1.* FROM student_special_constitution t1" +
|
|
|
+ " INNER JOIN xjr_workflow_form_relation t2 ON t1.id = CAST(t2.form_key_value AS SIGNED)" +
|
|
|
+ " WHERE t1.delete_mark = 0 AND t1.enabled_mark = 1 AND t2.current_state = 'COMPLETED'";
|
|
|
+ List<Map<String, Object>> specialConstitutionList = SqlRunnerAdapter.db().selectList(sql);
|
|
|
+ for (Map<String, Object> objectMap : specialConstitutionList) {
|
|
|
+ notInIds.add(Long.parseLong(objectMap.get("id").toString()));
|
|
|
+ }
|
|
|
+
|
|
|
+ BaseStudentInfoPageDto studentInfoPageDto = new BaseStudentInfoPageDto();
|
|
|
+ studentInfoPageDto.setNotInIds(notInIds);
|
|
|
+ return baseStudentSchoolRollService.getMobilePage(page, studentInfoPageDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询带队的学生
|
|
|
+ * @param page
|
|
|
+ * @param dto
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Page<BaseStudentInfoPageVo> getTeamStudentPage(Page<BaseStudentInfoPageVo> page, InternshipPlanManageParticipantPageDto dto) {
|
|
|
+ long teacherId = StpUtil.getLoginIdAsLong();
|
|
|
+
|
|
|
+ List<InternshipPlanManageParticipant> list = this.list(
|
|
|
+ new QueryWrapper<InternshipPlanManageParticipant>().lambda()
|
|
|
+ .eq(InternshipPlanManageParticipant::getInternshipPlanManageId, dto.getInternshipPlanManageId())
|
|
|
+ .eq(InternshipPlanManageParticipant::getTeacherId, teacherId)
|
|
|
+ );
|
|
|
+ BaseStudentInfoPageDto studentInfoPageDto = new BaseStudentInfoPageDto();
|
|
|
+ studentInfoPageDto.setInIds(list.stream().map(InternshipPlanManageParticipant::getParticipantUserId).collect(Collectors.toList()));
|
|
|
+ return baseStudentSchoolRollService.getMobilePage(page, studentInfoPageDto);
|
|
|
+ }
|
|
|
}
|