|
@@ -2,10 +2,10 @@ package com.persagy.dmp.rwd.digital.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.persagy.dmp.basic.dto.RelationCalDTO;
|
|
|
import com.persagy.dmp.common.constant.ValidEnum;
|
|
|
import com.persagy.dmp.digital.entity.ObjectRelation;
|
|
|
import com.persagy.dmp.rwd.basic.utils.DigitalCommonUtils;
|
|
@@ -67,12 +67,50 @@ public class ObjectRelationServiceImpl extends ServiceImpl<ObjectRelationMapper,
|
|
|
public List<ObjectRelation> insert(List<ObjectRelation> voList) {
|
|
|
//创建默认的图实例id
|
|
|
createGraphId(voList);
|
|
|
+ //数据重复性校验,若存在重复数据,填充关系ID
|
|
|
+ checkRepeatData(voList,false);
|
|
|
//新增关系数据
|
|
|
iService.saveOrUpdateBatch(voList);
|
|
|
return voList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 数据重复性校验,存在重复数据时,自动填充关系ID,作更新操作
|
|
|
+ * @param voList
|
|
|
+ */
|
|
|
+ private Boolean checkRepeatData(List<ObjectRelation> voList,Boolean isUpdate){
|
|
|
+ if(CollUtil.isEmpty(voList)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ Boolean flag = true;
|
|
|
+ for (ObjectRelation relation : voList) {
|
|
|
+ //条件查询关系数据
|
|
|
+ LambdaQueryWrapper<ObjectRelation> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(ObjectRelation::getGroupCode,relation.getGroupCode());
|
|
|
+ wrapper.eq(ObjectRelation::getProjectId,relation.getProjectId());
|
|
|
+ wrapper.eq(ObjectRelation::getGraphCode, relation.getGraphCode());
|
|
|
+ wrapper.eq(ObjectRelation::getRelCode,relation.getRelCode());
|
|
|
+ wrapper.eq(ObjectRelation::getObjFrom,relation.getObjFrom());
|
|
|
+ wrapper.eq(ObjectRelation::getObjTo,relation.getObjTo());
|
|
|
+ wrapper.eq(ObjectRelation::getValid,true);
|
|
|
+ List<ObjectRelation> relationList = queryByCondition(wrapper);
|
|
|
+
|
|
|
+ if(CollUtil.isNotEmpty(relationList)){
|
|
|
+ //判断新增关系时数据是否已存在,存在时自动填充ID
|
|
|
+ if(!isUpdate){
|
|
|
+ relation.setId(relationList.get(0).getId());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //判断更新时关系数据是否重复
|
|
|
+ String existId = relationList.get(0).getId();
|
|
|
+ if(isUpdate && !relation.getId().equals(existId)){
|
|
|
+ flag = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+ /**
|
|
|
* 创建默认的图实例id
|
|
|
* @param voList
|
|
|
*/
|
|
@@ -87,14 +125,18 @@ public class ObjectRelationServiceImpl extends ServiceImpl<ObjectRelationMapper,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 修改关系数据
|
|
|
* @param voList 修改条件
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<ObjectRelation> update(List<ObjectRelation> voList) {
|
|
|
+ public List<ObjectRelation> update(List<ObjectRelation> voList) throws Exception{
|
|
|
+ //数据重复性校验
|
|
|
+ Boolean flag = checkRepeatData(voList, true);
|
|
|
+ if(!flag){
|
|
|
+ throw new Exception("存在重复的关系数据");
|
|
|
+ }
|
|
|
iService.saveOrUpdateBatch(voList);
|
|
|
return voList;
|
|
|
}
|