题目导入优化修复,完成不存在课程时自动添加课程

beetlsql3-dev
yaodan 2 years ago
parent a1f1ffe5ae
commit 11c706f87b

@ -231,7 +231,7 @@ public class CourseInfoService extends CoreBaseService<CourseInfo>{
model.setCourseInfoId(courseInfo.getCourseInfoId());
model.setCourseInfoFullId(StrUtil.prependIfMissing(StrUtil.appendIfMissing(courseInfoFullId, "_"), "_"));
updateTemplate(model);
courseInfo.setCourseInfoFullId(model.getCourseInfoFullId());
return courseInfo;
}

@ -9,7 +9,6 @@ import com.ibeetl.jlw.web.query.CourseLabelQuery;
import org.apache.commons.collections4.CollectionUtils;
import org.beetl.sql.core.SqlId;
import org.beetl.sql.core.engine.PageQuery;
import org.beetl.sql.core.page.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -64,7 +63,7 @@ public class CourseLabelService extends CoreBaseService<CourseLabel> {
}
public CourseLabel getOnce(CourseLabel courseLabel) {
PageResult<CourseLabel> page = courseLabelDao.createLambdaQuery().addParam(courseLabel).page(1, 1);
return CollectionUtils.isEmpty(page.getList()) ? null : page.getList().get(0);
List<CourseLabel> list = courseLabelDao.template(courseLabel);
return CollectionUtils.isEmpty(list) ? null : list.get(0);
}
}

@ -18,7 +18,6 @@ import com.ibeetl.jlw.enums.ChatLogSendTypeEnum;
import com.ibeetl.jlw.enums.ResourcesQuestionSnapshotFromTypeEnum;
import com.ibeetl.jlw.enums.SignInTypeEnum;
import com.ibeetl.jlw.web.query.TeacherOpenCourseMergeStudentQuery;
import com.ibeetl.jlw.web.query.TeacherOpenCourseScheduleSessionQuery;
import com.ibeetl.jlw.web.query.TeacherOpenCourseScoreDashboardQuery;
import com.ibeetl.jlw.web.query.TeacherOpenCourseStudentSigninLogQuery;
import lombok.extern.slf4j.Slf4j;
@ -530,6 +529,7 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService<Teac
realOperationScore = NumberUtil.add(realOperationScore,
NumberUtil.toBigDecimal(studentHandsOnTaskVideo.getVideoScore()));
} catch (Exception ee) {
ee.printStackTrace();
}
}
@ -540,6 +540,7 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService<Teac
realOperationScore = NumberUtil.add(realOperationScore,
NumberUtil.toBigDecimal(studentHandsOnTaskPpt.getPptScore()));
} catch (Exception ee) {
ee.printStackTrace();
}
}
@ -550,6 +551,7 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService<Teac
realOperationScore = NumberUtil.add(realOperationScore,
NumberUtil.toBigDecimal(studentHandsOnTaskStep.getTheoryScore()));
} catch (Exception ee) {
ee.printStackTrace();
}
}
@ -560,6 +562,7 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService<Teac
realOperationScore = NumberUtil.add(realOperationScore,
NumberUtil.toBigDecimal(studentHandsOnTaskReport.getReportScore()));
} catch (Exception ee) {
ee.printStackTrace();
}
}
@ -570,6 +573,7 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService<Teac
realOperationScore = NumberUtil.add(realOperationScore,
NumberUtil.toBigDecimal(studentHandsOnTaskTheory.getTheoryScore()));
} catch (Exception ee) {
ee.printStackTrace();
}
}
@ -588,7 +592,7 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService<Teac
.andEq(QuestionLogSummary::getPersonId, studentId)
.andIn(QuestionLogSummary::getQuestionSettingId, collect).select();
if (CollectionUtil.isEmpty(select1)) {
scoreDashboard.setCourseScore(BigDecimal.ZERO);
scoreDashboard.setQuestionHomeworkScore(BigDecimal.ZERO);
} else {
BigDecimal b = BigDecimal.ZERO;
for (QuestionLogSummary questionLogSummary : select1) {
@ -602,7 +606,7 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService<Teac
.andEq(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseId, teacherOpenCourseId)
.andEq(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseQuestionSettingType, ResourcesQuestionSnapshotFromTypeEnum.EXAM).select();
if (CollectionUtil.isEmpty(select3)) {
scoreDashboard.setCourseScore(BigDecimal.ZERO);
scoreDashboard.setExamScore(BigDecimal.ZERO);
} else {
if (weight == null || "1".equals(weight.getCoursePracticeResultSetting())) {
List<Long> collect = select3.stream().map(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseQuestionSettingId).collect(Collectors.toList());
@ -610,7 +614,7 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService<Teac
.andEq(QuestionLogSummary::getPersonId, studentId)
.andIn(QuestionLogSummary::getQuestionSettingId, collect).select();
if (CollectionUtil.isEmpty(select1)) {
scoreDashboard.setCourseScore(BigDecimal.ZERO);
scoreDashboard.setExamScore(BigDecimal.ZERO);
} else {
BigDecimal b = BigDecimal.ZERO;
for (QuestionLogSummary questionLogSummary : select1) {
@ -656,8 +660,7 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService<Teac
.add(scoreDashboard.getRealOperationScore())
.add(scoreDashboard.getQuestionHomeworkScore())
.add(scoreDashboard.getExamScore())
.add(scoreDashboard.getChatScore())
;
.add(scoreDashboard.getChatScore());
scoreDashboard.setTotalScore(totalScore);
if (weight != null) {
lastStatus(weight, totalScore, scoreDashboard);

@ -9,7 +9,6 @@ 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.entity.CourseInfo;
@ -29,9 +28,6 @@ import com.ibeetl.jlw.web.query.ResourcesQuestionQuery;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Name;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.xssf.usermodel.*;
@ -57,10 +53,7 @@ import java.util.stream.Collectors;
import static cn.hutool.core.util.ArrayUtil.join;
import static cn.hutool.core.util.ObjectUtil.defaultIfNull;
import static cn.jlw.util.excel.ExcelUtil.standardName;
import static com.ibeetl.admin.core.util.StreamUtils.listJoin;
import static com.ibeetl.admin.core.util.excelGroupValidation.ExcelUtil.replaceNameName;
import static java.util.stream.Collectors.toList;
/**
* ResourcesQuestion
@ -439,49 +432,49 @@ public class ResourcesQuestionController{
workbook = new XSSFWorkbook(is);
// 获取模板中的Sheet1
Sheet sheetPro = workbook.getSheet("Sheet1");
//// 获取模板中的Sheet1
//Sheet sheetPro = workbook.getSheet("Sheet1");
// 查询特定的课程名称及其章的名称
List<String> courseInfoArr = new ArrayList<String>();
Map<String, List<String>> map = new HashMap<String, List<String>>();
CourseInfoQuery courseInfoQuery = new CourseInfoQuery();
courseInfoQuery.setCourseLabelStatus(1);
// courseInfoQuery.setCourseLabelTypes("应用课程类");
courseInfoQuery.setCourseInfoType(1);
courseInfoQuery.setCourseInfoStatus(1);
List<CourseInfo> courseInfoList = courseInfoService.getCourseInfoValues(courseInfoQuery);
if(null != courseInfoList && courseInfoList.size()>0){
for(int i=0;i<courseInfoList.size();i++){
String mergeCourseNameId = courseInfoList.get(i).getCourseInfoName() + "__ID" + courseInfoList.get(i).getCourseInfoId();
mergeCourseNameId = standardName(mergeCourseNameId);
// key不可重复
mergeCourseNameId = replaceNameName(mergeCourseNameId);
courseInfoArr.add(mergeCourseNameId);
// 整理数据放入一个Map中mapkey存放父地点value 存放院校下的班级
Object chapter = courseInfoList.get(i).get("chapter");
if(null != chapter && StringUtils.isNotBlank(chapter.toString())){
map.put(mergeCourseNameId, Arrays.stream(chapter.toString().split(",")).map(String::trim).collect(toList()));
}else {
map.put(mergeCourseNameId,new ArrayList<>());
}
}
}else {
throw new PlatformException("请先添加院校");
}
// CourseInfoQuery courseInfoQuery = new CourseInfoQuery();
// courseInfoQuery.setCourseLabelStatus(1);
//// courseInfoQuery.setCourseLabelTypes("应用课程类");
// courseInfoQuery.setCourseInfoType(1);
// courseInfoQuery.setCourseInfoStatus(1);
//List<CourseInfo> courseInfoList = courseInfoService.getCourseInfoValues(courseInfoQuery);
//
//if(null != courseInfoList && courseInfoList.size()>0){
// for(int i=0;i<courseInfoList.size();i++){
// String mergeCourseNameId = courseInfoList.get(i).getCourseInfoName() + "__ID" + courseInfoList.get(i).getCourseInfoId();
// mergeCourseNameId = standardName(mergeCourseNameId);
// // key不可重复
// mergeCourseNameId = replaceNameName(mergeCourseNameId);
// courseInfoArr.add(mergeCourseNameId);
//
// // 整理数据放入一个Map中mapkey存放父地点value 存放院校下的班级
// Object chapter = courseInfoList.get(i).get("chapter");
// if(null != chapter && StringUtils.isNotBlank(chapter.toString())){
// map.put(mergeCourseNameId, Arrays.stream(chapter.toString().split(",")).map(String::trim).collect(toList()));
// }else {
// map.put(mergeCourseNameId,new ArrayList<>());
// }
//
// }
//}else {
// throw new PlatformException("请先添加院校");
//}
// 创建一个专门用来存放地区信息的隐藏sheet页
// 因此也不能在现实页之前创建,否则无法隐藏。
Sheet hideSheet = workbook.createSheet("课程章节信息");
// 将此sheet隐藏
workbook.setSheetHidden(workbook.getSheetIndex(hideSheet), true);
//Sheet hideSheet = workbook.createSheet("课程章节信息");
//// 将此sheet隐藏
//workbook.setSheetHidden(workbook.getSheetIndex(hideSheet), true);
int rowId = 0;
//int rowId = 0;
// 设置第一行,存省的信息
// Row provinceRow = hideSheet.createRow(rowId++);
// provinceRow.createCell(0).setCellValue("省列表");
@ -490,23 +483,23 @@ public class ResourcesQuestionController{
// provinceCell.setCellValue(provinceArr.get(i));
// }
// 将具体的数据写入到每一行中,行开头为父级区域,后面是子区域。
Iterator<String> keyIterator = map.keySet().iterator();
while (keyIterator.hasNext()) {
String key = keyIterator.next();
List<String> son = map.get(key);
Row row = hideSheet.createRow(rowId++);
row.createCell(0).setCellValue(key);
for (int i = 0; i < son.size(); i++) {
Cell cell = row.createCell(i+1);
cell.setCellValue(son.get(i));
}
// 添加名称管理器
String range = getRange(1, rowId, son.size());
Name name = workbook.createName();
name.setNameName(key);
String formula = "课程章节信息!" + range;
name.setRefersToFormula(formula);
}
//Iterator<String> keyIterator = map.keySet().iterator();
//while (keyIterator.hasNext()) {
// String key = keyIterator.next();
// List<String> son = map.get(key);
// Row row = hideSheet.createRow(rowId++);
// row.createCell(0).setCellValue(key);
// for (int i = 0; i < son.size(); i++) {
// Cell cell = row.createCell(i+1);
// cell.setCellValue(son.get(i));
// }
// // 添加名称管理器
// String range = getRange(1, rowId, son.size());
// Name name = workbook.createName();
// name.setNameName(key);
// String formula = "课程章节信息!" + range;
// name.setRefersToFormula(formula);
//}
// 课程规则
// DVConstraint provConstraint = DVConstraint.createExplicitListConstraint(courseInfoArr.toArray(new String[] {}));
@ -515,26 +508,26 @@ public class ResourcesQuestionController{
// provinceDataValidation.createErrorBox("error", "请选择正确的课程");
// sheetPro.addValidationData(provinceDataValidation);
XSSFDataValidationHelper dvHelper = new XSSFDataValidationHelper((XSSFSheet)sheetPro);
XSSFDataValidationConstraint dvConstraint = (XSSFDataValidationConstraint) dvHelper.createExplicitListConstraint(courseInfoArr.toArray(new String[] {}));
CellRangeAddressList addressList = new CellRangeAddressList(1, 20, 0, 0);
XSSFDataValidation validation = (XSSFDataValidation) dvHelper.createValidation(dvConstraint, addressList);
validation.createErrorBox("error", "请选择正确的课程");
sheetPro.addValidationData(validation);
// 对前200行设置有效性
for (int i = 2; i < 200; i++) {
setDataValidation("A", sheetPro, i, 2);
}
try {
if(null != is){
is.close();
}
}catch (Exception e){
e.printStackTrace();
}
//XSSFDataValidationHelper dvHelper = new XSSFDataValidationHelper((XSSFSheet)sheetPro);
//XSSFDataValidationConstraint dvConstraint = (XSSFDataValidationConstraint) dvHelper.createExplicitListConstraint(courseInfoArr.toArray(new String[] {}));
//CellRangeAddressList addressList = new CellRangeAddressList(1, 20, 0, 0);
//XSSFDataValidation validation = (XSSFDataValidation) dvHelper.createValidation(dvConstraint, addressList);
//validation.createErrorBox("error", "请选择正确的课程");
//sheetPro.addValidationData(validation);
//
//
//// 对前200行设置有效性
//for (int i = 2; i < 200; i++) {
// setDataValidation("A", sheetPro, i, 2);
//}
//
//try {
// if(null != is){
// is.close();
// }
//}catch (Exception e){
// e.printStackTrace();
//}
//准备将Excel的输出流通过response输出到页面下载
//八进制输出流
@ -558,7 +551,9 @@ public class ResourcesQuestionController{
if (null != response && null != response.getOutputStream()) {
response.getOutputStream().close();
}
} catch (Exception e) { }
} catch (Exception e) {
e.printStackTrace();
}
}
}
@ -632,8 +627,8 @@ public class ResourcesQuestionController{
//导入模板信息
@PostMapping(MODEL + "/importTemplate.json")
@ResponseBody
public JsonResult importTemplate(@RFile FileEntity fileEntity) {
return resourcesQuestionService.importTemplate(fileEntity);
public JsonResult importTemplate(@RFile FileEntity fileEntity,@SCoreUser CoreUser coreUser) {
return resourcesQuestionService.importTemplate(fileEntity,coreUser);
}
//查询客观题树结构

@ -77,6 +77,8 @@ public class CourseInfoQuery extends PageParam {
// 机构IDs
private String orgIdPlural;
private String courseInfoStatusPlural;
public String getOrgIdPlural() {
return orgIdPlural;
}
@ -332,4 +334,12 @@ public class CourseInfoQuery extends PageParam {
public void setCourseInfoFullId(String courseInfoFullId) {
this.courseInfoFullId = courseInfoFullId;
}
public String getCourseInfoStatusPlural() {
return courseInfoStatusPlural;
}
public void setCourseInfoStatusPlural(String courseInfoStatusPlural) {
this.courseInfoStatusPlural = courseInfoStatusPlural;
}
}

@ -381,7 +381,13 @@ getCourseInfoValues
and t.org_id =#orgId#
@}
@if(!isEmpty(userId)){
and t.user_id =#userId#
and t.user_id =#userId#
@}
@if(!isEmpty(orgIdPlural)){
and t.org_id in (#text(orgIdPlural)#)
@}
@if(!isEmpty(courseInfoStatusPlural)){
and t.course_info_status in (#text(courseInfoStatusPlural)#)
@}

@ -59,7 +59,7 @@
{{# layui.each(d.list, function(index, item){ }}
<tr>
<td style="text-align: center;">{{index + 1}}</td>
<td>{{item.failMessage}}</td>
<td>{{item}}</td>
<!-- <td style="text-align: center;">-->
<!-- {{#if(item.length ==2){}}-->
<!-- <a resourcesQuestionId="{{item[1]}}" class="layui-btn layui-btn-sm bg_button del">删除</a>-->
@ -107,9 +107,10 @@
parent.window.dataReload();
layer.msg(res.msg, {icon: 1});
} else {
layer.msg(res.msg, {icon: 2});
var getTpl = demo.innerHTML
,view = document.getElementById('view');
laytpl(getTpl).render({list:JSON.parse(res.msg)}, function(html){
laytpl(getTpl).render({list:res.data}, function(html){
view.innerHTML = html;
$(".del").click(deleteInfo);
});

Loading…
Cancel
Save