修改老师端单点登录

newBigdata
xiaoCJ 10 months ago
parent 7b0ad54236
commit ec4bd7c526

@ -36,4 +36,6 @@ public interface SysCourseChapterMapper {
@Select("SELECT COUNT(chapter_id) FROM sys_course JOIN sys_course_chapter WHERE sys_course.course_id = sys_course_chapter.course_id AND school_Id in(999999999,#{schoolId})")
BigDecimal selectChapterBySchoolId(@Param("schoolId")String schoolId);
List<SysCourseChapter> selectChapterDataBySchoolId(@Param("schoolId")String schoolId);
}

@ -10,6 +10,7 @@ import com.sztzjy.financial_bigdata.service.common.ICourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@ -72,7 +73,10 @@ public class CourseServiceImpl implements ICourseService {
public List<SysCourse> selectAllBySchoolId(String schoolId) {
SysCourseExample example=new SysCourseExample();
SysCourseExample.Criteria criteria = example.createCriteria();
criteria.andSchoolIdEqualTo(schoolId);
List<String> list =new ArrayList();
list.add("999999999");
list.add(schoolId);
criteria.andSchoolIdIn(list);
List<SysCourse> courseList = courseMapper.selectByExample(example);
return courseList;
}

@ -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,13 +115,13 @@ 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);
System.out.println("!!!" + content);
String question_a = "";
String question_b = "";
String question_c = "";
@ -145,12 +148,12 @@ public class TeaObjectiveServiceImpl implements ITeaObjectiveService {
obj.setChapterId(chapterMap.get(chapterName));
obj.setChapterName(chapterName);
obj.setInputType(Constant.INPUT_TYPE_BUILT_IN);
if(type.equals("0.0")){
type="0";
}else if(type.equals("1.0")){
type="1";
}else {
type="2";
if (type.equals("0.0")) {
type = "0";
} else if (type.equals("1.0")) {
type = "1";
} else {
type = "2";
}
obj.setType(type);
obj.setScore(new BigDecimal(score));
@ -166,57 +169,69 @@ 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";
}else if(type.equals("1.0")){
type="1";
}else {
type="2";
if (type.equals("0.0")) {
type = "0";
} else if (type.equals("1.0")) {
type = "1";
} else {
type = "2";
}
obj.setType(String.valueOf(type));
obj.setScore(new BigDecimal(score));
obj.setType(type);
obj.setContent(content);
obj.setQuestionA(question_a);
obj.setQuestionB(question_b);

@ -2,10 +2,10 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.sztzjy.financial_bigdata.mapper.SysCourseChapterMapper">
<resultMap id="BaseResultMap" type="com.sztzjy.financial_bigdata.entity.SysCourseChapter">
<id column="chapter_id" jdbcType="VARCHAR" property="chapterId" />
<result column="chapter_name" jdbcType="VARCHAR" property="chapterName" />
<result column="course_id" jdbcType="VARCHAR" property="courseId" />
<result column="sequence" jdbcType="INTEGER" property="sequence" />
<id column="chapter_id" jdbcType="VARCHAR" property="chapterId"/>
<result column="chapter_name" jdbcType="VARCHAR" property="chapterName"/>
<result column="course_id" jdbcType="VARCHAR" property="courseId"/>
<result column="sequence" jdbcType="INTEGER" property="sequence"/>
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -25,7 +25,8 @@
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
@ -54,7 +55,8 @@
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
@ -66,17 +68,19 @@
</where>
</sql>
<sql id="Base_Column_List">
chapter_id, chapter_name, course_id, sequence
chapter_id
, chapter_name, course_id, sequence
</sql>
<select id="selectByExample" parameterType="com.sztzjy.financial_bigdata.entity.SysCourseChapterExample" resultMap="BaseResultMap">
<select id="selectByExample" parameterType="com.sztzjy.financial_bigdata.entity.SysCourseChapterExample"
resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
<include refid="Base_Column_List"/>
from sys_course_chapter
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
<include refid="Example_Where_Clause"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
@ -84,18 +88,19 @@
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
<include refid="Base_Column_List"/>
from sys_course_chapter
where chapter_id = #{chapterId,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from sys_course_chapter
delete
from sys_course_chapter
where chapter_id = #{chapterId,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="com.sztzjy.financial_bigdata.entity.SysCourseChapterExample">
delete from sys_course_chapter
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
<include refid="Example_Where_Clause"/>
</if>
</delete>
<insert id="insert" parameterType="com.sztzjy.financial_bigdata.entity.SysCourseChapter">
@ -135,10 +140,11 @@
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.sztzjy.financial_bigdata.entity.SysCourseChapterExample" resultType="java.lang.Long">
<select id="countByExample" parameterType="com.sztzjy.financial_bigdata.entity.SysCourseChapterExample"
resultType="java.lang.Long">
select count(*) from sys_course_chapter
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
<include refid="Example_Where_Clause"/>
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
@ -158,7 +164,7 @@
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByExample" parameterType="map">
@ -168,7 +174,7 @@
course_id = #{record.courseId,jdbcType=VARCHAR},
sequence = #{record.sequence,jdbcType=INTEGER}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.sztzjy.financial_bigdata.entity.SysCourseChapter">
@ -193,4 +199,12 @@
sequence = #{sequence,jdbcType=INTEGER}
where chapter_id = #{chapterId,jdbcType=VARCHAR}
</update>
<select id="selectChapterDataBySchoolId" parameterType="java.lang.String" resultMap="BaseResultMap">
SELECT *
FROM sys_course
JOIN sys_course_chapter
WHERE sys_course.course_id = sys_course_chapter.course_id
AND school_Id in (999999999, #{schoolId})
</select>
</mapper>
Loading…
Cancel
Save