6个文件已删除
4 文件已重命名
16个文件已添加
8个文件已修改
| | |
| | | <scope>runtime</scope> |
| | | <optional>true</optional> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-configuration-processor</artifactId> |
| | | <optional>true</optional> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.projectlombok</groupId> |
| File was renamed from component/component-Influxdb/src/main/java/com/zy/influxdb/config/InfluxDBAutoConfiguration.java |
| | |
| | | package com.zy.influxdb.config; |
| | | package com.zy.component.influxdb.config; |
| | | |
| | | import com.influxdb.v3.client.InfluxDBClient; |
| | | import com.zy.component.influxdb.properties.InfluxDBProperties; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| File was renamed from component/component-Influxdb/src/main/java/com/zy/influxdb/config/InfluxDBProperties.java |
| | |
| | | package com.zy.influxdb.config; |
| | | package com.zy.component.influxdb.properties; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| File was renamed from component/component-Influxdb/src/main/java/com/zy/influxdb/service/InfluxDBService.java |
| | |
| | | package com.zy.influxdb.service; |
| | | package com.zy.component.influxdb.service; |
| | | |
| | | import com.influxdb.v3.client.InfluxDBClient; |
| | | import com.influxdb.v3.client.Point; |
| | | import com.influxdb.v3.client.write.WritePrecision; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | try { |
| | | // 执行查询 |
| | | Stream<Object[]> query = influxDBClient.query(sql); |
| | | logger.info("查询数据:{}", query); |
| | | // 转换为 Map 列表(便于后续处理) |
| | | List<Map<String, Object>> collect = query.map(record -> { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| New file |
| | |
| | | { |
| | | "properties": [ |
| | | { |
| | | "name": "influxdb3.enabled", |
| | | "type": "java.lang.Boolean", |
| | | "description": "Enables influxdb functionality.", |
| | | "defaultValue": "true" |
| | | } |
| | | ] |
| | | } |
| | |
| | | com.zy.influxdb.service.InfluxDBService |
| | | |
| | | org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.zy.component.influxdb.service.InfluxDBService |
| New file |
| | |
| | | { |
| | | "properties": [ |
| | | { |
| | | "name": "influxdb3.enabled", |
| | | "type": "java.lang.Boolean", |
| | | "description": "Enables influxdb functionality.", |
| | | "defaultValue": "true" |
| | | } |
| | | ] |
| | | } |
| | |
| | | "sourceType": "com.zy.influxdb.config.InfluxDBProperties" |
| | | }, |
| | | { |
| | | "name": "influxdb3.enabled", |
| | | "type": "java.lang.Boolean", |
| | | "description": "Enables mqtt functionality.", |
| | | "defaultValue": "true" |
| | | }, |
| | | { |
| | | "name": "influxdb3.token", |
| | | "type": "java.lang.String", |
| | | "description": "token", |
| | |
| | | com.zy.influxdb.service.InfluxDBService |
| | | |
| | | org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.zy.component.influxdb.service.InfluxDBService |
| New file |
| | |
| | | artifactId=component-Influxdb |
| | | groupId=com.zy |
| | | version=1.0.0 |
| New file |
| | |
| | | com\zy\component\influxdb\service\InfluxDBService.class |
| | | com\zy\component\influxdb\properties\InfluxDBProperties.class |
| | | com\zy\component\influxdb\config\InfluxDBAutoConfiguration.class |
| New file |
| | |
| | | D:\office\code\rcs-flow\component\component-Influxdb\src\main\java\com\zy\influxdb\config\InfluxDBProperties.java |
| | | D:\office\code\rcs-flow\component\component-Influxdb\src\main\java\com\zy\influxdb\service\InfluxDBService.java |
| | | D:\office\code\rcs-flow\component\component-Influxdb\src\main\java\com\zy\influxdb\config\InfluxDBAutoConfiguration.java |
| | |
| | | if (job != null) { |
| | | Integer workNo = staProtocol.getWorkNo(); |
| | | Integer targetSta = inSta.getTargetSta(); |
| | | // staProtocol.setWorkNo(0); |
| | | // staProtocol.setStaNo(0); |
| | | // MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol)); |
| | | // Thread.sleep(1500L); |
| | | staProtocol.setWorkNo(0); |
| | | staProtocol.setStaNo(0); |
| | | MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol)); |
| | | Thread.sleep(1500L); |
| | | staProtocol.setWorkNo(workNo); |
| | | staProtocol.setStaNo(targetSta); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol)); |
| | |
| | | <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> |
| | | <spring-boot.version>2.5.3</spring-boot.version> |
| | | <fastjson.version>1.2.58</fastjson.version> |
| | | <!-- Dependency Versions --> |
| | | <influxdb-java.version>1.7.0</influxdb-java.version> |
| | | </properties> |
| | | |
| | | |
| | |
| | | <artifactId>acs-common</artifactId> |
| | | <version>1.0.0</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.zy</groupId> |
| | | <artifactId>component-Influxdb</artifactId> |
| | | <version>1.0.0</version> |
| | | </dependency> |
| | | |
| | | <!-- SpringBoot Web --> |
| | | <dependency> |
| | |
| | | |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import org.springframework.context.annotation.ComponentScan; |
| | | |
| | | @ComponentScan(basePackages = {"com.zy.component","com.zy.acs"}) |
| | | @SpringBootApplication |
| | | public class HexApplication { |
| | | |
| New file |
| | |
| | | package com.zy.acs.hex.config; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.amqp.rabbit.connection.CachingConnectionFactory; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | @Slf4j |
| | | @Configuration |
| | | public class RabbitConfig { |
| | | |
| | | @Bean |
| | | public RabbitTemplate rabbitTemplate(CachingConnectionFactory connectionFactory) { |
| | | RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory); |
| | | rabbitTemplate.setConfirmCallback((correlationData, ack, cause) -> { |
| | | if (ack) { |
| | | log.info("消息成功发送到Exchange"); |
| | | } else { |
| | | log.info("消息发送失败:" + cause); |
| | | } |
| | | }); |
| | | // 也可以设置返回类型为mandatory,这样当消息无法路由到任何队列时,会返回给生产者一个Basic.Return。 |
| | | rabbitTemplate.setMandatory(true); |
| | | rabbitTemplate.setReturnCallback((message, replyCode, replyText, exchange, routingKey) -> { |
| | | log.info("消息无法路由到队列: " + replyText); |
| | | }); |
| | | return rabbitTemplate; |
| | | } |
| | | |
| | | } |
| File was renamed from zy-acs-hex/src/main/java/com/zy/acs/hex/config/RabbitMQConfig.java |
| | |
| | | package com.zy.acs.hex.config; |
| | | |
| | | |
| | | import org.springframework.amqp.core.*; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | package com.zy.acs.hex.constant; |
| | | |
| | | |
| | | /** |
| | |
| | | * |
| | | * @author ken |
| | | */ |
| | | @Configuration |
| | | public class RabbitMQConfig { |
| | | |
| | | public class RabbitConstant { |
| | | |
| | | public static final String DURABLE = "true"; |
| | | |
| | | public static final String TOPIC_EXCHANGE_TYPE = "topic"; |
| | | |
| | | // ========================== 主题模式 ========================== |
| | | /** |
| New file |
| | |
| | | package com.zy.acs.hex.consumer; |
| | | |
| | | import com.rabbitmq.client.Channel; |
| | | import com.zy.acs.hex.constant.RabbitConstant; |
| | | import com.zy.acs.hex.consumer.listener.AbstractListener; |
| | | import com.zy.component.influxdb.service.InfluxDBService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.amqp.rabbit.annotation.*; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.amqp.support.AmqpHeaders; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.messaging.handler.annotation.Header; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * 消费者 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | @RabbitListener(bindings = @QueueBinding( |
| | | value = @Queue(name = RabbitConstant.TOPIC_QUEUE_DOWN, durable = RabbitConstant.DURABLE), |
| | | exchange = @Exchange(name = RabbitConstant.TOPIC_EXCHANGE,type = RabbitConstant.TOPIC_EXCHANGE_TYPE), |
| | | key = RabbitConstant.ROUTING_KEY_DOWN |
| | | )) |
| | | public class DownMessageListener implements AbstractListener { |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | |
| | | @Autowired |
| | | private InfluxDBService influxDBService; |
| | | |
| | | |
| | | @RabbitHandler |
| | | public void handle(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) { |
| | | log.info("receive down message: {}" , msg); |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.zy.acs.hex.consumer; |
| | | |
| | | import com.rabbitmq.client.Channel; |
| | | import com.zy.acs.hex.constant.RabbitConstant; |
| | | import com.zy.acs.hex.consumer.listener.AbstractListener; |
| | | import com.zy.component.influxdb.service.InfluxDBService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.amqp.rabbit.annotation.*; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.amqp.support.AmqpHeaders; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.messaging.handler.annotation.Header; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * 消费者 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | @RabbitListener(bindings = @QueueBinding( |
| | | value = @Queue(name = RabbitConstant.TOPIC_QUEUE_UP, durable = RabbitConstant.DURABLE), |
| | | exchange = @Exchange(name = RabbitConstant.TOPIC_EXCHANGE, type = RabbitConstant.TOPIC_EXCHANGE_TYPE), |
| | | key = RabbitConstant.ROUTING_KEY_UP |
| | | )) |
| | | public class UpMessageListener implements AbstractListener { |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | |
| | | @Autowired |
| | | private InfluxDBService influxDBService; |
| | | |
| | | |
| | | @RabbitHandler |
| | | public void handle(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) { |
| | | log.info("receive up message: {}" , msg); |
| | | try { |
| | | channel.basicAck(tag,true); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | // 进入消息消费业务逻辑。 |
| | | //String data = new String(message.getBody()); |
| | | //log.info("收到消息:{}" ,data ); |
| | | //influxDBService.writeData(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.zy.acs.hex.consumer.listener; |
| | | |
| | | import com.rabbitmq.client.Channel; |
| | | import org.springframework.amqp.support.AmqpHeaders; |
| | | import org.springframework.messaging.handler.annotation.Header; |
| | | |
| | | public interface AbstractListener { |
| | | void handle(String event, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag); |
| | | } |
| New file |
| | |
| | | package com.zy.acs.hex.controller; |
| | | |
| | | import com.zy.acs.hex.constant.RabbitConstant; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | @RestController |
| | | @Slf4j |
| | | @RequestMapping(value = "/message") |
| | | public class TestController { |
| | | |
| | | @Autowired |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | /** |
| | | * 发送消息test1 |
| | | * @return |
| | | */ |
| | | @GetMapping(value = "/test1") |
| | | public void sendTest1() { |
| | | String router = RabbitConstant.ROUTING_KEY_UP.replaceFirst("\\*", "1").replaceFirst("\\*", "2"); |
| | | rabbitTemplate.convertAndSend(RabbitConstant.TOPIC_EXCHANGE,router,"1212321323"); |
| | | } |
| | | |
| | | /** |
| | | * 发送消息test2 |
| | | * @return |
| | | */ |
| | | @GetMapping(value = "/test2") |
| | | public void sendTest2() { |
| | | rabbitTemplate.convertAndSend(RabbitConstant.TOPIC_EXCHANGE, RabbitConstant.ROUTING_KEY_DOWN, "qswaqsaasas"); |
| | | } |
| | | |
| | | } |
| | |
| | | rabbitmq: |
| | | host: localhost |
| | | port: 5672 |
| | | username: admin |
| | | password: 123456 |
| | | username: root |
| | | password: xltys1995 |
| | | # 虚拟host可以不设置,默认/ |
| | | virtual-host: / |
| | | # 生产者确认配置 |
| | | publisher-confirm-type: correlated |
| | | publisher-returns: true |
| | | # 消费者配置 |
| | | listener: |
| | | simple: |
| | | # 手动确认模式 |
| | | acknowledge-mode: manual |
| | | # 消费者线程数 |
| | | concurrency: 1 |
| | | # 最大消费者线程数 |
| | | max-concurrency: 5 |
| | | # 每次从队列中获取的消息数量 |
| | | prefetch: 1 |
| | | direct: |
| | | acknowledge-mode: manual |
| | | |
| | | influxdb3: |
| | | enabled: true |
| | | url: http://127.0.0.1:8181 |
| | | token: apiv3_Jx1SvmBMV_kikGhc4eZJQbeGmNYN7KX1GdpoR9MClkKzMxSJ0MPKM_O2Xt3o1hVyRikMmlxZ_h9zfy6ybC5Idg |
| | | database: rcs |