|
|
package com.ibeetl.jlw.service;
|
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
import cn.hutool.core.util.EnumUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
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.PlatformException;
|
|
|
import com.ibeetl.admin.core.web.JsonResult;
|
|
|
import com.ibeetl.admin.core.web.JsonReturnCode;
|
|
|
import com.ibeetl.jlw.dao.GeneralResourcesQuestionSnapshotDao;
|
|
|
import com.ibeetl.jlw.entity.FileEntity;
|
|
|
import com.ibeetl.jlw.entity.GeneralQuestionLogScoreInfo;
|
|
|
import com.ibeetl.jlw.entity.GeneralResourcesQuestionSnapshot;
|
|
|
import com.ibeetl.jlw.entity.Student;
|
|
|
import com.ibeetl.jlw.entity.dto.GeneralQuestionTestSimpleInfoDTO;
|
|
|
import com.ibeetl.jlw.entity.dto.QuestionSettingDTO;
|
|
|
import com.ibeetl.jlw.entity.vo.GeneralQuestionTestSimpleInfoVO;
|
|
|
import com.ibeetl.jlw.enums.BusinessCourseInfoEnum;
|
|
|
import com.ibeetl.jlw.web.query.GeneralResourcesQuestionSnapshotQuery;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.assertj.core.util.Lists;
|
|
|
import org.beetl.sql.core.SQLReady;
|
|
|
import org.beetl.sql.core.SqlId;
|
|
|
import org.beetl.sql.core.engine.PageQuery;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import javax.annotation.Nullable;
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
import java.io.*;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
|
|
|
import static cn.jlw.util.CacheUserUtil.getStudent;
|
|
|
import static com.ibeetl.admin.core.util.ExcelUtil.getCellFormatValue;
|
|
|
|
|
|
/**
|
|
|
* 通用题目快照 Service
|
|
|
* 当分布式ID开启后请勿使用insert(*,true)
|
|
|
*/
|
|
|
|
|
|
@Service
|
|
|
@Transactional
|
|
|
@Validated
|
|
|
public class GeneralResourcesQuestionSnapshotService extends CoreBaseService<GeneralResourcesQuestionSnapshot>{
|
|
|
|
|
|
@Autowired private GeneralResourcesQuestionSnapshotDao generalResourcesQuestionSnapshotDao;
|
|
|
|
|
|
public PageQuery<GeneralResourcesQuestionSnapshot>queryByCondition(PageQuery query){
|
|
|
PageQuery ret = generalResourcesQuestionSnapshotDao.queryByCondition(query);
|
|
|
queryListAfter(ret.getList());
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
public PageQuery<GeneralResourcesQuestionSnapshot>queryByConditionQuery(PageQuery query){
|
|
|
PageQuery ret = generalResourcesQuestionSnapshotDao.queryByConditionQuery(query);
|
|
|
queryListAfter(ret.getList());
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
public void deleteByList(List list){
|
|
|
String ids = "";
|
|
|
ToolUtils.deleteNullList(list);
|
|
|
for(int i=0;null != list && i<list.size();i++){
|
|
|
ids += list.get(i).toString()+(i==list.size()-1?"":",");
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(ids)){
|
|
|
generalResourcesQuestionSnapshotDao.deleteGeneralResourcesQuestionSnapshotByIds(ids);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void deleteGeneralResourcesQuestionSnapshot(String ids){
|
|
|
try {
|
|
|
generalResourcesQuestionSnapshotDao.deleteGeneralResourcesQuestionSnapshotByIds(ids);
|
|
|
} catch (Exception e) {
|
|
|
throw new PlatformException("批量删除通用题目快照失败", e);
|
|
|
}
|
|
|
}
|
|
|
public void deleteBySettingIds(String ids){
|
|
|
try {
|
|
|
generalResourcesQuestionSnapshotDao.deleteBySettingIds(ids);
|
|
|
} catch (Exception e) {
|
|
|
throw new PlatformException("批量删除通用题目快照失败", e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public String addAll(GeneralResourcesQuestionSnapshotQuery generalResourcesQuestionSnapshotQuery){
|
|
|
String msg = "";
|
|
|
List<GeneralResourcesQuestionSnapshot> generalResourcesQuestionSnapshotList = new ArrayList<>();
|
|
|
try {
|
|
|
generalResourcesQuestionSnapshotList = JSON.parseArray(generalResourcesQuestionSnapshotQuery.getGeneralResourcesQuestionSnapshotJsonStr(), GeneralResourcesQuestionSnapshot.class);
|
|
|
} catch (Exception e) {
|
|
|
try {
|
|
|
generalResourcesQuestionSnapshotList.add(JSONObject.parseObject(generalResourcesQuestionSnapshotQuery.getGeneralResourcesQuestionSnapshotJsonStr(), GeneralResourcesQuestionSnapshot.class));
|
|
|
} catch (Exception e1) {}
|
|
|
}
|
|
|
ToolUtils.deleteNullList(generalResourcesQuestionSnapshotList);
|
|
|
if(null != generalResourcesQuestionSnapshotList && generalResourcesQuestionSnapshotList.size()>0){
|
|
|
for(int i=0;i<generalResourcesQuestionSnapshotList.size();i++){
|
|
|
GeneralResourcesQuestionSnapshot generalResourcesQuestionSnapshot = generalResourcesQuestionSnapshotList.get(i);
|
|
|
generalResourcesQuestionSnapshot.setUserId(generalResourcesQuestionSnapshotQuery.getUserId());
|
|
|
generalResourcesQuestionSnapshot.setOrgId(generalResourcesQuestionSnapshotQuery.getOrgId());
|
|
|
}
|
|
|
insertBatch(generalResourcesQuestionSnapshotList);
|
|
|
}
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
public JsonResult add(GeneralResourcesQuestionSnapshotQuery generalResourcesQuestionSnapshotQuery){
|
|
|
String msg = "";
|
|
|
GeneralResourcesQuestionSnapshot generalResourcesQuestionSnapshot = generalResourcesQuestionSnapshotQuery.pojo();
|
|
|
generalResourcesQuestionSnapshotDao.insert(generalResourcesQuestionSnapshot);
|
|
|
generalResourcesQuestionSnapshotQuery.setGeneralResourcesQuestionSnapshotId(generalResourcesQuestionSnapshot.getGeneralResourcesQuestionSnapshotId());
|
|
|
JsonResult jsonResult = new JsonResult();
|
|
|
jsonResult.setData(generalResourcesQuestionSnapshot.getGeneralResourcesQuestionSnapshotId());//自增的ID丢进去
|
|
|
jsonResult.setCode(JsonReturnCode.SUCCESS.getCode());
|
|
|
jsonResult.setMsg(msg);
|
|
|
return jsonResult;
|
|
|
}
|
|
|
|
|
|
public String edit(GeneralResourcesQuestionSnapshotQuery generalResourcesQuestionSnapshotQuery){
|
|
|
String msg = "";
|
|
|
GeneralResourcesQuestionSnapshot generalResourcesQuestionSnapshot = generalResourcesQuestionSnapshotQuery.pojo();
|
|
|
generalResourcesQuestionSnapshotDao.updateTemplateById(generalResourcesQuestionSnapshot);
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
public String updateGivenByIds(GeneralResourcesQuestionSnapshotQuery generalResourcesQuestionSnapshotQuery){
|
|
|
String msg = "";
|
|
|
if(StringUtils.isNotBlank(generalResourcesQuestionSnapshotQuery.get_given())){
|
|
|
boolean flag = generalResourcesQuestionSnapshotDao.updateGivenByIds(generalResourcesQuestionSnapshotQuery) > 0;
|
|
|
if(!flag){
|
|
|
msg = "更新指定参数失败";
|
|
|
}
|
|
|
}else{
|
|
|
msg = "指定参数为空";
|
|
|
}
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
public List<GeneralResourcesQuestionSnapshot> getValues (Object paras){
|
|
|
return sqlManager.select(SqlId.of("jlw.generalResourcesQuestionSnapshot.getGeneralResourcesQuestionSnapshotValues"), GeneralResourcesQuestionSnapshot.class, paras);
|
|
|
}
|
|
|
|
|
|
public List<GeneralResourcesQuestionSnapshot> getValuesByQuery (GeneralResourcesQuestionSnapshotQuery generalResourcesQuestionSnapshotQuery){
|
|
|
return generalResourcesQuestionSnapshotDao.getValuesByQuery(generalResourcesQuestionSnapshotQuery);
|
|
|
}
|
|
|
|
|
|
public List<GeneralResourcesQuestionSnapshot> getValuesByQueryNotWithPermission (GeneralResourcesQuestionSnapshotQuery generalResourcesQuestionSnapshotQuery){
|
|
|
return generalResourcesQuestionSnapshotDao.getValuesByQueryNotWithPermission(generalResourcesQuestionSnapshotQuery);
|
|
|
}
|
|
|
|
|
|
public GeneralResourcesQuestionSnapshot getInfo (Long generalResourcesQuestionSnapshotId){
|
|
|
GeneralResourcesQuestionSnapshotQuery generalResourcesQuestionSnapshotQuery = new GeneralResourcesQuestionSnapshotQuery();
|
|
|
generalResourcesQuestionSnapshotQuery.setGeneralResourcesQuestionSnapshotId(generalResourcesQuestionSnapshotId);
|
|
|
List<GeneralResourcesQuestionSnapshot> list = generalResourcesQuestionSnapshotDao.getValuesByQuery(generalResourcesQuestionSnapshotQuery);
|
|
|
if(null != list && list.size()>0){
|
|
|
return list.get(0);
|
|
|
}else{
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public GeneralResourcesQuestionSnapshot getInfo (GeneralResourcesQuestionSnapshotQuery generalResourcesQuestionSnapshotQuery){
|
|
|
List<GeneralResourcesQuestionSnapshot> list = generalResourcesQuestionSnapshotDao.getValuesByQuery(generalResourcesQuestionSnapshotQuery);
|
|
|
if(null != list && list.size()>0){
|
|
|
return list.get(0);
|
|
|
}else{
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public JsonResult importTemplate(List<FileEntity> fileEntityList,List<Long>list,CoreUser coreUser){
|
|
|
List<String[]>errMsg = new ArrayList<>();
|
|
|
String msg ="";
|
|
|
int count = 0;
|
|
|
Date date = new Date();
|
|
|
for(int item=0;null != fileEntityList && item<fileEntityList.size();item++){
|
|
|
FileEntity fileEntity = fileEntityList.get(item);
|
|
|
if(null != fileEntity){
|
|
|
File file = new File(fileEntity.getAbsoluteUrl());
|
|
|
if(file.exists() && file.isFile() && file.canRead() && ToolUtils.findInSet("xls,xlsx",fileEntity.getFormat())){
|
|
|
Workbook wb = null;
|
|
|
InputStream is = null;
|
|
|
try {
|
|
|
is = new FileInputStream(fileEntity.getAbsoluteUrl());
|
|
|
if("xls".equals(fileEntity.getFormat())){
|
|
|
wb = new HSSFWorkbook(is);
|
|
|
}else if("xlsx".equals(fileEntity.getFormat())){
|
|
|
wb = new XSSFWorkbook(is);
|
|
|
}
|
|
|
} catch (FileNotFoundException e) {
|
|
|
e.printStackTrace();
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
try {
|
|
|
if(null != is){
|
|
|
is.close();
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
if(wb != null){
|
|
|
//获取Sheet1
|
|
|
Sheet sheet = wb.getSheet("Sheet1");
|
|
|
//获取最大行数
|
|
|
int rowNum = sheet.getPhysicalNumberOfRows();
|
|
|
//获取第一行
|
|
|
Row firstRow = sheet.getRow(0);
|
|
|
//获取最大列数
|
|
|
int colNum = firstRow.getPhysicalNumberOfCells();
|
|
|
|
|
|
String columns[] = {
|
|
|
"通用题目配置",
|
|
|
"业务课程",
|
|
|
"业务课程类型",
|
|
|
"题型",
|
|
|
"分值",
|
|
|
"题干",
|
|
|
"选项A",
|
|
|
"选项B",
|
|
|
"选项C",
|
|
|
"选项D",
|
|
|
"选项E",
|
|
|
"答案",
|
|
|
"解析",
|
|
|
"题目状态 ",
|
|
|
};
|
|
|
|
|
|
Map<String,Integer> map = new HashMap<>();//获取需要的表头的列
|
|
|
|
|
|
//从第一列找到需要的表头
|
|
|
for (int i=0; i<colNum; i++){
|
|
|
String cellData = getCellFormatValue(firstRow.getCell(i));
|
|
|
for(int j=0;j<columns.length;j++){
|
|
|
if(columns[j].equals(cellData)){
|
|
|
map.put(columns[j],i);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//验证所需要的表头是否全
|
|
|
Integer flag = 0;
|
|
|
for(int i=0;i<columns.length;i++){
|
|
|
if(null != map.get(columns[i])){
|
|
|
flag ++;
|
|
|
}
|
|
|
}
|
|
|
if(flag != columns.length){
|
|
|
String str = " ";
|
|
|
for(int i=0;i<columns.length;i++){
|
|
|
str += "\""+columns[i]+"\""+(i == columns.length-1?"":", ");
|
|
|
}
|
|
|
return JsonResult.failMessage("导入失败,表格表头应包含"+str);
|
|
|
}
|
|
|
|
|
|
for (int i = 1; i<rowNum; i++) {
|
|
|
Row row = sheet.getRow(i);
|
|
|
if(null == row){
|
|
|
errMsg.add(new String[]{"第"+(i+1)+"数据为空"});
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
String generalQuestionSettingId = getCellFormatValue(row.getCell(map.get(columns[0])));
|
|
|
String businessCourseInfoId = getCellFormatValue(row.getCell(map.get(columns[1])));
|
|
|
String businessCourseInfoType = getCellFormatValue(row.getCell(map.get(columns[2])));
|
|
|
String questionType = getCellFormatValue(row.getCell(map.get(columns[3])));
|
|
|
String questionScore = getCellFormatValue(row.getCell(map.get(columns[4])));
|
|
|
String questionStem = getCellFormatValue(row.getCell(map.get(columns[5])));
|
|
|
String questionOptionA = getCellFormatValue(row.getCell(map.get(columns[6])));
|
|
|
String questionOptionB = getCellFormatValue(row.getCell(map.get(columns[7])));
|
|
|
String questionOptionC = getCellFormatValue(row.getCell(map.get(columns[8])));
|
|
|
String questionOptionD = getCellFormatValue(row.getCell(map.get(columns[9])));
|
|
|
String questionOptionE = getCellFormatValue(row.getCell(map.get(columns[10])));
|
|
|
String questionAnswer = getCellFormatValue(row.getCell(map.get(columns[11])));
|
|
|
String questionAnalysis = getCellFormatValue(row.getCell(map.get(columns[12])));
|
|
|
String questionStatus = getCellFormatValue(row.getCell(map.get(columns[13])));
|
|
|
//TODO 判断(如重复等复杂判断要额外写)
|
|
|
if(StringUtils.isBlank(generalQuestionSettingId)){
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[0])+1)+"列,第"+(i+1)+"行通用题目配置为空"});
|
|
|
continue;
|
|
|
}else
|
|
|
if(StringUtils.isBlank(businessCourseInfoId)){
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[1])+1)+"列,第"+(i+1)+"行业务课程为空"});
|
|
|
continue;
|
|
|
}else
|
|
|
if(StringUtils.isBlank(businessCourseInfoType)){
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[2])+1)+"列,第"+(i+1)+"行业务课程类型为空"});
|
|
|
continue;
|
|
|
}else
|
|
|
if(StringUtils.isBlank(questionType)){
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[3])+1)+"列,第"+(i+1)+"行题型为空"});
|
|
|
continue;
|
|
|
}else
|
|
|
if(StringUtils.isBlank(questionScore)){
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[4])+1)+"列,第"+(i+1)+"行分值为空"});
|
|
|
continue;
|
|
|
}else
|
|
|
if(StringUtils.isBlank(questionStem)){
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[5])+1)+"列,第"+(i+1)+"行题干为空"});
|
|
|
continue;
|
|
|
}else
|
|
|
if(StringUtils.isBlank(questionOptionA)){
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[6])+1)+"列,第"+(i+1)+"行选项A为空"});
|
|
|
continue;
|
|
|
}else
|
|
|
if(StringUtils.isBlank(questionOptionB)){
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[7])+1)+"列,第"+(i+1)+"行选项B为空"});
|
|
|
continue;
|
|
|
}else
|
|
|
if(StringUtils.isBlank(questionOptionC)){
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[8])+1)+"列,第"+(i+1)+"行选项C为空"});
|
|
|
continue;
|
|
|
}else
|
|
|
if(StringUtils.isBlank(questionOptionD)){
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[9])+1)+"列,第"+(i+1)+"行选项D为空"});
|
|
|
continue;
|
|
|
}else
|
|
|
if(StringUtils.isBlank(questionOptionE)){
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[10])+1)+"列,第"+(i+1)+"行选项E为空"});
|
|
|
continue;
|
|
|
}else
|
|
|
if(StringUtils.isBlank(questionAnswer)){
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[11])+1)+"列,第"+(i+1)+"行答案为空"});
|
|
|
continue;
|
|
|
}else
|
|
|
if(StringUtils.isBlank(questionAnalysis)){
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[12])+1)+"列,第"+(i+1)+"行解析为空"});
|
|
|
continue;
|
|
|
}else
|
|
|
if(StringUtils.isBlank(questionStatus)){
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[13])+1)+"列,第"+(i+1)+"行题目状态 为空"});
|
|
|
continue;
|
|
|
}else
|
|
|
{
|
|
|
//TODO 保存
|
|
|
GeneralResourcesQuestionSnapshot generalResourcesQuestionSnapshot = new GeneralResourcesQuestionSnapshot();
|
|
|
generalResourcesQuestionSnapshot.setGeneralQuestionSettingId(Long.parseLong(generalQuestionSettingId));
|
|
|
generalResourcesQuestionSnapshot.setBusinessCourseInfoId(Long.parseLong(businessCourseInfoId));
|
|
|
generalResourcesQuestionSnapshot.setBusinessCourseInfoType(EnumUtil.likeValueOf(BusinessCourseInfoEnum.class, businessCourseInfoType));
|
|
|
generalResourcesQuestionSnapshot.setQuestionType(Integer.parseInt(questionType));
|
|
|
generalResourcesQuestionSnapshot.setQuestionScore(new BigDecimal(questionScore));
|
|
|
generalResourcesQuestionSnapshot.setQuestionStem(questionStem);
|
|
|
generalResourcesQuestionSnapshot.setQuestionOptionA(questionOptionA);
|
|
|
generalResourcesQuestionSnapshot.setQuestionOptionB(questionOptionB);
|
|
|
generalResourcesQuestionSnapshot.setQuestionOptionC(questionOptionC);
|
|
|
generalResourcesQuestionSnapshot.setQuestionOptionD(questionOptionD);
|
|
|
generalResourcesQuestionSnapshot.setQuestionOptionE(questionOptionE);
|
|
|
generalResourcesQuestionSnapshot.setQuestionAnswer(questionAnswer);
|
|
|
generalResourcesQuestionSnapshot.setQuestionAnalysis(questionAnalysis);
|
|
|
generalResourcesQuestionSnapshot.setQuestionStatus(Integer.parseInt(questionStatus));
|
|
|
generalResourcesQuestionSnapshot.setUserId(coreUser.getId());
|
|
|
generalResourcesQuestionSnapshot.setOrgId(coreUser.getOrgId());
|
|
|
|
|
|
count++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
JsonResult jsonResult = new JsonResult();
|
|
|
jsonResult.setCode(count>0?JsonReturnCode.SUCCESS.getCode():JsonReturnCode.FAIL.getCode());
|
|
|
jsonResult.setData(errMsg);
|
|
|
jsonResult.setMsg((count>0?"导入成功,共导入"+count+"条":"导入失败")+(StringUtils.isNotBlank(msg)?"<br>"+msg:""));
|
|
|
return jsonResult;
|
|
|
}
|
|
|
|
|
|
public List<Map<String,Object>> getExcelValues (GeneralResourcesQuestionSnapshotQuery generalResourcesQuestionSnapshotQuery){
|
|
|
return generalResourcesQuestionSnapshotDao.getExcelValues(generalResourcesQuestionSnapshotQuery);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据课程新旧ID片段集合,设置新的课程ID
|
|
|
*
|
|
|
* @param insertList
|
|
|
* @param courseInfoIdPair
|
|
|
*/
|
|
|
public void setNewCourseInfoId(Collection<GeneralResourcesQuestionSnapshot> insertList, Map<Long, Long> courseInfoIdPair) {
|
|
|
if (ObjectUtil.isAllNotEmpty(insertList, courseInfoIdPair)) {
|
|
|
insertList.forEach(item -> {
|
|
|
Long courseMergeCourseInfoId = item.getBusinessCourseInfoId();
|
|
|
item.setBusinessCourseInfoId(courseInfoIdPair.getOrDefault(courseMergeCourseInfoId, courseMergeCourseInfoId));
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 从开课题库中获取题目。可以单独设置类型下的分数
|
|
|
*
|
|
|
* @param questionSettingOptions 根据题型动态分配题目
|
|
|
* @param courseInfoIdPair 新旧课程ID片段
|
|
|
*/
|
|
|
public List<GeneralResourcesQuestionSnapshot> getQuestionBySettingOptionDTOList(@Nullable Collection<QuestionSettingDTO> questionSettingOptions, Map<Long, Long> courseInfoIdPair) {
|
|
|
// 题目设置,来动态获取题目
|
|
|
if(ObjectUtil.isNotEmpty(questionSettingOptions)) {
|
|
|
List<GeneralResourcesQuestionSnapshot> result = new ArrayList<>();
|
|
|
|
|
|
for (QuestionSettingDTO questionSettingOption : questionSettingOptions) {
|
|
|
// 数据库动态设置分数,并获取题目列表
|
|
|
List<GeneralResourcesQuestionSnapshot> insertList =
|
|
|
generalResourcesQuestionSnapshotDao.getQuestionBySettingOptionDTO(questionSettingOption);
|
|
|
if (ObjectUtil.isNotEmpty(insertList)) {
|
|
|
setNewCourseInfoId(insertList, courseInfoIdPair);
|
|
|
result.addAll(insertList);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
return Lists.emptyList();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 简单获取题目的信息
|
|
|
* @param query 开课题目配置ID
|
|
|
* @return
|
|
|
*/
|
|
|
public PageQuery<GeneralQuestionTestSimpleInfoVO> getQuestionTestSimpleInfo(GeneralQuestionTestSimpleInfoDTO query) {
|
|
|
Student student = getStudent();
|
|
|
Assert.notNull(student, "该接口只允许学生访问");
|
|
|
PageQuery pageQuery = query.getPageQuery(); pageQuery.setPara("studentId", student.getStudentId());
|
|
|
PageQuery<GeneralQuestionTestSimpleInfoVO> questionTestSimpleInfo = generalResourcesQuestionSnapshotDao.getQuestionTestSimpleInfo(pageQuery);
|
|
|
dictParser(questionTestSimpleInfo.getList());
|
|
|
return questionTestSimpleInfo;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 学生端-开课相关
|
|
|
* 查询学生的得分信息
|
|
|
*
|
|
|
* @param questionSettingId 题目配置ID
|
|
|
* @return
|
|
|
*/
|
|
|
public GeneralQuestionLogScoreInfo getScoreInfo(@NotNull(message = "开课题目配置ID不能为空!") final Long questionSettingId) {
|
|
|
|
|
|
// 查询学生身份
|
|
|
Student student = getStudent();
|
|
|
Assert.notNull(student, "该接口只能学生访问");
|
|
|
|
|
|
// 给实体类传参数,剩下来的交给Fetch 来处理
|
|
|
// 查询符合条件的实体
|
|
|
GeneralQuestionLogScoreInfo scoreInfo = sqlManager.executeQueryOne(
|
|
|
new SQLReady("SELECT " +
|
|
|
"? as general_question_setting_id, " +
|
|
|
"? as student_id ",
|
|
|
questionSettingId, student.getStudentId()
|
|
|
),
|
|
|
GeneralQuestionLogScoreInfo.class
|
|
|
);
|
|
|
dictParser(scoreInfo);
|
|
|
return scoreInfo;
|
|
|
}
|
|
|
}
|