导入导出 模版下载 bug修复

This commit is contained in:
liumengyu
2026-08-21 12:08:52 +08:00
parent 2a5bf443fe
commit 179b12e3bf
65 changed files with 389 additions and 964 deletions
@@ -104,8 +104,11 @@ public interface LogService {
void addSubsidyProject(KSBZXM entity);
void updateSubsidyProject(KSBZXM entity);
void deleteSubsidyProject(String bh);
KSBZXM getSubsidyProjectById(String bh);
PageResult<KSBZXM> pageSubsidyProject(PageQuery query, KSBZXM cond);
int importSubsidyProject(org.springframework.web.multipart.MultipartFile file) throws Exception;
void exportSubsidyProject(jakarta.servlet.http.HttpServletResponse response) throws Exception;
// ==================== 教学日志课时补助审批表(汇总) ====================
@@ -234,7 +234,7 @@ public class DisciplineServiceImpl implements DisciplineService {
assertMaxLength(entity.getJc(), 50, "简称");
assertMaxLength(entity.getJclb(), 50, "节次类别");
assertMaxLength(entity.getXtms(), 50, "系统模式");
assertMaxLength(entity.getJsonzd(), 4000, "json字典");
assertMaxLength(entity.getJsonzd(), 4000, "JSONZD");
assertMaxLength(entity.getGfmc(), 250, "规范名称");
assertMaxLength(entity.getPymb(), 500, "培养目标");
}
@@ -159,7 +159,7 @@ public class KBServiceImpl implements KBService {
assertMaxLength(entity.getBb(), 50, "版本");
assertMaxLength(entity.getKczcfs(), 50, "课程支持方式");
assertMaxLength(entity.getKcjsfs(), 50, "课程建设方式");
assertMaxLength(entity.getJsonzd(), 4000, "json字典");
assertMaxLength(entity.getJsonzd(), 4000, "JSONZD");
assertMaxLength(entity.getKhfs(), 50, "考核方式");
assertMaxLength(entity.getMj(), 50, "密级");
assertMaxLength(entity.getPxqk(), 50, "评选情况");
@@ -545,12 +545,15 @@ public class LogServiceImpl implements LogService {
@Override
@Transactional
public void addSubsidyProject(KSBZXM entity) {
entity.setCjsj(LocalDateTime.now());
entity.setXgsj(LocalDateTime.now());
ksbzxmMapper.insert(entity);
}
@Override
@Transactional
public void updateSubsidyProject(KSBZXM entity) {
entity.setXgsj(LocalDateTime.now());
ksbzxmMapper.updateById(entity);
}
@@ -568,6 +571,79 @@ public class LogServiceImpl implements LogService {
return new PageResult<>(result.getRecords(), result.getTotal(), query.getPageNum(), query.getPageSize());
}
@Override
@Transactional
public void deleteSubsidyProject(String bh) {
ksbzxmMapper.deleteById(bh);
}
@Override
@Transactional(rollbackFor = Exception.class)
public int importSubsidyProject(org.springframework.web.multipart.MultipartFile file) throws Exception {
if (file == null || file.isEmpty()) {
throw new RuntimeException("导入文件不能为空");
}
List<KSBZXM> list = com.roomroot.jwgl.utils.ExcelParseUtil.parseKSBZXMExcel(
file.getInputStream(), file.getOriginalFilename());
if (list.isEmpty()) {
throw new RuntimeException("Excel中无有效数据");
}
LocalDateTime now = LocalDateTime.now();
for (KSBZXM entity : list) {
if (entity.getBh() == null || entity.getBh().isEmpty()) {
entity.setBh(com.roomroot.jwgl.utils.UuidUtil.getUUID());
}
if (entity.getXmlx() == null || entity.getXmlx().isEmpty()) {
entity.setXmlx("联教联训");
}
entity.setCjsj(now);
entity.setXgsj(now);
ksbzxmMapper.insert(entity);
}
return list.size();
}
@Override
public void exportSubsidyProject(jakarta.servlet.http.HttpServletResponse response) throws Exception {
List<KSBZXM> list = ksbzxmMapper.selectList(
new LambdaQueryWrapper<KSBZXM>().orderByDesc(KSBZXM::getCjsj));
String[] headers = {"编号", "名称", "性质", "依据", "开始日期", "结束日期", "天数",
"基本课时量", "课时类型", "说明", "备注", "项目类型"};
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));
try (org.apache.poi.xssf.usermodel.XSSFWorkbook workbook = new org.apache.poi.xssf.usermodel.XSSFWorkbook()) {
org.apache.poi.ss.usermodel.Sheet sheet = workbook.createSheet("联教联训");
org.apache.poi.ss.usermodel.Row headerRow = sheet.createRow(0);
for (int i = 0; i < headers.length; i++) {
headerRow.createCell(i).setCellValue(headers[i]);
}
int rowIdx = 1;
for (KSBZXM e : list) {
org.apache.poi.ss.usermodel.Row row = sheet.createRow(rowIdx++);
row.createCell(0).setCellValue(e.getBh() == null ? "" : e.getBh());
row.createCell(1).setCellValue(e.getMc() == null ? "" : e.getMc());
row.createCell(2).setCellValue(e.getXz() == null ? "" : e.getXz());
row.createCell(3).setCellValue(e.getYj() == null ? "" : e.getYj());
row.createCell(4).setCellValue(e.getKsrq() == null ? "" : e.getKsrq().toString());
row.createCell(5).setCellValue(e.getJsrq() == null ? "" : e.getJsrq().toString());
row.createCell(6).setCellValue(e.getTs() == null ? "" : String.valueOf(e.getTs()));
row.createCell(7).setCellValue(e.getJbksl() == null ? "" : String.valueOf(e.getJbksl()));
row.createCell(8).setCellValue(e.getKslx() == null ? "" : e.getKslx());
row.createCell(9).setCellValue(e.getSm() == null ? "" : e.getSm());
row.createCell(10).setCellValue(e.getBz() == null ? "" : e.getBz());
row.createCell(11).setCellValue(e.getXmlx() == null ? "" : e.getXmlx());
}
for (int i = 0; i < headers.length; i++) {
sheet.autoSizeColumn(i);
}
workbook.write(response.getOutputStream());
response.getOutputStream().flush();
}
}
// ==================== 教学日志课时补助审批表(汇总) ====================
@Override