|
@@ -4,7 +4,10 @@ import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.crypto.digest.MD5;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
import com.pavis.backend.slim.common.constant.Hodgepodge;
|
|
|
import com.pavis.backend.slim.common.utils.SecurityUtils;
|
|
|
import com.pavis.backend.slim.project.system.client.HttpClientUtil;
|
|
@@ -19,6 +22,7 @@ import com.pavis.backend.slim.project.system.domain.SysKgEntity;
|
|
|
import com.pavis.backend.slim.project.system.domain.SysKgRelation;
|
|
|
import com.pavis.backend.slim.project.system.domain.SysRelation;
|
|
|
import com.pavis.backend.slim.project.system.domain.algorithm.AlgSpO;
|
|
|
+import com.pavis.backend.slim.project.system.domain.front.FileKey;
|
|
|
import com.pavis.backend.slim.project.system.domain.front.InKgParameter;
|
|
|
import com.pavis.backend.slim.project.system.domain.front.KgReturn;
|
|
|
import com.pavis.backend.slim.project.system.domain.front.instance.KgInstance;
|
|
@@ -175,58 +179,69 @@ public class SysKgServiceImpl extends ServiceImpl<SysKgMapper, SysKg> implements
|
|
|
log.info("算法传参map:{}", JSON.toJSONString(algSpO));
|
|
|
// todo 先这么做,以后还需改动
|
|
|
Integer integer = 0;
|
|
|
+ String oCopy = "";
|
|
|
+ String sCopy = "";
|
|
|
if (integer == 0) {
|
|
|
for (Map map : algSpO.getSpo()) {
|
|
|
- // check库里是否存在此值
|
|
|
- String s = md5Check(MD5.create().digestHex16((String) map.get("s")));
|
|
|
- // 临时变量,将起点id赋值给sCopy,最后用于实例关系插入时使用
|
|
|
- String sCopy = "";
|
|
|
- if (s.equals("false")) {
|
|
|
- // 插入起始点实例
|
|
|
- SysEntityInstance sysEntityInstanceS = new SysEntityInstance();
|
|
|
- // 创建实例
|
|
|
- sysEntityInstanceS.setUserId(Hodgepodge.ALGORITHM);
|
|
|
- sysEntityInstanceS.setCreateBy(String.valueOf(Hodgepodge.ALGORITHM));
|
|
|
- sysEntityInstanceS.setCreateTime(DateUtil.date());
|
|
|
- sysEntityInstanceS.setInstanceId(MD5.create().digestHex16((String) map.get("s")));
|
|
|
- sysEntityInstanceS.setName((String) map.get("s"));
|
|
|
- sysEntityInstanceMapper.insert(sysEntityInstanceS);
|
|
|
- sCopy = MD5.create().digestHex16((String) map.get("s"));
|
|
|
- } else {
|
|
|
- sCopy = s;
|
|
|
+ if (map.get("s") != null) {
|
|
|
+ // check库里是否存在此值
|
|
|
+ String s = md5Check(MD5.create().digestHex16((String) map.get("s")));
|
|
|
+ // 临时变量,将起点id赋值给sCopy,最后用于实例关系插入时使用
|
|
|
+ if (s.equals("false")) {
|
|
|
+ // 插入起始点实例
|
|
|
+ SysEntityInstance sysEntityInstanceS = new SysEntityInstance();
|
|
|
+ // 创建实例
|
|
|
+ sysEntityInstanceS.setUserId(Hodgepodge.ALGORITHM);
|
|
|
+ sysEntityInstanceS.setCreateBy(String.valueOf(Hodgepodge.ALGORITHM));
|
|
|
+ sysEntityInstanceS.setKgId(algSpO.getKgId());
|
|
|
+ sysEntityInstanceS.setCreateTime(DateUtil.date());
|
|
|
+ sysEntityInstanceS.setInstanceId(MD5.create().digestHex16((String) map.get("s")));
|
|
|
+ sysEntityInstanceS.setName((String) map.get("s"));
|
|
|
+ sysEntityInstanceS.setEntityName((String) map.get("sType"));
|
|
|
+ sysEntityInstanceMapper.insert(sysEntityInstanceS);
|
|
|
+ sCopy = MD5.create().digestHex16((String) map.get("s"));
|
|
|
+ } else {
|
|
|
+ sCopy = s;
|
|
|
+ }
|
|
|
}
|
|
|
- String o = md5Check(MD5.create().digestHex16((String) map.get("o")));
|
|
|
- String oCopy = "";
|
|
|
- if (o.equals("false")) {
|
|
|
- // 插入终点实例
|
|
|
- SysEntityInstance sysEntityInstanceO = new SysEntityInstance();
|
|
|
- // 创建实例
|
|
|
- sysEntityInstanceO.setUserId(Hodgepodge.ALGORITHM);
|
|
|
- sysEntityInstanceO.setCreateBy(String.valueOf(Hodgepodge.ALGORITHM));
|
|
|
- sysEntityInstanceO.setCreateTime(DateUtil.date());
|
|
|
- sysEntityInstanceO.setInstanceId(MD5.create().digestHex16((String) map.get("o")));
|
|
|
- sysEntityInstanceO.setName((String) map.get("o"));
|
|
|
- sysEntityInstanceMapper.insert(sysEntityInstanceO);
|
|
|
- oCopy = MD5.create().digestHex16((String) map.get("o"));
|
|
|
- } else {
|
|
|
- oCopy = o;
|
|
|
+ if (map.get("o") != null) {
|
|
|
+ String o = md5Check(MD5.create().digestHex16((String) map.get("o")));
|
|
|
+ if (o.equals("false")) {
|
|
|
+ // 插入终点实例
|
|
|
+ SysEntityInstance sysEntityInstanceO = new SysEntityInstance();
|
|
|
+ // 创建实例
|
|
|
+ sysEntityInstanceO.setUserId(Hodgepodge.ALGORITHM);
|
|
|
+ sysEntityInstanceO.setCreateBy(String.valueOf(Hodgepodge.ALGORITHM));
|
|
|
+ sysEntityInstanceO.setKgId(algSpO.getKgId());
|
|
|
+ sysEntityInstanceO.setCreateTime(DateUtil.date());
|
|
|
+ sysEntityInstanceO.setInstanceId(MD5.create().digestHex16((String) map.get("o")));
|
|
|
+ sysEntityInstanceO.setName((String) map.get("o"));
|
|
|
+ sysEntityInstanceO.setEntityName((String) map.get("oType"));
|
|
|
+ sysEntityInstanceMapper.insert(sysEntityInstanceO);
|
|
|
+ oCopy = MD5.create().digestHex16((String) map.get("o"));
|
|
|
+ } else {
|
|
|
+ oCopy = o;
|
|
|
+ }
|
|
|
}
|
|
|
- // 对算法那边出现的重复数据进行去去重判断,如果数据库里有数据,则不在插入;如果数据库里没有,则进行插入
|
|
|
- List<SysEntityRelation> list = sysEntityRelationMapper.selectList(new QueryWrapper<SysEntityRelation>()
|
|
|
- .eq("kg_id", algSpO.getKgId())
|
|
|
- .eq("start_id", sCopy)
|
|
|
- .eq("end_id", oCopy));
|
|
|
- if (list.size() == Hodgepodge.NUMBER) {
|
|
|
- // 插入实例关系
|
|
|
- SysEntityRelation sysEntityRelation = new SysEntityRelation();
|
|
|
- sysEntityRelation.setKgId(algSpO.getKgId());
|
|
|
- sysEntityRelation.setUserId(Hodgepodge.ALGORITHM);
|
|
|
- sysEntityRelation.setStart((String) map.get("s"));
|
|
|
- sysEntityRelation.setStartId(sCopy);
|
|
|
- sysEntityRelation.setRelation((String) map.get("p"));
|
|
|
- sysEntityRelation.setEnd((String) map.get("o"));
|
|
|
- sysEntityRelation.setEndId(oCopy);
|
|
|
- sysEntityRelationMapper.insert(sysEntityRelation);
|
|
|
+ if (map.get("p") != null) {
|
|
|
+ // 对算法那边出现的重复数据进行去去重判断,如果数据库里有数据,则不在插入;如果数据库里没有,则进行插入
|
|
|
+ List<SysEntityRelation> list = sysEntityRelationMapper.selectList(new QueryWrapper<SysEntityRelation>()
|
|
|
+ .eq("kg_id", algSpO.getKgId())
|
|
|
+ .eq("start_id", sCopy)
|
|
|
+ .eq("end_id", oCopy));
|
|
|
+ if (list.size() == Hodgepodge.NUMBER) {
|
|
|
+ // 插入实例关系
|
|
|
+ SysEntityRelation sysEntityRelation = new SysEntityRelation();
|
|
|
+ sysEntityRelation.setKgId(algSpO.getKgId());
|
|
|
+ sysEntityRelation.setUserId(Hodgepodge.ALGORITHM);
|
|
|
+ sysEntityRelation.setStart((String) map.get("s"));
|
|
|
+ sysEntityRelation.setStartId(sCopy);
|
|
|
+ sysEntityRelation.setRelation((String) map.get("p"));
|
|
|
+ sysEntityRelation.setEnd((String) map.get("o"));
|
|
|
+ sysEntityRelation.setEndId(oCopy);
|
|
|
+ sysEntityRelation.setEntityRelation(map.get("sType") + "-" + map.get("pType") + "-" + (String) map.get("oType"));
|
|
|
+ sysEntityRelationMapper.insert(sysEntityRelation);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -362,42 +377,263 @@ public class SysKgServiceImpl extends ServiceImpl<SysKgMapper, SysKg> implements
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public SysEntityAll createEntityKg(SysEntityAll sysEntityAll) {
|
|
|
- // zez 获取登录用户id
|
|
|
- long userId = SecurityUtils.getUserId();
|
|
|
- // zez 如果主键id -->EntityAllId 是null或是空 则新增,否则 根据主键进行更新
|
|
|
- if (sysEntityAll.getEntityAllId() != null && !"".equals(sysEntityAll.getEntityAllId())) {
|
|
|
- sysEntityAll.setUpdateBy(String.valueOf(userId));
|
|
|
- sysEntityAll.setUpdateTime(new Date());
|
|
|
- sysEntityAllMapper.updateById(sysEntityAll);
|
|
|
- } else {
|
|
|
- // zez 将数据插入数据库,这个表--> sys_entity
|
|
|
- sysEntityAll.setCreateBy(String.valueOf(userId));
|
|
|
- sysEntityAll.setCreateTime(new Date());
|
|
|
- sysEntityAllMapper.insert(sysEntityAll);
|
|
|
- List<Map> entityAlList = JSON.parseObject(sysEntityAll.getEntityAll(), List.class);
|
|
|
- for (Map mapEntity : entityAlList) {
|
|
|
+ public SysEntityAll createEntityKg(SysEntity sysEntityAll) {
|
|
|
+ log.info("*********接口(createEntityKg)------>入参(sysEntityAll):{}", JSON.toJSONString(sysEntityAll));
|
|
|
+
|
|
|
+ // zez 根据前端传参先进行删除需要删除的关系和实体
|
|
|
+ this.delEntityAndRelation(sysEntityAll);
|
|
|
+ // zez 根据传参获取实例实体所需的值
|
|
|
+ List<Map> entityAlList = JSON.parseObject(sysEntityAll.getEntityAll(), List.class);
|
|
|
+ // zez 对实体实例进行更新和保存
|
|
|
+ this.entityInsOrUpd(entityAlList, sysEntityAll);
|
|
|
+ // zez 根据传参获取关系所需的值
|
|
|
+ List<Map> relationAlList = JSON.parseObject(sysEntityAll.getRelationAll(), List.class);
|
|
|
+ // zez 对实体实例进行更新和保存
|
|
|
+ this.relationInsOrUpd(relationAlList, sysEntityAll);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * zez 实体实例关系删除
|
|
|
+ */
|
|
|
+ public void delEntityAndRelation(SysEntity sysEntityAll) {
|
|
|
+ // zez 根据前端传参先进行删除
|
|
|
+ if (sysEntityAll.getEntityList() != null && sysEntityAll.getEntityList().size() > 0) {
|
|
|
+ log.info("******-->删除实体");
|
|
|
+ for (String entityId : sysEntityAll.getEntityList()) {
|
|
|
+ sysEntityMapper.deleteById(entityId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (sysEntityAll.getRelationList() != null && sysEntityAll.getRelationList().size() > 0) {
|
|
|
+ log.info("******-->删除关系");
|
|
|
+ for (String relationId : sysEntityAll.getRelationList()) {
|
|
|
+ sysRelationMapper.deleteById(relationId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * zez 实体实例保存或更新
|
|
|
+ */
|
|
|
+ public void entityInsOrUpd(List<Map> entityAlList, SysEntity sysEntityAll) {
|
|
|
+ for (Map mapEntity : entityAlList) {
|
|
|
+ log.info("********entity----->:{}", mapEntity.get("entityId"));
|
|
|
+ // zez 根据entityId进行判断,如果是null和空,则新增;否则修改
|
|
|
+ if (mapEntity.get("entityId") != null && !"".equals(mapEntity.get("entityId").toString())) {
|
|
|
+ List<SysEntity> list = sysEntityMapper.selectList(new QueryWrapper<SysEntity>()
|
|
|
+ .eq("entity_id", mapEntity.get("entityId").toString()));
|
|
|
+ if (list.size() > 0) {
|
|
|
+ // zez 更新实体实例
|
|
|
+ this.upaEntity(mapEntity, sysEntityAll);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // zez 新增实体实例
|
|
|
SysEntity sysEntity = new SysEntity();
|
|
|
sysEntity.setKgId(sysEntityAll.getKgId());
|
|
|
sysEntity.setColor(mapEntity.get("color").toString());
|
|
|
sysEntity.setName(mapEntity.get("name").toString());
|
|
|
- sysEntity.setUserId(userId);
|
|
|
- sysEntity.setUpdateBy(String.valueOf(userId));
|
|
|
- sysEntity.setUpdateTime(new Date());
|
|
|
+ sysEntity.setEntityAll(sysEntityAll.getEntityAll());
|
|
|
+ sysEntity.setEntityKgAll(sysEntityAll.getEntityKgAll());
|
|
|
+ sysEntity.setRelationAll(sysEntityAll.getRelationAll());
|
|
|
+ sysEntity.setRelationKgAll(sysEntityAll.getRelationKgAll());
|
|
|
+ sysEntity.setUserId(SecurityUtils.getUserId());
|
|
|
+ sysEntity.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
|
|
|
+ sysEntity.setCreateTime(new Date());
|
|
|
sysEntityMapper.insert(sysEntity);
|
|
|
+ // zez 新增后对主键id进行存储,存储到这里-->mapEntity
|
|
|
+ mapEntity.put("entityId", sysEntity.getEntityId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // zez 对数据结构的变更,进行更新 sysEntity-->entityAlList-->entityAll-->sysEntityAll 根据kg_id
|
|
|
+ sysEntityAll.setEntityAll(entityAlList.toString());
|
|
|
+ sysEntityMapper.update(sysEntityAll, new QueryWrapper<SysEntity>().eq("kg_id", sysEntityAll.getKgId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * zez 实体实例关系保存或更新
|
|
|
+ */
|
|
|
+ public void relationInsOrUpd(List<Map> relationAlList, SysEntity sysEntityAll) {
|
|
|
+ // zez relationAlList 是 [] ,说明没有创建关系,否则便有关系
|
|
|
+ if (!"[]".equals(relationAlList)) {
|
|
|
+ for (Map mapRelation : relationAlList) {
|
|
|
+ if (mapRelation.get("relationId") == null) {
|
|
|
+ SysRelation sysRelation = new SysRelation();
|
|
|
+ sysRelation.setKgId(sysEntityAll.getKgId());
|
|
|
+ sysRelation.setUserId(SecurityUtils.getUserId());
|
|
|
+ sysRelation.setStart(mapRelation.get("startName").toString());
|
|
|
+ sysRelation.setStartId(mapRelation.get("start").toString());
|
|
|
+ sysRelation.setEnd(mapRelation.get("endName").toString());
|
|
|
+ sysRelation.setEndId(mapRelation.get("end").toString());
|
|
|
+ sysRelation.setRelation(mapRelation.get("relation").toString());
|
|
|
+ sysRelation.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
|
|
|
+ sysRelation.setCreateTime(new Date());
|
|
|
+ sysRelationMapper.insert(sysRelation);
|
|
|
+ // zez 对关系主键进行存储,放入这里 -->mapRelation
|
|
|
+ mapRelation.put("relationId", sysRelation.getRelationId());
|
|
|
+ } else {
|
|
|
+ SysRelation sysRelation = new SysRelation();
|
|
|
+ sysRelation.setRelationId(mapRelation.get("relationId").toString());
|
|
|
+ sysRelation.setStart(mapRelation.get("startName").toString());
|
|
|
+ sysRelation.setStartId(mapRelation.get("start").toString());
|
|
|
+ sysRelation.setEnd(mapRelation.get("endName").toString());
|
|
|
+ sysRelation.setEndId(mapRelation.get("end").toString());
|
|
|
+ sysRelation.setRelation(mapRelation.get("relation").toString());
|
|
|
+ sysRelation.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
|
|
|
+ sysRelation.setUpdateTime(new Date());
|
|
|
+ sysRelationMapper.updateById(sysRelation);
|
|
|
+ }
|
|
|
}
|
|
|
+ // zez 对关系主键存储后,进行单个字段的更新 -->relation_all
|
|
|
+ sysEntityAll.setRelationAll(relationAlList.toString());
|
|
|
+ UpdateWrapper<SysEntity> updateWrapper = new UpdateWrapper();
|
|
|
+ updateWrapper.eq("kg_id", sysEntityAll.getKgId());
|
|
|
+ updateWrapper.set("relation_all", sysEntityAll.getRelationAll());
|
|
|
+ sysEntityMapper.update(null, updateWrapper);
|
|
|
}
|
|
|
- return sysEntityAll;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * zez 用于更新实体实例
|
|
|
+ */
|
|
|
+ public void upaEntity(Map mapEntity, SysEntity sysEntityAll) {
|
|
|
+ SysEntity sysEntity = new SysEntity();
|
|
|
+ sysEntity.setEntityId(mapEntity.get("entityId").toString());
|
|
|
+ sysEntity.setKgId(sysEntityAll.getKgId());
|
|
|
+ sysEntity.setColor(mapEntity.get("color").toString());
|
|
|
+ sysEntity.setName(mapEntity.get("name").toString());
|
|
|
+ sysEntity.setEntityAll(sysEntityAll.getEntityAll());
|
|
|
+ sysEntity.setEntityKgAll(sysEntityAll.getEntityKgAll());
|
|
|
+ sysEntity.setRelationAll(sysEntityAll.getRelationAll());
|
|
|
+ sysEntity.setRelationKgAll(sysEntityAll.getRelationKgAll());
|
|
|
+ sysEntity.setUserId(SecurityUtils.getUserId());
|
|
|
+ sysEntity.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
|
|
|
+ sysEntity.setCreateTime(new Date());
|
|
|
+ sysEntityMapper.updateById(sysEntity);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<SysEntityAll> selEntityAll(String kgId) {
|
|
|
+ public SysEntityAll selEntityAll(String kgId) {
|
|
|
log.info("------------------------>kgId:{}", kgId);
|
|
|
+ SysEntityAll entityAll = new SysEntityAll();
|
|
|
// zez 根据kgId去查询数据
|
|
|
if (kgId != null && !"".equals(kgId)) {
|
|
|
- List<SysEntityAll> listEntity = sysEntityAllMapper.selectList(new QueryWrapper<SysEntityAll>()
|
|
|
+ List<SysEntity> listEntity = sysEntityMapper.selectList(new QueryWrapper<SysEntity>()
|
|
|
.eq("kg_id", kgId));
|
|
|
- return listEntity;
|
|
|
+ if (listEntity.size() > 0) {
|
|
|
+ SysEntity sysEntity = listEntity.get(0);
|
|
|
+ entityAll.setEntityAll(sysEntity.getEntityAll());
|
|
|
+ entityAll.setEntityKgAll(sysEntity.getEntityKgAll());
|
|
|
+ entityAll.setRelationAll(sysEntity.getRelationAll());
|
|
|
+ entityAll.setRelationKgAll(sysEntity.getRelationKgAll());
|
|
|
+ }
|
|
|
+ log.info("*********出参--->:{}", JSON.toJSONString(entityAll));
|
|
|
+ return entityAll;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public SysEntityInstance insEntNce(SysEntityInstance sysEntityInstance) {
|
|
|
+ log.info("****新增实例或更新接口(insEntNce)--->入参(sysEntityInstance):{}", sysEntityInstance);
|
|
|
+ // zez 获取登录人id
|
|
|
+ Long userId = SecurityUtils.getUserId();
|
|
|
+ // zez 根据名字进行实体实例去重 -->sys_entity_instance 如果存在则不再进行新增而是更新,如果不存在,则新增
|
|
|
+ List<SysEntityInstance> nameSize = sysEntityInstanceMapper.selectList(new QueryWrapper<SysEntityInstance>()
|
|
|
+ .eq("name", sysEntityInstance.getName()));
|
|
|
+ // zez 根据前端传参的instanceId判断,此条数据是更新还是新增,如果为null或者是空,则是新增,否则是更新
|
|
|
+ if (sysEntityInstance.getInstanceId() == null || "".equals(sysEntityInstance.getInstanceId())) {
|
|
|
+ // zez 数据库内没数据,则新增 反之更新
|
|
|
+ if (nameSize.size() == 0) {
|
|
|
+ String instanceId = MD5.create().digestHex16(sysEntityInstance.getName());
|
|
|
+ sysEntityInstance.setInstanceId(instanceId);
|
|
|
+ sysEntityInstance.setCreateBy(String.valueOf(userId));
|
|
|
+ sysEntityInstance.setUserId(userId);
|
|
|
+ sysEntityInstance.setCreateTime(new Date());
|
|
|
+ sysEntityInstanceMapper.insert(sysEntityInstance);
|
|
|
+ } else {
|
|
|
+ sysEntityInstance.setInstanceId(nameSize.get(0).getInstanceId());
|
|
|
+ sysEntityInstance.setCreateBy(String.valueOf(userId));
|
|
|
+ sysEntityInstance.setUserId(userId);
|
|
|
+ sysEntityInstance.setCreateTime(new Date());
|
|
|
+ sysEntityInstance.setUpdateBy(String.valueOf(userId));
|
|
|
+ sysEntityInstance.setUpdateTime(new Date());
|
|
|
+ sysEntityInstanceMapper.updateById(sysEntityInstance);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ sysEntityInstanceMapper.updateById(sysEntityInstance);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void delEntNce(List<String> entityNceList) {
|
|
|
+ for (String instanceId : entityNceList) {
|
|
|
+ sysEntityInstanceMapper.deleteById(instanceId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageInfo selEntityInstance(FileKey keyEntityNce) {
|
|
|
+ log.info("********接口(selEntityInstance)--->入参(keyEntityNce):{}", JSON.toJSONString(keyEntityNce));
|
|
|
+ QueryWrapper<SysEntityInstance> queryWrapper = new QueryWrapper();
|
|
|
+ queryWrapper.eq("kg_id", keyEntityNce.getKgId());
|
|
|
+ if (keyEntityNce.getKeyWord() != null && !"".equals(keyEntityNce.getKeyWord())) {
|
|
|
+ queryWrapper.like("name",keyEntityNce.getKeyWord());
|
|
|
+ }
|
|
|
+
|
|
|
+ // zez 如果EntityName(实体名字)有值,则跟它一起连查,如果没有,则不管
|
|
|
+ if (keyEntityNce.getEntityName() != null && !"".equals(keyEntityNce.getEntityName())) {
|
|
|
+ queryWrapper.eq("entity_name", keyEntityNce.getEntityName());
|
|
|
+ }
|
|
|
+ PageHelper.startPage(keyEntityNce.getPageNum(), keyEntityNce.getPageSize());
|
|
|
+ List<SysEntityInstance> entityNceList = sysEntityInstanceMapper.selectList(queryWrapper);
|
|
|
+ PageInfo page = new PageInfo(entityNceList);
|
|
|
+ log.info("********接口(selEntityInstance)--->出参(page):{}", JSON.toJSONString(page));
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageInfo selEntityRelation(FileKey keyEntityRelation) {
|
|
|
+ log.info("********接口(selEntityRelation)--->入参(keyEntityRelation):{}", JSON.toJSONString(keyEntityRelation));
|
|
|
+ QueryWrapper<SysEntityRelation> queryWrap = new QueryWrapper();
|
|
|
+
|
|
|
+ if (keyEntityRelation.getKeyWord() != null && !"".equals(keyEntityRelation.getKeyWord())) {
|
|
|
+ queryWrap
|
|
|
+ .like("start",keyEntityRelation.getKeyWord())
|
|
|
+ .or()
|
|
|
+ .like("relation",keyEntityRelation.getKeyWord())
|
|
|
+ .or()
|
|
|
+ .like("end",keyEntityRelation.getKeyWord())
|
|
|
+ ;
|
|
|
+ }
|
|
|
+ // zez 根据实体名字查询实例关系
|
|
|
+ if (Hodgepodge.ZERO_STR.equals(keyEntityRelation.getEntOrRel())) {
|
|
|
+ if (keyEntityRelation.getEntityName() != null && !"".equals(keyEntityRelation.getEntityName())) {
|
|
|
+ queryWrap
|
|
|
+ .like("entity_relation", keyEntityRelation.getEntityName())
|
|
|
+ .eq("kg_id", keyEntityRelation.getKgId());
|
|
|
+ PageHelper.startPage(keyEntityRelation.getPageNum(), keyEntityRelation.getPageSize());
|
|
|
+ List<SysEntityRelation> sysEntityRelations = sysEntityRelationMapper.selectList(queryWrap);
|
|
|
+ PageInfo page = new PageInfo(sysEntityRelations);
|
|
|
+ log.info("********接口(selEntityRelation)--->出参(page):{}", JSON.toJSONString(page));
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // zez 根据实体关系查询关系
|
|
|
+ if (Hodgepodge.ONE_STR.equals(keyEntityRelation.getEntOrRel())) {
|
|
|
+ if (keyEntityRelation.getEntityRelation() != null && !"".equals(keyEntityRelation.getEntityRelation())) {
|
|
|
+ queryWrap
|
|
|
+ .eq("entity_relation", "-" + keyEntityRelation.getEntityRelation() + "-")
|
|
|
+ .eq("kg_id", keyEntityRelation.getKgId());
|
|
|
+ PageHelper.startPage(keyEntityRelation.getPageNum(), keyEntityRelation.getPageSize());
|
|
|
+ List<SysEntityRelation> sysEntityRelations = sysEntityRelationMapper.selectList(queryWrap);
|
|
|
+ PageInfo page = new PageInfo(sysEntityRelations);
|
|
|
+ log.info("********接口(selEntityRelation)--->出参(page):{}", JSON.toJSONString(page));
|
|
|
+ return page;
|
|
|
+ }
|
|
|
}
|
|
|
return null;
|
|
|
}
|