forked from liweijie/education
1、选修课选择教室、教员等用下拉选择,
2、绑定教材落库
This commit is contained in:
+3
@@ -35,6 +35,9 @@ public class ElectiveCourseSaveDTO {
|
||||
/** 教室编号 */
|
||||
private String jsbh;
|
||||
|
||||
/** 教材名称(按名称匹配教材信息,写入课程教材关联) */
|
||||
private String jcmc;
|
||||
|
||||
/** 计划人数 */
|
||||
private Integer rs;
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.roomroot.jwgl.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.roomroot.jwgl.entity.KCJC;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 课程教材 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface KCJCMapper extends BaseMapper<KCJC> {
|
||||
}
|
||||
+43
@@ -10,9 +10,11 @@ import com.roomroot.common.utils.poi.ExcelUtil;
|
||||
import com.roomroot.jwgl.dto.jys.ElectiveCourseImportDTO;
|
||||
import com.roomroot.jwgl.dto.jys.ElectiveCourseQuery;
|
||||
import com.roomroot.jwgl.dto.jys.ElectiveCourseSaveDTO;
|
||||
import com.roomroot.jwgl.entity.JCXX;
|
||||
import com.roomroot.jwgl.entity.JSB;
|
||||
import com.roomroot.jwgl.entity.JYB;
|
||||
import com.roomroot.jwgl.entity.KB;
|
||||
import com.roomroot.jwgl.entity.KCJC;
|
||||
import com.roomroot.jwgl.entity.XYDB;
|
||||
import com.roomroot.jwgl.entity.XYDNDXQJBXXB;
|
||||
import com.roomroot.jwgl.entity.XYDQB;
|
||||
@@ -23,7 +25,9 @@ import com.roomroot.jwgl.mapper.ClassSemesterMapper;
|
||||
import com.roomroot.jwgl.mapper.ElectiveCourseMapper;
|
||||
import com.roomroot.jwgl.mapper.JYBMapper;
|
||||
import com.roomroot.jwgl.mapper.KBMapper;
|
||||
import com.roomroot.jwgl.mapper.KCJCMapper;
|
||||
import com.roomroot.jwgl.mapper.StudentTeamTaskMapper;
|
||||
import com.roomroot.jwgl.mapper.TeachingMaterialMapper;
|
||||
import com.roomroot.jwgl.mapper.XYDBMapper;
|
||||
import com.roomroot.jwgl.mapper.XYDQBMapper;
|
||||
import com.roomroot.jwgl.mapper.ZYBMapper;
|
||||
@@ -93,6 +97,10 @@ public class ElectiveCourseServiceImpl implements ElectiveCourseService {
|
||||
private ZYBMapper zybMapper;
|
||||
@Resource
|
||||
private ClassSemesterMapper classSemesterMapper;
|
||||
@Resource
|
||||
private KCJCMapper kcjcMapper;
|
||||
@Resource
|
||||
private TeachingMaterialMapper teachingMaterialMapper;
|
||||
|
||||
@Resource
|
||||
private TeamCodeUtil teamCodeUtil;
|
||||
@@ -115,6 +123,8 @@ public class ElectiveCourseServiceImpl implements ElectiveCourseService {
|
||||
throw new ServiceException("选修课信息不能为空", BAD_REQUEST);
|
||||
}
|
||||
KB course = requireCourse(dto.getKbh());
|
||||
// 先校验教材存在性,避免先建班/学期后失败回滚留下副作用
|
||||
linkCourseTextbook(course.getKbh(), dto.getJcmc());
|
||||
String xydbh = resolveTeamId(dto.getXydbh(), dto.getXxbmc(), dto.getNj(), true, dto.getRs());
|
||||
XYDRWB task = new XYDRWB();
|
||||
task.setBh(UuidUtil.getOriginalUUID());
|
||||
@@ -259,6 +269,11 @@ public class ElectiveCourseServiceImpl implements ElectiveCourseService {
|
||||
}
|
||||
jsbh = room.getJsbh();
|
||||
}
|
||||
try {
|
||||
linkCourseTextbook(course.getKbh(), row.getJcmc());
|
||||
} catch (ServiceException e) {
|
||||
throw new ServiceException("第" + line + "行" + e.getMessage(), BAD_REQUEST);
|
||||
}
|
||||
String xydbh = resolveTeamId(null, row.getXxbmc().trim(), row.getKxbcnj(), true, row.getJhrs());
|
||||
XYDRWB task = new XYDRWB();
|
||||
task.setBh(UuidUtil.getOriginalUUID());
|
||||
@@ -656,6 +671,34 @@ public class ElectiveCourseServiceImpl implements ElectiveCourseService {
|
||||
return course;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按教材名称把教材挂到课程(课程教材表)。教材按「名称」精确匹配,
|
||||
* 同一课程同一教材的关联已存在则跳过,不覆盖课程已有教材。
|
||||
*/
|
||||
private void linkCourseTextbook(String kbh, String jcmc) {
|
||||
if (StringUtils.isEmpty(jcmc) || StringUtils.isEmpty(kbh)) {
|
||||
return;
|
||||
}
|
||||
JCXX material = teachingMaterialMapper.selectOne(new LambdaQueryWrapper<JCXX>()
|
||||
.eq(JCXX::getMc, jcmc.trim())
|
||||
.last("LIMIT 1"));
|
||||
if (material == null) {
|
||||
throw new ServiceException("教材不存在:" + jcmc, NOT_FOUND);
|
||||
}
|
||||
Long exists = kcjcMapper.selectCount(new LambdaQueryWrapper<KCJC>()
|
||||
.eq(KCJC::getKbh, kbh)
|
||||
.eq(KCJC::getJcbh, material.getBh()));
|
||||
if (exists != null && exists > 0) {
|
||||
return;
|
||||
}
|
||||
KCJC link = new KCJC();
|
||||
link.setBh(UuidUtil.getOriginalUUID());
|
||||
link.setKbh(kbh);
|
||||
link.setJcbh(material.getBh());
|
||||
link.setTy(0);
|
||||
kcjcMapper.insert(link);
|
||||
}
|
||||
|
||||
private void updateTeamDates(String xydbh, LocalDateTime start, LocalDateTime end) {
|
||||
if (start == null && end == null) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user