Browse Source

bug修复

master
luogw 2 months ago
parent
commit
c14d960cd0
  1. 6
      src/main/java/com/project/classicpaper/domain/service/impl/AlgorithmClassicPaperQuestionGenerator.java
  2. 7
      src/main/java/com/project/information/application/DraftReviewApplicationService.java
  3. 107
      src/main/java/com/project/information/application/impl/DraftReviewApplicationServiceImpl.java
  4. 10
      src/main/java/com/project/information/controller/InformationController.java
  5. 1
      src/main/java/com/project/information/domain/param/InformationParam.java
  6. 6
      src/main/java/com/project/interaction/domain/service/impl/PostToAiExtractDomainServiceImpl.java
  7. 7
      src/main/java/com/project/interaction/domain/service/impl/PostToAiScoringDomainServiceImpl.java
  8. 2
      src/main/java/com/project/interaction/domain/service/impl/PostToGenerateQuestionDomainServiceImpl.java
  9. 8
      src/main/resources/application-dev.yml
  10. 10
      src/main/resources/application-prod.yml
  11. 8
      src/main/resources/application-test.yml

6
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}") @Value("${algo.classicPaperGenerateUrl:/v1/generate/questions_from_cluster}")
private String generateUrl; private String generateUrl;
@Value("${algo.apiUrl:http://172.16.25.174:8000}") @Value("${algo.apiTwoUrl:http://172.16.25.174:8011}")
private String apiUrl; private String apiTwoUrl;
@Value("${algo.callbackUrl:http://172.16.204.50/evaluator-api}") @Value("${algo.callbackUrl:http://172.16.204.50/evaluator-api}")
private String callbackUrl; private String callbackUrl;
@ -80,7 +80,7 @@ public class AlgorithmClassicPaperQuestionGenerator implements ClassicPaperQuest
try { try {
GenerateQuestionResponseDTO response = algorithmWebClient.post() GenerateQuestionResponseDTO response = algorithmWebClient.post()
.uri(apiUrl + generateUrl) .uri(apiTwoUrl + generateUrl)
.bodyValue(request) .bodyValue(request)
.retrieve() .retrieve()
.onStatus( .onStatus(

7
src/main/java/com/project/information/application/DraftReviewApplicationService.java

@ -1,9 +1,10 @@
package com.project.information.application; package com.project.information.application;
import com.project.base.domain.result.PageResult;
import com.project.base.domain.result.Result; import com.project.base.domain.result.Result;
import com.project.information.domain.dto.DraftSaveDTO; import com.project.information.domain.dto.DraftSaveDTO;
import com.project.information.domain.dto.KnowledgePointDraftDTO; 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; import java.util.List;
@ -12,7 +13,7 @@ import java.util.List;
*/ */
public interface DraftReviewApplicationService { public interface DraftReviewApplicationService {
Result<List<KnowledgePointDraftDTO>> listDrafts(Long informationId); Result<PageResult<KnowledgePointDraftDTO>> listDrafts(InformationParam param);
Result<String> updateDraft(Long draftId, String content); Result<String> updateDraft(Long draftId, String content);
@ -20,7 +21,7 @@ public interface DraftReviewApplicationService {
Result<String> addDraft(Long informationId, String content, Integer knowledgeType); Result<String> addDraft(Long informationId, String content, Integer knowledgeType);
Result<String> confirm(Long informationId); Result<String> confirm(Long informationId, String name);
/** /**
* 批量保存草稿并确认替代逐条编辑+单独确认 * 批量保存草稿并确认替代逐条编辑+单独确认

107
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 cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.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.domain.result.Result;
import com.project.base.config.CustomIdGenerator;
import com.project.information.application.DraftReviewApplicationService; import com.project.information.application.DraftReviewApplicationService;
import com.project.information.domain.dto.DraftSaveDTO; import com.project.information.domain.dto.DraftSaveDTO;
import com.project.information.domain.dto.KnowledgePointDTO; 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.entity.KnowledgePointEntity;
import com.project.information.domain.enums.AuditStatusEnum; import com.project.information.domain.enums.AuditStatusEnum;
import com.project.information.domain.enums.DraftStatusEnum; 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.ConfirmKnowledgePointDraftDomainService;
import com.project.information.domain.service.InformationBaseService; import com.project.information.domain.service.InformationBaseService;
import com.project.information.domain.service.KnowledgeClusterBaseService; import com.project.information.domain.service.KnowledgeClusterBaseService;
@ -66,27 +70,32 @@ public class DraftReviewApplicationServiceImpl implements DraftReviewApplication
@Override @Override
public Result<List<KnowledgePointDraftDTO>> listDrafts(Long informationId) { public Result<PageResult<KnowledgePointDraftDTO>> listDrafts(InformationParam param) {
if (informationId == null) { if (param.getInformationId() == null) {
throw new BusinessErrorException("资料ID不能为空"); throw new BusinessErrorException("资料ID不能为空");
} }
List<KnowledgePointDraftEntity> drafts = knowledgePointDraftBaseService.list(
Page<KnowledgePointDraftEntity> page = new Page<>(param.getCurrent(), param.getSize());
IPage<KnowledgePointDraftEntity> pageResult = knowledgePointDraftBaseService.page(page,
new LambdaQueryWrapper<KnowledgePointDraftEntity>() new LambdaQueryWrapper<KnowledgePointDraftEntity>()
.eq(KnowledgePointDraftEntity::getInformationId, informationId) .eq(KnowledgePointDraftEntity::getInformationId, param.getInformationId())
.orderByAsc(KnowledgePointDraftEntity::getId)); .orderByAsc(KnowledgePointDraftEntity::getId));
List<KnowledgePointDraftDTO> res = drafts.stream()
List<KnowledgePointDraftDTO> res = pageResult.getRecords().stream()
.map(entity -> entity.toDTO(KnowledgePointDraftDTO::new)) .map(entity -> entity.toDTO(KnowledgePointDraftDTO::new))
.toList(); .toList();
Long infoId = drafts.stream() // 填充资料名称
.findAny() InformationEntity information = informationBaseService.getById(param.getInformationId());
.map(KnowledgePointDraftEntity::getInformationId) if (information != null) {
.orElse(null); // 或者 .orElse(0L) 给个默认值 String name = information.getName();
if (Objects.nonNull(infoId)) { res.forEach(dto -> dto.setInformationName(name));
InformationEntity one = informationBaseService.getById(infoId);
res.forEach(dto -> dto.setInformationName(one.getName()));
} }
return Result.success(res);
// 构造 DTO 分页结果
Page<KnowledgePointDraftDTO> dtoPage = new Page<>(pageResult.getCurrent(), pageResult.getSize(), pageResult.getTotal());
dtoPage.setRecords(res);
return Result.success(new PageResult<>(dtoPage));
} }
@Override @Override
@ -145,46 +154,21 @@ public class DraftReviewApplicationServiceImpl implements DraftReviewApplication
} }
@Override @Override
public Result<String> confirm(Long informationId) { public Result<String> confirm(Long informationId, String name) {
validateInformation(informationId, name);
return confirmKnowledgePointDraftDomainService.confirm(informationId); return confirmKnowledgePointDraftDomainService.confirm(informationId);
} }
@Override @Override
public Result<String> batchSaveAndConfirm(Long informationId, List<DraftSaveDTO> draftList, String name) { public Result<String> batchSaveAndConfirm(Long informationId, List<DraftSaveDTO> draftList, String name) {
if (informationId == null) {
throw new BusinessErrorException("资料ID不能为空");
}
if (draftList == null || draftList.isEmpty()) { if (draftList == null || draftList.isEmpty()) {
throw new BusinessErrorException("草稿数据不能为空"); throw new BusinessErrorException("草稿数据不能为空");
} }
// 1. 校验资料状态 // 1. 校验资料状态并更新名称
InformationEntity information = informationBaseService.getById(informationId); validateInformation(informationId, name);
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);
}
// 3. 获取该资料下所有待审核草稿ID(仅查ID,减少数据传输) // 2. 获取该资料下所有待审核草稿ID(仅查ID,减少数据传输)
List<Long> existingIds = knowledgePointDraftBaseService.lambdaQuery() List<Long> existingIds = knowledgePointDraftBaseService.lambdaQuery()
.select(KnowledgePointDraftEntity::getId) .select(KnowledgePointDraftEntity::getId)
.eq(KnowledgePointDraftEntity::getInformationId, informationId) .eq(KnowledgePointDraftEntity::getInformationId, informationId)
@ -194,7 +178,7 @@ public class DraftReviewApplicationServiceImpl implements DraftReviewApplication
.map(KnowledgePointDraftEntity::getId) .map(KnowledgePointDraftEntity::getId)
.toList(); .toList();
// 3. 用户传来的草稿ID集合(用Set,O(1)查找) // 2. 用户传来的草稿ID集合(用Set,O(1)查找)
Set<Long> incomingIdSet = draftList.stream() Set<Long> incomingIdSet = draftList.stream()
.map(DraftSaveDTO::getId) .map(DraftSaveDTO::getId)
.filter(Objects::nonNull) .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 处理 * 调用算法服务进行真实聚类回调结果由 saveClusterByInformationId 处理
*/ */

10
src/main/java/com/project/information/controller/InformationController.java

@ -90,11 +90,11 @@ public class InformationController {
// =============== V1.1 新增:草稿审核路由 ============ // =============== V1.1 新增:草稿审核路由 ============
/** /**
* 查询草稿列表 * 分页查询草稿列表
*/ */
@GetMapping("/draftList") @GetMapping("/draftList")
public Result<List<KnowledgePointDraftDTO>> draftList(Long informationId) { public Result<PageResult<KnowledgePointDraftDTO>> draftList(InformationParam param) {
return draftReviewApplicationService.listDrafts(informationId); return draftReviewApplicationService.listDrafts(param);
} }
/** /**
@ -125,8 +125,8 @@ public class InformationController {
* 确认提交固化不可逆 * 确认提交固化不可逆
*/ */
@PostMapping("/draft/confirm") @PostMapping("/draft/confirm")
public Result<String> confirmDraft(Long informationId) { public Result<String> confirmDraft(Long informationId, String name) {
return draftReviewApplicationService.confirm(informationId); return draftReviewApplicationService.confirm(informationId, name);
} }
/** /**

1
src/main/java/com/project/information/domain/param/InformationParam.java

@ -6,4 +6,5 @@ import lombok.Data;
@Data @Data
public class InformationParam extends BaseParam { public class InformationParam extends BaseParam {
private Long subLineId; private Long subLineId;
private Long informationId;
} }

6
src/main/java/com/project/interaction/domain/service/impl/PostToAiExtractDomainServiceImpl.java

@ -21,8 +21,8 @@ public class PostToAiExtractDomainServiceImpl implements PostToAiExtractDomainSe
@Resource(name = "algorithmWebClient") @Resource(name = "algorithmWebClient")
private WebClient algorithmWebClient; private WebClient algorithmWebClient;
@Value("${algo.apiUrl:http://172.16.204.50:8000}") @Value("${algo.apiThreeUrl:http://172.16.204.50:8012}")
private String apiUrl; private String apiThreeUrl;
/** 算法服务知识点提取路径 */ /** 算法服务知识点提取路径 */
@Value("${algo.extractUrl:/v1/key_points/extract}") @Value("${algo.extractUrl:/v1/key_points/extract}")
private String extractUrl; private String extractUrl;
@ -32,7 +32,7 @@ public class PostToAiExtractDomainServiceImpl implements PostToAiExtractDomainSe
try { try {
log.info(">>> [Interactor] 正在向算法端发送知识点提取请求, informationId: {}", request.getInformationId()); log.info(">>> [Interactor] 正在向算法端发送知识点提取请求, informationId: {}", request.getInformationId());
algorithmWebClient.post() algorithmWebClient.post()
.uri(apiUrl+extractUrl) .uri(apiThreeUrl+extractUrl)
.bodyValue(request) .bodyValue(request)
.retrieve() .retrieve()
.bodyToMono(String.class) .bodyToMono(String.class)

7
src/main/java/com/project/interaction/domain/service/impl/PostToAiScoringDomainServiceImpl.java

@ -24,8 +24,11 @@ public class PostToAiScoringDomainServiceImpl implements PostToAiScoringDomainSe
@Resource(name = "algorithmWebClient") @Resource(name = "algorithmWebClient")
private WebClient 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 String scoringUrl;
private final ObjectMapper objectMapper = new ObjectMapper(); private final ObjectMapper objectMapper = new ObjectMapper();
@ -36,7 +39,7 @@ public class PostToAiScoringDomainServiceImpl implements PostToAiScoringDomainSe
log.info(">>> [AI阅卷] 正在请求AI阅卷, question={}", request.getQuestion()); log.info(">>> [AI阅卷] 正在请求AI阅卷, question={}", request.getQuestion());
String responseBody = algorithmWebClient.post() String responseBody = algorithmWebClient.post()
.uri(scoringUrl) .uri(apiThreeUrl+scoringUrl)
.bodyValue(request) .bodyValue(request)
.retrieve() .retrieve()
.bodyToMono(String.class) .bodyToMono(String.class)

2
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}") @Value("${algo.generateQuestionUrl:/v1/generate/questions_from_cluster}")
private String generateQuestionUrl; private String generateQuestionUrl;
@Value("${algo.apiUrl:http://172.16.25.174:8000}") @Value("${algo.apiUrl:http://172.16.25.174:8010}")
private String apiUrl; private String apiUrl;
/** 题目生成回调地址 */ /** 题目生成回调地址 */

8
src/main/resources/application-dev.yml

@ -82,11 +82,13 @@ ding:
algo: algo:
clusterUrl: /semantic-cluster clusterUrl: /semantic-cluster
baseUrl: http://172.16.204.50:8003 baseUrl: http://172.16.204.50:8003
generateQuestionUrl: /v1/generate/questions_from_cluster apiUrl: http://172.16.204.50:8010
apiUrl: http://172.16.204.50:8000 apiTwoUrl: http://172.16.204.50:8011
apiThreeUrl: http://172.16.204.50:8012
extractUrl: /v1/key_points/extract extractUrl: /v1/key_points/extract
scoringUrl: /v1/score/short_answer
generateQuestionUrl: /v1/generate/questions_from_cluster
callbackUrl: http://172.16.204.50/evaluator-api callbackUrl: http://172.16.204.50/evaluator-api
scoringUrl: http://172.16.204.50:8000/v1/score/short_answer
jwt: jwt:
secret: "my-very-fixed-and-secure-secret-key-1234567890" secret: "my-very-fixed-and-secure-secret-key-1234567890"

10
src/main/resources/application-prod.yml

@ -80,11 +80,13 @@ ding:
algo: algo:
clusterUrl: /semantic-cluster clusterUrl: /semantic-cluster
baseUrl: http://127.0.0.1:8002 baseUrl: http://127.0.0.1:8002
generateQuestionUrl: /v1/generate/questions_from_cluster apiUrl: http://127.0.0.1:8010
apiUrl: http://127.0.0.1:8000 apiTwoUrl: http://127.0.0.1:8011
apiThreeUrl: http:/127.0.0.1:8012
extractUrl: /v1/key_points/extract extractUrl: /v1/key_points/extract
callbackUrl: http://8.129.84.155/evaluator-api scoringUrl: /v1/score/short_answer
scoringUrl: http://127.0.0.1:8010/v1/score/short_answer generateQuestionUrl: /v1/generate/questions_from_cluster
callbackUrl: http://127.0.0.1/evaluator-api
jwt: jwt:
secret: "my-very-fixed-and-secure-secret-key-1234567890" secret: "my-very-fixed-and-secure-secret-key-1234567890"

8
src/main/resources/application-test.yml

@ -77,11 +77,13 @@ ding:
algo: algo:
clusterUrl: /semantic-cluster clusterUrl: /semantic-cluster
baseUrl: http://127.0.0.1:8003 baseUrl: http://127.0.0.1:8003
generateQuestionUrl: /v1/generate/questions_from_cluster apiUrl: http://127.0.0.1:8010/
apiUrl: http://127.0.0.1:8000/ apiTwoUrl: http://127.0.0.1:8011
apiThreeUrl: http:/127.0.0.1:8012
extractUrl: /v1/key_points/extract extractUrl: /v1/key_points/extract
scoringUrl: /v1/score/short_answer
generateQuestionUrl: /v1/generate/questions_from_cluster
callbackUrl: http://127.0.0.1/evaluator-api callbackUrl: http://127.0.0.1/evaluator-api
scoringUrl: http://127.0.0.1:8010/v1/score/short_answer
jwt: jwt:
secret: "my-very-fixed-and-secure-secret-key-1234567890" secret: "my-very-fixed-and-secure-secret-key-1234567890"

Loading…
Cancel
Save