소스 검색

扩展服务:消息处理bug修复

linhuili 3 년 전
부모
커밋
4df38b766b

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

@@ -0,0 +1,133 @@
+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);
+        }
+    }
+
+
+}

+ 1 - 0
dmp-business/dmp-rwd-plus/src/main/java/com/persagy/dmp/rwd/qrcode/controller/QrCodeController.java

@@ -54,6 +54,7 @@ public class QrCodeController {
             if(pageList.size() <= 0){
                 continue;
             }
+            //todo 目前文件服务暂时支持单个文件上传,后期支持批量上传后,此接口需进行优化
             qrCodeService.createDefaultQrCode(pageList);
         }
         return CommonResult.success("创建成功");

+ 0 - 103
dmp-business/dmp-rwd-plus/src/main/java/com/persagy/dmp/rwd/qrcode/handler/QrCodeMessageHandler.java

@@ -1,103 +0,0 @@
-package com.persagy.dmp.rwd.qrcode.handler;
-import cn.hutool.core.util.StrUtil;
-import com.fasterxml.jackson.databind.ObjectMapper;
-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.amqp.handler.AbstractRabbitHandlerTemplate;
-import com.persagy.dmp.basic.model.DigitalManageMessage;
-import com.persagy.dmp.common.constant.CommonConstant;
-import com.persagy.dmp.common.exception.BusinessException;
-import com.persagy.dmp.digital.client.DigitalObjectFacade;
-import com.persagy.dmp.file.model.UploadMes;
-import com.persagy.dmp.basic.constant.DigitalMessageConstant;
-import com.persagy.dmp.rwd.qrcode.service.impl.QrCodeServiceImpl;
-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.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * 二维码消息处理
- * @author:linhuili
- * @date:2021/11/8
- */
-@Slf4j
-@Component
-@RabbitListener(queues = "queue-dmp-rwd")
-public class QrCodeMessageHandler extends AbstractRabbitHandlerTemplate {
-
-    @Autowired
-    private ObjectMapper objectMapper;
-
-    @Autowired
-    private QrCodeServiceImpl qrCodeService;
-
-    @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())){
-                log.info("新增消息格式有误:{}"+ messageVO);
-            }
-            //获取基本参数
-            String groupCode = objectDigital.get("groupCode").textValue();
-            String projectId = objectDigital.get("projectId").textValue();
-            //创建二维码图片
-            if(DigitalMessageConstant.OPERATE_AFTER_INSERT.equals(messageVO.getOperatorType())){
-                createObjectQrCode(groupCode,projectId,objectDigital);
-            }
-            //删除二维码信息
-            if(DigitalMessageConstant.OPERATE_AFTER_DELETE.equals(messageVO.getOperatorType())){
-                removeObjectQrCode(groupCode,projectId,objectDigital);
-            }
-        } catch (IOException e) {
-            log.error(e.getMessage(), e);
-            throw new BusinessException(e.getMessage(), e);
-        }
-    }
-
-    /**
-     * 生成对象二维码信息
-     * @param digital
-     */
-    private void createObjectQrCode(String groupCode,String projectId,ObjectNode digital){
-        //生成二维码图片并上传到文件服务器
-        UploadMes objectQrCode = qrCodeService.createObjectQrCode(groupCode,projectId,digital);
-        if(objectQrCode == null){
-            log.info("生成二维码失败");
-            return;
-        }
-        //设置对象二维码信息
-        qrCodeService.setObjectQrCode(digital,objectQrCode);
-        //更新对象二维码信息
-        List<ObjectNode> list = new ArrayList<>();
-        list.add(digital);
-        DigitalObjectFacade.update(groupCode,projectId,null,null,list);
-    }
-
-    /**
-     * 移除对象二维码信息点
-     * @param 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.put(CommonConstant.REMOVE_FIELD, removeInfos);
-
-        List<ObjectNode> list = new ArrayList<>();
-        list.add(digital);
-        DigitalObjectFacade.update(groupCode,projectId,null,null,list);
-    }
-}

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

@@ -11,4 +11,20 @@ public interface QrCodeService {
      * @param objectDigitals
      */
     void createDefaultQrCode(List<ObjectNode> objectDigitals);
+
+    /**
+     * 创建对象二维码信息
+     * @param groupCode
+     * @param projectId
+     * @param digital
+     */
+    void createObjectQrCode(String groupCode,String projectId,ObjectNode digital);
+
+    /**
+     * 删除对象二维码
+     * @param groupCode
+     * @param projectId
+     * @param digital
+     */
+    void removeObjectQrCode(String groupCode,String projectId,ObjectNode digital);
 }

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

@@ -2,24 +2,46 @@ package com.persagy.dmp.rwd.qrcode.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.util.IdUtil;
 import cn.hutool.crypto.SecureUtil;
 import cn.hutool.extra.qrcode.QrCodeUtil;
 import cn.hutool.extra.qrcode.QrConfig;
 import com.fasterxml.jackson.databind.node.ArrayNode;
 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.zxing.BarcodeFormat;
+import com.google.zxing.MultiFormatWriter;
+import com.google.zxing.common.BitMatrix;
 import com.persagy.dmp.common.constant.CommonConstant;
 import com.persagy.dmp.common.context.AppContext;
 import com.persagy.dmp.common.model.response.CommonResult;
 import com.persagy.dmp.digital.client.DigitalObjectFacade;
 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.model.FileRequestData;
 import com.persagy.dmp.file.model.UploadMes;
+import com.persagy.dmp.file.utils.FileStorageHelper;
 import com.persagy.dmp.rwd.qrcode.service.QrCodeService;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.springframework.mock.web.MockMultipartFile;
 import org.springframework.stereotype.Service;
+import org.springframework.util.IdGenerator;
+import org.springframework.util.StringUtils;
+import org.springframework.web.multipart.MultipartFile;
 
-import java.io.File;
+import javax.imageio.ImageIO;
+import javax.imageio.stream.ImageOutputStream;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.*;
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.List;
 
 /**
@@ -45,13 +67,13 @@ public class QrCodeServiceImpl implements QrCodeService {
         String groupCode = AppContext.getContext().getGroupCode();
         for (ObjectNode objectDigital : objectDigitals) {
             //生成二维码图片,并上传到文件服务器
-            UploadMes objectQrCode = createObjectQrCode(groupCode,projectId,objectDigital);
-            if(objectQrCode == null){
-                log.info("生成二维码失败");
+            String fileId = uploadQrCode(groupCode,projectId,objectDigital);
+            if(StringUtils.isEmpty(fileId)){
+                log.info("生成二维码失败:{}"+objectDigital.get("id"));
                 continue;
             }
             //设置对象二维码信息
-            setObjectQrCode(objectDigital,objectQrCode);
+            setObjectQrCode(objectDigital,fileId);
         }
         //更新对象二维码信息
         DigitalObjectFacade.update(groupCode,projectId,null,null,objectDigitals);
@@ -61,39 +83,71 @@ public class QrCodeServiceImpl implements QrCodeService {
      * 设置二维码图片
      * @param objectDigital
      */
-    public void setObjectQrCode(ObjectNode objectDigital, UploadMes objectQrCode){
+    public void setObjectQrCode(ObjectNode objectDigital, String fileId){
         //设置二维码信息
-        ArrayNode qrCodePics = JsonNodeFactory.instance.arrayNode();
         ObjectNode qrCodePic = JsonNodeFactory.instance.objectNode();
-        qrCodePic.put("key", objectQrCode.getId());
-        qrCodePics.add(qrCodePic);
-        objectDigital.put(CommonConstant.QR_CODE_PIC_INFO,qrCodePics);
+        qrCodePic.put("key", fileId);
+        qrCodePic.put("name",objectDigital.get("id"));
+        qrCodePic.put("type","image");
+        objectDigital.put(CommonConstant.QR_CODE_PIC_INFO,qrCodePic);
     }
 
     /**
      * 生成二维码信息并上传到文件服务器
      * @param objectDigital
      */
-    public UploadMes createObjectQrCode(String groupCode,String projectId,ObjectNode objectDigital){
-        //获取基础参数
-        String objId =objectDigital.get("id").textValue();
-        String key = CommonConstant.QRCODE_KEY_PREFIX +"_"+ objId;
-        //生成二维码
-        QrConfig qrConfig = new QrConfig(300, 300);
-        File qrCodeFile = QrCodeUtil.generate(objId, qrConfig, FileUtil.file("/image"));
-        //上传到文件服务器
-        FileRequestData fileRequestData = new FileRequestData();
-        fileRequestData.setFileName(key);
-        fileRequestData.setFileMd5(SecureUtil.md5(qrCodeFile));
-        fileRequestData.setGroupCode(groupCode);
-        fileRequestData.setFileBucket(CommonConstant.FILE_BUCKET_NAME);
-        fileRequestData.setFileSize(qrCodeFile.length());
-        CommonResult<UploadMes> uploadMesCommonResult = FileClientFacade.initSingleUploadPrototype(groupCode,projectId,null,null,fileRequestData);
-        if(!CommonConstant.QUERY_SUCCESS.equals(uploadMesCommonResult.getResult())){
-            log.info("上传文件失败:"+uploadMesCommonResult.getMessage());
-            return new UploadMes();
+    public String uploadQrCode(String groupCode,String projectId,ObjectNode objectDigital){
+       try {
+           //获取基础参数
+           String content =objectDigital.get("id").textValue();
+           //生成二维码
+           QrConfig qrConfig = new QrConfig(300, 300);
+           byte[] bytes = QrCodeUtil.generatePng(content, qrConfig);
+           ByteArrayInputStream byteArrayInputStream = IoUtil.toStream(bytes);
+           FileInfo fileInfo = FileInfoCreator.of(groupCode, projectId, CommonConstant.FILE_BUCKET_NAME, content + ".png");
+           fileInfo.setId(IdUtil.simpleUUID());
+           //上传到文件服务器
+           String fileId = FileStorageHelper.uploadFile(fileInfo, byteArrayInputStream);
+           log.info("对象二维码信息上传到文件服务器,文件id:{}"+fileId);
+           return fileId;
+       }catch (Exception e){
+           log.info("对象二维码信息上传到文件服务器失败{}"+e.getMessage());
+       }
+       return null;
+    }
+
+    /**
+     * 生成对象二维码信息
+     * @param digital
+     */
+    public void createObjectQrCode(String groupCode,String projectId,ObjectNode digital){
+        //生成二维码图片并上传到文件服务器
+        String fileId = uploadQrCode(groupCode,projectId,digital);
+        if(StringUtils.isEmpty(fileId)){
+            log.info("生成二维码失败:{}"+fileId);
+            return;
         }
-        log.info("生成二维码信息"+uploadMesCommonResult.getMessage());
-        return uploadMesCommonResult.getData();
+        //设置对象二维码信息
+       setObjectQrCode(digital,fileId);
+        //更新对象二维码信息
+        List<ObjectNode> list = new ArrayList<>();
+        list.add(digital);
+        DigitalObjectFacade.update(groupCode,projectId,null,null,list);
+    }
+
+    /**
+     * 移除对象二维码信息点
+     * @param 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.put(CommonConstant.REMOVE_FIELD, removeInfos);
+
+        List<ObjectNode> list = new ArrayList<>();
+        list.add(digital);
+        DigitalObjectFacade.update(groupCode,projectId,null,null,list);
     }
 }

+ 0 - 77
dmp-business/dmp-rwd-plus/src/main/java/com/persagy/dmp/rwd/version/handler/ObjectDigitalHistoryMessageHandler.java

@@ -1,77 +0,0 @@
-package com.persagy.dmp.rwd.version.handler;
-
-import cn.hutool.core.bean.BeanUtil;
-import cn.hutool.core.util.StrUtil;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-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.model.QueryCriteria;
-import com.persagy.dmp.common.exception.BusinessException;
-import com.persagy.dmp.digital.client.DigitalObjectFacade;
-import com.persagy.dmp.digital.entity.ObjectDigital;
-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 org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.io.DataInput;
-
-/**
- * 历史对象记录消息处理
- * @author:linhuili
- * @date:2021/11/15
- */
-@Slf4j
-@Component
-@RabbitListener
-public class ObjectDigitalHistoryMessageHandler extends AbstractRabbitHandlerTemplate {
-
-    @Autowired
-    private ObjectMapper objectMapper;
-
-    @Autowired
-    private IObjectDigitalHistoryService objectDigitalHisService;
-
-    @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())){
-                return;
-            }
-            ObjectDigital objectDigitalVO = objectMapper.readValue(objectDigital.toString(), ObjectDigital.class);
-            //新增对象,历史记录
-            if(DigitalMessageConstant.OPERATE_AFTER_INSERT.equals(messageVO.getOperatorType())){
-                objectDigitalHisService.insert(objectDigitalVO);
-            }
-            //修改对象,历史记录
-            if(DigitalMessageConstant.OPERATE_AFTER_UPDATE.equals(messageVO.getOperatorType())){
-                objectDigitalHisService.update(objectDigitalVO);
-            }
-            //删除对象,历史记录
-            if(DigitalMessageConstant.OPERATE_AFTER_DELETE.equals(messageVO.getOperatorType())){
-                objectDigitalHisService.delete(objectDigitalVO);
-            }
-        } catch (Exception e) {
-            log.error(e.getMessage(), e);
-            throw new BusinessException(e.getMessage(), e);
-        }
-
-    }
-}

+ 0 - 69
dmp-business/dmp-rwd-plus/src/main/java/com/persagy/dmp/rwd/version/handler/ObjectRelationHistoryMessageHandler.java

@@ -1,69 +0,0 @@
-package com.persagy.dmp.rwd.version.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.exception.BusinessException;
-import com.persagy.dmp.digital.entity.ObjectRelation;
-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;
-
-import java.io.DataInput;
-
-/**
- * 历史关系记录消息处理
- * @author:linhuili
- * @date:2021/11/15
- */
-@Slf4j
-@Component
-@RabbitListener
-public class ObjectRelationHistoryMessageHandler extends AbstractRabbitHandlerTemplate {
-
-    @Autowired
-    private ObjectMapper objectMapper;
-
-    @Autowired
-    private IObjectRelationHistoryService objectRelationHisService;
-
-    @Override
-    protected void handler(String message, Channel channel, Message vo) {
-        try {
-            log.info("对象关系历史记录-接收对象关系消息:{}", message);
-            //接收对象消息
-            DigitalManageMessage messageVO = objectMapper.readValue(message, DigitalManageMessage.class);
-            ObjectNode objectRelation = messageVO.getNewObj();
-            if(objectRelation == null || StrUtil.isEmpty(messageVO.getOperatorType())){
-                log.info("对象关系消息格式有误:{}"+ messageVO);
-            }
-            if(!ObjectRelation.class.getSimpleName().equals(messageVO.getOperatorObj())){
-                return;
-            }
-            ObjectRelation objectRelationVO = objectMapper.readValue(objectRelation.toString(), ObjectRelation.class);
-            //新增对象关系,历史记录
-            if(DigitalMessageConstant.OPERATE_AFTER_INSERT.equals(messageVO.getOperatorType())){
-                objectRelationHisService.insert(objectRelationVO);
-            }
-            //修改对象关系,历史记录
-            if(DigitalMessageConstant.OPERATE_AFTER_INSERT.equals(messageVO.getOperatorType())){
-                objectRelationHisService.update(objectRelationVO);
-            }
-            //删除对象关系,历史记录
-            if(DigitalMessageConstant.OPERATE_AFTER_INSERT.equals(messageVO.getOperatorType())){
-                objectRelationHisService.delete(objectRelationVO);
-            }
-        } catch (Exception e) {
-            log.error(e.getMessage(), e);
-            throw new BusinessException(e.getMessage(), e);
-        }
-
-    }
-}

+ 10 - 0
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/digital/config/DigitalRabbitConfig.java

@@ -44,4 +44,14 @@ public class DigitalRabbitConfig {
     public TopicExchange bdtpDigitalExchange() {
         return new TopicExchange(DigitalMessageConstant.MESSAGE_EXCHANGE);
     }
+
+    @Bean
+    public Queue bdtpDigitalQueue(){
+        return new Queue(DigitalMessageConstant.MESSAGE_QUEUE);
+    }
+
+    @Bean
+    public Binding bdtpDigitalBinding() {
+        return BindingBuilder.bind(bdtpDigitalQueue()).to(bdtpDigitalExchange()).with(DigitalMessageConstant.MESSAGE_ROUTING);
+    }
 }

+ 1 - 1
dmp-common/src/main/java/com/persagy/dmp/common/constant/CommonConstant.java

@@ -48,7 +48,7 @@ public interface CommonConstant {
     String FILE_BUCKET_NAME = "dmp-rwd";
 
     /** 二维码图片信息点 */
-    String QR_CODE_PIC_INFO ="qrCodePic";
+    String QR_CODE_PIC_INFO ="qRCodePic";
 
     /** remove字段 */
     String REMOVE_FIELD ="$remove";

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

@@ -7,6 +7,8 @@ package com.persagy.dmp.basic.constant;
  */
 public interface DigitalMessageConstant {
 
+    /** 消息-queue */
+    String MESSAGE_QUEUE = "queue-bdtp-digital";
     /** 消息-exchange */
     String MESSAGE_EXCHANGE = "exchange-bdtp-digital";
     /** 消息-路由Key */