Commit b47176c96efb681cdff9660c9a2fa101564c61f3
1 parent
9eeaa115
新增:iot 模块 集成 emqx 接收 mqtt 接收消息
Showing
21 changed files
with
550 additions
and
68 deletions
pom.xml
| ... | ... | @@ -15,7 +15,8 @@ |
| 15 | 15 | <!-- 各种 module 拓展 --> |
| 16 | 16 | <module>yudao-module-system</module> |
| 17 | 17 | <module>yudao-module-infra</module> |
| 18 | -<!-- <module>yudao-module-member</module>--> | |
| 18 | + <module>yudao-module-iot</module> | |
| 19 | + <!-- <module>yudao-module-member</module>--> | |
| 19 | 20 | <!-- <module>yudao-module-bpm</module>--> |
| 20 | 21 | <!-- <module>yudao-module-report</module>--> |
| 21 | 22 | <!-- <module>yudao-module-mp</module>--> | ... | ... |
yudao-dependencies/pom.xml
| ... | ... | @@ -64,6 +64,7 @@ |
| 64 | 64 | <tika-core.version>2.9.2</tika-core.version> |
| 65 | 65 | <ip2region.version>2.7.0</ip2region.version> |
| 66 | 66 | <bizlog-sdk.version>3.0.6</bizlog-sdk.version> |
| 67 | + <mqtt.version>1.2.5</mqtt.version> | |
| 67 | 68 | <!-- 三方云服务相关 --> |
| 68 | 69 | <okio.version>3.5.0</okio.version> |
| 69 | 70 | <okhttp3.version>4.11.0</okhttp3.version> |
| ... | ... | @@ -621,6 +622,13 @@ |
| 621 | 622 | <version>${xercesImpl.version}</version> |
| 622 | 623 | </dependency> |
| 623 | 624 | |
| 625 | + <!-- mqtt --> | |
| 626 | + <dependency> | |
| 627 | + <groupId>org.eclipse.paho</groupId> | |
| 628 | + <artifactId>org.eclipse.paho.client.mqttv3</artifactId> | |
| 629 | + <version>${mqtt.version}</version> | |
| 630 | + </dependency> | |
| 631 | + | |
| 624 | 632 | </dependencies> |
| 625 | 633 | </dependencyManagement> |
| 626 | 634 | ... | ... |
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/banner/core/BannerApplicationRunner.java
| ... | ... | @@ -62,6 +62,10 @@ public class BannerApplicationRunner implements ApplicationRunner { |
| 62 | 62 | if (isNotPresent("cn.iocoder.yudao.module.ai.framework.web.config.AiWebConfiguration")) { |
| 63 | 63 | System.out.println("[AI 大模型 yudao-module-ai - 已禁用][参考 https://doc.iocoder.cn/ai/build/ 开启]"); |
| 64 | 64 | } |
| 65 | + // IOT 物联网 | |
| 66 | + if (isNotPresent("cn.iocoder.yudao.module.iot.framework.web.config.IotWebConfiguration")) { | |
| 67 | + System.out.println("[IOT 物联网 yudao-module-iot - 已禁用][参考 https://doc.iocoder.cn/iot/build/ 开启]"); | |
| 68 | + } | |
| 65 | 69 | }); |
| 66 | 70 | } |
| 67 | 71 | ... | ... |
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java
| ... | ... | @@ -360,6 +360,12 @@ public class GlobalExceptionHandler { |
| 360 | 360 | return CommonResult.error(NOT_IMPLEMENTED.getCode(), |
| 361 | 361 | "[AI 大模型 yudao-module-ai - 表结构未导入][参考 https://doc.iocoder.cn/ai/build/ 开启]"); |
| 362 | 362 | } |
| 363 | + // 9. IOT 物联网 | |
| 364 | + if (message.contains("iot_")) { | |
| 365 | + log.error("[IOT 物联网 yudao-module-iot - 表结构未导入][参考 https://doc.iocoder.cn/iot/build/ 开启]"); | |
| 366 | + return CommonResult.error(NOT_IMPLEMENTED.getCode(), | |
| 367 | + "[IOT 物联网 yudao-module-iot - 表结构未导入][参考 https://doc.iocoder.cn/iot/build/ 开启]"); | |
| 368 | + } | |
| 363 | 369 | return null; |
| 364 | 370 | } |
| 365 | 371 | ... | ... |
yudao-module-iot/pom.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 3 | + xmlns="http://maven.apache.org/POM/4.0.0" | |
| 4 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
| 5 | + <parent> | |
| 6 | + <artifactId>yudao</artifactId> | |
| 7 | + <groupId>cn.iocoder.boot</groupId> | |
| 8 | + <version>${revision}</version> | |
| 9 | + </parent> | |
| 10 | + <modules> | |
| 11 | + <module>yudao-module-iot-api</module> | |
| 12 | + <module>yudao-module-iot-biz</module> | |
| 13 | + </modules> | |
| 14 | + <modelVersion>4.0.0</modelVersion> | |
| 15 | + | |
| 16 | + <artifactId>yudao-module-iot</artifactId> | |
| 17 | + <packaging>pom</packaging> | |
| 18 | + | |
| 19 | + <name>${project.artifactId}</name> | |
| 20 | + <description> | |
| 21 | + 物联网模块 | |
| 22 | + </description> | |
| 23 | + | |
| 24 | +</project> | |
| 0 | 25 | \ No newline at end of file | ... | ... |
yudao-module-iot/yudao-module-iot-api/pom.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | |
| 3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 4 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
| 5 | + <parent> | |
| 6 | + <artifactId>yudao-module-iot</artifactId> | |
| 7 | + <groupId>cn.iocoder.boot</groupId> | |
| 8 | + <version>${revision}</version> | |
| 9 | + </parent> | |
| 10 | + <modelVersion>4.0.0</modelVersion> | |
| 11 | + <artifactId>yudao-module-iot-api</artifactId> | |
| 12 | + <packaging>jar</packaging> | |
| 13 | + | |
| 14 | + <name>${project.artifactId}</name> | |
| 15 | + <description> | |
| 16 | + 物联网 模块 API,暴露给其它模块调用 | |
| 17 | + </description> | |
| 18 | + | |
| 19 | + <dependencies> | |
| 20 | + <dependency> | |
| 21 | + <groupId>cn.iocoder.boot</groupId> | |
| 22 | + <artifactId>yudao-common</artifactId> | |
| 23 | + </dependency> | |
| 24 | + </dependencies> | |
| 25 | + | |
| 26 | +</project> | ... | ... |
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/package-info.java
0 → 100644
yudao-module-iot/yudao-module-iot-biz/pom.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | |
| 3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 4 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
| 5 | + <parent> | |
| 6 | + <artifactId>yudao-module-iot</artifactId> | |
| 7 | + <groupId>cn.iocoder.boot</groupId> | |
| 8 | + <version>${revision}</version> | |
| 9 | + </parent> | |
| 10 | + <modelVersion>4.0.0</modelVersion> | |
| 11 | + <packaging>jar</packaging> | |
| 12 | + | |
| 13 | + <artifactId>yudao-module-iot-biz</artifactId> | |
| 14 | + | |
| 15 | + <name>${project.artifactId}</name> | |
| 16 | + <description> | |
| 17 | + 物联网 模块,主要实现 产品管理、设备管理、协议管理等功能。 | |
| 18 | + </description> | |
| 19 | + | |
| 20 | + <dependencies> <!-- 5. 新增依赖,这里引入的都是比较常用的业务组件、技术组件 --> | |
| 21 | + <dependency> | |
| 22 | + <groupId>cn.iocoder.boot</groupId> | |
| 23 | + <artifactId>yudao-module-iot-api</artifactId> | |
| 24 | + <version>${revision}</version> | |
| 25 | + </dependency> | |
| 26 | + | |
| 27 | + <!-- Web 相关 --> | |
| 28 | + <dependency> | |
| 29 | + <groupId>cn.iocoder.boot</groupId> | |
| 30 | + <artifactId>yudao-spring-boot-starter-web</artifactId> | |
| 31 | + </dependency> | |
| 32 | + | |
| 33 | + <dependency> | |
| 34 | + <groupId>cn.iocoder.boot</groupId> | |
| 35 | + <artifactId>yudao-spring-boot-starter-security</artifactId> | |
| 36 | + </dependency> | |
| 37 | + | |
| 38 | + <!-- DB 相关 --> | |
| 39 | + <dependency> | |
| 40 | + <groupId>cn.iocoder.boot</groupId> | |
| 41 | + <artifactId>yudao-spring-boot-starter-mybatis</artifactId> | |
| 42 | + </dependency> | |
| 43 | + | |
| 44 | + <!-- Test 测试相关 --> | |
| 45 | + <dependency> | |
| 46 | + <groupId>cn.iocoder.boot</groupId> | |
| 47 | + <artifactId>yudao-spring-boot-starter-test</artifactId> | |
| 48 | + </dependency> | |
| 49 | + | |
| 50 | + <!-- mqtt --> | |
| 51 | + <dependency> | |
| 52 | + <groupId>org.eclipse.paho</groupId> | |
| 53 | + <artifactId>org.eclipse.paho.client.mqttv3</artifactId> | |
| 54 | + </dependency> | |
| 55 | + </dependencies> | |
| 56 | + | |
| 57 | +</project> | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/package-info.java
0 → 100644
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/callback/EmqxCallback.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.emq.callback; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.iot.emq.client.EmqxClient; | |
| 4 | +import cn.iocoder.yudao.module.iot.emq.service.EmqxService; | |
| 5 | +import jakarta.annotation.Resource; | |
| 6 | +import lombok.extern.slf4j.Slf4j; | |
| 7 | +import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; | |
| 8 | +import org.eclipse.paho.client.mqttv3.MqttCallbackExtended; | |
| 9 | +import org.eclipse.paho.client.mqttv3.MqttMessage; | |
| 10 | +import org.springframework.context.annotation.Lazy; | |
| 11 | +import org.springframework.stereotype.Component; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 用于处理MQTT连接的回调,如连接断开、消息到达、消息发布完成、连接完成等事件。 | |
| 15 | + * | |
| 16 | + * @author ahh | |
| 17 | + */ | |
| 18 | +@Slf4j | |
| 19 | +@Component | |
| 20 | +public class EmqxCallback implements MqttCallbackExtended { | |
| 21 | + | |
| 22 | + @Lazy | |
| 23 | + @Resource | |
| 24 | + private EmqxService emqxService; | |
| 25 | + | |
| 26 | + @Lazy | |
| 27 | + @Resource | |
| 28 | + private EmqxClient emqxClient; | |
| 29 | + | |
| 30 | + @Override | |
| 31 | + public void connectionLost(Throwable throwable) { | |
| 32 | + log.info("MQTT 连接断开", throwable); | |
| 33 | + } | |
| 34 | + | |
| 35 | + @Override | |
| 36 | + public void messageArrived(String topic, MqttMessage mqttMessage) { | |
| 37 | + emqxService.subscribeCallback(topic, mqttMessage); | |
| 38 | + } | |
| 39 | + | |
| 40 | + @Override | |
| 41 | + public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) { | |
| 42 | + log.info("消息发送成功: {}", iMqttDeliveryToken.getMessageId()); | |
| 43 | + } | |
| 44 | + | |
| 45 | + @Override | |
| 46 | + public void connectComplete(boolean reconnect, String serverURI) { | |
| 47 | + log.info("MQTT 已连接到服务器: {}", serverURI); | |
| 48 | + emqxService.subscribe(emqxClient.getMqttClient()); | |
| 49 | + } | |
| 50 | +} | |
| 51 | + | |
| 52 | + | |
| 53 | + | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/client/EmqxClient.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.emq.client; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.iot.emq.callback.EmqxCallback; | |
| 4 | +import cn.iocoder.yudao.module.iot.emq.config.MqttConfig; | |
| 5 | +import jakarta.annotation.Resource; | |
| 6 | +import lombok.Data; | |
| 7 | +import lombok.extern.slf4j.Slf4j; | |
| 8 | +import org.eclipse.paho.client.mqttv3.MqttClient; | |
| 9 | +import org.eclipse.paho.client.mqttv3.MqttConnectOptions; | |
| 10 | +import org.eclipse.paho.client.mqttv3.MqttException; | |
| 11 | +import org.eclipse.paho.client.mqttv3.MqttMessage; | |
| 12 | +import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; | |
| 13 | +import org.springframework.stereotype.Component; | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * MQTT客户端类,负责建立与MQTT服务器的连接,提供发布消息和订阅主题的功能 | |
| 17 | + * | |
| 18 | + * @author ahh | |
| 19 | + */ | |
| 20 | +@Slf4j | |
| 21 | +@Data | |
| 22 | +@Component | |
| 23 | +public class EmqxClient { | |
| 24 | + | |
| 25 | + @Resource | |
| 26 | + private EmqxCallback emqxCallback; | |
| 27 | + @Resource | |
| 28 | + private MqttConfig mqttConfig; | |
| 29 | + | |
| 30 | + private MqttClient mqttClient; | |
| 31 | + | |
| 32 | + public void connect() { | |
| 33 | + if (mqttClient == null) { | |
| 34 | + createMqttClient(); | |
| 35 | + } | |
| 36 | + try { | |
| 37 | + mqttClient.connect(createMqttOptions()); | |
| 38 | + log.info("MQTT客户端连接成功"); | |
| 39 | + } catch (MqttException e) { | |
| 40 | + log.error("MQTT客户端连接失败", e); | |
| 41 | + } | |
| 42 | + } | |
| 43 | + | |
| 44 | + private void createMqttClient() { | |
| 45 | + try { | |
| 46 | + mqttClient = new MqttClient(mqttConfig.getHostUrl(), "yudao-" + mqttConfig.getClientId(), new MemoryPersistence()); | |
| 47 | + mqttClient.setCallback(emqxCallback); | |
| 48 | + } catch (MqttException e) { | |
| 49 | + log.error("创建MQTT客户端失败", e); | |
| 50 | + } | |
| 51 | + } | |
| 52 | + | |
| 53 | + private MqttConnectOptions createMqttOptions() { | |
| 54 | + MqttConnectOptions options = new MqttConnectOptions(); | |
| 55 | + options.setUserName(mqttConfig.getUsername()); | |
| 56 | + options.setPassword(mqttConfig.getPassword().toCharArray()); | |
| 57 | + options.setConnectionTimeout(mqttConfig.getTimeout()); | |
| 58 | + options.setKeepAliveInterval(mqttConfig.getKeepalive()); | |
| 59 | + options.setCleanSession(mqttConfig.isClearSession()); | |
| 60 | + return options; | |
| 61 | + } | |
| 62 | + | |
| 63 | + public void publish(String topic, String message) { | |
| 64 | + try { | |
| 65 | + if (mqttClient == null || !mqttClient.isConnected()) { | |
| 66 | + connect(); | |
| 67 | + } | |
| 68 | + mqttClient.publish(topic, new MqttMessage(message.getBytes())); | |
| 69 | + log.info("消息已发布到主题: {}", topic); | |
| 70 | + } catch (MqttException e) { | |
| 71 | + log.error("消息发布失败", e); | |
| 72 | + } | |
| 73 | + } | |
| 74 | + | |
| 75 | + public void subscribe(String topic) { | |
| 76 | + try { | |
| 77 | + if (mqttClient == null || !mqttClient.isConnected()) { | |
| 78 | + connect(); | |
| 79 | + } | |
| 80 | + mqttClient.subscribe(topic); | |
| 81 | + log.info("订阅了主题: {}", topic); | |
| 82 | + } catch (MqttException e) { | |
| 83 | + log.error("订阅主题失败", e); | |
| 84 | + } | |
| 85 | + } | |
| 86 | +} | |
| 0 | 87 | \ No newline at end of file | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/config/MqttConfig.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.emq.config; | |
| 2 | + | |
| 3 | +import lombok.Data; | |
| 4 | +import org.springframework.boot.context.properties.ConfigurationProperties; | |
| 5 | +import org.springframework.stereotype.Component; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * 配置类,用于读取MQTT连接的配置信息,如用户名、密码、连接地址等 | |
| 9 | + * | |
| 10 | + * @author ahh | |
| 11 | + */ | |
| 12 | +@Data | |
| 13 | +@Component | |
| 14 | +@ConfigurationProperties("iot.emq") | |
| 15 | +public class MqttConfig { | |
| 16 | + | |
| 17 | + /** | |
| 18 | + * 用户名 | |
| 19 | + */ | |
| 20 | + private String username; | |
| 21 | + /** | |
| 22 | + * 密码 | |
| 23 | + */ | |
| 24 | + private String password; | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 连接地址 | |
| 28 | + */ | |
| 29 | + private String hostUrl; | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * 客户Id | |
| 33 | + */ | |
| 34 | + private String clientId; | |
| 35 | + | |
| 36 | + /** | |
| 37 | + * 默认连接话题 | |
| 38 | + */ | |
| 39 | + private String defaultTopic; | |
| 40 | + | |
| 41 | + /** | |
| 42 | + * 超时时间 | |
| 43 | + */ | |
| 44 | + private int timeout; | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * 保持连接数 | |
| 48 | + */ | |
| 49 | + private int keepalive; | |
| 50 | + | |
| 51 | + /** | |
| 52 | + * 是否清除session | |
| 53 | + */ | |
| 54 | + private boolean clearSession; | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * 是否共享订阅 | |
| 58 | + */ | |
| 59 | + private boolean isShared; | |
| 60 | + | |
| 61 | + /** | |
| 62 | + * 分组共享订阅 | |
| 63 | + */ | |
| 64 | + private boolean isSharedGroup; | |
| 65 | + | |
| 66 | +} | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/service/EmqxService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.emq.service; | |
| 2 | + | |
| 3 | +import lombok.extern.slf4j.Slf4j; | |
| 4 | +import org.eclipse.paho.client.mqttv3.MqttClient; | |
| 5 | +import org.eclipse.paho.client.mqttv3.MqttMessage; | |
| 6 | +import org.springframework.stereotype.Service; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * 用于处理MQTT消息的具体业务逻辑,如订阅回调 | |
| 10 | + * | |
| 11 | + * @author ahh | |
| 12 | + */ | |
| 13 | +@Slf4j | |
| 14 | +@Service | |
| 15 | +public class EmqxService { | |
| 16 | + | |
| 17 | + public void subscribeCallback(String topic, MqttMessage mqttMessage) { | |
| 18 | + log.info("收到消息,主题: {}, 内容: {}", topic, new String(mqttMessage.getPayload())); | |
| 19 | + // 根据不同的主题,处理不同的业务逻辑 | |
| 20 | + if (topic.contains("/property/post")) { | |
| 21 | + // 设备上报数据 | |
| 22 | + } | |
| 23 | + } | |
| 24 | + | |
| 25 | + public void subscribe(MqttClient client) { | |
| 26 | + try { | |
| 27 | + // 订阅默认主题,可以根据需要修改 | |
| 28 | + client.subscribe("$share/yudao/+/+/#", 1); | |
| 29 | + log.info("订阅默认主题成功"); | |
| 30 | + } catch (Exception e) { | |
| 31 | + log.error("订阅默认主题失败", e); | |
| 32 | + } | |
| 33 | + } | |
| 34 | +} | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/start/EmqxStart.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.emq.start; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.iot.emq.client.EmqxClient; | |
| 4 | +import jakarta.annotation.Resource; | |
| 5 | +import org.springframework.boot.ApplicationArguments; | |
| 6 | +import org.springframework.boot.ApplicationRunner; | |
| 7 | +import org.springframework.stereotype.Component; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 用于在应用启动时自动连接MQTT服务器 | |
| 11 | + * | |
| 12 | + * @author ahh | |
| 13 | + */ | |
| 14 | +@Component | |
| 15 | +public class EmqxStart implements ApplicationRunner { | |
| 16 | + | |
| 17 | + @Resource | |
| 18 | + private EmqxClient emqxClient; | |
| 19 | + | |
| 20 | + @Override | |
| 21 | + public void run(ApplicationArguments applicationArguments) { | |
| 22 | + emqxClient.connect(); | |
| 23 | + } | |
| 24 | +} | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/framework/package-info.java
0 → 100644
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/framework/web/config/IotWebConfiguration.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.framework.web.config; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.swagger.config.YudaoSwaggerAutoConfiguration; | |
| 4 | +import org.springdoc.core.models.GroupedOpenApi; | |
| 5 | +import org.springframework.context.annotation.Bean; | |
| 6 | +import org.springframework.context.annotation.Configuration; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * iot 模块的 web 组件的 Configuration | |
| 10 | + * | |
| 11 | + * @author 芋道源码 | |
| 12 | + */ | |
| 13 | +@Configuration(proxyBeanMethods = false) | |
| 14 | +public class IotWebConfiguration { | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * iot 模块的 API 分组 | |
| 18 | + */ | |
| 19 | + @Bean | |
| 20 | + public GroupedOpenApi iotGroupedOpenApi() { | |
| 21 | + return YudaoSwaggerAutoConfiguration.buildGroupedOpenApi("iot"); | |
| 22 | + } | |
| 23 | + | |
| 24 | +} | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/framework/web/package-info.java
0 → 100644
yudao-server/pom.xml
| 1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | -<project xmlns="http://maven.apache.org/POM/4.0.0" | |
| 3 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 2 | +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 3 | + xmlns="http://maven.apache.org/POM/4.0.0" | |
| 4 | 4 | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| 5 | 5 | <parent> |
| 6 | 6 | <groupId>cn.iocoder.boot</groupId> |
| ... | ... | @@ -33,80 +33,87 @@ |
| 33 | 33 | </dependency> |
| 34 | 34 | |
| 35 | 35 | <!-- 会员中心。默认注释,保证编译速度 --> |
| 36 | -<!-- <dependency>--> | |
| 37 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 38 | -<!-- <artifactId>yudao-module-member-biz</artifactId>--> | |
| 39 | -<!-- <version>${revision}</version>--> | |
| 40 | -<!-- </dependency>--> | |
| 36 | + <!-- <dependency>--> | |
| 37 | + <!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 38 | + <!-- <artifactId>yudao-module-member-biz</artifactId>--> | |
| 39 | + <!-- <version>${revision}</version>--> | |
| 40 | + <!-- </dependency>--> | |
| 41 | 41 | |
| 42 | 42 | <!-- 数据报表。默认注释,保证编译速度 --> |
| 43 | -<!-- <dependency>--> | |
| 44 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 45 | -<!-- <artifactId>yudao-module-report-biz</artifactId>--> | |
| 46 | -<!-- <version>${revision}</version>--> | |
| 47 | -<!-- </dependency>--> | |
| 43 | + <!-- <dependency>--> | |
| 44 | + <!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 45 | + <!-- <artifactId>yudao-module-report-biz</artifactId>--> | |
| 46 | + <!-- <version>${revision}</version>--> | |
| 47 | + <!-- </dependency>--> | |
| 48 | 48 | <!-- 工作流。默认注释,保证编译速度 --> |
| 49 | -<!-- <dependency>--> | |
| 50 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 51 | -<!-- <artifactId>yudao-module-bpm-biz</artifactId>--> | |
| 52 | -<!-- <version>${revision}</version>--> | |
| 53 | -<!-- </dependency>--> | |
| 49 | + <!-- <dependency>--> | |
| 50 | + <!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 51 | + <!-- <artifactId>yudao-module-bpm-biz</artifactId>--> | |
| 52 | + <!-- <version>${revision}</version>--> | |
| 53 | + <!-- </dependency>--> | |
| 54 | 54 | <!-- 支付服务。默认注释,保证编译速度 --> |
| 55 | -<!-- <dependency>--> | |
| 56 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 57 | -<!-- <artifactId>yudao-module-pay-biz</artifactId>--> | |
| 58 | -<!-- <version>${revision}</version>--> | |
| 59 | -<!-- </dependency>--> | |
| 55 | + <!-- <dependency>--> | |
| 56 | + <!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 57 | + <!-- <artifactId>yudao-module-pay-biz</artifactId>--> | |
| 58 | + <!-- <version>${revision}</version>--> | |
| 59 | + <!-- </dependency>--> | |
| 60 | 60 | |
| 61 | 61 | <!-- 微信公众号模块。默认注释,保证编译速度 --> |
| 62 | -<!-- <dependency>--> | |
| 63 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 64 | -<!-- <artifactId>yudao-module-mp-biz</artifactId>--> | |
| 65 | -<!-- <version>${revision}</version>--> | |
| 66 | -<!-- </dependency>--> | |
| 62 | + <!-- <dependency>--> | |
| 63 | + <!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 64 | + <!-- <artifactId>yudao-module-mp-biz</artifactId>--> | |
| 65 | + <!-- <version>${revision}</version>--> | |
| 66 | + <!-- </dependency>--> | |
| 67 | 67 | |
| 68 | 68 | <!-- 商城相关模块。默认注释,保证编译速度--> |
| 69 | -<!-- <dependency>--> | |
| 70 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 71 | -<!-- <artifactId>yudao-module-promotion-biz</artifactId>--> | |
| 72 | -<!-- <version>${revision}</version>--> | |
| 73 | -<!-- </dependency>--> | |
| 74 | -<!-- <dependency>--> | |
| 75 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 76 | -<!-- <artifactId>yudao-module-product-biz</artifactId>--> | |
| 77 | -<!-- <version>${revision}</version>--> | |
| 78 | -<!-- </dependency>--> | |
| 79 | -<!-- <dependency>--> | |
| 80 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 81 | -<!-- <artifactId>yudao-module-trade-biz</artifactId>--> | |
| 82 | -<!-- <version>${revision}</version>--> | |
| 83 | -<!-- </dependency>--> | |
| 84 | -<!-- <dependency>--> | |
| 85 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 86 | -<!-- <artifactId>yudao-module-statistics-biz</artifactId>--> | |
| 87 | -<!-- <version>${revision}</version>--> | |
| 88 | -<!-- </dependency>--> | |
| 69 | + <!-- <dependency>--> | |
| 70 | + <!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 71 | + <!-- <artifactId>yudao-module-promotion-biz</artifactId>--> | |
| 72 | + <!-- <version>${revision}</version>--> | |
| 73 | + <!-- </dependency>--> | |
| 74 | + <!-- <dependency>--> | |
| 75 | + <!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 76 | + <!-- <artifactId>yudao-module-product-biz</artifactId>--> | |
| 77 | + <!-- <version>${revision}</version>--> | |
| 78 | + <!-- </dependency>--> | |
| 79 | + <!-- <dependency>--> | |
| 80 | + <!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 81 | + <!-- <artifactId>yudao-module-trade-biz</artifactId>--> | |
| 82 | + <!-- <version>${revision}</version>--> | |
| 83 | + <!-- </dependency>--> | |
| 84 | + <!-- <dependency>--> | |
| 85 | + <!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 86 | + <!-- <artifactId>yudao-module-statistics-biz</artifactId>--> | |
| 87 | + <!-- <version>${revision}</version>--> | |
| 88 | + <!-- </dependency>--> | |
| 89 | 89 | |
| 90 | 90 | <!-- CRM 相关模块。默认注释,保证编译速度 --> |
| 91 | -<!-- <dependency>--> | |
| 92 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 93 | -<!-- <artifactId>yudao-module-crm-biz</artifactId>--> | |
| 94 | -<!-- <version>${revision}</version>--> | |
| 95 | -<!-- </dependency>--> | |
| 91 | + <!-- <dependency>--> | |
| 92 | + <!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 93 | + <!-- <artifactId>yudao-module-crm-biz</artifactId>--> | |
| 94 | + <!-- <version>${revision}</version>--> | |
| 95 | + <!-- </dependency>--> | |
| 96 | 96 | |
| 97 | 97 | <!-- ERP 相关模块。默认注释,保证编译速度 --> |
| 98 | -<!-- <dependency>--> | |
| 99 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 100 | -<!-- <artifactId>yudao-module-erp-biz</artifactId>--> | |
| 101 | -<!-- <version>${revision}</version>--> | |
| 102 | -<!-- </dependency>--> | |
| 98 | + <!-- <dependency>--> | |
| 99 | + <!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 100 | + <!-- <artifactId>yudao-module-erp-biz</artifactId>--> | |
| 101 | + <!-- <version>${revision}</version>--> | |
| 102 | + <!-- </dependency>--> | |
| 103 | 103 | |
| 104 | 104 | <!-- AI 大模型相关模块。默认注释,保证编译速度 --> |
| 105 | -<!-- <dependency>--> | |
| 106 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 107 | -<!-- <artifactId>yudao-module-ai-biz</artifactId>--> | |
| 108 | -<!-- <version>${revision}</version>--> | |
| 109 | -<!-- </dependency>--> | |
| 105 | + <!-- <dependency>--> | |
| 106 | + <!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 107 | + <!-- <artifactId>yudao-module-ai-biz</artifactId>--> | |
| 108 | + <!-- <version>${revision}</version>--> | |
| 109 | + <!-- </dependency>--> | |
| 110 | + | |
| 111 | + <!-- IOT 物联网相关模块。默认注释,保证编译速度 --> | |
| 112 | + <dependency> | |
| 113 | + <groupId>cn.iocoder.boot</groupId> | |
| 114 | + <artifactId>yudao-module-iot-biz</artifactId> | |
| 115 | + <version>${revision}</version> | |
| 116 | + </dependency> | |
| 110 | 117 | |
| 111 | 118 | <!-- spring boot 配置所需依赖 --> |
| 112 | 119 | <dependency> | ... | ... |
yudao-server/src/main/java/cn/iocoder/yudao/server/controller/DefaultController.java
| ... | ... | @@ -65,4 +65,10 @@ public class DefaultController { |
| 65 | 65 | "[AI 大模型 yudao-module-ai - 已禁用][参考 https://doc.iocoder.cn/ai/build/ 开启]"); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | + @RequestMapping(value = {"/admin-api/iot/**"}) | |
| 69 | + public CommonResult<Boolean> iot404() { | |
| 70 | + return CommonResult.error(NOT_IMPLEMENTED.getCode(), | |
| 71 | + "[IOT 物联网 yudao-module-iot - 已禁用][参考 https://doc.iocoder.cn/iot/build/ 开启]"); | |
| 72 | + } | |
| 73 | + | |
| 68 | 74 | } | ... | ... |
yudao-server/src/main/resources/application-dev.yaml
| ... | ... | @@ -193,4 +193,23 @@ justauth: |
| 193 | 193 | cache: |
| 194 | 194 | type: REDIS |
| 195 | 195 | prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE:: |
| 196 | - timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟 | |
| 197 | 196 | \ No newline at end of file |
| 197 | + timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟 | |
| 198 | + | |
| 199 | + | |
| 200 | +--- #################### iot相关配置 #################### | |
| 201 | +iot: | |
| 202 | + emq: | |
| 203 | + # 账号 | |
| 204 | + username: anhaohao | |
| 205 | + # 密码 | |
| 206 | + password: ahh@123456 | |
| 207 | + # 主机地址 | |
| 208 | + hostUrl: tcp://chaojiniu.top:1883 | |
| 209 | + # 客户端Id,不能相同,采用随机数 ${random.value} | |
| 210 | + client-id: ${random.int} | |
| 211 | + # 默认主题 | |
| 212 | + default-topic: test | |
| 213 | + # 保持连接 | |
| 214 | + keepalive: 60 | |
| 215 | + # 清除会话(设置为false,断开连接,重连后使用原来的会话 保留订阅的主题,能接收离线期间的消息) | |
| 216 | + clearSession: true | |
| 198 | 217 | \ No newline at end of file | ... | ... |
yudao-server/src/main/resources/application-local.yaml
| ... | ... | @@ -45,7 +45,7 @@ spring: |
| 45 | 45 | primary: master |
| 46 | 46 | datasource: |
| 47 | 47 | master: |
| 48 | - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 | |
| 48 | + url: jdbc:mysql://127.0.0.1:3307/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 | |
| 49 | 49 | # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 |
| 50 | 50 | # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 |
| 51 | 51 | # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 |
| ... | ... | @@ -54,7 +54,7 @@ spring: |
| 54 | 54 | # url: jdbc:kingbase8://127.0.0.1:54321/test # 人大金仓 KingbaseES 连接的示例 |
| 55 | 55 | # url: jdbc:postgresql://127.0.0.1:5432/postgres # OpenGauss 连接的示例 |
| 56 | 56 | username: root |
| 57 | - password: 123456 | |
| 57 | + password: ahh@123456 | |
| 58 | 58 | # username: sa # SQL Server 连接的示例 |
| 59 | 59 | # password: Yudao@2024 # SQL Server 连接的示例 |
| 60 | 60 | # username: SYSDBA # DM 连接的示例 |
| ... | ... | @@ -63,9 +63,9 @@ spring: |
| 63 | 63 | # password: Yudao@2024 # OpenGauss 连接的示例 |
| 64 | 64 | slave: # 模拟从库,可根据自己需要修改 |
| 65 | 65 | lazy: true # 开启懒加载,保证启动速度 |
| 66 | - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true | |
| 66 | + url: jdbc:mysql://127.0.0.1:3307/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true | |
| 67 | 67 | username: root |
| 68 | - password: 123456 | |
| 68 | + password: ahh@123456 | |
| 69 | 69 | |
| 70 | 70 | # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 |
| 71 | 71 | data: |
| ... | ... | @@ -249,3 +249,20 @@ justauth: |
| 249 | 249 | prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE:: |
| 250 | 250 | timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟 |
| 251 | 251 | |
| 252 | +--- #################### iot相关配置 #################### | |
| 253 | +iot: | |
| 254 | + emq: | |
| 255 | + # 账号 | |
| 256 | + username: anhaohao | |
| 257 | + # 密码 | |
| 258 | + password: ahh@123456 | |
| 259 | + # 主机地址 | |
| 260 | + hostUrl: tcp://chaojiniu.top:1883 | |
| 261 | + # 客户端Id,不能相同,采用随机数 ${random.value} | |
| 262 | + client-id: ${random.int} | |
| 263 | + # 默认主题 | |
| 264 | + default-topic: test | |
| 265 | + # 保持连接 | |
| 266 | + keepalive: 60 | |
| 267 | + # 清除会话(设置为false,断开连接,重连后使用原来的会话 保留订阅的主题,能接收离线期间的消息) | |
| 268 | + clearSession: true | |
| 252 | 269 | \ No newline at end of file | ... | ... |