TRBasicInfoController.java 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. package com.qmth.distributed.print.api;
  2. import com.alibaba.fastjson.JSONArray;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  5. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  6. import com.deepoove.poi.XWPFTemplate;
  7. import com.google.gson.reflect.TypeToken;
  8. import com.qmth.boot.api.annotation.Aac;
  9. import com.qmth.boot.api.constant.ApiConstant;
  10. import com.qmth.boot.api.exception.ApiException;
  11. import com.qmth.boot.core.rateLimit.annotation.RateLimit;
  12. import com.qmth.distributed.print.business.bean.dto.CourseWeightDetailDto;
  13. import com.qmth.distributed.print.business.bean.dto.CourseWeightDto;
  14. import com.qmth.distributed.print.business.bean.dto.TCUsualScoreDto;
  15. import com.qmth.distributed.print.business.bean.dto.report.*;
  16. import com.qmth.distributed.print.business.bean.result.ObeCourseWeightResult;
  17. import com.qmth.distributed.print.business.bean.result.ObeScoreResult;
  18. import com.qmth.distributed.print.business.bean.result.report.PaperStructDimensionResult;
  19. import com.qmth.distributed.print.business.bean.result.report.ReportChangeResult;
  20. import com.qmth.distributed.print.business.bean.result.report.ReportResult;
  21. import com.qmth.distributed.print.business.bean.result.report.word.CourseBasicBean;
  22. import com.qmth.distributed.print.business.bean.result.report.word.CourseReportBean;
  23. import com.qmth.distributed.print.business.entity.*;
  24. import com.qmth.distributed.print.business.service.*;
  25. import com.qmth.teachcloud.common.annotation.OperationLogDetail;
  26. import com.qmth.teachcloud.common.contant.SystemConstant;
  27. import com.qmth.teachcloud.common.entity.BasicCourse;
  28. import com.qmth.teachcloud.common.entity.BasicSchool;
  29. import com.qmth.teachcloud.common.entity.SysConfig;
  30. import com.qmth.teachcloud.common.entity.SysUser;
  31. import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
  32. import com.qmth.teachcloud.common.enums.FieldUniqueEnum;
  33. import com.qmth.teachcloud.common.enums.ImportTemplateEnum;
  34. import com.qmth.teachcloud.common.enums.log.OperationTypeEnum;
  35. import com.qmth.teachcloud.common.service.BasicCourseService;
  36. import com.qmth.teachcloud.common.service.CommonCacheService;
  37. import com.qmth.teachcloud.common.service.FileUploadService;
  38. import com.qmth.teachcloud.common.util.*;
  39. import com.qmth.teachcloud.mark.entity.MarkPaper;
  40. import io.swagger.annotations.*;
  41. import org.apache.commons.collections4.CollectionUtils;
  42. import org.apache.commons.io.FileUtils;
  43. import org.slf4j.Logger;
  44. import org.slf4j.LoggerFactory;
  45. import org.springframework.dao.DuplicateKeyException;
  46. import org.springframework.transaction.annotation.Transactional;
  47. import org.springframework.validation.BindingResult;
  48. import org.springframework.web.bind.annotation.*;
  49. import javax.annotation.Resource;
  50. import javax.validation.Valid;
  51. import javax.validation.constraints.Max;
  52. import javax.validation.constraints.Min;
  53. import java.io.File;
  54. import java.io.FileInputStream;
  55. import java.io.InputStream;
  56. import java.math.BigDecimal;
  57. import java.util.*;
  58. import java.util.stream.Collectors;
  59. /**
  60. * <p>
  61. * 报告基本情况表 前端控制器
  62. * </p>
  63. *
  64. * @author wangliang
  65. * @since 2024-02-18
  66. */
  67. @Api(tags = "课程目标达成度-报告基本情况Controller")
  68. @RestController
  69. @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_COURSE_DEGREE)
  70. public class TRBasicInfoController {
  71. private final static Logger log = LoggerFactory.getLogger(TRBasicInfoController.class);
  72. @Resource
  73. PrintCommonService printCommonService;
  74. @Resource
  75. TRBasicInfoService trBasicInfoService;
  76. @Resource
  77. TRExamStudentService trExamStudentService;
  78. @Resource
  79. CommonCacheService commonCacheService;
  80. @Resource
  81. FileUploadService fileUploadService;
  82. @Resource
  83. TCPaperStructService tcPaperStructService;
  84. @Resource
  85. TCUsualScoreService tcUsualScoreService;
  86. @Resource
  87. ObeCourseOutlineService obeCourseOutlineService;
  88. @Resource
  89. BasicCourseService basicCourseService;
  90. @ApiOperation(value = "报告管理列表")
  91. @RequestMapping(value = "/report/list", method = RequestMethod.POST)
  92. @ApiResponses({@ApiResponse(code = 200, message = "分页查询", response = ObeScoreResult.class)})
  93. public Result reportList(@ApiParam(value = "培养方案ID", required = true) @RequestParam Long cultureProgramId,
  94. @ApiParam(value = "学期ID") @RequestParam(required = false) Long semesterId,
  95. @ApiParam(value = "课程id", required = true) Long courseId,
  96. @ApiParam(value = "分页页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
  97. @ApiParam(value = "分页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
  98. return ResultUtil.ok(
  99. printCommonService.scoreList(new Page<>(pageNumber, pageSize), cultureProgramId, semesterId, courseId));
  100. }
  101. @ApiOperation(value = "查看报告")
  102. @RequestMapping(value = "/report/view", method = RequestMethod.POST)
  103. @ApiResponses({@ApiResponse(code = 200, message = "查看报告", response = ReportResult.class)})
  104. @Transactional
  105. public Result reportView(@ApiParam(value = "培养方案id", required = true) @RequestParam Long cultureProgramId,
  106. @ApiParam(value = "课程id", required = true) @RequestParam Long courseId,
  107. @ApiParam(value = "试卷编号") @RequestParam(required = false) String paperNumber) {
  108. SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
  109. BasicCourse basicCourse = basicCourseService.getById(courseId);
  110. TRBasicInfo trBasicInfo = trBasicInfoService.queryBasicInfo(cultureProgramId, courseId, paperNumber);
  111. ObeCourseOutline obeCourseOutline = obeCourseOutlineService.findByCultureProgramIdAndCourseId(cultureProgramId,
  112. courseId);
  113. ObeCourseWeightResult obeCourseWeightResult = trBasicInfoService.findCourseWeightResultRmi(obeCourseOutline.getId());
  114. log.info("ObeCourseWeightResult:{}", JacksonUtil.parseJson(obeCourseWeightResult));
  115. TCPaperStruct tcPaperStruct = tcPaperStructService.queryPaperStruct(cultureProgramId, courseId, paperNumber);
  116. if (Objects.isNull(tcPaperStruct) || Objects.isNull(tcPaperStruct.getPaperStructDimension())) {
  117. throw ExceptionResultEnum.ERROR.exception("未找到试卷蓝图信息");
  118. }
  119. MarkPaper markPaper = printCommonService.getMarkPaper(null, basicCourse.getCode(), tcPaperStruct.getPaperNumber(), courseId);
  120. if (Objects.isNull(trBasicInfo)) {
  121. trBasicInfo = trBasicInfoService.getReportView(trBasicInfo, markPaper, sysUser.getId(),
  122. obeCourseWeightResult, cultureProgramId, courseId);
  123. } else {
  124. ReportCourseEvaluationResultDto reportCourseEvaluationResultDto = Objects.nonNull(trBasicInfo.getCourseEvaluationResult()) ?
  125. JSONObject.parseObject(trBasicInfo.getCourseEvaluationResult(), ReportCourseEvaluationResultDto.class) :
  126. null;
  127. if (Objects.nonNull(reportCourseEvaluationResultDto.getWeightSettingSign())
  128. && reportCourseEvaluationResultDto.getWeightSettingSign().longValue() != obeCourseWeightResult.getWeightSettingSign().longValue()) {
  129. trBasicInfoService.clearReportData(cultureProgramId, courseId, paperNumber,
  130. Objects.nonNull(tcPaperStruct.getDimensionSign())
  131. && tcPaperStruct.getDimensionSign().longValue()
  132. != obeCourseWeightResult.getDimensionSign().longValue());
  133. trBasicInfo = trBasicInfoService.getReportView(trBasicInfo, markPaper, sysUser.getId(),
  134. obeCourseWeightResult, cultureProgramId, courseId);
  135. } else {
  136. ReportCourseBasicInfoDto reportCourseBasicInfoDto = new ReportCourseBasicInfoDto(trBasicInfo);
  137. ReportCourseEvaluationSpreadDto reportCourseEvaluationSpreadDto = Objects.nonNull(trBasicInfo.getCourseEvaluationSpread()) ?
  138. JSONObject.parseObject(trBasicInfo.getCourseEvaluationSpread(), ReportCourseEvaluationSpreadDto.class) :
  139. null;
  140. ReportCourseEvaluationResultDetailDto reportCourseEvaluationResultDetailDto = null;
  141. List<TRExamStudent> trExamStudentList = trExamStudentService.list(
  142. new QueryWrapper<TRExamStudent>().lambda().eq(TRExamStudent::getrBasicInfoId, trBasicInfo.getId()));
  143. if (!CollectionUtils.isEmpty(trExamStudentList)) {
  144. List<ReportExamStudentDto> examStudentList = new ArrayList<>(trExamStudentList.size());
  145. for (TRExamStudent trExamStudent : trExamStudentList) {
  146. examStudentList.add(new ReportExamStudentDto(trExamStudent));
  147. }
  148. reportCourseEvaluationResultDetailDto = new ReportCourseEvaluationResultDetailDto(examStudentList);
  149. }
  150. trBasicInfo.setReportResult(new ReportResult(new ReportCommonDto(null, basicCourse.getCode(), markPaper.getCourseName(), paperNumber),
  151. reportCourseBasicInfoDto, reportCourseEvaluationSpreadDto, reportCourseEvaluationResultDto,
  152. reportCourseEvaluationResultDetailDto, trBasicInfo));
  153. }
  154. }
  155. trBasicInfo.updateInfo(sysUser.getId());
  156. //课程目标达成评价明细结果-课程目标达成评价值图
  157. trBasicInfoService.saveOrUpdate(trBasicInfo);
  158. return ResultUtil.ok(trBasicInfo.getReportResult());
  159. }
  160. @ApiOperation(value = "保存报告")
  161. @RequestMapping(value = "/report/save", method = RequestMethod.POST)
  162. @OperationLogDetail(operationType = OperationTypeEnum.UPDATE)
  163. @ApiResponses({@ApiResponse(code = 200, message = "保存报告", response = Object.class)})
  164. @Transactional
  165. public Result reportSave(@ApiParam(value = "保存报告结构", required = true) @Valid @RequestBody TRBasicInfo trBasicInfo, BindingResult bindingResult) {
  166. if (bindingResult.hasErrors()) {
  167. return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
  168. }
  169. SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
  170. TRBasicInfo trBasicInfoDb = null;
  171. try {
  172. trBasicInfoDb = trBasicInfoService.queryBasicInfo(trBasicInfo.getCultureProgramId(), trBasicInfo.getCourseId(), trBasicInfo.getPaperNumber());
  173. if (Objects.isNull(trBasicInfoDb)) {
  174. trBasicInfoDb = new TRBasicInfo(trBasicInfo, sysUser.getId());
  175. TCPaperStruct tcPaperStruct = tcPaperStructService.queryPaperStruct(trBasicInfo.getCultureProgramId(), trBasicInfo.getCourseId(), trBasicInfo.getPaperNumber());
  176. MarkPaper markPaper = printCommonService.getMarkPaper(trBasicInfo.getExamId(), trBasicInfo.getCourseCode(), Objects.nonNull(tcPaperStruct) ? tcPaperStruct.getPaperNumber() : trBasicInfo.getPaperNumber(), trBasicInfo.getCourseId());
  177. ObeCourseOutline obeCourseOutline = obeCourseOutlineService.findByCultureProgramIdAndCourseId(trBasicInfo.getCultureProgramId(), trBasicInfo.getCourseId());
  178. trBasicInfoDb = trBasicInfoService.getReportView(trBasicInfoDb, markPaper, sysUser.getId(), trBasicInfoService.findCourseWeightResultRmi(obeCourseOutline.getId()), trBasicInfo.getCultureProgramId(), trBasicInfo.getCourseId());
  179. } else {
  180. trBasicInfoDb.updateInfo(trBasicInfo, sysUser.getId());
  181. }
  182. } catch (Exception e) {
  183. log.error(SystemConstant.LOG_ERROR, e);
  184. if (e instanceof DuplicateKeyException) {
  185. String errorColumn = e.getCause().toString();
  186. String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
  187. throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
  188. } else if (e instanceof ApiException) {
  189. ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
  190. } else {
  191. ResultUtil.error(e.getMessage());
  192. }
  193. }
  194. return ResultUtil.ok(trBasicInfoService.saveOrUpdate(trBasicInfoDb));
  195. }
  196. @ApiOperation(value = "导出报告")
  197. @RequestMapping(value = "/report/export", method = RequestMethod.POST)
  198. @OperationLogDetail(operationType = OperationTypeEnum.EXPORT)
  199. @ApiResponses({@ApiResponse(code = 200, message = "下载成功", response = Object.class)})
  200. @Aac(rateLimit = @RateLimit(count = 1, period = 1000L))
  201. public void reportExport(@ApiParam(value = "培养方案id", required = true) @RequestParam Long cultureProgramId,
  202. @ApiParam(value = "课程id", required = true) @RequestParam Long courseId,
  203. @ApiParam(value = "试卷编号") @RequestParam(required = false) String paperNumber) {
  204. File txtFileTemp = null, fileTemp = null;
  205. try {
  206. Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
  207. ObeCourseOutline obeCourseOutline = obeCourseOutlineService.findByCultureProgramIdAndCourseId(cultureProgramId, courseId);
  208. BasicSchool basicSchool = commonCacheService.schoolCache(schoolId);
  209. TRBasicInfo trBasicInfo = trBasicInfoService.queryBasicInfo(cultureProgramId, courseId, paperNumber);
  210. Objects.requireNonNull(trBasicInfo, "没有报告信息");
  211. Objects.requireNonNull(trBasicInfo.getCourseEvaluationResult(), "没有课程目标信息");
  212. Objects.requireNonNull(trBasicInfo.getCourseEvaluationResultDetail(), "没有课程考生信息");
  213. ObeCourseWeightResult obeCourseWeightResult = trBasicInfoService.findCourseWeightResultRmi(obeCourseOutline.getId());
  214. TCPaperStruct tcPaperStruct = tcPaperStructService.queryPaperStruct(cultureProgramId, courseId, paperNumber);
  215. if (Objects.nonNull(tcPaperStruct) && Objects.nonNull(tcPaperStruct.getPaperStructDimension())) {
  216. List<PaperStructDimensionResult> paperStructDimensionResultList = GsonUtil.fromJson(tcPaperStruct.getPaperStructDimension(), new TypeToken<List<PaperStructDimensionResult>>() {
  217. }.getType());
  218. for (CourseWeightDto c : obeCourseWeightResult.getSubmitForm()) {
  219. Double score = paperStructDimensionResultList.stream().filter(s -> Objects.equals(s.getCourseTargetName(), c.getCourseTargetName())).mapToDouble(s -> s.getScore().doubleValue()).sum();
  220. Objects.requireNonNull(c.getTotalWeight(), "[" + c.getCourseTargetName() + "]未设置权重");
  221. List<CourseWeightDetailDto> courseWeightDetailDtoList = c.getEvaluationList();
  222. for (CourseWeightDetailDto courseWeightDetailDto : courseWeightDetailDtoList) {
  223. if (Objects.equals(courseWeightDetailDto.getEvaluationName(), SystemConstant.FINAL_SCORE_STR)) {
  224. courseWeightDetailDto.setTargetScore(new BigDecimal(score));
  225. break;
  226. }
  227. }
  228. }
  229. }
  230. ReportCourseEvaluationResultDto reportCourseEvaluationResultDto = JSONObject.parseObject(trBasicInfo.getCourseEvaluationResult(), ReportCourseEvaluationResultDto.class);
  231. if (Objects.nonNull(reportCourseEvaluationResultDto.getWeightSettingSign()) && reportCourseEvaluationResultDto.getWeightSettingSign().longValue() != obeCourseWeightResult.getWeightSettingSign().longValue()) {
  232. trBasicInfoService.clearReportData(cultureProgramId, courseId, paperNumber,
  233. Objects.nonNull(tcPaperStruct) && Objects.nonNull(tcPaperStruct.getDimensionSign())
  234. && tcPaperStruct.getDimensionSign().longValue()
  235. != obeCourseWeightResult.getDimensionSign().longValue());
  236. this.reportView(cultureProgramId, courseId, paperNumber);
  237. this.reportExport(cultureProgramId, courseId, paperNumber);
  238. } else {
  239. //评价样本的基本信息
  240. JSONObject jsonObject = JSONObject.parseObject(trBasicInfo.getCourseEvaluationResultDetail());
  241. List<CourseTargetWordDto> courseTargetWordDtoList = JSONArray.parseArray(jsonObject.get("targetWordMap").toString(), CourseTargetWordDto.class);
  242. StringJoiner courseTarget = new StringJoiner("");
  243. courseTargetWordDtoList.stream().peek(s -> {
  244. courseTarget.add(" ").add(s.getTargetName()).add("——").add(s.getGraduationRequirementPoint()).add("\r\n");
  245. }).collect(Collectors.toList());
  246. CourseBasicBean courseBasicBean = new CourseBasicBean(trBasicInfo, courseTarget.toString(), reportCourseEvaluationResultDto.getTargetList().size());
  247. CourseReportBean courseReportBean = new CourseReportBean(trBasicInfo.getOpenTime() + "《" + trBasicInfo.getCourseName() + "》", courseBasicBean);
  248. //table1-课程目标目标与毕业要求指标点的对应关系
  249. courseReportBean.setCourseTargetTable1(trBasicInfoService.buildWordTable1(courseTargetWordDtoList));
  250. //table2-课程目标达成评价依据
  251. courseReportBean.setCourseTargetTable2(trBasicInfoService.buildWordTable2(courseTargetWordDtoList));
  252. //examstudent-课程目标达成评价依据-考生
  253. courseReportBean.setExamStudentTable1(trBasicInfoService.buildWordTable5(trBasicInfo, courseReportBean));
  254. InputStream inputStream = null;
  255. txtFileTemp = SystemConstant.getFileTempVar(SystemConstant.WORD_PREFIX);
  256. SysConfig sysConfig = commonCacheService.addSysConfigCache(schoolId, SystemConstant.SCHOOL_COURSE_DEGREE_TEMPLATE);
  257. if (Objects.isNull(sysConfig)) {
  258. inputStream = FileUtil.getStream("static/" + ImportTemplateEnum.STATIC_COURSE_DEGREE_REPORT.getTemplateName());
  259. } else {
  260. fileTemp = SystemConstant.getFileTempVar(SystemConstant.WORD_PREFIX);
  261. fileTemp = fileUploadService.downloadFile(Long.parseLong(sysConfig.getConfigValue()), fileTemp.getPath());
  262. inputStream = new FileInputStream(fileTemp);
  263. }
  264. FileUtils.copyInputStreamToFile(inputStream, txtFileTemp);
  265. XWPFTemplate template = XWPFTemplate.compile(txtFileTemp.getAbsolutePath()).render(courseReportBean);
  266. template.writeToFile(txtFileTemp.getAbsolutePath());
  267. // 导出
  268. String fileName = Objects.nonNull(basicSchool) ? basicSchool.getName() + "_" + courseReportBean.getTitle1() + "_" + ImportTemplateEnum.STATIC_COURSE_DEGREE_REPORT.getFileName() + SystemConstant.WORD_PREFIX : courseReportBean.getTitle1() + "_" + ImportTemplateEnum.STATIC_COURSE_DEGREE_REPORT.getFileName() + SystemConstant.WORD_PREFIX;
  269. FileUtil.outputFile(ServletUtil.getResponse(), new FileInputStream(txtFileTemp), fileName);
  270. }
  271. } catch (Exception e) {
  272. if (e instanceof ApiException) {
  273. ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
  274. } else {
  275. ResultUtil.error(e.getMessage());
  276. }
  277. } finally {
  278. if (Objects.nonNull(txtFileTemp)) {
  279. txtFileTemp.delete();
  280. }
  281. if (Objects.nonNull(fileTemp)) {
  282. fileTemp.delete();
  283. }
  284. }
  285. }
  286. @ApiOperation(value = "报告发生改变")
  287. @RequestMapping(value = "/report/change", method = RequestMethod.POST)
  288. @ApiResponses({@ApiResponse(code = 200, message = "下载成功", response = Object.class)})
  289. public Result reportDataChange(@ApiParam(value = "培养方案id", required = true) @RequestParam Long cultureProgramId,
  290. @ApiParam(value = "课程id", required = true) @RequestParam Long courseId,
  291. @ApiParam(value = "试卷编号") @RequestParam(required = false) String paperNumber,
  292. @ApiParam(value = "true:报告,false:成绩管理", required = true) @RequestParam boolean report) {
  293. ObeCourseOutline obeCourseOutline = obeCourseOutlineService.findByCultureProgramIdAndCourseId(cultureProgramId, courseId);
  294. ReportChangeResult reportChangeResult = new ReportChangeResult();
  295. List<TCUsualScore> tcUsualScoreList = tcUsualScoreService.queryUsualScore(cultureProgramId, courseId, paperNumber);
  296. if (CollectionUtils.isNotEmpty(tcUsualScoreList)) {
  297. Set<String> usualScoreCourseSet = new LinkedHashSet<>();
  298. TCUsualScore tcUsualScore = tcUsualScoreList.get(0);
  299. List<TCUsualScoreDto> tcUsualScoreDtoList = JSONArray.parseArray(tcUsualScore.getScore(), TCUsualScoreDto.class);
  300. List<String> usualScoreList = tcUsualScoreDtoList.stream().map(s -> s.getName()).collect(Collectors.toList());
  301. List<CourseWeightDto> courseWeightDtoList = trBasicInfoService.findCourseWeightDtoRmi(obeCourseOutline.getId());
  302. List<String> courseTargetList = new ArrayList<>(courseWeightDtoList.size());
  303. if (CollectionUtils.isNotEmpty(courseWeightDtoList)) {
  304. courseWeightDtoList.stream().peek(e -> {
  305. courseTargetList.add(e.getCourseTargetName());
  306. List<CourseWeightDetailDto> courseWeightDetailDtoList = e.getEvaluationList();
  307. courseWeightDetailDtoList.stream().peek(s -> {
  308. if (Objects.nonNull(s.getEnable()) && s.getEnable() && !Objects.equals(s.getEvaluationName(), SystemConstant.FINAL_SCORE_STR)) {
  309. usualScoreCourseSet.add(s.getEvaluationName());
  310. }
  311. }).collect(Collectors.toList());
  312. }).collect(Collectors.toList());
  313. }
  314. if (CollectionUtils.isNotEmpty(usualScoreList) && CollectionUtils.isNotEmpty(usualScoreCourseSet)) {
  315. List<String> usualScoreCourseList = new ArrayList<>(usualScoreCourseSet);
  316. Collections.sort(usualScoreList);
  317. Collections.sort(usualScoreCourseList);
  318. if (!CollectionUtils.isEqualCollection(usualScoreList, usualScoreCourseList)) {
  319. reportChangeResult.setEvaluationChange(true);
  320. }
  321. }
  322. TRBasicInfo trBasicInfo = trBasicInfoService.queryBasicInfo(cultureProgramId, courseId, paperNumber);
  323. if (Objects.nonNull(trBasicInfo) && Objects.nonNull(trBasicInfo.getCourseEvaluationResultDetail())) {
  324. JSONObject jsonObject = JSONObject.parseObject(trBasicInfo.getCourseEvaluationResultDetail());
  325. List<CourseTargetWordDto> courseTargetWordDtoList = JSONArray.parseArray(jsonObject.get("targetWordMap").toString(), CourseTargetWordDto.class);
  326. List<String> courseTargetDbList = courseTargetWordDtoList.stream().map(
  327. CourseTargetWordDto::getTargetName).collect(Collectors.toList());
  328. if (CollectionUtils.isNotEmpty(courseTargetList) && CollectionUtils.isNotEmpty(courseTargetDbList)) {
  329. Collections.sort(courseTargetList);
  330. Collections.sort(courseTargetDbList);
  331. if (!CollectionUtils.isEqualCollection(courseTargetList, courseTargetDbList)) {
  332. reportChangeResult.setCourseTargetChange(true);
  333. }
  334. }
  335. }
  336. if (!report) {
  337. TCPaperStruct tcPaperStruct = tcPaperStructService.queryPaperStruct(cultureProgramId, courseId, paperNumber);
  338. if (Objects.nonNull(tcPaperStruct) && Objects.nonNull(tcPaperStruct.getPaperStructDimension())) {
  339. List<PaperStructDimensionResult> paperStructDimensionResultList = GsonUtil.fromJson(tcPaperStruct.getPaperStructDimension(), new TypeToken<List<PaperStructDimensionResult>>() {
  340. }.getType());
  341. StringJoiner stringJoiner = new StringJoiner("");
  342. for (CourseWeightDto c : courseWeightDtoList) {
  343. if (Objects.isNull(c.getTotalWeight())) {
  344. reportChangeResult.setTargetScoreChange(true);
  345. stringJoiner.add("[").add(c.getCourseTargetName()).add("]").add("未设置权重").add("\r\n");
  346. }
  347. }
  348. if (reportChangeResult.isTargetScoreChange()) {
  349. trBasicInfoService.clearReportData(cultureProgramId, courseId, paperNumber, false);
  350. reportChangeResult.setTargetScoreChangeStr(stringJoiner.toString());
  351. }
  352. }
  353. }
  354. }
  355. return ResultUtil.ok(reportChangeResult);
  356. }
  357. }