课表申请功能重写 bug修复

This commit is contained in:
liumengyu
2026-08-25 18:47:22 +08:00
parent aa4145fd33
commit a30b963dea
58 changed files with 1203 additions and 1632 deletions
@@ -5,10 +5,13 @@ import com.roomroot.jwgl.dto.courserunning.SemesterImportDTO;
import com.roomroot.jwgl.dto.courserunning.SingleCourseImportDTO;
import com.roomroot.jwgl.dto.departmentpersonnel.DepartmentPersonnelCreateDTO;
import com.roomroot.jwgl.entity.JXSSJH;
import com.roomroot.jwgl.entity.JYB;
import com.roomroot.jwgl.entity.JYSB;
import com.roomroot.jwgl.entity.KSBZXM;
import com.roomroot.jwgl.entity.XYDB;
import com.roomroot.jwgl.entity.XYXX;
import com.roomroot.jwgl.entity.ZYB;
import com.roomroot.jwgl.entity.ZYJXJHB;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
@@ -386,6 +389,144 @@ public class ExcelParseUtil {
return result;
}
/**
* 解析教员管理导入 Excel 文件(支持 .xls / .xlsx)。
* <p>表头顺序:</p>
* 教员编号, 教员姓名, 教研室代号, 职称, 专业技术职务等级, 教员类别,
* 性别, 手机号, 身份证号, 备注, 序号, 虚实类型
*
* @return 教员实体列表(离职状态由业务层默认填充)
* @throws Exception 解析异常
*/
public static List<JYB> parseJYBExcel(InputStream inputStream, String fileName) throws Exception {
List<JYB> result = new ArrayList<>();
Workbook workbook = createWorkbook(inputStream, fileName);
try {
Sheet sheet = workbook.getSheetAt(0);
int lastRowNum = sheet.getLastRowNum();
for (int rowNum = 1; rowNum <= lastRowNum; rowNum++) {
Row row = sheet.getRow(rowNum);
if (row == null) {
continue;
}
JYB entity = new JYB();
entity.setJybh(getCellStringValue(row.getCell(0)));
entity.setJyxm(getCellStringValue(row.getCell(1)));
entity.setJysdh(getCellStringValue(row.getCell(2)));
entity.setZc(getCellStringValue(row.getCell(3)));
entity.setZyjszwdj(getCellStringValue(row.getCell(4)));
entity.setJylb(getCellStringValue(row.getCell(5)));
entity.setXb(parseIntCell(row.getCell(6)));
entity.setSjh(getCellStringValue(row.getCell(7)));
entity.setSfzh(getCellStringValue(row.getCell(8)));
entity.setBz(getCellStringValue(row.getCell(9)));
entity.setXh(getCellStringValue(row.getCell(10)));
entity.setXslx(parseIntCell(row.getCell(11)));
// 至少要有姓名才视为有效行
if (entity.getJyxm() != null && !entity.getJyxm().isEmpty()) {
result.add(entity);
}
}
} finally {
workbook.close();
}
return result;
}
/**
* 解析培养方案(专业表)导入 Excel 文件(支持 .xls / .xlsx)。
* <p>表头顺序:</p>
* 专业代号, 专业名称, 专业代码, 专业版本, 培训类型, 培训层次, 学年制, 学期数,
* 专业方向, 专业备注, 学员类别, 简称, 培训类型2
*
* @return 专业实体列表
* @throws Exception 解析异常
*/
public static List<ZYB> parseZYBExcel(InputStream inputStream, String fileName) throws Exception {
List<ZYB> result = new ArrayList<>();
Workbook workbook = createWorkbook(inputStream, fileName);
try {
Sheet sheet = workbook.getSheetAt(0);
int lastRowNum = sheet.getLastRowNum();
for (int rowNum = 1; rowNum <= lastRowNum; rowNum++) {
Row row = sheet.getRow(rowNum);
if (row == null) {
continue;
}
ZYB entity = new ZYB();
entity.setZydh(getCellStringValue(row.getCell(0)));
entity.setZymc(getCellStringValue(row.getCell(1)));
entity.setZydm(getCellStringValue(row.getCell(2)));
entity.setZybb(getCellStringValue(row.getCell(3)));
entity.setPxlx(getCellStringValue(row.getCell(4)));
entity.setPxcc(getCellStringValue(row.getCell(5)));
entity.setXnz(getCellStringValue(row.getCell(6)));
entity.setXqs(parseIntCell(row.getCell(7)));
entity.setZyfx(getCellStringValue(row.getCell(8)));
entity.setZybz(getCellStringValue(row.getCell(9)));
entity.setXylb(getCellStringValue(row.getCell(10)));
entity.setJc(getCellStringValue(row.getCell(11)));
entity.setPxlx2(getCellStringValue(row.getCell(12)));
// 至少要有专业代号或名称才视为有效行
if (entity.getZydh() != null && !entity.getZydh().isEmpty()
|| entity.getZymc() != null && !entity.getZymc().isEmpty()) {
result.add(entity);
}
}
} finally {
workbook.close();
}
return result;
}
/**
* 解析专业教学计划表导入 Excel 文件(支持 .xls / .xlsx)。
* <p>表头顺序:</p>
* 专业代号, 课编号, 学期第次, 课类型, 学时, 学分, 周课时, 课程定位,
* 模块, 成绩分制, 理论学时, 实践学时, 考试课时, 教研室代号, 简称
*
* @return 专业教学计划实体列表
* @throws Exception 解析异常
*/
public static List<ZYJXJHB> parseZYJXJHBExcel(InputStream inputStream, String fileName) throws Exception {
List<ZYJXJHB> result = new ArrayList<>();
Workbook workbook = createWorkbook(inputStream, fileName);
try {
Sheet sheet = workbook.getSheetAt(0);
int lastRowNum = sheet.getLastRowNum();
for (int rowNum = 1; rowNum <= lastRowNum; rowNum++) {
Row row = sheet.getRow(rowNum);
if (row == null) {
continue;
}
ZYJXJHB entity = new ZYJXJHB();
entity.setZydh(getCellStringValue(row.getCell(0)));
entity.setKbh(getCellStringValue(row.getCell(1)));
entity.setXqdc(parseIntCell(row.getCell(2)));
entity.setKlx(getCellStringValue(row.getCell(3)));
entity.setXs(parseIntCell(row.getCell(4)));
entity.setXf(parseFloatCell(row.getCell(5)));
entity.setZks(parseIntCell(row.getCell(6)));
entity.setKcdw(getCellStringValue(row.getCell(7)));
entity.setMk(getCellStringValue(row.getCell(8)));
entity.setCjfz(getCellStringValue(row.getCell(9)));
entity.setLlxs(parseIntCell(row.getCell(10)));
entity.setSjxs(parseIntCell(row.getCell(11)));
entity.setKsks(parseIntCell(row.getCell(12)));
entity.setJysdh(getCellStringValue(row.getCell(13)));
entity.setJc(getCellStringValue(row.getCell(14)));
// 至少要有专业代号或课编号才视为有效行
if (entity.getZydh() != null && !entity.getZydh().isEmpty()
|| entity.getKbh() != null && !entity.getKbh().isEmpty()) {
result.add(entity);
}
}
} finally {
workbook.close();
}
return result;
}
private static Workbook createWorkbook(InputStream inputStream, String fileName) throws Exception {
String name = fileName == null ? "" : fileName.toLowerCase();
if (!name.endsWith(".xlsx") && !name.endsWith(".xls")) {
@@ -426,6 +567,21 @@ public class ExcelParseUtil {
}
}
/**
* 解析单元格浮点数值。
*/
private static Float parseFloatCell(Cell cell) {
String value = getCellStringValue(cell);
if (value == null || value.isEmpty()) {
return null;
}
try {
return Float.valueOf(value);
} catch (NumberFormatException e) {
return null;
}
}
private static String getCellStringValue(Cell cell) {
if (cell == null) {
return null;
@@ -37,4 +37,42 @@ public class UuidUtil {
public static String getUuidWithPrefix(String prefix) {
return prefix + getUUID();
}
/**
* 将 32 位十六进制或 36 位带横线 UUID 转为 16 字节,供达梦 VARBINARY 主键写入。
*/
public static byte[] toBytes(String guid) {
if (guid == null) {
return null;
}
String hex = guid.trim().replace("-", "");
if (hex.length() < 32) {
throw new IllegalArgumentException("GUID hex length must be 32, actual=" + hex.length());
}
hex = hex.substring(0, 32);
byte[] out = new byte[16];
for (int i = 0; i < 16; i++) {
out[i] = (byte) Integer.parseInt(hex.substring(i * 2, i * 2 + 2), 16);
}
return out;
}
/**
* 将 VARBINARY(16) 转为带横线的 36 位 UUID,与 CHAR(36) 外键存储格式一致。
*/
public static String fromBytes(byte[] bytes) {
if (bytes == null || bytes.length == 0) {
return null;
}
StringBuilder hex = new StringBuilder(bytes.length * 2);
for (byte value : bytes) {
hex.append(String.format("%02x", value));
}
String h = hex.toString();
if (h.length() < 32) {
return h;
}
return h.substring(0, 8) + "-" + h.substring(8, 12) + "-" + h.substring(12, 16)
+ "-" + h.substring(16, 20) + "-" + h.substring(20, 32);
}
}