diff --git a/enlish-service/src/main/java/com/yinlihupo/enlish/service/constant/ExamWordsConstant.java b/enlish-service/src/main/java/com/yinlihupo/enlish/service/constant/ExamWordsConstant.java index dcdc469..e8a27ef 100644 --- a/enlish-service/src/main/java/com/yinlihupo/enlish/service/constant/ExamWordsConstant.java +++ b/enlish-service/src/main/java/com/yinlihupo/enlish/service/constant/ExamWordsConstant.java @@ -31,9 +31,15 @@ public class ExamWordsConstant { public static final int ZONE_F_SIZE = 7; + // 摸底 public static final int EXAM_TYPE_BASELINE = 1; + // 中期 public static final int EXAM_TYPE_MIDTERM = 2; + // 期末 public static final int EXAM_TYPE_FINAL = 3; + // 小测 + public static final int EXAM_TYPE_TEST = 4; + public static int getZoneA(int gradeId) { return switch (gradeId) { @@ -131,4 +137,17 @@ public class ExamWordsConstant { default -> ""; }; } + + public static String day2Chinese(int day) { + return switch (day) { + case 1 -> "一"; + case 2 -> "二"; + case 3 -> "三"; + case 4 -> "四"; + case 5 -> "五"; + case 6 -> "六"; + case 7 -> "七"; + default -> ""; + }; + } } diff --git a/enlish-service/src/main/java/com/yinlihupo/enlish/service/controller/ExamWordsController.java b/enlish-service/src/main/java/com/yinlihupo/enlish/service/controller/ExamWordsController.java index 90a7b56..2c2befa 100644 --- a/enlish-service/src/main/java/com/yinlihupo/enlish/service/controller/ExamWordsController.java +++ b/enlish-service/src/main/java/com/yinlihupo/enlish/service/controller/ExamWordsController.java @@ -113,8 +113,8 @@ public class ExamWordsController { .builder() .id(examWordsJudgeResultDO.getId()) .studentId(examWordsJudgeResultDO.getStudentId()) - .studentName(studentService.getStudentById(examWordsJudgeResultDO.getStudentId()).getName()) - .examWordsTitle(examWordsService.getExamWordsDOById(examWordsJudgeResultDO.getExamWordsId()).getTitle()) + .studentName(examWordsJudgeResultDO.getStudentId() != null ? studentService.getStudentById(examWordsJudgeResultDO.getStudentId()).getName() : "") + .examWordsTitle(examWordsJudgeResultDO.getExamWordsId() != null ? examWordsService.getExamWordsDOById(examWordsJudgeResultDO.getExamWordsId()).getTitle() : "") .examWordsId(examWordsJudgeResultDO.getExamWordsId()) .startDate(examWordsJudgeResultDO.getStartDate()) .correctWordCount(examWordsJudgeResultDO.getCorrectWordCount()) diff --git a/enlish-service/src/main/java/com/yinlihupo/enlish/service/domain/dataobject/PlanExamDO.java b/enlish-service/src/main/java/com/yinlihupo/enlish/service/domain/dataobject/PlanExamDO.java new file mode 100644 index 0000000..b1baee5 --- /dev/null +++ b/enlish-service/src/main/java/com/yinlihupo/enlish/service/domain/dataobject/PlanExamDO.java @@ -0,0 +1,21 @@ +package com.yinlihupo.enlish.service.domain.dataobject; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@AllArgsConstructor +@NoArgsConstructor +@Data +@Builder +public class PlanExamDO { + + private Integer id; + + private Integer planId; + + private Integer examId; + + +} \ No newline at end of file diff --git a/enlish-service/src/main/java/com/yinlihupo/enlish/service/domain/mapper/PlanExamDOMapper.java b/enlish-service/src/main/java/com/yinlihupo/enlish/service/domain/mapper/PlanExamDOMapper.java new file mode 100644 index 0000000..261da67 --- /dev/null +++ b/enlish-service/src/main/java/com/yinlihupo/enlish/service/domain/mapper/PlanExamDOMapper.java @@ -0,0 +1,9 @@ +package com.yinlihupo.enlish.service.domain.mapper; + +import com.yinlihupo.enlish.service.domain.dataobject.PlanExamDO; + +public interface PlanExamDOMapper { + void insert(PlanExamDO record); + + PlanExamDO selectByExamId(Integer examId); +} \ No newline at end of file diff --git a/enlish-service/src/main/java/com/yinlihupo/enlish/service/service/judge/ExamWordsJudgeServiceImpl.java b/enlish-service/src/main/java/com/yinlihupo/enlish/service/service/judge/ExamWordsJudgeServiceImpl.java index 9ed460c..9db5c05 100644 --- a/enlish-service/src/main/java/com/yinlihupo/enlish/service/service/judge/ExamWordsJudgeServiceImpl.java +++ b/enlish-service/src/main/java/com/yinlihupo/enlish/service/service/judge/ExamWordsJudgeServiceImpl.java @@ -9,6 +9,7 @@ import com.yinlihupo.enlish.service.model.bo.exam.ActionType; import com.yinlihupo.enlish.service.model.bo.exam.DiagnosisResult; import com.yinlihupo.enlish.service.model.bo.exam.ZoneStats; import com.yinlihupo.enlish.service.service.ExamWordsJudgeService; +import com.yinlihupo.enlish.service.service.StudentLessonPlansService; import com.yinlihupo.enlish.service.utils.PngUtil; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; @@ -40,6 +41,10 @@ public class ExamWordsJudgeServiceImpl implements ExamWordsJudgeService { private GradeUnitDOMapper gradeUnitDOMapper; @Resource private StudentDOMapper studentDOMapper; + @Resource + private PlanExamDOMapper planExamDOMapper; + @Resource + private StudentLessonPlansService studentLessonPlansService; @Value("${templates.data}") private String tessdataPath; @@ -56,6 +61,7 @@ public class ExamWordsJudgeServiceImpl implements ExamWordsJudgeService { StudentExamId studentExamId = PngUtil.analyzeExamWordsIdAndStudentId(ansSheetPath, tessdataPath, coordinatesXIES); Integer examWordsJudgeResultDOId = examWordsJudgeResultDO.getId(); if (studentExamId == null) { + log.info("未找到学生 id 和考试 id"); examWordsJudgeResultDOMapper.updateMsg(examWordsJudgeResultDOId, "未识别学生 id 和考试 id"); continue; } @@ -93,9 +99,13 @@ public class ExamWordsJudgeServiceImpl implements ExamWordsJudgeService { .wrongWordCount(unmemorizedWordIds.size()) .isFinished(1) .build(); - // 判断考试等级 - judgeExamActualGrade(wordsJudgeResultDO, examWordsDO); + if (examWordsDO.getType().equals(ExamWordsConstant.EXAM_TYPE_BASELINE)) { + // 判断考试等级 + judgeExamActualGrade(wordsJudgeResultDO, examWordsDO); + } else { + wordsJudgeResultDO.setMsg("此次考试" + examWordsDO.getTitle() + "答对单词数为" + memorizedWordIds.size()); + } int updated = examWordsJudgeResultDOMapper.updateExamWordsJudgeResultDO(wordsJudgeResultDO); if (updated != 1) { examWordsJudgeResultDOMapper.updateMsg(examWordsJudgeResultDOId, "更新考试记录失败"); @@ -103,6 +113,12 @@ public class ExamWordsJudgeServiceImpl implements ExamWordsJudgeService { } log.info("更新考试记录成功"); + PlanExamDO planExamDO = planExamDOMapper.selectByExamId(examWordsId); + if (planExamDO != null) { + studentLessonPlansService.finishStudentLessonPlan(studentId, planExamDO.getPlanId()); + log.info("完成学案成功, planId: {}", planExamDO.getPlanId()); + } + List wordMasteryLogDOS = new ArrayList<>(unmemorizedWordIds.stream().map(wordId -> WordMasteryLogDO.builder() .wordId(wordId) .studentId(studentId) diff --git a/enlish-service/src/main/java/com/yinlihupo/enlish/service/service/plan/LessonPlansServiceImpl.java b/enlish-service/src/main/java/com/yinlihupo/enlish/service/service/plan/LessonPlansServiceImpl.java index 338b236..7ff086d 100644 --- a/enlish-service/src/main/java/com/yinlihupo/enlish/service/service/plan/LessonPlansServiceImpl.java +++ b/enlish-service/src/main/java/com/yinlihupo/enlish/service/service/plan/LessonPlansServiceImpl.java @@ -1,5 +1,6 @@ package com.yinlihupo.enlish.service.service.plan; +import com.yinlihupo.enlish.service.constant.ExamWordsConstant; import com.yinlihupo.enlish.service.constant.LessonPlanConstant; import com.yinlihupo.enlish.service.domain.dataobject.*; import com.yinlihupo.enlish.service.domain.mapper.*; @@ -36,6 +37,14 @@ public class LessonPlansServiceImpl implements LessonPlansService { private GradeDOMapper gradeDOMapper; @Resource private DifyClient difyClient; + @Resource + private ExamWordsDOMapper examWordsDOMapper; + @Resource + private StudentExamWordsDOMapper studentExamWordsDOMapper; + @Resource + private StudentDOMapper studentDOMapper; + @Resource + private PlanExamDOMapper planExamDOMapper; @Override @@ -116,6 +125,13 @@ public class LessonPlansServiceImpl implements LessonPlansService { .build(); studentLessonPlansDOMapper.insert(studentLessonPlansDO); + Integer examId = (Integer) lessonPlanMap.get("examId"); + PlanExamDO planExamDO = PlanExamDO.builder() + .planId(lessonPlansDO.getId()) + .examId(examId) + .build(); + planExamDOMapper.insert(planExamDO); + } catch (Exception e) { log.info("生成第{}天计划失败,失败原因 {}", i + 1, e.getMessage()); } @@ -244,6 +260,40 @@ public class LessonPlansServiceImpl implements LessonPlansService { data.put("sentences", sentences); data.put("sentencesAns", sentences); log.info( "生成连词成句成功"); + + + // 教案小测 + List words = new ArrayList<>(syncVocabList); + words.addAll(gapVocabList); + words.addAll(reviewVocabList); + if (words.size() < 100) { + words.addAll(vocabularyBankDOMapper.selectVocabularyBankListByGradeIdRandom(gradeDO.getId(), 100 - words.size())); + } else { + words = words.subList(0, 100); + } + words.forEach(word -> word.setDefinition(word.getDefinition().length() > 5 ? word.getDefinition().substring(0, 5) : word.getDefinition())); + List wordIds = words.stream().map(VocabularyBankDO::getId).toList(); + StudentDO studentDO = studentDOMapper.selectStudentById(studentId); + + String ExamTitle = gradeDO.getTitle() + unitDO.getTitle() + "教案小测 第" + ExamWordsConstant.day2Chinese(day) + "天" + studentDO.getName(); + ExamWordsDO examWordsDO = ExamWordsDO.builder() + .gradeId(gradeDO.getId()) + .level(1) + .wordIds(wordIds) + .type(ExamWordsConstant.EXAM_TYPE_TEST) + .title(ExamTitle) + .createdAt(LocalDateTime.now()) + .build(); + examWordsDOMapper.insert(examWordsDO); + studentExamWordsDOMapper.insertStudentsExam(studentId, examWordsDO.getId()); + + data.put("examId", examWordsDO.getId()); + data.put("studentId", studentId); + data.put("studentStr", studentDO.getName()); + data.put("examStr", ExamTitle); + data.put("words", words); + log.info("生成教案小测成功"); + // LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy(); // Configure config = Configure.builder() // .bind("syncVocabList", policy) diff --git a/enlish-service/src/main/java/com/yinlihupo/enlish/service/job/AutoJudgeExamWordsTask.java b/enlish-service/src/main/java/com/yinlihupo/enlish/service/task/AutoJudgeExamWordsTask.java similarity index 59% rename from enlish-service/src/main/java/com/yinlihupo/enlish/service/job/AutoJudgeExamWordsTask.java rename to enlish-service/src/main/java/com/yinlihupo/enlish/service/task/AutoJudgeExamWordsTask.java index 7bf889b..56d9d62 100644 --- a/enlish-service/src/main/java/com/yinlihupo/enlish/service/job/AutoJudgeExamWordsTask.java +++ b/enlish-service/src/main/java/com/yinlihupo/enlish/service/task/AutoJudgeExamWordsTask.java @@ -1,13 +1,13 @@ -package com.yinlihupo.enlish.service.job; +package com.yinlihupo.enlish.service.task; import com.yinlihupo.enlish.service.service.ExamWordsJudgeService; import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; -import java.time.LocalDateTime; - @Component +@Slf4j public class AutoJudgeExamWordsTask { @Resource @@ -15,7 +15,9 @@ public class AutoJudgeExamWordsTask { @Scheduled(fixedRate = 5000) public void autoJudgeExamWords() { - System.out.println("【固定频率】开始自动判卷,时间:" + LocalDateTime.now()); - examWordsJudgeService.judgeExamWords(5); + if (examWordsJudgeService.getExamWordsJudgeResultCount() != 0) { + log.info("有试卷待检测,开始检测"); + examWordsJudgeService.judgeExamWords(5); + } } } diff --git a/enlish-service/src/main/java/com/yinlihupo/enlish/service/utils/WordExportUtil.java b/enlish-service/src/main/java/com/yinlihupo/enlish/service/utils/WordExportUtil.java index 169c809..89c86dd 100644 --- a/enlish-service/src/main/java/com/yinlihupo/enlish/service/utils/WordExportUtil.java +++ b/enlish-service/src/main/java/com/yinlihupo/enlish/service/utils/WordExportUtil.java @@ -52,6 +52,7 @@ public class WordExportUtil { .bind("checkListAns", policyLessonPlanWeekday) .bind("sentences", policyLessonPlanWeekday) .bind("sentencesAns", policyLessonPlanWeekday) + .bind("words", policyLessonPlanWeekday) .build(); LoopRowTableRenderPolicy policyLessonPlan = new LoopRowTableRenderPolicy(); @@ -96,7 +97,7 @@ public class WordExportUtil { } else { template = XWPFTemplate.compile(inputStream, configLessonPlanWeekend); } - String url = "http://localhost:5173/#/plan/tts?planId=" + lessonPlan.getId(); + String url = "http://english.yinlihupo.cn/#/plan/tts?planId=" + lessonPlan.getId(); map.put("img", Pictures.ofBytes(generateQR(url), PictureType.PNG).create()); OutputStream out = response.getOutputStream(); template.render(map); diff --git a/enlish-service/src/main/resources/config/application-dev.yml b/enlish-service/src/main/resources/config/application-dev.yml index 10f2240..cda3cad 100644 --- a/enlish-service/src/main/resources/config/application-dev.yml +++ b/enlish-service/src/main/resources/config/application-dev.yml @@ -35,7 +35,7 @@ templates: count: 100 data: C:\project\tess plan: - weekday: C:\project\java\enlish_edu\enlish\enlish-service\src\main\resources\templates\tem_study_plan_v4.docx + weekday: C:\project\java\enlish_edu\enlish\enlish-service\src\main\resources\templates\tem_study_plan_v5.docx weekend: C:\project\java\enlish_edu\enlish\enlish-service\src\main\resources\templates\study_plan_review_v1.docx plan_day: 7 tmp: diff --git a/enlish-service/src/main/resources/config/application-pro.yml b/enlish-service/src/main/resources/config/application-pro.yml new file mode 100644 index 0000000..636b8e2 --- /dev/null +++ b/enlish-service/src/main/resources/config/application-pro.yml @@ -0,0 +1,52 @@ +spring: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver # 指定数据库驱动类 + # 数据库连接信息 + url: jdbc:mysql://124.220.58.5:3306/enlish?allowMultiQueries=true + username: root # 数据库用户名 + password: YLHP@admin123 # 数据库密码 + data: + redis: + database: 6 # Redis 数据库索引(默认为 0) + host: 124.220.58.5 # Redis 服务器地址 + port: 6543 # Redis 服务器连接端口 + password: 741963 # Redis 服务器连接密码(默认为空) + timeout: 5s # 读超时时间 + connect-timeout: 5s # 链接超时时间 + lettuce: + pool: + max-active: 200 # 连接池最大连接数 + max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) + min-idle: 0 # 连接池中的最小空闲连接 + max-idle: 10 # 连接池中的最大空闲连接 + ai: + openai: + api-key: your_api_key_here + base-url: http://124.220.58.5:2233 + audio: + speech: + options: + model: tts-1 + voice: alloy + + +templates: + word: assessment_v5.docx + count: 100 + data: eng.traineddata + plan: + weekday: tem_study_plan_v4.docx + weekend: study_plan_review_v1.docx + plan_day: 7 +tmp: + png: tmp\png\ + +ai: + key: app-loC6IrJpj4cS54MAYp73QtGl + analyzeKey: app-hrUFcopdcpnflsvpHWRuBfCp + sentenceKey: app-Emk5YQBaD2YruRXuE5sK1vEU + url: https://chat.cosonggle.com/v1/chat-messages + +aliyun: + accessKeyId: + accessKeySecret: diff --git a/enlish-service/src/main/resources/generatorConfig.xml b/enlish-service/src/main/resources/generatorConfig.xml index f731f84..e55c440 100644 --- a/enlish-service/src/main/resources/generatorConfig.xml +++ b/enlish-service/src/main/resources/generatorConfig.xml @@ -45,7 +45,7 @@ targetProject="src/main/java"/> - - insert into exam_words (grade_id, level, title, word_ids, created_at) - VALUES (#{gradeId}, #{level}, #{title}, #{wordIds, typeHandler=com.yinlihupo.enlish.service.config.ListWordIdTypeHandler}, #{createdAt}) + insert into exam_words (grade_id, level, title, word_ids, type, created_at) + VALUES (#{gradeId}, #{level}, #{title}, #{wordIds, typeHandler=com.yinlihupo.enlish.service.config.ListWordIdTypeHandler}, #{type}, #{createdAt}) diff --git a/enlish-service/src/main/resources/mapper/ExamWordsJudgeResultDOMapper.xml b/enlish-service/src/main/resources/mapper/ExamWordsJudgeResultDOMapper.xml index 5e7acd9..bc8b5e2 100644 --- a/enlish-service/src/main/resources/mapper/ExamWordsJudgeResultDOMapper.xml +++ b/enlish-service/src/main/resources/mapper/ExamWordsJudgeResultDOMapper.xml @@ -61,7 +61,9 @@ + + select * from plan_exam where exam_id = #{examId} + + + \ No newline at end of file diff --git a/enlish-service/src/main/resources/templates/assessment_v7.docx b/enlish-service/src/main/resources/templates/assessment_v7.docx new file mode 100644 index 0000000..370ae0b Binary files /dev/null and b/enlish-service/src/main/resources/templates/assessment_v7.docx differ diff --git a/enlish-service/src/main/resources/templates/tem_study_plan_v5.docx b/enlish-service/src/main/resources/templates/tem_study_plan_v5.docx new file mode 100644 index 0000000..c6aceb7 Binary files /dev/null and b/enlish-service/src/main/resources/templates/tem_study_plan_v5.docx differ diff --git a/enlish-service/src/test/java/com/yinlihupo/enlish/service/ai/AITest.java b/enlish-service/src/test/java/com/yinlihupo/enlish/service/ai/AITest.java index c3b91cd..2c9fc7a 100644 --- a/enlish-service/src/test/java/com/yinlihupo/enlish/service/ai/AITest.java +++ b/enlish-service/src/test/java/com/yinlihupo/enlish/service/ai/AITest.java @@ -27,9 +27,6 @@ public class AITest { try { - List vocabularyBankDOS = vocabularyBankDOMapper.selectVocabularyBankDOAllByUnitId(269); - List sentences = client.sendSentenceAnalyze(vocabularyBankDOS, "小学4年级"); - } catch (Exception e) { e.printStackTrace(); diff --git a/enlish-service/src/test/java/com/yinlihupo/enlish/service/mapper/TestVocabularyBankInsert.java b/enlish-service/src/test/java/com/yinlihupo/enlish/service/mapper/TestVocabularyBankInsert.java index 76590b8..5468809 100644 --- a/enlish-service/src/test/java/com/yinlihupo/enlish/service/mapper/TestVocabularyBankInsert.java +++ b/enlish-service/src/test/java/com/yinlihupo/enlish/service/mapper/TestVocabularyBankInsert.java @@ -35,68 +35,68 @@ public class TestVocabularyBankInsert { private GradeUnitDOMapper gradeUnitDOMapper; @Test void test() { - String file = "C:\\project\\java\\enlish_edu\\enlish\\enlish-service\\src\\test\\java\\com\\yinlihupo\\enlish\\service\\mapper\\八下.xlsx"; - HashMap map = new HashMap<>(); - int gradeId = 8; - try (FileInputStream fis = new FileInputStream(file); Workbook workbook = new XSSFWorkbook(fis)) { - - Sheet sheet = workbook.getSheetAt(0); - - for (int i = 1; i <= sheet.getLastRowNum(); i++) { - Row row = sheet.getRow(i); - if (row == null) { - continue; - } - - +// String file = "C:\\project\\java\\enlish_edu\\enlish\\enlish-service\\src\\test\\java\\com\\yinlihupo\\enlish\\service\\mapper\\八下.xlsx"; +// HashMap map = new HashMap<>(); +// int gradeId = 8; +// try (FileInputStream fis = new FileInputStream(file); Workbook workbook = new XSSFWorkbook(fis)) { +// +// Sheet sheet = workbook.getSheetAt(0); +// +// for (int i = 1; i <= sheet.getLastRowNum(); i++) { +// Row row = sheet.getRow(i); +// if (row == null) { +// continue; +// } +// +// // String word = row.getCell(0).getStringCellValue(); // String pronunciation = row.getCell(1) != null ? row.getCell(1).getStringCellValue() : ""; // String pos = row.getCell(2) != null ? row.getCell(2).getStringCellValue() : ""; // String meaning = row.getCell(3) != null ? row.getCell(3).getStringCellValue() : ""; // String gradeUnit = row.getCell(4) != null ? row.getCell(4).getStringCellValue() : ""; - - String word = row.getCell(0).getStringCellValue(); - String meaning = row.getCell(1) != null ? row.getCell(1).getStringCellValue() : ""; - String gradeUnit = row.getCell(2) != null ? row.getCell(2).getStringCellValue() : ""; - String pronunciation = ""; - String pos = ""; - if (word.contains("Unit")) { - continue; - } - - int gradeUnitId; - if (map.containsKey(gradeUnit)) { - gradeUnitId = map.get(gradeUnit); - } else { - UnitDO unitDO = unitDOMapper.selectByTitle(gradeUnit); - if (unitDO == null) { - unitDO = UnitDO.builder() - .title(gradeUnit) - .version("人教版") - .createAt(LocalDateTime.now()) - .build(); - unitDOMapper.insert(unitDO); - gradeUnitDOMapper.insert(GradeUnitDO.builder().unitId(unitDO.getId()).gradeId(gradeId).build()); - gradeUnitId = unitDO.getId(); - } else { - gradeUnitId = unitDO.getId(); - } - - map.put(gradeUnit, gradeUnitId); - } - VocabularyBankDO vocabularyBankDO = VocabularyBankDO.builder() - .word(word) - .definition(meaning) - .pronunciation(pronunciation) - .pos(pos) - .unitId(gradeUnitId) - .build(); - vocabularyBankMapper.insertSelective(vocabularyBankDO); - log.info("插入数据 {} ", vocabularyBankDO); - } - - } catch (IOException e) { - throw new RuntimeException(e); - } +// +// String word = row.getCell(0).getStringCellValue(); +// String meaning = row.getCell(1) != null ? row.getCell(1).getStringCellValue() : ""; +// String gradeUnit = row.getCell(2) != null ? row.getCell(2).getStringCellValue() : ""; +// String pronunciation = ""; +// String pos = ""; +// if (word.contains("Unit")) { +// continue; +// } +// +// int gradeUnitId; +// if (map.containsKey(gradeUnit)) { +// gradeUnitId = map.get(gradeUnit); +// } else { +// UnitDO unitDO = unitDOMapper.selectByTitle(gradeUnit); +// if (unitDO == null) { +// unitDO = UnitDO.builder() +// .title(gradeUnit) +// .version("人教版") +// .createAt(LocalDateTime.now()) +// .build(); +// unitDOMapper.insert(unitDO); +// gradeUnitDOMapper.insert(GradeUnitDO.builder().unitId(unitDO.getId()).gradeId(gradeId).build()); +// gradeUnitId = unitDO.getId(); +// } else { +// gradeUnitId = unitDO.getId(); +// } +// +// map.put(gradeUnit, gradeUnitId); +// } +// VocabularyBankDO vocabularyBankDO = VocabularyBankDO.builder() +// .word(word) +// .definition(meaning) +// .pronunciation(pronunciation) +// .pos(pos) +// .unitId(gradeUnitId) +// .build(); +// vocabularyBankMapper.insertSelective(vocabularyBankDO); +// log.info("插入数据 {} ", vocabularyBankDO); +// } +// +// } catch (IOException e) { +// throw new RuntimeException(e); +// } } } diff --git a/enlish-service/src/test/java/com/yinlihupo/enlish/service/mapper/WordMasteryLogInsertTest.java b/enlish-service/src/test/java/com/yinlihupo/enlish/service/mapper/WordMasteryLogInsertTest.java index d785d1d..05d23ec 100644 --- a/enlish-service/src/test/java/com/yinlihupo/enlish/service/mapper/WordMasteryLogInsertTest.java +++ b/enlish-service/src/test/java/com/yinlihupo/enlish/service/mapper/WordMasteryLogInsertTest.java @@ -22,7 +22,7 @@ public class WordMasteryLogInsertTest { @Test void test() { - List integers = vocabularyBankMapper.selectAllIds(); - wordMasteryLogDOMapper.batchInsertInitialization(integers, 1); +// List integers = vocabularyBankMapper.selectAllIds(); +// wordMasteryLogDOMapper.batchInsertInitialization(integers, 1); } } diff --git a/enlish-service/src/test/java/com/yinlihupo/enlish/service/omr/TestOmr.java b/enlish-service/src/test/java/com/yinlihupo/enlish/service/omr/TestOmr.java index b666dbf..ba2b4c9 100644 --- a/enlish-service/src/test/java/com/yinlihupo/enlish/service/omr/TestOmr.java +++ b/enlish-service/src/test/java/com/yinlihupo/enlish/service/omr/TestOmr.java @@ -24,25 +24,25 @@ public class TestOmr { public void testOmr(){ OpenCV.loadLocally(); - List knownIds = Arrays.asList(3184, 3185, 3186, 3187, 3188, 3189, 3190, 3191, 3192, 3193, - 3195, 3196, 3197, 3198, 3199, 3200, 3201, 3202, 3203, 3204, - 3206, 3208, 3209, 3210, 3211, 3212, 3507, 3508, 3509, 3510, - 3511, 3512, 3513, 3514, 3515, 3516, 3517, 3519, 3521, 3522, - 3523, 3524, 3525, 3526, 3527, 3528, 3529, 3530, 3531, 3532, - 3533, 3535, 3536, 3537, 3538, 3539); - - List knowsIds = knownIds.stream().map(id -> id + "").toList(); - String path = "C:\\project\\java\\enlish_edu\\enlish\\enlish-service\\src\\main\\resources\\templates\\p3.png"; - List coordinatesXIES = PngUtil.analysisXY(path); +// List knownIds = Arrays.asList(3184, 3185, 3186, 3187, 3188, 3189, 3190, 3191, 3192, 3193, +// 3195, 3196, 3197, 3198, 3199, 3200, 3201, 3202, 3203, 3204, +// 3206, 3208, 3209, 3210, 3211, 3212, 3507, 3508, 3509, 3510, +// 3511, 3512, 3513, 3514, 3515, 3516, 3517, 3519, 3521, 3522, +// 3523, 3524, 3525, 3526, 3527, 3528, 3529, 3530, 3531, 3532, +// 3533, 3535, 3536, 3537, 3538, 3539); +// +// List knowsIds = knownIds.stream().map(id -> id + "").toList(); +// String path = "C:\\project\\java\\enlish_edu\\enlish\\enlish-service\\src\\main\\resources\\templates\\p3.png"; +// List coordinatesXIES = PngUtil.analysisXY(path); } @Test public void testInteger(){ - String filePath = "C:\\project\\java\\enlish_edu\\enlish\\enlish-service\\src\\main\\resources\\templates\\p3.png"; - List coordinatesXIES = PngUtil.analysisXY(filePath); - StudentExamId studentExamId = PngUtil.analyzeExamWordsIdAndStudentId(filePath, tessdataPath, coordinatesXIES); - log.info("studentExamId:{}",studentExamId); +// String filePath = "C:\\project\\java\\enlish_edu\\enlish\\enlish-service\\src\\main\\resources\\templates\\p3.png"; +// List coordinatesXIES = PngUtil.analysisXY(filePath); +// StudentExamId studentExamId = PngUtil.analyzeExamWordsIdAndStudentId(filePath, tessdataPath, coordinatesXIES); +// log.info("studentExamId:{}",studentExamId); } } diff --git a/enlish-service/src/test/java/com/yinlihupo/enlish/service/service/exam/ExamTest.java b/enlish-service/src/test/java/com/yinlihupo/enlish/service/service/exam/ExamTest.java index 8e6b80d..e7c295a 100644 --- a/enlish-service/src/test/java/com/yinlihupo/enlish/service/service/exam/ExamTest.java +++ b/enlish-service/src/test/java/com/yinlihupo/enlish/service/service/exam/ExamTest.java @@ -26,36 +26,36 @@ public class ExamTest { private VocabularyService vocabularyService; @Test public void test() { - ExamWordsDO examWordsDO = examWordsService.generateExamWords(5, 0); - log.info("{}", examWordsDO); - List vocabularyBankDOS = vocabularyService.findVocabularyBankDOListById(examWordsDO.getWordIds()); - List assessmentWords = vocabularyBankDOS.stream().map(vocabularyBankDO -> Word.builder() - .id(vocabularyBankDO.getId()) - .title(vocabularyBankDO.getWord()) - .definition(vocabularyBankDO.getDefinition()) - .build()).toList(); - - - LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy(); - Configure config = Configure.builder() - .bind("words", policy) - .build(); - - Map data = new HashMap<>(); - data.put("examId", examWordsDO.getId()); - data.put("studentId", 1); - data.put("studentStr","小明三班一年级"); - data.put("examStr", examWordsDO.getTitle()); - data.put("words", assessmentWords); - data.put("answer", assessmentWords); - - // 4. 渲染并输出 - try (XWPFTemplate template = XWPFTemplate.compile("C:\\project\\java\\enlish_edu\\enlish\\enlish-service\\src\\main\\resources\\templates\\assessment_v5.docx", config)) { - template.render(data); - template.write(new FileOutputStream("学生单词测试卷.docx")); - System.out.println("文档生成成功!"); - } catch (Exception e) { - e.printStackTrace(); - } +// ExamWordsDO examWordsDO = examWordsService.generateExamWords(5, 0); +// log.info("{}", examWordsDO); +// List vocabularyBankDOS = vocabularyService.findVocabularyBankDOListById(examWordsDO.getWordIds()); +// List assessmentWords = vocabularyBankDOS.stream().map(vocabularyBankDO -> Word.builder() +// .id(vocabularyBankDO.getId()) +// .title(vocabularyBankDO.getWord()) +// .definition(vocabularyBankDO.getDefinition()) +// .build()).toList(); +// +// +// LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy(); +// Configure config = Configure.builder() +// .bind("words", policy) +// .build(); +// +// Map data = new HashMap<>(); +// data.put("examId", examWordsDO.getId()); +// data.put("studentId", 1); +// data.put("studentStr","小明三班一年级"); +// data.put("examStr", examWordsDO.getTitle()); +// data.put("words", assessmentWords); +// data.put("answer", assessmentWords); +// +// // 4. 渲染并输出 +// try (XWPFTemplate template = XWPFTemplate.compile("C:\\project\\java\\enlish_edu\\enlish\\enlish-service\\src\\main\\resources\\templates\\assessment_v5.docx", config)) { +// template.render(data); +// template.write(new FileOutputStream("学生单词测试卷.docx")); +// System.out.println("文档生成成功!"); +// } catch (Exception e) { +// e.printStackTrace(); +// } } } diff --git a/enlish-service/src/test/java/com/yinlihupo/enlish/service/service/exam/ExamWordsJudgeServiceTest.java b/enlish-service/src/test/java/com/yinlihupo/enlish/service/service/exam/ExamWordsJudgeServiceTest.java index aa135ef..d6f3255 100644 --- a/enlish-service/src/test/java/com/yinlihupo/enlish/service/service/exam/ExamWordsJudgeServiceTest.java +++ b/enlish-service/src/test/java/com/yinlihupo/enlish/service/service/exam/ExamWordsJudgeServiceTest.java @@ -36,22 +36,22 @@ public class ExamWordsJudgeServiceTest { @Test public void judgeExamWords() { - String ansSheetPath = "C:\\project\\java\\enlish_edu\\enlish\\enlish-service\\src\\main\\resources\\templates\\3.png"; - List coordinatesXIES = PngUtil.analysisXY(ansSheetPath); - // 从图片中获取学生 id 和考试 id - String tessdataPath = "C:\\project\\tess"; - StudentExamId studentExamId = PngUtil.analyzeExamWordsIdAndStudentId(ansSheetPath, tessdataPath, coordinatesXIES); - Integer examWordsId = 41; - - ExamWordsDO examWordsDO = examWordsDOMapper.selectById(examWordsId); - - List wordIds = examWordsDO.getWordIds(); - List unmemorizedWordIds = PngUtil.analyzePngForUnmemorizedWordIds(ansSheetPath, wordIds, coordinatesXIES); - List memorizedWordIds = wordIds.stream().filter(wordId -> !unmemorizedWordIds.contains(wordId)).toList(); - List vocabularyBankDOS = vocabularyBankDOMapper.selectVocabularyBankDOListByIds(unmemorizedWordIds); - for (VocabularyBankDO vocabularyBankDO : vocabularyBankDOS) { - log.info("未掌握的单词:{}", vocabularyBankDO); - } +// String ansSheetPath = "C:\\project\\java\\enlish_edu\\enlish\\enlish-service\\src\\main\\resources\\templates\\3.png"; +// List coordinatesXIES = PngUtil.analysisXY(ansSheetPath); +// // 从图片中获取学生 id 和考试 id +// String tessdataPath = "C:\\project\\tess"; +// StudentExamId studentExamId = PngUtil.analyzeExamWordsIdAndStudentId(ansSheetPath, tessdataPath, coordinatesXIES); +// Integer examWordsId = 41; +// +// ExamWordsDO examWordsDO = examWordsDOMapper.selectById(examWordsId); +// +// List wordIds = examWordsDO.getWordIds(); +// List unmemorizedWordIds = PngUtil.analyzePngForUnmemorizedWordIds(ansSheetPath, wordIds, coordinatesXIES); +// List memorizedWordIds = wordIds.stream().filter(wordId -> !unmemorizedWordIds.contains(wordId)).toList(); +// List vocabularyBankDOS = vocabularyBankDOMapper.selectVocabularyBankDOListByIds(unmemorizedWordIds); +// for (VocabularyBankDO vocabularyBankDO : vocabularyBankDOS) { +// log.info("未掌握的单词:{}", vocabularyBankDO); +// } } @Test @@ -60,16 +60,16 @@ public class ExamWordsJudgeServiceTest { log.info("examWordsJudgeResult:{}", examWordsJudgeResult); } - @Test - public void selectExamWordsJudgeResult2() { - String s = studentService.analyzeStudentStudy(1); - try { - DifyClient.DifyResponse difyResponse = difyClient.sendStudentAnalyze(s); - String answer = difyResponse.getAnswer(); - log.info("answer:{}", answer); - } catch (Exception e) { - throw new RuntimeException(e); - } - log.info("s:{}", s); - } +// @Test +// public void selectExamWordsJudgeResult2() { +// String s = studentService.analyzeStudentStudy(1); +// try { +// DifyClient.DifyResponse difyResponse = difyClient.sendStudentAnalyze(s); +// String answer = difyResponse.getAnswer(); +// log.info("answer:{}", answer); +// } catch (Exception e) { +// throw new RuntimeException(e); +// } +// log.info("s:{}", s); +// } }