人才培养方案

This commit is contained in:
2026-09-20 11:59:04 +08:00
parent e4f4720113
commit 9f0c0ac873
9 changed files with 280 additions and 48 deletions
@@ -63,6 +63,9 @@ public interface TrainingProgramService {
/** 导出培养方案(专业)到 Excel(.xlsx) */
void exportZYBExcel(jakarta.servlet.http.HttpServletResponse response) throws Exception;
/** 下载培养方案目录导入模板(仅表头) */
void exportZYBTemplate(jakarta.servlet.http.HttpServletResponse response) throws Exception;
/**
* 查询未停用的教学管理机构下拉选项。
*/
@@ -104,6 +104,7 @@ public class DisciplineServiceImpl implements DisciplineService {
}
assertMajorCodeUnique(entity.getZydh());
fillMajorDefaults(entity);
com.roomroot.jwgl.handler.ZybInsertFillHandler.fillNotNullColumns(entity);
zybMapper.insert(entity);
}
@@ -284,6 +285,7 @@ public class DisciplineServiceImpl implements DisciplineService {
if (StringUtils.isEmpty(entity.getGfmc())) {
entity.setGfmc(entity.getZymc());
}
com.roomroot.jwgl.handler.ZybInsertFillHandler.fillNotNullColumns(entity);
}
/**
@@ -44,6 +44,10 @@ public class TrainingProgramServiceImpl implements TrainingProgramService {
}
entity.setTy(false);
entity.setQysj(LocalDateTime.now());
com.roomroot.jwgl.handler.ZybInsertFillHandler.fillNotNullColumns(entity);
if (findExistingMajor(entity) != null) {
throw new RuntimeException("专业名称已存在,请勿重复新增");
}
zybMapper.insert(entity);
}
@@ -90,24 +94,84 @@ public class TrainingProgramServiceImpl implements TrainingProgramService {
if (list.isEmpty()) {
throw new RuntimeException("Excel中无有效数据");
}
int inserted = 0;
int updated = 0;
int rowNo = 1;
for (ZYB entity : list) {
if (entity.getZydh() == null || entity.getZydh().isEmpty()) {
entity.setZydh(com.roomroot.jwgl.utils.UuidUtil.getUUID());
rowNo++;
if (entity.getZymc() == null || entity.getZymc().trim().isEmpty()) {
throw new RuntimeException("第" + rowNo + "行:专业名称不能为空");
}
if (entity.getTy() == null) {
entity.setZymc(entity.getZymc().trim());
if (entity.getZydh() != null) {
entity.setZydh(entity.getZydh().trim());
if (entity.getZydh().isEmpty()) {
entity.setZydh(null);
}
}
com.roomroot.jwgl.handler.ZybInsertFillHandler.fillNotNullColumns(entity);
ZYB existing = findExistingMajor(entity);
if (existing != null) {
entity.setZydh(existing.getZydh());
if (entity.getZybsh() == null || entity.getZybsh().isEmpty()) {
entity.setZybsh(existing.getZybsh() != null ? existing.getZybsh() : existing.getZydh());
}
entity.setTy(false);
zybMapper.updateById(entity);
updated++;
} else {
if (entity.getZydh() == null || entity.getZydh().isEmpty()) {
entity.setZydh(com.roomroot.jwgl.utils.UuidUtil.getUUID());
}
if (entity.getZybsh() == null || entity.getZybsh().isEmpty()) {
entity.setZybsh(entity.getZydh());
}
entity.setTy(false);
entity.setQysj(LocalDateTime.now());
zybMapper.insert(entity);
inserted++;
}
zybMapper.insert(entity);
}
return list.size();
return inserted + updated;
}
/**
* 按主键或专业名称命中已有记录,避免触发 PK_专业名称表。
*/
private ZYB findExistingMajor(ZYB entity) {
if (entity.getZydh() != null && !entity.getZydh().isEmpty()) {
ZYB byId = zybMapper.selectById(entity.getZydh());
if (byId != null) {
return byId;
}
}
java.util.List<ZYB> sameName = zybMapper.selectList(new LambdaQueryWrapper<ZYB>()
.eq(ZYB::getZymc, entity.getZymc()));
if (sameName == null || sameName.isEmpty()) {
return null;
}
for (ZYB row : sameName) {
boolean fxSame = java.util.Objects.equals(
nullToEmpty(row.getZyfx()), nullToEmpty(entity.getZyfx()));
boolean lxSame = java.util.Objects.equals(
nullToEmpty(row.getPxlx()), nullToEmpty(entity.getPxlx()));
if (fxSame && lxSame) {
return row;
}
}
return sameName.get(0);
}
private static String nullToEmpty(String value) {
return value == null ? "" : value.trim();
}
@Override
public void exportZYBExcel(jakarta.servlet.http.HttpServletResponse response) throws Exception {
java.util.List<ZYB> list = zybMapper.selectList(
new LambdaQueryWrapper<ZYB>().orderByAsc(ZYB::getZydh));
String[] headers = {"专业代号", "专业名称", "专业代码", "专业版本", "培训类型", "培训层次",
"学年制", "学期数", "专业方向", "专业备注", "学员类别", "简称", "培训类型2"};
String[] headers = com.roomroot.jwgl.utils.ExcelParseUtil.TRAINING_PROGRAM_IMPORT_HEADERS;
byte[] bytes = com.roomroot.jwgl.utils.ExcelExportUtil.export("培养方案", headers, list,
ZYB::getZydh, ZYB::getZymc, ZYB::getZydm, ZYB::getZybb, ZYB::getPxlx,
ZYB::getPxcc, ZYB::getXnz, ZYB::getXqs, ZYB::getZyfx, ZYB::getZybz,
@@ -120,6 +184,19 @@ public class TrainingProgramServiceImpl implements TrainingProgramService {
response.getOutputStream().flush();
}
@Override
public void exportZYBTemplate(jakarta.servlet.http.HttpServletResponse response) throws Exception {
String[] headers = com.roomroot.jwgl.utils.ExcelParseUtil.TRAINING_PROGRAM_IMPORT_HEADERS;
byte[] bytes = com.roomroot.jwgl.utils.ExcelExportUtil.export("培养方案", headers,
java.util.Collections.emptyList());
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition",
"attachment; filename=" + java.net.URLEncoder.encode(
"人才培养方案目录模板.xlsx", java.nio.charset.StandardCharsets.UTF_8));
response.getOutputStream().write(bytes);
response.getOutputStream().flush();
}
@Override
public java.util.List<JXGLJG> listTeachingOrganizations() {
java.util.List<JXGLJG> list = jxgljgMapper.selectEnabledOptions();