自动生成配置文件和mapper xml

newBigdata
xiaoCJ 11 months ago
parent c1de307680
commit 93dd731bbe

@ -64,24 +64,51 @@ public class TeaGradeManageController {
@AnonymousAccess
@PostMapping("/getExamInfo")
@ApiOperation("考试模式--页面展示(学生端实战考核复用)")
public ResultEntity<PageInfo> getExamInfo(@RequestParam Integer index,
public ResultEntity<PageInfo<TeaExamManageCountDto>> getExamInfo(@RequestParam Integer index,
@RequestParam Integer size,
@ApiParam("ManyAnswer为考试时间JudgeAnswer为发布人") @RequestParam String schoolId) {
PageHelper.startPage(index, size);
TeaExamManageExample teaExamManageExample = new TeaExamManageExample();
teaExamManageExample.createCriteria().andSchoolIdEqualTo(schoolId);
List<TeaExamManage> teaExamManages = teaExamManageMapper.selectByExample(teaExamManageExample);
List<TeaExamManageCountDto> teaExamManageCountDtos = new ArrayList<>();
for (TeaExamManage teaExamManage : teaExamManages) {
List<String> nameList = new ArrayList<>();
TeaExamManageCountDto copyexamManageWithBLOBs = new TeaExamManageCountDto();
int num = 0;
//获取班级和考试人数
String classId = teaAndStudentExamMapper.selectByExamId(teaExamManage.getExamManageId());
String[] split = classId.split(",");
for (String s : split) {
StuClass stuClass = stuClassMapper.selectByPrimaryKey(s);
String className = stuClass.getClassName();
nameList.add(className);
int count = userMapper.selectNumByClass(s);
num = num + count;
}
copyexamManageWithBLOBs.setExamClass(nameList);
copyexamManageWithBLOBs.setExamNum(num);
BeanUtils.copyProperties(teaExamManage, copyexamManageWithBLOBs);
Date startTime = teaExamManage.getStartTime();
Date endTime = teaExamManage.getEndTime();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String startTimeString = formatter.format(startTime);
String endTimeString = formatter.format(endTime);
Date date = new Date(); // 当前日期
Date endtimeDtae = teaExamManage.getEndTime(); // 从 teaExamManage 对象中获取的日期
Date startTimeDtae = teaExamManage.getStartTime();
long now = date.getTime();
long end = endtimeDtae.getTime();
long start = startTimeDtae.getTime();
if (now > end) {
// 当前 大于 结束时间
copyexamManageWithBLOBs.setExamStatus("已结束");
} else if (now < start) {
// 当前 小于 开始时间
copyexamManageWithBLOBs.setExamStatus("未开始");
} else {
copyexamManageWithBLOBs.setExamStatus("进行中");
}
String concatenatedTimeString = startTimeString + " -- " + endTimeString;
copyexamManageWithBLOBs.setExamTime(concatenatedTimeString); //考试时间
String userId = teaExamManage.getUserId();
@ -89,7 +116,8 @@ public class TeaGradeManageController {
copyexamManageWithBLOBs.setName(stuUser.getName()); //发布人
teaExamManageCountDtos.add(copyexamManageWithBLOBs);
}
return new ResultEntity<>(new PageInfo(teaExamManageCountDtos));
PageUtil.pageHelper(teaExamManageCountDtos, index, size);
return new ResultEntity<>(new PageInfo<>(teaExamManageCountDtos));
}
@AnonymousAccess
@ -300,7 +328,7 @@ public class TeaGradeManageController {
public ResultEntity<PageInfo<StuUserDto>> getReportCorrect(@RequestParam String schoolId,
@RequestParam Integer index,
@RequestParam Integer size,
@RequestParam String module,
@RequestParam(required = false) String module,
@RequestParam(required = false) String classId,
@RequestParam(required = false) String keyWord) {
@ -333,7 +361,7 @@ public class TeaGradeManageController {
SysWeightExample sysWeightExample = new SysWeightExample();
sysWeightExample.createCriteria().andCourseIdEqualTo(sysWeight.getCourseId());
List<SysWeight> sysWeights = sysWeightMapper.selectByExample(sysWeightExample);
if (sysWeights.isEmpty()) {//有 update
if (!sysWeights.isEmpty()) {//有 update
sysWeightMapper.updateByPrimaryKey(sysWeight);
} else { //没有 insert
sysWeightMapper.insert(sysWeight);
@ -349,6 +377,21 @@ public class TeaGradeManageController {
return new ResultEntity<>(moduleBySchoolId);
}
@AnonymousAccess
@PostMapping("/getModuleByCourseId")
@ApiOperation("练习模式--权重回显")
public ResultEntity<SysWeight> getModuleBySchoolId(@RequestParam String courseId,
@RequestParam String schoolId) {
SysWeightExample sysWeightExample = new SysWeightExample();
sysWeightExample.createCriteria().andSchoolIdEqualTo(schoolId).andCourseIdEqualTo(courseId);
List<SysWeight> sysWeights = sysWeightMapper.selectByExample(sysWeightExample);
if (sysWeights.isEmpty()) {
//todo 是否需要设置默认权重
return new ResultEntity<>(new SysWeight());
}
return new ResultEntity<>(sysWeights.get(0));
}
@AnonymousAccess
@PostMapping("/getTheoryInfo")

@ -9,6 +9,7 @@ import com.sztzjy.financial_bigdata.config.security.JwtUser;
import com.sztzjy.financial_bigdata.config.security.LoginResult;
import com.sztzjy.financial_bigdata.config.security.TokenProvider;
import com.sztzjy.financial_bigdata.entity.*;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import com.sztzjy.financial_bigdata.entity.stu_dto.StuUserDto;
import com.sztzjy.financial_bigdata.mapper.StuClassMapper;
import com.sztzjy.financial_bigdata.mapper.StuUserMapper;
@ -30,6 +31,7 @@ import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
@ -51,6 +53,9 @@ public class UserController {
private ITeaUserService userService;
@Autowired
private SysLoginLogMapper sysLoginLogMapper;
@Autowired
private AuthenticationManagerBuilder authenticationManagerBuilder;
// 用户登录时记录的信息
private static LocalDateTime loginTime;
private static String loginIp;
@ -65,10 +70,15 @@ public class UserController {
@RequestParam String userName,
HttpServletRequest request,
@RequestParam(required = false) String TOKEN) throws Exception {
JwtUser jwtUser;
String passWord = RsaUtil.decryptByPrivateKey(passwordEncode);
if (StringUtils.isBlank(TOKEN)) {
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(userName, passWord);
System.out.println(authenticationToken);
Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authenticationToken);
SecurityContextHolder.getContext().setAuthentication(authentication);
JwtUser jwtUser1 = (JwtUser) authentication.getPrincipal();
String token = TokenProvider.createToken(jwtUser1);
// 1、子系统直接登录
StuUserExample stuUserExample = new StuUserExample();
stuUserExample.createCriteria().andUsernameEqualTo(userName).andPasswordEqualTo(passWord);
@ -89,6 +99,7 @@ public class UserController {
map.put("userId", user.getUserid());
String uuid = getIPAndPlace(request, user.getName(), user.getUserid(), user.getStudentId());
map.put("logId", uuid);
map.put("token", token);
return new ResultEntity(HttpStatus.OK, map);
}
} else { // 2、智云单点登录
@ -116,6 +127,7 @@ public class UserController {
map.put("schoolId", loginResult.getSchoolId());
map.put("classId", loginResult.getClassId());
map.put("userId", loginResult.getUserId());
map.put("token", token);
String uuid = getIPAndPlace(request, loginResult.getName(), loginResult.getUserId(), jwtUser.getUsername()); //todo 学号暂时没有
map.put("logId", uuid);
return new ResultEntity(HttpStatus.OK, map); //todo 从智云登录后将用户添加到本地用户表

@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @Author xcj
* @Date 2024/3/14
@ -37,4 +39,13 @@ public class TeaExamManageCountDto {
@ApiModelProperty("LOGO地址")
private String logoAddress;
@ApiModelProperty("状态")
private String examStatus;
@ApiModelProperty("考试人数")
private int examNum;
@ApiModelProperty("考试班级")
private List<String> examClass;
}

@ -15,6 +15,9 @@ import java.math.BigDecimal;
public class TeaTrainingInfoDTO {
private String userId;
@ApiModelProperty("实训ID")
private String trainingId;
@ApiModelProperty("排名")
private int rank;

@ -42,7 +42,7 @@ public interface StuTrainingMapper {
int updateByPrimaryKey(StuTraining record);
@Select("select count(progress) FROM stu_training WHERE progress = 1 and user_id = #{userId}")
@Select("select count(progress) FROM stu_training WHERE progress = 6 and user_id = #{userId}")
int selectProgressFinish(@Param("userId") String userId);
@Select("SELECT COUNT(progress) FROM stu_training WHERE user_id = #{userId} AND (exp_training_score <> 0 AND exp_training_score IS NOT NULL)")

@ -40,9 +40,12 @@ public interface StuUserMapper {
void batchInsertStudents(List<StuUser> users);
List<StuUserDto> selectByCondition(@Param("classId") String classId,
List<StuUserDto> selectByCondition(@Param("schoolId") String schoolId,
@Param("module") String module,
@Param("keyWord") String keyWord,
@Param("schoolId") String schoolId);
@Param("classId") String classId,
@Param("keyWord") String keyWord);
@Select("select count(*) from stu_userinfo where class_id = #{s}")
int selectNumByClass(@Param("s") String s);
}

@ -6,6 +6,8 @@ import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@Mapper
public interface TeaAndStudentExamMapper {
long countByExample(TeaAndStudentExamExample example);
@ -29,4 +31,7 @@ public interface TeaAndStudentExamMapper {
int updateByPrimaryKeySelective(TeaAndStudentExam record);
int updateByPrimaryKey(TeaAndStudentExam record);
@Select("select class_id from tea_and_student_exam where exam_manage_id =#{examManageId}")
String selectByExamId(@Param("examManageId") String examManageId);
}

@ -47,7 +47,6 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
private StuTrainingMapper stuTrainingMapper;
@Override
public PageInfo<TeaTrainingInfoDTO> getTrainingInfo(Integer index, Integer size, String schoolId, String keyWord, String classId, String userId) {
List<TeaTrainingInfoDTO> list = getTeaTrainingInfoDTOS(schoolId, keyWord, classId, userId);
@ -175,7 +174,9 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
SysCourseChapter sysCourseChapter = sysCourseChapterMapper.selectByPrimaryKey(stuTrainingWithBLOB.getChapterId());
TeaTrainingDto newData = new TeaTrainingDto();
BeanUtils.copyProperties(stuTrainingWithBLOBs, newData);
if (sysCourseChapter != null) {
newData.setTaskModule(sysCourseChapter.getChapterName());
}
if (StringUtils.isNotBlank(stuTrainingWithBLOB.getReportId())) {
String reportId = stuTrainingWithBLOB.getReportId();
TrainingReport trainingReport = trainingReportMapper.selectByPrimaryKey(reportId);
@ -300,7 +301,7 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
if (stuUsers.isEmpty()) {
return null;
} else {
for (StuUser stuUser : stuUsers) {
for (StuUser stuUser : stuUsers) { //先查出学校下所有的用户ID再根据USERid去实训表中查实训记录实训记录为空就跳过有数据就封装
TeaTrainingInfoDTO teaTrainingInfoDTO = new TeaTrainingInfoDTO();
StuClass stuClass = classMapper.selectByPrimaryKey(stuUser.getClassId());
//封装user表的数据
@ -308,29 +309,25 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
teaTrainingInfoDTO.setStudentId(stuUser.getStudentId());
teaTrainingInfoDTO.setName(stuUser.getName());
teaTrainingInfoDTO.setUserId(stuUser.getUserid());
//求实训进度
//看用户在实训表有没有记录
StuTrainingExample stuTrainingExample = new StuTrainingExample();
stuTrainingExample.createCriteria().andProgressEqualTo(BigDecimal.valueOf(6)).andUserIdEqualTo(stuUser.getUserid()); //进度为6代表这个章节完成了
stuTrainingExample.createCriteria().andUserIdEqualTo(stuUser.getUserid());
List<StuTrainingWithBLOBs> stuTrainings = trainingMapper.selectByExampleWithBLOBs(stuTrainingExample);
int trainingSize = stuTrainingMapper.selectProgressFinish(userId); //已学任务数量
if (stuTrainings.isEmpty()) {
teaTrainingInfoDTO.setProgress(BigDecimal.ZERO); //实训表为0设置为0
teaTrainingInfoDTO.setTotalScore(BigDecimal.ZERO);
list.add(teaTrainingInfoDTO);
int trainingSize = stuTrainingMapper.selectProgressFinish(stuUser.getUserid()); //已学任务数量
if (stuTrainings.isEmpty()) { //实训为空跳过这个用户
continue;
}
for (StuTrainingWithBLOBs stuTrainingWithBLOB : stuTrainings) {
if (trainingSize != 0 && chapterNum != 0) {
int i = chapterNum / trainingSize; //综合进度
int i = trainingSize / chapterNum; //综合进度
teaTrainingInfoDTO.setProgress(BigDecimal.valueOf(i));
}
//求综合得分 拿到每个已完成的章节分数
BigDecimal totalScore = BigDecimal.valueOf(0);
if (stuTrainings.isEmpty()) {
list.add(teaTrainingInfoDTO);
continue;
}
for (StuTrainingWithBLOBs stuTrainingWithBLOB : stuTrainings) {
teaTrainingInfoDTO.setTrainingId(stuTrainingWithBLOB.getTrainingId());
TrainingReport trainingReport = trainingReportMapper.selectByPrimaryKey(stuTrainingWithBLOB.getReportId());
BigDecimal reportScore = null;
if (trainingReport != null) {
@ -355,12 +352,12 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
if (learningEvalScore != null && BigDecimal.ZERO.compareTo(learningEvalScore) == 0) {
totalScore = totalScore.add(learningEvalScore);
}
}
}
int score = totalScore.intValue() / chapterNum; //已完成的模块分数/总模块数量
teaTrainingInfoDTO.setTotalScore(BigDecimal.valueOf(score));
}
list.add(teaTrainingInfoDTO);
}
}
return list;
}
}
@ -368,10 +365,17 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
public class TotalScoreComparator implements Comparator<TeaTrainingInfoDTO> {
@Override
public int compare(TeaTrainingInfoDTO o1, TeaTrainingInfoDTO o2) {
if (o2.getTotalScore() == null && o1.getTotalScore() == null) {
return 0;
} else if (o1 == null) {
return -1;
} else if (o2 == null) {
return 1;
} else {
return Integer.compare(o2.getTotalScore().intValueExact(), o1.getTotalScore().intValueExact());
}
}
}
/*
* @author xcj

@ -386,18 +386,17 @@
from stu_userinfo u
JOIN training_report r ON u.userid = r.user_id
JOIN stu_class sc ON u.class_id = sc.class_id
<where>
AND u.school_id = #{schoolId}
<if test="module != null">
AND r.chapter_name = #{module}
</if>
<if test="classId != null">
where
u.school_id = #{schoolId}
<if test="classId != null and classId !=''">
AND u.class_id = #{classId}
</if>
<if test="keyWord != null">
<if test="module != null and module !=''">
AND r.chapter_name = #{module}
</if>
<if test="keyWord != null and keyWord!=''">
AND (u.name = #{keyWord} OR u.student_id = #{keyWord})
</if>
</where>
ORDER BY r.teacher_score DESC
</select>

Loading…
Cancel
Save