From c14d960cd0720cdff7e635a852158a5493a4d79a Mon Sep 17 00:00:00 2001 From: luogw <3132758203@qq.com> Date: Mon, 20 Jul 2026 14:29:32 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...lgorithmClassicPaperQuestionGenerator.java | 6 +- .../DraftReviewApplicationService.java | 7 +- .../DraftReviewApplicationServiceImpl.java | 107 ++++++++++-------- .../controller/InformationController.java | 10 +- .../domain/param/InformationParam.java | 1 + .../PostToAiExtractDomainServiceImpl.java | 6 +- .../PostToAiScoringDomainServiceImpl.java | 7 +- ...stToGenerateQuestionDomainServiceImpl.java | 2 +- src/main/resources/application-dev.yml | 8 +- src/main/resources/application-prod.yml | 10 +- src/main/resources/application-test.yml | 8 +- 11 files changed, 100 insertions(+), 72 deletions(-) diff --git a/src/main/java/com/project/classicpaper/domain/service/impl/AlgorithmClassicPaperQuestionGenerator.java b/src/main/java/com/project/classicpaper/domain/service/impl/AlgorithmClassicPaperQuestionGenerator.java index 0337373..4696b49 100644 --- a/src/main/java/com/project/classicpaper/domain/service/impl/AlgorithmClassicPaperQuestionGenerator.java +++ b/src/main/java/com/project/classicpaper/domain/service/impl/AlgorithmClassicPaperQuestionGenerator.java @@ -36,8 +36,8 @@ public class AlgorithmClassicPaperQuestionGenerator implements ClassicPaperQuest @Value("${algo.classicPaperGenerateUrl:/v1/generate/questions_from_cluster}") private String generateUrl; - @Value("${algo.apiUrl:http://172.16.25.174:8000}") - private String apiUrl; + @Value("${algo.apiTwoUrl:http://172.16.25.174:8011}") + private String apiTwoUrl; @Value("${algo.callbackUrl:http://172.16.204.50/evaluator-api}") private String callbackUrl; @@ -80,7 +80,7 @@ public class AlgorithmClassicPaperQuestionGenerator implements ClassicPaperQuest try { GenerateQuestionResponseDTO response = algorithmWebClient.post() - .uri(apiUrl + generateUrl) + .uri(apiTwoUrl + generateUrl) .bodyValue(request) .retrieve() .onStatus( diff --git a/src/main/java/com/project/information/application/DraftReviewApplicationService.java b/src/main/java/com/project/information/application/DraftReviewApplicationService.java index b31000f..f9b6996 100644 --- a/src/main/java/com/project/information/application/DraftReviewApplicationService.java +++ b/src/main/java/com/project/information/application/DraftReviewApplicationService.java @@ -1,9 +1,10 @@ package com.project.information.application; +import com.project.base.domain.result.PageResult; import com.project.base.domain.result.Result; import com.project.information.domain.dto.DraftSaveDTO; import com.project.information.domain.dto.KnowledgePointDraftDTO; -import com.project.information.domain.entity.KnowledgePointDraftEntity; +import com.project.information.domain.param.InformationParam; import java.util.List; @@ -12,7 +13,7 @@ import java.util.List; */ public interface DraftReviewApplicationService { - Result> listDrafts(Long informationId); + Result> listDrafts(InformationParam param); Result updateDraft(Long draftId, String content); @@ -20,7 +21,7 @@ public interface DraftReviewApplicationService { Result addDraft(Long informationId, String content, Integer knowledgeType); - Result confirm(Long informationId); + Result confirm(Long informationId, String name); /** * 批量保存草稿并确认(替代逐条编辑+单独确认) diff --git a/src/main/java/com/project/information/application/impl/DraftReviewApplicationServiceImpl.java b/src/main/java/com/project/information/application/impl/DraftReviewApplicationServiceImpl.java index fd41b21..c6a7b72 100644 --- a/src/main/java/com/project/information/application/impl/DraftReviewApplicationServiceImpl.java +++ b/src/main/java/com/project/information/application/impl/DraftReviewApplicationServiceImpl.java @@ -2,9 +2,12 @@ package com.project.information.application.impl; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.project.base.domain.exception.BusinessErrorException; -import com.project.base.config.CustomIdGenerator; +import com.project.base.domain.result.PageResult; import com.project.base.domain.result.Result; +import com.project.base.config.CustomIdGenerator; import com.project.information.application.DraftReviewApplicationService; import com.project.information.domain.dto.DraftSaveDTO; import com.project.information.domain.dto.KnowledgePointDTO; @@ -15,6 +18,7 @@ import com.project.information.domain.entity.KnowledgePointDraftEntity; import com.project.information.domain.entity.KnowledgePointEntity; import com.project.information.domain.enums.AuditStatusEnum; import com.project.information.domain.enums.DraftStatusEnum; +import com.project.information.domain.param.InformationParam; import com.project.information.domain.service.ConfirmKnowledgePointDraftDomainService; import com.project.information.domain.service.InformationBaseService; import com.project.information.domain.service.KnowledgeClusterBaseService; @@ -66,27 +70,32 @@ public class DraftReviewApplicationServiceImpl implements DraftReviewApplication @Override - public Result> listDrafts(Long informationId) { - if (informationId == null) { + public Result> listDrafts(InformationParam param) { + if (param.getInformationId() == null) { throw new BusinessErrorException("资料ID不能为空"); } - List drafts = knowledgePointDraftBaseService.list( + + Page page = new Page<>(param.getCurrent(), param.getSize()); + IPage pageResult = knowledgePointDraftBaseService.page(page, new LambdaQueryWrapper() - .eq(KnowledgePointDraftEntity::getInformationId, informationId) + .eq(KnowledgePointDraftEntity::getInformationId, param.getInformationId()) .orderByAsc(KnowledgePointDraftEntity::getId)); - List res = drafts.stream() + + List res = pageResult.getRecords().stream() .map(entity -> entity.toDTO(KnowledgePointDraftDTO::new)) .toList(); - Long infoId = drafts.stream() - .findAny() - .map(KnowledgePointDraftEntity::getInformationId) - .orElse(null); // 或者 .orElse(0L) 给个默认值 - if (Objects.nonNull(infoId)) { - InformationEntity one = informationBaseService.getById(infoId); - res.forEach(dto -> dto.setInformationName(one.getName())); + // 填充资料名称 + InformationEntity information = informationBaseService.getById(param.getInformationId()); + if (information != null) { + String name = information.getName(); + res.forEach(dto -> dto.setInformationName(name)); } - return Result.success(res); + + // 构造 DTO 分页结果 + Page dtoPage = new Page<>(pageResult.getCurrent(), pageResult.getSize(), pageResult.getTotal()); + dtoPage.setRecords(res); + return Result.success(new PageResult<>(dtoPage)); } @Override @@ -145,46 +154,21 @@ public class DraftReviewApplicationServiceImpl implements DraftReviewApplication } @Override - public Result confirm(Long informationId) { + public Result confirm(Long informationId, String name) { + validateInformation(informationId, name); return confirmKnowledgePointDraftDomainService.confirm(informationId); } @Override public Result batchSaveAndConfirm(Long informationId, List draftList, String name) { - if (informationId == null) { - throw new BusinessErrorException("资料ID不能为空"); - } if (draftList == null || draftList.isEmpty()) { throw new BusinessErrorException("草稿数据不能为空"); } - // 1. 校验资料状态 - InformationEntity information = informationBaseService.getById(informationId); - if (information == null) { - throw new BusinessErrorException("资料不存在"); - } - if (DraftStatusEnum.APPROVED.getValue().equals(information.getDraftStatus())) { - return Result.success("该资料已审核通过,无需重复操作"); - } - if (!DraftStatusEnum.PENDING.getValue().equals(information.getDraftStatus())) { - throw new BusinessErrorException("该资料不在待审核状态"); - } - - // 2. 如果传了名称且与原名不同,查重并更新 - if (StrUtil.isNotBlank(name) && !StrUtil.equals(name, information.getName())) { - boolean exists = informationBaseService.lambdaQuery() - .eq(InformationEntity::getSubLineId, information.getSubLineId()) - .eq(InformationEntity::getName, name) - .ne(InformationEntity::getId, informationId) - .exists(); - if (exists) { - throw new BusinessErrorException("该子产品线下已存在同名资料「" + name + "」,请修改文件名"); - } - information.setName(name); - informationBaseService.updateById(information); - } + // 1. 校验资料状态并更新名称 + validateInformation(informationId, name); - // 3. 获取该资料下所有待审核草稿ID(仅查ID,减少数据传输) + // 2. 获取该资料下所有待审核草稿ID(仅查ID,减少数据传输) List existingIds = knowledgePointDraftBaseService.lambdaQuery() .select(KnowledgePointDraftEntity::getId) .eq(KnowledgePointDraftEntity::getInformationId, informationId) @@ -194,7 +178,7 @@ public class DraftReviewApplicationServiceImpl implements DraftReviewApplication .map(KnowledgePointDraftEntity::getId) .toList(); - // 3. 用户传来的草稿ID集合(用Set,O(1)查找) + // 2. 用户传来的草稿ID集合(用Set,O(1)查找) Set incomingIdSet = draftList.stream() .map(DraftSaveDTO::getId) .filter(Objects::nonNull) @@ -268,6 +252,39 @@ public class DraftReviewApplicationServiceImpl implements DraftReviewApplication } /** + * 校验资料存在性及状态,并更新名称(如有变更) + */ + private void validateInformation(Long informationId, String name) { + if (informationId == null) { + throw new BusinessErrorException("资料ID不能为空"); + } + InformationEntity information = informationBaseService.getById(informationId); + if (information == null) { + throw new BusinessErrorException("资料不存在"); + } + if (DraftStatusEnum.APPROVED.getValue().equals(information.getDraftStatus())) { + throw new BusinessErrorException("该资料已审核通过,不可重复操作"); + } + if (!DraftStatusEnum.PENDING.getValue().equals(information.getDraftStatus())) { + throw new BusinessErrorException("该资料不在待审核状态"); + } + // 如果传了名称且与原名不同,查重并更新 + if (StrUtil.isNotBlank(name) && !StrUtil.equals(name, information.getName())) { + boolean exists = informationBaseService.lambdaQuery() + .eq(InformationEntity::getSubLineId, information.getSubLineId()) + .eq(InformationEntity::getName, name) + .ne(InformationEntity::getId, informationId) + .exists(); + if (exists) { + throw new BusinessErrorException("该子产品线下已存在同名资料「" + name + "」,请修改文件名"); + } + information.setName(name); + informationBaseService.updateById(information); + } + } + + /** + * 触发语义聚类 * 触发语义聚类 * 调用算法服务进行真实聚类,回调结果由 saveClusterByInformationId 处理 */ diff --git a/src/main/java/com/project/information/controller/InformationController.java b/src/main/java/com/project/information/controller/InformationController.java index 100d932..416355a 100644 --- a/src/main/java/com/project/information/controller/InformationController.java +++ b/src/main/java/com/project/information/controller/InformationController.java @@ -90,11 +90,11 @@ public class InformationController { // =============== V1.1 新增:草稿审核路由 ============ /** - * 查询草稿列表 + * 分页查询草稿列表 */ @GetMapping("/draftList") - public Result> draftList(Long informationId) { - return draftReviewApplicationService.listDrafts(informationId); + public Result> draftList(InformationParam param) { + return draftReviewApplicationService.listDrafts(param); } /** @@ -125,8 +125,8 @@ public class InformationController { * 确认提交(固化,不可逆) */ @PostMapping("/draft/confirm") - public Result confirmDraft(Long informationId) { - return draftReviewApplicationService.confirm(informationId); + public Result confirmDraft(Long informationId, String name) { + return draftReviewApplicationService.confirm(informationId, name); } /** diff --git a/src/main/java/com/project/information/domain/param/InformationParam.java b/src/main/java/com/project/information/domain/param/InformationParam.java index d286324..5fc58c2 100644 --- a/src/main/java/com/project/information/domain/param/InformationParam.java +++ b/src/main/java/com/project/information/domain/param/InformationParam.java @@ -6,4 +6,5 @@ import lombok.Data; @Data public class InformationParam extends BaseParam { private Long subLineId; + private Long informationId; } diff --git a/src/main/java/com/project/interaction/domain/service/impl/PostToAiExtractDomainServiceImpl.java b/src/main/java/com/project/interaction/domain/service/impl/PostToAiExtractDomainServiceImpl.java index b51e908..0ef0c02 100644 --- a/src/main/java/com/project/interaction/domain/service/impl/PostToAiExtractDomainServiceImpl.java +++ b/src/main/java/com/project/interaction/domain/service/impl/PostToAiExtractDomainServiceImpl.java @@ -21,8 +21,8 @@ public class PostToAiExtractDomainServiceImpl implements PostToAiExtractDomainSe @Resource(name = "algorithmWebClient") private WebClient algorithmWebClient; - @Value("${algo.apiUrl:http://172.16.204.50:8000}") - private String apiUrl; + @Value("${algo.apiThreeUrl:http://172.16.204.50:8012}") + private String apiThreeUrl; /** 算法服务知识点提取路径 */ @Value("${algo.extractUrl:/v1/key_points/extract}") private String extractUrl; @@ -32,7 +32,7 @@ public class PostToAiExtractDomainServiceImpl implements PostToAiExtractDomainSe try { log.info(">>> [Interactor] 正在向算法端发送知识点提取请求, informationId: {}", request.getInformationId()); algorithmWebClient.post() - .uri(apiUrl+extractUrl) + .uri(apiThreeUrl+extractUrl) .bodyValue(request) .retrieve() .bodyToMono(String.class) diff --git a/src/main/java/com/project/interaction/domain/service/impl/PostToAiScoringDomainServiceImpl.java b/src/main/java/com/project/interaction/domain/service/impl/PostToAiScoringDomainServiceImpl.java index a4a6a84..c024746 100644 --- a/src/main/java/com/project/interaction/domain/service/impl/PostToAiScoringDomainServiceImpl.java +++ b/src/main/java/com/project/interaction/domain/service/impl/PostToAiScoringDomainServiceImpl.java @@ -24,8 +24,11 @@ public class PostToAiScoringDomainServiceImpl implements PostToAiScoringDomainSe @Resource(name = "algorithmWebClient") private WebClient algorithmWebClient; + @Value("${algo.apiThreeUrl:http://172.16.204.50:8012}") + private String apiThreeUrl; + /** 算法服务阅卷路径 */ - @Value("${algo.scoringUrl:http://172.16.204.50:8010/v1/score/short_answer}") + @Value("${algo.scoringUrl:/v1/score/short_answer}") private String scoringUrl; private final ObjectMapper objectMapper = new ObjectMapper(); @@ -36,7 +39,7 @@ public class PostToAiScoringDomainServiceImpl implements PostToAiScoringDomainSe log.info(">>> [AI阅卷] 正在请求AI阅卷, question={}", request.getQuestion()); String responseBody = algorithmWebClient.post() - .uri(scoringUrl) + .uri(apiThreeUrl+scoringUrl) .bodyValue(request) .retrieve() .bodyToMono(String.class) diff --git a/src/main/java/com/project/interaction/domain/service/impl/PostToGenerateQuestionDomainServiceImpl.java b/src/main/java/com/project/interaction/domain/service/impl/PostToGenerateQuestionDomainServiceImpl.java index edb0696..b3e2213 100644 --- a/src/main/java/com/project/interaction/domain/service/impl/PostToGenerateQuestionDomainServiceImpl.java +++ b/src/main/java/com/project/interaction/domain/service/impl/PostToGenerateQuestionDomainServiceImpl.java @@ -41,7 +41,7 @@ public class PostToGenerateQuestionDomainServiceImpl implements PostToGenerateQu @Value("${algo.generateQuestionUrl:/v1/generate/questions_from_cluster}") private String generateQuestionUrl; - @Value("${algo.apiUrl:http://172.16.25.174:8000}") + @Value("${algo.apiUrl:http://172.16.25.174:8010}") private String apiUrl; /** 题目生成回调地址 */ diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 732db32..cab0fbc 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -82,11 +82,13 @@ ding: algo: clusterUrl: /semantic-cluster baseUrl: http://172.16.204.50:8003 - generateQuestionUrl: /v1/generate/questions_from_cluster - apiUrl: http://172.16.204.50:8000 + apiUrl: http://172.16.204.50:8010 + apiTwoUrl: http://172.16.204.50:8011 + apiThreeUrl: http://172.16.204.50:8012 extractUrl: /v1/key_points/extract + scoringUrl: /v1/score/short_answer + generateQuestionUrl: /v1/generate/questions_from_cluster callbackUrl: http://172.16.204.50/evaluator-api - scoringUrl: http://172.16.204.50:8000/v1/score/short_answer jwt: secret: "my-very-fixed-and-secure-secret-key-1234567890" diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index e1ec3dd..074e956 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -80,11 +80,13 @@ ding: algo: clusterUrl: /semantic-cluster baseUrl: http://127.0.0.1:8002 - generateQuestionUrl: /v1/generate/questions_from_cluster - apiUrl: http://127.0.0.1:8000 + apiUrl: http://127.0.0.1:8010 + apiTwoUrl: http://127.0.0.1:8011 + apiThreeUrl: http:/127.0.0.1:8012 extractUrl: /v1/key_points/extract - callbackUrl: http://8.129.84.155/evaluator-api - scoringUrl: http://127.0.0.1:8010/v1/score/short_answer + scoringUrl: /v1/score/short_answer + generateQuestionUrl: /v1/generate/questions_from_cluster + callbackUrl: http://127.0.0.1/evaluator-api jwt: secret: "my-very-fixed-and-secure-secret-key-1234567890" diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index e123d2d..80dc6e5 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -77,11 +77,13 @@ ding: algo: clusterUrl: /semantic-cluster baseUrl: http://127.0.0.1:8003 - generateQuestionUrl: /v1/generate/questions_from_cluster - apiUrl: http://127.0.0.1:8000/ + apiUrl: http://127.0.0.1:8010/ + apiTwoUrl: http://127.0.0.1:8011 + apiThreeUrl: http:/127.0.0.1:8012 extractUrl: /v1/key_points/extract + scoringUrl: /v1/score/short_answer + generateQuestionUrl: /v1/generate/questions_from_cluster callbackUrl: http://127.0.0.1/evaluator-api - scoringUrl: http://127.0.0.1:8010/v1/score/short_answer jwt: secret: "my-very-fixed-and-secure-secret-key-1234567890"