dengsixing 3 년 전
부모
커밋
975a9e4a07

+ 8 - 1
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/ConstantFilePath.java

@@ -12,6 +12,8 @@ public class ConstantFilePath {
     public static final String TEMP_IMAGES_PATH = "/mnt/4Dkankan/temp/upload/image/";
     // 场景
     public static final String SCENE_PATH = "/mnt/4Dkankan/scene/";
+    // 场景
+    public static final String SCENE_v4_PATH = "/mnt/4Dkankan/scene_v4/";
     // 代理商
     public static final String AGENT_PATH = "/mnt/4Dkankan/agent/";
     //电子发票
@@ -66,10 +68,15 @@ public class ConstantFilePath {
     public static final String TOURLIST_FOLDER_PATH_FORMAT = SCENE_PATH + "data/data%s/" + ConstantFileName.TOURLIST_FOLDER;
 
     /**
-     * 漫游文件路径
+     * scenejson文件本地路径
      */
     public static final String SCENE_PATH_FORMAT = DATABUFFER_FORMAT + ConstantFileName.SCENE_JSON;
 
+    /**
+     * scenejson文件本地路径 V4
+     */
+    public static final String SCENE_JSON_V4_PATH = SCENE_v4_PATH + "data/data%s/" + ConstantFileName.SCENE_JSON;
+
     public static final String MEDIAINFO_PATH_FORMAT = DATABUFFER_FORMAT + ConstantFileName.MEDIA_DATAFILE;
 
     public void setHardDiskLaser(String value){

+ 4 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/ErrorCode.java

@@ -141,6 +141,7 @@ public enum ErrorCode {
     FAILURE_CODE_5059(5059, "该压缩包无可用obj或者mtl文件"),
     FAILURE_CODE_5060(5060, "obj文件名应为mesh.obj"),
     FAILURE_CODE_5061(5061, "该压缩包无可用jpg文件"),
+    FAILURE_CODE_5062(5062, "无可用jpg文件"),
 
 
     FAILURE_CODE_7001(7001, "激光场景状态同步失败,请重试!"),
@@ -159,6 +160,9 @@ public enum ErrorCode {
     FAILURE_CODE_7014(7014, "压缩包中文件不能为空"),
     FAILURE_CODE_7015(7015, "仅支持.zip文件上传"),
     FAILURE_CODE_7016(7016, "仅支持.mp4格式文件"),
+    FAILURE_CODE_7017(7017, "场景同步失败"),
+    FAILURE_CODE_7018(7018, "压缩包内请勿包含文件夹"),
+
 
 
 

+ 5 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/exception/BusinessException.java

@@ -33,4 +33,9 @@ public class BusinessException extends RuntimeException {
         this.code = serverCode.code();
         this.message = serverCode.formatMessage(args);
     }
+
+    public BusinessException(ErrorCode errorCode, Object...args){
+        this.code = errorCode.code();
+        this.message = errorCode.formatMessage(args);
+    }
 }

+ 2 - 2
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/CreateObjUtil.java

@@ -307,7 +307,7 @@ public class CreateObjUtil {
 			JsonFormat.merge(jsonFormat, builder);
 			byte[] buf= builder.build().toByteArray();
 			
-			 //把序列化后的数据写入本地磁盘  
+			//把序列化后的数据写入本地磁盘
 	        ByteArrayInputStream stream = new ByteArrayInputStream(buf);  
 	        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径  
 	        BufferedInputStream bis = new BufferedInputStream(stream);  
@@ -612,7 +612,7 @@ public class CreateObjUtil {
 	}
 
 	public static void main(String[] args) throws Exception{
-		CreateObjUtil.convertTxtToVisionmodeldata("F:\\visiontest\\vision.txt", "F:\\visiontest\\vision.modeldata");
+		CreateObjUtil.convertTxtToVisionmodeldata("F:\\visiontest\\KJ-HXMNTDYs1E(2)(1).txt", "F:\\visiontest\\vision.modeldata");
 //		CreateObjUtil.convertTxtToDam("F:\\visiontest\\modeldata.txt", "F:\\visiontest\\dacf7dfa24ae47fab8fcebfe4dc41ab9_50k.dam");
 
 //		String text = "web:web";

+ 6 - 1
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/FileUtil.java

@@ -1,5 +1,6 @@
 package com.fdkankan.common.util;
 
+import cn.hutool.core.collection.CollUtil;
 import com.fdkankan.common.constant.ErrorCode;
 import com.fdkankan.common.exception.BusinessException;
 import java.io.*;
@@ -272,7 +273,11 @@ public class FileUtil {
 				list.add(files[i].getAbsolutePath());
 			} else {
 				System.out.println("目录:" + files[i]);
-				list.addAll(getFileList(files[i].getAbsolutePath()));
+				List<String> fileList = getFileList(files[i].getAbsolutePath());
+				if(CollUtil.isEmpty(fileList)){
+					continue;
+				}
+				list.addAll(fileList);
 			}
 		}
 

+ 29 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/TestUtil.java

@@ -0,0 +1,29 @@
+package com.fdkankan.common.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>
+ * TODO
+ * </p>
+ *
+ * @author dengsixing
+ * @since 2022/4/14
+ **/
+public class TestUtil {
+
+    public static String hostName = "aaa";
+
+    public static List<String> residenceServiceHostName = new ArrayList<>();
+
+    static{
+        residenceServiceHostName.add("aaa");
+        residenceServiceHostName.add("bbb");
+    }
+
+    public static void main(String[] args) {
+        System.out.println(residenceServiceHostName.contains(hostName));
+    }
+
+}

+ 1 - 0
4dkankan-utils-mq/src/main/java/com/fdkankan/mq/util/RocketMQProducer.java

@@ -6,6 +6,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.rocketmq.client.producer.SendCallback;
 import org.apache.rocketmq.client.producer.SendResult;
 import org.apache.rocketmq.spring.core.RocketMQTemplate;
+import org.apache.rocketmq.spring.support.RocketMQUtil;
 import org.springframework.messaging.Message;
 import org.springframework.messaging.support.MessageBuilder;
 import org.springframework.stereotype.Component;

+ 36 - 0
4dkankan-utils-rabbitmq/pom.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>4dkankan-utils</artifactId>
+    <groupId>com.fdkankan</groupId>
+    <version>2.0.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>4dkankan-utils-rabbitmq</artifactId>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-amqp</artifactId>
+      <version>2.3.12.RELEASE</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>8</source>
+          <target>8</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+
+</project>

+ 38 - 0
4dkankan-utils-rabbitmq/src/main/java/com/fdkankan/rabbitmq/callback/ProducerCallback.java

@@ -0,0 +1,38 @@
+package com.fdkankan.rabbitmq.callback;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.core.Message;
+import org.springframework.amqp.rabbit.connection.CorrelationData;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.stereotype.Component;
+
+/**
+ * <p>
+ * TODO
+ * </p>
+ *
+ * @author dengsixing
+ * @since 2022/4/19
+ **/
+@Slf4j
+@Component
+public class ProducerCallback implements RabbitTemplate.ConfirmCallback,RabbitTemplate.ReturnCallback {
+
+    //confirms模式:无论exchange投递消息是成功或是失败,都会返回ack,我们可以根据返回的ack是成功还是失败,做相应的业务处理
+    @Override
+    public void confirm(CorrelationData correlationData, boolean b, String s) {
+        //投递成功
+        if(b){
+            log.info("消息投递成功,id:{}", correlationData.getId());
+            return;
+        }
+        //投递失败
+        log.error("消息投递失败,id:{}", correlationData.getId());
+    }
+
+    //return模式:只有exchange投递消息失败时,才会执行回调函数,来做一些相应的业务处理
+    @Override
+    public void returnedMessage(Message message, int i, String s, String s1, String s2) {
+
+    }
+}

+ 41 - 0
4dkankan-utils-rabbitmq/src/main/java/com/fdkankan/rabbitmq/config/ExchangeConfig.java

@@ -0,0 +1,41 @@
+package com.fdkankan.rabbitmq.config;
+
+import com.fdkankan.rabbitmq.constant.RabbitMQConstant;
+import org.springframework.amqp.core.DirectExchange;
+import org.springframework.amqp.core.FanoutExchange;
+import org.springframework.amqp.core.TopicExchange;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class ExchangeConfig {
+
+    /**
+     * 交换机说明:
+     * durable="true" rabbitmq重启的时候不需要创建新的交换机
+     * auto-delete 表示交换机没有在使用时将被自动删除 默认是false
+     * direct交换器相对来说比较简单,匹配规则为:如果路由键匹配,消息就被投送到相关的队列
+     * topic交换器你采用模糊匹配路由键的原则进行转发消息到队列中
+     * fanout交换器中没有路由键的概念,他会把消息发送到所有绑定在此交换器上面的队列中。
+     */
+    @Bean(name = RabbitMQConstant.EXCHANGE_DIRECT)
+    public DirectExchange directExchange() {
+        return new DirectExchange(RabbitMQConstant.EXCHANGE_DIRECT, true, false);
+    }
+
+    @Bean(name = RabbitMQConstant.EXCHANGE_WORK)
+    public DirectExchange workExchange() {
+        return new DirectExchange(RabbitMQConstant.EXCHANGE_WORK, true, false);
+    }
+
+    @Bean(name = RabbitMQConstant.EXCHANGE_TOPIC)
+    public TopicExchange topicExchange() {
+        return new TopicExchange(RabbitMQConstant.EXCHANGE_TOPIC, true, false);
+    }
+
+    @Bean(name = RabbitMQConstant.EXCHANGE_FANOUT)
+    public FanoutExchange fanoutExchange() {
+        return new FanoutExchange(RabbitMQConstant.EXCHANGE_FANOUT, true, false);
+    }
+
+}

+ 28 - 0
4dkankan-utils-rabbitmq/src/main/java/com/fdkankan/rabbitmq/config/ModelingQueueConfig.java

@@ -0,0 +1,28 @@
+package com.fdkankan.rabbitmq.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * <p>
+ * TODO
+ * </p>
+ *
+ * @author dengsixing
+ * @since 2022/4/19
+ **/
+@Component
+@EnableConfigurationProperties(ModelingQueueConfig.class)
+@ConfigurationProperties(prefix = "queue.modeling")
+@Data
+public class ModelingQueueConfig {
+
+    public String modelingPre;
+
+    public String modelingPost;
+
+    public String modelingCall;
+
+}

+ 49 - 0
4dkankan-utils-rabbitmq/src/main/java/com/fdkankan/rabbitmq/config/QueueConfig.java

@@ -0,0 +1,49 @@
+package com.fdkankan.rabbitmq.config;
+
+import com.fdkankan.rabbitmq.constant.RabbitMQConstant;
+import org.springframework.amqp.core.Queue;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class QueueConfig {
+
+    /**
+     * durable="true" 持久化 rabbitmq重启的时候不需要创建新的队列
+     * exclusive 表示该消息队列是否只在当前connection生效,默认是false
+     * auto-delete 表示消息队列没有在使用时将被自动删除 默认是false
+     */
+//
+//    @Bean(name = RabbitMQConstant.QUEUE_EASY)
+//    public Queue easyQueue() {
+//        return new Queue(RabbitMQConstant.QUEUE_EASY, true, false, false);
+//    }
+
+//    @Bean(name = RabbitMQConstant.QUEUE_WORK)
+//    public Queue workQueue() {
+//        return new Queue(RabbitMQConstant.QUEUE_WORK, true, false, false);
+//    }
+
+//    @Bean(name = RabbitMQConstant.QUEUE_TOPIC_FIRST)
+//    public Queue topicQueue() {
+//        return new Queue(RabbitMQConstant.QUEUE_TOPIC_FIRST, true, false, false);
+//    }
+//
+//    @Bean(name = RabbitMQConstant.QUEUE_TOPIC_SECOND)
+//    public Queue topicQueueSecond() {
+//        return new Queue(RabbitMQConstant.QUEUE_TOPIC_SECOND, true, false, false);
+//    }
+//
+//    @Bean(name = RabbitMQConstant.QUEUE_FANOUT)
+//    public Queue fanoutQueue() {
+//        return new Queue(RabbitMQConstant.QUEUE_FANOUT, true, false, false);
+//    }
+//
+//    @Bean(name = RabbitMQConstant.QUEUE_FANOUT_SECOND)
+//    public Queue fanoutQueueSecond() {
+//        return new Queue(RabbitMQConstant.QUEUE_FANOUT_SECOND, true, false, false);
+//    }
+
+
+}

+ 120 - 0
4dkankan-utils-rabbitmq/src/main/java/com/fdkankan/rabbitmq/config/RabbitMqConfig.java

@@ -0,0 +1,120 @@
+package com.fdkankan.rabbitmq.config;
+
+import com.fdkankan.rabbitmq.callback.ProducerCallback;
+import com.fdkankan.rabbitmq.constant.RabbitMQConstant;
+import javax.annotation.Resource;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.core.Binding;
+import org.springframework.amqp.core.BindingBuilder;
+import org.springframework.amqp.rabbit.connection.ConnectionFactory;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@Slf4j
+public class RabbitMqConfig {
+
+    @Resource
+    private QueueConfig queueConfig;
+    @Resource
+    private ExchangeConfig exchangeConfig;
+    /**
+     * 连接工厂
+     */
+    @Resource
+    private ConnectionFactory connectionFactory;
+
+    @Resource
+    private ProducerCallback producerCallback;
+
+
+    /**
+     * 指定序列化转换器,否则mq消息存进去
+     * @return
+     */
+    @Bean
+    public Jackson2JsonMessageConverter messageConverter(){
+        return new Jackson2JsonMessageConverter();
+    }
+
+
+    /**
+     * 将消息队列和交换机进行绑定,指定路由
+     */
+//    @Bean
+//    public Binding bindingDirect() {
+//        return BindingBuilder.bind(queueConfig.easyQueue()).to(exchangeConfig.directExchange()).with(RabbitMQConstant.ROUTING_KEY_EASY);
+//    }
+//
+//    @Bean
+//    public Binding bindingWork() {
+//        return BindingBuilder.bind(queueConfig.workQueue()).to(exchangeConfig.workExchange()).with(RabbitMQConstant.ROUTING_KEY_WORK);
+//    }
+//
+//    @Bean
+//    public Binding bindingTopic() {
+//        return BindingBuilder.bind(queueConfig.topicQueue()).to(exchangeConfig.topicExchange()).with(RabbitMQConstant.ROUTING_KEY_TOPIC_FIRST);
+//    }
+//
+//    @Bean
+//    public Binding bindingTopicSecond() {
+//        return BindingBuilder.bind(queueConfig.topicQueueSecond()).to(exchangeConfig.topicExchange()).with(RabbitMQConstant.ROUTING_KEY_TOPIC_SECOND);
+//    }
+//
+//    @Bean
+//    public Binding bindingFanout() {
+//        return BindingBuilder.bind(queueConfig.fanoutQueue()).to(exchangeConfig.fanoutExchange());
+//    }
+//
+//    @Bean
+//    public Binding bindingFanoutSecond() {
+//        return BindingBuilder.bind(queueConfig.fanoutQueueSecond()).to(exchangeConfig.fanoutExchange());
+//    }
+
+    /** ======================== 定制一些处理策略 =============================*/
+
+    /**
+     * 定制化amqp模版
+     * <p>
+     * Rabbit MQ的消息确认有两种。
+     * <p>
+     * 一种是消息发送确认:这种是用来确认生产者将消息发送给交换机,交换机传递给队列过程中,消息是否成功投递。
+     * 发送确认分两步:一是确认是否到达交换机,二是确认是否到达队列
+     * <p>
+     * 第二种是消费接收确认:这种是确认消费者是否成功消费了队列中的消息。
+     */
+    @Bean
+    public RabbitTemplate rabbitTemplate() {
+        RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
+        // 消息发送失败返回到队列中, yml需要配置 publisher-returns: true
+//        rabbitTemplate.setMandatory(true);
+
+        /**
+         * 使用该功能需要开启消息确认,yml需要配置 publisher-confirm-type: correlated:表示消息成功到达Broker后触发ConfirmCalllBack回调
+         * 通过实现ConfirmCallBack接口,用于实现消息发送到交换机Exchange后接收ack回调
+         * correlationData  消息唯一标志
+         * ack              确认结果
+         *
+         * cause            失败原因
+         */
+        rabbitTemplate.setConfirmCallback(producerCallback);
+
+        /**
+         * 使用该功能需要开启消息返回确认,yml需要配置 publisher-returns: true
+         * 通过实现ReturnCallback接口,如果消息从交换机发送到对应队列失败时触发
+         * message    消息主体 message
+         * replyCode  消息主体 message
+         * replyText  描述
+         * exchange   消息使用的交换机
+         * routingKey 消息使用的路由键
+         */
+//        rabbitTemplate.setReturnCallback(new ProducerCallback());
+
+
+        return rabbitTemplate;
+    }
+
+}

+ 32 - 0
4dkankan-utils-rabbitmq/src/main/java/com/fdkankan/rabbitmq/constant/RabbitMQConstant.java

@@ -0,0 +1,32 @@
+package com.fdkankan.rabbitmq.constant;
+
+public class RabbitMQConstant {
+
+    //简单模式
+    public static final String QUEUE_EASY = "easy.queue";
+    //work模式
+    public static final String QUEUE_WORK = "work.queue";
+    //topic模式
+    public static final String QUEUE_TOPIC_FIRST = "topic.queue.first";
+    public static final String QUEUE_TOPIC_SECOND = "topic.queue.second";
+    //发布订阅模式
+    public static final String QUEUE_FANOUT = "fanout.queue";
+    public static final String QUEUE_FANOUT_SECOND = "fanout.queue.second";
+
+    //路由key
+    public static final String ROUTING_KEY_EASY = "routing.key.easy";
+    public static final String ROUTING_KEY_WORK = "routing.key.work";
+    public static final String ROUTING_KEY_TOPIC_FIRST = "routing.key.topic.first";
+    public static final String ROUTING_KEY_TOPIC_SECOND = "routing.key.topic.second";
+
+
+    // direct交换机
+    public static final String EXCHANGE_DIRECT = "direct_exchange";
+    // work交换机
+    public static final String EXCHANGE_WORK = "work_exchange";
+    // topic交换机
+    public static final String EXCHANGE_TOPIC = "topic_exchange";
+    // fanout交换机
+    public static final String EXCHANGE_FANOUT = "fanout_exchange";
+
+}

+ 37 - 0
4dkankan-utils-rabbitmq/src/main/java/com/fdkankan/rabbitmq/util/RabbitMqProducer.java

@@ -0,0 +1,37 @@
+package com.fdkankan.rabbitmq.util;
+
+import com.fdkankan.rabbitmq.config.ModelingQueueConfig;
+import java.util.UUID;
+import org.springframework.amqp.rabbit.connection.CorrelationData;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * <p>
+ * TODO
+ * </p>
+ *
+ * @author dengsixing
+ * @since 2022/4/19
+ **/
+@Component
+public class RabbitMqProducer {
+
+    @Autowired
+    ModelingQueueConfig modelingQueueConfig;
+
+    @Autowired
+    private RabbitTemplate rabbitTemplate;
+
+    /**
+     * 工作队列模式发送
+     */
+    public void sendByWorkQueue(String queue, Object content){
+        CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
+        rabbitTemplate.convertAndSend(queue, content, correlationId);
+    }
+
+
+
+}

+ 8 - 0
pom.xml

@@ -14,6 +14,7 @@
         <module>4dkankan-utils-dingtalk</module>
         <module>4dkankan-utils-mongodb</module>
         <module>4dkankan-utils-email</module>
+        <module>4dkankan-utils-rabbitmq</module>
     </modules>
 
     <groupId>com.fdkankan</groupId>
@@ -61,6 +62,13 @@
     <dependencyManagement>
         <dependencies>
             <dependency>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-dependencies</artifactId>
+                <version>2.3.12.RELEASE</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+            <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-core</artifactId>
                 <version>5.2.15.RELEASE</version>