|
@@ -46,10 +46,14 @@ import com.qmth.teachcloud.obe.service.*;
|
|
|
import io.swagger.annotations.*;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
+import org.apache.poi.ss.usermodel.*;
|
|
|
+import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.LinkedMultiValueMap;
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
@@ -62,6 +66,7 @@ import java.io.FileInputStream;
|
|
|
import java.io.InputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -388,7 +393,6 @@ public class TRBasicInfoController {
|
|
|
@ApiParam(value = "试卷编号") @RequestParam(required = false) String paperNumber,
|
|
|
@ApiParam(value = "true:报告,false:成绩管理", required = true) @RequestParam boolean report) {
|
|
|
ObeCourseOutline obeCourseOutline = obeCourseOutlineService.findByCultureProgramIdAndCourseId(cultureProgramId, courseId);
|
|
|
-
|
|
|
ReportChangeResult reportChangeResult = new ReportChangeResult();
|
|
|
List<TCUsualScore> tcUsualScoreList = tcUsualScoreService.queryUsualScore(cultureProgramId, courseId, paperNumber);
|
|
|
if (CollectionUtils.isNotEmpty(tcUsualScoreList)) {
|
|
@@ -457,6 +461,122 @@ public class TRBasicInfoController {
|
|
|
return ResultUtil.ok(reportChangeResult);
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "导出平时成绩报告")
|
|
|
+ @RequestMapping(value = "/report/usual_score/export", method = RequestMethod.POST)
|
|
|
+ @OperationLogDetail(operationType = OperationTypeEnum.EXPORT)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "下载成功", response = Object.class)})
|
|
|
+ @Aac(rateLimit = @RateLimit(count = 1, period = 1000L))
|
|
|
+ public void reportUsualscoreExport(@ApiParam(value = "培养方案id", required = true) @RequestParam Long cultureProgramId,
|
|
|
+ @ApiParam(value = "课程id", required = true) @RequestParam Long courseId,
|
|
|
+ @ApiParam(value = "试卷编号") @RequestParam(required = false) String paperNumber) {
|
|
|
+ TRBasicInfo trBasicInfo = trBasicInfoService.queryBasicInfo(cultureProgramId, courseId, paperNumber);
|
|
|
+ Objects.requireNonNull(trBasicInfo, "没有报告信息");
|
|
|
+ Objects.requireNonNull(trBasicInfo.getCourseEvaluationResult(), "没有课程目标信息");
|
|
|
+ Objects.requireNonNull(trBasicInfo.getCourseEvaluationResultDetail(), "没有课程考生信息");
|
|
|
+
|
|
|
+ List<TRExamStudent> trExamStudentList = trExamStudentService.list(new QueryWrapper<TRExamStudent>().lambda()
|
|
|
+ .eq(TRExamStudent::getrBasicInfoId, trBasicInfo.getId()).and(w -> w.notIn(TRExamStudent::getStudentCode, "各课程目标平均分", "平均分", "目标分")));
|
|
|
+ if (CollectionUtils.isEmpty(trExamStudentList)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未找到学生信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ LinkedMultiValueMap<String, String> courseTargetMap = new LinkedMultiValueMap<>();
|
|
|
+ for (TRExamStudent t : trExamStudentList) {
|
|
|
+ if (Objects.nonNull(t.getResultDetail())) {
|
|
|
+ List<ReportExamStudentTargetDto> reportExamStudentTargetDtoList = JSONArray.parseArray(t.getResultDetail(), ReportExamStudentTargetDto.class);
|
|
|
+ for (ReportExamStudentTargetDto r : reportExamStudentTargetDtoList) {
|
|
|
+ if (Objects.nonNull(r.getUsualScore()) && CollectionUtils.isNotEmpty(r.getUsualScore().getScoreList())) {
|
|
|
+ for (ReportExamStudentUsualScoreObjDto reportExamStudentUsualScoreObjDto : r.getUsualScore().getScoreList()) {
|
|
|
+ if (!courseTargetMap.containsKey(r.getTargetName())) {
|
|
|
+ courseTargetMap.add(r.getTargetName(), reportExamStudentUsualScoreObjDto.getEvaluation());
|
|
|
+ } else {
|
|
|
+ List<String> list = courseTargetMap.get(r.getTargetName());
|
|
|
+ if (!list.contains(reportExamStudentUsualScoreObjDto.getEvaluation())) {
|
|
|
+ courseTargetMap.add(r.getTargetName(), reportExamStudentUsualScoreObjDto.getEvaluation());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
+ BasicSchool basicSchool = commonCacheService.schoolCache(schoolId);
|
|
|
+ String fileName = Objects.nonNull(basicSchool) ? basicSchool.getName() + "_" + trBasicInfo.getOpenTime() + "《" + trBasicInfo.getCourseName() + "》_平时成绩" : trBasicInfo.getOpenTime() + "《" + trBasicInfo.getCourseName() + "》_平时成绩";
|
|
|
+
|
|
|
+ SXSSFWorkbook wb = new SXSSFWorkbook();
|
|
|
+ Sheet sheet = wb.createSheet("过程考核");
|
|
|
+ CellStyle style = wb.createCellStyle();
|
|
|
+ style.setAlignment(HorizontalAlignment.CENTER); // 水平居中格式
|
|
|
+ style.setVerticalAlignment(VerticalAlignment.CENTER); //垂直居中
|
|
|
+ Row row1 = sheet.createRow(0);
|
|
|
+ Row row2 = sheet.createRow(1);
|
|
|
+
|
|
|
+ Cell cell = row1.createCell(0);
|
|
|
+ cell.setCellValue("姓名");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ CellRangeAddress region = new CellRangeAddress(0, 1, (short) 0, (short) 0);
|
|
|
+ sheet.addMergedRegion(region);
|
|
|
+ sheet.setColumnWidth(0, sheet.getColumnWidth(0) * 17 / 10);
|
|
|
+
|
|
|
+// courseTargetMap.add("测试1", "1");
|
|
|
+// courseTargetMap.add("测试1", "2");
|
|
|
+// courseTargetMap.add("测试1", "3");
|
|
|
+// courseTargetMap.add("测试1", "4");
|
|
|
+// courseTargetMap.add("测试2", "5");
|
|
|
+// courseTargetMap.add("测试2", "6");
|
|
|
+// courseTargetMap.add("测试3", "7");
|
|
|
+// courseTargetMap.add("测试4", "8");
|
|
|
+// courseTargetMap.add("测试5", "9");
|
|
|
+// courseTargetMap.add("测试5", "10");
|
|
|
+// courseTargetMap.add("测试5", "11");
|
|
|
+// courseTargetMap.add("测试5", "12");
|
|
|
+// courseTargetMap.add("测试5", "13");
|
|
|
+// courseTargetMap.add("测试5", "14");
|
|
|
+
|
|
|
+ AtomicInteger cellOneIndex = new AtomicInteger(1);
|
|
|
+ AtomicInteger oneFirst = new AtomicInteger(1);
|
|
|
+ AtomicInteger oneLast = new AtomicInteger(0);
|
|
|
+ AtomicInteger cellTwoIndex = new AtomicInteger(1);
|
|
|
+ for (Map.Entry<String, List<String>> entry : courseTargetMap.entrySet()) {
|
|
|
+ List<String> childKeys = entry.getValue();
|
|
|
+ String key = entry.getKey();
|
|
|
+ Cell cell1 = row1.createCell(cellOneIndex.get());
|
|
|
+ cell1.setCellValue(key);
|
|
|
+ cell1.setCellStyle(style);
|
|
|
+ oneLast.compareAndSet(oneLast.get(), oneLast.get() + childKeys.size());
|
|
|
+ if (oneFirst.get() != oneLast.get()) {
|
|
|
+ CellRangeAddress region1 = new CellRangeAddress(0, 0, (short) oneFirst.get(), (short) oneLast.get());
|
|
|
+ sheet.addMergedRegion(region1);
|
|
|
+ }
|
|
|
+ sheet.setColumnWidth(cellOneIndex.get(), sheet.getColumnWidth(cellOneIndex.get()) * 17 / 10);
|
|
|
+
|
|
|
+ cellOneIndex.compareAndSet(cellOneIndex.get(), cellOneIndex.get() + childKeys.size());
|
|
|
+ oneFirst.compareAndSet(oneFirst.get(), cellOneIndex.get());
|
|
|
+
|
|
|
+ for (String s : childKeys) {
|
|
|
+ Cell cell2 = row2.createCell(cellTwoIndex.get());
|
|
|
+ cell2.setCellValue(s);
|
|
|
+ cell2.setCellStyle(style);
|
|
|
+ sheet.setColumnWidth(cellTwoIndex.get(), sheet.getColumnWidth(cellTwoIndex.get()) * 17 / 10);
|
|
|
+ cellTwoIndex.incrementAndGet();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //绘制固定表头
|
|
|
+// sheet = drawExcelFixedHead(scoreInterval, sheet, style, row, subjectMap, workId);
|
|
|
+
|
|
|
+ for (int i = 0; i < trExamStudentList.size(); i++) {
|
|
|
+ TRExamStudent trExamStudent = trExamStudentList.get(i);
|
|
|
+ if (Objects.nonNull(trExamStudent.getResultDetail())) {
|
|
|
+ List<ReportExamStudentTargetDto> reportExamStudentTargetDtoList = JSONArray.parseArray(trExamStudent.getResultDetail(), ReportExamStudentTargetDto.class);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ExcelUtil.exportEXCEL(fileName, wb, ServletUtil.getResponse());
|
|
|
+ }
|
|
|
+
|
|
|
@Resource
|
|
|
WordToPdfUtil wordToPdfUtil;
|
|
|
|