AI测试反馈的报错调整

This commit is contained in:
2026-09-18 18:12:59 +08:00
parent 68b02ea58e
commit f36b1f4701
16 changed files with 90 additions and 25 deletions
@@ -67,4 +67,11 @@ public interface TeachingPlanService {
* @throws Exception 解析或导入异常
*/
int importFromExcel(MultipartFile file) throws Exception;
/**
* 生成导入模板 Excel(列序与 {@link #importFromExcel} 解析一致)。
*
* @return xlsx 字节
*/
byte[] buildImportTemplate() throws Exception;
}
@@ -11,10 +11,15 @@ import com.roomroot.jwgl.unit.PageResult;
import com.roomroot.jwgl.utils.ExcelParseUtil;
import com.roomroot.jwgl.utils.UuidUtil;
import jakarta.annotation.Resource;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.ByteArrayOutputStream;
import java.util.List;
/**
@@ -104,4 +109,44 @@ public class TeachingPlanServiceImpl implements TeachingPlanService {
}
return list.size();
}
@Override
public byte[] buildImportTemplate() throws Exception {
String[] headers = {
"序号", "年度", "原序号", "日期", "原节次", "节次", "课程名称", "班次",
"责任单位", "授课教员", "教学场地", "教学内容", "教学方法",
"教员备注", "教务备注", "检查结果", "课程表编号"
};
String[] example = {
"1", "2026", "", "2026-03-02 08:00:00", "", "1", "高等数学", "1班",
"基础教研室", "张三", "教学楼A-101", "函数与极限", "讲授",
"", "", "", ""
};
try (Workbook wb = new XSSFWorkbook(); ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
Sheet sheet = wb.createSheet("教学实施计划");
Row header = sheet.createRow(0);
for (int i = 0; i < headers.length; i++) {
header.createCell(i).setCellValue(headers[i]);
sheet.setColumnWidth(i, 14 * 256);
}
Row row = sheet.createRow(1);
for (int i = 0; i < example.length; i++) {
row.createCell(i).setCellValue(example[i]);
}
Sheet help = wb.createSheet("填写说明");
String[] notes = {
"1. 数据从第2行开始填写,第1行表头请勿修改,列顺序固定不可调整。",
"2. 「课程名称」必填,课程名称为空的行将被跳过;其余列可留空。",
"3. 「序号」「年度」「节次」为整数;「日期」支持 yyyy-MM-dd 或 yyyy-MM-dd HH:mm:ss。",
"4. 第2行为示例数据,导入前请删除。",
"5. 标识号、登录编号由系统自动生成,无需填写。"
};
for (int i = 0; i < notes.length; i++) {
help.createRow(i).createCell(0).setCellValue(notes[i]);
}
help.setColumnWidth(0, 100 * 256);
wb.write(bos);
return bos.toByteArray();
}
}
}