diff --git a/iot-accessControl/src/main/java/com/java110/accessControl/AccessControlApplicationStart.java b/iot-accessControl/src/main/java/com/java110/accessControl/AccessControlApplicationStart.java index 333eb0dbaf75f46f66e659cc72c86a5d22f26610..55930d446bbb82a26eb2243fd0865ad0afc15bef 100644 --- a/iot-accessControl/src/main/java/com/java110/accessControl/AccessControlApplicationStart.java +++ b/iot-accessControl/src/main/java/com/java110/accessControl/AccessControlApplicationStart.java @@ -45,6 +45,10 @@ import java.util.concurrent.TimeUnit; }) @EnableFeignClients(basePackages = { "com.java110.intf.community", + "com.java110.intf.barrier", + "com.java110.intf.user", + "com.java110.intf.system", + "com.java110.intf.monitor", }) @Java110CmdDiscovery(cmdPublishClass = ServiceCmdEventPublishing.class, basePackages = {"com.java110.user.cmd"}) diff --git a/iot-accessControl/src/main/resources/application-dev.yml b/iot-accessControl/src/main/resources/application-dev.yml index 062035d5452ef63bcf279f2dee9077e25ad30fdc..59ffd369a04b6eb15a8c9240ecc4aaeebfdf6bbf 100644 --- a/iot-accessControl/src/main/resources/application-dev.yml +++ b/iot-accessControl/src/main/resources/application-dev.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9998 tomcat: @@ -25,9 +26,9 @@ spring: name: iot-accessControl redis: database: 4 - host: 192.168.1.109 + host: 192.168.56.21 port: 6379 - password: hc12345678 + password: park pool: max-active: 300 max-wait: 10000 @@ -35,6 +36,17 @@ spring: min-idle: 0 timeout: 0 maxWaitMillis: 20000 + datasource: + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + druid: + initial-size: 5 + max-active: 10 + min-idle: 5 + max-wait: 60000 feign: client: diff --git a/iot-accessControl/src/main/resources/application-zihao.yml b/iot-accessControl/src/main/resources/application-zihao.yml index 5961625cbc9449e782cdfb8ffdff7c77dc3699ea..8e0e8ba15d3652f1af58b4e11dbbef94471ae9f3 100644 --- a/iot-accessControl/src/main/resources/application-zihao.yml +++ b/iot-accessControl/src/main/resources/application-zihao.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9998 tomcat: diff --git a/iot-accessControl/src/main/resources/dataSource-zihao.yml b/iot-accessControl/src/main/resources/dataSource-zihao.yml index 6736e1cc047482980145e1609ea71aa19fe3d578..c4fc75afb42c0917db6ad7682976fc65c512b8ba 100644 --- a/iot-accessControl/src/main/resources/dataSource-zihao.yml +++ b/iot-accessControl/src/main/resources/dataSource-zihao.yml @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-accessControl/src/main/resources/dataSource.yml b/iot-accessControl/src/main/resources/dataSource.yml index 8226eb288c8a87ac479007a9630ecb7cd2cffd35..f05af6bebd44af3da720600f6c9858608519784e 100644 --- a/iot-accessControl/src/main/resources/dataSource.yml +++ b/iot-accessControl/src/main/resources/dataSource.yml @@ -1,9 +1,9 @@ dataSources: ds0: !!com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.100.108:3306/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 - username: hc_iot - password: hc_iot12345678 + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 minIdle: 5 validationQuery: SELECT 1 FROM DUAL initialSize: 5 @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-acct/src/main/java/com/java110/acct/AcctApplicationStart.java b/iot-acct/src/main/java/com/java110/acct/AcctApplicationStart.java index 92878ffc04452644dfdb357c38557b73bc5fbfed..06914aab065ac21e4befe84ba3ec983649d814d8 100644 --- a/iot-acct/src/main/java/com/java110/acct/AcctApplicationStart.java +++ b/iot-acct/src/main/java/com/java110/acct/AcctApplicationStart.java @@ -43,6 +43,12 @@ import java.util.concurrent.TimeUnit; }) @EnableFeignClients(basePackages = { "com.java110.intf.user", + "com.java110.intf.car", + "com.java110.intf.community", + "com.java110.intf.charge", + "com.java110.intf.system", + "com.java110.intf.meter", + "com.java110.intf.barrier", }) @Java110CmdDiscovery(cmdPublishClass = ServiceCmdEventPublishing.class, basePackages = {"com.java110.acct.cmd"}) diff --git a/iot-acct/src/main/java/com/java110/acct/payment/adapt/wechat/WechatPaymentFactoryAdapt.java b/iot-acct/src/main/java/com/java110/acct/payment/adapt/wechat/WechatPaymentFactoryAdapt.java index a749889d3f36ad6696b3a7c6434c3bfd8c1d8546..b59a892957365743695bfda5bb356658eaf9826e 100644 --- a/iot-acct/src/main/java/com/java110/acct/payment/adapt/wechat/WechatPaymentFactoryAdapt.java +++ b/iot-acct/src/main/java/com/java110/acct/payment/adapt/wechat/WechatPaymentFactoryAdapt.java @@ -169,15 +169,15 @@ public class WechatPaymentFactoryAdapt implements IPaymentFactoryAdapt { SortedMap paramMap = new TreeMap(); paramMap.put("appid", smallWeChatDto.getAppId()); + paramMap.put("body", feeName); paramMap.put("mch_id", mchId); paramMap.put("nonce_str", PayUtil.makeUUID(32)); - paramMap.put("body", feeName); + paramMap.put("notify_url", notifyUrl); + paramMap.put("openid", openid); paramMap.put("out_trade_no", orderNum); - paramMap.put("total_fee", PayUtil.moneyToIntegerStr(payAmount)); paramMap.put("spbill_create_ip", PayUtil.getLocalIp()); - paramMap.put("notify_url", notifyUrl); + paramMap.put("total_fee", PayUtil.moneyToIntegerStr(payAmount)); paramMap.put("trade_type", tradeType); - paramMap.put("openid", openid); String paySwitch = MappingCache.getValue(DOMAIN_WECHAT_PAY, WECHAT_SERVICE_PAY_SWITCH); if (WECHAT_SERVICE_PAY_SWITCH_ON.equals(paySwitch)) { diff --git a/iot-acct/src/main/resources/application-dev.yml b/iot-acct/src/main/resources/application-dev.yml index c47ebd3a95c635b102bfa540f1520418ec6eedd6..589d339be40d676bb2aae4b9e58d2db0af27d6c1 100644 --- a/iot-acct/src/main/resources/application-dev.yml +++ b/iot-acct/src/main/resources/application-dev.yml @@ -3,13 +3,14 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: - port: 9988 + port: 9982 tomcat: uri-encoding: UTF-8 @@ -22,12 +23,12 @@ spring: enabled: true force: true application: - name: iot-charge + name: iot-acct redis: database: 4 - host: 192.168.1.109 + host: 192.168.56.21 port: 6379 - password: hc12345678 + password: park pool: max-active: 300 max-wait: 10000 @@ -35,6 +36,17 @@ spring: min-idle: 0 timeout: 0 maxWaitMillis: 20000 + datasource: + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + druid: + initial-size: 5 + max-active: 10 + min-idle: 5 + max-wait: 60000 feign: client: diff --git a/iot-acct/src/main/resources/application-zihao.yml b/iot-acct/src/main/resources/application-zihao.yml index fc4f79a688d9e67f48bc690f5eff6fffc3af1c61..34447340ec8784d1ab56a084e40aa651debad155 100644 --- a/iot-acct/src/main/resources/application-zihao.yml +++ b/iot-acct/src/main/resources/application-zihao.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9988 tomcat: @@ -23,7 +24,7 @@ spring: enabled: true force: true application: - name: iot-charge + name: iot-acct redis: database: 0 host: dev.redis.java110.com diff --git a/iot-acct/src/main/resources/dataSource-zihao.yml b/iot-acct/src/main/resources/dataSource-zihao.yml index 6736e1cc047482980145e1609ea71aa19fe3d578..c4fc75afb42c0917db6ad7682976fc65c512b8ba 100644 --- a/iot-acct/src/main/resources/dataSource-zihao.yml +++ b/iot-acct/src/main/resources/dataSource-zihao.yml @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-acct/src/main/resources/dataSource.yml b/iot-acct/src/main/resources/dataSource.yml index 8226eb288c8a87ac479007a9630ecb7cd2cffd35..f05af6bebd44af3da720600f6c9858608519784e 100644 --- a/iot-acct/src/main/resources/dataSource.yml +++ b/iot-acct/src/main/resources/dataSource.yml @@ -1,9 +1,9 @@ dataSources: ds0: !!com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.100.108:3306/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 - username: hc_iot - password: hc_iot12345678 + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 minIdle: 5 validationQuery: SELECT 1 FROM DUAL initialSize: 5 @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-acct/src/main/resources/java110.properties b/iot-acct/src/main/resources/java110.properties index 4dd80f3aab46ab3da3ced690fcc55b6df60bd55d..ea1b49f5bd3197ac0f3574026e73f76b3b0bf599 100644 --- a/iot-acct/src/main/resources/java110.properties +++ b/iot-acct/src/main/resources/java110.properties @@ -1,4 +1,4 @@ -java110.mappingPath=classpath:mapper/charge/*.xml,classpath:mapper/service/*.xml +java110.mappingPath=classpath:mapper/acct/*.xml,classpath:mapper/acct/*.xml java110.testSwitch=ON diff --git a/iot-barrier/pom.xml b/iot-barrier/pom.xml index 0f7f3922e136e4e938ac73d3727faa9bae2d2f5a..c26639f18638d743ae8d1fdb02343dafa3c2a03a 100644 --- a/iot-barrier/pom.xml +++ b/iot-barrier/pom.xml @@ -24,6 +24,21 @@ 3.8.1 test + + com.java110 + iot-hal + 1.0-SNAPSHOT + + + + + + + + + + + com.java110 java110-core diff --git a/iot-barrier/src/main/java/com/java110/barrier/BarrierApplicationStart.java b/iot-barrier/src/main/java/com/java110/barrier/BarrierApplicationStart.java index 840a3e7015cfe692ac8f4306eab00d128ce87334..d6ef729874daeb463f1c46da19ec103f6cdb15d3 100644 --- a/iot-barrier/src/main/java/com/java110/barrier/BarrierApplicationStart.java +++ b/iot-barrier/src/main/java/com/java110/barrier/BarrierApplicationStart.java @@ -7,6 +7,7 @@ import com.java110.core.cmd.ServiceCmdEventPublishing; import com.java110.core.init.ServiceStartInit; import com.java110.core.trace.Java110FeignClientInterceptor; import com.java110.core.trace.Java110RestTemplateInterceptor; +import com.java110.hal.mqtt.init.MqttConfig; import okhttp3.ConnectionPool; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -22,6 +23,7 @@ import org.springframework.cloud.client.loadbalancer.LoadBalanced; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; import org.springframework.http.converter.StringHttpMessageConverter; import javax.annotation.Resource; @@ -40,13 +42,21 @@ import java.util.concurrent.TimeUnit; "com.java110.barrier", "com.java110.core", "com.java110.doc", -}) +},scanBasePackageClasses = {MqttConfig.class}) @EnableFeignClients(basePackages = { "com.java110.intf.community", "com.java110.intf.gatway", + "com.java110.intf.job", + "com.java110.intf.car", + "com.java110.intf.gateway", + "com.java110.intf.accessControl", + "com.java110.intf.user", + "com.java110.intf.charge", + "com.java110.intf.system", + "com.java110.intf.monitor", }) @Java110CmdDiscovery(cmdPublishClass = ServiceCmdEventPublishing.class, - basePackages = {"com.java110.user.cmd"}) + basePackages = {"com.java110.barrier.cmd"}) @EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class}) @EnableDiscoveryClient public class BarrierApplicationStart { diff --git a/iot-barrier/src/main/java/com/java110/barrier/factory/CarMachineProcessFactory.java b/iot-barrier/src/main/java/com/java110/barrier/factory/CarMachineProcessFactory.java index fa2fcf732b12aa66b5d088761002df1100ba9da3..fddecf38b0f9f4da8f174e503236a6f956ad67e5 100644 --- a/iot-barrier/src/main/java/com/java110/barrier/factory/CarMachineProcessFactory.java +++ b/iot-barrier/src/main/java/com/java110/barrier/factory/CarMachineProcessFactory.java @@ -30,11 +30,11 @@ public class CarMachineProcessFactory { */ ICarMachineProcess carMachineProcessImpl = null; - IHardwareManufacturerV1InnerServiceSMO manufacturerServiceImpl = ApplicationContextFactory.getBean("hardwareManufacturerV1InnerServiceSMOImpl", IHardwareManufacturerV1InnerServiceSMO.class); + IHardwareManufacturerV1InnerServiceSMO manufacturerServiceImpl = ApplicationContextFactory.getBean(IHardwareManufacturerV1InnerServiceSMO.class.getName(), IHardwareManufacturerV1InnerServiceSMO.class); - if (manufacturerServiceImpl == null) { - manufacturerServiceImpl = ApplicationContextFactory.getBean(IHardwareManufacturerV1InnerServiceSMO.class.getName(), IHardwareManufacturerV1InnerServiceSMO.class); - } +// if (manufacturerServiceImpl == null) { +// manufacturerServiceImpl = ApplicationContextFactory.getBean(IHardwareManufacturerV1InnerServiceSMO.class.getName(), IHardwareManufacturerV1InnerServiceSMO.class); +// } HardwareManufacturerDto tmpManufacturerDto = new HardwareManufacturerDto(); tmpManufacturerDto.setHmType(HardwareManufacturerDto.HM_TYPE_BARRIER); diff --git a/iot-barrier/src/main/resources/application-dev.yml b/iot-barrier/src/main/resources/application-dev.yml index df2a3d87f73de7cac1a6198ee4de54da32b07ea4..7cb04e61c4aa44ad7148b7646289c646a9d9a0a3 100644 --- a/iot-barrier/src/main/resources/application-dev.yml +++ b/iot-barrier/src/main/resources/application-dev.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9996 tomcat: @@ -25,9 +26,9 @@ spring: name: iot-barrier redis: database: 4 - host: 192.168.1.109 + host: 192.168.56.21 port: 6379 - password: hc12345678 + password: park pool: max-active: 300 max-wait: 10000 @@ -35,6 +36,28 @@ spring: min-idle: 0 timeout: 0 maxWaitMillis: 20000 + mqtt: + client: + id: java110-client-id8 + completionTimeout: 10 + default: + topic: topic + url: tcp://127.0.0.1:12001 + username: admin + password: public + keepalive: 20 + poolSize: 20 + datasource: + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + druid: + initial-size: 5 + max-active: 10 + min-idle: 5 + max-wait: 60000 feign: client: diff --git a/iot-barrier/src/main/resources/application-zihao.yml b/iot-barrier/src/main/resources/application-zihao.yml index 575eb8fe3ceb43b6f47feeb8f8ee10b4cd0c6eda..34bd9b5ff55b36ba9752e0511c66f7f05e9182cd 100644 --- a/iot-barrier/src/main/resources/application-zihao.yml +++ b/iot-barrier/src/main/resources/application-zihao.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9996 tomcat: diff --git a/iot-barrier/src/main/resources/dataSource-zihao.yml b/iot-barrier/src/main/resources/dataSource-zihao.yml index 6736e1cc047482980145e1609ea71aa19fe3d578..c4fc75afb42c0917db6ad7682976fc65c512b8ba 100644 --- a/iot-barrier/src/main/resources/dataSource-zihao.yml +++ b/iot-barrier/src/main/resources/dataSource-zihao.yml @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-barrier/src/main/resources/dataSource.yml b/iot-barrier/src/main/resources/dataSource.yml index 8226eb288c8a87ac479007a9630ecb7cd2cffd35..f05af6bebd44af3da720600f6c9858608519784e 100644 --- a/iot-barrier/src/main/resources/dataSource.yml +++ b/iot-barrier/src/main/resources/dataSource.yml @@ -1,9 +1,9 @@ dataSources: ds0: !!com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.100.108:3306/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 - username: hc_iot - password: hc_iot12345678 + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 minIdle: 5 validationQuery: SELECT 1 FROM DUAL initialSize: 5 @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-barrier/src/test/java/com/java110/AppTest.java b/iot-barrier/src/test/java/com/java110/AppTest.java index 3880484620aa5fcc88cf62c409dc7aabbcd72d58..a1f14eb09622bdb008f4d32e1d6a10b539bf34f4 100644 --- a/iot-barrier/src/test/java/com/java110/AppTest.java +++ b/iot-barrier/src/test/java/com/java110/AppTest.java @@ -5,8 +5,6 @@ import com.java110.core.utils.Base64Convert; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; -import sun.misc.BASE64Decoder; - import java.io.IOException; import org.apache.commons.codec.binary.Base64; diff --git a/iot-broker/pom.xml b/iot-broker/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..807568957d13ef9599e1e4f05a5b6945acf71dd4 --- /dev/null +++ b/iot-broker/pom.xml @@ -0,0 +1,48 @@ + + + MicroCommunityIot + com.java110 + 1.0-SNAPSHOT + + 4.0.0 + + iot-broker + jar + + iot-broker + http://maven.apache.org + + + UTF-8 + + + + + junit + junit + 3.8.1 + test + + + com.java110 + java110-core + + + com.java110 + java110-db + + + com.java110 + java110-doc + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + diff --git a/iot-broker/src/main/java/com/java110/MqttBrokerServerApp.java b/iot-broker/src/main/java/com/java110/MqttBrokerServerApp.java new file mode 100644 index 0000000000000000000000000000000000000000..12a13d7fffd205b230f91bc7138574cb5407061f --- /dev/null +++ b/iot-broker/src/main/java/com/java110/MqttBrokerServerApp.java @@ -0,0 +1,111 @@ +package com.java110; + +import com.java110.broker.mqtt.MqttServer; +import com.java110.core.annotation.Java110CmdDiscovery; +import com.java110.core.client.OutRestTemplate; +import com.java110.core.client.RestTemplate; +import com.java110.core.cmd.ServiceCmdEventPublishing; +import com.java110.core.init.ServiceStartInit; +import com.java110.core.trace.Java110FeignClientInterceptor; +import com.java110.core.trace.Java110RestTemplateInterceptor; +import okhttp3.ConnectionPool; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.client.loadbalancer.LoadBalanced; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.http.converter.StringHttpMessageConverter; + +import javax.annotation.Resource; +import java.nio.charset.Charset; +import java.util.concurrent.TimeUnit; + +@SpringBootApplication(scanBasePackages = { + "com.java110.car", + "com.java110.core", + "com.java110.doc", + "com.java110.broker", +}) +@EnableFeignClients(basePackages = { + "com.java110.intf.barrier", +}) + +@EnableDiscoveryClient +public class MqttBrokerServerApp implements CommandLineRunner +{ + @Autowired + private MqttServer mqttService; + private static Logger logger = LoggerFactory.getLogger(MqttBrokerServerApp.class); + + @Resource + private Java110RestTemplateInterceptor java110RestTemplateInterceptor; + + @Bean + @LoadBalanced + public RestTemplate restTemplate() { + StringHttpMessageConverter m = new StringHttpMessageConverter(Charset.forName("UTF-8")); + RestTemplate restTemplate = new RestTemplateBuilder().additionalMessageConverters(m).build(RestTemplate.class); + restTemplate.getInterceptors().add(java110RestTemplateInterceptor); + return restTemplate; + } + + /** + * 实例化RestTemplate + * + * @return restTemplate + */ + @Bean + public OutRestTemplate outRestTemplate() { + StringHttpMessageConverter m = new StringHttpMessageConverter(Charset.forName("UTF-8")); + OutRestTemplate restTemplate = new RestTemplateBuilder().additionalMessageConverters(m).build(OutRestTemplate.class); + return restTemplate; + } + + @Bean + @ConditionalOnBean(Java110FeignClientInterceptor.class) + public okhttp3.OkHttpClient okHttpClient(@Autowired + Java110FeignClientInterceptor okHttpLoggingInterceptor){ + okhttp3.OkHttpClient.Builder ClientBuilder = new okhttp3.OkHttpClient.Builder() + .readTimeout(30, TimeUnit.SECONDS) //读取超时 + .connectTimeout(10, TimeUnit.SECONDS) //连接超时 + .writeTimeout(60, TimeUnit.SECONDS) //写入超时 + .connectionPool(new ConnectionPool(10 /*maxIdleConnections*/, 3, TimeUnit.MINUTES)) + .addInterceptor(okHttpLoggingInterceptor); + return ClientBuilder.build(); + } + + + public static void main(String[] args) throws Exception { + try { + ServiceStartInit.preInitSystemConfig(); + ApplicationContext context = SpringApplication.run(MqttBrokerServerApp.class, args); + new Thread(new Runnable() { + public void run() { + try { + context.getBean(MqttServer.class).start(); + } catch (Throwable $ex) { + throw $ex; + } + } + }).start(); + //服务启动加载 + ServiceStartInit.initSystemConfig(context); + } catch (Throwable e) { + logger.error("系统启动失败", e); + } + } + @Override + public void run(String... args) throws Exception { + + } +} diff --git a/iot-broker/src/main/java/com/java110/broker/controller/HkISApiController.java b/iot-broker/src/main/java/com/java110/broker/controller/HkISApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..09b7c29a30f889775568d2e735266df1450b6283 --- /dev/null +++ b/iot-broker/src/main/java/com/java110/broker/controller/HkISApiController.java @@ -0,0 +1,62 @@ +package com.java110.broker.controller; + +import com.java110.broker.service.HkISApiRequestService; +import com.java110.intf.barrier.IBarrierV1InnerServiceSMO; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; +import java.util.Map; + +@RestController +public class HkISApiController { + private static final Logger log = LoggerFactory.getLogger(HkISApiController.class); + + @Autowired + HkISApiRequestService hkISApiRequestService; + + @RequestMapping("/hc/barrier/request") + public String printParameters(HttpServletRequest request) { + + if (request instanceof MultipartHttpServletRequest) { + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; + // 获取所有上传的文件 + Map> fileMap = multipartRequest.getMultiFileMap(); + + // 循环打印所有上传的文件 + for (Map.Entry> entry : fileMap.entrySet()) { + String paramName = entry.getKey(); + List files = entry.getValue(); + + for (MultipartFile file : files) { + log.info("File Parameter Name: " + paramName); + log.info("File Name: " + file.getOriginalFilename()); + log.info("File Size: " + file.getSize() + " bytes"); + log.info("File Content Type: " + file.getContentType()); + + if (file.getContentType() != null) { + if (file.getContentType().startsWith("application/xml") || file.getContentType().startsWith("text/xml")) { + hkISApiRequestService.parseXmlData(file); + } else if (file.getContentType().startsWith("image")) { + hkISApiRequestService.parseImageData(file); + } else { + log.info("Unsupported file type: " + file.getContentType()); + } + } else { + log.info("File content type is null."); + } + } + } + } else { + return "Request is not a multipart request."; + } + + return "Parameters received and printed."; + } + +} diff --git a/iot-broker/src/main/java/com/java110/broker/model/BarrierPo.java b/iot-broker/src/main/java/com/java110/broker/model/BarrierPo.java new file mode 100644 index 0000000000000000000000000000000000000000..9506cbfbbce1dafd54373a557e28ef0bff0758af --- /dev/null +++ b/iot-broker/src/main/java/com/java110/broker/model/BarrierPo.java @@ -0,0 +1,166 @@ +/* + * Copyright 2017-2020 吴学文 and java110 team. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.java110.broker.model; + +import java.io.Serializable; + +/** + * 类表述: Po 数据模型实体对象 基本保持与数据库模型一直 用于 增加修改删除 等时的数据载体 + * add by 吴学文 at 2023-09-21 01:05:11 mail: 928255095@qq.com + * open source address: https://gitee.com/wuxw7/MicroCommunity + * 官网:http://www.homecommunity.cn + * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下 + * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行 + */ +public class BarrierPo implements Serializable { + + private String heartbeatTime; + private String implBean; + private String machineId; + private String machineCode; + private String statusCd = "0"; + private String communityId; + private String machineName; + private String machineIp; + private Integer machinePort; + private String machineLoginName; + private String machinePassword; + private String direction; + private String boxId; + + private String monitorId; + private String monitorName; + + public Integer getMachinePort() { + return machinePort; + } + + public void setMachinePort(Integer machinePort) { + this.machinePort = machinePort; + } + + public String getMachineLoginName() { + return machineLoginName; + } + + public void setMachineLoginName(String machineLoginName) { + this.machineLoginName = machineLoginName; + } + + public String getMachinePassword() { + return machinePassword; + } + + public void setMachinePassword(String machinePassword) { + this.machinePassword = machinePassword; + } + + public String getHeartbeatTime() { + return heartbeatTime; + } + + public void setHeartbeatTime(String heartbeatTime) { + this.heartbeatTime = heartbeatTime; + } + + public String getImplBean() { + return implBean; + } + + public void setImplBean(String implBean) { + this.implBean = implBean; + } + + public String getMachineId() { + return machineId; + } + + public void setMachineId(String machineId) { + this.machineId = machineId; + } + + public String getMachineCode() { + return machineCode; + } + + public void setMachineCode(String machineCode) { + this.machineCode = machineCode; + } + + public String getStatusCd() { + return statusCd; + } + + public void setStatusCd(String statusCd) { + this.statusCd = statusCd; + } + + public String getCommunityId() { + return communityId; + } + + public void setCommunityId(String communityId) { + this.communityId = communityId; + } + + public String getMachineName() { + return machineName; + } + + public void setMachineName(String machineName) { + this.machineName = machineName; + } + + public String getMachineIp() { + return machineIp; + } + + public void setMachineIp(String machineIp) { + this.machineIp = machineIp; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getBoxId() { + return boxId; + } + + public void setBoxId(String boxId) { + this.boxId = boxId; + } + + public String getMonitorId() { + return monitorId; + } + + public void setMonitorId(String monitorId) { + this.monitorId = monitorId; + } + + public String getMonitorName() { + return monitorName; + } + + public void setMonitorName(String monitorName) { + this.monitorName = monitorName; + } +} diff --git a/iot-broker/src/main/java/com/java110/broker/mqtt/JsonUtil.java b/iot-broker/src/main/java/com/java110/broker/mqtt/JsonUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..9cc700cdc3a4299ca4c595ebbff4b13030936a03 --- /dev/null +++ b/iot-broker/src/main/java/com/java110/broker/mqtt/JsonUtil.java @@ -0,0 +1,20 @@ +package com.java110.broker.mqtt; + +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.StringUtils; + +public class JsonUtil { + + public static boolean isJsonObject(String content) { + if (StringUtils.isBlank(content)) { + return false; + } else { + try { + JSONObject jsonStr = JSONObject.parseObject(content); + return true; + } catch (Exception var2) { + return false; + } + } + } +} \ No newline at end of file diff --git a/iot-broker/src/main/java/com/java110/broker/mqtt/MonitorMsgTime.java b/iot-broker/src/main/java/com/java110/broker/mqtt/MonitorMsgTime.java new file mode 100644 index 0000000000000000000000000000000000000000..a89572873d1b62b5e95aed77553a5b6f04567d35 --- /dev/null +++ b/iot-broker/src/main/java/com/java110/broker/mqtt/MonitorMsgTime.java @@ -0,0 +1,60 @@ +package com.java110.broker.mqtt; + +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.mqtt.MqttMessage; +import io.netty.handler.codec.mqtt.MqttPublishMessage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.net.InetSocketAddress; +import java.util.concurrent.ScheduledFuture; + +/** + * @author: zhouwenjie + * @description: 判断策略相关消息是否在规定时间段内发送,获取结束状态 + * @create: 2021-01-07 16:09 + **/ +public class MonitorMsgTime implements Runnable { + private static final Logger log = LoggerFactory.getLogger(MonitorMsgTime.class); + private Integer packetId; + private MqttMessage mqttMessage; + private ChannelHandlerContext ctx; + + public MonitorMsgTime(Integer packetId, MqttMessage mqttMessage, ChannelHandlerContext ctx) { + this.packetId = packetId; + this.mqttMessage = mqttMessage; + this.ctx = ctx; + } + + @Override + public void run() { + //注意,整个执行过程中,代码报错,线程就会终止 + InetSocketAddress address = (InetSocketAddress) ctx.channel().remoteAddress(); + if (ctx != null && ctx.channel().isActive()) { + log.info("重复发送消息给客户端:" + address.getHostString()); + if (mqttMessage instanceof MqttPublishMessage) { + //推送的原始消息,每次推送,都需要重新拷贝一份 + try { + MqttPublishMessage mqttPublishMessage = (MqttPublishMessage) mqttMessage; + ByteBuf byteBuf = mqttPublishMessage.payload(); + byteBuf.retainedDuplicate(); + ctx.writeAndFlush(mqttPublishMessage); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } else { + //回复的ack类型消息 + ctx.writeAndFlush(mqttMessage); + } + } else { + log.error(address.getHostString() + " 客户端断开,结束重复发送"); + //如果离线了,就不发了 + ScheduledFuture scheduledFuture = TimerData.scheduledFutureMap.remove(packetId); + if (scheduledFuture != null) { + scheduledFuture.cancel(true); + } + } + } +} diff --git a/iot-broker/src/main/java/com/java110/broker/mqtt/MqttCodecUtil.java b/iot-broker/src/main/java/com/java110/broker/mqtt/MqttCodecUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..24767b8d62fd65e74c3c656b24131fa01c2fb9ea --- /dev/null +++ b/iot-broker/src/main/java/com/java110/broker/mqtt/MqttCodecUtil.java @@ -0,0 +1,96 @@ +package com.java110.broker.mqtt; + +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.DecoderException; +import io.netty.handler.codec.mqtt.MqttFixedHeader; +import io.netty.handler.codec.mqtt.MqttQoS; +import io.netty.handler.codec.mqtt.MqttVersion; +import io.netty.util.Attribute; +import io.netty.util.AttributeKey; + +public class MqttCodecUtil { + + private static final char[] TOPIC_WILDCARDS = new char[]{'#', '+'}; + static final AttributeKey MQTT_VERSION_KEY = AttributeKey.valueOf("NETTY_CODEC_MQTT_VERSION"); + + static MqttVersion getMqttVersion(ChannelHandlerContext ctx) { + Attribute attr = ctx.channel().attr(MQTT_VERSION_KEY); + MqttVersion version = (MqttVersion)attr.get(); + return version == null ? MqttVersion.MQTT_3_1_1 : version; + } + + static void setMqttVersion(ChannelHandlerContext ctx, MqttVersion version) { + Attribute attr = ctx.channel().attr(MQTT_VERSION_KEY); + attr.set(version); + } + + static boolean isValidPublishTopicName(String topicName) { + for(char c : TOPIC_WILDCARDS) { + if (topicName.indexOf(c) >= 0) { + return false; + } + } + + return true; + } + + static boolean isValidMessageId(int messageId) { + return messageId != 0; + } + + static boolean isValidClientId(MqttVersion mqttVersion, int maxClientIdLength, String clientId) { + if (mqttVersion != MqttVersion.MQTT_3_1) { + if (mqttVersion != MqttVersion.MQTT_3_1_1) { + throw new IllegalArgumentException(mqttVersion + " is unknown mqtt version"); + } else { + return clientId != null; + } + } else { + return clientId != null && clientId.length() >= 1 && clientId.length() <= maxClientIdLength; + } + } + + static MqttFixedHeader validateFixedHeader(ChannelHandlerContext ctx, MqttFixedHeader mqttFixedHeader) { + switch (mqttFixedHeader.messageType()) { + case PUBREL: + case SUBSCRIBE: + case UNSUBSCRIBE: + if (mqttFixedHeader.qosLevel() != MqttQoS.AT_LEAST_ONCE) { + throw new DecoderException(mqttFixedHeader.messageType().name() + " message must have QoS 1"); + } + + return mqttFixedHeader; + default: + return mqttFixedHeader; + } + } + + static MqttFixedHeader resetUnusedFields(MqttFixedHeader mqttFixedHeader) { + switch (mqttFixedHeader.messageType()) { + case PUBREL: + case SUBSCRIBE: + case UNSUBSCRIBE: + if (mqttFixedHeader.isRetain()) { + return new MqttFixedHeader(mqttFixedHeader.messageType(), mqttFixedHeader.isDup(), mqttFixedHeader.qosLevel(), false, mqttFixedHeader.remainingLength()); + } + + return mqttFixedHeader; + default: + return mqttFixedHeader; + case CONNECT: + case CONNACK: + case PUBACK: + case PUBREC: + case PUBCOMP: + case SUBACK: + case UNSUBACK: + case PINGREQ: + case PINGRESP: + case DISCONNECT: + return !mqttFixedHeader.isDup() && mqttFixedHeader.qosLevel() == MqttQoS.AT_MOST_ONCE && !mqttFixedHeader.isRetain() ? mqttFixedHeader : new MqttFixedHeader(mqttFixedHeader.messageType(), false, MqttQoS.AT_MOST_ONCE, false, mqttFixedHeader.remainingLength()); + } + } + + private MqttCodecUtil() { + } +} \ No newline at end of file diff --git a/iot-broker/src/main/java/com/java110/broker/mqtt/MqttMessageIdGenerator.java b/iot-broker/src/main/java/com/java110/broker/mqtt/MqttMessageIdGenerator.java new file mode 100644 index 0000000000000000000000000000000000000000..d94ad34e444560ecc132590b29f508ab41e1c972 --- /dev/null +++ b/iot-broker/src/main/java/com/java110/broker/mqtt/MqttMessageIdGenerator.java @@ -0,0 +1,19 @@ +package com.java110.broker.mqtt; + +import org.springframework.stereotype.Component; + +import java.util.concurrent.atomic.AtomicInteger; +@Component +public class MqttMessageIdGenerator { + private static final int MAX_MESSAGE_ID = 65535; + private AtomicInteger messageIdCounter = new AtomicInteger(1); + + public synchronized int nextMessageId() { + int messageId = messageIdCounter.getAndIncrement(); + if (messageId > MAX_MESSAGE_ID) { + messageIdCounter.set(1); + messageId = messageIdCounter.getAndIncrement(); + } + return messageId; + } +} \ No newline at end of file diff --git a/iot-broker/src/main/java/com/java110/broker/mqtt/MqttMsgBack.java b/iot-broker/src/main/java/com/java110/broker/mqtt/MqttMsgBack.java new file mode 100644 index 0000000000000000000000000000000000000000..6b7dd86a492e2bee3fdb8ad15748bc5feb6fb362 --- /dev/null +++ b/iot-broker/src/main/java/com/java110/broker/mqtt/MqttMsgBack.java @@ -0,0 +1,533 @@ +package com.java110.broker.mqtt; + +import com.java110.broker.service.MqttServiceHandler; +import com.java110.broker.utils.MqttCommonUtils; +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.mqtt.MqttConnAckMessage; +import io.netty.handler.codec.mqtt.MqttConnAckVariableHeader; +import io.netty.handler.codec.mqtt.MqttConnectMessage; +import io.netty.handler.codec.mqtt.MqttConnectReturnCode; +import io.netty.handler.codec.mqtt.MqttConnectVariableHeader; +import io.netty.handler.codec.mqtt.MqttFixedHeader; +import io.netty.handler.codec.mqtt.MqttMessage; +import io.netty.handler.codec.mqtt.MqttMessageIdVariableHeader; +import io.netty.handler.codec.mqtt.MqttMessageType; +import io.netty.handler.codec.mqtt.MqttPubAckMessage; +import io.netty.handler.codec.mqtt.MqttPublishMessage; +import io.netty.handler.codec.mqtt.MqttPublishVariableHeader; +import io.netty.handler.codec.mqtt.MqttQoS; +import io.netty.handler.codec.mqtt.MqttSubAckMessage; +import io.netty.handler.codec.mqtt.MqttSubAckPayload; +import io.netty.handler.codec.mqtt.MqttSubscribeMessage; +import io.netty.handler.codec.mqtt.MqttSubscribePayload; +import io.netty.handler.codec.mqtt.MqttTopicSubscription; +import io.netty.handler.codec.mqtt.MqttUnsubAckMessage; +import io.netty.handler.codec.mqtt.MqttUnsubscribeMessage; +import io.netty.util.ReferenceCountUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.net.InetSocketAddress; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; + +import static io.netty.handler.codec.mqtt.MqttMessageType.PUBACK; +import static io.netty.handler.codec.mqtt.MqttMessageType.PUBREC; +import static io.netty.handler.codec.mqtt.MqttQoS.AT_LEAST_ONCE; +import static io.netty.handler.codec.mqtt.MqttQoS.AT_MOST_ONCE; +import static io.netty.handler.codec.mqtt.MqttQoS.EXACTLY_ONCE; + +/** + * @author: zhouwenjie + * @description: 对接收到的消息进行业务处理 + * @create: 2023-04-07 16:29 + * CONNECT 1 C->S 客户端请求与服务端建立连接 (服务端接收) + * CONNACK 2 S->C 服务端确认连接建立(客户端接收) + * PUBLISH 3 CóS 发布消息 (服务端接收【QoS(服务质量等级) 0级别,最多分发一次】)-->生产者只会发送一次消息,不关心消息是否被代理服务端或消费者收到 + * PUBACK 4 CóS 收到发布消息确认(客户端接收【QoS 1级别,至少分发一次】) -->保证消息发送到服务端(也就是代理服务器broker),如果没收到或一定时间没收到服务端的ack,就会重发消息 + * PUBREC 5 CóS 收到发布消息(客户端接收【QoS 2级别】)| + * PUBREL 6 CóS 释放发布消息(服务端接收【QoS 2级别】)|只分发一次消息,且保证到达 -->这三步保证消息有且仅有一次传递给消费者 + * PUBCOMP 7 CóS 完成发布消息(客户端接收【QoS 2级别】)| + * SUBSCRIBE 8 C->S 订阅请求(服务端接收) + * SUBACK 9 S->C 订阅确认(客户端接收) + * UNSUBSCRIBE 10 C->S 取消订阅(服务端接收) + * UNSUBACK 11 S->C 取消订阅确认(客户端接收) + * PINGREQ 12 C->S 客户端发送PING(连接保活)命令(服务端接收) + * PINGRESP 13 S->C PING命令回复(客户端接收) + * DISCONNECT 14 C->S 断开连接 (服务端接收) + *

+ * 注意:在我们发送消息的时候,一定要确认好等级,回复确认的消息统一设置为qos=0; + * 比如,我们需要发送最高等级的消息就将qos设置为2,当我们接收方收到这个等级的消息的时候判断一下等级,设置好消息类型,然后qos因为是回复消息, + * 所以全部设置成0,而当发送端收到消息之后,比如PUBREC,那么我们还将发送(注意不是回复)PUBREL给接收端,希望对方回复确认一下,所以qos设置为1。 + * 综上可知:发送端没有回复确认消息之说,只有发送消息,接收端没有发送消息之说,只有回复确认消息,搞清楚这个概念,在设置参数的时候就明了。 + **/ + +@Component +public class MqttMsgBack { + private static final Logger log = LoggerFactory.getLogger(MqttMsgBack.class); + @Value("${driver.mqtt.user_name}") + private String userName; + + @Value("${driver.mqtt.password}") + private String password; + + @Value("${driver.mqtt.wait_time}") + private long waitTime; + + @Autowired + private MqttServiceHandler mqttServiceHandler; + /** + * 功能描述:连接请求处理 + */ + public static final ConcurrentHashMap connectMap = new ConcurrentHashMap<>(); + + /** + * 功能描述:存放主题和其订阅的客户端集合 + */ + public static final ConcurrentHashMap> subMap = new ConcurrentHashMap>(); + + /** + * 功能描述:存放订阅是的服务质量等级,只有发送小于或等于这个服务质量的消息给订阅者 + */ + public static final ConcurrentHashMap qoSMap = new ConcurrentHashMap(); + + /** + * 功能描述:存放客户端和其所订阅的主题集合,用来在客户端断开的时候删除订阅中的客户端 + */ + public static final ConcurrentHashMap> ctMap = new ConcurrentHashMap>(); + + /** + * 功能描述:存放需要缓存的消息,一边发送给新订阅的客户端 + */ + public static final ConcurrentHashMap cacheRetainedMessages = new ConcurrentHashMap(); + + /** + * 功能描述:缓存需要重复发送的消息,以便在收到ack的时候将消息内存释放掉 + */ + public static final ConcurrentHashMap cacheRepeatMessages = new ConcurrentHashMap(); + + /** + * 确认连接请求 + * + * @param ctx + * @param mqttMessage + */ + public void connectionAck(ChannelHandlerContext ctx, MqttMessage mqttMessage) { + MqttConnectMessage mqttConnectMessage; + try { + mqttConnectMessage = (MqttConnectMessage) mqttMessage; + //获取连接者的ClientId + String clientIdentifier = mqttConnectMessage.payload().clientIdentifier(); + //查询用户名密码是否正确 + String userNameNow = mqttConnectMessage.payload().userName(); + String passwordNow = mqttConnectMessage.payload().password(); + if (userName.equals(userNameNow) && password.equals(passwordNow)) { + MqttFixedHeader mqttFixedHeaderInfo = mqttConnectMessage.fixedHeader(); + MqttConnectVariableHeader mqttConnectVariableHeaderInfo = mqttConnectMessage.variableHeader(); + //构建返回报文, 可变报头 + MqttConnAckVariableHeader mqttConnAckVariableHeaderBack = new MqttConnAckVariableHeader(MqttConnectReturnCode.CONNECTION_ACCEPTED, mqttConnectVariableHeaderInfo.isCleanSession()); + //构建返回报文, 固定报头 至多一次(至少—次,只有一次) + MqttFixedHeader mqttFixedHeaderBack = new MqttFixedHeader(MqttMessageType.CONNACK, mqttFixedHeaderInfo.isDup(), AT_MOST_ONCE, mqttFixedHeaderInfo.isRetain(), 0x02); + //构建连接回复消息体 + MqttConnAckMessage connAck = new MqttConnAckMessage(mqttFixedHeaderBack, mqttConnAckVariableHeaderBack); + ctx.writeAndFlush(connAck); + //设置节点名 + InetSocketAddress address = (InetSocketAddress) ctx.channel().remoteAddress(); + + if (connectMap.contains(ctx.channel().id().asLongText())) { + ChannelHandlerContext channelHandlerContext = connectMap.get(ctx.channel().id().asLongText()); + channelHandlerContext.close(); + connectMap.remove(ctx.channel().id().asLongText()); + } + connectMap.put(ctx.channel().id().asLongText(), ctx); + + log.info("终端登录成功,ID号:{},IP信息:{},终端号:{}", clientIdentifier, address.getHostString(), address.getPort()); + } else { + //如果用户名密码错误则提示对方 + MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.CONNACK, false, AT_MOST_ONCE, false, 0x02); + MqttConnAckVariableHeader variableHeader = new MqttConnAckVariableHeader(MqttConnectReturnCode.CONNECTION_REFUSED_BAD_USER_NAME_OR_PASSWORD, false); + MqttConnAckMessage mqttConnAckMessage = new MqttConnAckMessage(fixedHeader, variableHeader); + ctx.writeAndFlush(mqttConnAckMessage); + ctx.close(); + log.error("连接失败:" + MqttConnectReturnCode.CONNECTION_REFUSED_BAD_USER_NAME_OR_PASSWORD.name()); + } + } catch (ClassCastException e) { + //转换失败,对方发送的协议版本不兼容 + MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.CONNACK, false, AT_MOST_ONCE, false, 0x02); + MqttConnAckVariableHeader variableHeader = new MqttConnAckVariableHeader(MqttConnectReturnCode.CONNECTION_REFUSED_UNACCEPTABLE_PROTOCOL_VERSION, false); + MqttConnAckMessage mqttConnAckMessage = new MqttConnAckMessage(fixedHeader, variableHeader); + ctx.writeAndFlush(mqttConnAckMessage); + ctx.close(); + e.printStackTrace(); + log.error("连接失败:" + MqttConnectReturnCode.CONNECTION_REFUSED_UNACCEPTABLE_PROTOCOL_VERSION.name()); + } + } + + /** + * 根据qos发布确认 + * 1:表示发送的消息需要一直持久保存(不受服务器重启影响),不但要发送给当前的订阅者,并且以后新来的订阅了此Topic name的订阅者会马上得到推送。 + * 0:仅仅为当前订阅者推送此消息。 + * 假如服务器收到一个空消息体(zero-length payload)、RETAIN = 1、那么就代表需要将这个缓存消息删除掉,不再继续推送给新订阅者,前提是一定保证空消息体。 + * 两个条件需要对应上才能删除,消息体为空、主题名称对应. + * 注意:对于每个主题,只能保留一条消息。当发布一个带有RETAIN标志的新消息时,它将替换上一条保留的消息,因此在同一主题下只会存在一条保留消息。 + * + * @param ctx + * @param mqttMessage 拷贝的数据需要释放,其他的消息,比如连接消息,不用转发,会在handler中自动释放 + */ + public void publishAck(ChannelHandlerContext ctx, MqttMessage mqttMessage) { + MqttPublishMessage mqttPublishMessage = (MqttPublishMessage) mqttMessage; + MqttFixedHeader mqttFixedHeaderInfo = mqttPublishMessage.fixedHeader(); + MqttQoS qos = mqttFixedHeaderInfo.qosLevel(); + //得到主题 + MqttPublishVariableHeader variableHeader = mqttPublishMessage.variableHeader(); + String topicName = variableHeader.topicName(); + //将消息发送给订阅的客户端 + ByteBuf byteBuf = mqttPublishMessage.payload(); + HashSet set = subMap.get(topicName); + if (set != null) { + for (String channelId : set) { + ChannelHandlerContext context = ServerMqttHandler.clientMap.get(channelId); + if (context != null && context.channel().isActive()) { + MqttQoS cacheQos = qoSMap.get(topicName + "-" + channelId); + if (cacheQos != null && qos.value() <= cacheQos.value()) { + // retainedDuplicate()增加引用计数器,不至于后续操作byteBuf出现错误,引用计数器为0的情况,这里会清除retainedDuplicate的操作有: + // SimpleChannelInboundHandler处理器、编码器 MqttEncoder、和最后确认的时候释放,所以每次操作消息之前,先进行一次retainedDuplicate + byteBuf.retainedDuplicate(); + context.writeAndFlush(mqttPublishMessage); + if (qos == AT_LEAST_ONCE || qos == EXACTLY_ONCE) { + + //只发送服务质量等级小于等于订阅时客户端指定的服务质量等级 + // 创建一个新的缓冲区 + byteBuf.retainedDuplicate(); + //防止内存溢出,最后在消息被ack或者客户端断开掉线的时候,拿到并进行释放 + cacheRepeatMessages.put(channelId, byteBuf); + cachePublishMsg(qos, byteBuf, variableHeader, mqttFixedHeaderInfo, context); + } + } + } else { + if (context != null) { + InetSocketAddress address = (InetSocketAddress) ctx.channel().remoteAddress(); + log.error(address.getHostString() + "转发订阅消息提醒:客户端连接异常~"); + } + //防止客户端频繁上下线导致id变化,带来不必要的空指针 + ServerMqttHandler.clientMap.remove(channelId); + //删除订阅主题 + Set topicSet = ctMap.get(channelId); + if (topicSet != null && !topicSet.isEmpty()) { + for (String topic : topicSet) { + if (subMap != null) { + HashSet ids = subMap.get(topic); + if (ids != null && !ids.isEmpty()) { + ids.remove(channelId); + if (ids == null || ids.isEmpty()) { + subMap.remove(topic); + } + } + } + if (qoSMap != null) { + qoSMap.remove(topic + "-" + channelId); + } + } + } + ctMap.remove(channelId); + } + } + } + // 缓存消息给后订阅的客户端 + boolean retain = mqttFixedHeaderInfo.isRetain(); + if (retain) { + if (byteBuf.readableBytes() > 0) { + byteBuf.retainedDuplicate(); + cacheRetainedMessages.put(topicName, mqttPublishMessage); + } else { + MqttPublishMessage message = cacheRetainedMessages.get(topicName); + if (message != null) { + cacheRetainedMessages.remove(topicName); + // 这里需要手动删除ByteBuf缓存,因为一直会有一份缓存在内存中备用 + boolean release = ReferenceCountUtil.release(message); + log.info("缓存消息给后订阅的客户端释放成功失败:{}", release); + } + } + } + //返回消息给发送端 + switch (qos) { + //至多一次 + case AT_MOST_ONCE: + break; + //至少一次 + case AT_LEAST_ONCE: + //构建返回报文, 可变报头 + MqttMessageIdVariableHeader mqttMessageIdVariableHeaderBack = MqttMessageIdVariableHeader.from(mqttPublishMessage.variableHeader().packetId()); + //构建返回报文, 固定报头 + MqttFixedHeader mqttFixedHeaderBack = new MqttFixedHeader(PUBACK, mqttFixedHeaderInfo.isDup(), AT_MOST_ONCE, mqttFixedHeaderInfo.isRetain(), 0x02); + //构建PUBACK消息体 + MqttPubAckMessage pubAck = new MqttPubAckMessage(mqttFixedHeaderBack, mqttMessageIdVariableHeaderBack); + ctx.writeAndFlush(pubAck); + mqttServiceHandler.handleMessage(topicName, MqttCommonUtils.convertbyteBufToString(byteBuf)); + break; + //刚好一次 + case EXACTLY_ONCE: + //构建返回报文,固定报头 + MqttFixedHeader mqttFixedHeaderBack2 = new MqttFixedHeader(PUBREC, false, AT_MOST_ONCE, false, 0x02); + //构建返回报文,可变报头 + MqttMessageIdVariableHeader mqttPubReplyMessageVariableHeader = MqttMessageIdVariableHeader.from(mqttPublishMessage.variableHeader().packetId()); + + MqttMessage mqttMessageBack = new MqttMessage(mqttFixedHeaderBack2, mqttPubReplyMessageVariableHeader); + ctx.writeAndFlush(mqttMessageBack); + break; + default: + break; + } + } + + private void cachePublishMsg(MqttQoS qos, ByteBuf byteBuf, MqttPublishVariableHeader variableHeader, MqttFixedHeader mqttFixedHeaderInfo, ChannelHandlerContext context) { + //缓存一份消息,规定时间内没有收到ack,用作重发,重发时将isDup设置为true,代表重复消息 + MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.PUBLISH, true, qos, false, mqttFixedHeaderInfo.remainingLength()); + MqttPublishMessage cachePubMessage = new MqttPublishMessage(fixedHeader, variableHeader, byteBuf); + ScheduledFuture scheduledFuture = TimerData.scheduledThreadPoolExecutor.scheduleAtFixedRate(new MonitorMsgTime(variableHeader.packetId(), cachePubMessage, context), waitTime, waitTime, TimeUnit.MILLISECONDS); + TimerData.scheduledFutureMap.put(variableHeader.packetId(), scheduledFuture); + } + + /** + * 发布完成 qos2 + * + * @param ctx + * @param mqttMessage + */ + public void publishComp(ChannelHandlerContext ctx, MqttMessage mqttMessage) { + MqttMessageIdVariableHeader messageIdVariableHeader = (MqttMessageIdVariableHeader) mqttMessage.variableHeader(); + //构建返回报文, 固定报头 + MqttFixedHeader mqttFixedHeaderBack = new MqttFixedHeader(MqttMessageType.PUBCOMP, false, AT_MOST_ONCE, false, 0x02); + //构建返回报文, 可变报头 + MqttMessageIdVariableHeader mqttPubReplyMessageVariableHeader = MqttMessageIdVariableHeader.from(messageIdVariableHeader.messageId()); + MqttMessage mqttMessageBack = new MqttMessage(mqttFixedHeaderBack, mqttPubReplyMessageVariableHeader); + ctx.writeAndFlush(mqttMessageBack); + } + + /** + * 订阅确认 + * 订阅和取消订阅没有qos2级别,默认就是1级别 + * 需要存储订阅主题和客户端、客户端和订阅主题、验证防止重复订阅、发送缓存消息 + * + * @param ctx + * @param mqttMessage + */ + public void subscribeAck(ChannelHandlerContext ctx, MqttMessage mqttMessage) { + MqttSubscribeMessage mqttSubscribeMessage = (MqttSubscribeMessage) mqttMessage; + MqttMessageIdVariableHeader messageIdVariableHeader = mqttSubscribeMessage.variableHeader(); + //构建返回报文, 可变报头 + MqttMessageIdVariableHeader variableHeaderBack = MqttMessageIdVariableHeader.from(messageIdVariableHeader.messageId()); + MqttSubscribePayload subscribePayload = mqttSubscribeMessage.payload(); + List mqttTopicSubscriptions = subscribePayload.topicSubscriptions(); + List grantedQoSLevels = new ArrayList(); + String id = ctx.channel().id().toString(); + //存储客户端订阅的主题集合,断开或者异常连接时,删除订阅ctMap和subMap里的值 + Set topicSet = ctMap.get(id); + if (topicSet == null) { + topicSet = new HashSet(); + } + for (MqttTopicSubscription subscription : mqttTopicSubscriptions) { + String topicName = subscription.topicName(); + + HashSet contexts = subMap.get(topicName); + if (contexts == null) { + contexts = new HashSet(); + } + //先判断主题是否已经订阅过了,防止重复订阅 + boolean isSub = contexts.contains(topicName); + if (!isSub) { + MqttQoS qos = subscription.qualityOfService(); + //存储主题被订阅的客户端集合 + contexts.add(id); + qoSMap.put(topicName + "-" + id, qos); + subMap.put(topicName, contexts); + //存储客户端订阅的主题集合 + topicSet.add(topicName); + } + //存储客户端订阅的主题集合 + int value = subscription.qualityOfService().value(); + grantedQoSLevels.add(value); + } + // 构建返回报文 有效负载 + MqttSubAckPayload payloadBack = new MqttSubAckPayload(grantedQoSLevels); + // 构建返回报文 固定报头 + MqttFixedHeader mqttFixedHeaderBack = new MqttFixedHeader(MqttMessageType.SUBACK, false, AT_MOST_ONCE, false, 0); + // 构建返回报文 订阅确认 + MqttSubAckMessage subAck = new MqttSubAckMessage(mqttFixedHeaderBack, variableHeaderBack, payloadBack); + ctx.writeAndFlush(subAck); + for (String topic : topicSet) { + MqttQoS cacheQos = qoSMap.get(topic + "-" + id); + //查看订阅的主题是否需要需要发送消息 + MqttPublishMessage mqttMsg = cacheRetainedMessages.get(topic); + if (mqttMsg != null) { + MqttFixedHeader mqttFixedHeaderInfo = mqttMsg.fixedHeader(); + MqttQoS qos = mqttFixedHeaderInfo.qosLevel(); + if (cacheQos != null && qos.value() <= cacheQos.value()) { + if (mqttMsg != null) { + MqttPublishVariableHeader variableHeader = mqttMsg.variableHeader(); + ByteBuf payload = mqttMsg.payload(); + //引用计数器增加 + payload.retainedDuplicate(); + ctx.writeAndFlush(mqttMsg); + // 开启消息重发机制 + if (qos == AT_LEAST_ONCE || qos == EXACTLY_ONCE) { + //引用计数器增加 + payload.retainedDuplicate(); + cacheRepeatMessages.put(id, payload); + cachePublishMsg(qos, payload, variableHeader, mqttFixedHeaderInfo, ctx); + } + } + } + } + } + } + + /** + * 取消订阅确认 + * + * @param ctx + * @param mqttMessage + */ + public void unsubscribeAck(ChannelHandlerContext ctx, MqttMessage mqttMessage) { + MqttUnsubscribeMessage mqttUnsubscribeMessage = (MqttUnsubscribeMessage) mqttMessage; + MqttMessageIdVariableHeader messageIdVariableHeader = mqttUnsubscribeMessage.variableHeader(); + // 构建返回报文 可变报头 + MqttMessageIdVariableHeader variableHeaderBack = MqttMessageIdVariableHeader.from(messageIdVariableHeader.messageId()); + // 构建返回报文 固定报头 + MqttFixedHeader mqttFixedHeaderBack = new MqttFixedHeader(MqttMessageType.UNSUBACK, false, AT_MOST_ONCE, false, 0x02); + // 构建返回报文 取消订阅确认 + MqttUnsubAckMessage unSubAck = new MqttUnsubAckMessage(mqttFixedHeaderBack, variableHeaderBack); + log.info("取消订阅回复:{}", unSubAck); + //删除本地订阅客户端 + String id = ctx.channel().id().toString(); + List topics = mqttUnsubscribeMessage.payload().topics(); + Set topicSet = ctMap.get(id); + for (String topic : topics) { + if (subMap != null) { + HashSet ids = subMap.get(topic); + if (ids != null && !ids.isEmpty()) { + ids.remove(id); + if (ids == null || ids.isEmpty()) { + subMap.remove(topic); + } + } + } + if (qoSMap != null) { + qoSMap.remove(topic + "-" + id); + } + + if (topicSet != null && !topicSet.isEmpty()) { + topicSet.remove(topic); + } + } + ctx.writeAndFlush(unSubAck); + } + + /** + * 心跳响应 + * + * @param ctx + * @param mqttMessage + */ + public void pingResp(ChannelHandlerContext ctx, MqttMessage mqttMessage) { + MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.PINGRESP, false, AT_MOST_ONCE, false, 0); + MqttMessage mqttMessageBack = new MqttMessage(fixedHeader); + log.info("心跳回复:{}", mqttMessageBack.toString()); + ctx.writeAndFlush(mqttMessageBack); + } + + + /** + * ------------------------------------------------------服务端作为发送消息端可能会接收的事件---------------------------------------------------------------- + *

+ * 收到接收方消息确认,qos>1的情况,应该删除消息缓存(缓存消息保存到线程定时中了,循环发送取消,消息缓存也没有了),取消消息重发机制 + * + * @param ctx + * @param mqttMessage + */ + public void receivePubAck(ChannelHandlerContext ctx, MqttMessage mqttMessage) { + MqttFixedHeader fixedHeader = mqttMessage.fixedHeader(); + MqttMessageType messageType = fixedHeader.messageType(); + if (messageType == PUBACK) { + MqttMessageIdVariableHeader variableHeader = (MqttMessageIdVariableHeader) mqttMessage.variableHeader(); + int messageId = variableHeader.messageId(); + //等级为1的情况,直接删除原始消息,取消消息重发机制 + ScheduledFuture scheduledFuture = TimerData.scheduledFutureMap.remove(messageId); + if (scheduledFuture != null) { + scheduledFuture.cancel(true); + } + //移除消息记录 + ByteBuf byteBuf = cacheRepeatMessages.remove(ctx.channel().id().toString()); + if (byteBuf != null) { + // 释放内存 + byteBuf.release(); + } + } + if (messageType == PUBREC) { + //等级为2的情况,收到PUBREC报文消息,先停止消息重发机制,再响应一个PUBREL报文并且构建消息重发机制 + MqttMessageIdVariableHeader variableHeader = (MqttMessageIdVariableHeader) mqttMessage.variableHeader(); + int messageId = variableHeader.messageId(); + //构建返回报文,固定报头 + MqttFixedHeader mqttFixedHeaderBack = new MqttFixedHeader(MqttMessageType.PUBREL, false, AT_LEAST_ONCE, false, 0); + //构建返回报文,可变报头 + MqttMessageIdVariableHeader mqttPubReplyMessageVariableHeader = MqttMessageIdVariableHeader.from(messageId); + MqttMessage mqttMessageBack = new MqttMessage(mqttFixedHeaderBack, mqttPubReplyMessageVariableHeader); + //删除初始消息重发机制 + ScheduledFuture scheduledFuture = TimerData.scheduledFutureMap.remove(messageId); + if (scheduledFuture != null) { + scheduledFuture.cancel(true); + } + //释放消息缓存 + ByteBuf byteBuf = cacheRepeatMessages.remove(ctx.channel().id().toString()); + if (byteBuf != null) { + byteBuf.release(); + } + ctx.writeAndFlush(mqttMessageBack); + //重发机制要放在最下方,否则,一旦出错,会多次出发此机制 + cachePubrelMsg(messageId, ctx); + } + } + + private void cachePubrelMsg(int messageId, ChannelHandlerContext context) { + //缓存一份消息,规定时间内没有收到ack,用作重发,重发时将isDup设置为true,代表重复消息 + //构建返回报文,固定报头 + MqttFixedHeader mqttFixedHeaderBack = new MqttFixedHeader(MqttMessageType.PUBREL, true, AT_LEAST_ONCE, false, 0); + //构建返回报文,可变报头 + MqttMessageIdVariableHeader mqttMessageIdVariableHeaderBack = MqttMessageIdVariableHeader.from(messageId); + MqttMessage mqttMessageBack = new MqttMessage(mqttFixedHeaderBack, mqttMessageIdVariableHeaderBack); + ScheduledFuture scheduledFuture = TimerData.scheduledThreadPoolExecutor.scheduleAtFixedRate(new MonitorMsgTime(messageId, mqttMessageBack, context), waitTime, waitTime, TimeUnit.MILLISECONDS); + TimerData.scheduledFutureMap.put(messageId, scheduledFuture); + } + + /** + * 功能描述: 接收到最后一次确认,取消上次PUBREL的消息重发机制 + * + * @param ctx + * @param mqttMessage + * @return void + * @author zhouwenjie + * @date 2023/6/9 16:00 + */ + public void receivePubcomp(ChannelHandlerContext ctx, MqttMessage mqttMessage) { + MqttMessageIdVariableHeader variableHeader = (MqttMessageIdVariableHeader) mqttMessage.variableHeader(); + int messageId = variableHeader.messageId(); + ScheduledFuture scheduledFuture = TimerData.scheduledFutureMap.remove(messageId); + if (scheduledFuture != null) { + scheduledFuture.cancel(true); + } + ByteBuf byteBuf = cacheRepeatMessages.remove(ctx.channel().id().toString()); + if (byteBuf != null) { + byteBuf.release(); + } + } +} + diff --git a/iot-broker/src/main/java/com/java110/broker/mqtt/MqttRequest.java b/iot-broker/src/main/java/com/java110/broker/mqtt/MqttRequest.java new file mode 100644 index 0000000000000000000000000000000000000000..f8e224ed60e575f87cda4e4e08b7174a8714cbb6 --- /dev/null +++ b/iot-broker/src/main/java/com/java110/broker/mqtt/MqttRequest.java @@ -0,0 +1,95 @@ +package com.java110.broker.mqtt; + +import io.netty.handler.codec.mqtt.MqttQoS; + +public class MqttRequest { + private boolean mutable = true; + private byte[] payload; + private MqttQoS qos; + private boolean retained; + private boolean dup; + private int messageId; + + public MqttRequest() { + this.qos = MqttQoS.AT_LEAST_ONCE; + this.retained = false; + this.dup = false; + this.setPayload(new byte[0]); + } + + public MqttRequest(byte[] payload) { + this.qos = MqttQoS.AT_LEAST_ONCE; + this.retained = false; + this.dup = false; + this.setPayload(payload); + } + + public byte[] getPayload() { + return this.payload; + } + + public void clearPayload() { + this.checkMutable(); + this.payload = new byte[0]; + } + + public void setPayload(byte[] payload) { + this.checkMutable(); + if (payload == null) { + throw new NullPointerException(); + } else { + this.payload = payload; + } + } + + public boolean isRetained() { + return this.retained; + } + + public void setRetained(boolean retained) { + this.checkMutable(); + this.retained = retained; + } + + public MqttQoS getQos() { + return this.qos; + } + + public void setQos(MqttQoS qos) { + this.qos = qos; + } + + public boolean isMutable() { + return this.mutable; + } + + public void setMutable(boolean mutable) { + this.mutable = mutable; + } + + protected void checkMutable() throws IllegalStateException { + if (!this.mutable) { + throw new IllegalStateException(); + } + } + + public boolean isDup() { + return this.dup; + } + + public void setDup(boolean dup) { + this.dup = dup; + } + + public int getMessageId() { + return this.messageId; + } + + public void setMessageId(int messageId) { + this.messageId = messageId; + } + + public String toString() { + return new String(this.payload); + } +} diff --git a/iot-broker/src/main/java/com/java110/broker/mqtt/MqttServer.java b/iot-broker/src/main/java/com/java110/broker/mqtt/MqttServer.java new file mode 100644 index 0000000000000000000000000000000000000000..2d7acd35c60fa66b10ea220b8f0a3763630a1ce5 --- /dev/null +++ b/iot-broker/src/main/java/com/java110/broker/mqtt/MqttServer.java @@ -0,0 +1,89 @@ +package com.java110.broker.mqtt; + +import io.netty.bootstrap.ServerBootstrap; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelOption; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.nio.NioServerSocketChannel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import javax.annotation.PreDestroy; + +/** + * @author: zhouwenjie + * @description: netty启动配置类 + * @create: 2020-04-03 11:43 + **/ +@Component +public class MqttServer { + + private static final Logger log = LoggerFactory.getLogger(MqttServer.class); + + @Autowired + private MqttServerChannelInitializer mqttServerChannelInitializer; + + private NioEventLoopGroup bossGroup; + + private NioEventLoopGroup workerGroup; + + private ChannelFuture future; + + @Value("${driver.mqtt.socket_port:12001}") + private int socketPort; + + public void start() { + //创建接收请求和处理请求的实例(默认线程数为 CPU 核心数乘以2也可自定义) + bossGroup = new NioEventLoopGroup(3); + workerGroup = new NioEventLoopGroup(6); + try { + //创建服务端启动辅助类(boostrap 用来为 Netty 程序的启动组装配置一些必须要组件,例如上面的创建的两个线程组) + ServerBootstrap socketBs = new ServerBootstrap(); + //channel 方法用于指定服务器端监听套接字通道 + + //socket配置 + socketBs.group(bossGroup, workerGroup) + .channel(NioServerSocketChannel.class) + //ChannelOption.SO_BACKLOG对应的是tcp/ip协议listen函数中的backlog参数, + // 函数listen(int socketfd,int backlog)用来初始化服务端可连接队列, + // 服务端处理客户端连接请求是顺序处理的,所以同一时间只能处理一个客户端连接, + // 多个客户端来的时候,服务端将不能处理的客户端连接请求放在队列中等待处理,backlog参数指定了队列的大小 + .option(ChannelOption.SO_BACKLOG, 1024) + //快速复用,防止服务端重启端口被占用的情况发生 + .option(ChannelOption.SO_REUSEADDR, true) + .childHandler(mqttServerChannelInitializer) + //如果TCP_NODELAY没有设置为true,那么底层的TCP为了能减少交互次数,会将网络数据积累到一定的数量后, + // 服务器端才发送出去,会造成一定的延迟。在互联网应用中,通常希望服务是低延迟的,建议将TCP_NODELAY设置为true + .childOption(ChannelOption.TCP_NODELAY, true) + //默认的心跳间隔是7200s即2小时。Netty默认关闭该功能。 + .childOption(ChannelOption.SO_KEEPALIVE, true); + future = socketBs.bind(socketPort).sync(); + if (future.isSuccess()) { + log.info("[*MQTT驱动服务端启动成功]"); + future.channel().closeFuture().sync(); + } else { + log.info("[~~~MQTT驱动服务端启动失败~~~]"); + } + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + bossGroup.shutdownGracefully(); + workerGroup.shutdownGracefully(); + } + } + + /** + * 这里可以手动关闭,同时在整个springboot应用停止的时候,这里也得以调用【@PreDestroy】 + * 参考 https://www.cnblogs.com/CreatorKou/p/11606870.html + */ + @PreDestroy + public void shutdown() { + // 优雅关闭两个 EventLoopGroup 对象 + bossGroup.shutdownGracefully(); + workerGroup.shutdownGracefully(); + log.info("[*MQTT服务端关闭成功]"); + } +} diff --git a/iot-broker/src/main/java/com/java110/broker/mqtt/MqttServerChannelInitializer.java b/iot-broker/src/main/java/com/java110/broker/mqtt/MqttServerChannelInitializer.java new file mode 100644 index 0000000000000000000000000000000000000000..4a41de95bc6e2d154a3c0d12738f3c52023d205f --- /dev/null +++ b/iot-broker/src/main/java/com/java110/broker/mqtt/MqttServerChannelInitializer.java @@ -0,0 +1,29 @@ +package com.java110.broker.mqtt; + +import io.netty.channel.ChannelInitializer; +import io.netty.channel.ChannelPipeline; +import io.netty.channel.socket.SocketChannel; +import io.netty.handler.codec.mqtt.MqttDecoder; +import io.netty.handler.codec.mqtt.MqttEncoder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * @author: zhouwenjie + * @description: 配置管道 服务端初始化,客户端与服务器端连接一旦创建,这个类中方法就会被回调,设置出站编码器和入站解码器 + * @create: 2020-04-03 14:14 + **/ +@Component +public class MqttServerChannelInitializer extends ChannelInitializer { + + @Autowired + private ServerMqttHandler serverMqttHandler; + + @Override + protected void initChannel(SocketChannel ch) { + ChannelPipeline pipeline = ch.pipeline(); + pipeline.addLast("decoder", new MqttDecoder(1024 * 8)); + pipeline.addLast("encoder", MqttEncoder.INSTANCE); + pipeline.addLast(serverMqttHandler); + } +} diff --git a/iot-broker/src/main/java/com/java110/broker/mqtt/ServerMqttHandler.java b/iot-broker/src/main/java/com/java110/broker/mqtt/ServerMqttHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..6d81f0d2275a89548eeb0772105d5404729e0882 --- /dev/null +++ b/iot-broker/src/main/java/com/java110/broker/mqtt/ServerMqttHandler.java @@ -0,0 +1,192 @@ +package com.java110.broker.mqtt; + +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; +import io.netty.handler.codec.mqtt.MqttFixedHeader; +import io.netty.handler.codec.mqtt.MqttMessage; +import io.netty.handler.codec.mqtt.MqttQoS; +import io.netty.handler.timeout.IdleState; +import io.netty.handler.timeout.IdleStateEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.net.InetSocketAddress; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +@Component +@ChannelHandler.Sharable +public class ServerMqttHandler extends SimpleChannelInboundHandler { + private static final Logger log = LoggerFactory.getLogger(ServerMqttHandler.class); + + public static final ConcurrentHashMap clientMap = new ConcurrentHashMap(); + + @Value("${driver.mqtt.address_list:192.168.0.64}") + private List addressList; + + @Autowired + private MqttMsgBack mqttMsgBack; + + @Override + public void channelActive(ChannelHandlerContext ctx) throws Exception { + InetSocketAddress address = (InetSocketAddress) ctx.channel().remoteAddress(); + //判断连接是否合法 + if (addressList.contains(address.getHostString())) { + clientMap.put(ctx.channel().id().toString(), ctx); + super.handlerAdded(ctx); + } else { + ctx.close(); + } + } + + /** + * 功能描述: 客户端终止连接服务器会触发此函数 + * + * @param ctx + * @return void + * @author zhouwenjie + * @date 2020/4/3 16:47 + */ + @Override + public void channelInactive(ChannelHandlerContext ctx) throws Exception { + delSubCache(ctx); + super.channelInactive(ctx); + } + + + /** + * 功能描述: 有客户端发消息会触发此函数 + * + * @param ctx + * @param mqttMessage + * @return void + * @author zhouwenjie + * @date 2020/4/3 16:48 + */ + @Override + public void channelRead0(ChannelHandlerContext ctx, MqttMessage mqttMessage) { + if (null != mqttMessage) { + log.info("接收mqtt消息:" + mqttMessage); + MqttFixedHeader mqttFixedHeader = mqttMessage.fixedHeader(); + + switch (mqttFixedHeader.messageType()) { + // ----------------------接收消息端(服务端)可能会触发的事件---------------------------------------------------------------- + case CONNECT: + // 在一个网络连接上,客户端只能发送一次CONNECT报文。服务端必须将客户端发送的第二个CONNECT报文当作协议违规处理并断开客户端的连接 + // 建议connect消息单独处理,用来对客户端进行认证管理等 这里直接返回一个CONNACK消息 + mqttMsgBack.connectionAck(ctx, mqttMessage); + break; + case PUBLISH: + // 收到消息,返回确认,PUBACK报文是对QoS 1等级的PUBLISH报文的响应,PUBREC报文是对PUBLISH报文的响应 + mqttMsgBack.publishAck(ctx, mqttMessage); + break; + case PUBREL: + // 释放消息,PUBREL报文是对QoS 2等级的PUBREC报文的响应,此时我们应该回应一个PUBCOMP报文 + mqttMsgBack.publishComp(ctx, mqttMessage); + break; + case SUBSCRIBE: + // 客户端订阅主题 + // 客户端向服务端发送SUBSCRIBE报文用于创建一个或多个订阅,每个订阅注册客户端关心的一个或多个主题。 + // 为了将应用消息转发给与那些订阅匹配的主题,服务端发送PUBLISH报文给客户端。 + // SUBSCRIBE报文也(为每个订阅)指定了最大的QoS等级,服务端根据这个发送应用消息给客户端 + mqttMsgBack.subscribeAck(ctx, mqttMessage); + break; + case UNSUBSCRIBE: + // 客户端取消订阅 + // 客户端发送UNSUBSCRIBE报文给服务端,用于取消订阅主题 + mqttMsgBack.unsubscribeAck(ctx, mqttMessage); + break; + case PINGREQ: + // 客户端发起心跳 + mqttMsgBack.pingResp(ctx, mqttMessage); + break; + case DISCONNECT: + // 客户端主动断开连接 + // DISCONNECT报文是客户端发给服务端的最后一个控制报文, 服务端必须验证所有的保留位都被设置为0 + break; + // ----------------------服务端作为发送消息端可能会接收的事件---------------------------------------------------------------- + case PUBACK: + case PUBREC: + //QoS 2级别,响应一个PUBREL报文消息,PUBACK、PUBREC这俩都是ack消息 + //PUBACK报文是对QoS 1等级的PUBLISH报文的响应,如果一段时间没有收到客户端ack,服务端会重新发送消息 + mqttMsgBack.receivePubAck(ctx, mqttMessage); + break; + case PUBCOMP: + //收到qos2级别接收端最后一次发送过来的确认消息 + mqttMsgBack.receivePubcomp(ctx, mqttMessage); + break; + default: + break; + } + } + } + + /** + * 功能描述: 心跳检测 + * + * @param ctx 这里的作用主要是解决断网,弱网的情况发生 + * @param evt + * @return void + * @author zhouwenjie + * @date 2020/4/3 17:02 + */ + @Override + public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { + String socketString = ctx.channel().remoteAddress().toString(); + if (evt instanceof IdleStateEvent) { + IdleStateEvent event = (IdleStateEvent) evt; + if (event.state() == IdleState.READER_IDLE) { + log.info("Client: " + socketString + " READER_IDLE 读超时"); + delSubCache(ctx); + ctx.disconnect(); + } + } + } + + + /** + * 功能描述: + * + * @param ctx + * @param cause + * @return void + * @author 发生异常会触发此函数 + * @date 2020/4/3 16:49 + */ + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { + cause.printStackTrace(); + } + + private void delSubCache(ChannelHandlerContext ctx){ + String id = ctx.channel().id().toString(); + clientMap.remove(id); + //删除订阅主题 + Set topicSet = MqttMsgBack.ctMap.get(id); + if (topicSet != null && !topicSet.isEmpty()) { + ConcurrentHashMap> subMap = MqttMsgBack.subMap; + ConcurrentHashMap qoSMap = MqttMsgBack.qoSMap; + for (String topic : topicSet) { + if (subMap != null) { + HashSet ids = subMap.get(topic); + if (!ids.isEmpty()) { + ids.remove(id); + if (ids.isEmpty()) { + subMap.remove(topic); + } + } + } + if (qoSMap != null) { + qoSMap.remove(topic + "-" + id); + } + } + } + MqttMsgBack.ctMap.remove(id); + } +} diff --git a/iot-broker/src/main/java/com/java110/broker/mqtt/TimerData.java b/iot-broker/src/main/java/com/java110/broker/mqtt/TimerData.java new file mode 100644 index 0000000000000000000000000000000000000000..b4711e2e8910611570ad306dca38cc4616511f42 --- /dev/null +++ b/iot-broker/src/main/java/com/java110/broker/mqtt/TimerData.java @@ -0,0 +1,18 @@ +package com.java110.broker.mqtt; + +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.ScheduledThreadPoolExecutor; + +/** + * @author: zhouwenjie + * @description: 轮询线程信息存储 + * @create: 2021-04-29 08:06 + **/ +public class TimerData { + + + public static ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(10); + + public static ConcurrentHashMap> scheduledFutureMap = new ConcurrentHashMap<>(); +} diff --git a/iot-broker/src/main/java/com/java110/broker/service/HkISApiRequestService.java b/iot-broker/src/main/java/com/java110/broker/service/HkISApiRequestService.java new file mode 100644 index 0000000000000000000000000000000000000000..9b62acb41b457b745aa88436129c307bc941dc7d --- /dev/null +++ b/iot-broker/src/main/java/com/java110/broker/service/HkISApiRequestService.java @@ -0,0 +1,10 @@ +package com.java110.broker.service; + +import org.springframework.web.multipart.MultipartFile; + +public interface HkISApiRequestService { + + public void parseXmlData(MultipartFile file); + + public void parseImageData(MultipartFile file); +} diff --git a/iot-broker/src/main/java/com/java110/broker/service/MqttServiceHandler.java b/iot-broker/src/main/java/com/java110/broker/service/MqttServiceHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..1bd38e460c8171c672187a15593e210763873b34 --- /dev/null +++ b/iot-broker/src/main/java/com/java110/broker/service/MqttServiceHandler.java @@ -0,0 +1,5 @@ +package com.java110.broker.service; + +public interface MqttServiceHandler { + void handleMessage(String topicName, String payload); +} diff --git a/iot-broker/src/main/java/com/java110/broker/service/impl/HkISApiRequestServiceImpl.java b/iot-broker/src/main/java/com/java110/broker/service/impl/HkISApiRequestServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..0b29d95ac2325ca56d7d4fa32d55cdc8ec70590d --- /dev/null +++ b/iot-broker/src/main/java/com/java110/broker/service/impl/HkISApiRequestServiceImpl.java @@ -0,0 +1,123 @@ +package com.java110.broker.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.java110.broker.controller.HkISApiController; +import com.java110.broker.mqtt.*; +import com.java110.broker.service.HkISApiRequestService; +import com.java110.broker.utils.XmlUtils; +import com.java110.dto.barrier.BarrierDto; +import com.java110.intf.barrier.IBarrierV1InnerServiceSMO; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.mqtt.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; +@Service +public class HkISApiRequestServiceImpl implements HkISApiRequestService { + private static final Logger log = LoggerFactory.getLogger(HkISApiController.class); + + private static final String UPLOAD_DIR = "/Users/admin/workspace/MicroCommunityIot/iot-broker/src/main/resources/images/"; + + @Autowired + MqttMessageIdGenerator messageIdGenerator; + + @Autowired + private IBarrierV1InnerServiceSMO barrierService; + + @Value("${driver.mqtt.wait_time}") + private long waitTime; + @Override + public void parseXmlData(MultipartFile file) { + // 处理XML文件 + try { + String xmlContent = new String(file.getBytes()); + JSONObject jsonObject = XmlUtils.parseXmlToJsonObject(xmlContent); + if (jsonObject.containsKey("EventNotificationAlert") + && jsonObject.getJSONObject("EventNotificationAlert").containsKey("ANPR") + &&"ANPR".equals(jsonObject.getJSONObject("EventNotificationAlert").getString("eventType"))) { + JSONObject ANPRObj = jsonObject.getJSONObject("EventNotificationAlert").getJSONObject("ANPR"); + String ipAddress = jsonObject.getJSONObject("EventNotificationAlert").getString("ipAddress"); + String licensePlate = ANPRObj.getString("licensePlate"); + BarrierDto barrierDto = new BarrierDto(); + barrierDto.setMachineIp(ipAddress); + List barrierDtos = barrierService.queryBarriers(barrierDto); + if (barrierDtos == null || barrierDtos.size() < 1) { + log.warn("未找到对应设备"); + return; + } + BarrierDto barrierPo = barrierDtos.get(0); + String plateColor = ANPRObj.getString("plateColor"); + int taskId = messageIdGenerator.nextMessageId(); + JSONObject response = new JSONObject(); + response.put("carNum", licensePlate); + response.put("carType", "1003"); + response.put("machineCode", barrierPo.getMachineCode()); + response.put("cmd", "barrierResult"); + response.put("taskId", taskId); + if (!MqttMsgBack.connectMap.isEmpty()) { + MqttMsgBack.connectMap.forEach((key, cxt) -> { + try { + sendByChannel(cxt, "hc/barrier/response", response.toJSONString(), taskId); + } catch (Exception e) { + e.printStackTrace(); + } + }); + }; + System.out.println("JSON Content: " + jsonObject.toString()); + } else { + System.out.println("Unsupported file xmlContent: " + xmlContent); + } + + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + public void parseImageData(MultipartFile file) { + // 处理图片文件 + try { + File dest = new File(UPLOAD_DIR + file.getOriginalFilename()); + file.transferTo(dest); + System.out.println("File saved to: " + dest.getAbsolutePath()); + } catch (IOException e) { + e.printStackTrace(); + } + } + + + public void sendByChannel(ChannelHandlerContext ctx, String topic, String sendMessage, Integer packetId) throws Exception { + + MqttRequest request = new MqttRequest(sendMessage.getBytes()); + ByteBuf byteBuf = Unpooled.buffer().writeBytes(request.getPayload()); + MqttPublishVariableHeader mqttPublishVariableHeader = new MqttPublishVariableHeader(topic, packetId); + MqttFixedHeader mqttFixedHeader = new MqttFixedHeader( + MqttMessageType.PUBLISH, + request.isDup(), + request.getQos(), + request.isRetained(), + 2); + MqttPublishMessage pubMessage = (MqttPublishMessage) MqttMessageFactory.newMessage(mqttFixedHeader, mqttPublishVariableHeader, byteBuf); + ctx.writeAndFlush(pubMessage); + cachePublishMsg(request.getQos(), byteBuf, mqttPublishVariableHeader, mqttFixedHeader, ctx); + } + + private void cachePublishMsg(MqttQoS qos, ByteBuf byteBuf, MqttPublishVariableHeader variableHeader, MqttFixedHeader mqttFixedHeaderInfo, ChannelHandlerContext context) { + //缓存一份消息,规定时间内没有收到ack,用作重发,重发时将isDup设置为true,代表重复消息 + MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.PUBLISH, true, qos, false, mqttFixedHeaderInfo.remainingLength()); + MqttPublishMessage cachePubMessage = new MqttPublishMessage(fixedHeader, variableHeader, byteBuf); + ScheduledFuture scheduledFuture = TimerData.scheduledThreadPoolExecutor.scheduleAtFixedRate(new MonitorMsgTime(variableHeader.packetId(), cachePubMessage, context), waitTime, waitTime, TimeUnit.MILLISECONDS); + TimerData.scheduledFutureMap.put(variableHeader.packetId(), scheduledFuture); + } +} diff --git a/iot-broker/src/main/java/com/java110/broker/service/impl/MqttServiceHandlerImpl.java b/iot-broker/src/main/java/com/java110/broker/service/impl/MqttServiceHandlerImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..7cbb40cf162ddc23838253e095de900bf2b4f8e5 --- /dev/null +++ b/iot-broker/src/main/java/com/java110/broker/service/impl/MqttServiceHandlerImpl.java @@ -0,0 +1,64 @@ +package com.java110.broker.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.java110.broker.mqtt.JsonUtil; +import com.java110.broker.service.MqttServiceHandler; +import com.java110.broker.utils.ApacheHttpClientService; +import com.java110.dto.barrier.BarrierDto; +import com.java110.intf.barrier.IBarrierV1InnerServiceSMO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.io.IOException; +import java.util.List; + +@Service +public class MqttServiceHandlerImpl implements MqttServiceHandler { + @Autowired + private IBarrierV1InnerServiceSMO barrierService; + @Autowired + private ApacheHttpClientService clientService; + public static final String BARRIER_URL = "http://%s:%s"; + @Override + public void handleMessage(String topicName, String payload) { + if (!topicName.startsWith("hc/barrier/request/")) { + return; + } + System.out.println("topicName=" + topicName + ",payload=" + payload); + String machineCode = topicName.substring("hc/barrier/request/".length()); + BarrierDto barrierDto = new BarrierDto(); + barrierDto.setMachineCode(machineCode); + List barrierDtos = barrierService.queryBarriers(barrierDto); + if (barrierDtos == null || barrierDtos.size() < 1) { + return; + } + BarrierDto barrierPo = barrierDtos.get(0); + if (!JsonUtil.isJsonObject(payload)) { + System.out.println("payload not jsonobject , " + payload); + } + String baseUrl = String.format(BARRIER_URL, barrierPo.getMachineIp(), barrierPo.getMachinePort()); + JSONObject jsonStr = JSONObject.parseObject(payload); + switch (jsonStr.getString("cmd")) { + case "heartbeat": + break; + case "playTts": + try { + clientService.sendLcdRequestWithAuth(baseUrl, barrierPo.getMachineLoginName(), barrierPo.getMachinePassword(), jsonStr.getString("text")); + clientService.sendBroadcastRequestWithAuth(baseUrl, barrierPo.getMachineLoginName(), barrierPo.getMachinePassword(), jsonStr.getString("text")); + } catch (IOException e) { + e.printStackTrace(); + } + break; + case "openBarrier": + try { + clientService.sendOpenBarrierRequestWithAuth(baseUrl, barrierPo.getMachineLoginName(), barrierPo.getMachinePassword()); + } catch (IOException e) { + e.printStackTrace(); + } + break; + case "barrierResult": + break; + } + } + +} diff --git a/iot-broker/src/main/java/com/java110/broker/utils/ApacheHttpClientService.java b/iot-broker/src/main/java/com/java110/broker/utils/ApacheHttpClientService.java new file mode 100644 index 0000000000000000000000000000000000000000..4e8a20a4f6e2858ff423e16eb3e03f9c275bb6b9 --- /dev/null +++ b/iot-broker/src/main/java/com/java110/broker/utils/ApacheHttpClientService.java @@ -0,0 +1,135 @@ +package com.java110.broker.utils; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.http.HttpEntity; +import org.apache.http.auth.AuthScope; +import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.client.CredentialsProvider; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPut; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.BasicCredentialsProvider; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; +import org.springframework.stereotype.Service; + +import java.io.IOException; +@Service +public class ApacheHttpClientService { + + public String sendRequestWithAuth(String url, String username, String password) throws IOException { + CredentialsProvider credsProvider = new BasicCredentialsProvider(); + credsProvider.setCredentials( + AuthScope.ANY, + new UsernamePasswordCredentials(username, password) + ); + + try (CloseableHttpClient httpClient = HttpClients.custom() + .setDefaultCredentialsProvider(credsProvider) + .build()) { + + HttpGet request = new HttpGet(url); + try (CloseableHttpResponse response = httpClient.execute(request)) { + HttpEntity entity = response.getEntity(); + if (entity != null) { + return EntityUtils.toString(entity); + } + } + } + return null; + } + + public String sendPostRequestWithAuth(String url, String username, String password, String requestBody, String contentType) throws IOException { + + CredentialsProvider credsProvider = new BasicCredentialsProvider(); + credsProvider.setCredentials( + AuthScope.ANY, + new UsernamePasswordCredentials(username, password) + ); + try (CloseableHttpClient httpClient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build()) { + HttpPut request = new HttpPut(url); + request.setEntity(new StringEntity(requestBody, "UTF-8")); + request.setHeader("Content-Type", contentType); + try (CloseableHttpResponse response = httpClient.execute(request)) { + HttpEntity entity = response.getEntity(); + if (entity != null) { + return EntityUtils.toString(entity); + } + } catch (Exception e ) { + e.printStackTrace(); + } + } catch (Exception e ) { + e.printStackTrace(); + } + return null; + } + + public void sendLcdRequestWithAuth(String baseUrl, String username, String password, String text) throws IOException { + String requestUrl = baseUrl + "/ISAPI/Parking/channels/1/LCD"; + JSONObject customContent = new JSONObject(); + customContent.put("id", 1); + customContent.put("content", text); + + JSONArray customContentList = new JSONArray(); + JSONObject customContentListObj = new JSONObject(); + customContentListObj.put("CustomContent", customContent); + customContentList.add(customContentListObj); + + JSONObject lcd = new JSONObject(); + lcd.put("CustomContentList", customContentList); + + JSONObject lcdObject = new JSONObject(); + lcdObject.put("LCD", lcd); + sendPostRequestWithAuth(requestUrl, username, password, lcdObject.toString(), "application/json"); + } + + public void sendBroadcastRequestWithAuth(String baseUrl, String username, String password, String text) throws IOException { + String requestUrl = baseUrl + "/ISAPI/Parking/channels/1/voiceBroadcastInfo/combinateBroadcast"; + JSONObject BroadcastInfo = new JSONObject(); + BroadcastInfo.put("id", 1); + BroadcastInfo.put("customValue", text); + + JSONArray BroadcastInfoList = new JSONArray(); + JSONObject BroadcastInfoListObj = new JSONObject(); + BroadcastInfoListObj.put("BroadcastInfo", BroadcastInfo); + BroadcastInfoList.add(BroadcastInfoListObj); + + JSONObject Broadcast = new JSONObject(); + Broadcast.put("BroadcastInfoList", BroadcastInfoList); + + JSONObject broadcastObject = new JSONObject(); + broadcastObject.put("CombinateBroadcast", Broadcast); + sendPostRequestWithAuth(requestUrl, username, password, broadcastObject.toString(), "application/json"); + } + + public void sendOpenBarrierRequestWithAuth(String baseUrl, String username, String password) throws IOException { + String requestUrl = baseUrl + "/ISAPI/Parking/channels/1/barrierGate"; + String requestXml = "\n" + + " open\n" + + ""; + sendPostRequestWithAuth(requestUrl, username, password, requestXml, "application/xml"); + } + + + public static void main(String[] args) throws IOException { + ApacheHttpClientService ac = new ApacheHttpClientService(); +// String res = ac.sendRequestWithAuth("http://192.168.0.64/ISAPI/Security/userCheck", "admin", "Zaq1xsw2cde3vfr4"); +// String res = ac.sendRequestWithAuth("http://192.168.0.64/ISAPI/Parking/capabilities?format=json", "admin", "Zaq1xsw2cde3vfr4"); +// String res = ac.sendRequestWithAuth("http://192.168.0.64/ISAPI/Parking/channels/1/barrierGate/capabilities?format=json", "admin", "Zaq1xsw2cde3vfr4"); +// String res = ac.sendRequestWithAuth("http://192.168.0.64/ISAPI/Parking/channels/1/barrierGate/capabilities?format=json", "admin", "Zaq1xsw2cde3vfr4"); +// String res = ac.sendRequestWithAuth("http://192.168.0.64/ISAPI/Parking/channels/1/voiceBroadcastInfo/capabilities", "admin", "Zaq1xsw2cde3vfr4"); +// String res = ac.sendRequestWithAuth("http://192.168.0.64/ISAPI/Parking/channels/1/LCD/capabilities", "admin", "Zaq1xsw2cde3vfr4"); +// String res = ac.sendRequestWithAuth("http://192.168.0.64/ISAPI/System/capabilities?format=json", "admin", "Zaq1xsw2cde3vfr4"); +// String res = ac.sendRequestWithAuth("http://192.168.0.64/ISAPI/Event/notification/httpHosts/capabilities?format=json", "admin", "Zaq1xsw2cde3vfr4"); +// String res = ac.sendRequestWithAuth("http://192.168.0.64/ISAPI/Event/notification/httpHosts/capabilities?format=json", "admin", "Zaq1xsw2cde3vfr4"); +// String res = ac.sendPostRequestWithAuth("http://192.168.0.64/ISAPI/Parking/channels/1/barrierGate", "admin", "Zaq1xsw2cde3vfr4", XmlUtils.readBarrierXml("template/barrier.xml")); +// String res = ac.sendPostRequestWithAuth("http://192.168.0.64/ISAPI/Parking/channels/1/voiceBroadcastInfo/combinateBroadcast", "admin", "Zaq1xsw2cde3vfr4", XmlUtils.readBarrierXml("template/voice.json"), "application/json"); + ac.sendBroadcastRequestWithAuth("http://192.168.0.64", "admin", "Zaq1xsw2cde3vfr4", "欢迎关联"); +// String res = ac.sendPostRequestWithAuth("http://192.168.0.64/ISAPI/Parking/channels/1/LCD", "admin", "Zaq1xsw2cde3vfr4", XmlUtils.readBarrierXml("template/lcd-all.json"), "application/json"); + +// System.out.println(res); + } +} diff --git a/iot-broker/src/main/java/com/java110/broker/utils/MqttCommonUtils.java b/iot-broker/src/main/java/com/java110/broker/utils/MqttCommonUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..5a59da213f1619eca36087bda6184e81eef6f383 --- /dev/null +++ b/iot-broker/src/main/java/com/java110/broker/utils/MqttCommonUtils.java @@ -0,0 +1,15 @@ +package com.java110.broker.utils; + +import io.netty.buffer.ByteBuf; + +public class MqttCommonUtils { + + public static String convertbyteBufToString(ByteBuf byteBuf) { + if (byteBuf == null) { + return null; + } + byte[] tmp = new byte[byteBuf.readableBytes()]; + byteBuf.readBytes(tmp); + return new String(tmp); + } +} diff --git a/iot-broker/src/main/java/com/java110/broker/utils/XmlUtils.java b/iot-broker/src/main/java/com/java110/broker/utils/XmlUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..371002c00c7acc1fb2925812024baf75f791790d --- /dev/null +++ b/iot-broker/src/main/java/com/java110/broker/utils/XmlUtils.java @@ -0,0 +1,148 @@ +package com.java110.broker.utils; + +import com.alibaba.fastjson.JSONObject; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import org.dom4j.io.OutputFormat; +import org.dom4j.io.SAXReader; +import org.dom4j.io.XMLWriter; +import org.springframework.core.io.ClassPathResource; + +import java.io.*; +import java.util.Iterator; + +public class XmlUtils { + + public static String createXmlString() { + // 创建一个新的XML文档 + Document document = DocumentHelper.createDocument(); + + // 创建根元素 + Element root = document.addElement("root"); + + // 添加子元素 + Element element1 = root.addElement("element"); + element1.addText("Value1"); + + Element element2 = root.addElement("element"); + element2.addText("Value2"); + + // 将XML文档转换为字符串 + return document.asXML(); + } + + public static String createPrettyXmlString() { + // 创建一个新的XML文档 + Document document = DocumentHelper.createDocument(); + + // 创建根元素 + Element root = document.addElement("root"); + + // 添加子元素 + Element element1 = root.addElement("element"); + element1.addText("Value1"); + + Element element2 = root.addElement("element"); + element2.addText("Value2"); + + // 使用OutputFormat来格式化XML + OutputFormat format = OutputFormat.createPrettyPrint(); + format.setEncoding("UTF-8"); + + StringWriter stringWriter = new StringWriter(); + XMLWriter xmlWriter = new XMLWriter(stringWriter, format); + + try { + xmlWriter.write(document); + xmlWriter.close(); + } catch (Exception e) { + e.printStackTrace(); + } + + return stringWriter.toString(); + } + + public static String readBarrierXml(String fileName) throws IOException { + // 获取资源文件 + ClassPathResource resource = new ClassPathResource(fileName); + InputStream inputStream = resource.getInputStream(); + + // 读取文件内容 + StringBuilder contentBuilder = new StringBuilder(); + try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) { + String line; + while ((line = reader.readLine()) != null) { + contentBuilder.append(line).append("\n"); + } + } + + return contentBuilder.toString(); + } + + public static JSONObject parseXmlToJsonObject(String xmlContent) { + try { + // 解析XML字符串 + Document document = DocumentHelper.parseText(xmlContent); + Element root = document.getRootElement(); + + // 将XML元素转换为JSONObject + JSONObject jsonObject = new JSONObject(); + parseElement(root, jsonObject); + + return jsonObject; + } catch (DocumentException e) { + e.printStackTrace(); + return new JSONObject(); + } + } + + private static void parseElement(Element element, JSONObject jsonObject) { + // 获取元素的名称和文本内容 + String elementName = element.getName(); + String elementText = element.getTextTrim(); + + // 如果元素有子元素,则递归处理 + if (element.elements().size() > 0) { + JSONObject childObject = new JSONObject(); + for (Iterator it = element.elementIterator(); it.hasNext(); ) { + Element childElement = it.next(); + parseElement(childElement, childObject); + } + jsonObject.put(elementName, childObject); + } else { + // 如果元素没有子元素,则直接添加文本内容 + jsonObject.put(elementName, elementText); + } + + // 处理属性 + if (element.attributes().size() > 0) { + for (Iterator it = element.attributeIterator(); it.hasNext(); ) { + org.dom4j.Attribute attribute = (org.dom4j.Attribute) it.next(); + jsonObject.put("@" + attribute.getName(), attribute.getValue()); + } + } + } + + public static JSONObject readXmlFileToJsonObject(String filePath) { + try { + // 读取XML文件 + ClassPathResource resource = new ClassPathResource(filePath); + InputStream inputStream = resource.getInputStream(); + SAXReader reader = new SAXReader(); + Document document = reader.read(inputStream); + + // 将XML文档转换为JSONObject + Element root = document.getRootElement(); + JSONObject jsonObject = new JSONObject(); + parseElement(root, jsonObject); + + return jsonObject; + } catch (DocumentException | IOException e) { + e.printStackTrace(); + return new JSONObject(); + } + } +} + diff --git a/iot-broker/src/main/resources/application-dev.yml b/iot-broker/src/main/resources/application-dev.yml new file mode 100644 index 0000000000000000000000000000000000000000..bdf90f0da1289fbadab173663733e5a62f46f3f7 --- /dev/null +++ b/iot-broker/src/main/resources/application-dev.yml @@ -0,0 +1,67 @@ +eureka: + instance: + leaseRenewalIntervalInSeconds: 10 + leaseExpirationDurationInSeconds: 30 + preferIpAddress: true + ip-address: 127.0.0.1 + instanceId: ${spring.cloud.client.ip-address}:${server.port} + client: + serviceUrl: +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ +server: + port: 12000 + tomcat: + uri-encoding: UTF-8 +logging: + level: + root: debug + +spring: + profiles: + active: share + http: + encoding: + charset: UTF-8 + enabled: true + force: true + application: + name: iot-broker + redis: + database: 4 + host: 192.168.56.21 + port: 6379 + password: park + pool: + max-active: 300 + max-wait: 10000 + max-idle: 100 + min-idle: 0 + timeout: 0 + maxWaitMillis: 20000 + datasource: + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + druid: + initial-size: 5 + max-active: 10 + min-idle: 5 + max-wait: 60000 + +driver: + mqtt: + socket_port: 12001 + wait_time: 3000 + address_list: 127.0.0.1 + user_name: admin + password: public + +feign: + client: + config: + default: + connect-timeout: 10000 + read-timeout: 20000 \ No newline at end of file diff --git a/iot-broker/src/main/resources/application.yml b/iot-broker/src/main/resources/application.yml new file mode 100644 index 0000000000000000000000000000000000000000..caf4dfcd647483863672818bd860d4ec4767e8de --- /dev/null +++ b/iot-broker/src/main/resources/application.yml @@ -0,0 +1,3 @@ +spring: + profiles: + active: dev \ No newline at end of file diff --git a/iot-broker/src/main/resources/images/licensePlatePicture.jpg b/iot-broker/src/main/resources/images/licensePlatePicture.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d3794778518b86fb9c0f8aa9b39da51318ccc125 Binary files /dev/null and b/iot-broker/src/main/resources/images/licensePlatePicture.jpg differ diff --git a/iot-broker/src/main/resources/java110.properties b/iot-broker/src/main/resources/java110.properties new file mode 100644 index 0000000000000000000000000000000000000000..e76452d1cb850859c9e1f52eca26b34925ab1fc4 --- /dev/null +++ b/iot-broker/src/main/resources/java110.properties @@ -0,0 +1,4 @@ +java110.mappingPath=classpath:mapper/car/*.xml,classpath:mapper/service/*.xml +java110.testSwitch=ON + + diff --git a/iot-broker/src/main/resources/template/barrier.xml b/iot-broker/src/main/resources/template/barrier.xml new file mode 100644 index 0000000000000000000000000000000000000000..60282a71824c2a9a8d07dedf9a7d71925617b1df --- /dev/null +++ b/iot-broker/src/main/resources/template/barrier.xml @@ -0,0 +1,3 @@ + + close + \ No newline at end of file diff --git a/iot-broker/src/main/resources/template/lcd-all.json b/iot-broker/src/main/resources/template/lcd-all.json new file mode 100644 index 0000000000000000000000000000000000000000..bf1b5a16ccbc2c57d21f679a626f48785568d698 --- /dev/null +++ b/iot-broker/src/main/resources/template/lcd-all.json @@ -0,0 +1,28 @@ +{ + "LCD": { + "displayPassingVehicleInfoEnabled": true, + "displayPlateEnable": true, + "displayTimeEnable": true, + "timeFormat": "hh-mm-ss", + "expireRemindDay": 30, + "CustomContentList": [{ + "CustomContent": { + "id": 1, + "content": "欢迎光临 郝思博" + } + }], + "HintContentList": [{ + "HintContent": { + "id": 1, + "content": "自动识别", + "contentType": "free" + } + }, { + "HintContent": { + "id": 2, + "content": "一车一杆", + "contentType": "free" + } + }] + } +} \ No newline at end of file diff --git a/iot-broker/src/main/resources/template/lcd.json b/iot-broker/src/main/resources/template/lcd.json new file mode 100644 index 0000000000000000000000000000000000000000..074f7c71c8538a72c03b6584c147a4ea2bab6bc4 --- /dev/null +++ b/iot-broker/src/main/resources/template/lcd.json @@ -0,0 +1,27 @@ +{ + "LCD": { + "CustomContentList": [{ + "CustomContent": { + "id": 1, + "content": "欢迎光临陕A2M297" + } + }], + "fontSize": 50, + "fontColor": { + "R": 0, + "G": 0, + "B": 255 + }, + "MediaDataInfo": { + "cycleIntervalTime": 60, + "cyclePlayOrder": [] + }, + "ctrlMode": "camera", + "displayTime": 20, + "HintContentList": [{ + "HintContent": { + "content": "测试自动识别车牌提示" + } + }] + } +} \ No newline at end of file diff --git a/iot-broker/src/main/resources/template/voice.json b/iot-broker/src/main/resources/template/voice.json new file mode 100644 index 0000000000000000000000000000000000000000..1b8a82b9b7582f451404f298be9136c81a2c4ec4 --- /dev/null +++ b/iot-broker/src/main/resources/template/voice.json @@ -0,0 +1,9 @@ +{ + "CombinateBroadcast": { + "BroadcastInfoList": [{ + "BroadcastInfo": { + "customValue": "欢 迎 光 临" + } + }] + } +} \ No newline at end of file diff --git a/iot-car/src/main/java/com/java110/car/CarApplicationStart.java b/iot-car/src/main/java/com/java110/car/CarApplicationStart.java index f7226c6281664f56fefc8b36a5d33712d027b17e..65fd75aca82d4a340ba98070026bb2d44f6e7be3 100644 --- a/iot-car/src/main/java/com/java110/car/CarApplicationStart.java +++ b/iot-car/src/main/java/com/java110/car/CarApplicationStart.java @@ -43,9 +43,15 @@ import java.util.concurrent.TimeUnit; }) @EnableFeignClients(basePackages = { "com.java110.intf.community", + "com.java110.intf.user", + "com.java110.intf.barrier", + "com.java110.intf.charge", + "com.java110.intf.job", + "com.java110.intf.monitor", + "com.java110.intf.system", }) @Java110CmdDiscovery(cmdPublishClass = ServiceCmdEventPublishing.class, - basePackages = {"com.java110.user.cmd"}) + basePackages = {"com.java110.car.cmd"}) @EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class}) @EnableDiscoveryClient public class CarApplicationStart { diff --git a/iot-car/src/main/java/com/java110/car/cmd/ownerCar/SaveOwnerCarCmd.java b/iot-car/src/main/java/com/java110/car/cmd/ownerCar/SaveOwnerCarCmd.java index 20e4dd89c38bdcfac66ae5b465165f2e00c6d650..02ff08e0a89f76975e1e3498e102c9d1e6592163 100644 --- a/iot-car/src/main/java/com/java110/car/cmd/ownerCar/SaveOwnerCarCmd.java +++ b/iot-car/src/main/java/com/java110/car/cmd/ownerCar/SaveOwnerCarCmd.java @@ -72,7 +72,7 @@ public class SaveOwnerCarCmd extends Cmd { @Override public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException { Assert.hasKeyAndValue(reqJson, "communityId", "未包含小区ID"); - Assert.hasKeyAndValue(reqJson, "ownerId", "请求报文中未包含ownerId"); +// Assert.hasKeyAndValue(reqJson, "ownerId", "请求报文中未包含ownerId"); Assert.hasKeyAndValue(reqJson, "carNum", "请求报文中未包含carNum"); Assert.hasKeyAndValue(reqJson, "carType", "请求报文中未包含carType"); Assert.hasKeyAndValue(reqJson, "psId", "未包含psId"); diff --git a/iot-car/src/main/resources/application-dev.yml b/iot-car/src/main/resources/application-dev.yml index 1f6a0ea1b4b529c8a879cd5573113405f587ebb7..586d8a547f26503dc478d7f7ce6e14a6de511de2 100644 --- a/iot-car/src/main/resources/application-dev.yml +++ b/iot-car/src/main/resources/application-dev.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9995 tomcat: @@ -25,9 +26,9 @@ spring: name: iot-car redis: database: 4 - host: 192.168.1.109 + host: 192.168.56.21 port: 6379 - password: hc12345678 + password: park pool: max-active: 300 max-wait: 10000 @@ -35,7 +36,17 @@ spring: min-idle: 0 timeout: 0 maxWaitMillis: 20000 - + datasource: + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + druid: + initial-size: 5 + max-active: 10 + min-idle: 5 + max-wait: 60000 feign: client: config: diff --git a/iot-car/src/main/resources/application-zihao.yml b/iot-car/src/main/resources/application-zihao.yml index ebb91702bf648ad64670bd0522446fd472e5b282..3c464e955bdc2bbbdfbb84300ede5a1b2783a356 100644 --- a/iot-car/src/main/resources/application-zihao.yml +++ b/iot-car/src/main/resources/application-zihao.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9995 tomcat: diff --git a/iot-car/src/main/resources/dataSource-zihao.yml b/iot-car/src/main/resources/dataSource-zihao.yml index 6736e1cc047482980145e1609ea71aa19fe3d578..c4fc75afb42c0917db6ad7682976fc65c512b8ba 100644 --- a/iot-car/src/main/resources/dataSource-zihao.yml +++ b/iot-car/src/main/resources/dataSource-zihao.yml @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-car/src/main/resources/dataSource.yml b/iot-car/src/main/resources/dataSource.yml index 8226eb288c8a87ac479007a9630ecb7cd2cffd35..f05af6bebd44af3da720600f6c9858608519784e 100644 --- a/iot-car/src/main/resources/dataSource.yml +++ b/iot-car/src/main/resources/dataSource.yml @@ -1,9 +1,9 @@ dataSources: ds0: !!com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.100.108:3306/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 - username: hc_iot - password: hc_iot12345678 + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 minIdle: 5 validationQuery: SELECT 1 FROM DUAL initialSize: 5 @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-charge/src/main/java/com/java110/charge/ChargeApplicationStart.java b/iot-charge/src/main/java/com/java110/charge/ChargeApplicationStart.java index c5b49fba2f0d683e7906a6840b60ce62a7624c7c..904e206ad391512348f9ec763c3c838704ed5652 100644 --- a/iot-charge/src/main/java/com/java110/charge/ChargeApplicationStart.java +++ b/iot-charge/src/main/java/com/java110/charge/ChargeApplicationStart.java @@ -43,6 +43,10 @@ import java.util.concurrent.TimeUnit; }) @EnableFeignClients(basePackages = { "com.java110.intf.user", + "com.java110.intf.acct", + "com.java110.intf.car", + "com.java110.intf.monitor", + "com.java110.intf.hal", }) @Java110CmdDiscovery(cmdPublishClass = ServiceCmdEventPublishing.class, basePackages = {"com.java110.charge.cmd"}) diff --git a/iot-charge/src/main/resources/application-dev.yml b/iot-charge/src/main/resources/application-dev.yml index c47ebd3a95c635b102bfa540f1520418ec6eedd6..2e74603aa6d17236ad7d30441e4a785e996dc4f4 100644 --- a/iot-charge/src/main/resources/application-dev.yml +++ b/iot-charge/src/main/resources/application-dev.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9988 tomcat: @@ -25,9 +26,9 @@ spring: name: iot-charge redis: database: 4 - host: 192.168.1.109 + host: 192.168.56.21 port: 6379 - password: hc12345678 + password: park pool: max-active: 300 max-wait: 10000 @@ -35,6 +36,17 @@ spring: min-idle: 0 timeout: 0 maxWaitMillis: 20000 + datasource: + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + druid: + initial-size: 5 + max-active: 10 + min-idle: 5 + max-wait: 60000 feign: client: diff --git a/iot-charge/src/main/resources/application-zihao.yml b/iot-charge/src/main/resources/application-zihao.yml index fc4f79a688d9e67f48bc690f5eff6fffc3af1c61..d2a58cb0e604c0ef128eb7cdfe96d5364c28db02 100644 --- a/iot-charge/src/main/resources/application-zihao.yml +++ b/iot-charge/src/main/resources/application-zihao.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9988 tomcat: diff --git a/iot-charge/src/main/resources/dataSource-zihao.yml b/iot-charge/src/main/resources/dataSource-zihao.yml index 6736e1cc047482980145e1609ea71aa19fe3d578..c4fc75afb42c0917db6ad7682976fc65c512b8ba 100644 --- a/iot-charge/src/main/resources/dataSource-zihao.yml +++ b/iot-charge/src/main/resources/dataSource-zihao.yml @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-charge/src/main/resources/dataSource.yml b/iot-charge/src/main/resources/dataSource.yml index 8226eb288c8a87ac479007a9630ecb7cd2cffd35..f05af6bebd44af3da720600f6c9858608519784e 100644 --- a/iot-charge/src/main/resources/dataSource.yml +++ b/iot-charge/src/main/resources/dataSource.yml @@ -1,9 +1,9 @@ dataSources: ds0: !!com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.100.108:3306/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 - username: hc_iot - password: hc_iot12345678 + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 minIdle: 5 validationQuery: SELECT 1 FROM DUAL initialSize: 5 @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-community/src/main/java/com/java110/community/CommunityApplicationStart.java b/iot-community/src/main/java/com/java110/community/CommunityApplicationStart.java index 5c69033c472dad160a08b5badf753c58190408c5..a7a06e5a98cbcd7ffbd85f81e2102fd9f82f18d4 100644 --- a/iot-community/src/main/java/com/java110/community/CommunityApplicationStart.java +++ b/iot-community/src/main/java/com/java110/community/CommunityApplicationStart.java @@ -43,6 +43,8 @@ import java.util.concurrent.TimeUnit; }) @EnableFeignClients(basePackages = { "com.java110.intf.user", + "com.java110.intf.accessControl", + "com.java110.intf.system", }) @Java110CmdDiscovery(cmdPublishClass = ServiceCmdEventPublishing.class, basePackages = {"com.java110.community.cmd"}) diff --git a/iot-community/src/main/resources/application-dev.yml b/iot-community/src/main/resources/application-dev.yml index ef8f56c10c2c9849a1997bef7e3ef0bb0cc342b5..bdd4b61765b2337e0ddc118e3978043eed913d9a 100644 --- a/iot-community/src/main/resources/application-dev.yml +++ b/iot-community/src/main/resources/application-dev.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9994 tomcat: @@ -25,9 +26,9 @@ spring: name: iot-community redis: database: 4 - host: 192.168.1.109 + host: 192.168.56.21 port: 6379 - password: hc12345678 + password: park pool: max-active: 300 max-wait: 10000 @@ -35,6 +36,17 @@ spring: min-idle: 0 timeout: 0 maxWaitMillis: 20000 + datasource: + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + druid: + initial-size: 5 + max-active: 10 + min-idle: 5 + max-wait: 60000 feign: client: diff --git a/iot-community/src/main/resources/application-zihao.yml b/iot-community/src/main/resources/application-zihao.yml index 0fb1a769c2f8013c70db2f780e914dc40f7fd18c..a1bcc59f71fc5d3de7b0b8ce188d3f1119cd445a 100644 --- a/iot-community/src/main/resources/application-zihao.yml +++ b/iot-community/src/main/resources/application-zihao.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9994 tomcat: diff --git a/iot-community/src/main/resources/dataSource-zihao.yml b/iot-community/src/main/resources/dataSource-zihao.yml index 6736e1cc047482980145e1609ea71aa19fe3d578..c4fc75afb42c0917db6ad7682976fc65c512b8ba 100644 --- a/iot-community/src/main/resources/dataSource-zihao.yml +++ b/iot-community/src/main/resources/dataSource-zihao.yml @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-community/src/main/resources/dataSource.yml b/iot-community/src/main/resources/dataSource.yml index 8226eb288c8a87ac479007a9630ecb7cd2cffd35..f05af6bebd44af3da720600f6c9858608519784e 100644 --- a/iot-community/src/main/resources/dataSource.yml +++ b/iot-community/src/main/resources/dataSource.yml @@ -1,9 +1,9 @@ dataSources: ds0: !!com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.100.108:3306/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 - username: hc_iot - password: hc_iot12345678 + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 minIdle: 5 validationQuery: SELECT 1 FROM DUAL initialSize: 5 @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-dev/src/main/java/com/java110/dev/DevApplicationStart.java b/iot-dev/src/main/java/com/java110/dev/DevApplicationStart.java index 4daa5e77e6cd8f12695f7f92ad0c672eb60f28e8..d7a720973a55f5bb276f13c656b37142af03bab1 100644 --- a/iot-dev/src/main/java/com/java110/dev/DevApplicationStart.java +++ b/iot-dev/src/main/java/com/java110/dev/DevApplicationStart.java @@ -41,8 +41,11 @@ import java.nio.charset.Charset; @EnableDiscoveryClient @Java110CmdDiscovery(cmdPublishClass = ServiceCmdEventPublishing.class, basePackages = {"com.java110.dev.cmd"}) -@EnableFeignClients(basePackages = {"com.java110.intf.user", - "com.java110.intf.community","com.java110.intf.job"}) +@EnableFeignClients(basePackages = { + "com.java110.intf.user", + "com.java110.intf.community", + "com.java110.intf.job" +}) public class DevApplicationStart { private static Logger logger = LoggerFactory.getLogger(DevApplicationStart.class); diff --git a/iot-dev/src/main/resources/application-dev.yml b/iot-dev/src/main/resources/application-dev.yml index 50b5ed9a870f38055a496d40e9b3ba879e8e82c7..7dc9353778dd7ba5b82b0004d1304a12a0ffc121 100644 --- a/iot-dev/src/main/resources/application-dev.yml +++ b/iot-dev/src/main/resources/application-dev.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9993 tomcat: @@ -25,9 +26,9 @@ spring: name: iot-dev redis: database: 4 - host: 192.168.1.109 + host: 192.168.56.21 port: 6379 - password: hc12345678 + password: park pool: max-active: 300 max-wait: 10000 @@ -35,6 +36,17 @@ spring: min-idle: 0 timeout: 0 maxWaitMillis: 20000 + datasource: + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + druid: + initial-size: 5 + max-active: 10 + min-idle: 5 + max-wait: 60000 feign: client: diff --git a/iot-dev/src/main/resources/application-zihao.yml b/iot-dev/src/main/resources/application-zihao.yml index bf384573c3efac26617b28135e4b770c9534769c..ef9c339feee304da65b58e67cfd31bb3537f215c 100644 --- a/iot-dev/src/main/resources/application-zihao.yml +++ b/iot-dev/src/main/resources/application-zihao.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9993 tomcat: diff --git a/iot-dev/src/main/resources/dataSource-zihao.yml b/iot-dev/src/main/resources/dataSource-zihao.yml index 6736e1cc047482980145e1609ea71aa19fe3d578..c4fc75afb42c0917db6ad7682976fc65c512b8ba 100644 --- a/iot-dev/src/main/resources/dataSource-zihao.yml +++ b/iot-dev/src/main/resources/dataSource-zihao.yml @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-dev/src/main/resources/dataSource.yml b/iot-dev/src/main/resources/dataSource.yml index 8226eb288c8a87ac479007a9630ecb7cd2cffd35..f05af6bebd44af3da720600f6c9858608519784e 100644 --- a/iot-dev/src/main/resources/dataSource.yml +++ b/iot-dev/src/main/resources/dataSource.yml @@ -1,9 +1,9 @@ dataSources: ds0: !!com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.100.108:3306/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 - username: hc_iot - password: hc_iot12345678 + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 minIdle: 5 validationQuery: SELECT 1 FROM DUAL initialSize: 5 @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-gateway/src/main/java/com/java110/gateway/GatewayApplicationStart.java b/iot-gateway/src/main/java/com/java110/gateway/GatewayApplicationStart.java index fd7c82d3d8df6695cca4748c0ceaa47138a942a4..0ea89d6b8762299f0e209090fe1507dafb912c37 100644 --- a/iot-gateway/src/main/java/com/java110/gateway/GatewayApplicationStart.java +++ b/iot-gateway/src/main/java/com/java110/gateway/GatewayApplicationStart.java @@ -43,6 +43,11 @@ import java.util.concurrent.TimeUnit; "com.java110.intf.user", "com.java110.intf.community", "com.java110.intf.job", + "com.java110.intf.system", + "com.java110.intf.charge", + "com.java110.intf.acct", + "com.java110.intf.meter", + "com.java110.intf.barrier", }) @EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class}) @EnableDiscoveryClient diff --git a/iot-gateway/src/main/java/com/java110/gateway/configuration/ServiceConfiguration.java b/iot-gateway/src/main/java/com/java110/gateway/configuration/ServiceConfiguration.java index 227b5a05b9a59e7902bc55f3672a126321aecfb8..67d7d89f52dca3918f7757751b1fec67dd6f7641 100644 --- a/iot-gateway/src/main/java/com/java110/gateway/configuration/ServiceConfiguration.java +++ b/iot-gateway/src/main/java/com/java110/gateway/configuration/ServiceConfiguration.java @@ -79,6 +79,8 @@ public class ServiceConfiguration { //exclusions.append("/iot/api/appUser.saveAppUser,");// 房屋认证 + exclusions.append("/iot/api/wechat.getWechatMiniOpenId,");// 获取openId + } diff --git a/iot-gateway/src/main/java/com/java110/gateway/service/impl/AppServiceCheckImpl.java b/iot-gateway/src/main/java/com/java110/gateway/service/impl/AppServiceCheckImpl.java index 96a3056b6180b149502886112c691e300820f3be..e238055d0b4f47b3e886ae3700893a3db1472cff 100644 --- a/iot-gateway/src/main/java/com/java110/gateway/service/impl/AppServiceCheckImpl.java +++ b/iot-gateway/src/main/java/com/java110/gateway/service/impl/AppServiceCheckImpl.java @@ -74,6 +74,7 @@ public class AppServiceCheckImpl implements IAppServiceCheck { throw new IllegalArgumentException("USER-ID 不能为空"); } for (AppRoute appRoute : appRoutes) { + System.out.println("========"+appRoute.getAppService().getServiceCode()); if (StatusConstant.STATUS_CD_VALID.equals(appRoute.getStatusCd()) && appRoute.getAppService().getServiceCode().equals(serviceCode)) { appService = appRoute.getAppService(); diff --git a/iot-gateway/src/main/resources/application-dev.yml b/iot-gateway/src/main/resources/application-dev.yml index 64623e84677ce74942b9530004d3cb413e688358..58c8000b290d786b7e51e8c0bf197eec2a86661c 100644 --- a/iot-gateway/src/main/resources/application-dev.yml +++ b/iot-gateway/src/main/resources/application-dev.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9999 tomcat: @@ -29,9 +30,9 @@ spring: name: iot-gateway redis: database: 4 - host: 192.168.1.109 + host: 192.168.56.21 port: 6379 - password: hc12345678 + password: park pool: max-active: 300 max-wait: 10000 @@ -39,6 +40,17 @@ spring: min-idle: 0 timeout: 0 maxWaitMillis: 20000 + datasource: + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + druid: + initial-size: 5 + max-active: 10 + min-idle: 5 + max-wait: 60000 feign: client: diff --git a/iot-gateway/src/main/resources/application-zihao.yml b/iot-gateway/src/main/resources/application-zihao.yml index 30f8847a04ab48c0243916f959ad29ff385f0133..5216cca1866a261c9389303b648320fc534fd1e2 100644 --- a/iot-gateway/src/main/resources/application-zihao.yml +++ b/iot-gateway/src/main/resources/application-zihao.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9999 tomcat: diff --git a/iot-gateway/src/main/resources/dataSource-zihao.yml b/iot-gateway/src/main/resources/dataSource-zihao.yml index 6736e1cc047482980145e1609ea71aa19fe3d578..c4fc75afb42c0917db6ad7682976fc65c512b8ba 100644 --- a/iot-gateway/src/main/resources/dataSource-zihao.yml +++ b/iot-gateway/src/main/resources/dataSource-zihao.yml @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-gateway/src/main/resources/dataSource.yml b/iot-gateway/src/main/resources/dataSource.yml index 8226eb288c8a87ac479007a9630ecb7cd2cffd35..f05af6bebd44af3da720600f6c9858608519784e 100644 --- a/iot-gateway/src/main/resources/dataSource.yml +++ b/iot-gateway/src/main/resources/dataSource.yml @@ -1,9 +1,9 @@ dataSources: ds0: !!com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.100.108:3306/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 - username: hc_iot - password: hc_iot12345678 + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 minIdle: 5 validationQuery: SELECT 1 FROM DUAL initialSize: 5 @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-h5/iot-user/api/user/sessionApi.js b/iot-h5/iot-user/api/user/sessionApi.js index e23746a31d075acf3fdffc220efebb9d66ef7e98..09a5b8714435ef39df92e9b82f0b799c724c1f7d 100644 --- a/iot-h5/iot-user/api/user/sessionApi.js +++ b/iot-h5/iot-user/api/user/sessionApi.js @@ -147,6 +147,7 @@ export function _refreshWechatMiniOpenId() { return; } let openId = _data.data; + console.log("======", openId) loginByOpenId(openId); }) }, diff --git a/iot-h5/iot-user/api/user/userApi.js b/iot-h5/iot-user/api/user/userApi.js index 2b9e861939214f9d5ccc9a072af311b938adbbb2..89e3f422ac4f8921de2432dc636968ee1892cbf6 100644 --- a/iot-h5/iot-user/api/user/userApi.js +++ b/iot-h5/iot-user/api/user/userApi.js @@ -250,6 +250,7 @@ export function getWechatMiniOpenId(_objData){ method: "GET", data: _objData, //动态数据 success: function(res) { + console.log("-----------",_objData) if (res.statusCode == 200) { resolve(res.data); return; @@ -257,6 +258,7 @@ export function getWechatMiniOpenId(_objData){ reject(); }, fail: function(e) { + console.log("-----e------",e) reject(); } }); diff --git a/iot-h5/iot-user/conf/config.js b/iot-h5/iot-user/conf/config.js index 014d02be9f348d376da51524fc905c1febbb4b8e..4e8a7355f0a7ba3ec8712e36324b133bcbda3411 100644 --- a/iot-h5/iot-user/conf/config.js +++ b/iot-h5/iot-user/conf/config.js @@ -15,7 +15,7 @@ const baseUrl = '/'; // #ifndef H5 //服务器域名 小程序 或者 app 时 后端地址 -const baseUrl = 'http://192.168.100.108:9999/'; +const baseUrl = 'http://127.0.0.1:9999/'; // #endif let commonBaseUrl = 'http://iot.newwish.cc/'; diff --git a/iot-h5/iot-user/lib/java110/utils/EnvUtil.js b/iot-h5/iot-user/lib/java110/utils/EnvUtil.js index 5fef0ff8e6cb0760a8eb8077c871780dbe526feb..0443c400cae98c3fbbd25e2b61be32b6afa9a201 100644 --- a/iot-h5/iot-user/lib/java110/utils/EnvUtil.js +++ b/iot-h5/iot-user/lib/java110/utils/EnvUtil.js @@ -1,11 +1,12 @@ export function isWxOrAli() { - let _env = "WECHAT" - if (/MicroMessenger/.test(window.navigator.userAgent)) { - _env = "WECHAT" - } else if (/AlipayClient/.test(window.navigator.userAgent)) { - _env = "ALIPAY" - } else { - _env = "OTHER" - } - return _env; + return "WECHAT" + // let _env = "WECHAT" + // if (/MicroMessenger/.test(window.navigator.userAgent)) { + // _env = "WECHAT" + // } else if (/AlipayClient/.test(window.navigator.userAgent)) { + // _env = "ALIPAY" + // } else { + // _env = "OTHER" + // } + // return _env; } diff --git a/iot-h5/iot-user/manifest.json b/iot-h5/iot-user/manifest.json index 18e74d03837be08676a834c4af93bcec1a4c4c9b..3bfbac0074ca1c2190f5ffc7cde47937f5c87529 100644 --- a/iot-h5/iot-user/manifest.json +++ b/iot-h5/iot-user/manifest.json @@ -1,6 +1,6 @@ { "name" : "HC小区物联网用户端", - "appid" : "__UNI__A1B0B07", + "appid" : "__UNI__7B52CBC", "description" : "用户业主设备控制", "versionName" : "1.0.0", "versionCode" : "100", @@ -59,10 +59,12 @@ "quickapp" : {}, "mp-weixin" : { "usingComponents" : true, - "appid" : "wxf83d66b0e9f5964d", + "appid" : "wxc00307c8836a6c45", "setting" : { "urlCheck" : false, - "es6" : false + "es6" : true, + "postcss" : true, + "minified" : true }, "navigateToMiniProgramAppIDList" : [ "xxxx" ], //商城小程序AppId "permission" : { @@ -89,5 +91,8 @@ "domain" : "owner.demo.winqi.cn", "publicPath" : "./", "title" : "业主版" + }, + "uniStatistics" : { + "version" : "2" } } diff --git a/iot-h5/iot-user/pages.json b/iot-h5/iot-user/pages.json index 2f6fdfbdec5f4721f9bfb10d8f7e0cd71881bd98..07d31a53d9a0cd01705c9f17ec739115e79c7d64 100644 --- a/iot-h5/iot-user/pages.json +++ b/iot-h5/iot-user/pages.json @@ -445,8 +445,8 @@ "condition": { //模式配置,仅开发期间生效 "current": 0, //当前激活的模式(list 的索引项) "list": [{ - "name": "", //模式名称 - "path": "", //启动页面,必选 + "name": "首页", //模式名称 + "path": "pages/index/index", //启动页面,必选 "query": "" //启动参数,在页面的onLoad函数里面得到 }] }, diff --git a/iot-h5/iot-user/pages/fee/tempCarFee.vue b/iot-h5/iot-user/pages/fee/tempCarFee.vue index 866f42709ec579dfe587372d932e42b4c4827f4d..c1c4998a381bd3b0a179cb8c6e716c0298db2991 100644 --- a/iot-h5/iot-user/pages/fee/tempCarFee.vue +++ b/iot-h5/iot-user/pages/fee/tempCarFee.vue @@ -216,6 +216,36 @@ }); }); // #endif + + // #ifdef MP-WEIXIN + uni.requestPayment({ + provider: 'wxpay', + timeStamp: _data.timeStamp, + nonceStr: _data.nonceStr, + package: _data.package, + signType: _data.signType, + paySign: _data.sign, + success: function(res) { + if (res.errMsg == 'requestPayment:ok') { + + uni.showToast({ + title: "支付成功", + duration: 2000 + }); + uni.navigateBack({ + delta:1 + }); + } + }, + fail: function(err) { + uni.showToast({ + title: err, + icon: 'none' + }) + console.log(err); + } + }); + // #endif return; } if(_data.code == '100'){ diff --git a/iot-h5/iot-user/pages/fee/tempParkingFee.vue b/iot-h5/iot-user/pages/fee/tempParkingFee.vue index 87d0ae287ea3b0519c46b28ffbda1931f3444437..aa9c825ea5b45bf19fb1b6fbcf6a0c664992a615 100644 --- a/iot-h5/iot-user/pages/fee/tempParkingFee.vue +++ b/iot-h5/iot-user/pages/fee/tempParkingFee.vue @@ -111,6 +111,7 @@ } from '../../lib/java110/utils/StringUtil.js' import { refreshUserOpenId, + getWechatMiniOpenId, getOpenIdFromAliPay } from '../../api/user/userApi.js' import { @@ -120,6 +121,10 @@ import { queryWaitPayFeeTempCar } from '@/api/car/carApi.js'; + + import { + _refreshWechatMiniOpenId + } from '@/api/user/sessionApi.js'; export default { data() { return { @@ -168,14 +173,31 @@ this.machineId = options.machineId; this.communityId = options.communityId; uni.setStorageSync("wAppId", this.appId) + let _that =this; if (!isNotNull(this.openId)) { + //刷新 openId + // #ifdef H5 if (isWxOrAli() == 'ALIPAY') { - this._refreshAliPayOpenId(); - } else { - this._refreshWechatOpenId(); + //_that._refreshAliPayOpenId(); + return; } + //todo h5 情况 + _that._refreshWechatOpenId(); return; + // #endif + + // #ifdef MP-WEIXIN + _that._refreshWechatMiniOpenId(); + // #endif + + // //刷新 openId + // if (isWxOrAli() == 'ALIPAY') { + // this._refreshAliPayOpenId(); + // } else { + // this._refreshWechatOpenId(); + // } + // return; } this._loadExistsCarNum(); }, @@ -292,6 +314,42 @@ } }); }, + _refreshWechatMiniOpenId:function(){ + console.log("===================") + let _that =this; + wx.login({ + success: function(loginRes) { + + if (!loginRes.code) { + return; + } + let accountInfo = wx.getAccountInfoSync(); + let appId = accountInfo.miniProgram.appId; + console.log("===================", appId, accountInfo) + getWechatMiniOpenId({ + code:loginRes.code, + appId:appId, + }).then(_data =>{ + console.log("===================", _data) + if(_data.code != 0){ + uni.showToast({ + icon:'none', + title:_data.msg + }) + return; + } + _that.openId = _data.data; + + }) + + }, + fail: function(error) { + // 调用 wx.login 接口失败 + console.log('调用wx.login获取code失败'); + console.log(error); + } + }); + }, _loadExistsCarNum: function() { let _that = this; let _openType = "WECHAT"; diff --git a/iot-hal/src/main/java/com/java110/hal/HalApplicationStart.java b/iot-hal/src/main/java/com/java110/hal/HalApplicationStart.java index e6b3d7100fb197aa415e7bee37f7d0824fe80990..1adf9609f58a4f8e48ac69a526d2256785684996 100644 --- a/iot-hal/src/main/java/com/java110/hal/HalApplicationStart.java +++ b/iot-hal/src/main/java/com/java110/hal/HalApplicationStart.java @@ -44,6 +44,15 @@ import java.util.concurrent.TimeUnit; }) @EnableFeignClients(basePackages = { "com.java110.intf.community", + "com.java110.intf.intf", + "com.java110.intf.accessControl", + "com.java110.intf.lift", + "com.java110.intf.car", + "com.java110.intf.user", + "com.java110.intf.system", + "com.java110.intf.monitor", + "com.java110.intf.meter", + "com.java110.intf.barrier", }) @Java110CmdDiscovery(cmdPublishClass = ServiceCmdEventPublishing.class, basePackages = {"com.java110.job.cmd"}) diff --git a/iot-hal/src/main/java/com/java110/hal/mqtt/heartbeat/CustomMqttMsgThread.java b/iot-hal/src/main/java/com/java110/hal/mqtt/heartbeat/CustomMqttMsgThread.java index 897094e7920bf2bfa2ee0fd40a528942fa62531d..7542a5198d63c08aca266c51678dcc6e143329e6 100644 --- a/iot-hal/src/main/java/com/java110/hal/mqtt/heartbeat/CustomMqttMsgThread.java +++ b/iot-hal/src/main/java/com/java110/hal/mqtt/heartbeat/CustomMqttMsgThread.java @@ -50,12 +50,12 @@ public class CustomMqttMsgThread implements Runnable { IHardwareManufacturerAttrV1InnerServiceSMO hardwareManufacturerAttrV1InnerServiceSMOImpl - = ApplicationContextFactory.getBean("hardwareManufacturerAttrV1InnerServiceSMOImpl", + = ApplicationContextFactory.getBean(IHardwareManufacturerAttrV1InnerServiceSMO.class.getName(), IHardwareManufacturerAttrV1InnerServiceSMO.class); - if (hardwareManufacturerAttrV1InnerServiceSMOImpl == null) { - hardwareManufacturerAttrV1InnerServiceSMOImpl = ApplicationContextFactory.getBean(IHardwareManufacturerAttrV1InnerServiceSMO.class.getName(), - IHardwareManufacturerAttrV1InnerServiceSMO.class); - } +// if (hardwareManufacturerAttrV1InnerServiceSMOImpl == null) { +// hardwareManufacturerAttrV1InnerServiceSMOImpl = ApplicationContextFactory.getBean(IHardwareManufacturerAttrV1InnerServiceSMO.class.getName(), +// IHardwareManufacturerAttrV1InnerServiceSMO.class); +// } // todo 根据topic 查询 HardwareManufacturerAttrDto tmpManufacturerDto = new HardwareManufacturerAttrDto(); tmpManufacturerDto.setSpecCd(HardwareManufacturerAttrDto.SPEC_TOPIC); @@ -97,10 +97,10 @@ public class CustomMqttMsgThread implements Runnable { return; } - IAttendanceCheckinV1InnerServiceSMO attendanceCheckinV1InnerServiceSMO = ApplicationContextFactory.getBean("attendanceCheckinV1InnerServiceSMOImpl", IAttendanceCheckinV1InnerServiceSMO.class); - if (attendanceCheckinV1InnerServiceSMO == null) { - attendanceCheckinV1InnerServiceSMO = ApplicationContextFactory.getBean(IAttendanceCheckinV1InnerServiceSMO.class.getName(), IAttendanceCheckinV1InnerServiceSMO.class); - } + IAttendanceCheckinV1InnerServiceSMO attendanceCheckinV1InnerServiceSMO = ApplicationContextFactory.getBean(IAttendanceCheckinV1InnerServiceSMO.class.getName(), IAttendanceCheckinV1InnerServiceSMO.class); +// if (attendanceCheckinV1InnerServiceSMO == null) { +// attendanceCheckinV1InnerServiceSMO = ApplicationContextFactory.getBean(IAttendanceCheckinV1InnerServiceSMO.class.getName(), IAttendanceCheckinV1InnerServiceSMO.class); +// } if (!manufacturerAttrDto.getValue().contains("SN") && manufacturerAttrDto.getValue().equals(mqttMsgDto.getTopic())) { attendanceCheckinV1InnerServiceSMO.attendanceResult(new MqttResultDto(manufacturerAttrDto.getHmId(), mqttMsgDto.getTopic(), mqttMsgDto.getMsg())); @@ -121,10 +121,10 @@ public class CustomMqttMsgThread implements Runnable { return; } - IInstrumentV1InnerServiceSMO instrumentV1InnerServiceSMO = ApplicationContextFactory.getBean("instrumentV1InnerServiceSMOImpl", IInstrumentV1InnerServiceSMO.class); - if (instrumentV1InnerServiceSMO == null) { - instrumentV1InnerServiceSMO = ApplicationContextFactory.getBean(IInstrumentV1InnerServiceSMO.class.getName(), IInstrumentV1InnerServiceSMO.class); - } + IInstrumentV1InnerServiceSMO instrumentV1InnerServiceSMO = ApplicationContextFactory.getBean(IInstrumentV1InnerServiceSMO.class.getName(), IInstrumentV1InnerServiceSMO.class); +// if (instrumentV1InnerServiceSMO == null) { +// instrumentV1InnerServiceSMO = ApplicationContextFactory.getBean(IInstrumentV1InnerServiceSMO.class.getName(), IInstrumentV1InnerServiceSMO.class); +// } if (!manufacturerAttrDto.getValue().contains("SN") && manufacturerAttrDto.getValue().equals(mqttMsgDto.getTopic())) { instrumentV1InnerServiceSMO.instrumentResult(new MqttResultDto(manufacturerAttrDto.getHmId(), mqttMsgDto.getTopic(), mqttMsgDto.getMsg())); @@ -153,12 +153,12 @@ public class CustomMqttMsgThread implements Runnable { } IAccessControlResultV1InnerServiceSMO accessControlResultV1InnerServiceSMO = - ApplicationContextFactory.getBean("accessControlResultV1InnerServiceSMOImpl", + ApplicationContextFactory.getBean(IAccessControlResultV1InnerServiceSMO.class.getName(), IAccessControlResultV1InnerServiceSMO.class); - if (accessControlResultV1InnerServiceSMO == null) { - accessControlResultV1InnerServiceSMO = ApplicationContextFactory.getBean(IAccessControlResultV1InnerServiceSMO.class.getName(), - IAccessControlResultV1InnerServiceSMO.class); - } +// if (accessControlResultV1InnerServiceSMO == null) { +// accessControlResultV1InnerServiceSMO = ApplicationContextFactory.getBean(IAccessControlResultV1InnerServiceSMO.class.getName(), +// IAccessControlResultV1InnerServiceSMO.class); +// } //todo 检查 配置的topic 中是否存在sn if (!manufacturerAttrDto.getValue().contains("SN") && manufacturerAttrDto.getValue().equals(mqttMsgDto.getTopic())) { accessControlResultV1InnerServiceSMO.accessControlResult(new AccessControlResultDto(manufacturerAttrDto.getHmId(), mqttMsgDto.getTopic(), mqttMsgDto.getMsg())); @@ -195,7 +195,7 @@ public class CustomMqttMsgThread implements Runnable { return; } IMqttNotifyBarrierV1InnerServiceSMO mqttNotifyBarrierV1InnerServiceSMOImpl = - ApplicationContextFactory.getBean("mqttNotifyBarrierV1InnerServiceSMOImpl", + ApplicationContextFactory.getBean(IMqttNotifyBarrierV1InnerServiceSMO.class.getName(), IMqttNotifyBarrierV1InnerServiceSMO.class); if (mqttNotifyBarrierV1InnerServiceSMOImpl == null) { mqttNotifyBarrierV1InnerServiceSMOImpl = ApplicationContextFactory.getBean(IMqttNotifyBarrierV1InnerServiceSMO.class.getName(), diff --git a/iot-hal/src/main/java/com/java110/hal/mqtt/subscribe/MqttClientSubscribeFactory.java b/iot-hal/src/main/java/com/java110/hal/mqtt/subscribe/MqttClientSubscribeFactory.java index aa664ee353d6b74bb40440af9c8fccefc1a04796..071fee9d4b5cb13cd732e82d74d30e3f58497c0d 100644 --- a/iot-hal/src/main/java/com/java110/hal/mqtt/subscribe/MqttClientSubscribeFactory.java +++ b/iot-hal/src/main/java/com/java110/hal/mqtt/subscribe/MqttClientSubscribeFactory.java @@ -24,11 +24,11 @@ public class MqttClientSubscribeFactory { public static void subscribe() { - IHardwareManufacturerAttrV1InnerServiceSMO hardwareManufacturerAttrV1InnerServiceSMOImpl = ApplicationContextFactory.getBean("hardwareManufacturerAttrV1InnerServiceSMOImpl", IHardwareManufacturerAttrV1InnerServiceSMO.class); + IHardwareManufacturerAttrV1InnerServiceSMO hardwareManufacturerAttrV1InnerServiceSMOImpl = ApplicationContextFactory.getBean(IHardwareManufacturerAttrV1InnerServiceSMO.class.getName(), IHardwareManufacturerAttrV1InnerServiceSMO.class); - if (hardwareManufacturerAttrV1InnerServiceSMOImpl == null) { - hardwareManufacturerAttrV1InnerServiceSMOImpl = ApplicationContextFactory.getBean(IHardwareManufacturerAttrV1InnerServiceSMO.class.getName(), IHardwareManufacturerAttrV1InnerServiceSMO.class); - } +// if (hardwareManufacturerAttrV1InnerServiceSMOImpl == null) { +// hardwareManufacturerAttrV1InnerServiceSMOImpl = ApplicationContextFactory.getBean(IHardwareManufacturerAttrV1InnerServiceSMO.class.getName(), IHardwareManufacturerAttrV1InnerServiceSMO.class); +// } HardwareManufacturerAttrDto hardwareManufacturerAttrDto = new HardwareManufacturerAttrDto(); hardwareManufacturerAttrDto.setSpecCd(HardwareManufacturerAttrDto.SPEC_TOPIC); @@ -70,10 +70,10 @@ public class MqttClientSubscribeFactory { return; } - IAttendanceMachineV1InnerServiceSMO attendanceMachineV1InnerServiceSMOImpl = ApplicationContextFactory.getBean("attendanceMachineV1InnerServiceSMOImpl", IAttendanceMachineV1InnerServiceSMO.class); - if (attendanceMachineV1InnerServiceSMOImpl == null) { - attendanceMachineV1InnerServiceSMOImpl = ApplicationContextFactory.getBean(IAttendanceMachineV1InnerServiceSMO.class.getName(), IAttendanceMachineV1InnerServiceSMO.class); - } + IAttendanceMachineV1InnerServiceSMO attendanceMachineV1InnerServiceSMOImpl = ApplicationContextFactory.getBean(IAttendanceMachineV1InnerServiceSMO.class.getName(), IAttendanceMachineV1InnerServiceSMO.class); +// if (attendanceMachineV1InnerServiceSMOImpl == null) { +// attendanceMachineV1InnerServiceSMOImpl = ApplicationContextFactory.getBean(IAttendanceMachineV1InnerServiceSMO.class.getName(), IAttendanceMachineV1InnerServiceSMO.class); +// } AttendanceMachineDto attendanceMachineDto = new AttendanceMachineDto(); attendanceMachineDto.setImplBean(manufacturerAttrDto.getHmId()); @@ -100,10 +100,10 @@ public class MqttClientSubscribeFactory { return; } - IInstrumentV1InnerServiceSMO instrumentV1InnerServiceSMOImpl = ApplicationContextFactory.getBean("instrumentV1InnerServiceSMOImpl", IInstrumentV1InnerServiceSMO.class); - if (instrumentV1InnerServiceSMOImpl == null) { - instrumentV1InnerServiceSMOImpl = ApplicationContextFactory.getBean(IInstrumentV1InnerServiceSMO.class.getName(), IInstrumentV1InnerServiceSMO.class); - } + IInstrumentV1InnerServiceSMO instrumentV1InnerServiceSMOImpl = ApplicationContextFactory.getBean(IInstrumentV1InnerServiceSMO.class.getName(), IInstrumentV1InnerServiceSMO.class); +// if (instrumentV1InnerServiceSMOImpl == null) { +// instrumentV1InnerServiceSMOImpl = ApplicationContextFactory.getBean(IInstrumentV1InnerServiceSMO.class.getName(), IInstrumentV1InnerServiceSMO.class); +// } InstrumentDto instrumentDto = new InstrumentDto(); instrumentDto.setImplBean(manufacturerAttrDto.getHmId()); @@ -137,11 +137,11 @@ public class MqttClientSubscribeFactory { return; } - IBarrierV1InnerServiceSMO barrierV1InnerServiceSMOImpl = ApplicationContextFactory.getBean("barrierV1InnerServiceSMOImpl", IBarrierV1InnerServiceSMO.class); + IBarrierV1InnerServiceSMO barrierV1InnerServiceSMOImpl = ApplicationContextFactory.getBean(IBarrierV1InnerServiceSMO.class.getName(), IBarrierV1InnerServiceSMO.class); - if (barrierV1InnerServiceSMOImpl == null) { - barrierV1InnerServiceSMOImpl = ApplicationContextFactory.getBean(IBarrierV1InnerServiceSMO.class.getName(), IBarrierV1InnerServiceSMO.class); - } +// if (barrierV1InnerServiceSMOImpl == null) { +// barrierV1InnerServiceSMOImpl = ApplicationContextFactory.getBean(IBarrierV1InnerServiceSMO.class.getName(), IBarrierV1InnerServiceSMO.class); +// } BarrierDto barrierDto = new BarrierDto(); barrierDto.setImplBean(manufacturerAttrDto.getHmId()); @@ -178,11 +178,11 @@ public class MqttClientSubscribeFactory { return; } - IAccessControlV1InnerServiceSMO accessControlV1InnerServiceSMOImpl = ApplicationContextFactory.getBean("accessControlV1InnerServiceSMOImpl", IAccessControlV1InnerServiceSMO.class); + IAccessControlV1InnerServiceSMO accessControlV1InnerServiceSMOImpl = ApplicationContextFactory.getBean(IAccessControlV1InnerServiceSMO.class.getName(), IAccessControlV1InnerServiceSMO.class); - if (accessControlV1InnerServiceSMOImpl == null) { - accessControlV1InnerServiceSMOImpl = ApplicationContextFactory.getBean(IAccessControlV1InnerServiceSMO.class.getName(), IAccessControlV1InnerServiceSMO.class); - } +// if (accessControlV1InnerServiceSMOImpl == null) { +// accessControlV1InnerServiceSMOImpl = ApplicationContextFactory.getBean(IAccessControlV1InnerServiceSMO.class.getName(), IAccessControlV1InnerServiceSMO.class); +// } AccessControlDto accessControlDto = new AccessControlDto(); accessControlDto.setImplBean(manufacturerAttrDto.getHmId()); diff --git a/iot-hal/src/main/resources/application-dev.yml b/iot-hal/src/main/resources/application-dev.yml index 1cdb5d001683a1a2b03af2675f387d953bf94bb0..7215945691711099942394b2970767650ab7ddcc 100644 --- a/iot-hal/src/main/resources/application-dev.yml +++ b/iot-hal/src/main/resources/application-dev.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9987 tomcat: @@ -29,9 +30,9 @@ spring: name: iot-hal redis: database: 4 - host: 192.168.1.109 + host: 192.168.56.21 port: 6379 - password: hc12345678 + password: park pool: max-active: 300 max-wait: 10000 @@ -45,12 +46,22 @@ spring: completionTimeout: 10 default: topic: topic - password: wuxw2015 - url: tcp://mqtt.homecommunity.cn:1883 - username: wuxw + url: tcp://127.0.0.1:12001 + username: admin + password: public keepalive: 20 poolSize: 20 - + datasource: + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + druid: + initial-size: 5 + max-active: 10 + min-idle: 5 + max-wait: 60000 feign: diff --git a/iot-hal/src/main/resources/application-zihao.yml b/iot-hal/src/main/resources/application-zihao.yml index 30139cfc0972a4babe51b9f72c649b1b6d2db4ef..dbda350dfb57e2306ac9ce704aeec2f4298c16bf 100644 --- a/iot-hal/src/main/resources/application-zihao.yml +++ b/iot-hal/src/main/resources/application-zihao.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9987 tomcat: diff --git a/iot-hal/src/main/resources/dataSource-zihao.yml b/iot-hal/src/main/resources/dataSource-zihao.yml index 6736e1cc047482980145e1609ea71aa19fe3d578..c4fc75afb42c0917db6ad7682976fc65c512b8ba 100644 --- a/iot-hal/src/main/resources/dataSource-zihao.yml +++ b/iot-hal/src/main/resources/dataSource-zihao.yml @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-hal/src/main/resources/dataSource.yml b/iot-hal/src/main/resources/dataSource.yml index 8226eb288c8a87ac479007a9630ecb7cd2cffd35..f05af6bebd44af3da720600f6c9858608519784e 100644 --- a/iot-hal/src/main/resources/dataSource.yml +++ b/iot-hal/src/main/resources/dataSource.yml @@ -1,9 +1,9 @@ dataSources: ds0: !!com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.100.108:3306/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 - username: hc_iot - password: hc_iot12345678 + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 minIdle: 5 validationQuery: SELECT 1 FROM DUAL initialSize: 5 @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-job/src/main/resources/application-dev.yml b/iot-job/src/main/resources/application-dev.yml index 5a8cb5c6768cf76a3c3a66e2097c92a868115519..381f0e0d6e34427d1b467091437d9fbcb7d76027 100644 --- a/iot-job/src/main/resources/application-dev.yml +++ b/iot-job/src/main/resources/application-dev.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9992 tomcat: @@ -25,9 +26,9 @@ spring: name: iot-job redis: database: 4 - host: 192.168.1.109 + host: 192.168.56.21 port: 6379 - password: hc12345678 + password: park pool: max-active: 300 max-wait: 10000 diff --git a/iot-job/src/main/resources/application-zihao.yml b/iot-job/src/main/resources/application-zihao.yml index 6a24556505eea4bf1ee225de283a1e392339fd35..bc8fa631bf09d2c03b8af33d0681da5dd4e51d04 100644 --- a/iot-job/src/main/resources/application-zihao.yml +++ b/iot-job/src/main/resources/application-zihao.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9992 tomcat: diff --git a/iot-job/src/main/resources/dataSource-zihao.yml b/iot-job/src/main/resources/dataSource-zihao.yml index 6736e1cc047482980145e1609ea71aa19fe3d578..c4fc75afb42c0917db6ad7682976fc65c512b8ba 100644 --- a/iot-job/src/main/resources/dataSource-zihao.yml +++ b/iot-job/src/main/resources/dataSource-zihao.yml @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-job/src/main/resources/dataSource.yml b/iot-job/src/main/resources/dataSource.yml index 8226eb288c8a87ac479007a9630ecb7cd2cffd35..f05af6bebd44af3da720600f6c9858608519784e 100644 --- a/iot-job/src/main/resources/dataSource.yml +++ b/iot-job/src/main/resources/dataSource.yml @@ -1,9 +1,9 @@ dataSources: ds0: !!com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.100.108:3306/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 - username: hc_iot - password: hc_iot12345678 + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 minIdle: 5 validationQuery: SELECT 1 FROM DUAL initialSize: 5 @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-lamp/src/main/java/com/java110/lamp/LampApplicationStart.java b/iot-lamp/src/main/java/com/java110/lamp/LampApplicationStart.java index 5ed6b809b1d156ff64eb1b01ce8f64c809962c51..6240c6c7e8b6a0b097d269fd43cac9650c837a5f 100644 --- a/iot-lamp/src/main/java/com/java110/lamp/LampApplicationStart.java +++ b/iot-lamp/src/main/java/com/java110/lamp/LampApplicationStart.java @@ -34,7 +34,8 @@ import java.util.concurrent.TimeUnit; "com.java110.doc", }) @EnableFeignClients(basePackages = { - "com.java110.intf.lamp", +// "com.java110.intf.lamp", + "com.java110.intf.user", }) @Java110CmdDiscovery(cmdPublishClass = ServiceCmdEventPublishing.class, basePackages = {"com.java110.lamp.cmd"}) diff --git a/iot-lamp/src/main/resources/application-dev.yml b/iot-lamp/src/main/resources/application-dev.yml index 81dc1ea013e2199544e34e8575cbdc4e4be388b3..eddc8ab39b2e63ec664d89f4f2d260126800e497 100644 --- a/iot-lamp/src/main/resources/application-dev.yml +++ b/iot-lamp/src/main/resources/application-dev.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9985 tomcat: @@ -25,9 +26,9 @@ spring: name: iot-lamp redis: database: 4 - host: 192.168.1.109 + host: 192.168.56.21 port: 6379 - password: hc12345678 + password: park pool: max-active: 300 max-wait: 10000 @@ -35,6 +36,17 @@ spring: min-idle: 0 timeout: 0 maxWaitMillis: 20000 + datasource: + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + druid: + initial-size: 5 + max-active: 10 + min-idle: 5 + max-wait: 60000 feign: client: diff --git a/iot-lamp/src/main/resources/application-zihao.yml b/iot-lamp/src/main/resources/application-zihao.yml index 3d0cfc3193f6ad117adc1dfc62da1ab25c870832..bd659c746d39c12f7f49490ba4ecb6f7338ec05c 100644 --- a/iot-lamp/src/main/resources/application-zihao.yml +++ b/iot-lamp/src/main/resources/application-zihao.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9985 tomcat: diff --git a/iot-lamp/src/main/resources/dataSource-zihao.yml b/iot-lamp/src/main/resources/dataSource-zihao.yml index 6736e1cc047482980145e1609ea71aa19fe3d578..c4fc75afb42c0917db6ad7682976fc65c512b8ba 100644 --- a/iot-lamp/src/main/resources/dataSource-zihao.yml +++ b/iot-lamp/src/main/resources/dataSource-zihao.yml @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-lamp/src/main/resources/dataSource.yml b/iot-lamp/src/main/resources/dataSource.yml index 8226eb288c8a87ac479007a9630ecb7cd2cffd35..f05af6bebd44af3da720600f6c9858608519784e 100644 --- a/iot-lamp/src/main/resources/dataSource.yml +++ b/iot-lamp/src/main/resources/dataSource.yml @@ -1,9 +1,9 @@ dataSources: ds0: !!com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.100.108:3306/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 - username: hc_iot - password: hc_iot12345678 + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 minIdle: 5 validationQuery: SELECT 1 FROM DUAL initialSize: 5 @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-lift/src/main/java/com/java110/lift/LiftApplicationStart.java b/iot-lift/src/main/java/com/java110/lift/LiftApplicationStart.java index 76e0d8439066cacfced8ef1d4568aba07061dd7d..01f0ce50e35c0282e5ddbf9064a3b025cdd80cd9 100644 --- a/iot-lift/src/main/java/com/java110/lift/LiftApplicationStart.java +++ b/iot-lift/src/main/java/com/java110/lift/LiftApplicationStart.java @@ -42,7 +42,9 @@ import java.util.concurrent.TimeUnit; "com.java110.doc", }) @EnableFeignClients(basePackages = { - "com.java110.intf.lift", + "com.java110.intf.monitor", + "com.java110.intf.accessControl", + "com.java110.intf.system", }) @Java110CmdDiscovery(cmdPublishClass = ServiceCmdEventPublishing.class, basePackages = {"com.java110.lift.cmd"}) diff --git a/iot-lift/src/main/resources/application-dev.yml b/iot-lift/src/main/resources/application-dev.yml index 4f4b5c61dc57a5741b0e4c6b9fc4ae27efd694c6..19d4707a0278e6f1fb11ebe689e6d1c8f19561ea 100644 --- a/iot-lift/src/main/resources/application-dev.yml +++ b/iot-lift/src/main/resources/application-dev.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9986 tomcat: @@ -25,9 +26,9 @@ spring: name: iot-lift redis: database: 4 - host: 192.168.1.109 + host: 192.168.56.21 port: 6379 - password: hc12345678 + password: park pool: max-active: 300 max-wait: 10000 @@ -35,6 +36,17 @@ spring: min-idle: 0 timeout: 0 maxWaitMillis: 20000 + datasource: + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + druid: + initial-size: 5 + max-active: 10 + min-idle: 5 + max-wait: 60000 feign: client: diff --git a/iot-lift/src/main/resources/application-zihao.yml b/iot-lift/src/main/resources/application-zihao.yml index 249d608304584d667b6364a83fbf519f72f885eb..fec66487d198ddfea9437823d973dba47620590e 100644 --- a/iot-lift/src/main/resources/application-zihao.yml +++ b/iot-lift/src/main/resources/application-zihao.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9986 tomcat: diff --git a/iot-lift/src/main/resources/dataSource-zihao.yml b/iot-lift/src/main/resources/dataSource-zihao.yml index 6736e1cc047482980145e1609ea71aa19fe3d578..c4fc75afb42c0917db6ad7682976fc65c512b8ba 100644 --- a/iot-lift/src/main/resources/dataSource-zihao.yml +++ b/iot-lift/src/main/resources/dataSource-zihao.yml @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-lift/src/main/resources/dataSource.yml b/iot-lift/src/main/resources/dataSource.yml index 8226eb288c8a87ac479007a9630ecb7cd2cffd35..f05af6bebd44af3da720600f6c9858608519784e 100644 --- a/iot-lift/src/main/resources/dataSource.yml +++ b/iot-lift/src/main/resources/dataSource.yml @@ -1,9 +1,9 @@ dataSources: ds0: !!com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.100.108:3306/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 - username: hc_iot - password: hc_iot12345678 + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 minIdle: 5 validationQuery: SELECT 1 FROM DUAL initialSize: 5 @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-lock/src/main/resources/application-dev.yml b/iot-lock/src/main/resources/application-dev.yml index 335bd0c001b5a8c8987dc92b9c8c33cc64aee14a..03bb66541f22704a3a0067907212899ec9513b96 100644 --- a/iot-lock/src/main/resources/application-dev.yml +++ b/iot-lock/src/main/resources/application-dev.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9984 tomcat: @@ -25,9 +26,9 @@ spring: name: iot-lock redis: database: 4 - host: 192.168.1.109 + host: 192.168.56.21 port: 6379 - password: hc12345678 + password: park pool: max-active: 300 max-wait: 10000 @@ -35,6 +36,17 @@ spring: min-idle: 0 timeout: 0 maxWaitMillis: 20000 + datasource: + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + druid: + initial-size: 5 + max-active: 10 + min-idle: 5 + max-wait: 60000 feign: client: diff --git a/iot-lock/src/main/resources/application-zihao.yml b/iot-lock/src/main/resources/application-zihao.yml index b8185ddf33e7847be352d14bda48d44e3f44f20f..f032f1622f98c3e304aed09cf3c5bc6de021c2c2 100644 --- a/iot-lock/src/main/resources/application-zihao.yml +++ b/iot-lock/src/main/resources/application-zihao.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9984 tomcat: diff --git a/iot-lock/src/main/resources/dataSource-zihao.yml b/iot-lock/src/main/resources/dataSource-zihao.yml index 6736e1cc047482980145e1609ea71aa19fe3d578..c4fc75afb42c0917db6ad7682976fc65c512b8ba 100644 --- a/iot-lock/src/main/resources/dataSource-zihao.yml +++ b/iot-lock/src/main/resources/dataSource-zihao.yml @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-lock/src/main/resources/dataSource.yml b/iot-lock/src/main/resources/dataSource.yml index 8226eb288c8a87ac479007a9630ecb7cd2cffd35..f05af6bebd44af3da720600f6c9858608519784e 100644 --- a/iot-lock/src/main/resources/dataSource.yml +++ b/iot-lock/src/main/resources/dataSource.yml @@ -1,9 +1,9 @@ dataSources: ds0: !!com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.100.108:3306/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 - username: hc_iot - password: hc_iot12345678 + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 minIdle: 5 validationQuery: SELECT 1 FROM DUAL initialSize: 5 @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-meter/src/main/java/com/java110/meter/MeterApplicationStart.java b/iot-meter/src/main/java/com/java110/meter/MeterApplicationStart.java index 8163159b40b93a189c250d32c37b59b438c3d997..a028f6871b67cc0a037bbd6af2b59d5e4c9d3f6d 100644 --- a/iot-meter/src/main/java/com/java110/meter/MeterApplicationStart.java +++ b/iot-meter/src/main/java/com/java110/meter/MeterApplicationStart.java @@ -43,6 +43,8 @@ import java.util.concurrent.TimeUnit; }) @EnableFeignClients(basePackages = { "com.java110.intf.user", + "com.java110.intf.system", + "com.java110.intf.community", }) @Java110CmdDiscovery(cmdPublishClass = ServiceCmdEventPublishing.class, basePackages = {"com.java110.meter.cmd"}) diff --git a/iot-meter/src/main/resources/application-dev.yml b/iot-meter/src/main/resources/application-dev.yml index a49c89158ede5e23dc042ef9a3b779f2093ce5ac..c1c3355a354ecc485e292b624095b751347174a4 100644 --- a/iot-meter/src/main/resources/application-dev.yml +++ b/iot-meter/src/main/resources/application-dev.yml @@ -3,13 +3,14 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: - port: 9987 + port: 9983 tomcat: uri-encoding: UTF-8 @@ -25,9 +26,9 @@ spring: name: iot-meter redis: database: 4 - host: 192.168.1.109 + host: 192.168.56.21 port: 6379 - password: hc12345678 + password: park pool: max-active: 300 max-wait: 10000 @@ -35,6 +36,17 @@ spring: min-idle: 0 timeout: 0 maxWaitMillis: 20000 + datasource: + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + druid: + initial-size: 5 + max-active: 10 + min-idle: 5 + max-wait: 60000 feign: client: diff --git a/iot-meter/src/main/resources/application-zihao.yml b/iot-meter/src/main/resources/application-zihao.yml index 9bc1424c96d6612198c4182261aa71f694c860c7..04880f5937cda57997c6492bd97ad3ba7e59758a 100644 --- a/iot-meter/src/main/resources/application-zihao.yml +++ b/iot-meter/src/main/resources/application-zihao.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9987 tomcat: diff --git a/iot-meter/src/main/resources/dataSource-zihao.yml b/iot-meter/src/main/resources/dataSource-zihao.yml index 6736e1cc047482980145e1609ea71aa19fe3d578..c4fc75afb42c0917db6ad7682976fc65c512b8ba 100644 --- a/iot-meter/src/main/resources/dataSource-zihao.yml +++ b/iot-meter/src/main/resources/dataSource-zihao.yml @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-meter/src/main/resources/dataSource.yml b/iot-meter/src/main/resources/dataSource.yml index 8226eb288c8a87ac479007a9630ecb7cd2cffd35..f05af6bebd44af3da720600f6c9858608519784e 100644 --- a/iot-meter/src/main/resources/dataSource.yml +++ b/iot-meter/src/main/resources/dataSource.yml @@ -1,9 +1,9 @@ dataSources: ds0: !!com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.100.108:3306/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 - username: hc_iot - password: hc_iot12345678 + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 minIdle: 5 validationQuery: SELECT 1 FROM DUAL initialSize: 5 @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-monitor/src/main/resources/application-dev.yml b/iot-monitor/src/main/resources/application-dev.yml index 036c5451a64941d7e150e0760063c369ea511152..988da68a2b8f7a5eaefded45aaa81c320a4599e7 100644 --- a/iot-monitor/src/main/resources/application-dev.yml +++ b/iot-monitor/src/main/resources/application-dev.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9991 tomcat: @@ -25,9 +26,9 @@ spring: name: iot-monitor redis: database: 4 - host: 192.168.1.109 + host: 192.168.56.21 port: 6379 - password: hc12345678 + password: park pool: max-active: 300 max-wait: 10000 @@ -35,6 +36,17 @@ spring: min-idle: 0 timeout: 0 maxWaitMillis: 20000 + datasource: + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + druid: + initial-size: 5 + max-active: 10 + min-idle: 5 + max-wait: 60000 feign: client: diff --git a/iot-monitor/src/main/resources/application-zihao.yml b/iot-monitor/src/main/resources/application-zihao.yml index a3987a3b46c53222926fcf4e1df81165be3ae625..756d3a95dd74e9820e1c52f404435f846374f2d0 100644 --- a/iot-monitor/src/main/resources/application-zihao.yml +++ b/iot-monitor/src/main/resources/application-zihao.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9991 tomcat: diff --git a/iot-monitor/src/main/resources/dataSource-zihao.yml b/iot-monitor/src/main/resources/dataSource-zihao.yml index 6736e1cc047482980145e1609ea71aa19fe3d578..c4fc75afb42c0917db6ad7682976fc65c512b8ba 100644 --- a/iot-monitor/src/main/resources/dataSource-zihao.yml +++ b/iot-monitor/src/main/resources/dataSource-zihao.yml @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-monitor/src/main/resources/dataSource.yml b/iot-monitor/src/main/resources/dataSource.yml index 8226eb288c8a87ac479007a9630ecb7cd2cffd35..f05af6bebd44af3da720600f6c9858608519784e 100644 --- a/iot-monitor/src/main/resources/dataSource.yml +++ b/iot-monitor/src/main/resources/dataSource.yml @@ -1,9 +1,9 @@ dataSources: ds0: !!com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.100.108:3306/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 - username: hc_iot - password: hc_iot12345678 + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 minIdle: 5 validationQuery: SELECT 1 FROM DUAL initialSize: 5 @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-openapi/src/main/java/com/java110/openapi/OpenApiApplicationStart.java b/iot-openapi/src/main/java/com/java110/openapi/OpenApiApplicationStart.java index cf73eab53534015c0f51338736b791e0dbb0a4fc..01fa10fdb6376d02f201a74bd1ac9a6856e8b10b 100644 --- a/iot-openapi/src/main/java/com/java110/openapi/OpenApiApplicationStart.java +++ b/iot-openapi/src/main/java/com/java110/openapi/OpenApiApplicationStart.java @@ -44,6 +44,15 @@ import java.util.concurrent.TimeUnit; @EnableFeignClients(basePackages = { "com.java110.intf.community", "com.java110.intf.user", + "com.java110.intf.car", + "com.java110.intf.barrier", + "com.java110.intf.accessControl", + "com.java110.intf.monitor", + "com.java110.intf.charge", + "com.java110.intf.meter", + "com.java110.intf.system", + "com.java110.intf.lamp", + "com.java110.intf.acct", }) @Java110CmdDiscovery(cmdPublishClass = ServiceCmdEventPublishing.class, basePackages = {"com.java110.openapi.cmd"}) diff --git a/iot-openapi/src/main/resources/application-dev.yml b/iot-openapi/src/main/resources/application-dev.yml index 22cb704a0584038165ca44c1c5d6d412705ab94c..77d329dd9add1775954096e2e3681ee87817224e 100644 --- a/iot-openapi/src/main/resources/application-dev.yml +++ b/iot-openapi/src/main/resources/application-dev.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9997 tomcat: @@ -25,9 +26,9 @@ spring: name: iot-openapi redis: database: 4 - host: 192.168.1.109 + host: 192.168.56.21 port: 6379 - password: hc12345678 + password: park pool: max-active: 300 max-wait: 10000 @@ -35,6 +36,17 @@ spring: min-idle: 0 timeout: 0 maxWaitMillis: 20000 + datasource: + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + druid: + initial-size: 5 + max-active: 10 + min-idle: 5 + max-wait: 60000 feign: client: diff --git a/iot-openapi/src/main/resources/application-zihao.yml b/iot-openapi/src/main/resources/application-zihao.yml index 26018d84ef737830f614f24394faa1169d4aace4..3e670fe879d024abf811761b9a26a7c9f308632b 100644 --- a/iot-openapi/src/main/resources/application-zihao.yml +++ b/iot-openapi/src/main/resources/application-zihao.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9997 tomcat: diff --git a/iot-openapi/src/main/resources/dataSource-zihao.yml b/iot-openapi/src/main/resources/dataSource-zihao.yml index 6736e1cc047482980145e1609ea71aa19fe3d578..c4fc75afb42c0917db6ad7682976fc65c512b8ba 100644 --- a/iot-openapi/src/main/resources/dataSource-zihao.yml +++ b/iot-openapi/src/main/resources/dataSource-zihao.yml @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-openapi/src/main/resources/dataSource.yml b/iot-openapi/src/main/resources/dataSource.yml index 8226eb288c8a87ac479007a9630ecb7cd2cffd35..f05af6bebd44af3da720600f6c9858608519784e 100644 --- a/iot-openapi/src/main/resources/dataSource.yml +++ b/iot-openapi/src/main/resources/dataSource.yml @@ -1,9 +1,9 @@ dataSources: ds0: !!com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.100.108:3306/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 - username: hc_iot - password: hc_iot12345678 + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 minIdle: 5 validationQuery: SELECT 1 FROM DUAL initialSize: 5 @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-openapi/src/main/resources/java110.properties b/iot-openapi/src/main/resources/java110.properties index b190fe459c363afd39baec7ab8e219d180a4bd4c..013cafc93555c058a97bf8e98a96bd157f25554f 100644 --- a/iot-openapi/src/main/resources/java110.properties +++ b/iot-openapi/src/main/resources/java110.properties @@ -1,4 +1,4 @@ -java110.mappingPath=classpath:mapper/openapi/*.xml,classpath:mapper/service/*.xml +#java110.mappingPath=classpath:mapper/openapi/*.xml,classpath:mapper/service/*.xml java110.testSwitch=ON diff --git a/iot-system/src/main/java/com/java110/system/SystemApplicationStart.java b/iot-system/src/main/java/com/java110/system/SystemApplicationStart.java index 6765c227155cac0b5a8cc709458051f6035b725c..113105fca5aeb657a49ecfb84b85818c55bf758b 100644 --- a/iot-system/src/main/java/com/java110/system/SystemApplicationStart.java +++ b/iot-system/src/main/java/com/java110/system/SystemApplicationStart.java @@ -43,9 +43,20 @@ import java.util.concurrent.TimeUnit; }) @EnableFeignClients(basePackages = { "com.java110.intf.community", + "com.java110.intf.user", + "com.java110.intf.car", + "com.java110.intf.accessControl", + "com.java110.intf.barrier", + "com.java110.intf.charge", + "com.java110.intf.meter", + "com.java110.intf.lift", + "com.java110.intf.monitor", + "com.java110.intf.lock", + "com.java110.intf.dev", + "com.java110.intf.lamp", }) @Java110CmdDiscovery(cmdPublishClass = ServiceCmdEventPublishing.class, - basePackages = {"com.java110.user.cmd"}) + basePackages = {"com.java110.system.cmd"}) @EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class}) @EnableDiscoveryClient public class SystemApplicationStart { diff --git a/iot-system/src/main/resources/application-dev.yml b/iot-system/src/main/resources/application-dev.yml index 1193aaae012ce67f019ce5e1166ed023c727c1a8..19dfa76ffd03740fbbf3731bd545caef82b3512d 100644 --- a/iot-system/src/main/resources/application-dev.yml +++ b/iot-system/src/main/resources/application-dev.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9990 tomcat: @@ -25,9 +26,9 @@ spring: name: iot-system redis: database: 4 - host: 192.168.1.109 + host: 192.168.56.21 port: 6379 - password: hc12345678 + password: park pool: max-active: 300 max-wait: 10000 @@ -35,6 +36,17 @@ spring: min-idle: 0 timeout: 0 maxWaitMillis: 20000 + datasource: + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + druid: + initial-size: 5 + max-active: 10 + min-idle: 5 + max-wait: 60000 feign: client: diff --git a/iot-system/src/main/resources/application-zihao.yml b/iot-system/src/main/resources/application-zihao.yml index 0b8963fbdbaf5b3ab5845884e0a0d9a76abc9d4a..f3ccab1e5640a32e8540e915fd87c064ada562b2 100644 --- a/iot-system/src/main/resources/application-zihao.yml +++ b/iot-system/src/main/resources/application-zihao.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9990 tomcat: diff --git a/iot-system/src/main/resources/dataSource-zihao.yml b/iot-system/src/main/resources/dataSource-zihao.yml index 6736e1cc047482980145e1609ea71aa19fe3d578..c4fc75afb42c0917db6ad7682976fc65c512b8ba 100644 --- a/iot-system/src/main/resources/dataSource-zihao.yml +++ b/iot-system/src/main/resources/dataSource-zihao.yml @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-system/src/main/resources/dataSource.yml b/iot-system/src/main/resources/dataSource.yml index 8226eb288c8a87ac479007a9630ecb7cd2cffd35..f05af6bebd44af3da720600f6c9858608519784e 100644 --- a/iot-system/src/main/resources/dataSource.yml +++ b/iot-system/src/main/resources/dataSource.yml @@ -1,9 +1,9 @@ dataSources: ds0: !!com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.100.108:3306/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 - username: hc_iot - password: hc_iot12345678 + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 minIdle: 5 validationQuery: SELECT 1 FROM DUAL initialSize: 5 @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-user/src/main/java/com/java110/user/UserApplicationStart.java b/iot-user/src/main/java/com/java110/user/UserApplicationStart.java index dc3bef2c4d099d1ad733cda90c4791857f119e57..9ca719f5bbc21c5cdda8f2a641160497a05278cd 100644 --- a/iot-user/src/main/java/com/java110/user/UserApplicationStart.java +++ b/iot-user/src/main/java/com/java110/user/UserApplicationStart.java @@ -40,9 +40,16 @@ import java.util.concurrent.TimeUnit; "com.java110.user", "com.java110.core", "com.java110.doc", + "com.java110.intf.accessControl", + "com.java110.accessControl.smo.impl", }) @EnableFeignClients(basePackages = { "com.java110.intf.community", + "com.java110.intf.accessControl", + "com.java110.intf.system", + "com.java110.intf.car", + "com.java110.intf.acct", + "com.java110.intf.charge", }) @Java110CmdDiscovery(cmdPublishClass = ServiceCmdEventPublishing.class, basePackages = {"com.java110.user.cmd"}) diff --git a/iot-user/src/main/resources/application-dev.yml b/iot-user/src/main/resources/application-dev.yml index a20dafb63e6838861e33da44ee8052cce8ead77e..a06898fa8088136eecadc9981665fb423bd5ea61 100644 --- a/iot-user/src/main/resources/application-dev.yml +++ b/iot-user/src/main/resources/application-dev.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9989 tomcat: @@ -25,9 +26,9 @@ spring: name: iot-user redis: database: 4 - host: 192.168.1.109 + host: 192.168.56.21 port: 6379 - password: hc12345678 + password: park pool: max-active: 300 max-wait: 10000 @@ -35,7 +36,17 @@ spring: min-idle: 0 timeout: 0 maxWaitMillis: 20000 - + datasource: + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + druid: + initial-size: 5 + max-active: 10 + min-idle: 5 + max-wait: 60000 feign: client: config: diff --git a/iot-user/src/main/resources/application-zihao.yml b/iot-user/src/main/resources/application-zihao.yml index ef6231ae8fced4cb5cef77366fb4c98e0191fe59..d7e15ceace38adb75228688f7e697b3f6208631a 100644 --- a/iot-user/src/main/resources/application-zihao.yml +++ b/iot-user/src/main/resources/application-zihao.yml @@ -3,11 +3,12 @@ eureka: leaseRenewalIntervalInSeconds: 10 leaseExpirationDurationInSeconds: 30 preferIpAddress: true + ip-address: 127.0.0.1 instanceId: ${spring.cloud.client.ip-address}:${server.port} client: serviceUrl: - defaultZone: http://dev.java110.com:8761/eureka/ - #defaultZone: http://localhost:8761/eureka/ +# defaultZone: http://dev.java110.com:8761/eureka/ + defaultZone: http://localhost:8761/eureka/ server: port: 9989 tomcat: diff --git a/iot-user/src/main/resources/dataSource-zihao.yml b/iot-user/src/main/resources/dataSource-zihao.yml index 6736e1cc047482980145e1609ea71aa19fe3d578..c4fc75afb42c0917db6ad7682976fc65c512b8ba 100644 --- a/iot-user/src/main/resources/dataSource-zihao.yml +++ b/iot-user/src/main/resources/dataSource-zihao.yml @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-user/src/main/resources/dataSource.yml b/iot-user/src/main/resources/dataSource.yml index 8226eb288c8a87ac479007a9630ecb7cd2cffd35..f05af6bebd44af3da720600f6c9858608519784e 100644 --- a/iot-user/src/main/resources/dataSource.yml +++ b/iot-user/src/main/resources/dataSource.yml @@ -1,9 +1,9 @@ dataSources: ds0: !!com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.100.108:3306/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 - username: hc_iot - password: hc_iot12345678 + url: jdbc:mysql://bj-cdb-dnfgsdho.sql.tencentcdb.com:21302/hc_iot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + username: mysql.park + password: aa1T3ETx5rX8#2 minIdle: 5 validationQuery: SELECT 1 FROM DUAL initialSize: 5 @@ -20,4 +20,4 @@ shardingRule: props: - sql.show: true \ No newline at end of file + sql.show: false \ No newline at end of file diff --git a/iot-web/public/components/car/addBarrier/addBarrier.html b/iot-web/public/components/car/addBarrier/addBarrier.html index dab45e48508f84b3851cb92de0d43bdffe08825e..b9aaeb53658d69fd5d84557d40af2e9bfae859f7 100644 --- a/iot-web/public/components/car/addBarrier/addBarrier.html +++ b/iot-web/public/components/car/addBarrier/addBarrier.html @@ -33,6 +33,33 @@ class="form-control"> +

+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+