beetlsql3-dev
Mlxa0324 2 years ago
parent adabf6c762
commit cff24bed81

@ -11,7 +11,6 @@ import org.beetl.sql.annotation.entity.AssignID;
import org.beetl.sql.annotation.entity.InsertIgnore;
import org.beetl.sql.annotation.entity.UpdateIgnore;
import org.beetl.sql.fetch.annotation.Fetch;
import org.beetl.sql.fetch.annotation.FetchOne;
import org.beetl.sql.fetch.annotation.FetchSql;
import javax.validation.constraints.NotNull;
@ -107,11 +106,11 @@ public class TeacherOpenCourseStudentSigninLog extends BaseEntity{
private Long userId ;
// 扩展属性
@FetchOne("studentId")
@UpdateIgnore
@InsertIgnore
private Student student;
// @FetchOne("studentId")
//
// @UpdateIgnore
// @InsertIgnore
// private Student student;
public TeacherOpenCourseStudentSigninLog(){
}
@ -270,14 +269,6 @@ public class TeacherOpenCourseStudentSigninLog extends BaseEntity{
this.teacherOpenCourseStudentSigninSettingSessionTime = DateUtil.date(teacherOpenCourseStudentSigninSettingSessionTime);
}
public Student getStudent() {
return student;
}
public void setStudent(Student student) {
this.student = student;
}
public String getStudentIdText() {
return studentIdText;
}

@ -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);
}
}

@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.util.List;
@ -180,7 +181,7 @@ public class TeacherOpenCourseStudentSigninSettingController{
*/
@PostMapping(MODEL + "/sessionDateList.json")
@Function("teacherOpenCourseStudentSigninSetting.query")
public JsonResult<List<String>> sessionDateList(Long teacherOpenCourseId){
public JsonResult<List<String>> sessionDateList(@NotNull(message = "开课ID不能为空") Long teacherOpenCourseId, @SCoreUser CoreUser coreUser){
return JsonResult.success(teacherOpenCourseStudentSigninSettingService.sessionDateList(teacherOpenCourseId));
}

@ -6,7 +6,7 @@ queryByCondition
t.*
@}
from teacher_open_course_student_signin_log t
inner join student ta on ta.student_status = 1
inner join student ta on ta.student_status = 1 and ta.student_id = t.student_id
where 1=1
@//数据权限该sql语句功能点,如果不考虑数据权限,可以删除此行
and #function("teacherOpenCourseStudentSigninLog.query")#

@ -14,6 +14,7 @@ layui.define([], function(exports) {
},
exportExcel:function(form,extendData, callback){
var formPara = form.serializeJson();
formPara.teacherOpenCourseId = '10086'
Common.downLoad("/jlw/teacherOpenCourseStudentSigninLog/excel/export.json", {...formPara, ...extendData}, 'POST')
}

Loading…
Cancel
Save