瀏覽代碼

Merge remote-tracking branch 'origin/develop' into develop

lijie 3 年之前
父節點
當前提交
0099d2d634
共有 20 個文件被更改,包括 35389 次插入33069 次删除
  1. 133 0
      dmp-business/dmp-rwd-plus/src/main/java/com/persagy/dmp/rwd/handler/DigitalMessageHandler.java
  2. 1 0
      dmp-business/dmp-rwd-plus/src/main/java/com/persagy/dmp/rwd/qrcode/controller/QrCodeController.java
  3. 0 103
      dmp-business/dmp-rwd-plus/src/main/java/com/persagy/dmp/rwd/qrcode/handler/QrCodeMessageHandler.java
  4. 16 0
      dmp-business/dmp-rwd-plus/src/main/java/com/persagy/dmp/rwd/qrcode/service/QrCodeService.java
  5. 84 30
      dmp-business/dmp-rwd-plus/src/main/java/com/persagy/dmp/rwd/qrcode/service/impl/QrCodeServiceImpl.java
  6. 0 77
      dmp-business/dmp-rwd-plus/src/main/java/com/persagy/dmp/rwd/version/handler/ObjectDigitalHistoryMessageHandler.java
  7. 0 69
      dmp-business/dmp-rwd-plus/src/main/java/com/persagy/dmp/rwd/version/handler/ObjectRelationHistoryMessageHandler.java
  8. 10 0
      dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/digital/config/DigitalRabbitConfig.java
  9. 1 1
      dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/digital/service/impl/ObjectDigitalServiceImpl.java
  10. 34944 32786
      dmp-business/dmp-rwd/src/main/resources/db/init/data.sql
  11. 2 0
      dmp-business/dmp-rwd/src/main/resources/db/init/schema.sql
  12. 2 2
      dmp-business/dmp-rwd/src/main/resources/mapper/DefineInfoMapper.xml
  13. 1 1
      dmp-common/src/main/java/com/persagy/dmp/common/constant/CommonConstant.java
  14. 2 0
      dmp-comp/dmp-digital-starter/src/main/java/com/persagy/dmp/basic/constant/DigitalMessageConstant.java
  15. 2 0
      dmp-comp/dmp-digital-starter/src/main/java/com/persagy/dmp/define/entity/ObjectInfoDefine.java
  16. 2 0
      dmp-comp/dmp-digital-starter/src/main/java/com/persagy/dmp/define/entity/ObjectTypeDefine.java
  17. 35 0
      docker/dockerfiles/dmp-rwd-plus/Dockerfile
  18. 3 0
      docker/dockerfiles/dmp-rwd-plus/entrypoint.sh
  19. 76 0
      docker/k8sfiles/dmp-rwd-plus-standard.yml
  20. 75 0
      docker/k8sfiles/dmp-rwd-plus.yml

+ 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-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/digital/service/impl/ObjectDigitalServiceImpl.java

@@ -155,7 +155,7 @@ public class ObjectDigitalServiceImpl extends ServiceImpl<ObjectDigitalMapper, O
      */
     private void ensureUpdateInfos(ObjectDigital vo, ObjectDigital dbVO, Set<String> removeColumns) {
         // 获取对象属性,不需要处理基类属性
-        Field[] fields = ReflectUtil.getFieldsDirectly(ObjectDigital.class, false);
+        Field[] fields = ReflectUtil.getFields(ObjectDigital.class);
         // 按属性处理
         for(Field field:fields) {
             Object fieldValue = ReflectUtil.getFieldValue(vo, field);

File diff suppressed because it is too large
+ 34944 - 32786
dmp-business/dmp-rwd/src/main/resources/db/init/data.sql


+ 2 - 0
dmp-business/dmp-rwd/src/main/resources/db/init/schema.sql

@@ -12,6 +12,7 @@ CREATE TABLE IF NOT EXISTS `dt_define_type` (
   `equipment_code` varchar(40) DEFAULT NULL COMMENT '设备编码,上级类型是部件时该字段有值,值为设备类型的code',
   `parent_code` varchar(40) DEFAULT NULL COMMENT '上级类型code,默认为"0"',
   `version` varchar(40) DEFAULT NULL COMMENT '最后修改版本',
+  `source_from` tinyint DEFAULT 1 NOT NULL COMMENT '类型来源,0-common',
   `creator` varchar(32) DEFAULT NULL COMMENT '创建人',
   `creation_time` char(14) NULL DEFAULT NULL COMMENT '创建时间',
   `modifier` varchar(32) DEFAULT NULL COMMENT '最后修改人',
@@ -52,6 +53,7 @@ CREATE TABLE IF NOT EXISTS `dt_define_info` (
   `weak_point` int(11) DEFAULT NULL COMMENT '虚点',
   `show_order` int(11) DEFAULT NULL COMMENT '显示顺序',
   `version` varchar(40) DEFAULT NULL COMMENT '最后修改版本',
+  `source_from` tinyint DEFAULT 1 NOT NULL COMMENT '信息点来源,0-common',
   `creator` varchar(32) DEFAULT NULL COMMENT '创建人',
   `creation_time` char(14) NULL DEFAULT NULL COMMENT '创建时间',
   `modifier` varchar(32) DEFAULT NULL COMMENT '最后修改人',

+ 2 - 2
dmp-business/dmp-rwd/src/main/resources/mapper/DefineInfoMapper.xml

@@ -21,7 +21,7 @@
           dt_define_info.remark,dt_define_info.sub_flag,
           dt_define_info.weak_point,dt_define_info.show_order,dt_define_info.version,dt_define_info.creator,
           dt_define_info.creation_time,dt_define_info.modifier,dt_define_info.modified_time,
-          dt_define_info.valid,dt_define_info.ts
+          dt_define_info.valid,dt_define_info.ts, dt_define_info.source_from
     </sql>
     <!--
         1. 如果为基础类型、且为平台级,优先级100
@@ -102,7 +102,7 @@
             sum(case when category != 'STATIC' and info_value is not null then 1 else 0 end) as dynamic_value_num
         from (
             select dt_object.id, dt_object.local_id, dt_object.local_name, dt_define_info.class_code, dt_define_type.name as class_name,
-            dt_define_info.code, dt_define_info.name,dt_define_info.first_tag, dt_define_info.data_type,dt_define_info.category,
+            dt_define_info.code, dt_define_info.name,dt_define_info.first_tag, dt_define_info.data_type,dt_define_info.category,dt_define_info.source_from,
             json_unquote(json_extract(dt_object.infos, concat('$.', dt_define_info.code))) as info_value
             from ( <include refid="InfoTableSQL"/> ) dt_define_info
             inner join dt_define_type on dt_define_info.class_code = dt_define_type.code and dt_define_type.valid = 1

+ 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 */

+ 2 - 0
dmp-comp/dmp-digital-starter/src/main/java/com/persagy/dmp/define/entity/ObjectInfoDefine.java

@@ -80,4 +80,6 @@ public class ObjectInfoDefine extends AuditableEntity {
     private Long showOrder;
     /** 版本 */
     private String version;
+    /** 信息点来源  0-common */
+    private Integer sourceFrom;
 }

+ 2 - 0
dmp-comp/dmp-digital-starter/src/main/java/com/persagy/dmp/define/entity/ObjectTypeDefine.java

@@ -55,4 +55,6 @@ public class ObjectTypeDefine extends AuditableEntity {
     private String parentCode;
     /** 版本 */
     private String version;
+    /** 类型来源  0-common */
+    private Integer sourceFrom;
 }

+ 35 - 0
docker/dockerfiles/dmp-rwd-plus/Dockerfile

@@ -0,0 +1,35 @@
+#构建此镜像的基础镜像
+FROM registry.persagy.com/base/centos:v-jdk1.8
+#指定作者名称
+MAINTAINER lijie<lijie@persagy.com>
+
+#定义标签属性
+LABEL tier=backend
+LABEL product=dmp
+LABEL project=dmp-rwd-plus
+LABEL name=bdtp-rwd
+
+#设置环境变量
+ENV JAVA_OPTS -Dfile.encoding=UTF-8 -Xms2048m -Xmx2048m
+ENV TZ Asia/Shanghai
+#ARG 可以接收docker build命令中以--build-arg 指定的参数
+ARG WORKER_HOME
+
+#执行的命令
+RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime	&& echo 'Asia/Shanghai' > /etc/timezone
+
+RUN mkdir -p $WORKER_HOME/config
+
+#复制文件到容器内
+COPY *.jar $WORKER_HOME/app.jar
+COPY entrypoint.sh $WORKER_HOME/
+COPY version.txt $WORKER_HOME/
+COPY config $WORKER_HOME/config
+#设置工作目录
+WORKDIR $WORKER_HOME
+
+#查看上述复制的文件,是否复制成功
+RUN ls
+
+#启动执行
+ENTRYPOINT ["sh","./entrypoint.sh"]

+ 3 - 0
docker/dockerfiles/dmp-rwd-plus/entrypoint.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+echo "entrypoint run..."
+java -jar $JAVA_OPTS -Dfile.encoding=UTF-8 -Dconsole.encoding=UTF-8 -Dfile.encoding=UTF-8 -Dconsole.encoding=UTF-8 -Dserver.port=$SERVER_PORT -Deureka.client.service-url.defaultZone=$EUREKA_CLIENT_DEFAULT_ZONE -Dspring.cloud.config.profile=$SPRING_CLOUD_CONFIG_PROFILE -Dspring.cloud.config.uri=$SPRING_CLOUD_CONFIG_URI app.jar

+ 76 - 0
docker/k8sfiles/dmp-rwd-plus-standard.yml

@@ -0,0 +1,76 @@
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: dmp-rwd-plus
+  labels:
+    app: dmp-rwd-plus
+spec:
+  selector:
+    app: dmp-rwd-plus
+  ports:
+  - port: 8080
+    targetPort: 8080
+    name: server-port
+
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: dmp-rwd-plus
+spec:
+  replicas: 1
+  selector:
+    matchLabels:
+      app: dmp-rwd-plus
+  template:
+    metadata:
+      labels:
+        app: dmp-rwd-plus
+    spec:
+      containers:
+      - name: dmp-rwd-plus
+        image: labisenlin.persagy.com/library/dmp-rwd-plus:latest
+        imagePullPolicy: Always
+        ports:
+        - containerPort: 8080
+          name: server-port
+        env:
+        - name: TZ
+          value: Asia/Shanghai
+        - name: SERVER_PORT
+          value: "8080"
+        - name: SPRING_CLOUD_CONFIG_URI
+          value: "http://integrated-config:8080"
+        - name: SPRING_PROFILES_ACTIVE
+          value: "dev"
+        - name: SPRING_CLOUD_CONFIG_PROFILE
+          value: "dev"
+        - name: EUREKA_CLIENT_DEFAULT_ZONE
+          value: "http://frame:123456@integrated-eureka:8080/integrated-eureka/eureka/"
+        - name: logging.config
+          value: classpath:logback-spring.xml
+        - name: eureka.instance.status-page-url
+          value: "http://${eureka.instance.ip-address}:${eureka.instance.non-secure-port}/${spring.application.name}/info"
+        - name: eureka.instance.non-secure-port-enabled
+          value: "true"
+        - name: eureka.instance.ip-address
+          value: "dmp-rwd-plus"
+        - name: eureka.instance.health-check-url
+          value: "http://${eureka.instance.ip-address}:${eureka.instance.non-secure-port}/${spring.application.name}/health"
+        - name: eureka.instance.non-secure-port
+          value: "8080"
+        - name: persagy.common.auth.channel
+          value: "1"
+        - name: saas.ems.web.service
+          value: "http://ems-saas-web:8080"
+        - name: mybatis-plus.configuration.log-impl
+          value: "org.apache.ibatis.logging.nologging.NoLoggingImpl"
+        volumeMounts:
+          - mountPath: /mnt/persagy/dmp-rwd-plus/config/data.sql
+            name: nfs-pvc
+            subPath: dmp-rwd-plus/data.sql
+      volumes:
+        - name: nfs-pvc
+          persistentVolumeClaim:
+            claimName: pv-oss-bdtp

+ 75 - 0
docker/k8sfiles/dmp-rwd-plus.yml

@@ -0,0 +1,75 @@
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: dmp-rwd-plus
+  labels:
+    app: dmp-rwd-plus
+spec:
+  selector:
+    app: dmp-rwd-plus
+
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: dmp-rwd-plus
+spec:
+  replicas: 1
+  selector:
+    matchLabels:
+      app: dmp-rwd-plus
+  template:
+    metadata:
+      labels:
+        app: dmp-rwd-plus
+    spec:
+      containers:
+      - name: dmp-rwd-plus
+        image: labisenlin.persagy.com/library/dmp-rwd-plus:v1.0.0
+        imagePullPolicy: Always
+        resources:
+          limits:
+            memory: 2Gi
+          requests:
+            memory: 512Mi
+        env:
+        - name: TZ
+          value: Asia/Shanghai
+        - name: SERVER_PORT
+          value: "8117"
+        - name: SPRING_CLOUD_CONFIG_URI
+          valueFrom:
+            configMapKeyRef:
+              name: dmp-rwd-plus
+              key: spring.cloud.config.uri
+        - name: SPRING_PROFILES_ACTIVE
+          valueFrom:
+            configMapKeyRef:
+              name: dmp-rwd-plus
+              key: spring.profiles.active
+        - name: SPRING_CLOUD_CONFIG_PROFILE
+          valueFrom:
+            configMapKeyRef:
+              name: dmp-rwd-plus
+              key: spring.cloud.config.profile
+        - name: EUREKA_CLIENT_FETCH_REGISTRY
+          valueFrom:
+            configMapKeyRef:
+              name: dmp-rwd-plus
+              key: eureka.client.fetch-registry
+        - name: EUREKA_CLIENT_REGISTER_WITH_EUREKA
+          valueFrom:
+            configMapKeyRef:
+              name: dmp-rwd-plus
+              key: eureka.client.register-with-eureka
+        - name: EUREKA_CLIENT_DEFAULT_ZONE
+          valueFrom:
+            configMapKeyRef:
+              name: dmp-rwd-plus
+              key: eureka.client.default.zone
+        - name: EUREKA_INSTANCE_IP_ADDRESS
+          valueFrom:
+            configMapKeyRef:
+              name: dmp-rwd-plus
+              key: eureka.instance.ip.address