topo_dev
liu
parent c00a2c2da0
commit c99dcf02dd

@ -21,10 +21,14 @@ public class R<T> implements Serializable {
public static final String TOTAL_COUNT = "total";
public static final String RESULT_LIST = "result";
/** 成功 */
/**
*
*/
public static final int SUCCESS = Constants.SUCCESS;
/** 失败 */
/**
*
*/
public static final int FAIL = Constants.FAIL;
private int code;
@ -37,6 +41,14 @@ public class R<T> implements Serializable {
return restResult(null, SUCCESS, null);
}
public static <T> R<T> judgeResult(Boolean bo, String successMessage, String failMessage) {
if (bo) {
return restResult(null, SUCCESS, successMessage);
} else {
return restResult(null, FAIL, failMessage);
}
}
public static <T> R<T> okMsg(String msg) {
return restResult(null, SUCCESS, msg);
}
@ -73,7 +85,9 @@ public class R<T> implements Serializable {
return restResult(resultStatusEnum);
}
public static <T> R<T> fail(ResultStatusEnum resultStatusEnum, T data) {return restResult(resultStatusEnum,data);}
public static <T> R<T> fail(ResultStatusEnum resultStatusEnum, T data) {
return restResult(resultStatusEnum, data);
}
private static <T> R<T> restResult(ResultStatusEnum resultStatusEnum, T data) {
R<T> apiResult = new R<>();
@ -100,7 +114,6 @@ public class R<T> implements Serializable {
}
public static Map<String, Object> buildDataMap(List list) {
Map<String, Object> dataMap = new HashMap<>();
if (list == null) {

@ -65,7 +65,8 @@ public class Neo4jController {
@PostMapping("/saveRelation")
public R<?> saveRelation(@RequestBody Rel rel) {
return neo4jService.saveRelation(rel);
Boolean result = neo4jService.saveRelation(rel);
return R.judgeResult(result, null, "保存失败");
}
/*************************************************************************************/

@ -23,7 +23,7 @@ public interface Neo4jService {
Rel findRelation(Rel rel);
R<?> saveRelation(Rel rel);
Boolean saveRelation(Rel rel);
R<?> getNode(String picType, String caseId);

@ -198,7 +198,7 @@ public class Neo4jServiceImpl implements Neo4jService {
}
@Override
public R<?> saveRelation(Rel rel) {
public Boolean saveRelation(Rel rel) {
Rel res = null;
try {
Session session = driver.session();
@ -214,11 +214,7 @@ public class Neo4jServiceImpl implements Neo4jService {
} catch (Exception e) {
e.printStackTrace();
}
if (rel != null) {
return R.ok(rel);
} else {
return R.fail("保存失败");
}
return rel != null;
}
@Override

@ -1,5 +1,6 @@
package com.supervision.police.service.impl;
import cn.hutool.core.util.StrUtil;
import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -121,7 +122,7 @@ public class ModelRecordTypeServiceImpl extends ServiceImpl<ModelRecordTypeMappe
}
}
private List<TripleInfo> extractThreeInfo(String caseId, String name, String recordId) {
private List<TripleInfo> extractTripleInfo(String caseId, String name, String recordId) {
List<NoteRecord> records = noteRecordMapper.selectRecord(caseId, name, recordId);
List<TripleInfo> tripleInfos = new ArrayList<>();
for (NoteRecord record : records) {
@ -150,9 +151,8 @@ public class ModelRecordTypeServiceImpl extends ServiceImpl<ModelRecordTypeMappe
String endNodeType = object.getString("endNodeType");
String property = object.getString("property");
String value = object.getString("value");
//去空
if (StringUtils.isEmpty(startNodeType) || StringUtils.isEmpty(entity) || StringUtils.isEmpty(endNodeType)
|| StringUtils.isEmpty(property) || StringUtils.isEmpty(value)) {
// 去空,如果存在任何的空值,则忽略
if (StrUtil.hasEmpty(startNodeType, entity, endNodeType, property, value)) {
continue;
}
TripleInfo tripleInfo = new TripleInfo(entity, property, value, record.getId(), new Date(), startNodeType, endNodeType);
@ -170,7 +170,7 @@ public class ModelRecordTypeServiceImpl extends ServiceImpl<ModelRecordTypeMappe
@Override
public List<TripleInfo> getThreeInfo(String caseId, String name, String recordId) {
// TODO 这里应该改成异步的形式,通过异步的形式来进行提取三元组信息,不能每次点击就跑一遍
return extractThreeInfo(caseId, name, recordId);
return extractTripleInfo(caseId, name, recordId);
}
@Override
@ -181,6 +181,7 @@ public class ModelRecordTypeServiceImpl extends ServiceImpl<ModelRecordTypeMappe
try {
//开始节点
String start = tripleInfo.getStartNode();
// 首先看是否已经存在了,如果已经存在了,就不添加了
CaseNode startNode = neo4jService.findOneByName(tripleInfo.getCaseId(), tripleInfo.getNoteRecordsId(), tripleInfo.getStartNodeType(), start, "1");
if (startNode == null) {
startNode = new CaseNode(start, tripleInfo.getStartNodeType(), tripleInfo.getNoteRecordId(), tripleInfo.getNoteRecordsId(), tripleInfo.getCaseId(), "1");
@ -199,13 +200,14 @@ public class ModelRecordTypeServiceImpl extends ServiceImpl<ModelRecordTypeMappe
Rel rel = new Rel(startNode.getId(), tripleInfo.getRelation(), endNode.getId());
Rel relation = neo4jService.findRelation(rel);
if (relation == null) {
R<?> r = neo4jService.saveRelation(rel);
neo4jService.saveRelation(rel);
}
tripleInfo.setAddNeo4j("1");
int j = tripleInfoMapper.updateById(tripleInfo);
if (j > 0) {
i++;
}
// TODO 重复添加的OK了,删除的呢?
} catch (Exception e) {
log.error(e.getMessage(), e);
}

Loading…
Cancel
Save