取证单保存不再做去重
This commit is contained in:
@@ -20,6 +20,8 @@ import org.springframework.stereotype.Service;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class AuditEvidenceServiceImpl extends ServiceImpl<AuditEvidenceMapper, AuditEvidence> implements AuditEvidenceService {
|
public class AuditEvidenceServiceImpl extends ServiceImpl<AuditEvidenceMapper, AuditEvidence> implements AuditEvidenceService {
|
||||||
@@ -335,14 +337,15 @@ public class AuditEvidenceServiceImpl extends ServiceImpl<AuditEvidenceMapper, A
|
|||||||
return new ApiResult<>(1, "项目编号不能为空");
|
return new ApiResult<>(1, "项目编号不能为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
LambdaQueryWrapper<AuditEvidence> queryWrapper = new LambdaQueryWrapper<>();
|
AuditEvidence auditEvidence;
|
||||||
|
|
||||||
|
/*LambdaQueryWrapper<AuditEvidence> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(AuditEvidence::getProjectId, request.getProjectId())
|
queryWrapper.eq(AuditEvidence::getProjectId, request.getProjectId())
|
||||||
.eq(AuditEvidence::getAuditMatterType, request.getAuditMatterType())
|
.eq(AuditEvidence::getAuditMatterType, request.getAuditMatterType())
|
||||||
.eq(AuditEvidence::getDeleted, 0);
|
.eq(AuditEvidence::getDeleted, 0);
|
||||||
|
|
||||||
AuditEvidence existingEvidence = baseMapper.selectOne(queryWrapper);
|
AuditEvidence existingEvidence = baseMapper.selectOne(queryWrapper);
|
||||||
|
|
||||||
AuditEvidence auditEvidence;
|
|
||||||
if (existingEvidence != null) {
|
if (existingEvidence != null) {
|
||||||
// 3. 更新现有记录
|
// 3. 更新现有记录
|
||||||
log.info("发现已存在的记录,执行更新操作 - ID: {}", existingEvidence.getId());
|
log.info("发现已存在的记录,执行更新操作 - ID: {}", existingEvidence.getId());
|
||||||
@@ -389,7 +392,8 @@ public class AuditEvidenceServiceImpl extends ServiceImpl<AuditEvidenceMapper, A
|
|||||||
baseMapper.updateById(auditEvidence);
|
baseMapper.updateById(auditEvidence);
|
||||||
|
|
||||||
log.info("审计取证单更新成功 - ID: {}", auditEvidence.getId());
|
log.info("审计取证单更新成功 - ID: {}", auditEvidence.getId());
|
||||||
} else {
|
}
|
||||||
|
else {*/
|
||||||
// 4. 新增记录
|
// 4. 新增记录
|
||||||
log.info("未发现已存在的记录,执行新增操作");
|
log.info("未发现已存在的记录,执行新增操作");
|
||||||
auditEvidence = new AuditEvidence();
|
auditEvidence = new AuditEvidence();
|
||||||
@@ -442,12 +446,13 @@ public class AuditEvidenceServiceImpl extends ServiceImpl<AuditEvidenceMapper, A
|
|||||||
// 状态信息
|
// 状态信息
|
||||||
auditEvidence.setStatus(0); // 正常状态
|
auditEvidence.setStatus(0); // 正常状态
|
||||||
auditEvidence.setDeleted(0); // 未删除
|
auditEvidence.setDeleted(0); // 未删除
|
||||||
|
auditEvidence.setCreateTime(LocalDateTime.now());
|
||||||
|
|
||||||
// 保存到数据库
|
// 保存到数据库
|
||||||
baseMapper.insert(auditEvidence);
|
baseMapper.insert(auditEvidence);
|
||||||
|
|
||||||
log.info("审计取证单保存成功 - ID: {}", auditEvidence.getId());
|
log.info("审计取证单保存成功 - ID: {}", auditEvidence.getId());
|
||||||
}
|
// }
|
||||||
|
|
||||||
return new ApiResult<>(Constants.RESULT_OK_CODE, Constants.RESULT_OK_MSG, auditEvidence);
|
return new ApiResult<>(Constants.RESULT_OK_CODE, Constants.RESULT_OK_MSG, auditEvidence);
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.aliyun.bailian20231229.models.DeleteIndexResponse;
|
|||||||
import com.aliyun.bailian20231229.models.ListIndexDocumentsResponse;
|
import com.aliyun.bailian20231229.models.ListIndexDocumentsResponse;
|
||||||
import com.aliyun.bailian20231229.models.ListIndicesResponse;
|
import com.aliyun.bailian20231229.models.ListIndicesResponse;
|
||||||
import com.aliyun.bailian20231229.models.RetrieveResponse;
|
import com.aliyun.bailian20231229.models.RetrieveResponse;
|
||||||
|
import com.aliyun.bailian20231229.models.RetrieveResponseBody;
|
||||||
import com.aliyun.bailian20231229.models.RetrieveResponseBody.RetrieveResponseBodyDataNodes;
|
import com.aliyun.bailian20231229.models.RetrieveResponseBody.RetrieveResponseBodyDataNodes;
|
||||||
import com.gxwebsoft.ai.config.KnowledgeBaseConfig;
|
import com.gxwebsoft.ai.config.KnowledgeBaseConfig;
|
||||||
import com.gxwebsoft.ai.constants.KnowledgeBaseConstants;
|
import com.gxwebsoft.ai.constants.KnowledgeBaseConstants;
|
||||||
@@ -17,6 +18,7 @@ import com.gxwebsoft.ai.service.KnowledgeBaseService;
|
|||||||
import com.gxwebsoft.ai.util.AiCloudDataCenterUtil;
|
import com.gxwebsoft.ai.util.AiCloudDataCenterUtil;
|
||||||
import com.gxwebsoft.ai.util.AiCloudKnowledgeBaseUtil;
|
import com.gxwebsoft.ai.util.AiCloudKnowledgeBaseUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -32,6 +34,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class KnowledgeBaseServiceImpl implements KnowledgeBaseService {
|
public class KnowledgeBaseServiceImpl implements KnowledgeBaseService {
|
||||||
|
|
||||||
@@ -58,12 +61,42 @@ public class KnowledgeBaseServiceImpl implements KnowledgeBaseService {
|
|||||||
try {
|
try {
|
||||||
Client client = clientFactory.createClient();
|
Client client = clientFactory.createClient();
|
||||||
RetrieveResponse resp = AiCloudKnowledgeBaseUtil.retrieveIndex(client, workspaceId, indexId, searchQuery);
|
RetrieveResponse resp = AiCloudKnowledgeBaseUtil.retrieveIndex(client, workspaceId, indexId, searchQuery);
|
||||||
for (RetrieveResponseBodyDataNodes node : resp.getBody().getData().getNodes()) {
|
|
||||||
result.add(node.getText());
|
// 检查响应是否为空
|
||||||
if (result.size() >= searchTopK) {
|
RetrieveResponseBody respBody = resp.getBody();
|
||||||
break;
|
if (respBody == null) {
|
||||||
|
throw new RuntimeException("知识库查询响应为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
if("Index.BailianIndexServiceOutOfCredit".equals(respBody.getCode())){
|
||||||
|
throw new RuntimeException("知识库查询失败: 账户余额不足");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查数据是否为空
|
||||||
|
RetrieveResponseBody.RetrieveResponseBodyData data = respBody.getData();
|
||||||
|
if (data == null) {
|
||||||
|
// 记录警告但不抛异常,返回空结果集
|
||||||
|
log.warn("警告: 知识库查询返回的数据为空,可能未找到相关文档");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查节点列表是否为空
|
||||||
|
List<RetrieveResponseBodyDataNodes> nodes = data.getNodes();
|
||||||
|
if (nodes == null || nodes.isEmpty()) {
|
||||||
|
log.warn("警告: 知识库查询未找到匹配的节点");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (RetrieveResponseBodyDataNodes node : nodes) {
|
||||||
|
if (node != null && StrUtil.isNotEmpty(node.getText())) {
|
||||||
|
result.add(node.getText());
|
||||||
|
if (result.size() >= searchTopK) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("查询知识库失败: " + e.getMessage(), e);
|
throw new RuntimeException("查询知识库失败: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user