diff --git a/.DS_Store b/.DS_Store index fafe254b..54ee152c 100755 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/data/components/.DS_Store b/data/components/.DS_Store new file mode 100644 index 00000000..a81c8a53 Binary files /dev/null and b/data/components/.DS_Store differ diff --git a/iot-components/iot-emqx-component/emqx_rule_data.json b/iot-components/iot-emqx-component/emqx_rule_data.json new file mode 100644 index 00000000..9db7184b --- /dev/null +++ b/iot-components/iot-emqx-component/emqx_rule_data.json @@ -0,0 +1,185 @@ +{ + "data":[ + { + "rawsql":"SELECT\n reason,\n clientid,\n username,\n peername,\n socketname\nFROM\n \"$events/client_connected\"", + "on_action_failed":"continue", + "metrics":[ + { + "speed_max":0, + "speed_last5m":0, + "speed":0, + "passed":0, + "node":"emqx@127.0.0.1", + "no_result":0, + "matched":0, + "failed":0, + "exception":0 + } + ], + "id":"rule:012980", + "for":[ + "$events/client_connected" + ], + "enabled":true, + "description":" 连接", + "actions":[ + { + "params":{ + "target_topic":"/sys/client/connected", + "target_qos":1, + "payload_tmpl":"{\"reason\":\"${reason}\",\"clientid\":\"${clientid}\",\"username\":\"${username}\",\"peername\":\"${peername}\",\"socketname\":\"${socketname}\"}" + }, + "name":"republish", + "metrics":[ + { + "taken":0, + "success":0, + "node":"emqx@127.0.0.1", + "failed":0 + } + ], + "id":"republish_16528854106752092", + "fallbacks":[ + + ] + } + ] + }, + { + "rawsql":"SELECT\n reason,\n clientid,\n username,\n peername,\n socketname\nFROM\n \"$events/client_disconnected\"", + "on_action_failed":"continue", + "metrics":[ + { + "speed_max":0, + "speed_last5m":0, + "speed":0, + "passed":0, + "node":"emqx@127.0.0.1", + "no_result":0, + "matched":0, + "failed":0, + "exception":0 + } + ], + "id":"rule:377397", + "for":[ + "$events/client_disconnected" + ], + "enabled":true, + "description":"断开连接", + "actions":[ + { + "params":{ + "target_topic":"/sys/client/disconnected", + "target_qos":0, + "payload_tmpl":"{\"reason\":\"${reason}\",\"clientid\":\"${clientid}\",\"username\":\"${username}\",\"peername\":\"${peername}\",\"socketname\":\"${socketname}\"}" + }, + "name":"republish", + "metrics":[ + { + "taken":0, + "success":0, + "node":"emqx@127.0.0.1", + "failed":0 + } + ], + "id":"republish_16528854190433372", + "fallbacks":[ + + ] + } + ] + }, + { + "rawsql":"SELECT\n clientid,\n username,\n topic,\n qos\nFROM\n \"$events/session_subscribed\"", + "on_action_failed":"continue", + "metrics":[ + { + "speed_max":0, + "speed_last5m":0, + "speed":0, + "passed":0, + "node":"emqx@127.0.0.1", + "no_result":0, + "matched":0, + "failed":0, + "exception":0 + } + ], + "id":"rule:758695", + "for":[ + "$events/session_subscribed" + ], + "enabled":true, + "description":"子设备注册成功后,订阅topic: /sys/{productKey}/{deviceName}/c/#", + "actions":[ + { + "params":{ + "target_topic":"/sys/session/subscribed", + "target_qos":1, + "payload_tmpl":"{\"username\":\"${username}\",\"topic\":\"${topic}\",\"qos\":\"${qos}\",\"clientid\":\"${clientid}\"}" + }, + "name":"republish", + "metrics":[ + { + "taken":0, + "success":0, + "node":"emqx@127.0.0.1", + "failed":0 + } + ], + "id":"republish_16530236276902029", + "fallbacks":[ + + ] + } + ] + }, + { + "rawsql":"SELECT\n clientid,\n username,\n topic,\n qos\nFROM\n \"$events/session_unsubscribed\"", + "on_action_failed":"continue", + "metrics":[ + { + "speed_max":0, + "speed_last5m":0, + "speed":0, + "passed":0, + "node":"emqx@127.0.0.1", + "no_result":0, + "matched":0, + "failed":0, + "exception":0 + } + ], + "id":"rule:514503", + "for":[ + "$events/session_unsubscribed" + ], + "enabled":true, + "description":"", + "actions":[ + { + "params":{ + "target_topic":"/sys/session/unsubscribed", + "target_qos":0, + "payload_tmpl":"{\"username\":\"${username}\",\"topic\":\"${topic}\",\"qos\":\"${qos}\",\"clientid\":\"${clientid}\"}" + }, + "name":"republish", + "metrics":[ + { + "taken":0, + "success":0, + "node":"emqx@127.0.0.1", + "failed":0 + } + ], + "id":"republish_16530237303922829", + "fallbacks":[ + + ] + } + ] + } + ], + "code":0 +} \ No newline at end of file diff --git a/iot-components/iot-emqx-component/readme.md b/iot-components/iot-emqx-component/readme.md new file mode 100644 index 00000000..1be0885d --- /dev/null +++ b/iot-components/iot-emqx-component/readme.md @@ -0,0 +1,6 @@ +## EMQX配置 + +接入emqx需要在EMQX的规则引擎界面新增订阅、取消订阅、连接、断开连接的消息转发。 + +配置内容见:emqx_rule_data.json + diff --git a/iot-standalone/src/main/resources/application-dev.yml b/iot-standalone/src/main/resources/application-dev.yml index 485e1d30..7dd8e9c7 100755 --- a/iot-standalone/src/main/resources/application-dev.yml +++ b/iot-standalone/src/main/resources/application-dev.yml @@ -22,6 +22,7 @@ spring: password: 123456 driverClassName: org.h2.Driver + #注: 切换数据库时需要将项目根目录中的.init文件删除再重启 ## 内置h2 web console设置 platform: h2 h2: diff --git a/iot-standalone/src/main/resources/application-mysql.yml b/iot-standalone/src/main/resources/application-mysql.yml new file mode 100644 index 00000000..48683e3e --- /dev/null +++ b/iot-standalone/src/main/resources/application-mysql.yml @@ -0,0 +1,75 @@ +server: + port: 8086 + +spring: + servlet: + multipart: + enabled: true + max-file-size: 10MB + max-request-size: 12MB + + #注: 切换数据库时需要将项目根目录中的.init文件删除再重启 + # <<==========mysql配置开始============== + datasource: + url: jdbc:mysql://127.0.0.1:3306/iotkit?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&useSSL=false + driverClassName: com.mysql.cj.jdbc.Driver + username: root + password: 123456 + validationQuery: SELECT 1 + testOnBorrow: true + jpa: + database: MySQL + database-platform: org.hibernate.dialect.MySQL5InnoDBDialect +# show-sql: true + hibernate: + ddl-auto: update + properties: + hibernate: + format_sql: true + # ============mysql配置结束============>> + + elasticsearch: + rest: + #使用内置es的配置 + uris: http://127.0.0.1:9200 + username: + password: + connection-timeout: 10s + + redis: + #使用内置redis的配置 + host: 127.0.0.1 + port: 6379 + database: 0 + password: + + mvc: + pathmatch: + matching-strategy: ant_path_matcher + +#图片存储用的是阿里云oss,如果需要上传产品图片才需要配置 +aliyun: + bucketId: iotkit-img + endpoint: oss-cn-shenzhen.aliyuncs.com + accessKeyId: 填写阿里云accessKeyId + accessKeySecret: 填写阿里云accessKeySecret + +sa-token: + # token名称 (同时也是cookie名称) + token-name: token + # token有效期,单位s 默认30天, -1代表永不过期 + timeout: 2592000 + # token临时有效期 (指定时间内无操作就视为token过期) 单位: 秒 + activity-timeout: -1 + # 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录) + is-concurrent: true + # 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token) + is-share: false + # token风格 + token-style: uuid + # 是否输出操作日志 + is-log: false + +#认证中心地址 +oauth2: + auth-server-url: http://127.0.0.1:8086 diff --git a/iot-standalone/src/main/resources/application.yml b/iot-standalone/src/main/resources/application.yml index 10f7a303..f55c753a 100755 --- a/iot-standalone/src/main/resources/application.yml +++ b/iot-standalone/src/main/resources/application.yml @@ -8,6 +8,7 @@ spring: max-file-size: 10MB max-request-size: 12MB + #注: 切换数据库时需要将项目根目录中的.init文件删除再重启 # <<=======内置H2数据库连接设置开始========== jpa: # show-sql: true