修改实训演练页面接口

master
xiaoCJ
parent ec4bd7c526
commit 6b84bd6f20

76
.gitignore vendored

@ -1,34 +1,58 @@
HELP.md # ignore these folders
target/ target/
!.mvn/wrapper/maven-wrapper.jar .idea/
!**/src/main/**/target/ .settings/
!**/src/test/**/target/ .vscode/
bin/
out/
### STS ### # ignore these files
.apt_generated
.classpath .classpath
.factorypath
.project .project
.settings .settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea .idea
*.iws
# filter databfile、sln file
*.mdb
*.ldb
*.sln
# class file
*.com
*.class
*.dll
*.exe
*.o
*.so
# compression file
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
*.via
*.tmp
*.err
*.log
*.iml *.iml
*.ipr
.log
.jar
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ### # OS generated files
.vscode/ .DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db
.factorypath
.mvn/
mvnw.cmd
mvnw
# Files or folders need to be retained
# ...

@ -19,8 +19,8 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.*;
import java.util.List; import java.util.stream.Collectors;
//实训演练-实训案例-实验实训 //实训演练-实训案例-实验实训
@RestController @RestController
@ -97,70 +97,115 @@ public class ExerciseExperimentalTraining {
} }
} }
@AnonymousAccess
@ApiOperation("实训演练页面查询")
@PostMapping("getCourseChapter")
public ResultEntity<List<SysCourseDto>> getIndexTheoryTest(@RequestParam String userId) {
List<SysCourse> sysCourseList = sysCourseMapper.getBySchoolId();
List<SysCourseDto> dtoList = new ArrayList<>();
for (SysCourse sysCourse : sysCourseList) {
SysCourseDto newDto = new SysCourseDto();
BeanUtils.copyProperties(sysCourse, newDto);
String courseId = newDto.getCourseId();
SysCourseChapterExample courseChapterExample = new SysCourseChapterExample();
courseChapterExample.createCriteria().andCourseIdEqualTo(courseId);
courseChapterExample.setOrderByClause("sequence ASC");
List<SysCourseChapter> sysCourseChapters = sysCourseChapterMapper.selectByExample(courseChapterExample);
List<SysCourseChapterDto> CourseChapterDtoList = new ArrayList<>();
for (SysCourseChapter sysCourseChapter : sysCourseChapters) {
SysCourseChapterDto sysCourseChapterDto = new SysCourseChapterDto();
BeanUtils.copyProperties(sysCourseChapter, sysCourseChapterDto);
BigDecimal progress = stuTrainingMapper.getByUserIdAndChapterId(userId, sysCourseChapter.getChapterId());
sysCourseChapterDto.setSchedule(progress);
CourseChapterDtoList.add(sysCourseChapterDto);
}
newDto.setSysCourseChapterDtos(CourseChapterDtoList);
dtoList.add(newDto);
}
return new ResultEntity<List<SysCourseDto>>(dtoList);
}
//
// @AnonymousAccess // @AnonymousAccess
// @ApiOperation("实训演练页面查询") // @ApiOperation("实训演练页面查询")
// @PostMapping("getCourseChapter") // @PostMapping("getCourseChapter")
// public ResultEntity<List<SysCourseDto>> getIndexTheoryTest(@RequestParam String userId) { // public ResultEntity<List<SysCourseDto>> getIndexTheoryTest(@RequestParam String userId) {
// List<SysCourse> sysCourseList = sysCourseMapper.getBySchoolId(); // List<SysCourse> sysCourseList = sysCourseMapper.getBySchoolId();
// List<SysCourseDto> dtoList = new ArrayList<>(); // List<SysCourseDto> dtoList = new ArrayList<>();
// Map<String, SysCourseDto> map = new HashMap<>();
// for (SysCourse sysCourse : sysCourseList) { // for (SysCourse sysCourse : sysCourseList) {
// SysCourseDto newDto = new SysCourseDto(); // SysCourseDto newDto = new SysCourseDto();
// BeanUtils.copyProperties(sysCourse, newDto); // BeanUtils.copyProperties(sysCourse, newDto);
// String courseId = newDto.getCourseId(); // String courseId = newDto.getCourseId();
// map.put(courseId,newDto);
// SysCourseChapterExample courseChapterExample = new SysCourseChapterExample(); // SysCourseChapterExample courseChapterExample = new SysCourseChapterExample();
// courseChapterExample.createCriteria().andCourseIdEqualTo(courseId); // courseChapterExample.createCriteria().andCourseIdEqualTo(courseId);
// courseChapterExample.setOrderByClause("sequence ASC"); // courseChapterExample.setOrderByClause("sequence ASC");
// List<SysCourseChapter> sysCourseChapters = sysCourseChapterMapper.selectByExample(courseChapterExample); // List<SysCourseChapter> sysCourseChapters = sysCourseChapterMapper.selectByExample(courseChapterExample);
// List<SysCourseChapterDto> CourseChapterDtoList = new ArrayList<>(); // List<SysCourseChapterDto> CourseChapterDtoList = new ArrayList<>();
//
// List<String> chapterIds = new ArrayList<>();
// for (SysCourseChapter sysCourseChapter : sysCourseChapters) { // for (SysCourseChapter sysCourseChapter : sysCourseChapters) {
//// stuTrainingMapper.getByUserIdAndChaptetId()
// SysCourseChapterDto sysCourseChapterDto = new SysCourseChapterDto(); // SysCourseChapterDto sysCourseChapterDto = new SysCourseChapterDto();
// BeanUtils.copyProperties(sysCourseChapter, sysCourseChapterDto); // BeanUtils.copyProperties(sysCourseChapter, sysCourseChapterDto);
// StuTrainingExample example = new StuTrainingExample(); // String chapterId = sysCourseChapter.getChapterId();
// example.createCriteria().andUserIdEqualTo(userId).andChapterIdEqualTo(sysCourseChapter.getChapterId()); // BigDecimal progress = stuTrainingMapper.getByUserIdAndChapterId(userId, chapterId);
// List<StuTrainingWithBLOBs> list = stuTrainingMapper.selectByExampleWithBLOBs(example); // sysCourseChapterDto.setSchedule(progress);
// if (!list.isEmpty()) {
// StuTrainingWithBLOBs stuTrainingWithBLOBs = list.get(0);
// sysCourseChapterDto.setSchedule(stuTrainingWithBLOBs.getProgress());
// }
// CourseChapterDtoList.add(sysCourseChapterDto); // CourseChapterDtoList.add(sysCourseChapterDto);
// chapterIds.add(chapterId);
// } // }
// SysCaseQuestionExample example = new SysCaseQuestionExample();
// example.createCriteria().andChapterIdIn(chapterIds);
// List<SysCaseQuestion> list = caseQuestionMapper.selectByExample(example);
// List<String> caseIds = list.stream().map(SysCaseQuestion::getCaseId).collect(Collectors.toList());
// SysCaseQuestionStepExample sysCaseQuestionStepExample = new SysCaseQuestionStepExample();
// sysCaseQuestionStepExample.createCriteria().andCaseIdIn(caseIds);
// List<SysCaseQuestionStep> sysCaseQuestionSteps = caseQuestionStepMapper.selectByExample(sysCaseQuestionStepExample);
// Map<String,String> collect = sysCaseQuestionSteps.stream().collect(Collectors.toMap(SysCaseQuestionStep::getCaseStepId,SysCaseQuestionStep::getTitle));
// newDto.setTitleAndId(collect);
// newDto.setSysCourseChapterDtos(CourseChapterDtoList); // newDto.setSysCourseChapterDtos(CourseChapterDtoList);
// dtoList.add(newDto); // dtoList.add(newDto);
// } // }
// return new ResultEntity<List<SysCourseDto>>(dtoList); // return new ResultEntity<List<SysCourseDto>>(dtoList);
// } // }
//
@AnonymousAccess
@ApiOperation("实训演练页面查询")
@PostMapping("getCourseChapter")
public ResultEntity<List<SysCourseDto>> getIndexTheoryTest(@RequestParam String userId) {
List<SysCourse> sysCourseList = sysCourseMapper.getBySchoolId();
List<SysCourseDto> dtoList = new ArrayList<>();
List<String> courseIds = sysCourseList.stream()
.map(SysCourse::getCourseId)
.collect(Collectors.toList());
List<SysCourseChapter> sysCourseChapters = sysCourseChapterMapper.getChaptersByCourseIds(courseIds);
List<String> courseChapterIds = sysCourseChapters.stream().map(SysCourseChapter::getChapterId).collect(Collectors.toList());
Map<String, List<String>> idMap = new HashMap<>();
for (SysCourse sysCourse : sysCourseList) {
String courseId = sysCourse.getCourseId();
List<String> chapterIds = sysCourseChapters.stream()
.filter(chapter -> chapter.getCourseId().equals(courseId))
.map(SysCourseChapter::getChapterId)
.collect(Collectors.toList());
idMap.put(courseId, chapterIds);
}
//为循环提供数据
List<StuTraining> progressByChapterIds = stuTrainingMapper.getByUserIdAndChapterIds(userId, courseChapterIds); //循环外先查出所有进度
Map<String, BigDecimal> progressMap = progressByChapterIds.stream()
.collect(Collectors.toMap(StuTraining::getChapterId,
stuTraining -> Optional.ofNullable(stuTraining.getProgress()).orElse(BigDecimal.ZERO),
(p1, p2) -> p1)); // 默认值为 BigDecimal.ZERO //进度为空则给0
//一层一层查出 课程,章节,章节下案例题
for (SysCourse sysCourse : sysCourseList) {
SysCourseDto newDto = new SysCourseDto();
BeanUtils.copyProperties(sysCourse, newDto);
String courseId = newDto.getCourseId();
List<SysCourseChapterDto> CourseChapterDtoList = new ArrayList<>();
for (SysCourseChapter sysCourseChapter : sysCourseChapters) {
SysCourseChapterDto sysCourseChapterDto = new SysCourseChapterDto();
BeanUtils.copyProperties(sysCourseChapter, sysCourseChapterDto);
String chapterId = sysCourseChapter.getChapterId();
BigDecimal progress = progressMap.get(chapterId);
sysCourseChapterDto.setSchedule(progress);
CourseChapterDtoList.add(sysCourseChapterDto);
}
//查询案例题
List<String> list1 = idMap.get(courseId); //取出章节ID
SysCaseQuestionExample example = new SysCaseQuestionExample();
example.createCriteria().andChapterIdIn(list1);
List<SysCaseQuestion> list = caseQuestionMapper.selectByExample(example);
List<String> caseIds = list.stream().map(SysCaseQuestion::getCaseId).collect(Collectors.toList());
SysCaseQuestionStepExample sysCaseQuestionStepExample = new SysCaseQuestionStepExample();
sysCaseQuestionStepExample.createCriteria().andCaseIdIn(caseIds);
List<SysCaseQuestionStep> sysCaseQuestionSteps = caseQuestionStepMapper.selectByExample(sysCaseQuestionStepExample);
Map<String, String> collect = sysCaseQuestionSteps.stream().collect(Collectors.toMap(SysCaseQuestionStep::getCaseStepId, SysCaseQuestionStep::getTitle));
newDto.setSysCourseChapterDtos(CourseChapterDtoList);
dtoList.add(newDto);
newDto.setTitleAndId(collect);
newDto.setSysCourseChapterDtos(CourseChapterDtoList);
dtoList.add(newDto);
}
return new ResultEntity<List<SysCourseDto>>(dtoList);
}
//数据集下载 //数据集下载

@ -1,5 +1,5 @@
package com.sztzjy.financial_bigdata.controller.tea; package com.sztzjy.financial_bigdata.controller.tea;
import javax.swing.JOptionPane;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
@ -22,7 +22,6 @@ import com.sztzjy.financial_bigdata.util.excel.FilePortUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.Synchronized;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -39,6 +38,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* @Author xcj * @Author xcj
@ -66,6 +66,30 @@ public class UserController {
private static String loginIp; private static String loginIp;
// public static void main(String[] args) {
// StuUser a = new StuUser();
// a.setPhone("111");
// a.setUserid("111");
// StuUser a2 = new StuUser();
// a2.setPhone("111");
// a2.setUserid("111");
// StuUser a3 = new StuUser();
// a3.setPhone("222");
// a3.setUserid("111");
// List<StuUser> list = new ArrayList<>();
// list.add(a);
// list.add(a2);
// list.add(a3);
// List<String> collect = list.stream().map(StuUser::getPhone).collect(Collectors.toList());
// Map<String, String> collect1 = list.stream()
// .collect(Collectors.toMap(StuUser::getPhone, StuUser::getUserid,(w, ww) -> w));
//// System.out.println(collect);
// System.out.println(collect1);
// }
@PostMapping("/login") @PostMapping("/login")
@ApiOperation("登录接口") @ApiOperation("登录接口")
@AnonymousAccess @AnonymousAccess
@ -97,7 +121,6 @@ public class UserController {
if (stuUsers.isEmpty()) { if (stuUsers.isEmpty()) {
return new ResultEntity(HttpStatus.BAD_REQUEST, "密码错误"); return new ResultEntity(HttpStatus.BAD_REQUEST, "密码错误");
} }
StuUser user1 = stuUsers.get(0);
// 保存用户的登录信息 // 保存用户的登录信息
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
StuUser user = stuUsers.get(0); StuUser user = stuUsers.get(0);

@ -16,6 +16,27 @@ public class StuUser {
@ApiModelProperty("姓名") @ApiModelProperty("姓名")
private String name; private String name;
@Override
public String toString() {
return "StuUser{" +
"userid='" + userid + '\'' +
", name='" + name + '\'' +
", studentId='" + studentId + '\'' +
", classId='" + classId + '\'' +
", username='" + username + '\'' +
", password='" + password + '\'' +
", phone='" + phone + '\'' +
", email='" + email + '\'' +
", major='" + major + '\'' +
", roleId=" + roleId +
", createTime=" + createTime +
", schoolId='" + schoolId + '\'' +
", schoolName='" + schoolName + '\'' +
", status=" + status +
", examStatus='" + examStatus + '\'' +
'}';
}
@ApiModelProperty("学号") @ApiModelProperty("学号")
private String studentId; private String studentId;

@ -6,6 +6,7 @@ import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @Author xcj * @Author xcj
@ -29,5 +30,8 @@ public class SysCourseDto {
@ApiModelProperty("0为老师导入 1为内置") @ApiModelProperty("0为老师导入 1为内置")
private String inputType; private String inputType;
@ApiModelProperty("案例题名称和步骤ID")
private Map<String,String> titleAndId;
private List<SysCourseChapterDto> sysCourseChapterDtos; private List<SysCourseChapterDto> sysCourseChapterDtos;
} }

@ -5,12 +5,15 @@ import com.sztzjy.financial_bigdata.entity.StuTrainingExample;
import com.sztzjy.financial_bigdata.entity.StuTrainingWithBLOBs; import com.sztzjy.financial_bigdata.entity.StuTrainingWithBLOBs;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map;
import com.sztzjy.financial_bigdata.entity.tea_dto.TrainingDto; import com.sztzjy.financial_bigdata.entity.tea_dto.TrainingDto;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import org.geolatte.geom.M;
@Mapper @Mapper
public interface StuTrainingMapper { public interface StuTrainingMapper {
@ -52,4 +55,6 @@ public interface StuTrainingMapper {
@Select("SELECT progress FROM stu_training WHERE user_id = #{userId} AND chapter_id = #{chapterId}") @Select("SELECT progress FROM stu_training WHERE user_id = #{userId} AND chapter_id = #{chapterId}")
BigDecimal getByUserIdAndChapterId(@Param("userId")String userId, @Param("chapterId")String chapterId); BigDecimal getByUserIdAndChapterId(@Param("userId")String userId, @Param("chapterId")String chapterId);
List<StuTraining> getByUserIdAndChapterIds(@Param("userId") String userId, @Param("chapterIds") List<String> chapterIds);
} }

@ -38,4 +38,8 @@ public interface SysCourseChapterMapper {
BigDecimal selectChapterBySchoolId(@Param("schoolId")String schoolId); BigDecimal selectChapterBySchoolId(@Param("schoolId")String schoolId);
List<SysCourseChapter> selectChapterDataBySchoolId(@Param("schoolId")String schoolId); List<SysCourseChapter> selectChapterDataBySchoolId(@Param("schoolId")String schoolId);
List<SysCourseChapter> getChapters(@Param("courseId") String courseId);
List<SysCourseChapter> getChaptersByCourseIds(@Param("courseIds")List<String> courseIds);
} }

File diff suppressed because it is too large Load Diff

@ -207,4 +207,23 @@
WHERE sys_course.course_id = sys_course_chapter.course_id WHERE sys_course.course_id = sys_course_chapter.course_id
AND school_Id in (999999999, #{schoolId}) AND school_Id in (999999999, #{schoolId})
</select> </select>
<select id="getChapters" parameterType="java.lang.String" resultMap="BaseResultMap">
select *
from sys_course_chapter
where course_id =#{courseId}
order by sequence ASC
</select>
<select id="getChaptersByCourseIds" parameterType="java.lang.String" resultMap="BaseResultMap">
select *
from sys_course_chapter
where course_id IN
<foreach item="item" index="index" collection="courseIds" open="(" separator="," close=")">
#{item}
</foreach>
order by sequence ASC
</select>
</mapper> </mapper>
Loading…
Cancel
Save