|
|
|
@ -11,7 +11,6 @@ import com.ibeetl.admin.core.annotation.Function;
|
|
|
|
|
import com.ibeetl.admin.core.entity.CoreUser;
|
|
|
|
|
import com.ibeetl.admin.core.file.FileService;
|
|
|
|
|
import com.ibeetl.admin.core.util.BeanCopyUtil;
|
|
|
|
|
import com.ibeetl.admin.core.util.PlatformException;
|
|
|
|
|
import com.ibeetl.admin.core.util.TimeTool;
|
|
|
|
|
import com.ibeetl.admin.core.web.JsonResult;
|
|
|
|
|
import com.ibeetl.jlw.entity.FileEntity;
|
|
|
|
@ -24,9 +23,6 @@ import lombok.SneakyThrows;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
|
|
|
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
|
|
|
|
import org.apache.poi.ss.usermodel.VerticalAlignment;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
import org.beetl.sql.core.engine.PageQuery;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
@ -154,38 +150,33 @@ public class TeacherOpenCourseStudentSigninLogController{
|
|
|
|
|
*/
|
|
|
|
|
@SneakyThrows
|
|
|
|
|
@PostMapping(API + "/export.do")
|
|
|
|
|
public void easyExcelExport(HttpServletResponse resp, TeacherOpenCourseStudentSigninLogQuery condition, @SCoreUser CoreUser coreUser) {
|
|
|
|
|
|
|
|
|
|
if(null == coreUser){
|
|
|
|
|
throw new PlatformException("请登录后再操作");
|
|
|
|
|
} else {
|
|
|
|
|
Assert.notNull(condition.getTeacherOpenCourseId(), "teacherOpenCourseId 开课ID不能为空!");
|
|
|
|
|
|
|
|
|
|
/** 构建表头 */
|
|
|
|
|
Map<String, String> header = new LinkedHashMap<>(11);
|
|
|
|
|
header.put("studentIdText", "学生姓名");
|
|
|
|
|
header.put("studentSn", "学号");
|
|
|
|
|
header.put("teacherOpenCourseIdText", "开课名称");
|
|
|
|
|
header.put("schoolClassIdText", "班级名称");
|
|
|
|
|
header.put("teacherOpenCourseStudentSigninSettingSessionTime", "签到场次");
|
|
|
|
|
header.put("teacherOpenCourseStudentSigninLogTypeText", "签到类型");
|
|
|
|
|
header.put("teacherOpenCourseStudentSigninLogTagText", "签到标签");
|
|
|
|
|
header.put("teacherOpenCourseStudentSigninLogAddTime", "签到时间");
|
|
|
|
|
header.put("teacherOpenCourseStudentSigninLogRemark", "备注");
|
|
|
|
|
|
|
|
|
|
List<TeacherOpenCourseStudentSigninLog> datas =
|
|
|
|
|
teacherOpenCourseStudentSigninLogService.getValuesByQueryNotWithPermission(condition);
|
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> maps = BeanCopyUtil.baseEntity2MapWithParallel(datas);
|
|
|
|
|
|
|
|
|
|
String filename = StrUtil.format("签到日志导出 {}.xlsx", DateUtil.now());
|
|
|
|
|
write(resp, filename,"Sheet1", header.values(), convertData(header.keySet(), maps));
|
|
|
|
|
}
|
|
|
|
|
public String easyExcelExportDo(HttpServletResponse resp, TeacherOpenCourseStudentSigninLogQuery condition, @SCoreUser CoreUser coreUser) {
|
|
|
|
|
|
|
|
|
|
Assert.notNull(condition.getTeacherOpenCourseId(), "teacherOpenCourseId 开课ID不能为空!");
|
|
|
|
|
|
|
|
|
|
/** 构建表头 */
|
|
|
|
|
Map<String, String> header = new LinkedHashMap<>(11);
|
|
|
|
|
header.put("studentIdText", "学生姓名");
|
|
|
|
|
header.put("studentSn", "学号");
|
|
|
|
|
header.put("teacherOpenCourseIdText", "开课名称");
|
|
|
|
|
header.put("schoolClassIdText", "班级名称");
|
|
|
|
|
header.put("teacherOpenCourseStudentSigninSettingSessionTime", "签到场次");
|
|
|
|
|
header.put("teacherOpenCourseStudentSigninLogTypeText", "签到类型");
|
|
|
|
|
header.put("teacherOpenCourseStudentSigninLogTagText", "签到标签");
|
|
|
|
|
header.put("teacherOpenCourseStudentSigninLogAddTime", "签到时间");
|
|
|
|
|
header.put("teacherOpenCourseStudentSigninLogRemark", "备注");
|
|
|
|
|
|
|
|
|
|
PageQuery pageQuery = condition.getPageQuery();
|
|
|
|
|
pageQuery.setPageNumber(1); pageQuery.setPageSize(Integer.MAX_VALUE);
|
|
|
|
|
PageQuery<TeacherOpenCourseStudentSigninLog> page = teacherOpenCourseStudentSigninLogService.queryByCondition(pageQuery);
|
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> maps = BeanCopyUtil.baseEntity2MapWithParallel(page.getList());
|
|
|
|
|
|
|
|
|
|
String filename = StrUtil.format("签到日志导出 {}.xlsx", DateUtil.now());
|
|
|
|
|
write(resp, filename,"Sheet1", header.values(), convertData(header.keySet(), maps));
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 后台页面 */
|
|
|
|
|
|
|
|
|
|
@GetMapping(MODEL + "/index.do")
|
|
|
|
@ -389,112 +380,19 @@ public class TeacherOpenCourseStudentSigninLogController{
|
|
|
|
|
}
|
|
|
|
|
return jsonResult;
|
|
|
|
|
}
|
|
|
|
|
//导出信息
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 教师端-签到日志导出
|
|
|
|
|
* @param condition 日志记录查询条件
|
|
|
|
|
* @param coreUser
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping(MODEL + "/excel/export.json")
|
|
|
|
|
@Function("teacherOpenCourseStudentSigninLog.exportDocument")
|
|
|
|
|
public void export(HttpServletRequest request, HttpServletResponse response, TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery, @SCoreUser CoreUser coreUser) {
|
|
|
|
|
if(null == coreUser){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
HSSFWorkbook workbook = null;
|
|
|
|
|
try {
|
|
|
|
|
//表头数据
|
|
|
|
|
String[] header = {
|
|
|
|
|
"姓名",
|
|
|
|
|
"学号",
|
|
|
|
|
"班级",
|
|
|
|
|
"状态",
|
|
|
|
|
"缺勤理由",
|
|
|
|
|
"签到日期",
|
|
|
|
|
};
|
|
|
|
|
String[] headerCode = {
|
|
|
|
|
"studentIdText",
|
|
|
|
|
"studentSn",
|
|
|
|
|
"schoolClassIdText",
|
|
|
|
|
"teacherOpenCourseStudentSigninLogTagText",
|
|
|
|
|
"teacherOpenCourseStudentSigninLogRemark",
|
|
|
|
|
"teacherOpenCourseStudentSigninLogAddTime",
|
|
|
|
|
};
|
|
|
|
|
//数据内容
|
|
|
|
|
List<Map<String, Object>> mapList = teacherOpenCourseStudentSigninLogService.getExcelValues(teacherOpenCourseStudentSigninLogQuery);
|
|
|
|
|
//内容宽度
|
|
|
|
|
Map<String, Object> widthMap = mapList.get(0);
|
|
|
|
|
mapList.remove(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];
|
|
|
|
|
Integer w = Integer.parseInt(width) > header[i].length()*3?Integer.parseInt(width):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,"teacherOpenCourseStudentSigninLog(" + 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) { }
|
|
|
|
|
}
|
|
|
|
|
@SneakyThrows
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public String easyExcelExport(HttpServletResponse resp, TeacherOpenCourseStudentSigninLogQuery condition, @SCoreUser CoreUser coreUser) {
|
|
|
|
|
return easyExcelExportDo(resp, condition, coreUser);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|