|
|
|
@ -1,8 +1,10 @@
|
|
|
|
|
package com.ibeetl.jlw.web;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.ListUtil;
|
|
|
|
|
import cn.jlw.Interceptor.SCoreUser;
|
|
|
|
|
import cn.jlw.util.ToolUtils;
|
|
|
|
|
import cn.jlw.validate.ValidateConfig;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.ibeetl.admin.core.annotation.Function;
|
|
|
|
|
import com.ibeetl.admin.core.entity.CoreUser;
|
|
|
|
|
import com.ibeetl.admin.core.file.FileService;
|
|
|
|
@ -240,6 +242,128 @@ public class TeacherOpenCourseHandsOnController{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
/**
|
|
|
|
|
* 实操列表导出信息
|
|
|
|
|
* @param teacherOpenCourseId 开课ID
|
|
|
|
|
* @param classId 班级ID
|
|
|
|
|
* @param coreUser
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping(MODEL + "/getHandsOnList/export.json")
|
|
|
|
|
public JsonResult<PageQuery> getHandsOnListExport(GetHandsOnListParam param,
|
|
|
|
|
HttpServletRequest request,
|
|
|
|
|
HttpServletResponse response,
|
|
|
|
|
@SCoreUser CoreUser coreUser) {
|
|
|
|
|
if(null == coreUser){
|
|
|
|
|
return JsonResult.failMessage("请登录后再操作");
|
|
|
|
|
}else{
|
|
|
|
|
PageQuery list = teacherOpenCourseHandsOnService.getHandsOnList(param);
|
|
|
|
|
|
|
|
|
|
HSSFWorkbook workbook = null;
|
|
|
|
|
try {
|
|
|
|
|
//表头数据
|
|
|
|
|
String[] header = {
|
|
|
|
|
"项目名称",
|
|
|
|
|
"观看视频平均得分",
|
|
|
|
|
"观看PPT平均得分",
|
|
|
|
|
"理论测评平均得分",
|
|
|
|
|
"实训操作步骤平均得分",
|
|
|
|
|
"报告撰写平均得分"
|
|
|
|
|
};
|
|
|
|
|
String[] headerCode = {
|
|
|
|
|
"handsOnName",
|
|
|
|
|
"videoAvgScore",
|
|
|
|
|
"pptAvgScore",
|
|
|
|
|
"theoryAvgScore",
|
|
|
|
|
"stepAvgScore",
|
|
|
|
|
"reportAvgScore"
|
|
|
|
|
};
|
|
|
|
|
//数据内容
|
|
|
|
|
List<TeacherOpenCourseHandsOnList> hands = list.getList();
|
|
|
|
|
//内容宽度
|
|
|
|
|
List<Map> mapList = JSON.parseArray(JSON.toJSONString(hands), Map.class);
|
|
|
|
|
Map<String, Object> widthMap = mapList.get(0);
|
|
|
|
|
//声明一个工作簿
|
|
|
|
|
workbook = new HSSFWorkbook();
|
|
|
|
|
//生成一个表格,设置表格名称为"Sheet1"
|
|
|
|
|
HSSFSheet sheet = workbook.createSheet("Sheet1");
|
|
|
|
|
//冻结表头
|
|
|
|
|
sheet.createFreezePane(0, 1, 0, 1);
|
|
|
|
|
//设置默认列宽度为5个字节
|
|
|
|
|
sheet.setDefaultColumnWidth(5);
|
|
|
|
|
//创建第一行表头
|
|
|
|
|
HSSFRow headRow = sheet.createRow(0);
|
|
|
|
|
//头部样式
|
|
|
|
|
HSSFCellStyle headerStyle = workbook.createCellStyle();
|
|
|
|
|
//垂直居中
|
|
|
|
|
headerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
|
|
//水平居中
|
|
|
|
|
headerStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
|
//单元格样式
|
|
|
|
|
HSSFCellStyle cellStyle = workbook.createCellStyle();
|
|
|
|
|
//垂直居中
|
|
|
|
|
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
|
|
//水平居左
|
|
|
|
|
cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
|
//自动换行
|
|
|
|
|
cellStyle.setWrapText(true);
|
|
|
|
|
//遍历添加表头
|
|
|
|
|
for (int i = 0; i < header.length; i++) {
|
|
|
|
|
//设置表格特定的列宽度
|
|
|
|
|
if (null != widthMap.get(headerCode[i])) {
|
|
|
|
|
String width = widthMap.get(headerCode[i]).toString().split("\\.")[0];
|
|
|
|
|
int w = Math.max(width.length(), header[i].length() * 3);
|
|
|
|
|
sheet.setColumnWidth(i, w * 190);
|
|
|
|
|
}
|
|
|
|
|
//创建一个单元格
|
|
|
|
|
HSSFCell cell = headRow.createCell(i);
|
|
|
|
|
//创建一个内容对象
|
|
|
|
|
HSSFRichTextString text = new HSSFRichTextString(header[i]);
|
|
|
|
|
//将内容对象的文字内容写入到单元格中
|
|
|
|
|
cell.setCellValue(text);
|
|
|
|
|
//设置样式
|
|
|
|
|
cell.setCellStyle(headerStyle);
|
|
|
|
|
}
|
|
|
|
|
//遍历结果集,把内容加入表格
|
|
|
|
|
for (int i = 0; i < mapList.size(); i++) {
|
|
|
|
|
HSSFRow row = sheet.createRow(i + 1);
|
|
|
|
|
row.setHeight((short) (50*10));
|
|
|
|
|
Map<String, Object> map = mapList.get(i);
|
|
|
|
|
for (int j = 0; j < headerCode.length; j++) {
|
|
|
|
|
HSSFCell cell = row.createCell(j);
|
|
|
|
|
cell.setCellStyle(cellStyle);
|
|
|
|
|
HSSFRichTextString text = new HSSFRichTextString(null != map.get(headerCode[j]) ? map.get(headerCode[j]).toString() : " ");
|
|
|
|
|
cell.setCellValue(text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//准备将Excel的输出流通过response输出到页面下载
|
|
|
|
|
//八进制输出流
|
|
|
|
|
response.setContentType("application/octet-stream");
|
|
|
|
|
//这后面可以设置导出Excel的名称,此例中名为student.xls
|
|
|
|
|
String fileName = ToolUtils.web2fileName(request,"teacherOpenCourseHandsOn(" + TimeTool.getNowTime("YMD") + ").xls");
|
|
|
|
|
response.setHeader("Content-disposition", "attachment;filename="+fileName);
|
|
|
|
|
//刷新缓冲
|
|
|
|
|
response.flushBuffer();
|
|
|
|
|
//workbook将Excel写入到response的输出流中,供页面下载
|
|
|
|
|
workbook.write(response.getOutputStream());
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} finally {
|
|
|
|
|
try {
|
|
|
|
|
if (null != workbook) {
|
|
|
|
|
workbook.close();
|
|
|
|
|
}
|
|
|
|
|
if (null != response && null != response.getOutputStream()) {
|
|
|
|
|
response.getOutputStream().close();
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) { }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return JsonResult.success(list);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 实操列表上方数值
|
|
|
|
|
* @param teacherOpenCourseId 开课ID
|
|
|
|
|