123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435 |
- package com.qmth.distributed.print.api;
- import cn.hutool.core.date.DateUtil;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.deepoove.poi.XWPFTemplate;
- import com.deepoove.poi.data.style.CellStyle;
- import com.deepoove.poi.data.style.ParagraphStyle;
- import com.deepoove.poi.data.style.RowStyle;
- import com.qmth.boot.api.constant.ApiConstant;
- import com.qmth.distributed.print.business.bean.dto.report.*;
- import com.qmth.distributed.print.business.bean.result.ScoreResult;
- import com.qmth.distributed.print.business.bean.result.report.ReportResult;
- import com.qmth.distributed.print.business.bean.result.report.word.CourseBasicBean;
- import com.qmth.distributed.print.business.bean.result.report.word.CourseReportBean;
- import com.qmth.distributed.print.business.entity.TRBasicInfo;
- import com.qmth.distributed.print.business.entity.TRExamStudent;
- import com.qmth.distributed.print.business.service.PrintCommonService;
- import com.qmth.distributed.print.business.service.TRBasicInfoService;
- import com.qmth.distributed.print.business.service.TRExamStudentService;
- import com.qmth.teachcloud.common.annotation.OperationLogDetail;
- import com.qmth.teachcloud.common.contant.SystemConstant;
- import com.qmth.teachcloud.common.entity.SysUser;
- import com.qmth.teachcloud.common.enums.log.CustomizedOperationTypeEnum;
- import com.qmth.teachcloud.common.util.ResultUtil;
- import com.qmth.teachcloud.common.util.ServletUtil;
- import com.qmth.teachcloud.mark.entity.MarkPaper;
- import com.qmth.teachcloud.mark.service.MarkPaperService;
- import io.swagger.annotations.*;
- import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
- import org.apache.poi.xwpf.usermodel.XWPFTableCell;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.util.CollectionUtils;
- import org.springframework.validation.BindingResult;
- import org.springframework.web.bind.annotation.*;
- import javax.annotation.Resource;
- import javax.validation.Valid;
- import javax.validation.constraints.Max;
- import javax.validation.constraints.Min;
- import java.io.IOException;
- import java.util.*;
- /**
- * <p>
- * 报告基本情况表 前端控制器
- * </p>
- *
- * @author wangliang
- * @since 2024-02-18
- */
- @Api(tags = "课程目标达成度-报告基本情况Controller")
- @RestController
- @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_COURSE_DEGREE)
- public class TRBasicInfoController {
- @Resource
- PrintCommonService printCommonService;
- @Resource
- MarkPaperService markPaperService;
- @Resource
- TRBasicInfoService trBasicInfoService;
- @Resource
- TRExamStudentService trExamStudentService;
- @ApiOperation(value = "报告管理列表")
- @RequestMapping(value = "/report/list", method = RequestMethod.POST)
- @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.SEARCH)
- @ApiResponses({@ApiResponse(code = 200, message = "分页查询", response = ScoreResult.class)})
- public Object reportList(@ApiParam(value = "考试ID", required = true) @RequestParam Long examId,
- @ApiParam(value = "课程编码") @RequestParam(required = false) String courseCode,
- @ApiParam(value = "分页页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
- @ApiParam(value = "分页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
- return ResultUtil.ok(printCommonService.scoreList(new Page<>(pageNumber, pageSize), examId, courseCode));
- }
- @ApiOperation(value = "查看报告")
- @RequestMapping(value = "/report/view", method = RequestMethod.POST)
- @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.SEARCH)
- @ApiResponses({@ApiResponse(code = 200, message = "查看报告", response = ReportResult.class)})
- @Transactional
- public Object reportView(@ApiParam(value = "考试id", required = true) @RequestParam Long examId,
- @ApiParam(value = "科目编码", required = true) @RequestParam String courseCode,
- @ApiParam(value = "试卷编号", required = true) @RequestParam String paperNumber) {
- MarkPaper markPaper = markPaperService.getByExamIdAndPaperNumber(examId, paperNumber);
- Objects.requireNonNull(markPaper, "未找到科目信息");
- SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
- TRBasicInfo trBasicInfo = trBasicInfoService.getOne(new QueryWrapper<TRBasicInfo>().lambda().eq(TRBasicInfo::getExamId, examId).eq(TRBasicInfo::getCourseCode, courseCode).eq(TRBasicInfo::getPaperNumber, paperNumber));
- if (Objects.isNull(trBasicInfo)) {
- trBasicInfo = trBasicInfoService.getReportView(trBasicInfo, markPaper, sysUser.getId());
- } else {
- ReportCourseBasicInfoDto reportCourseBasicInfoDto = new ReportCourseBasicInfoDto(trBasicInfo);
- ReportCourseEvaluationSpreadDto reportCourseEvaluationSpreadDto = Objects.nonNull(trBasicInfo.getCourseEvaluationSpread()) ? JSONObject.parseObject(trBasicInfo.getCourseEvaluationSpread(), ReportCourseEvaluationSpreadDto.class) : null;
- ReportCourseEvaluationResultDto reportCourseEvaluationResultDto = Objects.nonNull(trBasicInfo.getCourseEvaluationResult()) ? JSONObject.parseObject(trBasicInfo.getCourseEvaluationResult(), ReportCourseEvaluationResultDto.class) : null;
- ReportCourseEvaluationResultDetailDto reportCourseEvaluationResultDetailDto = null;
- List<TRExamStudent> trExamStudentList = trExamStudentService.list(new QueryWrapper<TRExamStudent>().lambda().eq(TRExamStudent::getrBasicInfoId, trBasicInfo.getId()));
- if (!CollectionUtils.isEmpty(trExamStudentList)) {
- List<ReportExamStudentDto> examStudentList = new ArrayList<>(trExamStudentList.size());
- for (TRExamStudent trExamStudent : trExamStudentList) {
- examStudentList.add(new ReportExamStudentDto(trExamStudent));
- }
- reportCourseEvaluationResultDetailDto = new ReportCourseEvaluationResultDetailDto(examStudentList);
- }
- trBasicInfo.setReportResult(new ReportResult(new ReportCommonDto(examId, courseCode, markPaper.getCourseName(), paperNumber), reportCourseBasicInfoDto, reportCourseEvaluationSpreadDto, reportCourseEvaluationResultDto, reportCourseEvaluationResultDetailDto));
- }
- trBasicInfo.updateInfo(sysUser.getId());
- //课程目标达成评价明细结果-课程目标达成评价值图
- trBasicInfoService.saveOrUpdate(trBasicInfo);
- return ResultUtil.ok(trBasicInfo.getReportResult());
- }
- @ApiOperation(value = "保存报告")
- @RequestMapping(value = "/report/save", method = RequestMethod.POST)
- @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.UPDATE)
- @ApiResponses({@ApiResponse(code = 200, message = "保存报告", response = Object.class)})
- @Transactional
- public Object reportSave(@ApiParam(value = "保存报告结构", required = true) @Valid @RequestBody TRBasicInfo trBasicInfo, BindingResult bindingResult) {
- if (bindingResult.hasErrors()) {
- return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
- }
- SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
- TRBasicInfo trBasicInfoDb = trBasicInfoService.getOne(new QueryWrapper<TRBasicInfo>().lambda().eq(TRBasicInfo::getExamId, trBasicInfo.getExamId()).eq(TRBasicInfo::getCourseCode, trBasicInfo.getCourseCode()).eq(TRBasicInfo::getPaperNumber, trBasicInfo.getPaperNumber()));
- if (Objects.isNull(trBasicInfoDb)) {
- trBasicInfoDb = new TRBasicInfo(trBasicInfo, sysUser.getId());
- MarkPaper markPaper = markPaperService.getByExamIdAndPaperNumber(trBasicInfo.getExamId(), trBasicInfo.getPaperNumber());
- Objects.requireNonNull(markPaper, "未找到科目信息");
- trBasicInfoDb = trBasicInfoService.getReportView(trBasicInfoDb, markPaper, sysUser.getId());
- } else {
- trBasicInfoDb.updateInfo(trBasicInfo, sysUser.getId());
- }
- return ResultUtil.ok(trBasicInfoService.saveOrUpdate(trBasicInfoDb));
- }
- @ApiOperation(value = "导出报告")
- @RequestMapping(value = "/report/export", method = RequestMethod.POST)
- @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.EXPORT)
- @ApiResponses({@ApiResponse(code = 200, message = "下载成功", response = Object.class)})
- public void reportExport(@ApiParam(value = "考试id", required = true) @RequestParam Long examId,
- @ApiParam(value = "科目编码", required = true) @RequestParam String courseCode,
- @ApiParam(value = "试卷编号", required = true) @RequestParam String paperNumber) throws IOException {
- TRBasicInfo trBasicInfo = trBasicInfoService.getOne(new QueryWrapper<TRBasicInfo>().lambda().eq(TRBasicInfo::getExamId, examId).eq(TRBasicInfo::getCourseCode, courseCode).eq(TRBasicInfo::getPaperNumber, paperNumber));
- Objects.requireNonNull(trBasicInfo, "没有报告信息");
- Objects.requireNonNull(trBasicInfo.getCourseEvaluationResult(), "没有课程目标信息");
- Objects.requireNonNull(trBasicInfo.getCourseEvaluationResultDetail(), "没有课程考生信息");
- //评价样本的基本信息
- String period = Objects.nonNull(trBasicInfo.getPeriod()) ? trBasicInfo.getPeriod() : null;
- String credit = Objects.nonNull(trBasicInfo.getCredit()) ? trBasicInfo.getCredit() : null;
- period = Objects.nonNull(credit) ? period + "/" + credit : period;
- ReportCourseEvaluationResultDto reportCourseEvaluationResultDto = JSONObject.parseObject(trBasicInfo.getCourseEvaluationResult(), ReportCourseEvaluationResultDto.class);
- CourseBasicBean courseBasicBean = new CourseBasicBean(trBasicInfo.getCourseName(),
- trBasicInfo.getCourseCode(), null, trBasicInfo.getCourseType(),
- period, null, null, trBasicInfo.getDirector(),
- DateUtil.format(new Date(trBasicInfo.getCreateTime()), SystemConstant.DEFAULT_DATE_PATTERN),
- "测试:我们的目标是没有目标", reportCourseEvaluationResultDto.getTargetList().size());
- CourseReportBean courseReportBean = new CourseReportBean(trBasicInfo.getOpenTime() + "《" + trBasicInfo.getCourseName() + "》", courseBasicBean);
- JSONObject jsonObject = JSONObject.parseObject(trBasicInfo.getCourseEvaluationResultDetail());
- List<CourseTargetWordDto> courseTargetWordDtoList = JSONArray.parseArray(jsonObject.get("targetWordMap").toString(), CourseTargetWordDto.class);
- List<CourseTargetWebDto> courseTargetWebDtoList = JSONArray.parseArray(jsonObject.get("targetWebMap").toString(), CourseTargetWebDto.class);
- //table1-课程目标目标与毕业要求指标点的对应关系
- List<String> header2_1List = new ArrayList<>(Arrays.asList("课程目标", "支撑毕业要求")), header2_2List = new ArrayList<>();
- header2_2List.addAll(header2_1List);
- header2_1List.add("考核/评价环节及目标分值");
- courseReportBean.setCourseTargetTable1(trBasicInfoService.buildWordTable1(courseTargetWordDtoList, header2_1List, header2_2List));
- //table2-课程目标达成评价依据
- courseReportBean.setCourseTargetTable2(trBasicInfoService.buildWordTable2(courseTargetWordDtoList, courseTargetWebDtoList, header2_1List, header2_2List));
- //table3-课程课后作业考核/评价内容及目标分值
- courseReportBean.setCourseTargetTable3(trBasicInfoService.buildWordTable3(courseTargetWordDtoList));
- //table4-课程期末考试考核/评价内容及目标分值
- courseReportBean.setCourseTargetTable4(trBasicInfoService.buildWordTable4(courseTargetWordDtoList));
- //examstudent-课程目标达成评价依据-考生
- // List<TRExamStudent> trExamStudentList = trExamStudentService.list(new QueryWrapper<TRExamStudent>().lambda().eq(TRExamStudent::getrBasicInfoId, trBasicInfo.getId()));
- // if (!CollectionUtils.isEmpty(trExamStudentList)) {
- //// List<FinalScoreResult> finalScoreResultList = tcFinalScoreService.examStudentOverview(trBasicInfo.getExamId(), trBasicInfo.getCourseCode(), trBasicInfo.getPaperNumber());//考生成绩
- //// Map<String, FinalScoreResult> finalScoreResultMap = finalScoreResultList.stream().collect(Collectors.toMap(FinalScoreResult::getStudentCode, Function.identity(), (dto1, dto2) -> dto1));
- //
- // List<CellRenderData> examStudent_cells_1 = new ArrayList<>(), examStudent_cells_2 = new ArrayList<>(), examStudent_cells_3 = new ArrayList<>(), examStudent_cells_4 = new ArrayList<>(), examStudent_cells_5 = new ArrayList<>();
- // examStudent_cells_1.add(Cells.of("序号").center().create());
- // examStudent_cells_1.add(Cells.of("学号").center().create());
- // examStudent_cells_1.add(Cells.of("姓名").center().create());
- // examStudent_cells_1.add(Cells.of("行政班级").center().create());
- // examStudent_cells_2.addAll(examStudent_cells_1);
- //
- // examStudent_cells_3.add(Cells.of("课程目标考核要素的目标分").center().create());
- // examStudent_cells_3.add(Cells.of("").center().create());
- // examStudent_cells_3.add(Cells.of("").center().create());
- // examStudent_cells_3.add(Cells.of("").center().create());
- //
- // examStudent_cells_4.add(Cells.of("课程目标考核要素的平均分").center().create());
- // examStudent_cells_4.add(Cells.of("").center().create());
- // examStudent_cells_4.add(Cells.of("").center().create());
- // examStudent_cells_4.add(Cells.of("").center().create());
- //
- // examStudent_cells_5.add(Cells.of("各课程目标平均分").center().create());
- // examStudent_cells_5.add(Cells.of("").center().create());
- // examStudent_cells_5.add(Cells.of("").center().create());
- // examStudent_cells_5.add(Cells.of("").center().create());
- //
- // List<ExamStudentTableBean> examStudentTableBeanList = new ArrayList<>();
- // int seq5 = 0;
- // Map<Long, Integer> targetUsualScoreSizeMap = new HashMap<>();
- // trExamStudentList.remove(trExamStudentList.size() - 1);
- // TRExamStudent trExamStudentTemp = trExamStudentList.get(0);
- //
- // //首行
- // if (Objects.nonNull(trExamStudentTemp.getResultDetail())) {
- // List<ReportExamStudentTargetDto> reportExamStudentTargetDtoList = JSONArray.parseArray(trExamStudentTemp.getResultDetail(), ReportExamStudentTargetDto.class);
- // for (ReportExamStudentTargetDto reportExamStudentTargetDto : reportExamStudentTargetDtoList) {
- // examStudent_cells_1.add(Cells.of(reportExamStudentTargetDto.getTargetName()).center().create());
- // ReportExamStudentUsualScoreDto reportExamStudentUsualScoreDto = reportExamStudentTargetDto.getUsualScore();
- // //平常作业
- // if (Objects.nonNull(reportExamStudentUsualScoreDto) && !CollectionUtils.isEmpty(reportExamStudentUsualScoreDto.getScoreList())) {
- // List<ReportExamStudentUsualScoreObjDto> reportExamStudentUsualScoreObjDtoList = reportExamStudentUsualScoreDto.getScoreList();
- // for (ReportExamStudentUsualScoreObjDto reportExamStudentUsualScoreObjDto : reportExamStudentUsualScoreObjDtoList) {
- // if (!targetUsualScoreSizeMap.containsKey(reportExamStudentTargetDto.getTargetId())) {
- // targetUsualScoreSizeMap.put(reportExamStudentTargetDto.getTargetId(), 1);
- // } else {
- // Integer size = targetUsualScoreSizeMap.get(reportExamStudentTargetDto.getTargetId());
- // targetUsualScoreSizeMap.put(reportExamStudentTargetDto.getTargetId(), size++);
- // }
- // examStudent_cells_1.add(Cells.of("").center().create());
- // //报错暂时去掉,记得恢复
- //// examStudent_cells_2.add(Cells.of(reportExamStudentUsualScoreObjDto.getName()).center().create());
- // }
- // }
- // //期末考试
- // ReportExamStudentFinalScoreDto reportExamStudentFinalScoreDto = reportExamStudentTargetDto.getFinalScore();
- // if (Objects.nonNull(reportExamStudentFinalScoreDto) && !CollectionUtils.isEmpty(reportExamStudentFinalScoreDto.getDimensionList())) {
- // examStudent_cells_2.add(Cells.of("期末考试").center().create());
- // }
- // }
- // examStudent_cells_1.add(Cells.of("综合成绩").center().create());
- // examStudent_cells_2.add(Cells.of("综合成绩").center().create());
- // }
- //
- // for (int i = 0; i < trExamStudentList.size(); i++) {
- // TRExamStudent trExamStudent = trExamStudentList.get(i);
- // LinkedMultiValueMap<Long, Map<String, ExamStudentScoreBean>> scoreMap = new LinkedMultiValueMap<>();
- // if (Objects.nonNull(trExamStudent.getResultDetail())) {
- // List<ReportExamStudentTargetDto> reportExamStudentTargetDtoList = JSONArray.parseArray(trExamStudent.getResultDetail(), ReportExamStudentTargetDto.class);
- // for (ReportExamStudentTargetDto reportExamStudentTargetDto : reportExamStudentTargetDtoList) {
- // if (Objects.nonNull(reportExamStudentTargetDto)) {
- // ReportExamStudentUsualScoreDto reportExamStudentUsualScoreDto = reportExamStudentTargetDto.getUsualScore();
- // //平常作业
- // if (Objects.nonNull(reportExamStudentUsualScoreDto) && !CollectionUtils.isEmpty(reportExamStudentUsualScoreDto.getScoreList())) {
- // List<ReportExamStudentUsualScoreObjDto> reportExamStudentUsualScoreObjDtoList = reportExamStudentUsualScoreDto.getScoreList();
- // for (ReportExamStudentUsualScoreObjDto reportExamStudentUsualScoreObjDto : reportExamStudentUsualScoreObjDtoList) {
- //// scoreMap.add(reportExamStudentTargetDto.getTargetId(), Collections.singletonMap(reportExamStudentUsualScoreObjDto.getName(), new ExamStudentScoreBean(reportExamStudentUsualScoreObjDto.getScore())));
- // }
- // }
- // //期末考试
- // ReportExamStudentFinalScoreDto reportExamStudentFinalScoreDto = reportExamStudentTargetDto.getFinalScore();
- // if (Objects.nonNull(reportExamStudentFinalScoreDto) && !CollectionUtils.isEmpty(reportExamStudentFinalScoreDto.getDimensionList())) {
- // Double sumScore = reportExamStudentFinalScoreDto.getDimensionList().stream().mapToDouble(DimensionDto::getDimensionScore).sum();
- // scoreMap.add(reportExamStudentTargetDto.getTargetId(), Collections.singletonMap("期末考试", new ExamStudentScoreBean(sumScore)));
- // }
- // }
- // }
- // seq5 = seq5 + 1;
- // examStudentTableBeanList.add(new ExamStudentTableBean(seq5, trExamStudent.getStudentCode(), trExamStudent.getName(), trExamStudent.getAdministrativeClass(), scoreMap, 0.0d));
- // }
- // }
- //
- // String title = trBasicInfo.getTeachingObject();
- // String sumTitle = "学生共${sum}名";
- // sumTitle = sumTitle.replace("${sum}", trExamStudentList.size() + "");
- //
- // courseReportBean.setExamStudentTitle1(title + sumTitle);
- // courseReportBean.setExamStudentTitle2(title + "《" + courseReportBean.getCourseBasicBean().getCourseName() + "》");
- //
- // RowRenderData[] rowRenderDataExamStudent = new RowRenderData[trExamStudentList.size() + 5];
- //
- // RowRenderData examStudent_header_1 = new RowRenderData();
- // examStudent_header_1.setCells(examStudent_cells_1);
- // examStudent_header_1.setRowStyle(this.getHeadRowStyle());
- //
- // RowRenderData examStudent_header_2 = new RowRenderData();
- // examStudent_header_2.setCells(examStudent_cells_2);
- // examStudent_header_2.setRowStyle(this.getHeadRowStyle());
- //
- // for (int i = 0; i < examStudentTableBeanList.size(); i++) {
- // ExamStudentTableBean e = examStudentTableBeanList.get(i);
- // RowRenderData examStudent_row = new RowRenderData();
- // List<CellRenderData> examStudent_cells = new ArrayList<>();
- // examStudent_cells.add(Cells.of(e.getNum().toString()).create());
- // examStudent_cells.add(Cells.of(e.getStudentCode()).create());
- // examStudent_cells.add(Cells.of(e.getName()).create());
- // examStudent_cells.add(Cells.of(e.getAdministrativeClass()).create());
- //
- // String key = null;
- // LinkedMultiValueMap<Long, Map<String, ExamStudentScoreBean>> map = e.getMap();
- // for (Map.Entry<Long, List<Map<String, ExamStudentScoreBean>>> entry : map.entrySet()) {
- // List<Map<String, ExamStudentScoreBean>> list = entry.getValue();
- // BigDecimal courseSumAvg = new BigDecimal(0);
- // for (int y = 0; y < list.size(); y++) {
- // Map<String, ExamStudentScoreBean> m = list.get(y);
- // for (Map.Entry<String, ExamStudentScoreBean> entry1 : m.entrySet()) {
- // courseSumAvg = courseSumAvg.add(new BigDecimal(entry1.getValue().getScore()));
- // entry1.getValue().setAllScore(new BigDecimal(new Random().nextInt(10) + 1).doubleValue());
- // key = entry1.getKey();
- // examStudent_cells.add(Cells.of(entry1.getValue().getScore().toString()).create());
- // }
- // if (y == list.size() - 1) {
- // courseSumAvg = courseSumAvg.divide(new BigDecimal(list.size()), 2, BigDecimal.ROUND_HALF_UP)
- // .setScale(2, BigDecimal.ROUND_HALF_UP);
- // list.get(y).get(key).setAvgAllScore(courseSumAvg.doubleValue());
- // }
- // }
- // }
- // if (i == examStudentTableBeanList.size() - 1) {
- // LinkedMultiValueMap<Long, Map<String, ExamStudentScoreBean>> map1 = e.getMap();
- // for (Map.Entry<Long, List<Map<String, ExamStudentScoreBean>>> entry1 : map1.entrySet()) {
- // List<Map<String, ExamStudentScoreBean>> list1 = entry1.getValue();
- // for (int k = 0; k < list1.size(); k++) {
- // Map<String, ExamStudentScoreBean> m = list1.get(k);
- // for (Map.Entry<String, ExamStudentScoreBean> entry2 : m.entrySet()) {
- // examStudent_cells_3.add(Cells.of(entry2.getValue().getTargetAllAvgScore().toString()).create());
- // examStudent_cells_4.add(Cells.of(entry2.getValue().getAllScore().toString()).create());
- // }
- // }
- // examStudent_cells_5.add(Cells.of(list1.get(list1.size() - 1).get(key).getAvgAllScore().toString()).create());
- // for (int k = 1; k < list1.size(); k++) {
- // examStudent_cells_5.add(Cells.of("").create());
- // }
- // }
- // examStudent_cells_3.add(Cells.of(e.getSumScore().toString()).create());
- // examStudent_cells_4.add(Cells.of(e.getSumScore().toString()).create());
- // examStudent_cells_5.add(Cells.of("").create());
- // }
- // examStudent_cells.add(Cells.of(e.getSumScore().toString()).create());
- // examStudent_row.setCells(examStudent_cells);
- // examStudent_row.setRowStyle(this.getRowStyle());
- // rowRenderDataExamStudent[i + 2] = examStudent_row;
- // }
- //
- // rowRenderDataExamStudent[0] = examStudent_header_1;
- // rowRenderDataExamStudent[1] = examStudent_header_2;
- // RowRenderData examStudent_row3 = new RowRenderData();
- // examStudent_row3.setCells(examStudent_cells_3);
- // examStudent_row3.setRowStyle(this.getRowStyle());
- // RowRenderData examStudent_row4 = new RowRenderData();
- // examStudent_row4.setCells(examStudent_cells_4);
- // examStudent_row4.setRowStyle(this.getRowStyle());
- // RowRenderData examStudent_row5 = new RowRenderData();
- // examStudent_row5.setCells(examStudent_cells_5);
- // examStudent_row5.setRowStyle(this.getRowStyle());
- //
- // rowRenderDataExamStudent[rowRenderDataExamStudent.length - 3] = examStudent_row3;
- // rowRenderDataExamStudent[rowRenderDataExamStudent.length - 2] = examStudent_row4;
- // rowRenderDataExamStudent[rowRenderDataExamStudent.length - 1] = examStudent_row5;
- //
- // // 表格合并,根据坐标
- // MergeCellRule mergeCellRuleExamStudent = MergeCellRule.builder().build();
- // mergeCellRuleExamStudent.getMapping().add(new MergeCellRule.GridRule(MergeCellRule.Grid.of(0, 0), MergeCellRule.Grid.of(1, 0)));
- // mergeCellRuleExamStudent.getMapping().add(new MergeCellRule.GridRule(MergeCellRule.Grid.of(0, 1), MergeCellRule.Grid.of(1, 1)));
- // mergeCellRuleExamStudent.getMapping().add(new MergeCellRule.GridRule(MergeCellRule.Grid.of(0, 2), MergeCellRule.Grid.of(1, 2)));
- // mergeCellRuleExamStudent.getMapping().add(new MergeCellRule.GridRule(MergeCellRule.Grid.of(0, 3), MergeCellRule.Grid.of(1, 3)));
- // mergeCellRuleExamStudent.getMapping().add(new MergeCellRule.GridRule(MergeCellRule.Grid.of(rowRenderDataExamStudent.length - 3, 0), MergeCellRule.Grid.of(rowRenderDataExamStudent.length - 3, 3)));
- // mergeCellRuleExamStudent.getMapping().add(new MergeCellRule.GridRule(MergeCellRule.Grid.of(rowRenderDataExamStudent.length - 2, 0), MergeCellRule.Grid.of(rowRenderDataExamStudent.length - 2, 3)));
- // mergeCellRuleExamStudent.getMapping().add(new MergeCellRule.GridRule(MergeCellRule.Grid.of(rowRenderDataExamStudent.length - 1, 0), MergeCellRule.Grid.of(rowRenderDataExamStudent.length - 1, 3)));
- //
- // //动态扩展列
- // AtomicInteger initNum = new AtomicInteger(4);
- // targetUsualScoreSizeMap.forEach((k, v) -> {
- // int increaseNum = 1;
- // while (increaseNum <= v) {
- // mergeCellRuleExamStudent.getMapping().add(new MergeCellRule.GridRule(MergeCellRule.Grid.of(0, initNum.get()), MergeCellRule.Grid.of(0, initNum.get() + increaseNum)));
- // mergeCellRuleExamStudent.getMapping().add(new MergeCellRule.GridRule(MergeCellRule.Grid.of(rowRenderDataExamStudent.length - 1, initNum.get()), MergeCellRule.Grid.of(rowRenderDataExamStudent.length - 1, initNum.get() + increaseNum)));
- // increaseNum++;
- // }
- // initNum.set(initNum.get() + increaseNum);
- // });
- // mergeCellRuleExamStudent.getMapping().add(new MergeCellRule.GridRule(MergeCellRule.Grid.of(0, initNum.get()), MergeCellRule.Grid.of(1, initNum.get())));
- //
- // Tables.TableBuilder tableBuilderExamStudent = Tables.ofPercentWidth("100%");
- // for (int i = 0; i < rowRenderDataExamStudent.length; i++) {
- // tableBuilderExamStudent.addRow(rowRenderDataExamStudent[i]);
- // }
- // TableRenderData tableRenderDataExamStudent = tableBuilderExamStudent.mergeRule(mergeCellRuleExamStudent).left().create();
- // courseReportBean.setExamStudentTable1(tableRenderDataExamStudent);
- // }
- XWPFTemplate template = XWPFTemplate.compile("/Users/king/git/teachcloud-server/distributed-print/src/main/resources/static/course_degree_report.docx").render(courseReportBean);
- template.writeToFile("/Users/king/Downloads/demo_course_degree_report.docx");
- }
- /**
- * 获取行样式
- *
- * @return
- */
- protected RowStyle getRowStyle() {
- RowStyle rowStyle = new RowStyle();
- ParagraphStyle paragraphStyle = new ParagraphStyle();
- paragraphStyle.setAlign(ParagraphAlignment.LEFT);
- CellStyle cellStyle = new CellStyle();
- cellStyle.setDefaultParagraphStyle(paragraphStyle);
- cellStyle.setVertAlign(XWPFTableCell.XWPFVertAlign.CENTER);
- rowStyle.setDefaultCellStyle(cellStyle);
- return rowStyle;
- }
- /**
- * 获取行样式
- *
- * @return
- */
- protected RowStyle getHeadRowStyle() {
- RowStyle rowStyle = new RowStyle();
- ParagraphStyle paragraphStyle = new ParagraphStyle();
- paragraphStyle.setAlign(ParagraphAlignment.CENTER);
- CellStyle cellStyle = new CellStyle();
- cellStyle.setDefaultParagraphStyle(paragraphStyle);
- cellStyle.setBackgroundColor("F2F2F2");
- rowStyle.setDefaultCellStyle(cellStyle);
- return rowStyle;
- }
- }
|