|
@@ -91,12 +91,12 @@ public class RelationInstanceService extends BaseService {
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
+ QGraphInstance qt = QGraphInstance.graphInstance;
|
|
|
// 优先级: graphId > graphCode
|
|
|
if (param.getGraphId() != null) {
|
|
|
GraphInstance gi = graphInstanceRepository.getOne(entity.getGraphId());
|
|
|
entity.setGraphCode(gi.getGraphCode());
|
|
|
} else if (param.getGraphCode() != null) {
|
|
|
- QGraphInstance qt = QGraphInstance.graphInstance;
|
|
|
Sort orders = Sort.by(new Sort.Order(Sort.Direction.ASC, "id"));
|
|
|
Iterable<GraphInstance> all = graphInstanceRepository.findAll(qt.groupCode.eq(groupCode).and(qt.projectId.eq(projectId).and(qt.graphCode.eq(entity.getGraphCode()))), orders);
|
|
|
GraphInstance next = all.iterator().next();
|
|
@@ -106,7 +106,25 @@ public class RelationInstanceService extends BaseService {
|
|
|
if (entity.getCreateApp() == null) {
|
|
|
entity.setCreateApp(DmpParameterStorage.getAppId());
|
|
|
}
|
|
|
- list.add(entity);
|
|
|
+ // 判断是否已存在
|
|
|
+ QRelationInstance rt = QRelationInstance.relationInstance;
|
|
|
+ BooleanExpression exp = rt.groupCode.eq(entity.getGroupCode())
|
|
|
+ .and(rt.projectId.eq(entity.getProjectId()))
|
|
|
+ .and(rt.graphId.eq(entity.getGraphId()))
|
|
|
+ .and(rt.relCode.eq(entity.getRelCode()))
|
|
|
+ .and(rt.objFrom.eq(entity.getObjFrom()))
|
|
|
+ .and(rt.objTo.eq(entity.getObjTo()));
|
|
|
+ if (entity.getRelValue() != null) {
|
|
|
+ exp = exp.and(rt.relValue.eq(entity.getRelValue()));
|
|
|
+ } else {
|
|
|
+ exp = exp.and(rt.relValue.isNull());
|
|
|
+ }
|
|
|
+
|
|
|
+ long count = relationInstanceRepository.count(exp);
|
|
|
+ if (count == 0) {
|
|
|
+ // 数据不存在, 新增, 已存在时忽略
|
|
|
+ list.add(entity);
|
|
|
+ }
|
|
|
}
|
|
|
if (list.size() > 0) {
|
|
|
relationInstanceRepository.saveAll(list);
|
|
@@ -121,6 +139,7 @@ public class RelationInstanceService extends BaseService {
|
|
|
message.add("graphId", relation.getGraphId());
|
|
|
message.add("graphCode", relation.getGraphCode());
|
|
|
message.add("relCode", relation.getRelCode());
|
|
|
+ message.add("relValue", relation.getRelValue());
|
|
|
message.add("objFrom", relation.getObjFrom());
|
|
|
message.add("objTo", relation.getObjTo());
|
|
|
response.add(message);
|
|
@@ -210,5 +229,6 @@ public class RelationInstanceService extends BaseService {
|
|
|
response.setCount(query.getCount());
|
|
|
return response;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|