From ef518efa4f37260ba7958259d0dae1f826a39456 Mon Sep 17 00:00:00 2001 From: whb <17803890193@163.com> Date: Mon, 22 Jul 2024 17:34:09 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=96=B0=E5=A2=9Ejupyter=E8=BF=90=E8=A1=8C?= =?UTF-8?q?python=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/stu/JupyterController.java | 252 ++++++++++++++++++ 1 file changed, 252 insertions(+) create mode 100644 src/main/java/com/sztzjy/financial_bigdata/controller/stu/JupyterController.java diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/JupyterController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/JupyterController.java new file mode 100644 index 0000000..7773d09 --- /dev/null +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/JupyterController.java @@ -0,0 +1,252 @@ +package com.sztzjy.financial_bigdata.controller.stu; + +import cn.hutool.core.util.IdUtil; +import com.alibaba.fastjson.JSONObject; +import com.sztzjy.financial_bigdata.annotation.AnonymousAccess; +import com.sztzjy.financial_bigdata.util.ResultEntity; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.codec.binary.Base64; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.*; + +import java.io.*; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + +/** + * @author 17803 + * @date 2024-07-22 17:31 + */ + +@RestController +@Api(tags = "jupyter运行python代码") +@RequestMapping("/api/jupyter") +public class JupyterController { + @ApiOperation("文件校验") + @PostMapping("/validate") + @AnonymousAccess + public ResultEntity getBlockResources(@RequestBody JSONObject upCodeJson) { + + //虚拟空间路径 + String pyPath = "/usr/local/tianzeProject/py/"; + + System.out.println(upCodeJson); + String pythonCodeUp = upCodeJson.getString("code"); + String pythonCode = ""; + + if (pythonCodeUp.contains("/dataResource")) { + pythonCode = pythonCodeUp.replace("/dataResource", pyPath + "dataResource"); + } else { + pythonCode = pythonCodeUp; + } + if (pythonCode.contains("show")) { + return validatePythonCodePhoto(upCodeJson); + } + try { + + String s = IdUtil.simpleUUID(); + // 写入临时Python文件 + String tempPythonFile = "/usr/local/tianzeProject/py/code/" + s + ".py"; + + try (PrintWriter out = new PrintWriter(tempPythonFile)) { + out.println(pythonCode); + } + + + String[] command = {"docker", "exec", "pyexe", "python", tempPythonFile}; + // 创建一个新的进程来执行Python代码 + Process process = Runtime.getRuntime().exec(command); + + // 获取进程的输入流 + BufferedReader inputStream = new BufferedReader(new InputStreamReader(process.getInputStream())); + + // 获取进程的输出流 + BufferedReader errorStream = new BufferedReader(new InputStreamReader(process.getErrorStream())); + +// // 向进程的输入流写入Python代码 +// process.getOutputStream().write(pythonCode.getBytes()); +// process.getOutputStream().flush(); +// process.getOutputStream().close(); + + // 读取Python代码的输出 + String line; + StringBuilder output = new StringBuilder(); + while ((line = inputStream.readLine()) != null) { + output.append(line).append("\n"); + } + + // 读取Python代码的错误信息 + StringBuilder errors = new StringBuilder(); + while ((line = errorStream.readLine()) != null) { + errors.append(line).append("\n"); + } + + // 等待进程执行完成 + int exitCode = process.waitFor(); + + if (exitCode == 0) { + // 执行成功,输出Python代码的结果 + System.out.println("Python code output:\n" + output.toString()); + return new ResultEntity(HttpStatus.OK, output.toString()); + } else { + // 执行失败,输出错误信息 + System.err.println("Error executing Python code:\n" + errors.toString()); + return new ResultEntity(HttpStatus.OK, errors.toString()); + } + } catch (IOException | InterruptedException e) { + e.printStackTrace(); + } + return new ResultEntity<>(HttpStatus.BAD_REQUEST); + } + + + @PostMapping("/validatePythonCodeImg") + @ApiOperation("代码检验图片") + @AnonymousAccess + public ResultEntity validatePythonCodePhoto(@RequestBody JSONObject upCodeJson) { + + + System.out.println(upCodeJson); + String pythonCode = upCodeJson.getString("code"); + + String s = IdUtil.simpleUUID(); + List stringList = new ArrayList<>(); + + try { + String pyCode = "/usr/local/tianzeProject/py/code/"; + String pyPath = "/usr/local/tianzeProject/py/img/"; + + // 写入临时Python文件 + String tempPythonFile = pyCode + s + ".py"; + + // 输出流示例 + PrintWriter out = null; + + //============ + if (pythonCode.contains("show")) { + // 将 pythonCode 按行拆分 + String[] lines = pythonCode.split("\\r?\\n"); + out = new PrintWriter(tempPythonFile); + int length = lines.length; + + for (int i = 0; i < lines.length; i++) { + + String imgPathv = IdUtil.simpleUUID(); + String plotFile = pyPath + imgPathv + ".png"; + + // 处理最后一行的情况,确保不重复插入 plt.savefig() + if (i == length - 1 && lines[i].contains("plt.show()")) { + out.println("plt.savefig('" + plotFile + "')"); + out.println(lines[i]); + + System.out.println("最后一次执行"+i); + stringList.add(pyPath + imgPathv + ".png"); + System.out.println("保存图片路径:" + pyPath + imgPathv + ".png"); + System.out.println("最后一行添加"+lines[i]); + continue; + } + + lines[i] = lines[i].trim(); + + // 判断是否为 plt.show() 相关的语句 + if (lines[i].contains("plt.show()")&&i != length - 1) { + + out.println("plt.savefig('" + plotFile + "')"); + stringList.add(pyPath + imgPathv + ".png"); + System.out.println("保存图片路径:" + pyPath + imgPathv + ".png"); + } + + // 在 plt.savefig() 之后输出原来的 plt.show() 语句 + out.println(lines[i]); + } + System.out.println("数据写入完成:"+stringList); + + out.close(); + } + + String[] command = {"docker", "exec", "pyexe", "python", pyCode + s + ".py"}; + // 创建一个新的进程来执行Python代码 + Process process = Runtime.getRuntime().exec(command); + + // 获取进程的输入流 + BufferedReader inputStream = new BufferedReader(new InputStreamReader(process.getInputStream())); + + // 获取进程的输出流 + BufferedReader errorStream = new BufferedReader(new InputStreamReader(process.getErrorStream())); + + // 向进程的输入流写入Python代码 + process.getOutputStream().write(pythonCode.getBytes()); + process.getOutputStream().flush(); + process.getOutputStream().close(); + + // 读取Python代码的输出 + String line; + StringBuilder output = new StringBuilder(); + while ((line = inputStream.readLine()) != null) { + output.append(line).append("\n"); + } + + // 读取Python代码的错误信息 + StringBuilder errors = new StringBuilder(); + while ((line = errorStream.readLine()) != null) { + errors.append(line).append("\n"); + } + + // 等待进程执行完成 + int exitCode = process.waitFor(); + System.out.println("代码运行结束!!"); + if (exitCode == 0) { + // 执行成功,输出Python代码的结果 + System.out.println("Python code output:\n" + output.toString()); + + + String base64Image = ""; + List base64ImageList = new ArrayList<>(); + + if (!stringList.isEmpty()) { + + for (int i = 0; i < stringList.size(); i++) { + // 读取图片文件并转换为Base64字符串 + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + System.out.println("读取的stringList文件:" + stringList.get(i)); + + try (FileInputStream fis = new FileInputStream(stringList.get(i))) { + byte[] buffer = new byte[1024]; + int len; + while ((len = fis.read(buffer)) != -1) { + baos.write(buffer, 0, len); + } + System.out.println("图片读取成功!!!!"); + } + base64Image = Base64.encodeBase64String(baos.toByteArray()); + base64ImageList.add(base64Image); + } + + return new ResultEntity(HttpStatus.OK, output.toString(), base64ImageList); + } else { + return new ResultEntity(HttpStatus.OK, output.toString()); + } + + + }else { + // 执行失败,输出错误信息 + System.err.println("Error executing Python code:\n" + errors.toString()); + return new ResultEntity(HttpStatus.OK, errors.toString()); + } + + + } catch (IOException | InterruptedException e) { + e.printStackTrace(); + return new ResultEntity(HttpStatus.BAD_REQUEST, e); + } + + } + + + + +} \ No newline at end of file From 9bba7faf0dc51cf6848a0fe6da5d34098ce4e668 Mon Sep 17 00:00:00 2001 From: yz <3614508250@qq.com> Date: Tue, 23 Jul 2024 18:24:07 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../financial_bigdata/config/Constant.java | 2 +- .../stu/ExerciseExperimentalTraining.java | 140 ++++++++++++------ .../stu/ExerciseLearningEvaluation.java | 8 +- .../controller/stu/JupyterController.java | 8 +- .../controller/stu/StuKnowledgeNote.java | 14 +- .../controller/stu/TheoryTestController.java | 10 +- .../controller/tea/TeaCaseController.java | 30 +++- .../tea/TeaExamManageController.java | 9 +- .../tea/TeaObjectiveController.java | 24 ++- .../controller/tea/UserController.java | 2 + .../TestSysKnowledgeSummary.java | 104 +++++++++++++ .../resourceCenterAPI/CaseApi.java | 71 ++++++++- .../KnowledgeSummaryApi.java | 37 +++++ .../resourceCenterAPI/ObjectiveApi.java | 58 +++++--- .../service/stu/IExerciseService.java | 4 +- .../service/stu/ITheoryTestService.java | 4 +- .../service/stu/impl/ExerciseServiceImpl.java | 19 ++- .../stu/impl/TheoryTestServiceImpl.java | 12 +- 18 files changed, 437 insertions(+), 119 deletions(-) create mode 100644 src/main/java/com/sztzjy/financial_bigdata/entity/resource_entity/TestSysKnowledgeSummary.java create mode 100644 src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/KnowledgeSummaryApi.java diff --git a/src/main/java/com/sztzjy/financial_bigdata/config/Constant.java b/src/main/java/com/sztzjy/financial_bigdata/config/Constant.java index 78dc0f6..3654e15 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/config/Constant.java +++ b/src/main/java/com/sztzjy/financial_bigdata/config/Constant.java @@ -32,6 +32,6 @@ public class Constant { public static final String SHIZHAN = "实战考核模块"; public static final String THEORY = "理论考试模块"; public static final String RESOURCE = "资源中心模块"; - public static final String API_URL = "http://192.168.2.16:8889"; + public static final String API_URL = "http://120.79.54.255:8889"; } diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseExperimentalTraining.java b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseExperimentalTraining.java index 4254e8d..c97fb8d 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseExperimentalTraining.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseExperimentalTraining.java @@ -105,88 +105,130 @@ public class ExerciseExperimentalTraining { } - - @AnonymousAccess - @ApiOperation("**实训演练页面查询") + @ApiOperation("实训演练页面查询") @PostMapping("getCourseChapter") public ResultEntity> getIndexTheoryTest(@RequestParam String userId,@RequestParam String systemOwner) { +// List sysCourseList = sysCourseMapper.getBySchoolId(); List sysCourseList = null; try { sysCourseList = CourseAPI.selectTwoCataLogByInnerAndAsc(systemOwner); } catch (IOException e) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心获取内置二级目录失败"); } + List dtoList = new ArrayList<>(); + // 批量查询所有章节 List courseIds = sysCourseList.stream() .map(SysTwoCatalog::getTwoId) .collect(Collectors.toList()); - - List sysCourseChapters = null; try { sysCourseChapters = CourseAPI.selectChaptersByCourseIdsAndAsc(courseIds); } catch (IOException e) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心根据课程IDList查询章节集合失败"); } - List courseChapterIds = sysCourseChapters.stream().map(SysThreeCatalog::getTwoId).collect(Collectors.toList()); - Map> idMap = new HashMap<>(); - for (SysTwoCatalog sysCourse : sysCourseList) { - String courseId = sysCourse.getTwoId(); - List chapterIds = sysCourseChapters.stream() - .filter(chapter -> chapter.getTwoId().equals(courseId)) - .map(SysThreeCatalog::getThreeId) - .collect(Collectors.toList()); - idMap.put(courseId, chapterIds); + // 批量查询所有案例题步骤 + SysCaseQuestionStepExample stepExample = new SysCaseQuestionStepExample(); + stepExample.setOrderByClause("sort"); + List sysCaseQuestionSteps= null; + try { + sysCaseQuestionSteps = CaseApi.selectAllStepBySystemOwner(systemOwner); + } catch (IOException e) { + e.printStackTrace(); + } + + + Map> caseStepsMap = sysCaseQuestionSteps.stream() + .collect(Collectors.groupingBy(TestTestSysCaseQuestionStepWithBLOBs::getCaseId)); + + // 批量查询案例题ID + Map> caseIdMap = null; + try { + caseIdMap = CaseApi.getMapChapterIdAndCaseIdsByCourseIdAndChapterId(sysCourseChapters,systemOwner); + } catch (IOException e) { + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心查询失败"); } - //为循环提供数据 - List progressByChapterIds = stuTrainingMapper.getByUserIdAndChapterIds(userId, courseChapterIds); //循环外先查出所有进度 + + // 批量获取用户对所有章节的进度 + List progressByChapterIds = stuTrainingMapper.getByUserIdAndChapterIds(userId, + sysCourseChapters.stream().map(SysThreeCatalog::getThreeId).collect(Collectors.toList())); Map progressMap = progressByChapterIds.stream() - .collect(Collectors.toMap(StuTraining::getChapterId, - stuTraining -> Optional.ofNullable(stuTraining.getProgress()).orElse(BigDecimal.ZERO), - (p1, p2) -> p1)); // 默认值为 BigDecimal.ZERO //进度为空则给0 + .collect(Collectors.toMap(StuTraining::getChapterId,stuTraining -> Optional.ofNullable(stuTraining.getProgress()).orElse(BigDecimal.ZERO), (p1, p2) -> p1)); - //一层一层查出 课程,章节,章节下案例题 + // 构建结果列表 for (SysTwoCatalog sysCourse : sysCourseList) { SysCourseDto newDto = new SysCourseDto(); - BeanUtils.copyProperties(sysCourse, newDto); - String courseId = newDto.getCourseId(); + newDto.setCourseId(sysCourse.getTwoId()); + newDto.setSequence(sysCourse.getSort()); + newDto.setCourseName(sysCourse.getTwoName()); +// newDto.setInputType(sysCourse.getCreator()); + newDto.setSchoolId(sysCourse.getCreator()); List CourseChapterDtoList = new ArrayList<>(); - for (SysThreeCatalog sysCourseChapter : sysCourseChapters) { - SysCourseChapterDto sysCourseChapterDto = new SysCourseChapterDto(); - BeanUtils.copyProperties(sysCourseChapter, sysCourseChapterDto); - String chapterId = sysCourseChapter.getThreeId(); - BigDecimal progress = progressMap.get(chapterId); - sysCourseChapterDto.setSchedule(progress); - CourseChapterDtoList.add(sysCourseChapterDto); - } - //查询案例题 - List list1 = idMap.get(courseId); //取出章节ID - List list = null; - try { - list = CaseApi.selectCaseByChapterIdList(list1); - } catch (IOException e) { - return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心根据三级IdList查询案例题失败"); - } - List caseIds = list.stream().map(TestSysCaseQuestion::getCaseId).collect(Collectors.toList()); - List sysCaseQuestionSteps = null; - try { - sysCaseQuestionSteps = CaseApi.selectCaseStepListBatchByIdListAndSort(caseIds); - } catch (IOException e) { - return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心根据案例题IDList 查询案例题步骤并排序失败"); + List chapterList = sysCourseChapters.stream() + .filter(chapter -> sysCourse.getTwoId().equals(chapter.getTwoId())) + .collect(Collectors.toList()); + for (SysThreeCatalog chapter : chapterList) { + SysCourseChapterDto chapterDto = new SysCourseChapterDto(); + chapterDto.setChapterId(chapter.getThreeId()); + chapterDto.setChapterName(chapter.getThreeName()); + chapterDto.setSequence(chapter.getSort()); + chapterDto.setCourseId(chapter.getTwoId()); + BigDecimal progress = progressMap.getOrDefault(chapter.getThreeId(), BigDecimal.ZERO); + chapterDto.setSchedule(progress); + + // 获取案例题步骤信息 + List caseIds = caseIdMap.get(chapter.getThreeId()); + if (caseIds != null && !caseIds.isEmpty()) { + Listlist =new ArrayList<>(); + for (String caseId : caseIds) { + List steps = caseStepsMap.get(caseId); + if (steps != null && !steps.isEmpty()) { + for (TestTestSysCaseQuestionStepWithBLOBs step : steps) { + AAA aaa =new AAA(); + aaa.setStepID(step.getCaseStepId()); + aaa.setTitle(step.getTitle()); + aaa.setSort(step.getSort()); + list.add(aaa); + } + } + } + + //排序 + List sortedList = list.stream() + .sorted(Comparator + .comparingInt(AAA::getSort) + .thenComparing(AAA::getStepID).reversed()) + .collect(Collectors.toList()); + + List orderedList = new ArrayList<>(); + for (AAA item : sortedList) { + // 获取sort字段的值 + int sort = item.getSort(); + + // 找到插入位置 + int index = 0; + for (; index < orderedList.size(); index++) { + if (orderedList.get(index).getSort() >= sort) { + break; + } + } + // 插入元素到指定位置 + orderedList.add(index, item); + } + chapterDto.setTitleAndId(orderedList); + } + CourseChapterDtoList.add(chapterDto); } - Map collect = sysCaseQuestionSteps.stream().collect(Collectors.toMap(TestTestSysCaseQuestionStepWithBLOBs::getCaseStepId, TestTestSysCaseQuestionStepWithBLOBs::getTitle)); - newDto.setSysCourseChapterDtos(CourseChapterDtoList); - dtoList.add(newDto); - newDto.setTitleAndId(collect); newDto.setSysCourseChapterDtos(CourseChapterDtoList); dtoList.add(newDto); } - return new ResultEntity>(dtoList); + return new ResultEntity<>(dtoList); } + //判断案例是否有数据集 @GetMapping("haveResourceData") @ApiOperation("判断案例是否有数据集") diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseLearningEvaluation.java b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseLearningEvaluation.java index 5dc22ad..c63b0f8 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseLearningEvaluation.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseLearningEvaluation.java @@ -32,10 +32,10 @@ public class ExerciseLearningEvaluation { @ApiOperation("**客观题列表查询,回显") @AnonymousAccess public ResultEntity> selectObjectQuestionList(@ApiParam("章节Id") @RequestParam String chapterId, - @RequestParam String userId) { + @RequestParam String userId,@RequestParam String schoolId,@RequestParam String systemOwner) { List list = null; try { - list = exerciseService.selectObjectQuestionListByChapterId(chapterId,userId); + list = exerciseService.selectObjectQuestionListByChapterId(chapterId,userId,schoolId,systemOwner); } catch (IOException e) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心查询失败"); } @@ -48,10 +48,10 @@ public class ExerciseLearningEvaluation { @AnonymousAccess public ResultEntity commitObjectQuestionList(@RequestBody List objectiveQuestionDtoList, @RequestParam String userId, - @ApiParam("章节Id")@RequestParam String chapterId){ + @ApiParam("章节Id")@RequestParam String chapterId,@RequestParam String schoolId,@RequestParam String systemOwner){ Boolean flag= null; try { - flag = exerciseService.commitObjectQuestionList(objectiveQuestionDtoList,userId,chapterId); + flag = exerciseService.commitObjectQuestionList(objectiveQuestionDtoList,userId,chapterId, schoolId, systemOwner); } catch (IOException e) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心客观题主键查询失败"); } diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/JupyterController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/JupyterController.java index 7773d09..546ec4c 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/JupyterController.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/JupyterController.java @@ -31,7 +31,7 @@ public class JupyterController { public ResultEntity getBlockResources(@RequestBody JSONObject upCodeJson) { //虚拟空间路径 - String pyPath = "/usr/local/tianzeProject/py/"; + String pyPath = "/usr/local/tianzeProject/financial_bigdata_total/py/"; System.out.println(upCodeJson); String pythonCodeUp = upCodeJson.getString("code"); @@ -49,7 +49,7 @@ public class JupyterController { String s = IdUtil.simpleUUID(); // 写入临时Python文件 - String tempPythonFile = "/usr/local/tianzeProject/py/code/" + s + ".py"; + String tempPythonFile = "/usr/local/tianzeProject/financial_bigdata_total/py/code/" + s + ".py"; try (PrintWriter out = new PrintWriter(tempPythonFile)) { out.println(pythonCode); @@ -116,8 +116,8 @@ public class JupyterController { List stringList = new ArrayList<>(); try { - String pyCode = "/usr/local/tianzeProject/py/code/"; - String pyPath = "/usr/local/tianzeProject/py/img/"; + String pyCode = "/usr/local/tianzeProject/financial_bigdata_total/py/code/"; + String pyPath = "/usr/local/tianzeProject/financial_bigdata_total/py/img/"; // 写入临时Python文件 String tempPythonFile = pyCode + s + ".py"; diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuKnowledgeNote.java b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuKnowledgeNote.java index 12f9fba..701e204 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuKnowledgeNote.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuKnowledgeNote.java @@ -5,9 +5,11 @@ import com.sztzjy.financial_bigdata.annotation.AnonymousAccess; import com.sztzjy.financial_bigdata.entity.StuTrainingExample; import com.sztzjy.financial_bigdata.entity.StuTrainingWithBLOBs; import com.sztzjy.financial_bigdata.entity.SysKnowledgeSummary; +import com.sztzjy.financial_bigdata.entity.resource_entity.TestSysKnowledgeSummary; import com.sztzjy.financial_bigdata.entity.stu_dto.ReceivingObject; import com.sztzjy.financial_bigdata.mapper.StuTrainingMapper; import com.sztzjy.financial_bigdata.mapper.SysKnowledgeSummaryMapper; +import com.sztzjy.financial_bigdata.resourceCenterAPI.KnowledgeSummaryApi; import com.sztzjy.financial_bigdata.util.PdfUtil; import com.sztzjy.financial_bigdata.util.ResultEntity; import com.sztzjy.financial_bigdata.util.file.IFileUtil; @@ -27,6 +29,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; +import java.io.IOException; import java.util.List; /** @@ -105,10 +108,15 @@ public class StuKnowledgeNote { @AnonymousAccess - @ApiOperation("知识概要-获取页面") + @ApiOperation("***知识概要-获取页面") @PostMapping("getSysKnowledgeSummaryByChapterId") - public ResultEntity getSysKnowledgeSummaryByChapterId(@RequestParam String chapterId) { - SysKnowledgeSummary sysKnowledgeSummary = sysKnowledgeSummaryMapper.selectByPrimaryKey(chapterId); + public ResultEntity getSysKnowledgeSummaryByChapterId(@RequestParam String chapterId,@RequestParam String courseId, @RequestParam String schoolId, @RequestParam String systemOwner) { + TestSysKnowledgeSummary sysKnowledgeSummary = null; + try { + sysKnowledgeSummary = KnowledgeSummaryApi.getSysKnowledgeSummary(courseId,chapterId, schoolId, systemOwner); + } catch (IOException e) { + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心接口异常"); + } return new ResultEntity<>(sysKnowledgeSummary); } diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/TheoryTestController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/TheoryTestController.java index 2451ff5..4276c02 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/TheoryTestController.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/TheoryTestController.java @@ -80,10 +80,10 @@ public class TheoryTestController { @GetMapping("selectErrors") @ApiOperation("**错题集展示") @AnonymousAccess - public ResultEntity> selectErrors(@RequestParam String userId) { + public ResultEntity> selectErrors(@RequestParam String userId,@RequestParam String schoolId,@RequestParam String systemOwner) { List list = null; try { - list = theoryTestService.selectErrors(userId); + list = theoryTestService.selectErrors(userId, schoolId, systemOwner); } catch (IOException e) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心查询异常"); } @@ -124,14 +124,14 @@ public class TheoryTestController { //考试记录详情查询 @GetMapping("getTheoryTestDetail") - @ApiOperation("获取理论考试数据详情") + @ApiOperation("**获取理论考试数据详情") @AnonymousAccess public ResultEntity> getTheoryTestDetail(@ApiParam("理论考试id") @RequestParam String theoryExamId, @RequestParam Integer index, - @RequestParam Integer size) { + @RequestParam Integer size,@RequestParam String schoolId,@RequestParam String systemOwner) { List detailDtoList = null; try { - detailDtoList = theoryTestService.getTheoryTestDetail(theoryExamId, index, size); + detailDtoList = theoryTestService.getTheoryTestDetail(theoryExamId, index, size, schoolId, systemOwner); } catch (IOException e) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心主键查询异常"); } diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaCaseController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaCaseController.java index 0f6344c..3fe06be 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaCaseController.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaCaseController.java @@ -69,9 +69,9 @@ public class TeaCaseController { @GetMapping("selectCaseDetails") @ApiOperation("**案例题详情查询、案例题编辑回显") @AnonymousAccess - public ResultEntity selectCaseDetails(@RequestParam String caseId) { + public ResultEntity selectCaseDetails(@RequestParam String caseId,@RequestParam String systemOwner) { try { - TestSysCaseQuestion caseQuestion = CaseApi.selectCaseDetails(caseId); + TestSysCaseQuestion caseQuestion = CaseApi.selectCaseDetails(caseId,systemOwner); return new ResultEntity<>(HttpStatus.OK, "案例题详情查询成功", caseQuestion); } catch (IOException e) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心接口异常"); @@ -129,4 +129,30 @@ public class TeaCaseController { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心接口异常"); } } + + //根据章节ID查询案例题 + @GetMapping("selectCaseByChapterId") + @ApiOperation("**根据章节ID查询案例题") + @AnonymousAccess + public ResultEntity> selectCaseByChapterId(@RequestParam String chapterId) { + try { + List caseQuestionList=CaseApi.selectCaseByChapterId(chapterId); + return new ResultEntity<>(HttpStatus.OK, "根据章节ID查询案例题", caseQuestionList); + } catch (IOException e) { + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心接口异常"); + } + } + + //根据章节ID查询案例题 + @GetMapping("selectCaseByCourseId") + @ApiOperation("**根据课程ID查询案例题") + @AnonymousAccess + public ResultEntity> selectCaseByCourseId(@RequestParam String courseId,@RequestParam String systemOwner,@RequestParam String schoolId) { + try { + List caseQuestionList=CaseApi.selectCaseByCourseId(courseId,systemOwner,schoolId); + return new ResultEntity<>(HttpStatus.OK, "根据课程ID查询案例题", caseQuestionList); + } catch (IOException e) { + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心接口异常"); + } + } } diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaExamManageController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaExamManageController.java index 4b4dd84..601e39e 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaExamManageController.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaExamManageController.java @@ -5,6 +5,7 @@ import com.github.pagehelper.PageInfo; import com.sztzjy.financial_bigdata.annotation.AnonymousAccess; import com.sztzjy.financial_bigdata.entity.*; import com.sztzjy.financial_bigdata.entity.resource_entity.SysObjectiveQuestions; +import com.sztzjy.financial_bigdata.entity.resource_entity.dto.SysObjectiveQuestionsDto; import com.sztzjy.financial_bigdata.entity.tea_dto.TeaExamManageCountDto; import com.sztzjy.financial_bigdata.entity.tea_dto.TeaExamManageDto; import com.sztzjy.financial_bigdata.entity.tea_dto.TrainingDto; @@ -55,9 +56,9 @@ public class TeaExamManageController { @AnonymousAccess @PostMapping("/getSelectCountAndScore") @ApiOperation("新增考试--获取选题量和分数") - public ResultEntity> getsingleId(@RequestBody @ApiParam("所有ID用,隔开一次传过来") List ids) { + public ResultEntity> getsingleId(@RequestBody @ApiParam("所有ID用,隔开一次传过来") List ids) { List list = new ArrayList<>(ids); - Map map = null; + Map map = null; try { map = ObjectiveApi.getChooseObjCountAndSorce(ids); } catch (IOException e) { @@ -87,9 +88,9 @@ public class TeaExamManageController { @AnonymousAccess @PostMapping("/selectObjectivityByType") @ApiOperation("***新增考试--选择客观题时展示") - public ResultEntity> selectObjectivityByType(@ApiParam("0单选 1多选 2判断") @RequestParam String type, + public ResultEntity> selectObjectivityByType(@ApiParam("0单选 1多选 2判断") @RequestParam String type, @RequestParam String schoolId,@RequestParam String systemOwner) { - List list = null; + List list = null; try { list = ObjectiveApi.selectObjByType(type, schoolId, systemOwner); } catch (IOException e) { diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaObjectiveController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaObjectiveController.java index a4f400c..54c5feb 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaObjectiveController.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaObjectiveController.java @@ -45,7 +45,23 @@ public class TeaObjectiveController { } catch (IOException e) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心接口异常"); } + } + //客观题编辑 + @PostMapping("updataObjective") + @ApiOperation("**客观题编辑") + @AnonymousAccess + public ResultEntity updataObjective(@RequestBody SysObjectiveQuestionsDto objectiveQuestion, @RequestParam String systemOwner, @RequestParam String schoolId) { + try { + Boolean flag = ObjectiveApi.updateObjective(objectiveQuestion, systemOwner, schoolId); + if (flag) { + return new ResultEntity<>(HttpStatus.OK, "客观题编辑成功"); + } else { + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "客观题编辑失败"); + } + } catch (IOException e) { + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心接口异常"); + } } //客观题删除 @@ -70,7 +86,7 @@ public class TeaObjectiveController { @GetMapping("/selectObjectiveList") @ApiOperation("**客观题列表查看") @AnonymousAccess - public ResultEntity> selectObjectiveList(@RequestParam String schoolId, + public ResultEntity> selectObjectiveList(@RequestParam String schoolId, @ApiParam("课程ID") @RequestParam String courseId, @ApiParam("章节Id") @RequestParam(required = false) String chapterId, @ApiParam("题目类型 0单选 1多选 2判断")@RequestParam(required = false)String type, @@ -78,7 +94,7 @@ public class TeaObjectiveController { @RequestParam Integer index, @RequestParam Integer size, @RequestParam String systemOwner) { - PageInfo pageInfo = null; + PageInfo pageInfo = null; try { pageInfo = ObjectiveApi.selectObjectiveList(schoolId, courseId,chapterId, type, content, index, size,systemOwner); return new ResultEntity<>(HttpStatus.OK, "客观题列表查看成功",pageInfo); @@ -91,9 +107,9 @@ public class TeaObjectiveController { @GetMapping("/selectObjectiveDetails") @ApiOperation("**客观题单个详情查看") @AnonymousAccess - public ResultEntity selectObjectiveDetails(@ApiParam("客观题ID") @RequestParam String objectiveId){ + public ResultEntity selectObjectiveDetails(@ApiParam("客观题ID") @RequestParam String objectiveId,@RequestParam String schoolId,@RequestParam String systemOwner){ try { - SysObjectiveQuestions objectiveQuestion = ObjectiveApi.selectObjectiveDetails(objectiveId); + SysObjectiveQuestionsDto objectiveQuestion = ObjectiveApi.selectObjectiveDetails(objectiveId,schoolId,systemOwner); return new ResultEntity<>(HttpStatus.OK, "客观题删除成功",objectiveQuestion); } catch (IOException e) { diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/UserController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/UserController.java index 063ced5..87e4841 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/UserController.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/UserController.java @@ -132,9 +132,11 @@ public class UserController { map.put("schoolId", user.getSchoolId()); map.put("classId", user.getClassId()); map.put("userId", user.getUserid()); + map.put("zyuserid",user.getZyUserid()); String uuid = getIPAndPlace(request, user.getName(), user.getUserid(), user.getStudentId()); map.put("logId", uuid); map.put("token", token); + map.put("systemOwner",user.getSystemOnwer()); return new ResultEntity(HttpStatus.OK, map); } else { // 2、智云单点登录 jwtUser = TokenProvider.getJWTUserByZhiYun(TOKEN); diff --git a/src/main/java/com/sztzjy/financial_bigdata/entity/resource_entity/TestSysKnowledgeSummary.java b/src/main/java/com/sztzjy/financial_bigdata/entity/resource_entity/TestSysKnowledgeSummary.java new file mode 100644 index 0000000..7bc5246 --- /dev/null +++ b/src/main/java/com/sztzjy/financial_bigdata/entity/resource_entity/TestSysKnowledgeSummary.java @@ -0,0 +1,104 @@ +package com.sztzjy.financial_bigdata.entity.resource_entity; + +import io.swagger.annotations.ApiModelProperty; + +public class TestSysKnowledgeSummary { + @ApiModelProperty("知识概要ID") + private String knowledgeSummaryId; + + @ApiModelProperty("一级标签ID") + private String oneTagId; + + @ApiModelProperty("一级标签名称") + private String oneTagName; + + @ApiModelProperty("二级标签ID") + private String twoTagId; + + @ApiModelProperty("二级标签名称") + private String twoTagName; + + @ApiModelProperty("三级标签ID") + private String threeTagId; + + @ApiModelProperty("三级标签名称") + private String threeTagName; + + @ApiModelProperty("管理员/学校ID") + private String source; + + @ApiModelProperty("内容") + private String content; + + public String getKnowledgeSummaryId() { + return knowledgeSummaryId; + } + + public void setKnowledgeSummaryId(String knowledgeSummaryId) { + this.knowledgeSummaryId = knowledgeSummaryId == null ? null : knowledgeSummaryId.trim(); + } + + public String getOneTagId() { + return oneTagId; + } + + public void setOneTagId(String oneTagId) { + this.oneTagId = oneTagId == null ? null : oneTagId.trim(); + } + + public String getOneTagName() { + return oneTagName; + } + + public void setOneTagName(String oneTagName) { + this.oneTagName = oneTagName == null ? null : oneTagName.trim(); + } + + public String getTwoTagId() { + return twoTagId; + } + + public void setTwoTagId(String twoTagId) { + this.twoTagId = twoTagId == null ? null : twoTagId.trim(); + } + + public String getTwoTagName() { + return twoTagName; + } + + public void setTwoTagName(String twoTagName) { + this.twoTagName = twoTagName == null ? null : twoTagName.trim(); + } + + public String getThreeTagId() { + return threeTagId; + } + + public void setThreeTagId(String threeTagId) { + this.threeTagId = threeTagId == null ? null : threeTagId.trim(); + } + + public String getThreeTagName() { + return threeTagName; + } + + public void setThreeTagName(String threeTagName) { + this.threeTagName = threeTagName == null ? null : threeTagName.trim(); + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source == null ? null : source.trim(); + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content == null ? null : content.trim(); + } +} diff --git a/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/CaseApi.java b/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/CaseApi.java index 2029459..3cfca0c 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/CaseApi.java +++ b/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/CaseApi.java @@ -7,10 +7,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.sztzjy.financial_bigdata.config.Constant; import com.sztzjy.financial_bigdata.entity.SysCaseQuestion; -import com.sztzjy.financial_bigdata.entity.resource_entity.SysObjectiveQuestions; -import com.sztzjy.financial_bigdata.entity.resource_entity.TestSysCaseQuestion; -import com.sztzjy.financial_bigdata.entity.resource_entity.TestSysCaseQuestionStep; -import com.sztzjy.financial_bigdata.entity.resource_entity.TestTestSysCaseQuestionStepWithBLOBs; +import com.sztzjy.financial_bigdata.entity.resource_entity.*; import com.sztzjy.financial_bigdata.entity.tea_dto.TrainingDto; import com.sztzjy.financial_bigdata.util.HttpUtils; import com.sztzjy.financial_bigdata.util.ResultEntity; @@ -22,6 +19,7 @@ import java.lang.reflect.Type; import java.net.URLEncoder; import java.util.Date; import java.util.List; +import java.util.Map; public class CaseApi { private final static String insertCase = Constant.API_URL + "/api/tea/CaseApi/insertCase"; @@ -31,6 +29,7 @@ public class CaseApi { private final static String updateCase = Constant.API_URL + "/api/tea/CaseApi/updateCase"; private final static String selectCaseByChapterId = Constant.API_URL + "/api/tea/CaseApi/selectCaseByChapterId"; private final static String selectCaseByChapterIdList = Constant.API_URL + "/api/tea/CaseApi/selectCaseByChapterIdList"; + private final static String selectCaseByCourseId = Constant.API_URL + "/api/tea/CaseApi/selectCaseByCourseId"; private final static String selectCaseStepDetailByCaseId = Constant.API_URL + "/api/tea/CaseApi/selectCaseStepDetailByCaseId"; private final static String insertCaseStep = Constant.API_URL + "/api/tea/CaseApi/insertCaseStep"; @@ -38,9 +37,12 @@ public class CaseApi { private final static String deleteCaseStep = Constant.API_URL + "/api/tea/CaseApi/deleteCaseStep"; private final static String selectCaseStepDetails = Constant.API_URL + "/api/tea/CaseApi/selectCaseStepDetails"; private final static String selectCaseStepListBatchByIdListAndSort = Constant.API_URL + "/api/tea/CaseApi/selectCaseStepListBatchByIdListAndSort"; + private final static String selectAllStepBySystemOwner = Constant.API_URL + "/api/tea/CaseApi/selectAllStepBySystemOwner"; + private final static String selectTrainingByIds = Constant.API_URL + "/api/tea/CaseApi/selectTrainingByIds"; private final static String getGradeReportCase = Constant.API_URL + "/api/tea/CaseApi/getGradeReportCase"; + private final static String getMapChapterIdAndCaseIdsByCourseIdAndChapterId = Constant.API_URL + "/api/tea/CaseApi/getMapChapterIdAndCaseIdsByCourseIdAndChapterId"; /** @@ -89,8 +91,8 @@ public class CaseApi { * local:案例题详情查询 * rsapi:案例题详情查询 */ - public static TestSysCaseQuestion selectCaseDetails(String caseId) throws IOException { - String requestBody = "caseId=" + caseId; + public static TestSysCaseQuestion selectCaseDetails(String caseId,String systemOwner) throws IOException { + String requestBody = "caseId=" + caseId+"&systemOwner="+systemOwner; JSONObject object = HttpUtils.sendPost( selectCaseDetails, requestBody); @@ -132,7 +134,25 @@ public class CaseApi { Gson gson = new GsonBuilder() .registerTypeAdapter(Date.class, new DateTypeAdapter()) .create(); - Type listType = new TypeToken>() { + Type listType = new TypeToken>() { + }.getType(); + List caseQuestionList = gson.fromJson(object.get("respString").toString(), listType); + return caseQuestionList; + } + + /** + * local:根据课程ID查询案例题 + * rsapi:根据二级Id查询案例题 + */ + public static List selectCaseByCourseId(String courseId, String systemOwner, String schoolId) throws IOException { + String requestBody = "courseId=" + courseId+"&systemOwner="+systemOwner+"&schoolId="+schoolId; + JSONObject object = HttpUtils.sendPost( + selectCaseByCourseId, + requestBody); + Gson gson = new GsonBuilder() + .registerTypeAdapter(Date.class, new DateTypeAdapter()) + .create(); + Type listType = new TypeToken>() { }.getType(); List caseQuestionList = gson.fromJson(object.get("respString").toString(), listType); return caseQuestionList; @@ -318,4 +338,41 @@ public class CaseApi { return list; } + + /** + * 获取所有内置案例题步骤信息 + */ + public static List selectAllStepBySystemOwner(String systemOwner) throws IOException { + String requestBody = "systemOwner=" + systemOwner; + JSONObject object = HttpUtils.sendPost( + selectAllStepBySystemOwner, + requestBody); + Gson gson = new GsonBuilder() + .registerTypeAdapter(Date.class, new DateTypeAdapter()) + .create(); + Type listType = new TypeToken>() { + }.getType(); + List stepList = gson.fromJson(object.get("respString").toString(), listType); + return stepList; + } + + /** + * 单独接口 + */ + public static Map> getMapChapterIdAndCaseIdsByCourseIdAndChapterId(List sysThreeCatalogs, String systemOwner) throws IOException { + Gson gson = new GsonBuilder() + .registerTypeAdapter(Date.class, new DateTypeAdapter()) + .create(); + // 构建带有 schoolId 的 URL + String urlWithParams = getMapChapterIdAndCaseIdsByCourseIdAndChapterId + "?systemOwner=" + URLEncoder.encode(systemOwner, "UTF-8"); +// String urlWithParams = getMapChapterIdAndCaseIdsByCourseIdAndChapterId + "?systemOwner=" +systemOwner; + JSONObject object = HttpUtils.sendPost( + urlWithParams, + gson.toJson(sysThreeCatalogs), "application/json", null); + Type listType = new TypeToken>>() { + }.getType(); + Map> map = gson.fromJson(object.get("respString").toString(), listType); + return map; + + } } diff --git a/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/KnowledgeSummaryApi.java b/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/KnowledgeSummaryApi.java new file mode 100644 index 0000000..d68fae8 --- /dev/null +++ b/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/KnowledgeSummaryApi.java @@ -0,0 +1,37 @@ +package com.sztzjy.financial_bigdata.resourceCenterAPI; + +import cn.hutool.json.JSONObject; +import com.google.common.reflect.TypeToken; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.sztzjy.financial_bigdata.config.Constant; +import com.sztzjy.financial_bigdata.entity.resource_entity.SysTwoCatalog; +import com.sztzjy.financial_bigdata.entity.resource_entity.TestSysKnowledgeSummary; +import com.sztzjy.financial_bigdata.util.HttpUtils; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.Date; +import java.util.List; + +public class KnowledgeSummaryApi { + private final static String getSysKnowledgeSummary = Constant.API_URL + "/api/stu/knowledgeNote/getSysKnowledgeSummary"; + + + /** + * local:知识概要查询 + */ + public static TestSysKnowledgeSummary getSysKnowledgeSummary(String courseId,String chapterId, String schoolId, String systemOwner) throws IOException { + String requestBody="systemOwner="+systemOwner+"&schoolId="+schoolId+"&chapterId="+chapterId+"&courseId="+courseId; + JSONObject object = HttpUtils.sendPost( + getSysKnowledgeSummary, + requestBody); + Gson gson = new GsonBuilder() + .registerTypeAdapter(Date.class, new DateTypeAdapter()) + .create(); + Type listType = new TypeToken() {}.getType(); + TestSysKnowledgeSummary knowledgeSummarie = gson.fromJson(object.get("respString").toString(), listType); + return knowledgeSummarie; + } + +} diff --git a/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/ObjectiveApi.java b/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/ObjectiveApi.java index f5e2d5a..018c660 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/ObjectiveApi.java +++ b/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/ObjectiveApi.java @@ -34,6 +34,7 @@ import java.util.Map; public class ObjectiveApi { private final static String insertObjective = Constant.API_URL + "/api/sys/ObjectiveApi/insertObjective"; + private final static String updateObjective = Constant.API_URL + "/api/sys/ObjectiveApi/updateObjective"; private final static String batchDeleteObjective = Constant.API_URL + "/api/sys/ObjectiveApi/batchDeleteObjective"; private final static String selectObjectiveList = Constant.API_URL + "/api/sys/ObjectiveApi/selectObjectiveList"; private final static String selectObjectiveDetails = Constant.API_URL + "/api/sys/ObjectiveApi/selectObjectiveDetails"; @@ -57,7 +58,7 @@ public class ObjectiveApi { */ public static Boolean insertObjective(SysObjectiveQuestionsDto objective, String systemOwner, String schoolId) throws IOException { objective.setSource(schoolId); - objective.setObjectiveId(systemOwner); + objective.setOneName(systemOwner); Gson gson = new Gson(); JSONObject object = HttpUtils.sendPost( insertObjective, @@ -70,6 +71,25 @@ public class ObjectiveApi { } } + /** + * local:客观题编辑 + * rsapi:客观题编辑 + */ + public static Boolean updateObjective(SysObjectiveQuestionsDto objective, String systemOwner, String schoolId) throws IOException { + Gson gson = new Gson(); + // 构建带有 schoolId 的 URL + String urlWithParams = updateObjective + "?schoolId=" + URLEncoder.encode(schoolId, "UTF-8")+"&systemOwner="+systemOwner; + JSONObject object = HttpUtils.sendPost( + urlWithParams, + gson.toJson(objective), "application/json", null); + String respString = object.get("respString").toString(); + if ("true".equals(respString)) { + return true; + } else { + return false; + } + } + /** * local:客观题批量删除 * rsapi:客观题批量删除 @@ -93,7 +113,7 @@ public class ObjectiveApi { * local:客观题列表查看 * rsapi:客观题列表查看 */ - public static PageInfo selectObjectiveList(String schoolId, String courseId,String chapterId, String type, String content, Integer index, Integer size,String systemOwner) throws IOException { + public static PageInfo selectObjectiveList(String schoolId, String courseId,String chapterId, String type, String content, Integer index, Integer size,String systemOwner) throws IOException { String requestBody = "schoolId=" + schoolId + "&courseId=" + courseId+"&index="+index+"&size="+size+"&systemOwner="+systemOwner; String contentStr=""; String typeStr=""; @@ -116,9 +136,9 @@ public class ObjectiveApi { Gson gson = new GsonBuilder() .registerTypeAdapter(Date.class, new DateTypeAdapter()) .create(); - Type listType = new TypeToken>() { + Type listType = new TypeToken>() { }.getType(); - PageInfo pageInfo = gson.fromJson(object.get("respString").toString(), listType); + PageInfo pageInfo = gson.fromJson(object.get("respString").toString(), listType); return pageInfo; } @@ -126,17 +146,17 @@ public class ObjectiveApi { * local:客观题单个详情查看 * rsapi:客观题单个详情查看 */ - public static SysObjectiveQuestions selectObjectiveDetails(String objectiveId) throws IOException { - String requestBody = "objectiveId="+objectiveId; + public static SysObjectiveQuestionsDto selectObjectiveDetails(String objectiveId,String schoolId,String systemOwner) throws IOException { + String requestBody = "objectiveId="+objectiveId+"&schoolId="+schoolId+"&systemOwner="+systemOwner; JSONObject object = HttpUtils.sendPost( selectObjectiveDetails, requestBody); Gson gson = new GsonBuilder() .registerTypeAdapter(Date.class, new DateTypeAdapter()) .create(); - Type listType = new TypeToken() { + Type listType = new TypeToken() { }.getType(); - SysObjectiveQuestions caseQuestion = gson.fromJson(object.get("respString").toString(), listType); + SysObjectiveQuestionsDto caseQuestion = gson.fromJson(object.get("respString").toString(), listType); return caseQuestion; } @@ -235,7 +255,7 @@ public class ObjectiveApi { *根据章节ID 查询所有内置题目 */ public static List selectObjectQuestionListByChapterId(String chapterId) throws IOException { - String requestBody = "threeId="+chapterId; + String requestBody = "chapterId="+chapterId; JSONObject object = HttpUtils.sendPost( selectObjectQuestionListByChapterId, requestBody); @@ -252,7 +272,7 @@ public class ObjectiveApi { * 随机获取35道内置单选题 */ public static List selectRandomObjectiveSingle(String systemOwner) throws IOException { - String requestBody = "oneId="+systemOwner; + String requestBody = "systemOwner="+systemOwner; JSONObject object = HttpUtils.sendPost( selectRandomObjectiveSingle, requestBody); @@ -269,7 +289,7 @@ public class ObjectiveApi { * 随机获取5道内置多选题 */ public static List selectRandomObjectiveMany(String systemOwner) throws IOException { - String requestBody = "oneId="+systemOwner; + String requestBody = "systemOwner="+systemOwner; JSONObject object = HttpUtils.sendPost( selectRandomObjectiveMany, requestBody); @@ -286,7 +306,7 @@ public class ObjectiveApi { * 随机获取10道内置判断题 */ public static List selectRandomObjectiveJudge(String systemOwner) throws IOException { - String requestBody = "oneId="+systemOwner; + String requestBody = "systemOwner="+systemOwner; JSONObject object = HttpUtils.sendPost( selectRandomObjectiveJudge, requestBody); @@ -339,7 +359,7 @@ public class ObjectiveApi { /** * 获取所选客观题数量及分数 */ - public static Map getChooseObjCountAndSorce(List objectIdList) throws IOException { + public static Map getChooseObjCountAndSorce(List objectIdList) throws IOException { Gson gson = new GsonBuilder() .registerTypeAdapter(Date.class, new DateTypeAdapter()) .create(); @@ -348,16 +368,16 @@ public class ObjectiveApi { JSONObject object = HttpUtils.sendPost( urlWithParams, gson.toJson(objectIdList), "application/json", null); - Type listType = new TypeToken>() { + Type listType = new TypeToken>() { }.getType(); - Map map = gson.fromJson(object.get("respString").toString(), listType); + Map map = gson.fromJson(object.get("respString").toString(), listType); return map; } /** * 根据客观题类型查询客观题 */ - public static List selectObjByType(String type,String schoolId,String systemOwner) throws IOException { + public static List selectObjByType(String type,String schoolId,String systemOwner) throws IOException { String requestBody = "type="+type+"&schoolId="+schoolId+"&systemOwner="+systemOwner; JSONObject object = HttpUtils.sendPost( selectObjByType, @@ -365,12 +385,14 @@ public class ObjectiveApi { Gson gson = new GsonBuilder() .registerTypeAdapter(Date.class, new DateTypeAdapter()) .create(); - Type listType = new TypeToken>() { + Type listType = new TypeToken>() { }.getType(); - List caseQuestionList = gson.fromJson(object.get("respString").toString(), listType); + List caseQuestionList = gson.fromJson(object.get("respString").toString(), listType); return caseQuestionList; } + + /** * 单独接口 */ diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/stu/IExerciseService.java b/src/main/java/com/sztzjy/financial_bigdata/service/stu/IExerciseService.java index fc8f31f..d8bbc53 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/service/stu/IExerciseService.java +++ b/src/main/java/com/sztzjy/financial_bigdata/service/stu/IExerciseService.java @@ -7,7 +7,7 @@ import java.io.IOException; import java.util.List; public interface IExerciseService { - List selectObjectQuestionListByChapterId(String chapterId, String userId) throws IOException; + List selectObjectQuestionListByChapterId(String chapterId, String userId,String schoolId,String systemOwner) throws IOException; - Boolean commitObjectQuestionList(List objectiveQuestionDtoList, String userId, String chapterId) throws IOException; + Boolean commitObjectQuestionList(List objectiveQuestionDtoList, String userId, String chapterId,String schoolId,String systemOwner) throws IOException; } diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/stu/ITheoryTestService.java b/src/main/java/com/sztzjy/financial_bigdata/service/stu/ITheoryTestService.java index c452149..1e170bd 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/service/stu/ITheoryTestService.java +++ b/src/main/java/com/sztzjy/financial_bigdata/service/stu/ITheoryTestService.java @@ -16,13 +16,13 @@ public interface ITheoryTestService { int endTheoryTest(StuTheoryTestDto theoryTestDto); - List selectErrors(String userId) throws IOException; + List selectErrors(String userId,String schoolId,String systemOwner) throws IOException; Boolean removeError(String userId, String objectiveQuestionId, String type); PageInfo getTheoryTestList(String userId, Integer index, Integer size); - List getTheoryTestDetail(String theoryExamId, Integer index, Integer size) throws IOException; + List getTheoryTestDetail(String theoryExamId, Integer index, Integer size,String schoolId,String systemOwner) throws IOException; Date getStartTime(String userId); } diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/ExerciseServiceImpl.java b/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/ExerciseServiceImpl.java index 499af0d..c7c916b 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/ExerciseServiceImpl.java +++ b/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/ExerciseServiceImpl.java @@ -29,7 +29,7 @@ public class ExerciseServiceImpl implements IExerciseService { SysObjectiveQuestionMapper objectiveQuestionMapper; @Override - public List selectObjectQuestionListByChapterId(String chapterId, String userId) throws IOException { + public List selectObjectQuestionListByChapterId(String chapterId, String userId,String schoolId,String systemOwner) throws IOException { StuTrainingExample example = new StuTrainingExample(); example.createCriteria().andUserIdEqualTo(userId).andChapterIdEqualTo(chapterId); List stuTrainingWithBLOBs = trainingMapper.selectByExampleWithBLOBs(example); @@ -88,7 +88,7 @@ public class ExerciseServiceImpl implements IExerciseService { List learningEvalIdlist = Arrays.asList(bloBs.getLearningEvalIdlist().substring(1, bloBs.getLearningEvalIdlist().length() - 1).split(", ")); for (int i = 0; i < learningEvalIdlist.size(); i++) { String objectiveId = learningEvalIdlist.get(i); - SysObjectiveQuestions objectiveQuestion = ObjectiveApi.selectObjectiveDetails(objectiveId); + SysObjectiveQuestions objectiveQuestion = ObjectiveApi.selectObjectiveDetails(objectiveId, schoolId, systemOwner); SysObjectiveQuestionDto sysObjectiveQuestionDto = new SysObjectiveQuestionDto("0","",objectiveQuestion); dtos.add(sysObjectiveQuestionDto); } @@ -99,7 +99,7 @@ public class ExerciseServiceImpl implements IExerciseService { for (int i = 0; i < learningEvalIdlist.size(); i++) { String objectiveId = learningEvalIdlist.get(i); String stuAnswer = learningEvalAnswerList.get(i); - SysObjectiveQuestions objectiveQuestion = ObjectiveApi.selectObjectiveDetails(objectiveId); + SysObjectiveQuestions objectiveQuestion = ObjectiveApi.selectObjectiveDetails(objectiveId, schoolId, systemOwner); SysObjectiveQuestionDto sysObjectiveQuestionDto = new SysObjectiveQuestionDto("1",stuAnswer,objectiveQuestion); dtos.add(sysObjectiveQuestionDto); } @@ -112,32 +112,35 @@ public class ExerciseServiceImpl implements IExerciseService { } @Override - public Boolean commitObjectQuestionList(List objectiveQuestionDtoList, String userId, String chapterId) throws IOException { + public Boolean commitObjectQuestionList(List objectiveQuestionDtoList, String userId, String chapterId,String schoolId,String systemOwner) throws IOException { StuTrainingExample example = new StuTrainingExample(); example.createCriteria().andUserIdEqualTo(userId).andChapterIdEqualTo(chapterId); List stuTrainingWithBLOBs = trainingMapper.selectByExampleWithBLOBs(example); - if (stuTrainingWithBLOBs.get(0).getLearningEvalAnswer()!=null){ - return false; - } +// if (stuTrainingWithBLOBs.get(0).getLearningEvalAnswer()!=null){ +// return false; +// } List stuAnswerList = new ArrayList<>(); BigDecimal learning_eval_score= BigDecimal.valueOf(0); + List objectiveIds=new ArrayList<>(); for (int i = 0; i < objectiveQuestionDtoList.size(); i++) { SysObjectiveQuestionDto sysObjectiveQuestionDto = objectiveQuestionDtoList.get(i); String stuAnswer = sysObjectiveQuestionDto.getStuAnswer(); String objectiveId = sysObjectiveQuestionDto.getObjectiveId(); - SysObjectiveQuestions objectiveQuestion = ObjectiveApi.selectObjectiveDetails(objectiveId); + SysObjectiveQuestions objectiveQuestion = ObjectiveApi.selectObjectiveDetails(objectiveId, schoolId, systemOwner); String answer = objectiveQuestion.getAnswer(); stuAnswerList.add(stuAnswer); if(answer.equals(stuAnswer)){ learning_eval_score= learning_eval_score.add(objectiveQuestion.getScore()); } + objectiveIds.add(objectiveId); } StuTrainingWithBLOBs bloBs = stuTrainingWithBLOBs.get(0); bloBs.setLearningEvalAnswer(String.valueOf(stuAnswerList)); bloBs.setLearningEvalScore(learning_eval_score); bloBs.setLearningEvalCompleteStatus(1); BigDecimal progress = bloBs.getProgress(); + bloBs.setLearningEvalIdlist(String.valueOf(objectiveIds)); if(progress==null){ progress= BigDecimal.valueOf(1); }else{ diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/TheoryTestServiceImpl.java b/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/TheoryTestServiceImpl.java index 66f6356..e3d37f1 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/TheoryTestServiceImpl.java +++ b/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/TheoryTestServiceImpl.java @@ -244,7 +244,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService { } @Override - public List selectErrors(String userId) throws IOException { + public List selectErrors(String userId,String schoolId,String systemOwner) throws IOException { StuErrorExample example = new StuErrorExample(); example.createCriteria().andUserIdEqualTo(userId); List stuErrors = errorMapper.selectByExampleWithBLOBs(example); @@ -257,7 +257,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService { if (!singleIds.isEmpty()) { List singleIdList = Arrays.asList(singleIds.substring(1, singleIds.length() - 1).split(", ")); for (int i = 0; i < singleIdList.size(); i++) { - SysObjectiveQuestions objectiveQuestion = ObjectiveApi.selectObjectiveDetails(singleIdList.get(i)); + SysObjectiveQuestions objectiveQuestion = ObjectiveApi.selectObjectiveDetails(singleIdList.get(i), schoolId, systemOwner); objectiveQuestionList.add(objectiveQuestion); } } @@ -265,7 +265,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService { if (!multipleIds.isEmpty()) { List stringList = Arrays.asList(multipleIds.substring(1, multipleIds.length() - 1).split(", ")); for (int i = 0; i < stringList.size(); i++) { - SysObjectiveQuestions objectiveQuestion = ObjectiveApi.selectObjectiveDetails(stringList.get(i)); + SysObjectiveQuestions objectiveQuestion = ObjectiveApi.selectObjectiveDetails(stringList.get(i), schoolId, systemOwner); objectiveQuestionList.add(objectiveQuestion); } } @@ -273,7 +273,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService { if (!judgeIds.isEmpty()) { List stringList = Arrays.asList(judgeIds.substring(1, judgeIds.length() - 1).split(", ")); for (int i = 0; i < stringList.size(); i++) { - SysObjectiveQuestions objectiveQuestion = ObjectiveApi.selectObjectiveDetails(stringList.get(i)); + SysObjectiveQuestions objectiveQuestion = ObjectiveApi.selectObjectiveDetails(stringList.get(i), schoolId, systemOwner); objectiveQuestionList.add(objectiveQuestion); } } @@ -337,7 +337,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService { } @Override - public List getTheoryTestDetail(String theoryExamId, Integer index, Integer size) throws IOException { + public List getTheoryTestDetail(String theoryExamId, Integer index, Integer size,String schoolId,String systemOwner) throws IOException { StuTheoryExamWithBLOBs theoryExam = theoryExamMapper.selectByPrimaryKey(theoryExamId); String singleIds = theoryExam.getSingleIds(); ArrayList idsList = new ArrayList<>(); @@ -395,7 +395,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService { StuTheoryExamDetailDto detailDto = new StuTheoryExamDetailDto(); String objectiveQuestionId = idsList.get(i); String stuAnswer = answerList.get(i).trim(); - SysObjectiveQuestions objectiveQuestion = ObjectiveApi.selectObjectiveDetails(objectiveQuestionId); + SysObjectiveQuestions objectiveQuestion = ObjectiveApi.selectObjectiveDetails(objectiveQuestionId, schoolId, systemOwner); BigDecimal score = objectiveQuestion.getScore(); String content = objectiveQuestion.getContent(); String answer = objectiveQuestion.getAnswer(); From 6834ac6a43aecfe3c174a41b60c221979ffb127a Mon Sep 17 00:00:00 2001 From: whb <17803890193@163.com> Date: Wed, 24 Jul 2024 09:27:16 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=BB=91=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E8=BF=90=E8=A1=8Cpython=E4=BB=A3=E7=A0=81=E7=94=9F?= =?UTF-8?q?=E6=88=90=E5=A4=9A=E5=BC=A0=E7=9B=B8=E5=90=8C=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../financial_bigdata/controller/stu/JupyterController.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/JupyterController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/JupyterController.java index 546ec4c..dd5f828 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/JupyterController.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/JupyterController.java @@ -134,6 +134,11 @@ public class JupyterController { for (int i = 0; i < lines.length; i++) { + // 跳过注释行 + if (lines[i].trim().startsWith("#")) { + continue; + } + String imgPathv = IdUtil.simpleUUID(); String plotFile = pyPath + imgPathv + ".png";