package com.walker.etaa;
|
|
import com.walker.etaa.extractor.SimpleQuestionExtractor;
|
import com.walker.infrastructure.utils.StringUtils;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
public class DemoSimpleExtractor extends SimpleQuestionExtractor<Object> {
|
|
private List<QuestionAlgorithm> data = null;
|
|
@Override
|
protected long acquireGlobalTotal(String ownerId, String deptId, String rootCatalog) {
|
if(StringUtils.isEmpty(rootCatalog)){
|
switch (ownerId){
|
case "default":
|
return 21;
|
case "mike":
|
return 10;
|
}
|
} else {
|
if(ownerId.equalsIgnoreCase("default")){
|
switch (rootCatalog){
|
case "数学":
|
return 11;
|
case "历史":
|
return 10;
|
}
|
} else {
|
switch (rootCatalog){
|
case "数学":
|
return 0;
|
case "历史":
|
return 10;
|
}
|
}
|
}
|
return 0;
|
}
|
|
@Override
|
protected List loadGlobalList(List<Integer> ownerHashCodeList, List<Integer> rootCatalogHashCodeList) {
|
logger.debug("ownerHashCodeList = {}, rootCatalogHashCodeList = {}", ownerHashCodeList, rootCatalogHashCodeList);
|
if(ownerHashCodeList != null){
|
for(Integer hashCode : ownerHashCodeList){
|
for(QuestionAlgorithm qa : this.data){
|
if(qa.getOwnerHashCode() == hashCode.intValue()){
|
logger.info("匹配一个试题:{}, ownerHashCode={}", qa.getOwner(), hashCode);
|
}
|
}
|
}
|
}
|
if(rootCatalogHashCodeList != null){
|
for(Integer hashCode : rootCatalogHashCodeList){
|
for(QuestionAlgorithm qa : this.data){
|
if(qa.getRootCatalogHashCode() == hashCode.intValue()){
|
logger.info("匹配一个试题:{}, rootCatalogHashCode={}", qa.getRootCatalog(), hashCode);
|
}
|
}
|
}
|
}
|
return null;
|
}
|
|
@Override
|
protected long acquireOptionItemTotal(String owner, String rootCatalog, String catalog, QuestionType questionType) {
|
if(questionType == null){
|
if(owner.equals("default")){
|
if(rootCatalog.equals("数学")){
|
switch (catalog){
|
case "三角函数":
|
return 5;
|
case "几何函数":
|
return 6;
|
}
|
} else {
|
// 历史
|
switch (catalog){
|
case "中国历史":
|
return 3;
|
case "国际历史":
|
return 7;
|
}
|
}
|
} else {
|
// do nothing...
|
}
|
|
} else {
|
// 试题类型
|
if(owner.equals("default")){
|
if(rootCatalog.equals("数学")){
|
throw new UnsupportedOperationException("不测试,数据太少!");
|
} else {
|
// 历史
|
if(catalog.equals("国际历史")){
|
if(questionType == QuestionType.SelectSingle){
|
return 0;
|
} else if(questionType == QuestionType.SelectMultiple){
|
return 2;
|
} else if(questionType == QuestionType.TrueOrFalse){
|
return 5;
|
} else {
|
return 0;
|
}
|
} else {
|
|
}
|
}
|
} else {
|
// do nothing...
|
}
|
}
|
return 0;
|
}
|
|
@Override
|
protected List loadOptionList(List<Integer> catalogHashCodeList, List<Integer> typeHashCodeList) {
|
logger.debug("catalogHashCodeList = {}, typeHashCodeList = {}", catalogHashCodeList, typeHashCodeList);
|
if(catalogHashCodeList != null){
|
for(Integer hashCode : catalogHashCodeList){
|
for(QuestionAlgorithm qa : this.data){
|
if(qa.getCatalogHashCode() == hashCode.intValue()){
|
logger.info("匹配一个试题:{}, catalogHashCode={}", qa.getCatalog(), hashCode);
|
}
|
}
|
}
|
}
|
if(typeHashCodeList != null){
|
for(Integer hashCode : typeHashCodeList){
|
for(QuestionAlgorithm qa : this.data){
|
if(qa.getTypeHashCode() == hashCode.intValue()){
|
logger.info("匹配一个试题:{}, typeHashCode={}", qa.getType(), hashCode);
|
}
|
}
|
}
|
}
|
return null;
|
}
|
|
public DemoSimpleExtractor(){
|
this.init();
|
}
|
|
private void init(){
|
this.data = new ArrayList<>();
|
this.data.add(this.createOne(1, "default", 1
|
, "数学", 1, "三角函数", 1, "1", 1));
|
this.data.add(this.createOne(2, "default", 2
|
, "数学", 2, "三角函数", 2, "1", 2));
|
this.data.add(this.createOne(3, "default", 3
|
, "数学", 3, "三角函数", 3, "2", 1));
|
this.data.add(this.createOne(4, "default", 4
|
, "数学", 4, "三角函数", 4, "2", 2));
|
this.data.add(this.createOne(5, "default", 5
|
, "数学", 5, "三角函数", 5, "2", 3));
|
this.data.add(this.createOne(6, "default", 6
|
, "数学", 6, "几何函数", 1, "1", 1));
|
this.data.add(this.createOne(7, "default", 7
|
, "数学", 7, "几何函数", 2, "1", 2));
|
this.data.add(this.createOne(8, "default", 8
|
, "数学", 8, "几何函数", 3, "1", 3));
|
this.data.add(this.createOne(9, "default", 9
|
, "数学", 9, "几何函数", 4, "2", 1));
|
this.data.add(this.createOne(10, "default", 10
|
, "数学", 10, "几何函数", 5, "3", 1));
|
this.data.add(this.createOne(11, "default", 11
|
, "数学", 11, "几何函数", 6, "3", 2));
|
this.data.add(this.createOne(12, "default", 12
|
, "历史", 1, "中国历史", 1, "1", 1));
|
this.data.add(this.createOne(13, "default", 13
|
, "历史", 2, "中国历史", 2, "1", 2));
|
this.data.add(this.createOne(14, "default", 14
|
, "历史", 3, "中国历史", 3, "2", 1));
|
this.data.add(this.createOne(15, "default", 15
|
, "历史", 4, "国际历史", 1, "2", 1));
|
this.data.add(this.createOne(16, "default", 16
|
, "历史", 5, "国际历史", 2, "2", 2));
|
this.data.add(this.createOne(17, "default", 17
|
, "历史", 6, "国际历史", 3, "3", 1));
|
this.data.add(this.createOne(18, "default", 18
|
, "历史", 7, "国际历史", 4, "3", 2));
|
this.data.add(this.createOne(19, "default", 19
|
, "历史", 8, "国际历史", 5, "3", 3));
|
this.data.add(this.createOne(20, "default", 20
|
, "历史", 9, "国际历史", 6, "3", 4));
|
this.data.add(this.createOne(21, "default", 21
|
, "历史", 10, "国际历史", 7, "3", 5));
|
this.data.add(this.createOne(22, "mike", 1
|
, "历史", 1, "国际历史", 1, "3", 1));
|
this.data.add(this.createOne(23, "mike", 2
|
, "历史", 2, "国际历史", 2, "3", 2));
|
this.data.add(this.createOne(24, "mike", 3
|
, "历史", 3, "国际历史", 3, "1", 1));
|
this.data.add(this.createOne(25, "mike", 4
|
, "历史", 4, "国际历史", 4, "1", 2));
|
this.data.add(this.createOne(26, "mike", 5
|
, "历史", 5, "国际历史", 5, "1", 3));
|
this.data.add(this.createOne(27, "mike", 6
|
, "历史", 6, "国际历史", 6, "1", 4));
|
this.data.add(this.createOne(28, "mike", 7
|
, "历史", 7, "中国历史", 1, "1", 1));
|
this.data.add(this.createOne(29, "mike", 8
|
, "历史", 8, "中国历史", 2, "1", 2));
|
this.data.add(this.createOne(30, "mike", 9
|
, "历史", 9, "中国历史", 3, "1", 3));
|
this.data.add(this.createOne(31, "mike", 10
|
, "历史", 10, "中国历史", 4, "2", 1));
|
}
|
|
private QuestionAlgorithm createOne(long id
|
, String owner, int ownerNum, String rootCatalog, int rootCatalogNum, String catalog, int catalogNum
|
, String type, int typeNum){
|
QuestionAlgorithm questionAlgorithm = new QuestionAlgorithm();
|
questionAlgorithm.setId(id);
|
questionAlgorithm.setOwner(owner);
|
questionAlgorithm.setOwnerNum(ownerNum);
|
questionAlgorithm.setOwnerHashCode(new StringBuilder(owner).append(ownerNum).toString().hashCode());
|
|
questionAlgorithm.setRootCatalog(rootCatalog);
|
questionAlgorithm.setRootCatalogNum(rootCatalogNum);
|
questionAlgorithm.setRootCatalogHashCode(new StringBuilder(owner)
|
.append(rootCatalog).append(rootCatalogNum).toString().hashCode());
|
|
questionAlgorithm.setCatalog(catalog);
|
questionAlgorithm.setCatalogNum(catalogNum);
|
questionAlgorithm.setCatalogHashCode(new StringBuilder(owner)
|
.append(rootCatalog).append(catalog).append(catalogNum).toString().hashCode());
|
|
questionAlgorithm.setType(type);
|
questionAlgorithm.setTypeNum(typeNum);
|
questionAlgorithm.setTypeHashCode(new StringBuilder(owner)
|
.append(rootCatalog).append(catalog).append(type).append(typeNum).toString().hashCode());
|
return questionAlgorithm;
|
}
|
}
|