班次编号生成,改为XYD+年度+补零序号

This commit is contained in:
2026-09-21 16:36:09 +08:00
parent 035c01e90b
commit 1482bfd31c
9 changed files with 112 additions and 18 deletions
@@ -31,6 +31,7 @@ import com.roomroot.jwgl.service.ElectiveCourseService;
import com.roomroot.jwgl.unit.PageQuery;
import com.roomroot.jwgl.unit.PageResult;
import com.roomroot.jwgl.utils.SemesterCodeUtil;
import com.roomroot.jwgl.utils.TeamCodeUtil;
import com.roomroot.jwgl.utils.UuidUtil;
import com.roomroot.jwgl.vo.jys.ElectiveCourseStudentVO;
import com.roomroot.jwgl.vo.jys.ElectiveCourseVO;
@@ -93,6 +94,9 @@ public class ElectiveCourseServiceImpl implements ElectiveCourseService {
@Resource
private ClassSemesterMapper classSemesterMapper;
@Resource
private TeamCodeUtil teamCodeUtil;
@Override
public PageResult<ElectiveCourseVO> pageList(PageQuery query, ElectiveCourseQuery cond) {
ElectiveCourseQuery filter = normalizeQuery(cond);
@@ -379,13 +383,13 @@ public class ElectiveCourseServiceImpl implements ElectiveCourseService {
throw new ServiceException("选修班不存在:" + xxbmc, NOT_FOUND);
}
XYDB created = new XYDB();
created.setXydbh(UuidUtil.getOriginalUUID());
created.setXydmc(xxbmc.trim());
created.setNj(blankToNull(nj));
created.setXydlx(CLASS_TYPE_ELECTIVE);
created.setXslx(0);
created.setXydrs(rs != null ? rs : 0);
fillTeamRequiredDefaults(created);
created.setXydbh(teamCodeUtil.nextXydbhForNj(created.getNj()));
xydbMapper.insert(created);
return created.getXydbh();
}
@@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.roomroot.jwgl.dto.elective.AddClassDTO;
import com.roomroot.jwgl.entity.*;
import com.roomroot.jwgl.mapper.*;
import com.roomroot.jwgl.utils.TeamCodeUtil;
import com.roomroot.jwgl.vo.elective.*;
import com.roomroot.jwgl.mapper.*;
import com.roomroot.jwgl.service.BuildService;
import com.roomroot.jwgl.service.ElectiveService;
import com.roomroot.jwgl.unit.BusinessException;
@@ -14,7 +14,6 @@ import com.roomroot.jwgl.unit.PageQuery;
import com.roomroot.jwgl.unit.PageResult;
import com.roomroot.jwgl.utils.SemesterCodeUtil;
import com.roomroot.jwgl.utils.UuidUtil;
import com.roomroot.jwgl.vo.elective.*;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -56,10 +55,18 @@ public class ElectiveServiceImpl implements ElectiveService {
@Resource
private ClassSemesterMapper classSemesterMapper;
@Resource
private TeamCodeUtil teamCodeUtil;
@Override
@Transactional
public void add(AddClassDTO dto) {
XYDB entity = dto.getClazz();
if (entity.getXydbh() == null || entity.getXydbh().isEmpty()) {
entity.setXydbh(teamCodeUtil.nextXydbhForNj(entity.getNj()));
} else if (xydbMapper.selectById(entity.getXydbh()) != null) {
throw new BusinessException("学员队编号已存在:" + entity.getXydbh());
}
xydbMapper.insert(entity);
// 同时写入学员队期表(学号规则、注册设置)
XYDQB period = dto.getPeriod();
@@ -29,6 +29,7 @@ import com.roomroot.jwgl.unit.PageQuery;
import com.roomroot.jwgl.unit.PageResult;
import com.roomroot.jwgl.utils.ExcelParseUtil;
import com.roomroot.jwgl.utils.JwglRoleHelper;
import com.roomroot.jwgl.utils.TeamCodeUtil;
import com.roomroot.jwgl.utils.UuidUtil;
import com.roomroot.jwgl.vo.StudentListEchoVO;
import jakarta.servlet.http.HttpServletResponse;
@@ -90,6 +91,9 @@ public class StudentRecordsServiceImpl implements StudentRecordsService {
@Resource
private JwglRoleHelper jwglRoleHelper;
@Resource
private TeamCodeUtil teamCodeUtil;
@Override
@Transactional
public void add(XYXX xyxx) {
@@ -704,7 +708,9 @@ public class StudentRecordsServiceImpl implements StudentRecordsService {
@Transactional
public void addTeam(XYDB entity) {
if (entity.getXydbh() == null || entity.getXydbh().isEmpty()) {
throw new RuntimeException("学员队编号不能为空");
entity.setXydbh(teamCodeUtil.nextXydbhForNj(entity.getNj()));
} else if (xydbMapper.selectById(entity.getXydbh()) != null) {
throw new RuntimeException("学员队编号已存在:" + entity.getXydbh());
}
xydbMapper.insert(entity);
}
@@ -748,10 +754,18 @@ public class StudentRecordsServiceImpl implements StudentRecordsService {
if (list.isEmpty()) {
throw new RuntimeException("Excel中无有效数据");
}
int count = 0;
for (XYDB entity : list) {
if (entity.getXydbh() == null || entity.getXydbh().isEmpty()) {
entity.setXydbh(teamCodeUtil.nextXydbhForNj(entity.getNj()));
} else if (xydbMapper.selectById(entity.getXydbh()) != null) {
// 编号已存在的跳过,避免整批导入因主键冲突中断
continue;
}
xydbMapper.insert(entity);
count++;
}
return list.size();
return count;
}
@Override