Merge remote-tracking branch 'origin/beetlsql3-dev' into beetlsql3-dev

beetlsql3-dev
姚丹ab 2 years ago
commit b751dc20f2

@ -29,4 +29,6 @@ public interface TeacherOpenCourseScoreDashboardDao extends BaseMapper<TeacherOp
List<Map<String,Object>>getExcelValues(TeacherOpenCourseScoreDashboardQuery teacherOpenCourseScoreDashboardQuery);
@Update
int deleteByTeacherOpenCourseId(Long teacherOpenCourseId);
List<TeacherOpenCourseScoreDashboard> queryByConditionQueryNotPage(TeacherOpenCourseScoreDashboardQuery teacherOpenCourseScoreDashboardQuery);
}

@ -175,7 +175,7 @@ public class TeacherOpenCourseQuestionSetting extends BaseEntity {
@UpdateIgnore
@InsertIgnore
@FetchSql("select count(1) " +
@FetchSql("select count(*) " +
"from resources_question_snapshot t where t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# \n" +
"and t.question_status = 1 \n"
)

@ -210,7 +210,7 @@ public class TeacherOpenCourseMergeResourcesQuestionService extends CoreBaseServ
//查询章节题目配置信息
TeacherOpenCourseQuestionSettingQuery questionSettingQuery = new TeacherOpenCourseQuestionSettingQuery();
questionSettingQuery.setTeacherOpenCourseQuestionSettingName(courseInfo.getCourseInfoName());
questionSettingQuery.setTeacherOpenCourseMergeCourseInfoId(mergeCourseInfoId);
questionSettingQuery.setTeacherOpenCourseQuestionSettingStatus(1);
TeacherOpenCourseQuestionSetting questionSetting = teacherOpenCourseQuestionSettingService.getInfo(questionSettingQuery);

@ -3,11 +3,13 @@ package com.ibeetl.jlw.service;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import cn.jlw.util.ToolUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ibeetl.admin.core.entity.CoreUser;
import com.ibeetl.admin.core.service.CoreBaseService;
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;
@ -34,6 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull;
import java.io.*;
import java.math.BigDecimal;
@ -43,6 +46,9 @@ import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import static com.ibeetl.admin.core.util.ExcelUtil.convertData;
import static com.ibeetl.admin.core.util.ExcelUtil.write;
/**
* Service
* ID使insert(*,true)
@ -82,8 +88,12 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService<Teac
private StudentHandsOnTaskTheoryDao theoryService;
@Autowired
private StudentHandsOnTaskReportDao reportService;
@Autowired private TeacherOpenCourseChatLogDao courseChatLogDao;
@Autowired private GeneralQuestionLogDao generalQuestionLogDao;
@Autowired
private TeacherOpenCourseChatLogDao courseChatLogDao;
@Autowired
private StudentService studentService;
public PageQuery<TeacherOpenCourseScoreDashboard> queryByCondition(PageQuery query) {
PageQuery ret = teacherOpenCourseScoreDashboardDao.queryByCondition(query);
@ -498,7 +508,7 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService<Teac
BigDecimal mul = NumberUtil.mul(div, 100);
scoreDashboard.setCourseScore(mul);
}
}else {
} else {
BigDecimal b = BigDecimal.ZERO;
for (QuestionLogSummary questionLogSummary : select1) {
b = b.add(questionLogSummary.getQuestionLogSummaryStudentTotalScore());
@ -637,7 +647,7 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService<Teac
//答题次数
long count3 = chatLogList.stream().filter(v ->
v.getChatLogSendType().equals(ChatLogSendTypeEnum.normal)
&& v.getStudentScore() != null
&& v.getStudentScore() != null
).count();
BigDecimal chatScore = BigDecimal.ZERO;
if (weight != null && StringUtils.isNotEmpty(weight.getInteractionResultSetting())) {
@ -645,13 +655,13 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService<Teac
if (interactionResultSetting.contains("1")) {
chatScore = NumberUtil.mul(count2, NumberUtil.toBigDecimal(weight.getInteractionResultMessageScore()));
}
if(interactionResultSetting.contains("2")) {
if (interactionResultSetting.contains("2")) {
chatScore = NumberUtil.mul(count, NumberUtil.toBigDecimal(weight.getInteractionResultQuestionScore()));
}
if(interactionResultSetting.contains("3")) {
if (interactionResultSetting.contains("3")) {
chatScore = NumberUtil.mul(count3, NumberUtil.toBigDecimal(weight.getInteractionResultAnswerScore()));
}
}else {
} else {
chatScore = BigDecimal.valueOf(count2);
}
scoreDashboard.setChatScore(chatScore);
@ -733,4 +743,40 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService<Teac
public void deleteTeacherOpenCourseAllRelatedByTeacherOpenCourseId(@NotNull(message = "开课ID不能为空") Long teacherOpenCourseId) {
log.info("需要实现删除操作!");
}
public List<TeacherOpenCourseScoreDashboard> queryByConditionQueryNotPage(TeacherOpenCourseScoreDashboardQuery teacherOpenCourseScoreDashboardQuery) {
return teacherOpenCourseScoreDashboardDao.queryByConditionQueryNotPage(teacherOpenCourseScoreDashboardQuery);
}
public void export(HttpServletResponse response, TeacherOpenCourseScoreDashboardQuery teacherOpenCourseScoreDashboardQuery, CoreUser coreUser) throws IOException {
if (coreUser.isStudent()) {
Student student = studentService.getByUserId(coreUser.getId());
if (student != null) {
teacherOpenCourseScoreDashboardQuery.setStudentId(student.getStudentId());
}
}
/** 构建表头 */
Map<String, String> header = new LinkedHashMap<>(13);
header.put("studentSn", "学号");
header.put("studentName", "姓名");
header.put("className", "班级");
header.put("signinScore", "签到成绩");
header.put("courseScore", "章节练习成绩");
header.put("realOperationScore", "课程实操成绩");
header.put("questionHomeworkScore", "作业成绩");
header.put("examScore", "考试成绩");
header.put("chatScore", "互动成绩");
header.put("totalScore", "总成绩");
header.put("manualScore", "手动调整的分数");
header.put("lastScore", "最终成绩");
header.put("lastStatus", "成绩状态");
List<TeacherOpenCourseScoreDashboard> teacherOpenCourseScoreDashboardList = this.queryByConditionQueryNotPage(teacherOpenCourseScoreDashboardQuery);
List<Map<String, Object>> maps = BeanCopyUtil.baseEntity2MapWithParallel(teacherOpenCourseScoreDashboardList);
String filename = StrUtil.format("成绩-导出 {}.xlsx", System.currentTimeMillis());
write(response, filename, "Sheet1", header.values(), convertData(header.keySet(), maps));
}
}

@ -7,21 +7,20 @@ import cn.jlw.validate.ValidateConfig;
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.PlatformException;
import com.ibeetl.admin.core.util.TimeTool;
import com.ibeetl.admin.core.web.JsonResult;
import com.ibeetl.jlw.dao.StudentDao;
import com.ibeetl.jlw.entity.FileEntity;
import com.ibeetl.jlw.entity.Student;
import com.ibeetl.jlw.entity.TeacherOpenCourseScoreDashboard;
import com.ibeetl.jlw.job.TeacherOpenCourseScoreDashboardJob;
import com.ibeetl.jlw.service.TeacherOpenCourseScoreDashboardService;
import com.ibeetl.jlw.web.query.TeacherOpenCourseScoreDashboardQuery;
import org.apache.commons.collections4.MapUtils;
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;
@ -34,6 +33,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
@ -283,149 +283,19 @@ public class TeacherOpenCourseScoreDashboardController {
//导出信息
@RequestMapping(MODEL + "/excel/export.json")
public void export(HttpServletRequest request, HttpServletResponse response, TeacherOpenCourseScoreDashboardQuery teacherOpenCourseScoreDashboardQuery, @SCoreUser CoreUser coreUser) {
public void export( HttpServletResponse response, TeacherOpenCourseScoreDashboardQuery teacherOpenCourseScoreDashboardQuery, @SCoreUser CoreUser coreUser) throws IOException {
if (null == coreUser) {
return;
throw new PlatformException("请登录后再操作");
}
HSSFWorkbook workbook = null;
try {
//表头数据
String[] header = {
"学生",
"签到成绩",
"章节练习成绩",
"课程实操成绩",
"作业成绩",
"考试成绩",
"互动成绩",
"总成绩",
"手动调整的分数",
"最终成绩",
"成绩状态",
"创建时间"
};
String[] headerCode = {
"studentId",
"signinScore",
"courseScore",
"realOperationScore",
"questionHomeworkScore",
"examScore",
"chatScore",
"totalScore",
"manualScore",
"lastScore",
"lastStatus",
"createTime"
};
//数据内容
List<Map<String, Object>> mapList = teacherOpenCourseScoreDashboardService.getExcelValues(teacherOpenCourseScoreDashboardQuery);
//内容宽度
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
response.setHeader("Content-disposition", "attachment;filename=competitionTeacher(" + TimeTool.getNowTime("YMD") + ").xls");
teacherOpenCourseScoreDashboardService.export( response, teacherOpenCourseScoreDashboardQuery, coreUser);
//刷新缓冲
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) {
}
}
}
/**
*
*
* @param map teacherOpenCourseId ID
* @return
*/

@ -598,3 +598,86 @@ deleteByTeacherOpenCourseId
delete from teacher_open_course_score_dashboard where teacher_open_course_id = #teacherOpenCourseId#
queryByConditionQueryNotPage
===
* 根据不为空的参数进行查询
select
@pageTag(){
t.*,
s1.student_sn studentSn,
s1.student_name studentName,
s2.class_name className
@}
from teacher_open_course_score_dashboard t
left join student s1 on s1.student_id = t.student_id
left join school_class s2 on s2.class_id = s1.class_id
where 1=1
and #function("teacherOpenCourseScoreDashboard.query")#
@if(!isEmpty(teacherOpenCourseScoreDashboardId)){
and t.teacher_open_course_score_dashboard_id =#teacherOpenCourseScoreDashboardId#
@}
@if(!isEmpty(teacherOpenCourseScoreDashboardIdPlural)){
and find_in_set(t.teacher_open_course_score_dashboard_id,#teacherOpenCourseScoreDashboardIdPlural#)
@}
@if(!isEmpty(studentId)){
and t.student_id =#studentId#
@}
@if(!isEmpty(studentIdPlural)){
and find_in_set(t.student_id,#studentIdPlural#)
@}
@if(!isEmpty(signinScore)){
and t.signin_score =#signinScore#
@}
@if(!isEmpty(courseScore)){
and t.course_score =#courseScore#
@}
@if(!isEmpty(realOperationScore)){
and t.real_operation_score =#realOperationScore#
@}
@if(!isEmpty(questionHomeworkScore)){
and t.question_homework_score =#questionHomeworkScore#
@}
@if(!isEmpty(examScore)){
and t.exam_score =#examScore#
@}
@if(!isEmpty(chatScore)){
and t.chat_score =#chatScore#
@}
@if(!isEmpty(totalScore)){
and t.total_score =#totalScore#
@}
@if(!isEmpty(manualScore)){
and t.manual_score =#manualScore#
@}
@if(!isEmpty(lastScore)){
and t.last_score =#lastScore#
@}
@if(!isEmpty(lastStatus)){
and t.last_status =#lastStatus#
@}
@if(!isEmpty(orgId)){
and t.org_id =#orgId#
@}
@if(!isEmpty(orgIdPlural)){
and find_in_set(t.org_id,#orgIdPlural#)
@}
@if(!isEmpty(userId)){
and t.user_id =#userId#
@}
@if(!isEmpty(userIdPlural)){
and find_in_set(t.user_id,#userIdPlural#)
@}
@if(!isEmpty(createTime)){
and t.create_time =#createTime#
@}
@if(!isEmpty(teacherOpenCourseId)){
and t.teacher_open_course_id =#teacherOpenCourseId#
@}
@if(!isEmpty(studentOrName)){
and (s1.student_name like #'%'+studentOrName+'%'# or s1.student_sn like #'%'+studentOrName+'%'#)
@}
@if(!isEmpty(classId)){
and s2.class_id =#classId#
@}
Loading…
Cancel
Save