mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-08 02:16:49 +08:00
Compare commits
3 Commits
master-104
...
zcwy-0913-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce1dae3ed2 | ||
|
|
4b1947bf06 | ||
|
|
39ba96f141 |
@@ -12,13 +12,16 @@ public class CaseScheduledTasks {
|
||||
@Resource
|
||||
private ICasesService casesService;
|
||||
|
||||
@Scheduled(cron = "0 0 1 1 * ?") // 每月的第一天的1:00执行
|
||||
/**
|
||||
* 每月的第一天的1:00执行
|
||||
*/
|
||||
@Scheduled(cron = "0 0 1 1 * ?")
|
||||
public void refreshViewsRankOfMajor() {
|
||||
casesService.refreshViewsRankOfMajor();
|
||||
}
|
||||
|
||||
/**
|
||||
* 季初执行,cron表达式设置为每个季度的第一个月的第一天的特定时间。每个季度的第一个月是1月、4月、7月和10月:
|
||||
* 季初第一天两点执行,cron表达式设置为每个季度的第一个月的第一天的特定时间。每个季度的第一个月是1月、4月、7月和10月:
|
||||
*/
|
||||
@Scheduled(cron = "0 0 2 1 1,4,7,10 ?")
|
||||
public void refreshLastQuarterStatistics() {
|
||||
|
||||
@@ -132,25 +132,7 @@ public class CasesApi extends ApiBaseController {
|
||||
views = casesService.queryPageCasesV2(req);
|
||||
}
|
||||
|
||||
if (views != null) {
|
||||
List<Cases> cases = views.getList();
|
||||
if (CollUtil.isNotEmpty(cases)) {
|
||||
for (Cases c : cases) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
List<CasesMajorType> caseId = casesMajorTypeDao.findList(FieldFilters.eq("caseId", c.getId()));
|
||||
if (caseId != null && !caseId.isEmpty()) {
|
||||
for (CasesMajorType cm : caseId) {
|
||||
stringBuffer.append(cm.getMajorId());
|
||||
stringBuffer.append(",");
|
||||
}
|
||||
}
|
||||
if (stringBuffer.length() > 0) {
|
||||
stringBuffer.deleteCharAt(stringBuffer.length() - 1);
|
||||
c.setMajorType(stringBuffer.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (views == null) {
|
||||
views = new PageList();
|
||||
views.setList(Collections.emptyList());
|
||||
views.setPageSize(req.getPageSize());
|
||||
|
||||
@@ -15,7 +15,9 @@ import java.util.stream.Collectors;
|
||||
@Repository
|
||||
@Slf4j
|
||||
public class CasesRankDao extends BaseDao<CasesRank> {
|
||||
|
||||
/**
|
||||
* 获取类别榜记录,默认按上榜时间降序排列
|
||||
*/
|
||||
public List<CasesRank> findViewsRankRecordByCaseId(String caseId) {
|
||||
String sql =
|
||||
"SELECT bdmt.name,bcvr.rise_rank_time,bcvr.rank,bcvr.major_id \n" +
|
||||
@@ -24,8 +26,7 @@ public class CasesRankDao extends BaseDao<CasesRank> {
|
||||
"JOIN boe_dict_major_type bdmt \n" +
|
||||
" ON bdmt.code = bcvr.major_id \n" +
|
||||
"WHERE bcvr.case_id = ?1 AND bcvr.deleted=0 AND bdmt.deleted=0\n" +
|
||||
"ORDER BY bcvr.sys_update_time DESC \n" +
|
||||
"LIMIT 2;";
|
||||
"ORDER BY bcvr.rise_rank_time DESC;";
|
||||
|
||||
List<Object[]> list = this.sqlFindList(sql, caseId);
|
||||
|
||||
|
||||
@@ -416,14 +416,36 @@ public class CasesServiceImpl implements ICasesService {
|
||||
if (CollUtil.isEmpty(casesList)) {
|
||||
return casesList;
|
||||
}
|
||||
|
||||
//1.推荐案例数据处理
|
||||
recommendCasesDataHandle(casesList, accountId);
|
||||
//2.标签处理,添加作者标签和新的案例标签
|
||||
addAuthorTagAndCaseNewTag(casesList);
|
||||
//3.案例类型处理
|
||||
majorTypeHandle(casesList);
|
||||
|
||||
return casesList;
|
||||
}
|
||||
|
||||
private void majorTypeHandle(List<Cases> casesList) {
|
||||
if (CollUtil.isNotEmpty(casesList)) {
|
||||
for (Cases c : casesList) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
List<CasesMajorType> caseId = casesMajorTypeDao.findList(FieldFilters.eq("caseId", c.getId()));
|
||||
if (caseId != null && !caseId.isEmpty()) {
|
||||
for (CasesMajorType cm : caseId) {
|
||||
stringBuffer.append(cm.getMajorId());
|
||||
stringBuffer.append(",");
|
||||
}
|
||||
}
|
||||
if (stringBuffer.length() > 0) {
|
||||
stringBuffer.deleteCharAt(stringBuffer.length() - 1);
|
||||
c.setMajorType(stringBuffer.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void recommendCasesDataHandle(List<Cases> casesList, String accountId) {
|
||||
if (StrUtil.isNotBlank(accountId)) {
|
||||
List<String> caseIdList = casesList.stream().map(Cases::getId).collect(Collectors.toList());
|
||||
@@ -483,7 +505,7 @@ public class CasesServiceImpl implements ICasesService {
|
||||
|
||||
|
||||
caseList.forEach(e -> {
|
||||
// 获取最新的两个浏览量上榜记录
|
||||
// 获取浏览量上榜记录
|
||||
List<CasesRank> viewsRankRecords = casesRankDao.findViewsRankRecordByCaseId(e.getId());
|
||||
if (CollUtil.isNotEmpty(viewsRankRecords)) {
|
||||
// 拼接生成浏览量排行榜的标签
|
||||
@@ -1181,16 +1203,10 @@ public class CasesServiceImpl implements ICasesService {
|
||||
}
|
||||
|
||||
//获取案例当月排名
|
||||
// String sql =
|
||||
// "SELECT bc.id,bcmt.major_id,bc.views - COALESCE(bc.last_month_views, 0) AS increment\n" +
|
||||
// "FROM boe_cases bc\n" +
|
||||
// "JOIN boe_cases_major_type bcmt ON bcmt.case_id = bc.id and bc.deleted=0 and file_path is not null and file_path!='' and bc.views - COALESCE(bc.last_month_views, 0)!=0";
|
||||
|
||||
String sql =
|
||||
"SELECT bc.id,bcmt.major_id,bc.views AS increment\n" +
|
||||
"FROM boe_cases bc\n" +
|
||||
"JOIN boe_cases_major_type bcmt ON bcmt.case_id = bc.id and bc.deleted=0 and file_path is not null and file_path!='' and bc.views !=0 and bc.views is not null";
|
||||
|
||||
"SELECT bc.id,bcmt.major_id,bc.views - COALESCE(bc.last_month_views, 0) AS increment\n" +
|
||||
"FROM boe_cases bc\n" +
|
||||
"JOIN boe_cases_major_type bcmt ON bcmt.case_id = bc.id and bc.deleted=0 and file_path is not null and file_path!='' and bc.views - COALESCE(bc.last_month_views, 0)!=0";
|
||||
List<Object> caseListOfObject = casesDao.sqlFindList(sql);
|
||||
|
||||
// 转为casesRank
|
||||
@@ -1231,7 +1247,7 @@ public class CasesServiceImpl implements ICasesService {
|
||||
@Override
|
||||
public void refreshLastQuarterStatistics() {
|
||||
log.info("开始执行每季案例相关定时任务");
|
||||
int i = casesDao.sqlUpdate("update boe_cases set last_quarter_views=views,last_quarter_praise=praise where deleted=0");
|
||||
int i = casesDao.sqlUpdate("update boe_cases set last_quarter_views=views,last_quarter_praises=praises where deleted=0");
|
||||
log.info("每季案例相关定时任务执行完成,boe_cases更新数据量为条数为"+i);
|
||||
}
|
||||
|
||||
@@ -1283,15 +1299,18 @@ public class CasesServiceImpl implements ICasesService {
|
||||
List<HashMap<String, Object>> popularityOfMajor = casesRankDao.findPopularityOfMajor(pageSize, startTime, endTime, majorId);
|
||||
List<String> caseIdList = popularityOfMajor.stream().map(map -> map.get("caseId").toString()).collect(Collectors.toList());
|
||||
|
||||
Map<Object, Integer> collect = popularityOfMajor.stream().collect(Collectors.toMap(map -> map.get("caseId").toString(), map -> Integer.valueOf(map.get("rank").toString())));
|
||||
|
||||
QueryBuilder query = QueryBuilder.from(Cases.class);
|
||||
query.addFilter(FieldFilters.in("id",caseIdList));
|
||||
query.addFilter(FieldFilters.eq("deleted",false));
|
||||
|
||||
List<Cases> casesList = casesDao.findList(query.builder());
|
||||
//处理案例数据-通用操作
|
||||
casesList = caseListCommonHandle(casesList, accountId);
|
||||
//获取案例与排名的映射关系
|
||||
Map<Object, Integer> collect = popularityOfMajor.stream().collect(Collectors.toMap(map -> map.get("caseId").toString(), map -> Integer.valueOf(map.get("rank").toString())));
|
||||
|
||||
//排序榜单案例顺序
|
||||
Collections.sort(casesList, new Comparator<Cases>() {
|
||||
@Override
|
||||
public int compare(Cases c1, Cases c2) {
|
||||
@@ -1300,6 +1319,23 @@ public class CasesServiceImpl implements ICasesService {
|
||||
return Integer.compare(order1, order2);
|
||||
}
|
||||
});
|
||||
|
||||
//排序榜单案例标签顺序
|
||||
casesList.forEach(cases -> {
|
||||
List<CaseViewRankingItemVo> viewRankTags = cases.getViewRankTags();
|
||||
Collections.sort(viewRankTags, new Comparator<CaseViewRankingItemVo>() {
|
||||
@Override
|
||||
public int compare(CaseViewRankingItemVo o1, CaseViewRankingItemVo o2) {
|
||||
// 将 majorId 等于 传参majorId 的项优先排序
|
||||
if (o1.getMajorId().equals(majorId) && !o2.getMajorId().equals(majorId)) {
|
||||
return -1; // o1 应该排在 o2 前面
|
||||
} else if (!o1.getMajorId().equals(majorId) && o2.getMajorId().equals(majorId)) {
|
||||
return 1; // o2 应该排在 o1 前面
|
||||
}
|
||||
return 0; // 相同或两者都不是 传参majorId 时,保持原有顺序
|
||||
}
|
||||
});
|
||||
});
|
||||
return casesList;
|
||||
}
|
||||
|
||||
|
||||
@@ -166,231 +166,118 @@ public class ExamQuestionApi extends ApiBaseController {
|
||||
return badRequest("请上传正确的试题文件");
|
||||
}
|
||||
//获取表头
|
||||
Row row ;
|
||||
Row row = sheetAt.getRow(2);
|
||||
//从第二行开始获取数据
|
||||
List<ExamQuestion> examQuestions1 = new ArrayList<>();
|
||||
QuestionDto questionDto = new QuestionDto();
|
||||
if(sheetAt.getRow(1).getCell(0).getStringCellValue().equals("标题(*)")){
|
||||
row = sheetAt.getRow(1);
|
||||
for (int i = 2;i<sheetAt.getPhysicalNumberOfRows();i++) {
|
||||
//获取每一行
|
||||
|
||||
Row row1 = sheetAt.getRow(i);
|
||||
if(row1==null || row1.getCell(0)==null){
|
||||
break;
|
||||
}
|
||||
if(StringUtil.isBlank(row1.getCell(0).getStringCellValue())){
|
||||
break;
|
||||
}
|
||||
ExamQuestion examQuestion = new ExamQuestion();
|
||||
examQuestion.setTitle(row1.getCell(0).getStringCellValue());
|
||||
if(row1.getCell(1).getStringCellValue().equals("单选题")){
|
||||
examQuestion.setType(1);
|
||||
}
|
||||
if(row1.getCell(1).getStringCellValue().equals("多选题")){
|
||||
examQuestion.setType(2);
|
||||
}
|
||||
examQuestion.setKnowledge(row1.getCell(2).getStringCellValue());
|
||||
if(row1.getCell(3).getStringCellValue().equals("中")){
|
||||
examQuestion.setDifficulty(2f);
|
||||
}
|
||||
if(row1.getCell(3).getStringCellValue().equals("难")){
|
||||
examQuestion.setDifficulty(3f);
|
||||
}
|
||||
if(row1.getCell(3).getStringCellValue().equals("低")){
|
||||
examQuestion.setDifficulty(1f);
|
||||
}
|
||||
Cell cell = row1.getCell(4);
|
||||
cell.setCellType(CellType.STRING);
|
||||
for (int i=3;i<sheetAt.getPhysicalNumberOfRows();i++) {
|
||||
//获取每一行
|
||||
|
||||
// examQuestion.setDefaultScore(Float.valueOf(cell.getStringCellValue()));
|
||||
|
||||
//单选
|
||||
if (!cell.getStringCellValue().contains(",")){
|
||||
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
|
||||
examQuestion.setDefaultScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
||||
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
||||
cell1.setCellType(CellType.STRING);
|
||||
examQuestion.setAnalysis(cell1.getStringCellValue());
|
||||
|
||||
List<ExamOption> examOptions = new ArrayList<>();
|
||||
for (int j=7;j<=13;j++) {
|
||||
|
||||
if(row1.getCell(j)!=null) {
|
||||
ExamOption examOption = new ExamOption();
|
||||
// 截取表头
|
||||
String substring = row.getCell(j).getStringCellValue().substring(3, 4);
|
||||
if (row1.getCell(6).getStringCellValue().contains(substring)) {
|
||||
|
||||
examOption.setIsAnswer(true);
|
||||
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
||||
} else {
|
||||
examOption.setIsAnswer(false);
|
||||
}
|
||||
if (examOption.getIsAnswer()) {
|
||||
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
||||
}
|
||||
|
||||
examOption.setOptions(row.getCell(j).getStringCellValue());
|
||||
|
||||
Cell cell2 = row1.getCell(j);
|
||||
cell2.setCellType(CellType.STRING);
|
||||
examOption.setContent(cell2.getStringCellValue());
|
||||
|
||||
if (examOption != null && StringUtil.isNotBlank(examOption.getContent())) {
|
||||
examOptions.add(examOption);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
examQuestion.setOptionList(examOptions);
|
||||
examQuestions1.add(examQuestion);
|
||||
}
|
||||
//多选 多选的默认分存的是最大分
|
||||
else{
|
||||
String stringCellValue = row1.getCell(4).getStringCellValue();
|
||||
String[] strings = stringCellValue.split(",");
|
||||
// String[] strings = new String[stringCellValue.length()];
|
||||
String max=strings[0];
|
||||
for (int j=0;j<strings.length;j++) {
|
||||
if(Float.valueOf(max)<Float.valueOf(strings[j])){
|
||||
max=strings[j];
|
||||
}
|
||||
}
|
||||
examQuestion.setDefaultScore(Float.valueOf(max));
|
||||
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
||||
cell1.setCellType(CellType.STRING);
|
||||
examQuestion.setAnalysis(cell1.getStringCellValue());
|
||||
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
|
||||
List<ExamOption> examOptions = new ArrayList<>();
|
||||
//A
|
||||
for (int j=7;j<=13;j++){
|
||||
if(row1.getCell(j)!=null && StringUtil.isNotBlank(row1.getCell(j).getStringCellValue())){
|
||||
ExamOption examOption=new ExamOption();
|
||||
examOption.setOptions(row.getCell(j).getStringCellValue());
|
||||
examOption.setContent(row1.getCell(j).getStringCellValue());
|
||||
examOption.setIsAnswer(true);
|
||||
examOption.setScore(Float.valueOf(strings[j-7]));
|
||||
if(examOption!=null && StringUtil.isNotBlank(examOption.getContent())){
|
||||
examOptions.add(examOption);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
examQuestion.setOptionList(examOptions);
|
||||
examQuestions1.add(examQuestion);
|
||||
}
|
||||
Row row1 = sheetAt.getRow(i);
|
||||
if(row1==null || row1.getCell(0)==null){
|
||||
break;
|
||||
}
|
||||
}else {
|
||||
row = sheetAt.getRow(2);
|
||||
for (int i = 3;i<sheetAt.getPhysicalNumberOfRows();i++) {
|
||||
//获取每一行
|
||||
|
||||
Row row1 = sheetAt.getRow(i);
|
||||
if(row1==null || row1.getCell(0)==null){
|
||||
break;
|
||||
}
|
||||
if(StringUtil.isBlank(row1.getCell(0).getStringCellValue())){
|
||||
break;
|
||||
}
|
||||
ExamQuestion examQuestion = new ExamQuestion();
|
||||
examQuestion.setTitle(row1.getCell(0).getStringCellValue());
|
||||
if(row1.getCell(1).getStringCellValue().equals("单选题")){
|
||||
examQuestion.setType(1);
|
||||
}
|
||||
if(row1.getCell(1).getStringCellValue().equals("多选题")){
|
||||
examQuestion.setType(2);
|
||||
}
|
||||
examQuestion.setKnowledge(row1.getCell(2).getStringCellValue());
|
||||
if(row1.getCell(3).getStringCellValue().equals("中")){
|
||||
examQuestion.setDifficulty(2f);
|
||||
}
|
||||
if(row1.getCell(3).getStringCellValue().equals("难")){
|
||||
examQuestion.setDifficulty(3f);
|
||||
}
|
||||
if(row1.getCell(3).getStringCellValue().equals("低")){
|
||||
examQuestion.setDifficulty(1f);
|
||||
}
|
||||
Cell cell = row1.getCell(4);
|
||||
cell.setCellType(CellType.STRING);
|
||||
if(StringUtil.isBlank(row1.getCell(0).getStringCellValue())){
|
||||
break;
|
||||
}
|
||||
ExamQuestion examQuestion = new ExamQuestion();
|
||||
examQuestion.setTitle(row1.getCell(0).getStringCellValue());
|
||||
if(row1.getCell(1).getStringCellValue().equals("单选题")){
|
||||
examQuestion.setType(1);
|
||||
}
|
||||
if(row1.getCell(1).getStringCellValue().equals("多选题")){
|
||||
examQuestion.setType(2);
|
||||
}
|
||||
examQuestion.setKnowledge(row1.getCell(2).getStringCellValue());
|
||||
if(row1.getCell(3).getStringCellValue().equals("中")){
|
||||
examQuestion.setDifficulty(2f);
|
||||
}
|
||||
if(row1.getCell(3).getStringCellValue().equals("难")){
|
||||
examQuestion.setDifficulty(3f);
|
||||
}
|
||||
if(row1.getCell(3).getStringCellValue().equals("低")){
|
||||
examQuestion.setDifficulty(1f);
|
||||
}
|
||||
Cell cell = row1.getCell(4);
|
||||
cell.setCellType(CellType.STRING);
|
||||
|
||||
// examQuestion.setDefaultScore(Float.valueOf(cell.getStringCellValue()));
|
||||
|
||||
//单选
|
||||
if (!cell.getStringCellValue().contains(",")){
|
||||
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
|
||||
examQuestion.setDefaultScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
||||
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
||||
cell1.setCellType(CellType.STRING);
|
||||
examQuestion.setAnalysis(cell1.getStringCellValue());
|
||||
//单选
|
||||
if (!cell.getStringCellValue().contains(",")){
|
||||
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
|
||||
examQuestion.setDefaultScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
||||
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
||||
cell1.setCellType(CellType.STRING);
|
||||
examQuestion.setAnalysis(cell1.getStringCellValue());
|
||||
|
||||
List<ExamOption> examOptions = new ArrayList<>();
|
||||
for (int j=7;j<=13;j++) {
|
||||
List<ExamOption> examOptions = new ArrayList<>();
|
||||
for (int j=7;j<=13;j++) {
|
||||
|
||||
if(row1.getCell(j)!=null) {
|
||||
ExamOption examOption = new ExamOption();
|
||||
if(row1.getCell(j)!=null) {
|
||||
ExamOption examOption = new ExamOption();
|
||||
// 截取表头
|
||||
String substring = row.getCell(j).getStringCellValue().substring(3, 4);
|
||||
if (row1.getCell(6).getStringCellValue().contains(substring)) {
|
||||
String substring = row.getCell(j).getStringCellValue().substring(3, 4);
|
||||
if (row1.getCell(6).getStringCellValue().contains(substring)) {
|
||||
|
||||
examOption.setIsAnswer(true);
|
||||
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
||||
} else {
|
||||
examOption.setIsAnswer(false);
|
||||
}
|
||||
if (examOption.getIsAnswer()) {
|
||||
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
||||
}
|
||||
|
||||
examOption.setOptions(row.getCell(j).getStringCellValue());
|
||||
|
||||
Cell cell2 = row1.getCell(j);
|
||||
cell2.setCellType(CellType.STRING);
|
||||
examOption.setContent(cell2.getStringCellValue());
|
||||
|
||||
if (examOption != null && StringUtil.isNotBlank(examOption.getContent())) {
|
||||
examOptions.add(examOption);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
examQuestion.setOptionList(examOptions);
|
||||
examQuestions1.add(examQuestion);
|
||||
}
|
||||
//多选 多选的默认分存的是最大分
|
||||
else{
|
||||
String stringCellValue = row1.getCell(4).getStringCellValue();
|
||||
String[] strings = stringCellValue.split(",");
|
||||
// String[] strings = new String[stringCellValue.length()];
|
||||
String max=strings[0];
|
||||
for (int j=0;j<strings.length;j++) {
|
||||
if(Float.valueOf(max)<Float.valueOf(strings[j])){
|
||||
max=strings[j];
|
||||
}
|
||||
}
|
||||
examQuestion.setDefaultScore(Float.valueOf(max));
|
||||
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
||||
cell1.setCellType(CellType.STRING);
|
||||
examQuestion.setAnalysis(cell1.getStringCellValue());
|
||||
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
|
||||
List<ExamOption> examOptions = new ArrayList<>();
|
||||
//A
|
||||
for (int j=7;j<=13;j++){
|
||||
if(row1.getCell(j)!=null && StringUtil.isNotBlank(row1.getCell(j).getStringCellValue())){
|
||||
ExamOption examOption=new ExamOption();
|
||||
examOption.setOptions(row.getCell(j).getStringCellValue());
|
||||
examOption.setContent(row1.getCell(j).getStringCellValue());
|
||||
examOption.setIsAnswer(true);
|
||||
examOption.setScore(Float.valueOf(strings[j-7]));
|
||||
if(examOption!=null && StringUtil.isNotBlank(examOption.getContent())){
|
||||
examOptions.add(examOption);
|
||||
}
|
||||
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
||||
} else {
|
||||
examOption.setIsAnswer(false);
|
||||
}
|
||||
if (examOption.getIsAnswer()) {
|
||||
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
||||
}
|
||||
|
||||
examOption.setOptions(row.getCell(j).getStringCellValue());
|
||||
|
||||
Cell cell2 = row1.getCell(j);
|
||||
cell2.setCellType(CellType.STRING);
|
||||
examOption.setContent(cell2.getStringCellValue());
|
||||
|
||||
if (examOption != null && StringUtil.isNotBlank(examOption.getContent())) {
|
||||
examOptions.add(examOption);
|
||||
}
|
||||
}
|
||||
examQuestion.setOptionList(examOptions);
|
||||
examQuestions1.add(examQuestion);
|
||||
}
|
||||
|
||||
examQuestion.setOptionList(examOptions);
|
||||
examQuestions1.add(examQuestion);
|
||||
}
|
||||
//多选 多选的默认分存的是最大分
|
||||
else{
|
||||
String stringCellValue = row1.getCell(4).getStringCellValue();
|
||||
String[] strings = stringCellValue.split(",");
|
||||
// String[] strings = new String[stringCellValue.length()];
|
||||
String max=strings[0];
|
||||
for (int j=0;j<strings.length;j++) {
|
||||
if(Float.valueOf(max)<Float.valueOf(strings[j])){
|
||||
max=strings[j];
|
||||
}
|
||||
}
|
||||
examQuestion.setDefaultScore(Float.valueOf(max));
|
||||
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
||||
cell1.setCellType(CellType.STRING);
|
||||
examQuestion.setAnalysis(cell1.getStringCellValue());
|
||||
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
|
||||
List<ExamOption> examOptions = new ArrayList<>();
|
||||
//A
|
||||
for (int j=7;j<=13;j++){
|
||||
if(row1.getCell(j)!=null && StringUtil.isNotBlank(row1.getCell(j).getStringCellValue())){
|
||||
ExamOption examOption=new ExamOption();
|
||||
examOption.setOptions(row.getCell(j).getStringCellValue());
|
||||
examOption.setContent(row1.getCell(j).getStringCellValue());
|
||||
examOption.setIsAnswer(true);
|
||||
examOption.setScore(Float.valueOf(strings[j-7]));
|
||||
if(examOption!=null && StringUtil.isNotBlank(examOption.getContent())){
|
||||
examOptions.add(examOption);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
examQuestion.setOptionList(examOptions);
|
||||
examQuestions1.add(examQuestion);
|
||||
}
|
||||
}
|
||||
//判断题 只存在试题表中
|
||||
|
||||
Reference in New Issue
Block a user