@ -7,11 +7,11 @@ import com.sztzjy.financial_bigdata.entity.SysCourse;
import com.sztzjy.financial_bigdata.entity.SysCourseChapter ;
import com.sztzjy.financial_bigdata.entity.SysObjectiveQuestion ;
import com.sztzjy.financial_bigdata.entity.SysObjectiveQuestionExample ;
import com.sztzjy.financial_bigdata.mapper.SysCourseChapterMapper ;
import com.sztzjy.financial_bigdata.mapper.SysObjectiveQuestionMapper ;
import com.sztzjy.financial_bigdata.service.common.ICourseChapterService ;
import com.sztzjy.financial_bigdata.service.common.ICourseService ;
import com.sztzjy.financial_bigdata.service.tea.ITeaObjectiveService ;
import io.swagger.models.auth.In ;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException ;
import org.apache.poi.ss.usermodel.* ;
import org.springframework.beans.factory.annotation.Autowired ;
@ -30,6 +30,9 @@ public class TeaObjectiveServiceImpl implements ITeaObjectiveService {
ICourseService courseService ;
@Autowired
ICourseChapterService chapterService ;
@Autowired
SysCourseChapterMapper sysCourseChapterMapper ;
@Override
public Boolean insertObjective ( SysObjectiveQuestion objectiveQuestion ) {
@ -112,10 +115,10 @@ public class TeaObjectiveServiceImpl implements ITeaObjectiveService {
iterator . next ( ) ;
while ( iterator . hasNext ( ) ) {
Row currentRow = iterator . next ( ) ;
String courseName = currentRow . getCell ( 0 ) . getStringCellValue ( ) ; //课程名称
String chapterName = currentRow . getCell ( 1 ) . getStringCellValue ( ) ; //章节名称
String type = String . valueOf ( currentRow . getCell ( 2 ) . getNumericCellValue ( ) ) ; //题目类型
String score = String . valueOf ( currentRow . getCell ( 3 ) . getNumericCellValue ( ) ) ; //分数
String courseName = currentRow . getCell ( 0 ) . getStringCellValue ( ) .trim ( ) ; //课程名称
String chapterName = currentRow . getCell ( 1 ) . getStringCellValue ( ) .trim ( ) ; //章节名称
String type = String . valueOf ( currentRow . getCell ( 2 ) . getNumericCellValue ( ) ) .trim ( ) ; //题目类型
String score = String . valueOf ( currentRow . getCell ( 3 ) . getNumericCellValue ( ) ) .trim ( ) ; //分数
String content = currentRow . getCell ( 4 ) . getStringCellValue ( ) ; //题目内容
System . out . println ( chapterName ) ;
System . out . println ( "!!!" + content ) ;
@ -166,47 +169,59 @@ public class TeaObjectiveServiceImpl implements ITeaObjectiveService {
}
} else { //老师批量新增题目
List < SysCourse > courseList = courseService . selectAllBySchoolId ( schoolId ) ;
List < SysCourse > builtInList = courseService . selectAllBuiltIn ( ) ;
courseList . addAll ( builtInList ) ;
Map < String , String > courseMap = new HashMap < > ( ) ;
Map < String , String > courseChapterMap = new HashMap < > ( ) ;
for ( int i = 0 ; i < courseList . size ( ) ; i + + ) {
courseMap . put ( courseList . get ( i ) . getCourseName ( ) , courseList . get ( i ) . getCourseId ( ) ) ;
}
List < SysCourseChapter > chapterList = sysCourseChapterMapper . selectChapterDataBySchoolId ( schoolId ) ;
for ( int i = 0 ; i < chapterList . size ( ) ; i + + ) {
courseChapterMap . put ( chapterList . get ( i ) . getChapterName ( ) , chapterList . get ( i ) . getChapterId ( ) ) ;
}
Workbook workbook = WorkbookFactory . create ( file . getInputStream ( ) ) ;
Sheet sheet = workbook . getSheetAt ( 0 ) ;
// 迭代每一行
Iterator < Row > iterator = sheet . iterator ( ) ;
iterator . next ( ) ;
while ( iterator . hasNext ( ) ) {
Row currentRow = iterator . next ( ) ;
String courseName = currentRow . getCell ( 0 ) . getStringCellValue ( ) ; //课程名称
String type = String . valueOf ( currentRow . getCell ( 1 ) . getNumericCellValue ( ) ) ; //题目类型
String score = String . valueOf ( currentRow . getCell ( 2 ) . getNumericCellValue ( ) ) ; //分数
String content = currentRow . getCell ( 3 ) . getStringCellValue ( ) ; //题目内容
String chapterName = currentRow . getCell ( 1 ) . getStringCellValue ( ) ; //章节名称
String type = String . valueOf ( currentRow . getCell ( 2 ) . getNumericCellValue ( ) ) ; //题目类型
String score = String . valueOf ( currentRow . getCell ( 3 ) . getNumericCellValue ( ) ) ; //分数
String content = currentRow . getCell ( 4 ) . getStringCellValue ( ) ; //题目内容
String question_a = "" ;
String question_b = "" ;
String question_c = "" ;
String question_d = "" ;
if ( type . equals ( "2.0" ) | | type . equals ( "2" ) ) {
question_a = "正确" ;
question_b = "错误" ;
} else {
question_a = currentRow . getCell ( 4 ) . getStringCellValue ( ) ;
question_b = currentRow . getCell ( 5 ) . getStringCellValue ( ) ;
question_c = currentRow . getCell ( 6 ) . getStringCellValue ( ) ;
question_d = currentRow . getCell ( 7 ) . getStringCellValue ( ) ;
question_a = currentRow . getCell ( 5 ) . getStringCellValue ( ) ;
question_b = currentRow . getCell ( 6 ) . getStringCellValue ( ) ;
question_c = currentRow . getCell ( 7 ) . getStringCellValue ( ) ;
question_d = currentRow . getCell ( 8 ) . getStringCellValue ( ) ;
}
String answer = currentRow . getCell ( 8 ) . getStringCellValue ( ) ;
Cell cell = currentRow . getCell ( 9 ) ;
String answer = currentRow . getCell ( 9 ) . getStringCellValue ( ) ;
Cell cell = currentRow . getCell ( 10 ) ;
String analyze = ( cell ! = null ) ? cell . getStringCellValue ( ) : "" ;
SysObjectiveQuestion obj = new SysObjectiveQuestion ( ) ;
obj . setObjectiveId ( String . valueOf ( UUID . randomUUID ( ) ) ) ;
obj . setCourseId ( courseMap . get ( courseName ) ) ;
String s = courseMap . get ( courseName ) ;
System . out . println ( s ) ;
obj . setScore ( new BigDecimal ( score ) ) ;
obj . setCourseName ( courseName ) ;
obj . setChapterName ( chapterName ) ;
obj . setChapterId ( courseChapterMap . get ( chapterName ) ) ;
obj . setInputType ( Constant . INPUT_TYPE_TEACHER ) ;
if ( type . equals ( "0.0" ) ) {
type = "0" ;
@ -215,8 +230,8 @@ public class TeaObjectiveServiceImpl implements ITeaObjectiveService {
} else {
type = "2" ;
}
obj . setType ( String . valueOf ( type ) ) ;
obj . set Score( new BigDecimal ( score ) ) ;
obj . set Type( type ) ;
obj . setContent ( content ) ;
obj . setQuestionA ( question_a ) ;
obj . setQuestionB ( question_b ) ;