|
|
|
@ -2,14 +2,21 @@ package com.blockchain.server.yyyf.controller; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.blockchain.common.base.constant.YyyfConstant; |
|
|
|
|
import com.blockchain.common.base.dto.ResultDTO; |
|
|
|
|
import com.blockchain.server.train.dto.ExamPaperDto; |
|
|
|
|
import com.blockchain.server.train.dto.TrainCaseTargetDto; |
|
|
|
|
import com.blockchain.server.yyyf.dto.PractiseProDto; |
|
|
|
|
import com.blockchain.server.yyyf.controller.api.StudentAnswerApi; |
|
|
|
|
import com.blockchain.server.yyyf.controller.api.TeachingGradeApi; |
|
|
|
|
import com.blockchain.server.yyyf.dto.ExamDetailsDto; |
|
|
|
|
import com.blockchain.server.yyyf.dto.OverviewDto; |
|
|
|
|
import com.blockchain.server.yyyf.dto.ReExamOverviewDto; |
|
|
|
|
import com.blockchain.server.yyyf.dto.StudentTargetErrorStatisticsDto; |
|
|
|
|
import com.blockchain.server.yyyf.entity.AssessUser; |
|
|
|
|
import com.blockchain.server.yyyf.service.AssessUserService; |
|
|
|
|
import com.blockchain.server.yyyf.service.AssessUserTargetService; |
|
|
|
|
import com.blockchain.server.yyyf.utils.ResponseUtils; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
import io.swagger.annotations.ApiParam; |
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCell; |
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFFont; |
|
|
|
@ -21,13 +28,9 @@ import org.slf4j.LoggerFactory; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.data.redis.core.HashOperations; |
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
|
import org.springframework.ui.Model; |
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
import springfox.documentation.annotations.ApiIgnore; |
|
|
|
|
import sun.misc.BASE64Decoder; |
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
@ -44,7 +47,8 @@ import java.util.Map; |
|
|
|
|
* @description 练习、考核成绩Controller |
|
|
|
|
* @date 2019-11-05 16:23 |
|
|
|
|
*/ |
|
|
|
|
@Controller |
|
|
|
|
@RestController |
|
|
|
|
@Api(TeachingGradeApi.CONTROLLER_API) |
|
|
|
|
@RequestMapping("/teachingGrade") |
|
|
|
|
public class TeachingGradeController { |
|
|
|
|
protected Logger logger = LoggerFactory.getLogger(TeachingGradeController.class); |
|
|
|
@ -65,20 +69,21 @@ public class TeachingGradeController { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* http://10.10.17.93:8080/BankTrain/teachingGrade/getGradeData?issueId=7e027a96764b4749b2a2d65cdc4a5c92&totalNum=10&caseId=38
|
|
|
|
|
* |
|
|
|
|
* @param [request, response] |
|
|
|
|
* @return void |
|
|
|
|
* @description 教师端获取错误率 (issueId:考核id【即reqId】;totalNum:班级总人数;caseId:项目id) |
|
|
|
|
* @description 教师获取考核概况 |
|
|
|
|
* @author huan.xu |
|
|
|
|
* @date 2019-11-08 18:03:39 |
|
|
|
|
* @date 2020-05-19 10:47:29 |
|
|
|
|
* @param [issueId, totalNum, caseId, response] |
|
|
|
|
* @return void |
|
|
|
|
**/ |
|
|
|
|
@GetMapping(value = "/getGradeData", produces = {"application/text;charset=UTF-8"}) |
|
|
|
|
@ResponseBody |
|
|
|
|
@SuppressWarnings("all") |
|
|
|
|
public void getGradeData( String issueId,Integer totalNum, String caseId, HttpServletResponse response) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = TeachingGradeApi.GetGradeData.METHOD_NAME, |
|
|
|
|
notes = TeachingGradeApi.GetGradeData.METHOD_NOTE) |
|
|
|
|
public void getGradeData(@ApiParam(TeachingGradeApi.GetGradeData.METHOD_ISSUE_ID) @RequestParam(name = "issueId") String issueId, |
|
|
|
|
@ApiParam(TeachingGradeApi.GetGradeData.METHOD_TOTAL_NUM) @RequestParam(name = "totalNum") Integer totalNum, |
|
|
|
|
@ApiParam(TeachingGradeApi.GetGradeData.METHOD_CASE_ID) @RequestParam(name = "caseId") String caseId, |
|
|
|
|
HttpServletResponse response) { |
|
|
|
|
|
|
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
|
try { |
|
|
|
@ -150,24 +155,22 @@ public class TeachingGradeController { |
|
|
|
|
private Map<String, Object> getWrongStatistics(String issueId, Integer totalNum, List<TrainCaseTargetDto> trainCaseTargeList) { |
|
|
|
|
Map<String, Object> wrongStatistics = new HashMap<String, Object>(); |
|
|
|
|
List<StudentTargetErrorStatisticsDto> studentTargetErrorStatisticsDtoLis = this.assessUserTargetService.getStudentTargetErrorStatisticsDtoListByIssueId(issueId); |
|
|
|
|
|
|
|
|
|
Map<String, Object> maxErrorRateInfo = null;//最大错误率信息记录
|
|
|
|
|
Map<String, Object> minErrorRateInfo = null;//最小错误率信息记录
|
|
|
|
|
//最大错误率信息记录
|
|
|
|
|
Map<String, Object> maxErrorRateInfo = null; |
|
|
|
|
//最小错误率信息记录
|
|
|
|
|
Map<String, Object> minErrorRateInfo = null; |
|
|
|
|
//记录考核点名称
|
|
|
|
|
String[] taskNames = new String[trainCaseTargeList.size()]; |
|
|
|
|
//记录错误率
|
|
|
|
|
double[] errorRates = new double[trainCaseTargeList.size()]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int i = 0; |
|
|
|
|
for (TrainCaseTargetDto trainCaseTargetDto : trainCaseTargeList) { |
|
|
|
|
String targetName = trainCaseTargetDto.getName(); |
|
|
|
|
taskNames[i] = targetName; |
|
|
|
|
|
|
|
|
|
//获取该考核点用户的答题情况
|
|
|
|
|
List<Map<String, Object>> userTasks = new ArrayList<Map<String, Object>>(); |
|
|
|
|
int errorCount = 0;//错误人数
|
|
|
|
|
//错误人数
|
|
|
|
|
int errorCount = 0; |
|
|
|
|
for (StudentTargetErrorStatisticsDto studentTargetErrorStatisticsDto : studentTargetErrorStatisticsDtoLis) { |
|
|
|
|
//答题错误记录人数
|
|
|
|
|
if (studentTargetErrorStatisticsDto.getTargetId().equals(trainCaseTargetDto.getId())) { |
|
|
|
@ -175,9 +178,10 @@ public class TeachingGradeController { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
double errorRate = (double) (errorCount) / (double) (totalNum) * 100;//计算错误率
|
|
|
|
|
errorRate = Double.valueOf(String.format("%.2f", errorRate));//四舍五入保留两位小数
|
|
|
|
|
//计算错误率
|
|
|
|
|
double errorRate = (double) (errorCount) / (double) (totalNum) * 100; |
|
|
|
|
//四舍五入保留两位小数
|
|
|
|
|
errorRate = Double.valueOf(String.format("%.2f", errorRate)); |
|
|
|
|
errorRates[i] = errorRate; |
|
|
|
|
//处理最大和最小错误率信息
|
|
|
|
|
if (maxErrorRateInfo == null) { |
|
|
|
@ -227,116 +231,79 @@ public class TeachingGradeController { |
|
|
|
|
return wrongStatistics; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param [reqType, issueId, userId, stuNo, userName, className, caseId, model] |
|
|
|
|
* @return java.lang.String |
|
|
|
|
* @description 获取考核详情 |
|
|
|
|
* @author huan.xu |
|
|
|
|
* @date 2019-11-08 18:27:50 |
|
|
|
|
**/ |
|
|
|
|
|
|
|
|
|
@RequestMapping("/studyGrade/mygrade") |
|
|
|
|
@ApiIgnore |
|
|
|
|
public String selectPractiseProList(String reqType, String issueId, String examName, Integer userId, String stuNo, String userName, String className, String caseId, Model model) { |
|
|
|
|
try {/* |
|
|
|
|
@PostMapping("/getExamOverview") |
|
|
|
|
@SuppressWarnings("all") |
|
|
|
|
@ApiOperation(value = TeachingGradeApi.GetExamOverview.METHOD_NAME, |
|
|
|
|
notes = TeachingGradeApi.GetExamOverview.METHOD_NOTE) |
|
|
|
|
public ResultDTO<OverviewDto> getExamOverview(@ApiParam(TeachingGradeApi.GetExamOverview.METHOD_REEXAMOVERVIEWDTO) ReExamOverviewDto reExamOverviewDto) { |
|
|
|
|
OverviewDto overviewDto = new OverviewDto(); |
|
|
|
|
try { |
|
|
|
|
AssessUser assessUser = null; |
|
|
|
|
List<String> assessUserIds = new ArrayList<String>(); |
|
|
|
|
model.addAttribute("assessUserIds", assessUserIds); |
|
|
|
|
model.addAttribute("reqType", reqType); |
|
|
|
|
model.addAttribute("caseId", caseId); |
|
|
|
|
if ("1".equals(reqType)) { //考核
|
|
|
|
|
assessUser = this.assessUserService.selectScore(SYS_CODE, issueId, userId); |
|
|
|
|
} else {//练习
|
|
|
|
|
List<AssessUser> assessUserList = this.assessUserService.selectAssessUserListByIssuerIdAndUserId(issueId, userId); |
|
|
|
|
for (AssessUser assessUserInner : assessUserList) { |
|
|
|
|
if ("1".equals(reExamOverviewDto.getReqType())) { //考试
|
|
|
|
|
assessUser = this.assessUserService.getAssessUserByIssueIdAndUserIdForExam(reExamOverviewDto.getIssueId(), reExamOverviewDto.getUserId()); |
|
|
|
|
} else { |
|
|
|
|
List<AssessUser> assessUserList = this.assessUserService.getAssessUserListByIssueIdAndUserId(reExamOverviewDto.getIssueId(), reExamOverviewDto.getUserId()); |
|
|
|
|
List<String> assessUserIdsList = new ArrayList<>(); |
|
|
|
|
for (AssessUser assessUserSingle : assessUserList) { |
|
|
|
|
if (assessUser == null) { |
|
|
|
|
//取第一个,最新的
|
|
|
|
|
assessUser = assessUserInner; |
|
|
|
|
} |
|
|
|
|
assessUserIds.add(assessUserInner.getId()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (assessUser != null) { //不为空,说明其做过
|
|
|
|
|
cratePractiseProDtosForNotNull(assessUser, model); |
|
|
|
|
} else { //为空,则生成一个,这个可不要,因为考核无答题的话,不会进入详情的页面
|
|
|
|
|
List<PractiseProDto> practiseProDtos = new ArrayList<PractiseProDto>(); |
|
|
|
|
//交易码
|
|
|
|
|
List<TiftrnDto> tiftrnDtoList = JedisUtil.getMapValueForList(JedisUtil.bulidKey(Const.TIFTRN_KEY), caseId, TiftrnDto.class); //获取所有交易关联信息
|
|
|
|
|
for (TiftrnDto tiftrnDto : tiftrnDtoList) { |
|
|
|
|
PractiseProDto practiseProDto = new PractiseProDto(); |
|
|
|
|
practiseProDto.setId(tiftrnDto.getTrxCode()); |
|
|
|
|
practiseProDto.setProjectCaseDesc(String.valueOf(tiftrnDto.getSerNum())); |
|
|
|
|
practiseProDto.setProjectScore(BigDecimal.ZERO); |
|
|
|
|
practiseProDto.setProName(tiftrnDto.getTrxName()); |
|
|
|
|
List<TestPointDto> testPoints = tiftrnDto.getTestPoints(); |
|
|
|
|
if (testPoints != null && testPoints.size() > 0) { |
|
|
|
|
List<PractiseTaskDto> taskList = new ArrayList<PractiseTaskDto>(); |
|
|
|
|
for (TestPointDto testPointDto : testPoints) { |
|
|
|
|
PractiseTaskDto practiseTaskDto = new PractiseTaskDto(); |
|
|
|
|
practiseTaskDto.setId(String.valueOf(testPointDto.getPointId())); |
|
|
|
|
practiseTaskDto.setAnswer(1); |
|
|
|
|
practiseTaskDto.setProjectName(tiftrnDto.getTrxName()); |
|
|
|
|
practiseTaskDto.setRightAnswer(testPointDto.getTestPointAnswer()); |
|
|
|
|
practiseTaskDto.setStuAnswer("-"); |
|
|
|
|
practiseTaskDto.setTaskName(testPointDto.getPointName()); |
|
|
|
|
practiseTaskDto.setTaskScore(BigDecimal.valueOf(testPointDto.getTestPointScore())); |
|
|
|
|
taskList.add(practiseTaskDto); |
|
|
|
|
} |
|
|
|
|
practiseProDto.setTaskList(taskList); |
|
|
|
|
} |
|
|
|
|
practiseProDtos.add(practiseProDto); |
|
|
|
|
} |
|
|
|
|
model.addAttribute("examDate", "-"); |
|
|
|
|
model.addAttribute("useTime", "00:00:00"); |
|
|
|
|
model.addAttribute("totalScore", BigDecimal.ZERO); |
|
|
|
|
model.addAttribute("practiseProDtos", practiseProDtos); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
model.addAttribute("stuNo", stuNo); |
|
|
|
|
model.addAttribute("userName", new String(new BASE64Decoder().decodeBuffer(userName.replaceAll(" ", "+")), "UTF-8")); |
|
|
|
|
model.addAttribute("className", new String(new BASE64Decoder().decodeBuffer(className.replaceAll(" ", "+")), "UTF-8")); |
|
|
|
|
model.addAttribute("examName", new String(new BASE64Decoder().decodeBuffer(examName.replaceAll(" ", "+")), "UTF-8")); |
|
|
|
|
model.addAttribute("caseInfo", JedisUtil.getMapValue(JedisUtil.bulidKey(Const.TIFPRO_KEY), caseId, TifPro.class).getCaseInfo()); |
|
|
|
|
*/} catch (Exception e) { |
|
|
|
|
logger.error("获取成绩失败: " + e.getMessage(), e); |
|
|
|
|
} |
|
|
|
|
return "/yyyf/exam_mesaage"; |
|
|
|
|
assessUser = assessUserSingle; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param [assessUserId, model] |
|
|
|
|
* @return java.lang.String |
|
|
|
|
* @description 练习用于上一次、下一次的页面切换 |
|
|
|
|
* @author huan.xu |
|
|
|
|
* @date 2019-11-08 18:46:05 |
|
|
|
|
**/ |
|
|
|
|
@RequestMapping("/studyGrade/examMesaageDetails") |
|
|
|
|
@ApiIgnore |
|
|
|
|
public String examMesaageDetails(String assessUserId, Model model) { |
|
|
|
|
AssessUser assessUser = this.assessUserService.selectAssessUserById(assessUserId.trim()); |
|
|
|
|
cratePractiseProDtosForNotNull(assessUser, model); |
|
|
|
|
return "/yyyf/exam_mesaage_details"; |
|
|
|
|
assessUserIdsList.add(assessUserSingle.getId()); |
|
|
|
|
} |
|
|
|
|
overviewDto.setAssessUserIdsList(assessUserIdsList); |
|
|
|
|
} |
|
|
|
|
double duration = assessUser.getEndTime().getTime() - assessUser.getStartTime().getTime(); |
|
|
|
|
StringBuilder stringBuilder = new StringBuilder(); |
|
|
|
|
stringBuilder.append(String.format("%02d", (int) Math.floor(duration / 1000 / 60 / 60))) |
|
|
|
|
.append(":").append(String.format("%02d", (int) Math.floor(duration / 1000 / 60 % 60))) |
|
|
|
|
.append(":").append(String.format("%02d", (int) Math.floor(duration / 1000 % 60))); |
|
|
|
|
//考试花费时间
|
|
|
|
|
overviewDto.setUseTime(stringBuilder.toString()); |
|
|
|
|
//考试开始时间
|
|
|
|
|
overviewDto.setExamDate(new SimpleDateFormat("yyyy/MM/dd").format(assessUser.getStartTime())); |
|
|
|
|
|
|
|
|
|
overviewDto.setAssessUserId(assessUser.getId()); |
|
|
|
|
//学生姓名
|
|
|
|
|
overviewDto.setUserName(new String(new BASE64Decoder().decodeBuffer(reExamOverviewDto.getUserName().replaceAll(" ", "+")), "UTF-8")); |
|
|
|
|
//班级名称
|
|
|
|
|
overviewDto.setClassName(new String(new BASE64Decoder().decodeBuffer(reExamOverviewDto.getClassName().replaceAll(" ", "+")), "UTF-8")); |
|
|
|
|
|
|
|
|
|
//考试成绩
|
|
|
|
|
overviewDto.setTotalScore(assessUser.getTotalScore()); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
logger.error(e.getMessage(), e); |
|
|
|
|
} |
|
|
|
|
return ResultDTO.requstSuccess(overviewDto); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param [assessUser, model] |
|
|
|
|
* @return void |
|
|
|
|
* @description 封装有成绩的答题详情 |
|
|
|
|
* @author huan.xu |
|
|
|
|
* @date 2019-11-08 18:38:41 |
|
|
|
|
**/ |
|
|
|
|
public void cratePractiseProDtosForNotNull(AssessUser assessUser, Model model) { |
|
|
|
|
List<PractiseProDto> practiseProDtos = null;//this.assessUserService.selectPractiseProList(assessUser.getId());
|
|
|
|
|
@GetMapping("/getExamDetails") |
|
|
|
|
@SuppressWarnings("all") |
|
|
|
|
@ApiOperation(value = TeachingGradeApi.GetExamDetails.METHOD_NAME, |
|
|
|
|
notes = TeachingGradeApi.GetExamDetails.METHOD_NOTE) |
|
|
|
|
public ResultDTO<ExamDetailsDto> getExamDetails(@ApiParam(TeachingGradeApi.GetExamDetails.METHOD_ASSESSUSER_ID)@RequestParam("assessUserId") String assessUserId, |
|
|
|
|
@ApiParam(TeachingGradeApi.GetExamDetails.METHOD_IS_FIRST)@RequestParam("isFirst") int isFirst) { |
|
|
|
|
ExamDetailsDto examDetailsDto = new ExamDetailsDto(); |
|
|
|
|
try { |
|
|
|
|
if (isFirst != 0) { |
|
|
|
|
AssessUser assessUser = this.assessUserService.selectById(assessUserId); |
|
|
|
|
double duration = assessUser.getEndTime().getTime() - assessUser.getStartTime().getTime(); |
|
|
|
|
String h = String.format("%02d", (int) Math.floor(duration / 1000 / 60 / 60)); |
|
|
|
|
String m = String.format("%02d", (int) Math.floor(duration / 1000 / 60 % 60)); |
|
|
|
|
String s = String.format("%02d", (int) Math.floor(duration / 1000 % 60)); |
|
|
|
|
model.addAttribute("useTime", h + ":" + m + ":" + s); |
|
|
|
|
model.addAttribute("totalScore", assessUser.getTotalScore()); |
|
|
|
|
model.addAttribute("examDate", new SimpleDateFormat("yyyy/MM/dd").format(assessUser.getStartTime())); |
|
|
|
|
model.addAttribute("practiseProDtos", practiseProDtos); |
|
|
|
|
model.addAttribute("assessUserId", assessUser.getId()); |
|
|
|
|
StringBuilder stringBuilder = new StringBuilder(); |
|
|
|
|
stringBuilder.append(String.format("%02d", (int) Math.floor(duration / 1000 / 60 / 60))) |
|
|
|
|
.append(":").append(String.format("%02d", (int) Math.floor(duration / 1000 / 60 % 60))) |
|
|
|
|
.append(":").append(String.format("%02d", (int) Math.floor(duration / 1000 % 60))); |
|
|
|
|
//考试花费时间
|
|
|
|
|
examDetailsDto.setUseTime(stringBuilder.toString()); |
|
|
|
|
//考试开始时间
|
|
|
|
|
examDetailsDto.setExamDate(new SimpleDateFormat("yyyy/MM/dd").format(assessUser.getStartTime())); |
|
|
|
|
//考试成绩
|
|
|
|
|
examDetailsDto.setTotalScore(assessUser.getTotalScore()); |
|
|
|
|
} |
|
|
|
|
examDetailsDto.setAssessUserTargetList(this.assessUserTargetService.selectAssessUserTargetByAssessUserId(assessUserId)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
logger.error(e.getMessage(), e); |
|
|
|
|
} |
|
|
|
|
return ResultDTO.requstSuccess(examDetailsDto); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -374,6 +341,7 @@ public class TeachingGradeController { |
|
|
|
|
|
|
|
|
|
@GetMapping("/export") |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiIgnore |
|
|
|
|
public void yhExport(HttpServletRequest request, HttpServletResponse response) {/* |
|
|
|
|
String examName = request.getParameter("examName"); |
|
|
|
|
String className = request.getParameter("className"); |
|
|
|
@ -570,11 +538,11 @@ public class TeachingGradeController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param [cell, wb, str, startIndex, endIndex] |
|
|
|
|
* @return void |
|
|
|
|
* @description poi实现单元格中部分字体颜色设定 |
|
|
|
|
* @author huan.xu |
|
|
|
|
* @date 2019-12-10 16:19:48 |
|
|
|
|
* @param [cell, wb, str, startIndex, endIndex] |
|
|
|
|
* @return void |
|
|
|
|
**/ |
|
|
|
|
private void setFontColor(HSSFWorkbook wb, HSSFCell cell, String str, int startIndex, int endIndex) { |
|
|
|
|
HSSFFont font = wb.createFont(); |
|
|
|
|