|
|
|
@ -1,7 +1,9 @@
|
|
|
|
|
package com.sztzjy.trade.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
import com.sztzjy.trade.config.exception.handler.ServiceException;
|
|
|
|
|
import com.sztzjy.trade.entity.*;
|
|
|
|
|
import com.sztzjy.trade.entity.dto.tch.TchAddStuDTO;
|
|
|
|
|
import com.sztzjy.trade.entity.dto.tch.TchStartCourseDTO;
|
|
|
|
|
import com.sztzjy.trade.entity.dto.tch.TchStartCourseNameListDTO;
|
|
|
|
|
import com.sztzjy.trade.mapper.StuUserMapper;
|
|
|
|
@ -9,12 +11,19 @@ import com.sztzjy.trade.mapper.TchClassAndStuMapper;
|
|
|
|
|
import com.sztzjy.trade.mapper.TchStartCourseManageMapper;
|
|
|
|
|
import com.sztzjy.trade.mapper.TchStartCourseNameListMapper;
|
|
|
|
|
import com.sztzjy.trade.service.TchTeachingManagementService;
|
|
|
|
|
import com.sztzjy.trade.util.BigDecimalUtils;
|
|
|
|
|
import com.sztzjy.trade.util.ConvertUtil;
|
|
|
|
|
import com.sztzjy.trade.util.PageUtil;
|
|
|
|
|
import com.sztzjy.trade.util.excel.ImportExcelUtil;
|
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.sql.Date;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
@ -41,6 +50,9 @@ public class TchTeachingManagementServiceImpl implements TchTeachingManagementSe
|
|
|
|
|
@Resource
|
|
|
|
|
TchStartCourseNameListMapper courseNameListMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
BigDecimalUtils bigDecimalUtils;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 开课班级展示
|
|
|
|
|
*/
|
|
|
|
@ -78,9 +90,19 @@ public class TchTeachingManagementServiceImpl implements TchTeachingManagementSe
|
|
|
|
|
//查询班级人数
|
|
|
|
|
List<StuUser> stuUsers=stuUserMapper.selectByCourseName(startCourseName);
|
|
|
|
|
|
|
|
|
|
//添加到开课学生名单中
|
|
|
|
|
//1、添加到开课学生名单中
|
|
|
|
|
List<TchStartCourseNameList> courseNameLists=new ArrayList<>();
|
|
|
|
|
for (StuUser stu : stuUsers) {
|
|
|
|
|
|
|
|
|
|
//2、判断该学生是否被单独添加到开课名单,是则不做添加
|
|
|
|
|
TchStartCourseNameListExample courseNameListExample=new TchStartCourseNameListExample();
|
|
|
|
|
courseNameListExample.createCriteria().andUserIdEqualTo(stu.getUserId());
|
|
|
|
|
List<TchStartCourseNameList> tchStartCourseNameLists = courseNameListMapper.selectByExample(courseNameListExample);
|
|
|
|
|
|
|
|
|
|
if(!tchStartCourseNameLists.isEmpty()){
|
|
|
|
|
continue; //跳出本次循环
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TchStartCourseNameList courseNameList=new TchStartCourseNameList();
|
|
|
|
|
courseNameList.setId(UUID.randomUUID().toString());
|
|
|
|
|
courseNameList.setName(stu.getName());
|
|
|
|
@ -89,6 +111,7 @@ public class TchTeachingManagementServiceImpl implements TchTeachingManagementSe
|
|
|
|
|
courseNameList.setMajor(stu.getMajor());
|
|
|
|
|
courseNameList.setStartCourseId(string);
|
|
|
|
|
courseNameList.setCreateTime(new java.util.Date());
|
|
|
|
|
courseNameList.setUserId(stu.getUserId());
|
|
|
|
|
|
|
|
|
|
courseNameLists.add(courseNameList);
|
|
|
|
|
}
|
|
|
|
@ -150,6 +173,9 @@ public class TchTeachingManagementServiceImpl implements TchTeachingManagementSe
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增开课班级--下拉框查看
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<String> getSelect(String userId,String schoolId) {
|
|
|
|
|
TchStartCourseManageExample courseManageExample=new TchStartCourseManageExample();
|
|
|
|
@ -172,11 +198,185 @@ public class TchTeachingManagementServiceImpl implements TchTeachingManagementSe
|
|
|
|
|
}
|
|
|
|
|
//再用动态sql查询出本次开课未添加的班级名称
|
|
|
|
|
|
|
|
|
|
List<String> list = stuUserMapper.selectByNoClassName(strings,schoolId);
|
|
|
|
|
return list;
|
|
|
|
|
return stuUserMapper.selectByNoClassName(strings,schoolId);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 开课学生名单--添加学生--回显
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public PageInfo addStuEcho(String startCourseId, String schoolId, Integer index, Integer size) {
|
|
|
|
|
//查询出本次开课已添加了的班级,排除这些班级的学生
|
|
|
|
|
TchStartCourseManage startCourseManage = startCourseManageMapper.selectByPrimaryKey(startCourseId);
|
|
|
|
|
|
|
|
|
|
//取得班级名称,去掉逗号得出班级名称集合
|
|
|
|
|
String[] split = startCourseManage.getStartCourseClassName().split(",");
|
|
|
|
|
|
|
|
|
|
List<String> list = new ArrayList<>(Arrays.asList(split));
|
|
|
|
|
|
|
|
|
|
List<StuUser> stuUsers=stuUserMapper.selectStuList(list,schoolId);
|
|
|
|
|
|
|
|
|
|
List<TchStartCourseNameListDTO> tchStartCourseNameListDTOS = convertUtil.entityToDTOList(stuUsers, TchStartCourseNameListDTO.class);
|
|
|
|
|
|
|
|
|
|
return PageUtil.pageHelper(tchStartCourseNameListDTOS, index, size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 开课学生名单--添加学生
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Integer addStu(TchAddStuDTO dto) {
|
|
|
|
|
//查询该学生是否已添加过本次开课
|
|
|
|
|
TchStartCourseManageExample courseManageExample=new TchStartCourseManageExample();
|
|
|
|
|
courseManageExample.createCriteria().andUserIdEqualTo(dto.getUserId());
|
|
|
|
|
List<TchStartCourseManage> startCourseManages = startCourseManageMapper.selectByExample(courseManageExample);
|
|
|
|
|
|
|
|
|
|
if(startCourseManages.isEmpty()){
|
|
|
|
|
|
|
|
|
|
//赋值
|
|
|
|
|
TchStartCourseNameList startCourseNameList=new TchStartCourseNameList();
|
|
|
|
|
startCourseNameList.setId(UUID.randomUUID().toString());
|
|
|
|
|
startCourseNameList.setName(dto.getName());
|
|
|
|
|
startCourseNameList.setStudentId(dto.getStudentId());
|
|
|
|
|
startCourseNameList.setClassName(dto.getClassName());
|
|
|
|
|
startCourseNameList.setMajor(dto.getMajor());
|
|
|
|
|
startCourseNameList.setStartCourseId(dto.getStartCourseId());
|
|
|
|
|
startCourseNameList.setUserId(dto.getUserId());
|
|
|
|
|
startCourseNameList.setCreateTime(new java.util.Date());
|
|
|
|
|
|
|
|
|
|
return courseNameListMapper.insert(startCourseNameList);
|
|
|
|
|
}else {
|
|
|
|
|
throw new ServiceException(HttpStatus.ACCEPTED,"该学生已存在本次开课");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Integer addClass(List<String> className,String schoolId,String startCourseId) {
|
|
|
|
|
|
|
|
|
|
//根据班级名称集合查询出所有学生信息
|
|
|
|
|
List<StuUser> stuUsers=stuUserMapper.selectStuList(className,schoolId);
|
|
|
|
|
|
|
|
|
|
//查询本次开课信息
|
|
|
|
|
TchStartCourseManage startCourseManage = startCourseManageMapper.selectByPrimaryKey(startCourseId);
|
|
|
|
|
//取出班级名称
|
|
|
|
|
String startCourseClassName = startCourseManage.getStartCourseClassName();
|
|
|
|
|
|
|
|
|
|
// TODO: 2024/8/2 更新本次开课信息
|
|
|
|
|
//1、将开课班级累加到开课班级后,逗号隔开
|
|
|
|
|
for (int i = 0; i < className.size(); i++) {
|
|
|
|
|
if(i==className.size()-1){
|
|
|
|
|
startCourseClassName=startCourseClassName+className.get(i);
|
|
|
|
|
}else {
|
|
|
|
|
startCourseClassName=startCourseClassName+className.get(i)+",";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//2、将开课总人数累加
|
|
|
|
|
BigDecimal add = bigDecimalUtils.add(String.valueOf(startCourseManage.getStartCoursePeoples()), String.valueOf(stuUsers.size()));
|
|
|
|
|
startCourseManage.setStartCoursePeoples(Integer.valueOf(add.toString()));
|
|
|
|
|
|
|
|
|
|
startCourseManage.setUpdateTime(new java.util.Date());
|
|
|
|
|
|
|
|
|
|
//更新开课信息
|
|
|
|
|
startCourseManageMapper.updateByPrimaryKey(startCourseManage);
|
|
|
|
|
|
|
|
|
|
// TODO: 2024/8/2 将所查询的班级学生信息添加到开课学生名单中
|
|
|
|
|
|
|
|
|
|
//1、添加到开课学生名单中
|
|
|
|
|
List<TchStartCourseNameList> courseNameLists=new ArrayList<>();
|
|
|
|
|
for (StuUser stu : stuUsers) {
|
|
|
|
|
|
|
|
|
|
//2、判断该学生是否被单独添加到开课名单,是则不做添加
|
|
|
|
|
TchStartCourseNameListExample courseNameListExample=new TchStartCourseNameListExample();
|
|
|
|
|
courseNameListExample.createCriteria().andUserIdEqualTo(stu.getUserId());
|
|
|
|
|
List<TchStartCourseNameList> tchStartCourseNameLists = courseNameListMapper.selectByExample(courseNameListExample);
|
|
|
|
|
|
|
|
|
|
if(!tchStartCourseNameLists.isEmpty()){
|
|
|
|
|
continue; //跳出本次循环
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TchStartCourseNameList courseNameList=new TchStartCourseNameList();
|
|
|
|
|
courseNameList.setId(UUID.randomUUID().toString());
|
|
|
|
|
courseNameList.setName(stu.getName());
|
|
|
|
|
courseNameList.setStudentId(stu.getStudentId());
|
|
|
|
|
courseNameList.setClassName(stu.getClassName());
|
|
|
|
|
courseNameList.setMajor(stu.getMajor());
|
|
|
|
|
courseNameList.setStartCourseId(startCourseId);
|
|
|
|
|
courseNameList.setCreateTime(new java.util.Date());
|
|
|
|
|
courseNameList.setUserId(stu.getUserId());
|
|
|
|
|
|
|
|
|
|
courseNameLists.add(courseNameList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
courseNameListMapper.addList(courseNameLists);
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量导入
|
|
|
|
|
* @param file 导入文件
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Integer batchImport(MultipartFile file,String startCourseId) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
List<TchStartCourseNameList> startCourseNameLists=new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
//获取数据
|
|
|
|
|
List<List<Object>> listByExcel = ImportExcelUtil.getListByExcel(file.getInputStream(), file.getOriginalFilename());
|
|
|
|
|
//封装数据
|
|
|
|
|
for (int i = 0; i < listByExcel.size(); i++) {
|
|
|
|
|
List<Object> list = listByExcel.get(i);
|
|
|
|
|
if (list.get(0) == "" || ("序号").equals(list.get(0))) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//判断该学是否在学生列表里
|
|
|
|
|
StuUser stuUser = stuUserMapper.selectByPrimaryKey(String.valueOf(list.get(0)));
|
|
|
|
|
if(stuUser==null){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//判断该学生是否已单独添加到开课名单
|
|
|
|
|
TchStartCourseNameListExample courseNameListExample=new TchStartCourseNameListExample();
|
|
|
|
|
courseNameListExample.createCriteria().andUserIdEqualTo(String.valueOf(list.get(0)));
|
|
|
|
|
|
|
|
|
|
List<TchStartCourseNameList> tchStartCourseNameLists = courseNameListMapper.selectByExample(courseNameListExample);
|
|
|
|
|
if(!tchStartCourseNameLists.isEmpty()){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TchStartCourseNameList tchStartCourseNameList=new TchStartCourseNameList();
|
|
|
|
|
tchStartCourseNameList.setId(UUID.randomUUID().toString());
|
|
|
|
|
tchStartCourseNameList.setUserId(String.valueOf(list.get(0)));
|
|
|
|
|
tchStartCourseNameList.setName(String.valueOf(list.get(1)));
|
|
|
|
|
tchStartCourseNameList.setStudentId(String.valueOf(list.get(2)));
|
|
|
|
|
tchStartCourseNameList.setClassName(String.valueOf(list.get(3)));
|
|
|
|
|
tchStartCourseNameList.setMajor(String.valueOf(list.get(4)));
|
|
|
|
|
tchStartCourseNameList.setStartCourseId(startCourseId);
|
|
|
|
|
tchStartCourseNameList.setUpdateTime(new java.util.Date());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
startCourseNameLists.add(tchStartCourseNameList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return courseNameListMapper.addList(startCourseNameLists);
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}finally {
|
|
|
|
|
try {
|
|
|
|
|
file.getInputStream().close();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|