图谱查询规则判断加入数量过滤

topo_dev
DESKTOP-DDTUS3E\yaxin 6 months ago
parent 5498fd9ad2
commit 70775cca50

@ -22,6 +22,7 @@ import com.supervision.police.dto.caseScore.CaseScoreDetailDTO;
import com.supervision.police.dto.indexRule.IndexRule; import com.supervision.police.dto.indexRule.IndexRule;
import com.supervision.police.dto.indexRule.Operand; import com.supervision.police.dto.indexRule.Operand;
import com.supervision.police.dto.indexRule.OperandUnit; import com.supervision.police.dto.indexRule.OperandUnit;
import com.supervision.police.dto.indexRule.RuleCondition;
import com.supervision.police.mapper.*; import com.supervision.police.mapper.*;
import com.supervision.police.mybatis.RowSqlMapper; import com.supervision.police.mybatis.RowSqlMapper;
import com.supervision.police.service.*; import com.supervision.police.service.*;
@ -234,7 +235,7 @@ public class ModelServiceImpl implements ModelService {
operandUnitResultSet.add(relationSymbol == dbIndexAnalysis(caseId, modelAtomicIndex.getQueryLang(), result)); operandUnitResultSet.add(relationSymbol == dbIndexAnalysis(caseId, modelAtomicIndex.getQueryLang(), result));
break; break;
case OPERAND_TYPE_GRAPH: case OPERAND_TYPE_GRAPH:
operandUnitResultSet.add(relationSymbol == graphIndexAnalysis(casePerson.getName(), modelAtomicIndex, analyseCaseDTO, result)); operandUnitResultSet.add(relationSymbol == graphIndexAnalysis(casePerson.getName(), modelAtomicIndex.getQueryLang(), analyseCaseDTO.getCaseId(), ruleCondition, result));
break; break;
case OPERAND_TYPE_STRUCTURE: case OPERAND_TYPE_STRUCTURE:
ruleCondition.getOperandUnitList().forEach(operandUnit -> operandUnitResultSet.add(structureIndexAnalysis(operandUnit, ruleCondition.getAtomicIndexId(), atomicIndices, notePrompts, evidenceDirectories, caseEvidences, result))); ruleCondition.getOperandUnitList().forEach(operandUnit -> operandUnitResultSet.add(structureIndexAnalysis(operandUnit, ruleCondition.getAtomicIndexId(), atomicIndices, notePrompts, evidenceDirectories, caseEvidences, result)));
@ -328,11 +329,13 @@ public class ModelServiceImpl implements ModelService {
* *
* *
* @param casePersonName * @param casePersonName
* @param modelAtomicIndex * @param queryLang
* @param analyseCaseDTO * @param caseId ID
* @param ruleCondition
* @param atomicResult
* @return * @return
*/ */
private boolean graphIndexAnalysis(String casePersonName, ModelAtomicIndex modelAtomicIndex, AnalyseCaseDTO analyseCaseDTO, ModelAtomicResult atomicResult) { private boolean graphIndexAnalysis(String casePersonName, String queryLang, String caseId, RuleCondition ruleCondition, ModelAtomicResult atomicResult) {
boolean flag = false; boolean flag = false;
Session session = driver.session(); Session session = driver.session();
//图谱 //图谱
@ -340,21 +343,22 @@ public class ModelServiceImpl implements ModelService {
// 行为人 // 行为人
params.put("lawActor", casePersonName); params.put("lawActor", casePersonName);
// 案号 // 案号
params.put("caseId", analyseCaseDTO.getCaseId()); params.put("caseId", caseId);
Result run; Result run;
try { try {
run = session.run(modelAtomicIndex.getQueryLang(), params); run = session.run(queryLang, params);
} catch (Exception e) { } catch (Exception e) {
log.error("图数据库查询出现错误,查询语句{},参数{}", modelAtomicIndex.getQueryLang(), JSONUtil.toJsonStr(params), e); log.error("图数据库查询出现错误,查询语句{},参数{}", queryLang, JSONUtil.toJsonStr(params), e);
return flag; return flag;
} }
List<ResultDTO> res = Neo4jUtils.getResultDTOList(run); List<ResultDTO> res = Neo4jUtils.getResultDTOList(run);
int count = 0;
if (!res.isEmpty()) { if (!res.isEmpty()) {
// 进行遍历,如果有存在的,就设置为有 // 进行遍历,如果有存在的,就设置为有
for (ResultDTO resultDTO : res) { for (ResultDTO resultDTO : res) {
if (StringUtils.isNotEmpty(resultDTO.getRelId())) { if (StringUtils.isNotEmpty(resultDTO.getRelId())) {
//存在关系 //存在关系
flag = true; count++;
atomicResult.setAtomicResult(JudgeResultEnum.EXIST.getCode()); atomicResult.setAtomicResult(JudgeResultEnum.EXIST.getCode());
atomicResult.setRecordId(resultDTO.getRecordId()); atomicResult.setRecordId(resultDTO.getRecordId());
// 在退出循环之前先合并相关文本分片id // 在退出循环之前先合并相关文本分片id
@ -366,6 +370,9 @@ public class ModelServiceImpl implements ModelService {
} }
} }
} }
if (CalculationUtil.evaluateExpression(String.valueOf(count), ruleCondition.getOperator(), ruleCondition.getValue())) {
flag = true;
}
modelAtomicResultService.saveOrUpdate(atomicResult); modelAtomicResultService.saveOrUpdate(atomicResult);
return flag; return flag;
} }

Loading…
Cancel
Save