瀏覽代碼

1.消息消费时增加幂等性校验,确保不会重复添加
2.关系ID不保真,修改采用唯一索引查询历史关系数据

linhuili 3 年之前
父節點
當前提交
f683b7046c

+ 0 - 133
dmp-business/dmp-rwd-plus/src/main/java/com/persagy/dmp/rwd/handler/DigitalMessageHandler.java

@@ -1,133 +0,0 @@
-package com.persagy.dmp.rwd.handler;
-
-import cn.hutool.core.util.StrUtil;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.persagy.dmp.amqp.handler.AbstractRabbitHandlerTemplate;
-import com.persagy.dmp.basic.constant.DigitalMessageConstant;
-import com.persagy.dmp.basic.model.DigitalManageMessage;
-import com.persagy.dmp.digital.entity.ObjectDigital;
-import com.persagy.dmp.digital.entity.ObjectRelation;
-import com.persagy.dmp.rwd.qrcode.service.impl.QrCodeServiceImpl;
-import com.persagy.dmp.rwd.version.service.IObjectDigitalHistoryService;
-import com.persagy.dmp.rwd.version.service.IObjectRelationHistoryService;
-import com.rabbitmq.client.Channel;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * 物理世界对象消息处理
- * @author:linhuili
- * @date:2021/11/23
- */
-@Slf4j
-@Component
-@RabbitListener(queues = DigitalMessageConstant.MESSAGE_QUEUE)
-public class DigitalMessageHandler extends AbstractRabbitHandlerTemplate {
-
-    @Autowired
-    private ObjectMapper objectMapper;
-
-    @Autowired
-    private QrCodeServiceImpl qrCodeService;
-
-    @Autowired
-    private IObjectDigitalHistoryService objectDigitalHisService;
-
-    @Autowired
-    private IObjectRelationHistoryService objectRelationHisService;
-
-    /**
-     * 物理世界对象:消息监听处理
-     * @param message 消息体字符串
-     * @param channel 通道对象
-     * @param vo     消息对象
-     */
-    @Override
-    protected void handler(String message, Channel channel, Message vo) {
-        try {
-            log.info("接收对象消息:{}", message);
-            //接收对象消息
-            DigitalManageMessage messageVO = objectMapper.readValue(message, DigitalManageMessage.class);
-            ObjectNode objectDigital = messageVO.getNewObj();
-            if(objectDigital == null || StrUtil.isEmpty(messageVO.getOperatorType()) || StrUtil.isEmpty(messageVO.getOperatorObj())){
-                log.info("对象消息格式有误:{}"+ messageVO);
-                return;
-            }
-            if(ObjectDigital.class.getSimpleName().equals(messageVO.getOperatorObj())){
-               //处理物理世界对象数据
-                handleDigitalObjectMessage(messageVO,objectDigital);
-            }
-            if(ObjectRelation.class.getSimpleName().equals(messageVO.getOperatorObj())){
-                //处理物理世界关系数据
-                handlerDigitalRelationMessage(messageVO,objectDigital);
-            }
-        }catch (Exception e){
-          log.info("物理世界对象消息处理失败:{} "+e.getMessage());
-        }
-    }
-
-    /**
-     * 处理物理世界对象消息
-     * @param messageVO
-     * @param objectDigital
-     * @throws Exception
-     */
-    private void handleDigitalObjectMessage(DigitalManageMessage messageVO, ObjectNode objectDigital) throws Exception{
-        ObjectDigital objectDigitalVO = objectMapper.readValue(objectDigital.toString(), ObjectDigital.class);
-        //获取基本参数
-        String groupCode = objectDigital.get("groupCode").textValue();
-        String projectId = objectDigital.get("projectId").textValue();
-        if(DigitalMessageConstant.OPERATE_AFTER_INSERT.equals(messageVO.getOperatorType())){
-            //创建二维码信息
-            log.info("消息处理:创建对象二维码{}"+objectDigital);
-            qrCodeService.createObjectQrCode(groupCode,projectId,objectDigital);
-            //新增对象历史记录
-            log.info("消息处理:新增对象历史记录{}"+objectDigital);
-            objectDigitalHisService.insert(objectDigitalVO);
-        }
-        if(DigitalMessageConstant.OPERATE_AFTER_UPDATE.equals(messageVO.getOperatorType())){
-            //修改对象历史记录
-            log.info("消息处理:修改对象历史记录{}"+objectDigital);
-            objectDigitalHisService.update(objectDigitalVO);
-        }
-        if(DigitalMessageConstant.OPERATE_AFTER_DELETE.equals(messageVO.getOperatorType())){
-            //删除对象二维码
-            log.info("消息处理:删除对象二维码{}"+objectDigital);
-            qrCodeService.removeObjectQrCode(groupCode,projectId,objectDigital);
-            //删除对象历史记录
-            log.info("消息处理:删除对象历史记录{}"+objectDigital);
-            objectDigitalHisService.delete(objectDigitalVO);
-        }
-    }
-
-    /**
-     * 处理物理世界关系数据
-     * @param messageVO
-     * @param objectRelation
-     * @throws Exception
-     */
-    private void handlerDigitalRelationMessage(DigitalManageMessage messageVO, ObjectNode objectRelation) throws Exception{
-        ObjectRelation objectRelationVO = objectMapper.readValue(objectRelation.toString(), ObjectRelation.class);
-        if(DigitalMessageConstant.OPERATE_AFTER_INSERT.equals(messageVO.getOperatorType())){
-            //新增对象关系-历史记录
-            log.info("消息处理:新增对象关系历史记录{}"+objectRelation);
-            objectRelationHisService.insert(objectRelationVO);
-        }
-        if(DigitalMessageConstant.OPERATE_AFTER_INSERT.equals(messageVO.getOperatorType())){
-            //修改对象关系-历史记录
-            log.info("消息处理:修改对象关系历史记录{}"+objectRelation);
-            objectRelationHisService.update(objectRelationVO);
-        }
-        if(DigitalMessageConstant.OPERATE_AFTER_INSERT.equals(messageVO.getOperatorType())){
-            //删除对象关系-历史记录
-            log.info("消息处理:删除对象关系历史记录{}"+objectRelation);
-            objectRelationHisService.delete(objectRelationVO);
-        }
-    }
-
-
-}

+ 151 - 0
dmp-business/dmp-rwd-plus/src/main/java/com/persagy/dmp/rwd/handler/DigitalObjectMessageHandler.java

@@ -0,0 +1,151 @@
+package com.persagy.dmp.rwd.handler;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.persagy.dmp.amqp.handler.AbstractRabbitHandlerTemplate;
+import com.persagy.dmp.basic.constant.DigitalMessageConstant;
+import com.persagy.dmp.basic.model.DigitalManageMessage;
+import com.persagy.dmp.basic.utils.JsonNodeUtils;
+import com.persagy.dmp.common.constant.CommonConstant;
+import com.persagy.dmp.common.context.AppContext;
+import com.persagy.dmp.digital.entity.ObjectDigital;
+import com.persagy.dmp.mybatis.helper.DynamicDataSourceHelper;
+import com.persagy.dmp.rwd.qrcode.service.impl.QrCodeServiceImpl;
+import com.persagy.dmp.rwd.version.service.IObjectDigitalHistoryService;
+import com.rabbitmq.client.Channel;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.core.Message;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * 物理世界对象消息处理
+ * @author:linhuili
+ * @date:2021/11/23
+ */
+@Slf4j
+@Component
+@RabbitListener(queues = DigitalMessageConstant.MESSAGE_DIGITAL_OBJECT_QUEUE)
+public class DigitalObjectMessageHandler extends AbstractRabbitHandlerTemplate {
+
+    @Autowired
+    private ObjectMapper objectMapper;
+
+    @Autowired
+    private QrCodeServiceImpl qrCodeService;
+
+    @Autowired
+    private IObjectDigitalHistoryService objectDigitalHisService;
+
+    /**
+     * 物理世界对象:消息监听处理
+     * @param message 消息体字符串
+     * @param channel 通道对象
+     * @param vo     消息对象
+     */
+    @Override
+    protected void handler(String message, Channel channel, Message vo) {
+        try {
+            //接收对象消息
+            DigitalManageMessage messageVO = objectMapper.readValue(message, DigitalManageMessage.class);
+            ObjectNode newObj = messageVO.getNewObj();
+            ObjectNode oldObj = messageVO.getOldObj();
+            if(newObj == null || StrUtil.isEmpty(messageVO.getOperatorType()) || StrUtil.isEmpty(messageVO.getOperatorObj())){
+                log.info("对象消息格式有误:{}"+ messageVO);
+                return;
+            }
+            if(!ObjectDigital.class.getSimpleName().equals(messageVO.getOperatorObj())){
+                return;
+            }
+            log.info("处理对象消息:{}", newObj);
+            //处理物理世界对象数据
+            handleDigitalObjectMessage(messageVO,newObj,oldObj);
+        }catch (Exception e){
+          log.info("物理世界对象消息处理失败:{} "+e.getMessage());
+        }
+    }
+
+    /**
+     * 处理物理世界对象消息
+     * @param messageVO
+     * @param newObj
+     * @param oldObj
+     * @throws Exception
+     */
+    private void handleDigitalObjectMessage(DigitalManageMessage messageVO, ObjectNode newObj,ObjectNode oldObj) throws Exception{
+        ObjectDigital objectDigitalVO = JsonNodeUtils.toEntity(newObj, ObjectDigital.class, ObjectDigital.EXTRA_COLUMN);
+        //获取基本参数
+        String groupCode = newObj.get("groupCode").textValue();
+        String projectId = newObj.get("projectId").textValue();
+        //初始化数据源
+        initContextInfo(groupCode,projectId,null,null);
+        //处理物理世界对象消息
+        if(DigitalMessageConstant.OPERATE_AFTER_INSERT.equals(messageVO.getOperatorType())){
+            //创建二维码信息
+            List<ObjectDigital> objectDigitalList = qrCodeService.createObjectQrCode(groupCode, projectId, newObj);
+            if(CollUtil.isNotEmpty(objectDigitalList)){
+                //记录对象新增操作
+                objectDigitalHisService.insert(objectDigitalList.get(0));
+            }
+        }
+        if(DigitalMessageConstant.OPERATE_AFTER_UPDATE.equals(messageVO.getOperatorType())){
+            //校验对象是否进行修改
+            Boolean isUpdate = checkIsUpdate(newObj, oldObj);
+            if(!isUpdate){
+              //对象无任何修改信息
+                return;
+            }
+            //记录对象修改操作
+            objectDigitalHisService.update(objectDigitalVO);
+        }
+        if(DigitalMessageConstant.OPERATE_AFTER_DELETE.equals(messageVO.getOperatorType())){
+            //删除对象二维码
+            qrCodeService.removeQrCodePic(groupCode,projectId,newObj);
+            //记录对象删除操作
+            objectDigitalHisService.update(objectDigitalVO);
+        }
+    }
+
+    /**
+     * 校验对象是否进行内容修改
+     * @param newObj
+     * @param oldObj
+     * @return
+     */
+    private Boolean checkIsUpdate(ObjectNode newObj,ObjectNode oldObj){
+        if(newObj == null || oldObj == null){
+            return true;
+        }
+        newObj.remove("modifiedTime");
+        oldObj.remove("modifiedTime");
+        if(newObj.equals(oldObj)){
+            return false;
+        }
+        return true;
+    }
+    
+    /**
+     * 初始化上下文,切换数据源
+     * @param groupCode
+     * @param projectId
+     * @param appId
+     * @param userId
+     */
+    private void initContextInfo(String groupCode,String projectId,String appId,String userId) {
+        AppContext.getContext().setGroupCode(groupCode);
+        AppContext.getContext().setProjectId(projectId);
+        AppContext.getContext().setAppId(appId);
+        // 无用户时,默认为默认系统用户
+        if(StrUtil.isBlank(userId)) {
+            userId = CommonConstant.DEFAULT_ID;
+        }
+        AppContext.getContext().setAccountId(userId);
+        DynamicDataSourceHelper.loadDataSource();
+    }
+
+}

+ 109 - 0
dmp-business/dmp-rwd-plus/src/main/java/com/persagy/dmp/rwd/handler/DigitalRelationMessageHandler.java

@@ -0,0 +1,109 @@
+package com.persagy.dmp.rwd.handler;
+import cn.hutool.core.util.StrUtil;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.persagy.dmp.amqp.handler.AbstractRabbitHandlerTemplate;
+import com.persagy.dmp.basic.constant.DigitalMessageConstant;
+import com.persagy.dmp.basic.model.DigitalManageMessage;
+import com.persagy.dmp.common.constant.CommonConstant;
+import com.persagy.dmp.common.context.AppContext;
+import com.persagy.dmp.digital.entity.ObjectRelation;
+import com.persagy.dmp.mybatis.helper.DynamicDataSourceHelper;
+import com.persagy.dmp.rwd.version.service.IObjectRelationHistoryService;
+import com.rabbitmq.client.Channel;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.core.Message;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * 物理世界关系消息处理
+ * @author:linhuili
+ * @date:2021/11/23
+ */
+@Slf4j
+@Component
+@RabbitListener(queues = DigitalMessageConstant.MESSAGE_DIGITAL_RELATION_QUEUE)
+public class DigitalRelationMessageHandler extends AbstractRabbitHandlerTemplate {
+
+    @Autowired
+    private ObjectMapper objectMapper;
+
+    @Autowired
+    private IObjectRelationHistoryService objectRelationHisService;
+
+   /**
+     * 物理世界关系数据:消息监听处理
+     * @param message 消息体字符串
+     * @param channel 通道对象
+     * @param vo     消息对象
+     */
+    @Override
+    protected void handler(String message, Channel channel, Message vo) {
+        try {
+            //接收对象消息
+            DigitalManageMessage messageVO = objectMapper.readValue(message, DigitalManageMessage.class);
+            ObjectNode objectRelation = messageVO.getNewObj();
+            if(objectRelation == null || StrUtil.isEmpty(messageVO.getOperatorType()) || StrUtil.isEmpty(messageVO.getOperatorObj())){
+                log.info("对象关系数据消息格式有误:{}"+ messageVO);
+                return;
+            }
+            if(!ObjectRelation.class.getSimpleName().equals(messageVO.getOperatorObj())){
+                return;
+            }
+            log.info("处理对象关系消息:{}", message);
+            //处理物理世界关系数据
+            handlerDigitalRelationMessage(messageVO,objectRelation);
+        }catch (Exception e){
+          log.info("物理世界关系消息处理失败:{} "+e.getMessage());
+        }
+    }
+
+    /**
+     * 处理物理世界关系数据
+     * @param messageVO
+     * @param objectRelation
+     * @throws Exception
+     */
+    private void handlerDigitalRelationMessage(DigitalManageMessage messageVO, ObjectNode objectRelation) throws Exception{
+        ObjectRelation objectRelationVO = objectMapper.readValue(objectRelation.toString(), ObjectRelation.class);
+        //获取基本参数
+        String groupCode = objectRelationVO.getGroupCode();
+        String projectId = objectRelationVO.getProjectId();
+        //初始化数据源
+        initContextInfo(groupCode,projectId,null,null);
+        if(DigitalMessageConstant.OPERATE_AFTER_INSERT.equals(messageVO.getOperatorType())){
+            //记录新增关系
+            objectRelationHisService.insert(objectRelationVO);
+        }
+        if(DigitalMessageConstant.OPERATE_AFTER_UPDATE.equals(messageVO.getOperatorType())){
+            //记录关系修改
+            objectRelationHisService.update(objectRelationVO);
+        }
+        if(DigitalMessageConstant.OPERATE_AFTER_DELETE.equals(messageVO.getOperatorType())){
+            //记录关系删除
+            objectRelationHisService.update(objectRelationVO);
+        }
+    }
+
+     /**
+     * 初始化上下文,切换数据源
+     * @param groupCode
+     * @param projectId
+     * @param appId
+     * @param userId
+     */
+    private void initContextInfo(String groupCode,String projectId,String appId,String userId) {
+        AppContext.getContext().setGroupCode(groupCode);
+        AppContext.getContext().setProjectId(projectId);
+        // 无用户时,默认为默认系统用户
+        if(StrUtil.isBlank(userId)) {
+            userId = CommonConstant.DEFAULT_ID;
+        }
+        AppContext.getContext().setAccountId(userId);
+        DynamicDataSourceHelper.loadDataSource();
+    }
+
+}
+

+ 5 - 2
dmp-business/dmp-rwd-plus/src/main/java/com/persagy/dmp/rwd/qrcode/service/QrCodeService.java

@@ -1,6 +1,7 @@
 package com.persagy.dmp.rwd.qrcode.service;
 
 import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.persagy.dmp.digital.entity.ObjectDigital;
 
 import java.util.List;
 
@@ -17,8 +18,10 @@ public interface QrCodeService {
      * @param groupCode
      * @param projectId
      * @param digital
+     * @return
      */
-    void createObjectQrCode(String groupCode,String projectId,ObjectNode digital);
+    List<ObjectDigital> createObjectQrCode(String groupCode, String projectId, ObjectNode digital);
+
 
     /**
      * 删除对象二维码
@@ -26,5 +29,5 @@ public interface QrCodeService {
      * @param projectId
      * @param digital
      */
-    void removeObjectQrCode(String groupCode,String projectId,ObjectNode digital);
+    void removeQrCodePic(String groupCode,String projectId,ObjectNode digital);
 }

+ 36 - 11
dmp-business/dmp-rwd-plus/src/main/java/com/persagy/dmp/rwd/qrcode/service/impl/QrCodeServiceImpl.java

@@ -5,12 +5,15 @@ import cn.hutool.core.io.IoUtil;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.extra.qrcode.QrCodeUtil;
 import cn.hutool.extra.qrcode.QrConfig;
+import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.node.ArrayNode;
 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.dmp.common.constant.CommonConstant;
 import com.persagy.dmp.common.context.AppContext;
 import com.persagy.dmp.digital.client.DigitalObjectFacade;
+import com.persagy.dmp.digital.entity.ObjectDigital;
+import com.persagy.dmp.file.client.FileClientFacade;
 import com.persagy.dmp.file.model.FileInfo;
 import com.persagy.dmp.file.model.FileInfoCreator;
 import com.persagy.dmp.file.utils.FileStorageHelper;
@@ -19,7 +22,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
-import java.io.*;
+import java.io.ByteArrayInputStream;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -66,9 +69,9 @@ public class QrCodeServiceImpl implements QrCodeService {
         //设置二维码信息
         ObjectNode qrCodePic = JsonNodeFactory.instance.objectNode();
         qrCodePic.put("key", fileId);
-        qrCodePic.putPOJO("name",objectDigital.get("id"));
+        qrCodePic.put("name",objectDigital.get("id"));
         qrCodePic.put("type","image");
-        objectDigital.putPOJO(CommonConstant.QR_CODE_PIC_INFO,qrCodePic);
+        objectDigital.put(CommonConstant.QR_CODE_PIC_INFO,qrCodePic);
     }
 
     /**
@@ -98,37 +101,59 @@ public class QrCodeServiceImpl implements QrCodeService {
     /**
      * 生成对象二维码信息
      * @param digital
+     * @return
      */
-    @Override
-    public void createObjectQrCode(String groupCode,String projectId,ObjectNode digital){
+    public List<ObjectDigital> createObjectQrCode(String groupCode, String projectId, ObjectNode digital){
         //生成二维码图片并上传到文件服务器
         String fileId = uploadQrCode(groupCode,projectId,digital);
         if(StringUtils.isEmpty(fileId)){
             log.info("生成二维码失败:{}"+fileId);
-            return;
+            return new ArrayList<>();
         }
         //设置对象二维码信息
-       setObjectQrCode(digital,fileId);
+        setObjectQrCode(digital,fileId);
         //更新对象二维码信息
         List<ObjectNode> list = new ArrayList<>();
         list.add(digital);
-        DigitalObjectFacade.update(groupCode,projectId,null,null,list);
+        return DigitalObjectFacade.update(groupCode, projectId, null, null, list);
     }
 
     /**
      * 移除对象二维码信息点
      * @param digital
      */
-    @Override
-    public void removeObjectQrCode(String groupCode,String projectId,ObjectNode digital){
+    /*public void removeObjectQrCode(String groupCode,String projectId,ObjectNode digital){
         ObjectNode infos = JsonNodeFactory.instance.objectNode();
         //删除二维码信息点
         ArrayNode removeInfos = JsonNodeFactory.instance.arrayNode();
         removeInfos.add(CommonConstant.QR_CODE_PIC_INFO);
-        infos.putPOJO(CommonConstant.REMOVE_FIELD, removeInfos);
+        infos.put(CommonConstant.REMOVE_FIELD, removeInfos);
 
         List<ObjectNode> list = new ArrayList<>();
         list.add(digital);
         DigitalObjectFacade.update(groupCode,projectId,null,null,list);
+        //删除二维码图片
+    }*/
+
+    /**
+     * 删除二维码图片
+     * @param digital
+     */
+    public void removeQrCodePic(String groupCode,String projectId,ObjectNode digital){
+        JsonNode infos = digital.get(ObjectDigital.EXTRA_COLUMN);
+        if(infos == null){
+            return;
+        }
+        //获取文件id
+        JsonNode qrCodePicNode = infos.get(CommonConstant.QR_CODE_PIC_INFO);
+        if(qrCodePicNode == null){
+            return;
+        }
+        JsonNode fileId = qrCodePicNode.get("key");
+        if(fileId == null){
+            return;
+        }
+        //删除文件
+        FileClientFacade.delete(fileId.textValue());
     }
 }

+ 13 - 4
dmp-business/dmp-rwd-plus/src/main/java/com/persagy/dmp/rwd/version/service/impl/IObjectDigitalHistoryServiceImpl.java

@@ -11,6 +11,7 @@ import com.persagy.dmp.rwd.version.dao.ObjectDigitalHistoryMapper;
 import com.persagy.dmp.rwd.version.entity.ObjectDigitalHistory;
 import com.persagy.dmp.rwd.version.service.IObjectDigitalHistoryService;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -24,7 +25,7 @@ import java.util.List;
  */
 @Slf4j
 @Service
-public class IObjectDigitalHistoryServiceImpl extends ServiceImpl<ObjectDigitalHistoryMapper,ObjectDigitalHistory> implements IObjectDigitalHistoryService {
+public class ObjectDigitalHistoryServiceImpl extends ServiceImpl<ObjectDigitalHistoryMapper,ObjectDigitalHistory> implements IObjectDigitalHistoryService {
 
     @Autowired
     private ObjectDigitalHistoryMapper objectDigitalHistoryMapper;
@@ -66,6 +67,15 @@ public class IObjectDigitalHistoryServiceImpl extends ServiceImpl<ObjectDigitalH
      */
     @Override
     public ObjectDigitalHistory insert(ObjectDigital vo) throws Exception {
+        //幂等性校验,确保数据不重复添加
+        QueryWrapper<ObjectDigitalHistory> wrapper = new QueryWrapper<>();
+        wrapper.eq("last_flag",true);
+        wrapper.eq("obj_id",vo.getId());
+        wrapper.eq("valid", ValidEnum.TRUE.getType());
+        List<ObjectDigitalHistory> objHistoryList = queryByCondition(wrapper);
+        if(CollUtil.isNotEmpty(objHistoryList)){
+            return objHistoryList.get(0);
+        }
         //设置对象历史信息
         ObjectDigitalHistory objectDigitalHistory = new ObjectDigitalHistory();
         BeanUtils.copyProperties(vo,objectDigitalHistory);
@@ -94,13 +104,12 @@ public class IObjectDigitalHistoryServiceImpl extends ServiceImpl<ObjectDigitalH
         List<ObjectDigitalHistory> objHistoryList = queryByCondition(wrapper);
         if(CollUtil.isNotEmpty(objHistoryList)){
             for (ObjectDigitalHistory objHistory : objHistoryList) {
-                objHistory.setLastFlag(false);
-                objHistory.setEndTime(vo.getModifiedTime());
+                 objHistory.setLastFlag(false);
+                 objHistory.setEndTime(vo.getModifiedTime());
             }
             //修改最新历史记录标识
             saveOrUpdateBatch(objHistoryList);
         }
-        //新增历史记录
         return insert(vo);
     }
 

+ 52 - 16
dmp-business/dmp-rwd-plus/src/main/java/com/persagy/dmp/rwd/version/service/impl/IObjectRelationHistoryServiceImpl.java

@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
 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.common.constant.ValidEnum;
 import com.persagy.dmp.digital.entity.ObjectRelation;
 import com.persagy.dmp.rwd.version.dao.ObjectRelationHistoryMapper;
 import com.persagy.dmp.rwd.version.entity.ObjectRelationHistory;
@@ -24,17 +23,17 @@ import java.util.List;
  */
 @Slf4j
 @Service
-public class IObjectRelationHistoryServiceImpl extends ServiceImpl<ObjectRelationHistoryMapper, ObjectRelationHistory>  implements IObjectRelationHistoryService {
+public class ObjectRelationHistoryServiceImpl extends ServiceImpl<ObjectRelationHistoryMapper, ObjectRelationHistory>  implements IObjectRelationHistoryService {
 
     @Autowired
-    private ObjectRelationHistoryMapper objectRelationHistoryMapper;
+    private ObjectRelationHistoryMapper ObjectRelationHistoryMapper;
 
     /**
      * 数量统计对象关系历史数据
      */
     @Override
     public Integer queryCount(Wrapper<ObjectRelationHistory> queryWrapper) {
-        return objectRelationHistoryMapper.selectCount(queryWrapper);
+        return ObjectRelationHistoryMapper.selectCount(queryWrapper);
     }
 
     /**
@@ -44,7 +43,7 @@ public class IObjectRelationHistoryServiceImpl extends ServiceImpl<ObjectRelatio
      */
     @Override
     public List<ObjectRelationHistory> queryByCondition(Wrapper<ObjectRelationHistory> queryWrapper) {
-        return objectRelationHistoryMapper.selectList(queryWrapper);
+        return ObjectRelationHistoryMapper.selectList(queryWrapper);
     }
 
     /**
@@ -55,7 +54,7 @@ public class IObjectRelationHistoryServiceImpl extends ServiceImpl<ObjectRelatio
      */
     @Override
     public Page queryByCondition(Page page, Wrapper<ObjectRelationHistory> queryWrapper) {
-        return objectRelationHistoryMapper.selectPage(page, queryWrapper);
+        return ObjectRelationHistoryMapper.selectPage(page, queryWrapper);
     }
 
     /**
@@ -66,18 +65,25 @@ public class IObjectRelationHistoryServiceImpl extends ServiceImpl<ObjectRelatio
      */
     @Override
     public ObjectRelationHistory insert(ObjectRelation vo) throws Exception {
+        //幂等性校验,确保数据不会重复添加
+        Boolean relationIsExist = checkRelationIsExist(vo);
+        if(relationIsExist){
+           return null;
+        }
         //设置对象历史信息
-        ObjectRelationHistory objectRelationHistory = new ObjectRelationHistory();
-        BeanUtils.copyProperties(vo,objectRelationHistory);
-        objectRelationHistory.setRelId(vo.getId());
-        objectRelationHistory.setId(null);
-        objectRelationHistory.setLastFlag(true);
-        objectRelationHistory.setStartTime(vo.getCreationTime());
+        ObjectRelationHistory ObjectRelationHistory = new ObjectRelationHistory();
+        BeanUtils.copyProperties(vo,ObjectRelationHistory);
+        ObjectRelationHistory.setRelId(vo.getId());
+        ObjectRelationHistory.setId(null);
+        ObjectRelationHistory.setLastFlag(true);
+        ObjectRelationHistory.setStartTime(vo.getCreationTime());
         //保存对象历史记录
-        save(objectRelationHistory);
-        return objectRelationHistory;
+        save(ObjectRelationHistory);
+        return ObjectRelationHistory;
     }
 
+
+
     /**
      * 修改对象关系历史记录
      * @param vo 待修改数据
@@ -89,8 +95,13 @@ public class IObjectRelationHistoryServiceImpl extends ServiceImpl<ObjectRelatio
         //查询最新历史记录
         QueryWrapper<ObjectRelationHistory> wrapper = new QueryWrapper<>();
         wrapper.eq("last_flag",true);
-        wrapper.eq("obj_id",vo.getId());
-        wrapper.eq("valid", ValidEnum.TRUE.getType());
+        //由于关系ID不保真,修改采用唯一索引查询历史关系数据
+        //wrapper.eq("obj_id",vo.getId());
+        wrapper.eq("graph_code",vo.getGraphCode());
+        wrapper.eq("rel_code",vo.getRelCode());
+        wrapper.eq("obj_from",vo.getObjFrom());
+        wrapper.eq("obj_to",vo.getObjTo());
+        wrapper.eq("project_id",vo.getProjectId());
         List<ObjectRelationHistory> objHistoryList = queryByCondition(wrapper);
         if(CollUtil.isNotEmpty(objHistoryList)){
             for (ObjectRelationHistory objHistory : objHistoryList) {
@@ -112,4 +123,29 @@ public class IObjectRelationHistoryServiceImpl extends ServiceImpl<ObjectRelatio
     public ObjectRelationHistory delete(ObjectRelation vo) throws Exception  {
         return update(vo);
     }
+
+    /**
+     * 校验关系是否存在
+     * @param vo
+     * @return
+     */
+    private Boolean checkRelationIsExist(ObjectRelation vo){
+        QueryWrapper<ObjectRelationHistory> wrapper = new QueryWrapper<>();
+        wrapper.eq("last_flag",true);
+        wrapper.eq("valid",true);
+        //由于关系ID不保真,修改采用唯一索引查询历史关系数据
+        //wrapper.eq("obj_id",vo.getId());
+        wrapper.eq("graph_code",vo.getGroupCode());
+        wrapper.eq("rel_code",vo.getRelCode());
+        wrapper.eq("obj_from",vo.getObjFrom());
+        wrapper.eq("obj_to",vo.getObjTo());
+        wrapper.eq("rel_value",vo.getRelValue());
+        wrapper.eq("project_id",vo.getProjectId());
+        List<ObjectRelationHistory> relHistoryList = queryByCondition(wrapper);
+        if(CollUtil.isEmpty(relHistoryList)){
+            return false;
+        }else{
+            return true;
+        }
+    }
 }

+ 60 - 61
dmp-business/dmp-rwd-plus/src/main/resources/db/init/schema.sql

@@ -1,64 +1,63 @@
-
 CREATE TABLE IF NOT EXISTS `dt_object_his` (
-  `id` varchar(100) NOT NULL COMMENT '主键',
-  `obj_id` varchar(100) DEFAULT NULL COMMENT '对象id',
-  `name` varchar(100) DEFAULT NULL COMMENT '对象名称',
-  `local_id` varchar(100) DEFAULT NULL COMMENT '对象本地编码',
-  `local_name` varchar(100) DEFAULT NULL COMMENT '对象本地名称',
-  `group_code` varchar(40) DEFAULT NULL COMMENT '集团编码',
-  `project_id` varchar(40) NOT NULL COMMENT '项目id',
-  `obj_type` varchar(40) NOT NULL COMMENT '对象分类',
-  `class_code` varchar(40) NOT NULL COMMENT '对象类型编码',
-  `grouping` int(11) NOT NULL DEFAULT '1' COMMENT '1单个对象,2对象组',
-  `infos` json DEFAULT NULL COMMENT '边类型编码',
-  `virtual_codes` json DEFAULT NULL COMMENT '虚点清单',
-  `create_app` varchar(40) DEFAULT NULL COMMENT '创建应用',
-  `update_app` varchar(40) DEFAULT NULL COMMENT '最后更新应用',
-  `creator` varchar(32) DEFAULT NULL COMMENT '创建人',
-  `creation_time` char(14) NULL DEFAULT NULL COMMENT '创建时间',
-  `modifier` varchar(32) DEFAULT NULL COMMENT '最后修改人',
-  `modified_time` char(14) NULL DEFAULT NULL COMMENT '最后修改时间',
-  `last_flag` tinyint DEFAULT NULL COMMENT '最新标示',
-  `start_time` char(14) NULL DEFAULT NULL COMMENT '版本开始时间',
-  `end_time` char(14) NULL DEFAULT NULL COMMENT '版本结束时间',
-  `valid` tinyint DEFAULT NULL COMMENT '合法标识',
-  `ts` timestamp default current_timestamp on update current_timestamp NOT NULL COMMENT '乐观锁',
-  PRIMARY KEY (`id`) USING BTREE,
-  KEY `idx_project_1` (`project_id`,`class_code`,`creation_time`) USING BTREE,
-  KEY `idx_project_2` (`project_id`,`creation_time`) USING BTREE,
-  KEY `idx_project_3` (`project_id`,`modified_time`) USING BTREE,
-  KEY `idx_project_4` (`obj_type`) USING BTREE,
-  KEY `idx_project_5` (`project_id`) USING BTREE
-) ENGINE=InnoDB ROW_FORMAT=DYNAMIC COMMENT='对象实例表';
+    `id` varchar(100) NOT NULL COMMENT '主键',
+    `obj_id` varchar(100) DEFAULT NULL COMMENT '对象id',
+    `name` varchar(100) DEFAULT NULL COMMENT '对象名称',
+    `local_id` varchar(100) DEFAULT NULL COMMENT '对象本地编码',
+    `local_name` varchar(100) DEFAULT NULL COMMENT '对象本地名称',
+    `group_code` varchar(40) DEFAULT NULL COMMENT '集团编码',
+    `project_id` varchar(40) NOT NULL COMMENT '项目id',
+    `obj_type` varchar(40) NOT NULL COMMENT '对象分类',
+    `class_code` varchar(40) NOT NULL COMMENT '对象类型编码',
+    `grouping` int(11) NOT NULL DEFAULT '1' COMMENT '1单个对象,2对象组',
+    `infos` json DEFAULT NULL COMMENT '边类型编码',
+    `virtual_codes` json DEFAULT NULL COMMENT '虚点清单',
+    `create_app` varchar(40) DEFAULT NULL COMMENT '创建应用',
+    `update_app` varchar(40) DEFAULT NULL COMMENT '最后更新应用',
+    `creator` varchar(32) DEFAULT NULL COMMENT '创建人',
+    `creation_time` char(14) NULL DEFAULT NULL COMMENT '创建时间',
+    `modifier` varchar(32) DEFAULT NULL COMMENT '最后修改人',
+    `modified_time` char(14) NULL DEFAULT NULL COMMENT '最后修改时间',
+    `last_flag` tinyint DEFAULT NULL COMMENT '最新标示',
+    `start_time` char(14) NULL DEFAULT NULL COMMENT '版本开始时间',
+    `end_time` char(14) NULL DEFAULT NULL COMMENT '版本结束时间',
+    `valid` tinyint DEFAULT NULL COMMENT '合法标识',
+    `ts` timestamp default current_timestamp on update current_timestamp NOT NULL COMMENT '乐观锁',
+    PRIMARY KEY (`id`) USING BTREE,
+    KEY `idx_project_1` (`project_id`,`class_code`,`creation_time`) USING BTREE,
+    KEY `idx_project_2` (`project_id`,`creation_time`) USING BTREE,
+    KEY `idx_project_3` (`project_id`,`modified_time`) USING BTREE,
+    KEY `idx_project_4` (`obj_type`) USING BTREE,
+    KEY `idx_project_5` (`project_id`) USING BTREE
+    ) ENGINE=InnoDB ROW_FORMAT=DYNAMIC COMMENT='对象实例表';
 
 CREATE TABLE IF NOT EXISTS `dt_relation_his` (
-  `id` varchar(40) NOT NULL COMMENT '主键',
-  `rel_id` varchar(40) DEFAULT NULL COMMENT '关系id',
-  `group_code` varchar(40) DEFAULT NULL,
-  `project_id` varchar(40) NOT NULL,
-  `graph_id` varchar(40) DEFAULT NULL COMMENT '图主键',
-  `graph_code` varchar(40) DEFAULT NULL COMMENT '图编码',
-  `rel_code` varchar(40) DEFAULT NULL COMMENT '关系编码',
-  `rel_value` varchar(50) DEFAULT NULL COMMENT '关系值',
-  `obj_from` varchar(60) DEFAULT NULL COMMENT '来源对象',
-  `obj_to` varchar(60) DEFAULT NULL COMMENT '目标对象',
-  `create_app` varchar(40) DEFAULT NULL COMMENT '创建应用',
-  `update_app` varchar(40) DEFAULT NULL COMMENT '最后更新应用',
-  `creator` varchar(32) DEFAULT NULL COMMENT '创建人',
-  `creation_time` char(14) NULL DEFAULT NULL COMMENT '创建时间',
-  `modifier` varchar(32) DEFAULT NULL COMMENT '最后修改人',
-  `modified_time` char(14) NULL DEFAULT NULL COMMENT '最后修改时间',
-  `last_flag` tinyint DEFAULT NULL COMMENT '最新标示',
-  `start_time` char(14) NULL DEFAULT NULL COMMENT '版本开始时间',
-  `end_time` char(14) NULL DEFAULT NULL COMMENT '版本结束时间',
-  `valid` tinyint DEFAULT '1' COMMENT '合法标识',
-  `ts` timestamp default current_timestamp on update current_timestamp NOT NULL COMMENT '乐观锁',
-  PRIMARY KEY (`id`) USING BTREE,
-  KEY `idx_graph_code` (`graph_code`) USING BTREE,
-  KEY `idx_1` (`graph_code`,`rel_code`,`obj_from`,`obj_to`,`project_id`) USING BTREE,
-  KEY `idx_2` (`graph_id`,`rel_code`,`obj_from`,`obj_to`,`project_id`) USING BTREE,
-  KEY `idx_3` (`graph_code`,`rel_code`,`obj_to`,`project_id`) USING BTREE,
-  KEY `idx_4` (`graph_id`,`rel_code`,`obj_to`,`project_id`) USING BTREE,
-  KEY `idx_5` (`obj_from`) USING BTREE,
-  KEY `idx_6` (`obj_to`) USING BTREE
-) ENGINE=InnoDB ROW_FORMAT=DYNAMIC COMMENT='关系实例表';
+    `id` varchar(100) NOT NULL COMMENT '主键',
+    `rel_id` varchar(100) DEFAULT NULL COMMENT '关系id',
+    `group_code` varchar(40) DEFAULT NULL,
+    `project_id` varchar(40) NOT NULL,
+    `graph_id` varchar(100) DEFAULT NULL COMMENT '图主键',
+    `graph_code` varchar(40) DEFAULT NULL COMMENT '图编码',
+    `rel_code` varchar(40) DEFAULT NULL COMMENT '关系编码',
+    `rel_value` varchar(50) DEFAULT NULL COMMENT '关系值',
+    `obj_from` varchar(60) DEFAULT NULL COMMENT '来源对象',
+    `obj_to` varchar(60) DEFAULT NULL COMMENT '目标对象',
+    `create_app` varchar(40) DEFAULT NULL COMMENT '创建应用',
+    `update_app` varchar(40) DEFAULT NULL COMMENT '最后更新应用',
+    `creator` varchar(32) DEFAULT NULL COMMENT '创建人',
+    `creation_time` char(14) NULL DEFAULT NULL COMMENT '创建时间',
+    `modifier` varchar(32) DEFAULT NULL COMMENT '最后修改人',
+    `modified_time` char(14) NULL DEFAULT NULL COMMENT '最后修改时间',
+    `last_flag` tinyint DEFAULT NULL COMMENT '最新标示',
+    `start_time` char(14) NULL DEFAULT NULL COMMENT '版本开始时间',
+    `end_time` char(14) NULL DEFAULT NULL COMMENT '版本结束时间',
+    `valid` tinyint DEFAULT '1' COMMENT '合法标识',
+    `ts` timestamp default current_timestamp on update current_timestamp NOT NULL COMMENT '乐观锁',
+    PRIMARY KEY (`id`) USING BTREE,
+    KEY `idx_graph_code` (`graph_code`) USING BTREE,
+    KEY `idx_1` (`graph_code`,`rel_code`,`obj_from`,`obj_to`,`project_id`) USING BTREE,
+    KEY `idx_2` (`graph_id`,`rel_code`,`obj_from`,`obj_to`,`project_id`) USING BTREE,
+    KEY `idx_3` (`graph_code`,`rel_code`,`obj_to`,`project_id`) USING BTREE,
+    KEY `idx_4` (`graph_id`,`rel_code`,`obj_to`,`project_id`) USING BTREE,
+    KEY `idx_5` (`obj_from`) USING BTREE,
+    KEY `idx_6` (`obj_to`) USING BTREE
+    ) ENGINE=InnoDB ROW_FORMAT=DYNAMIC COMMENT='关系实例表';

+ 29 - 4
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/digital/config/DigitalRabbitConfig.java

@@ -45,13 +45,38 @@ public class DigitalRabbitConfig {
         return new TopicExchange(DigitalMessageConstant.MESSAGE_EXCHANGE);
     }
 
+    /**
+     * 创建对象队列
+     * @return
+     */
     @Bean
-    public Queue bdtpDigitalQueue(){
-        return new Queue(DigitalMessageConstant.MESSAGE_QUEUE);
+    public Queue bdtpDigitalObjectQueue(){
+        return new Queue(DigitalMessageConstant.MESSAGE_DIGITAL_OBJECT_QUEUE);
     }
 
+    /**
+     * 交换机队列绑定-对象
+     * @return
+     */
     @Bean
-    public Binding bdtpDigitalBinding() {
-        return BindingBuilder.bind(bdtpDigitalQueue()).to(bdtpDigitalExchange()).with(DigitalMessageConstant.MESSAGE_ROUTING);
+    public Binding bdtpDigitalObjectBinding() {
+        return BindingBuilder.bind(bdtpDigitalObjectQueue()).to(bdtpDigitalExchange()).with(DigitalMessageConstant.MESSAGE_ROUTING);
+    }
+
+    /**
+     * 创建关系队列
+     * @return
+     */
+    @Bean
+    public Queue bdtpDigitalRelationQueue(){
+        return new Queue(DigitalMessageConstant.MESSAGE_DIGITAL_RELATION_QUEUE);
+    }
+    /**
+     * 交换机队列绑定-关系
+     * @return
+     */
+    @Bean
+    public Binding bdtpDigitalRelationBinding() {
+        return BindingBuilder.bind(bdtpDigitalRelationQueue()).to(bdtpDigitalExchange()).with(DigitalMessageConstant.MESSAGE_ROUTING);
     }
 }

+ 65 - 1
dmp-business/dmp-rwd/src/main/resources/db/init/schema.sql

@@ -235,4 +235,68 @@ CREATE TABLE IF NOT EXISTS `dt_define_info_collect`  (
 `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '乐观锁',
 `key_word` int(1) DEFAULT NULL COMMENT '是否为关键信息点',
 PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB ROW_FORMAT = Dynamic COMMENT = '采集信息点配置表' ;
+) ENGINE = InnoDB ROW_FORMAT = Dynamic COMMENT = '采集信息点配置表' ;
+
+CREATE TABLE IF NOT EXISTS `dt_object_his` (
+    `id` varchar(100) NOT NULL COMMENT '主键',
+    `obj_id` varchar(100) DEFAULT NULL COMMENT '对象id',
+    `name` varchar(100) DEFAULT NULL COMMENT '对象名称',
+    `local_id` varchar(100) DEFAULT NULL COMMENT '对象本地编码',
+    `local_name` varchar(100) DEFAULT NULL COMMENT '对象本地名称',
+    `group_code` varchar(40) DEFAULT NULL COMMENT '集团编码',
+    `project_id` varchar(40) NOT NULL COMMENT '项目id',
+    `obj_type` varchar(40) NOT NULL COMMENT '对象分类',
+    `class_code` varchar(40) NOT NULL COMMENT '对象类型编码',
+    `grouping` int(11) NOT NULL DEFAULT '1' COMMENT '1单个对象,2对象组',
+    `infos` json DEFAULT NULL COMMENT '边类型编码',
+    `virtual_codes` json DEFAULT NULL COMMENT '虚点清单',
+    `create_app` varchar(40) DEFAULT NULL COMMENT '创建应用',
+    `update_app` varchar(40) DEFAULT NULL COMMENT '最后更新应用',
+    `creator` varchar(32) DEFAULT NULL COMMENT '创建人',
+    `creation_time` char(14) NULL DEFAULT NULL COMMENT '创建时间',
+    `modifier` varchar(32) DEFAULT NULL COMMENT '最后修改人',
+    `modified_time` char(14) NULL DEFAULT NULL COMMENT '最后修改时间',
+    `last_flag` tinyint DEFAULT NULL COMMENT '最新标示',
+    `start_time` char(14) NULL DEFAULT NULL COMMENT '版本开始时间',
+    `end_time` char(14) NULL DEFAULT NULL COMMENT '版本结束时间',
+    `valid` tinyint DEFAULT NULL COMMENT '合法标识',
+    `ts` timestamp default current_timestamp on update current_timestamp NOT NULL COMMENT '乐观锁',
+    PRIMARY KEY (`id`) USING BTREE,
+    KEY `idx_project_1` (`project_id`,`class_code`,`creation_time`) USING BTREE,
+    KEY `idx_project_2` (`project_id`,`creation_time`) USING BTREE,
+    KEY `idx_project_3` (`project_id`,`modified_time`) USING BTREE,
+    KEY `idx_project_4` (`obj_type`) USING BTREE,
+    KEY `idx_project_5` (`project_id`) USING BTREE
+    ) ENGINE=InnoDB ROW_FORMAT=DYNAMIC COMMENT='对象实例表';
+
+CREATE TABLE IF NOT EXISTS `dt_relation_his` (
+    `id` varchar(100) NOT NULL COMMENT '主键',
+    `rel_id` varchar(100) DEFAULT NULL COMMENT '关系id',
+    `group_code` varchar(40) DEFAULT NULL,
+    `project_id` varchar(40) NOT NULL,
+    `graph_id` varchar(100) DEFAULT NULL COMMENT '图主键',
+    `graph_code` varchar(40) DEFAULT NULL COMMENT '图编码',
+    `rel_code` varchar(40) DEFAULT NULL COMMENT '关系编码',
+    `rel_value` varchar(50) DEFAULT NULL COMMENT '关系值',
+    `obj_from` varchar(60) DEFAULT NULL COMMENT '来源对象',
+    `obj_to` varchar(60) DEFAULT NULL COMMENT '目标对象',
+    `create_app` varchar(40) DEFAULT NULL COMMENT '创建应用',
+    `update_app` varchar(40) DEFAULT NULL COMMENT '最后更新应用',
+    `creator` varchar(32) DEFAULT NULL COMMENT '创建人',
+    `creation_time` char(14) NULL DEFAULT NULL COMMENT '创建时间',
+    `modifier` varchar(32) DEFAULT NULL COMMENT '最后修改人',
+    `modified_time` char(14) NULL DEFAULT NULL COMMENT '最后修改时间',
+    `last_flag` tinyint DEFAULT NULL COMMENT '最新标示',
+    `start_time` char(14) NULL DEFAULT NULL COMMENT '版本开始时间',
+    `end_time` char(14) NULL DEFAULT NULL COMMENT '版本结束时间',
+    `valid` tinyint DEFAULT '1' COMMENT '合法标识',
+    `ts` timestamp default current_timestamp on update current_timestamp NOT NULL COMMENT '乐观锁',
+    PRIMARY KEY (`id`) USING BTREE,
+    KEY `idx_graph_code` (`graph_code`) USING BTREE,
+    KEY `idx_1` (`graph_code`,`rel_code`,`obj_from`,`obj_to`,`project_id`) USING BTREE,
+    KEY `idx_2` (`graph_id`,`rel_code`,`obj_from`,`obj_to`,`project_id`) USING BTREE,
+    KEY `idx_3` (`graph_code`,`rel_code`,`obj_to`,`project_id`) USING BTREE,
+    KEY `idx_4` (`graph_id`,`rel_code`,`obj_to`,`project_id`) USING BTREE,
+    KEY `idx_5` (`obj_from`) USING BTREE,
+    KEY `idx_6` (`obj_to`) USING BTREE
+    ) ENGINE=InnoDB ROW_FORMAT=DYNAMIC COMMENT='关系实例表';

+ 4 - 2
dmp-comp/dmp-digital-starter/src/main/java/com/persagy/dmp/basic/constant/DigitalMessageConstant.java

@@ -7,8 +7,10 @@ package com.persagy.dmp.basic.constant;
  */
 public interface DigitalMessageConstant {
 
-    /** 消息-queue */
-    String MESSAGE_QUEUE = "queue-bdtp-digital";
+    /** 对象消息队列-queue */
+    String MESSAGE_DIGITAL_OBJECT_QUEUE = "queue-bdtp-digital-object";
+    /** 关系消息队列-queue */
+    String MESSAGE_DIGITAL_RELATION_QUEUE = "queue-bdtp-digital-relation";
     /** 消息-exchange */
     String MESSAGE_EXCHANGE = "exchange-bdtp-digital";
     /** 消息-路由Key */