导入导出 模版下载 bug修复
This commit is contained in:
+102
@@ -0,0 +1,102 @@
|
||||
package com.roomroot.web.controller.jwgl;
|
||||
|
||||
import com.roomroot.common.exception.ServiceException;
|
||||
import com.roomroot.common.utils.file.FileUtils;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* 导入模版下载。模版文件位于 classpath:file/
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/download")
|
||||
public class DownloadController {
|
||||
|
||||
private static final String TEMPLATE_DIR = "file/";
|
||||
|
||||
/**
|
||||
* 人才培养方案课程数据文件模板
|
||||
*/
|
||||
@GetMapping("/training-program")
|
||||
public void downloadTrainingProgram(HttpServletResponse response) throws IOException {
|
||||
downloadTemplate(response, "人才培养方案课程数据文件模板.xls");
|
||||
}
|
||||
|
||||
/**
|
||||
* 学员队模板
|
||||
*/
|
||||
@GetMapping("/student-team")
|
||||
public void downloadStudentTeam(HttpServletResponse response) throws IOException {
|
||||
downloadTemplate(response, "学员队模板.xls");
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入教学日志模板
|
||||
*/
|
||||
@GetMapping("/teaching-log")
|
||||
public void downloadTeachingLog(HttpServletResponse response) throws IOException {
|
||||
downloadTemplate(response, "导入教学日志模板.xls");
|
||||
}
|
||||
|
||||
/**
|
||||
* 教学场地管理模板
|
||||
*/
|
||||
@GetMapping("/classroom")
|
||||
public void downloadClassroom(HttpServletResponse response) throws IOException {
|
||||
downloadTemplate(response, "教学场地管理模板.xls");
|
||||
}
|
||||
|
||||
/**
|
||||
* 教材管理模板
|
||||
*/
|
||||
@GetMapping("/teaching-material")
|
||||
public void downloadTeachingMaterial(HttpServletResponse response) throws IOException {
|
||||
downloadTemplate(response, "教材管理.xls");
|
||||
}
|
||||
|
||||
/**
|
||||
* 教研室模板
|
||||
*/
|
||||
@GetMapping("/jys")
|
||||
public void downloadJys(HttpServletResponse response) throws IOException {
|
||||
downloadTemplate(response, "教研室模板.xls");
|
||||
}
|
||||
|
||||
/**
|
||||
* 联教连训管理模板
|
||||
*/
|
||||
@GetMapping("/joint-training")
|
||||
public void downloadJointTraining(HttpServletResponse response) throws IOException {
|
||||
downloadTemplate(response, "联教连训管理.xls");
|
||||
}
|
||||
|
||||
/**
|
||||
* 课程课目数据文件模板
|
||||
*/
|
||||
@GetMapping("/course-subject")
|
||||
public void downloadCourseSubject(HttpServletResponse response) throws IOException {
|
||||
downloadTemplate(response, "课程课目数据文件模板.xls");
|
||||
}
|
||||
|
||||
private void downloadTemplate(HttpServletResponse response, String fileName) throws IOException {
|
||||
ClassPathResource resource = new ClassPathResource(TEMPLATE_DIR + fileName);
|
||||
if (!resource.exists()) {
|
||||
throw new ServiceException("模板文件不存在:" + fileName);
|
||||
}
|
||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||
FileUtils.setAttachmentResponseHeader(response, fileName);
|
||||
try (InputStream is = resource.getInputStream(); OutputStream os = response.getOutputStream()) {
|
||||
IOUtils.copy(is, os);
|
||||
os.flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
+77
@@ -2,6 +2,7 @@ package com.roomroot.web.controller.jwgl;
|
||||
|
||||
import com.roomroot.jwgl.dto.ks.HourStatisticsQuery;
|
||||
import com.roomroot.jwgl.entity.KSFBZ;
|
||||
import com.roomroot.jwgl.entity.KSBZXM;
|
||||
import com.roomroot.jwgl.entity.KSXSFA;
|
||||
import com.roomroot.jwgl.service.KJService;
|
||||
import com.roomroot.jwgl.service.KSService;
|
||||
@@ -17,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
@@ -259,4 +261,79 @@ public class KSController {
|
||||
ksService.exportFeeStatistics(cond, response);
|
||||
}
|
||||
|
||||
// ======================== 联教联训管理(课时补助项目) ========================
|
||||
|
||||
/**
|
||||
* 新增联教联训(课时补助项目)。
|
||||
* <p>对应表:课时补助项目。编号为空时由服务端生成 UUID。</p>
|
||||
*/
|
||||
@PostMapping("/yjlx/add")
|
||||
public Result<Void> addSubsidyProject(@RequestBody KSBZXM entity) {
|
||||
logService.addSubsidyProject(entity);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除联教联训(课时补助项目)。
|
||||
*
|
||||
* @param bh 编号
|
||||
*/
|
||||
@PostMapping("/yjlx/delete")
|
||||
public Result<Void> deleteSubsidyProject(@RequestParam("bh") String bh) {
|
||||
logService.deleteSubsidyProject(bh);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新联教联训(课时补助项目)。
|
||||
*/
|
||||
@PostMapping("/yjlx/update")
|
||||
public Result<Void> updateSubsidyProject(@RequestBody KSBZXM entity) {
|
||||
logService.updateSubsidyProject(entity);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据编号查询联教联训详情。
|
||||
*/
|
||||
@GetMapping("/yjlx/get")
|
||||
public Result<KSBZXM> getSubsidyProject(@RequestParam("bh") String bh) {
|
||||
return Result.success(logService.getSubsidyProjectById(bh));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询联教联训列表(支持按名称模糊筛选)。
|
||||
*/
|
||||
@GetMapping("/yjlx/list")
|
||||
public Result<PageResult<KSBZXM>> listSubsidyProject(
|
||||
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(defaultValue = "20") Integer pageSize,
|
||||
@RequestParam(required = false) String mc) {
|
||||
KSBZXM cond = new KSBZXM();
|
||||
cond.setMc(mc);
|
||||
return Result.success(logService.pageSubsidyProject(new PageQuery(pageNum, pageSize), cond));
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 Excel(.xls/.xlsx) 导入联教联训数据。
|
||||
* <p>模板列:序号, 补助项目名称, 性质, 依据, 开始日期, 结束日期, 项目说明,
|
||||
* 项目备注, 教研室名称, 补助教员姓名, 补助课时量, 课时量备注</p>
|
||||
*
|
||||
* @param file 上传的联教连训管理.xls 文件
|
||||
* @return 导入条数
|
||||
*/
|
||||
@PostMapping("/yjlx/import")
|
||||
public Result<Integer> importSubsidyProject(@RequestParam("file") MultipartFile file) throws Exception {
|
||||
int count = logService.importSubsidyProject(file);
|
||||
return Result.success("导入成功,共" + count + "条", count);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出联教联训数据到 Excel(.xlsx)。
|
||||
*/
|
||||
@GetMapping("/yjlx/export")
|
||||
public void exportSubsidyProject(HttpServletResponse response) throws Exception {
|
||||
logService.exportSubsidyProject(response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user