| | |
| | | import com.mindskip.xzs.domain.ExamPaperSubject; |
| | | import com.mindskip.xzs.domain.Subject; |
| | | import com.mindskip.xzs.domain.exam.ExamPaperAnswerObject; |
| | | import com.mindskip.xzs.domain.vo.ExamPaperDataExportVO; |
| | | import com.mindskip.xzs.domain.vo.ExamPaperDataVO; |
| | | import com.mindskip.xzs.domain.vo.ExamPaperStatisticVO; |
| | | import com.mindskip.xzs.service.ExamPaperAnswerService; |
| | |
| | | import com.mindskip.xzs.utility.DateTimeUtil; |
| | | import com.mindskip.xzs.utility.ExamUtil; |
| | | import com.mindskip.xzs.utility.PageInfoHelper; |
| | | import com.mindskip.xzs.utility.excel.ExcelUtils; |
| | | import com.mindskip.xzs.viewmodel.admin.paper.ExamPaperAnswerPageRequestVM; |
| | | import com.mindskip.xzs.viewmodel.student.exampaper.ExamPaperAnswerPageResponseVM; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | |
| | | vm.setSubjectName(name); |
| | | vm.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime())); |
| | | |
| | | // vm.setUserName(user.getRealName()); |
| | | return vm; |
| | | }); |
| | | // page.setList(page.getList().stream().filter(e -> e != null).collect(Collectors.toList())); |
| | | if (page.getList().size() > 0) { |
| | | Double avg = page.getList().stream().mapToInt(ExamPaperAnswerPageResponseVM -> Integer.parseInt(ExamPaperAnswerPageResponseVM.getUserScore())).average().getAsDouble(); |
| | | BigDecimal sum = page.getList().stream() |
| | | .map(ExamPaperAnswerPageResponseVM -> new BigDecimal(ExamPaperAnswerPageResponseVM.getUserScore())) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); // 计算总和 |
| | | Double avg = sum.divide(BigDecimal.valueOf(page.getList().size()), 2, RoundingMode.HALF_UP).doubleValue(); |
| | | page.getList().get(0).setAvgSource(avg); |
| | | } |
| | | return RestResponse.ok(page); |
| | |
| | | public RestResponse<Map<String, Object>> data(@RequestBody ExamPaperDataVO examPaperDataVO) { |
| | | return RestResponse.ok(examPaperAnswerService.data(examPaperDataVO)); |
| | | } |
| | | |
| | | @RequestMapping(value = "/export", method = RequestMethod.GET) |
| | | public void export(Integer id, Integer type, HttpServletResponse response) { |
| | | List<ExamPaperDataExportVO> list = examPaperAnswerService.dataExport(new ExamPaperDataVO().setId(id).setType(type)); |
| | | ExcelUtils.export(response, "分数统计", list, ExamPaperDataExportVO.class); |
| | | } |
| | | |
| | | } |