From b21e879868cd91484a389c2ddebee68a75260752 Mon Sep 17 00:00:00 2001 From: luogw <3132758203@qq.com> Date: Fri, 29 May 2026 17:44:06 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/SaveClusterDomainServiceImpl.java | 6 +- .../QuestionInventoryDomainServiceImpl.java | 95 +++++++++++++------ 2 files changed, 68 insertions(+), 33 deletions(-) diff --git a/src/main/java/com/project/interaction/domain/service/impl/SaveClusterDomainServiceImpl.java b/src/main/java/com/project/interaction/domain/service/impl/SaveClusterDomainServiceImpl.java index 66af6a2..a42ec1a 100644 --- a/src/main/java/com/project/interaction/domain/service/impl/SaveClusterDomainServiceImpl.java +++ b/src/main/java/com/project/interaction/domain/service/impl/SaveClusterDomainServiceImpl.java @@ -142,13 +142,13 @@ public class SaveClusterDomainServiceImpl implements SaveClusterDomainService { for (TaskKnowledgePointEntity kp : taskKpList) { // 调用题目生成方法 produceDTOList.add(buildDTO(kp.getId() , QuestionSourceTypeEnum.Single_Concept, - targetNum * (int) Math.ceil(questionTypeMap.get(QuestionTypeEnum.TRUE_FALSE.name())), - targetNum * (int) Math.ceil(questionTypeMap.get(QuestionTypeEnum.SINGLE_CHOICE.name())), + (int) Math.ceil(targetNum * questionTypeMap.get(QuestionTypeEnum.TRUE_FALSE.name())), + (int) Math.ceil(targetNum * questionTypeMap.get(QuestionTypeEnum.SINGLE_CHOICE.name())), 0)); } if (clusterEntity.getClusterSize() > 1) { // 簇生成目标量 - int clusterTargetNum = targetNum * (int) Math.ceil(clusterEntity.getClusterSize() * questionTypeMap.get(QuestionTypeEnum.MULTIPLE_CHOICE.name())); + int clusterTargetNum = (int) Math.ceil(targetNum * clusterEntity.getClusterSize() * questionTypeMap.get(QuestionTypeEnum.MULTIPLE_CHOICE.name())); produceDTOList.add(buildDTO(clusterEntity.getId(), QuestionSourceTypeEnum.Multi_Concept ,0,0, clusterTargetNum)); } } diff --git a/src/main/java/com/project/question/domain/service/impl/QuestionInventoryDomainServiceImpl.java b/src/main/java/com/project/question/domain/service/impl/QuestionInventoryDomainServiceImpl.java index afa0579..e5e9d97 100644 --- a/src/main/java/com/project/question/domain/service/impl/QuestionInventoryDomainServiceImpl.java +++ b/src/main/java/com/project/question/domain/service/impl/QuestionInventoryDomainServiceImpl.java @@ -59,8 +59,8 @@ public class QuestionInventoryDomainServiceImpl implements QuestionInventoryDoma continue; } checkAndProduce(kp.getId() , questionType , - watermark * (int) Math.ceil(questionTypeMap.get(questionType.name())), - targetLine * (int) Math.ceil(questionTypeMap.get(questionType.name()))); + (int) Math.ceil(watermark * questionTypeMap.get(questionType.name())), + (int) Math.ceil(targetLine * questionTypeMap.get(questionType.name()))); } } // 针对每一个簇 @@ -73,9 +73,9 @@ public class QuestionInventoryDomainServiceImpl implements QuestionInventoryDoma } int w = cluster.getClusterSize(); // 簇水位线: 1.0 * U * W - int clusterWatermark = watermark * (int) Math.ceil(w * questionTypeMap.get(QuestionTypeEnum.MULTIPLE_CHOICE.name())); + int clusterWatermark = (int) Math.ceil(watermark * w * questionTypeMap.get(QuestionTypeEnum.MULTIPLE_CHOICE.name())); // 簇目标线: 2 * U * W - int clusterTargetLine = targetLine * (int) Math.ceil(w * questionTypeMap.get(QuestionTypeEnum.MULTIPLE_CHOICE.name())); + int clusterTargetLine = (int) Math.ceil(targetLine * w * questionTypeMap.get(QuestionTypeEnum.MULTIPLE_CHOICE.name())); checkClusterProduce(cluster.getId(), clusterWatermark, clusterTargetLine); } @@ -84,9 +84,6 @@ public class QuestionInventoryDomainServiceImpl implements QuestionInventoryDoma @Override public Result checkAndReplenishBoolean(Long taskId) { - Boolean flage = false; - Integer total = 0; - TaskEntity task = taskMapper.selectById(taskId); if (task == null || task.getEndTime().before(new Date())) { return Result.success("考试任务不存在"); @@ -95,44 +92,82 @@ public class QuestionInventoryDomainServiceImpl implements QuestionInventoryDoma if (unpassed <= 0) { return Result.success("考试任务未发现未通过人数"); } + + Map questionTypeMap = questionTypeProportion(task); + int waterLine = getWatermark(task); + + StringBuilder resultBuilder = new StringBuilder(); + resultBuilder.append("=== 库存检查报告 ===\n"); + + // 单知识点簇检查 + resultBuilder.append("\n【单知识点簇】\n"); List kpList = taskKpMapper.selectList( new LambdaQueryWrapper().eq(TaskKnowledgePointEntity::getTaskId , taskId)); - for (TaskKnowledgePointEntity kp : kpList) { - for (QuestionTypeEnum questionType : QuestionTypeEnum.values()) { - if (QuestionTypeEnum.MULTIPLE_CHOICE.equals(questionType)) { - continue; - } - Map questionTypeMap = questionTypeProportion(task); - int targetLine = getTargetLine(task); - int targetNum = targetLine * (int) Math.ceil(questionTypeMap.get(questionType.name())); - total = total + targetNum; - if (!checkKpInventory(kp.getId(), questionType, targetNum)) { - flage = true; + + for (QuestionTypeEnum questionType : QuestionTypeEnum.values()) { + if (QuestionTypeEnum.MULTIPLE_CHOICE.equals(questionType)) { + continue; + } + int watermark = (int) Math.ceil(waterLine * questionTypeMap.get(questionType.name())); + resultBuilder.append("\n题型: ").append(questionType.getDescription()).append("\n"); + resultBuilder.append(" 水位线: ").append(watermark).append("\n"); + + int kpCount = 0; + int passedCount = 0; + for (TaskKnowledgePointEntity kp : kpList) { + kpCount++; + int currentStock = questionKpMapper.countAvailableByKp(kp.getId(), questionType.getValue()); + boolean isEnough = currentStock >= watermark; + if (isEnough) { + passedCount++; } } + resultBuilder.append(" 知识点总数: ").append(kpCount).append("\n"); + resultBuilder.append(" 达标知识点数: ").append(passedCount).append("\n"); + resultBuilder.append(" 是否全部达标: ").append(passedCount == kpCount ? "是" : "否").append("\n"); } - // 针对每一个簇 + + // 多知识点簇检查 + resultBuilder.append("\n【多知识点簇】\n"); List clusterList = clusterMapper.selectList( new LambdaQueryWrapper().eq(TaskKnowledgeClusterEntity::getTaskId, taskId)); + + // 按簇大小分组统计 + Map sizeTotalMap = new HashMap<>(); + Map sizePassedMap = new HashMap<>(); + for (TaskKnowledgeClusterEntity cluster : clusterList) { if (cluster.getClusterSize() < 2) { continue; } - - Map questionTypeMap = questionTypeProportion(task); - int targetLine = getTargetLine(task); - // 簇目标线: 2 * U * W int w = cluster.getClusterSize(); - int targetNum = targetLine * (int) Math.ceil(w * questionTypeMap.get(QuestionTypeEnum.MULTIPLE_CHOICE.name())); - total = total + targetNum; - if (!checkClusterInventory(cluster.getId(), targetNum)) { - flage = true; + int watermark = (int) Math.ceil(waterLine * w * questionTypeMap.get(QuestionTypeEnum.MULTIPLE_CHOICE.name())); + int currentStock = questionKpMapper.countAvailableByCluster(cluster.getId()); + boolean isEnough = currentStock >= watermark; + + sizeTotalMap.merge(w, 1, Integer::sum); + if (isEnough) { + sizePassedMap.merge(w, 1, Integer::sum); } } - if (flage){ - return Result.success("题目未生成完成,目标题量:"+total); + + if (sizeTotalMap.isEmpty()) { + resultBuilder.append(" 无多知识点簇\n"); + } else { + for (Integer size : sizeTotalMap.keySet().stream().sorted().toList()) { + int total = sizeTotalMap.get(size); + int passed = sizePassedMap.getOrDefault(size, 0); + int watermark = (int) Math.ceil(waterLine * size * questionTypeMap.get(QuestionTypeEnum.MULTIPLE_CHOICE.name())); + resultBuilder.append("\n簇大小: ").append(size).append("\n"); + resultBuilder.append(" 题型: 多选题\n"); + resultBuilder.append(" 水位线: ").append(watermark).append("\n"); + resultBuilder.append(" 簇总数: ").append(total).append("\n"); + resultBuilder.append(" 达标簇数: ").append(passed).append("\n"); + resultBuilder.append(" 是否全部达标: ").append(passed == total ? "是" : "否").append("\n"); + } } - return Result.success("题目生成完成,目标题量:"+total); + + return Result.success(resultBuilder.toString()); } /**