diff --git a/iot-energy/.idea/.gitignore b/iot-energy/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/iot-energy/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/iot-energy/.idea/compiler.xml b/iot-energy/.idea/compiler.xml new file mode 100644 index 0000000..ed15471 --- /dev/null +++ b/iot-energy/.idea/compiler.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/iot-energy/.idea/encodings.xml b/iot-energy/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/iot-energy/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/iot-energy/.idea/jarRepositories.xml b/iot-energy/.idea/jarRepositories.xml new file mode 100644 index 0000000..2e1bf07 --- /dev/null +++ b/iot-energy/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/iot-energy/.idea/misc.xml b/iot-energy/.idea/misc.xml new file mode 100644 index 0000000..d24ea8e --- /dev/null +++ b/iot-energy/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/iot-energy/.idea/uiDesigner.xml b/iot-energy/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/iot-energy/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/iot-energy/.idea/vcs.xml b/iot-energy/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/iot-energy/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/iot-energy/target/classes/application.properties b/iot-energy/target/classes/application.properties new file mode 100644 index 0000000..61be5d9 --- /dev/null +++ b/iot-energy/target/classes/application.properties @@ -0,0 +1,32 @@ +spring.application.name=netty +server.servlet.encoding.force=true +server.port=7781 +lombok.var.flagUsage = ALLOW +# Single file max size +multipart.maxFileSize=50Mb +# All files max size +multipart.maxRequestSize=50Mb + +spring.datasource.dynamic.datasource.primary=primary +spring.datasource.dynamic.datasource.primary.url=jdbc:mysql://10.16.56.3:3308/jcxt?useUnicode=true&characterEncoding=utf-8&useSSL=false +spring.datasource.dynamic.datasource.primary.username=root +spring.datasource.dynamic.datasource.primary.password=Unity3du#d112233 +spring.datasource.dynamic.datasource.primary.driver-class-name=com.mysql.jdbc.Driver +spring.datasource.dynamic.druid.initial-size=10 +spring.datasource.dynamic.druid.max-idle=20 +spring.datasource.dynamic.druid.min-idle=5 +spring.datasource.dynamic.druid.max-active=50 +spring.datasource.dynamic.druid.log-abandoned=true +spring.datasource.dynamic.druid.remove-abandoned=true +spring.datasource.dynamic.druid.remove-abandoned-timeout-millis=120 +spring.datasource.dynamic.druid.max-wait=1000 +spring.datasource.dynamic.druid.test-while-idle=true +spring.datasource.dynamic.druid.validation-query=select 1 from dual +spring.datasource.dynamic.druid.test-on-borrow=true +spring.datasource.dynamic.druid.min-evictable-idle-time-millis=100000 +spring.datasource.dynamic.druid.max-evictable-idle-time-millis=100000 +spring.datasource.dynamic.druid.time-between-eviction-runs-millis=100000 +spring.datasource.dynamic.druid.break-after-acquire-failure=true +spring.datasource.dynamic.druid.connection-error-retry-attempts=5 +spring.datasource.dynamic.druid.fail-fast=true +spring.datasource.dynamic.druid.time-between-connect-error-millis=10000 \ No newline at end of file diff --git a/iot-energy/target/classes/org/example/IotApplication.class b/iot-energy/target/classes/org/example/IotApplication.class new file mode 100644 index 0000000..42fbc3c Binary files /dev/null and b/iot-energy/target/classes/org/example/IotApplication.class differ diff --git a/iot-energy/target/classes/org/example/background/condition/EnergyDataCondition.class b/iot-energy/target/classes/org/example/background/condition/EnergyDataCondition.class new file mode 100644 index 0000000..9108bdc Binary files /dev/null and b/iot-energy/target/classes/org/example/background/condition/EnergyDataCondition.class differ diff --git a/iot-energy/target/classes/org/example/background/dao/EnergyDataDao.class b/iot-energy/target/classes/org/example/background/dao/EnergyDataDao.class new file mode 100644 index 0000000..71a7119 Binary files /dev/null and b/iot-energy/target/classes/org/example/background/dao/EnergyDataDao.class differ diff --git a/iot-energy/target/classes/org/example/background/entity/EnergyDataEntity.class b/iot-energy/target/classes/org/example/background/entity/EnergyDataEntity.class new file mode 100644 index 0000000..777e3cc Binary files /dev/null and b/iot-energy/target/classes/org/example/background/entity/EnergyDataEntity.class differ diff --git a/iot-energy/target/classes/org/example/background/service/MakeInfoService.class b/iot-energy/target/classes/org/example/background/service/MakeInfoService.class new file mode 100644 index 0000000..6852e53 Binary files /dev/null and b/iot-energy/target/classes/org/example/background/service/MakeInfoService.class differ diff --git a/iot-energy/target/classes/org/example/background/utils/FieldUtils.class b/iot-energy/target/classes/org/example/background/utils/FieldUtils.class new file mode 100644 index 0000000..b7fd7e1 Binary files /dev/null and b/iot-energy/target/classes/org/example/background/utils/FieldUtils.class differ diff --git a/iot-energy/target/classes/org/example/druid/DBTypeEnum.class b/iot-energy/target/classes/org/example/druid/DBTypeEnum.class new file mode 100644 index 0000000..bca6c8e Binary files /dev/null and b/iot-energy/target/classes/org/example/druid/DBTypeEnum.class differ diff --git a/iot-energy/target/classes/org/example/druid/DbContextHolder.class b/iot-energy/target/classes/org/example/druid/DbContextHolder.class new file mode 100644 index 0000000..35a22fc Binary files /dev/null and b/iot-energy/target/classes/org/example/druid/DbContextHolder.class differ diff --git a/iot-energy/target/classes/org/example/druid/DruidProperties.class b/iot-energy/target/classes/org/example/druid/DruidProperties.class new file mode 100644 index 0000000..9b84267 Binary files /dev/null and b/iot-energy/target/classes/org/example/druid/DruidProperties.class differ diff --git a/iot-energy/target/classes/org/example/druid/DynamicDataSource.class b/iot-energy/target/classes/org/example/druid/DynamicDataSource.class new file mode 100644 index 0000000..695d344 Binary files /dev/null and b/iot-energy/target/classes/org/example/druid/DynamicDataSource.class differ diff --git a/iot-energy/target/classes/org/example/socket/BootNettySocketChannelInboundHandler.class b/iot-energy/target/classes/org/example/socket/BootNettySocketChannelInboundHandler.class new file mode 100644 index 0000000..80c2f44 Binary files /dev/null and b/iot-energy/target/classes/org/example/socket/BootNettySocketChannelInboundHandler.class differ diff --git a/iot-energy/target/classes/org/example/socket/BootNettySocketServer$1.class b/iot-energy/target/classes/org/example/socket/BootNettySocketServer$1.class new file mode 100644 index 0000000..e63e80f Binary files /dev/null and b/iot-energy/target/classes/org/example/socket/BootNettySocketServer$1.class differ diff --git a/iot-energy/target/classes/org/example/socket/BootNettySocketServer.class b/iot-energy/target/classes/org/example/socket/BootNettySocketServer.class new file mode 100644 index 0000000..d244fb4 Binary files /dev/null and b/iot-energy/target/classes/org/example/socket/BootNettySocketServer.class differ diff --git a/iot-energy/target/classes/org/example/socket/BootNettySocketServerThread.class b/iot-energy/target/classes/org/example/socket/BootNettySocketServerThread.class new file mode 100644 index 0000000..8518094 Binary files /dev/null and b/iot-energy/target/classes/org/example/socket/BootNettySocketServerThread.class differ diff --git a/iot-energy/target/classes/org/example/utils/CommonConfig.class b/iot-energy/target/classes/org/example/utils/CommonConfig.class new file mode 100644 index 0000000..afb81d8 Binary files /dev/null and b/iot-energy/target/classes/org/example/utils/CommonConfig.class differ diff --git a/iot-energy/target/classes/org/example/utils/IdService.class b/iot-energy/target/classes/org/example/utils/IdService.class new file mode 100644 index 0000000..e0470b6 Binary files /dev/null and b/iot-energy/target/classes/org/example/utils/IdService.class differ diff --git a/iot-energy/target/classes/org/example/utils/MyDecoder.class b/iot-energy/target/classes/org/example/utils/MyDecoder.class new file mode 100644 index 0000000..a1e9b20 Binary files /dev/null and b/iot-energy/target/classes/org/example/utils/MyDecoder.class differ diff --git a/iot-energy/target/classes/org/example/utils/MyEncoder.class b/iot-energy/target/classes/org/example/utils/MyEncoder.class new file mode 100644 index 0000000..ae5bd67 Binary files /dev/null and b/iot-energy/target/classes/org/example/utils/MyEncoder.class differ diff --git a/iot-energy/target/classes/org/example/utils/SnowflakeIdGenerator.class b/iot-energy/target/classes/org/example/utils/SnowflakeIdGenerator.class new file mode 100644 index 0000000..011e839 Binary files /dev/null and b/iot-energy/target/classes/org/example/utils/SnowflakeIdGenerator.class differ diff --git a/iot-energy/target/iot-energy-1.0-SNAPSHOT.jar b/iot-energy/target/iot-energy-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..474e7af Binary files /dev/null and b/iot-energy/target/iot-energy-1.0-SNAPSHOT.jar differ diff --git a/iot-energy/target/iot-energy-1.0-SNAPSHOT.jar.original b/iot-energy/target/iot-energy-1.0-SNAPSHOT.jar.original new file mode 100644 index 0000000..24e81f1 Binary files /dev/null and b/iot-energy/target/iot-energy-1.0-SNAPSHOT.jar.original differ diff --git a/iot-energy/target/maven-archiver/pom.properties b/iot-energy/target/maven-archiver/pom.properties new file mode 100644 index 0000000..707f031 --- /dev/null +++ b/iot-energy/target/maven-archiver/pom.properties @@ -0,0 +1,4 @@ +#Created by Apache Maven 3.9.5 +groupId=org.example +artifactId=iot-energy +version=1.0-SNAPSHOT diff --git a/iot-energy/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/iot-energy/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..1866223 --- /dev/null +++ b/iot-energy/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,19 @@ +org\example\background\condition\EnergyDataCondition.class +org\example\background\utils\FieldUtils.class +org\example\utils\MyDecoder.class +org\example\utils\MyEncoder.class +org\example\utils\CommonConfig.class +org\example\utils\IdService.class +org\example\druid\DynamicDataSource.class +org\example\socket\BootNettySocketChannelInboundHandler.class +org\example\socket\BootNettySocketServerThread.class +org\example\druid\DbContextHolder.class +org\example\socket\BootNettySocketServer$1.class +org\example\druid\DBTypeEnum.class +org\example\utils\SnowflakeIdGenerator.class +org\example\IotApplication.class +org\example\background\service\MakeInfoService.class +org\example\socket\BootNettySocketServer.class +org\example\druid\DruidProperties.class +org\example\background\entity\EnergyDataEntity.class +org\example\background\dao\EnergyDataDao.class diff --git a/iot-energy/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/iot-energy/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..dfa1cd5 --- /dev/null +++ b/iot-energy/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,18 @@ +D:\LGZN-p\iot-energy\src\main\java\org\example\utils\IdService.java +D:\LGZN-p\iot-energy\src\main\java\org\example\background\service\MakeInfoService.java +D:\LGZN-p\iot-energy\src\main\java\org\example\IotApplication.java +D:\LGZN-p\iot-energy\src\main\java\org\example\utils\CommonConfig.java +D:\LGZN-p\iot-energy\src\main\java\org\example\socket\BootNettySocketChannelInboundHandler.java +D:\LGZN-p\iot-energy\src\main\java\org\example\utils\SnowflakeIdGenerator.java +D:\LGZN-p\iot-energy\src\main\java\org\example\utils\MyEncoder.java +D:\LGZN-p\iot-energy\src\main\java\org\example\background\condition\EnergyDataCondition.java +D:\LGZN-p\iot-energy\src\main\java\org\example\druid\DbContextHolder.java +D:\LGZN-p\iot-energy\src\main\java\org\example\druid\DruidProperties.java +D:\LGZN-p\iot-energy\src\main\java\org\example\socket\BootNettySocketServer.java +D:\LGZN-p\iot-energy\src\main\java\org\example\utils\MyDecoder.java +D:\LGZN-p\iot-energy\src\main\java\org\example\socket\BootNettySocketServerThread.java +D:\LGZN-p\iot-energy\src\main\java\org\example\background\entity\EnergyDataEntity.java +D:\LGZN-p\iot-energy\src\main\java\org\example\druid\DBTypeEnum.java +D:\LGZN-p\iot-energy\src\main\java\org\example\druid\DynamicDataSource.java +D:\LGZN-p\iot-energy\src\main\java\org\example\background\dao\EnergyDataDao.java +D:\LGZN-p\iot-energy\src\main\java\org\example\background\utils\FieldUtils.java diff --git a/iot-energy/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/iot-energy/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/iot-zhengtai/.idea/.gitignore b/iot-zhengtai/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/iot-zhengtai/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/iot-zhengtai/.idea/compiler.xml b/iot-zhengtai/.idea/compiler.xml new file mode 100644 index 0000000..9906a21 --- /dev/null +++ b/iot-zhengtai/.idea/compiler.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/iot-zhengtai/.idea/encodings.xml b/iot-zhengtai/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/iot-zhengtai/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/iot-zhengtai/.idea/jarRepositories.xml b/iot-zhengtai/.idea/jarRepositories.xml new file mode 100644 index 0000000..2e1bf07 --- /dev/null +++ b/iot-zhengtai/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/iot-zhengtai/.idea/misc.xml b/iot-zhengtai/.idea/misc.xml new file mode 100644 index 0000000..accd629 --- /dev/null +++ b/iot-zhengtai/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/iot-zhengtai/.idea/uiDesigner.xml b/iot-zhengtai/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/iot-zhengtai/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/iot-zhengtai/.idea/vcs.xml b/iot-zhengtai/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/iot-zhengtai/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/iot-zhengtai/pom.xml b/iot-zhengtai/pom.xml new file mode 100644 index 0000000..09ab7bf --- /dev/null +++ b/iot-zhengtai/pom.xml @@ -0,0 +1,113 @@ + + + 4.0.0 + + + org.springframework.boot + spring-boot-starter-parent + 2.1.1.RELEASE + + + + org.example + iot-zhengtai + 1.0-SNAPSHOT + + + 11 + 11 + UTF-8 + + + + + io.netty + netty-all + 4.1.6.Final + + + net.sf.json-lib + json-lib + 2.4 + jdk15 + + + + com.alibaba + fastjson + 1.2.70 + + + + mysql + mysql-connector-java + 5.1.49 + + + + com.baomidou + mybatis-plus-boot-starter + 3.4.1 + + + com.baomidou + dynamic-datasource-spring-boot-starter + 3.4.1 + + + + com.alibaba + druid-spring-boot-starter + 1.1.10 + + + + org.projectlombok + lombok + 1.18.0 + provided + + + + commons-codec + commons-codec + 1.4 + + + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + 2.16.0 + + + + com.ghgande + j2mod + 2.5.3 + + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.1.1.RELEASE + + + + repackage + + + + + + + + \ No newline at end of file diff --git a/iot-zhengtai/src/main/java/org/example/IotApplication.java b/iot-zhengtai/src/main/java/org/example/IotApplication.java new file mode 100644 index 0000000..13173a9 --- /dev/null +++ b/iot-zhengtai/src/main/java/org/example/IotApplication.java @@ -0,0 +1,30 @@ +package org.example; + +import org.example.socket.BootNettySocketServerThread; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.scheduling.annotation.EnableScheduling; + +@SpringBootApplication(exclude = DataSourceAutoConfiguration.class) +@MapperScan({"org.example.background.dao"}) +@EnableScheduling //允许自动调用 +public class IotApplication implements CommandLineRunner { + + @Autowired + private BootNettySocketServerThread socketServerThread; + + public static void main(String[] args) { + SpringApplication app = new SpringApplication(IotApplication.class); + app.run(args); + } + + @Override + public void run(String... args) throws Exception { + socketServerThread.start(); + } + +} \ No newline at end of file diff --git a/iot-zhengtai/src/main/java/org/example/background/condition/ElectricityDataCondition.java b/iot-zhengtai/src/main/java/org/example/background/condition/ElectricityDataCondition.java new file mode 100644 index 0000000..f498811 --- /dev/null +++ b/iot-zhengtai/src/main/java/org/example/background/condition/ElectricityDataCondition.java @@ -0,0 +1,36 @@ +package org.example.background.condition; + +import org.apache.ibatis.jdbc.SQL; +import org.example.background.entity.ElectricityData; +import org.example.socket.utils.FieldUtils; +import org.springframework.cglib.beans.BeanMap; + +public class ElectricityDataCondition { + + public String insert(ElectricityData data){ + SQL sql = new SQL(); + sql.INSERT_INTO("electricity_data"); + BeanMap beanMap = BeanMap.create(data); + for (Object key : beanMap.keySet()) { + Object val = beanMap.get(key); + if (val != null) { + sql.VALUES(FieldUtils.camelToLines(key + ""), "#{" + key + "}"); + } + } + return sql.toString(); + } + + public String updateByPrimaryKey(ElectricityData data) { + SQL sql = new SQL(); + sql.UPDATE("electricity_data"); + BeanMap beanMap = BeanMap.create(data); + for (Object key : beanMap.keySet()) { + Object val = beanMap.get(key); + if (val != null) { + sql.SET(FieldUtils.camelToLines(key + "") + "=#{" + key + "}"); + } + } + sql.WHERE("electricity_id= #{electricityId}"); + return sql.toString(); + } +} diff --git a/iot-zhengtai/src/main/java/org/example/background/dao/ElectricityDataDao.java b/iot-zhengtai/src/main/java/org/example/background/dao/ElectricityDataDao.java new file mode 100644 index 0000000..652d0b9 --- /dev/null +++ b/iot-zhengtai/src/main/java/org/example/background/dao/ElectricityDataDao.java @@ -0,0 +1,19 @@ +package org.example.background.dao; + +import org.apache.ibatis.annotations.InsertProvider; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.UpdateProvider; +import org.example.background.condition.ElectricityDataCondition; +import org.example.background.entity.ElectricityData; + +public interface ElectricityDataDao { + + @InsertProvider(type = ElectricityDataCondition.class, method = "insert") + Integer insert(ElectricityData data); + + @Select("SELECT * FROM electricity_data WHERE zd_id = #{zdId} AND acquisition_time = #{acquisitionTime} ORDER BY create_time LIMIT 1") + ElectricityData select(ElectricityData data); + + @UpdateProvider(type = ElectricityDataCondition.class, method = "updateByPrimaryKey") + Integer updateByPrimaryKey(ElectricityData data); +} diff --git a/iot-zhengtai/src/main/java/org/example/background/entity/ElectricityData.java b/iot-zhengtai/src/main/java/org/example/background/entity/ElectricityData.java new file mode 100644 index 0000000..4023bfe --- /dev/null +++ b/iot-zhengtai/src/main/java/org/example/background/entity/ElectricityData.java @@ -0,0 +1,109 @@ +package org.example.background.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +@Data +public class ElectricityData implements Serializable { + + //id + @TableId + private String electricityId; + + //终端地址 (设备编号) + private String zdId; + + //互感电流倍率 + private Float taMultiplier; + + //互感电压倍率 + private Float tvMultiplier; + + //A相电流 + private Float aPhaseCurrent; + + //B相电流 + private Float bPhaseCurrent; + + //c相电流 + private Float cPhaseCurrent; + + //A相电压 + private Float aPhaseVoltage; + + //B相电压 + private Float bPhaseVoltage; + + //c相电压 + private Float cPhaseVoltage; + + //AB相电压 + private Float abPhaseVoltage; + + //BC相电压 + private Float bcPhaseVoltage; + + //AC相电压 + private Float acPhaseVoltage; + + //功率因数 + private Float powerFactor; + + //总有功功率 + private Float totalActivePower; + + //总无功功率 + private Float totalReactivePower; + + //视在功率 + private Float apparentPower; + + //频率 + private Float frequency; + + //正向有功电量 + private Float positiveActiveCharge; + + //反向有功电量 + private Float reverseActiveCharge; + + //正向有功尖电量 + private Float positiveActiveTipCharge; + + //正向有功峰电量 + private Float forwardActivePeakCharge; + + //正向有功平电量 + private Float positiveActivePowerLevel; + + //正向有功谷电量 + private Float positiveActiveValleyCharge; + + //反向有功尖电量 + private Float reverseActiveTipCharge; + + //反向有功峰电量 + private Float reverseActivePeakCharge; + + //反向有功平电量 + private Float reverseActivePowerLevel; + + //反向有功谷电量 + private Float reverseActiveValleyCharge; + + //@ApiModelProperty(value = "入库时间") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + + //@ApiModelProperty(value = "整点采集时间") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + private Date acquisitionTime; + + //@ApiModelProperty(value = "终端抄表时间") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + private Date readTime; +} diff --git a/iot-zhengtai/src/main/java/org/example/background/entity/ElectricityDayData.java b/iot-zhengtai/src/main/java/org/example/background/entity/ElectricityDayData.java new file mode 100644 index 0000000..2f45bb6 --- /dev/null +++ b/iot-zhengtai/src/main/java/org/example/background/entity/ElectricityDayData.java @@ -0,0 +1,7 @@ +package org.example.background.entity; + +import lombok.Data; + +@Data +public class ElectricityDayData { +} diff --git a/iot-zhengtai/src/main/java/org/example/background/entity/ElectricityMonthData.java b/iot-zhengtai/src/main/java/org/example/background/entity/ElectricityMonthData.java new file mode 100644 index 0000000..5f3ecac --- /dev/null +++ b/iot-zhengtai/src/main/java/org/example/background/entity/ElectricityMonthData.java @@ -0,0 +1,7 @@ +package org.example.background.entity; + +import lombok.Data; + +@Data +public class ElectricityMonthData { +} diff --git a/iot-zhengtai/src/main/java/org/example/background/service/MakeInfoService.java b/iot-zhengtai/src/main/java/org/example/background/service/MakeInfoService.java new file mode 100644 index 0000000..43ac85e --- /dev/null +++ b/iot-zhengtai/src/main/java/org/example/background/service/MakeInfoService.java @@ -0,0 +1,217 @@ +package org.example.background.service; + +import com.ghgande.j2mod.modbus.util.ModbusUtil; +import org.example.background.dao.ElectricityDataDao; +import org.example.background.entity.ElectricityData; +import org.example.socket.utils.CommonConfig; +import org.example.socket.utils.IdService; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; + +import javax.annotation.Resource; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +@Component +public class MakeInfoService { + + @Resource + private IdService idService; + + @Resource + private ElectricityDataDao electricityDataDao; + + @Resource + private CommonConfig config; + + + //F25信息类 电能表 + public int[] sendElectricMessage(String ip, int fn) { + return config.sendElectricInstruct(ip, fn); + } + + public String convertPlaintext(byte[] data) { + return ModbusUtil.toHex(data); + } + + public Integer convertTextToData(String param, String clientIP) { + String[] data = param.split(" "); + return electric0(data, clientIP); + } + + public Integer electric0(String[] data, String clientIp) { + Integer typeF = 0; + if(data.length > 12) { + switch (data[12]) { + case "0C": + switch (data[16] + data[17]) { + case "0103": //f25 + electric0InStorage0C_25(data, clientIp); + typeF = 25; + break; + case "0110": //f129 + electric0InStorage0C_129(data, clientIp); + typeF = 129; + break; + case "0410": //f131: + electric0InStorage0C_131(data, clientIp); + typeF = 131; + break; + } + break; + case "09": + switch (data[16] + data[17]) { + case "0100": //f1 查询终端配置信息 + electric0InStorage09_01(data, clientIp); + typeF = 1; + break; + } + break; + } + } + return typeF; + } + + public Integer electric0InStorage09_01(String[] data, String clientIp) { + ElectricityData entity = new ElectricityData(); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:00:00"); + String s = hexToAscii(data[18] + data[19] + data[20] + data[21]); + String s1 = hexToAscii(data[22] + data[23] + data[24] + data[25] + data[26] + data[27] + data[28] + data[29]); + entity.setElectricityId(idService.gen()); + try { + entity.setAcquisitionTime(formatter.parse(formatter.format(new Date()))); + }catch (ParseException e) { + e.printStackTrace(); + } + entity.setCreateTime(new Date()); + return 1; + } + + public Integer electric0InStorage0C_25(String[] data, String clientIp) { + ElectricityData entity = new ElectricityData(); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:00:00"); + entity.setElectricityId(idService.gen()); + entity.setZdId(String.valueOf(Integer.parseInt(data[9]+data[10],16))); + + try { + entity.setAcquisitionTime(formatter.parse(formatter.format(new Date()))); + }catch (ParseException e) { + e.printStackTrace(); + } + entity.setCreateTime(new Date()); + entity.setTotalActivePower(Float.parseFloat(data[25]+data[24] + data[23]) / 10000); //总有功功率 + entity.setTotalReactivePower(Float.parseFloat(data[37] + data[36] + fixZhi(data[35])) / 10000); //总无功功率 + entity.setPowerFactor(Float.parseFloat(data[48] + data[47]) / 10); //功率因数 + entity.setAPhaseVoltage(Float.parseFloat(data[56] + data[55]) / 10); //A相电压 + entity.setBPhaseVoltage(Float.parseFloat(data[58] + data[57]) / 10); //b相电压 + entity.setCPhaseVoltage(Float.parseFloat(data[60] + data[59]) / 10); //c相电压 + entity.setAPhaseCurrent(Float.parseFloat(data[63] + data[62] + data[61]) / 1000); //A相电流 + entity.setBPhaseCurrent(Float.parseFloat(data[66] + data[65] + data[64]) / 1000); //B相电流 + entity.setCPhaseCurrent(Float.parseFloat(data[69] + data[68] + data[67]) / 1000); //C相电流 + entity.setAbPhaseVoltage((float)(entity.getAPhaseVoltage() * Math.sqrt(3))); //AB相电压 + entity.setBcPhaseVoltage((float)(entity.getBPhaseVoltage() * Math.sqrt(3))); //BC相电压 + entity.setAcPhaseVoltage((float)(entity.getCPhaseVoltage() * Math.sqrt(3))); //AC相电压 + entity.setApparentPower(Float.parseFloat(data[75] + data[74] + data[73]) / 10000); //视在功率 + entity.setFrequency(50f); //频率 + entity.setTaMultiplier(20.0f); + entity.setTvMultiplier(1.0f); + Integer insert = electricityDataDao.insert(entity); + System.out.println("已入库"); + return insert; + } + + public Integer electric0InStorage0C_129(String [] data, String clientIp) { + ElectricityData entity = new ElectricityData(); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:00:00"); + entity.setZdId(String.valueOf(Integer.parseInt(data[9]+data[10],16))); + try { + entity.setAcquisitionTime(formatter.parse(formatter.format(new Date()))); + }catch (ParseException e) { + e.printStackTrace(); + } + ElectricityData electricityData = electricityDataDao.select(entity); + Integer integer = 0; + if(StringUtils.isEmpty(electricityData)){ + System.out.println("上一步数据没有载入,无法执行当前入库操作"); + }else { + DateFormat sdf1 = new SimpleDateFormat("yyMMddHHmm"); + try { + electricityData.setReadTime(sdf1.parse(data[22] + data[21] + data[20] + data[19] + data[18])); + }catch (ParseException e){ + e.printStackTrace(); + } + electricityData.setPositiveActiveCharge(Float.parseFloat(data[28] + data[27] + data[26] + data[25] + data[24]) / 10000); //正向有功总电能示值 + electricityData.setPositiveActiveTipCharge(Float.parseFloat(data[33] + data[32] + data[31] + data[30] + data[29]) / 10000);//尖 + electricityData.setForwardActivePeakCharge(Float.parseFloat(data[38] + data[37] + data[36] + data[35] + data[34]) / 10000);//峰 + electricityData.setPositiveActivePowerLevel(Float.parseFloat(data[43] + data[42] + data[41] + data[40] + data[39]) / 10000); //平 + electricityData.setPositiveActiveValleyCharge(Float.parseFloat(data[48] + data[47] + data[46] + data[45] + data[44]) / 10000);//谷 + integer = electricityDataDao.updateByPrimaryKey(electricityData); + System.out.println("已经填补剩余数据"); + } + return integer; + } + + public Integer electric0InStorage0C_131(String [] data, String clientIp) { + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:00:00"); + ElectricityData entity = new ElectricityData(); + entity.setZdId(String.valueOf(Integer.parseInt(data[9]+data[10],16))); + try { + entity.setAcquisitionTime(formatter.parse(formatter.format(new Date()))); + }catch (ParseException e) { + e.printStackTrace(); + } + ElectricityData electricityData = electricityDataDao.select(entity); + Integer integer = 0; + if(StringUtils.isEmpty(electricityData)){ + System.out.println("上一步数据没有载入,无法执行当前入库操作"); + }else { + electricityData.setReverseActiveCharge(Float.parseFloat(data[28] + data[27] + data[26] + data[25] + data[24]) / 10000);//反向有功总电能示值 + electricityData.setReverseActiveTipCharge(Float.parseFloat(data[33] + data[32] + data[31] + data[30] + data[29]) / 10000); //尖 + electricityData.setReverseActivePeakCharge(Float.parseFloat(data[38] + data[37] + data[36] + data[35] + data[34]) / 10000);//峰 + electricityData.setReverseActivePowerLevel(Float.parseFloat(data[43] + data[42] + data[41] + data[40] + data[39]) / 10000); //平 + electricityData.setReverseActiveValleyCharge(Float.parseFloat(data[48] + data[47] + data[46] + data[45] + data[44]) / 10000);//谷 + integer = electricityDataDao.updateByPrimaryKey(electricityData); + System.out.println("已经填补剩余数据"); + } + return integer; + } + + public int[] detectingHeartbeat(String param, String clientIp) { + String[] data = param.split(" "); + int[] ints = new int[0]; + if(data.length > 12) { + switch (data[12]) { + case "02": + switch (data[16] + data[17]) { + case "0100": + ints = config.sendElectricInstruct2(clientIp, 1); + break; + } + break; + } + } + return ints; + } + + //16进制转ASCII编码 + public static String hexToAscii(String hexString) { + StringBuilder asciiString = new StringBuilder(); + for (int i = 0; i < hexString.length(); i += 2) { + String hexPair = hexString.substring(i, i + 2); + int charCode = Integer.parseInt(hexPair, 16); + asciiString.append((char) charCode); + } + return asciiString.toString(); + } + + public static String fixZhi(String data) { + int i = Integer.parseInt(data); + if(i%80 == 0){ + return "00"; + }else { + return data; + } + } +} \ No newline at end of file diff --git a/iot-zhengtai/src/main/java/org/example/druid/DBTypeEnum.java b/iot-zhengtai/src/main/java/org/example/druid/DBTypeEnum.java new file mode 100644 index 0000000..40cfd4c --- /dev/null +++ b/iot-zhengtai/src/main/java/org/example/druid/DBTypeEnum.java @@ -0,0 +1,25 @@ +package org.example.druid; + +public enum DBTypeEnum { + /** + * 主库 + */ + MASTER("master"), + + /** + * 从库 + */ + SLAVE("slave"); + + private final String value; + + DBTypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + +} + diff --git a/iot-zhengtai/src/main/java/org/example/druid/DbContextHolder.java b/iot-zhengtai/src/main/java/org/example/druid/DbContextHolder.java new file mode 100644 index 0000000..289654b --- /dev/null +++ b/iot-zhengtai/src/main/java/org/example/druid/DbContextHolder.java @@ -0,0 +1,33 @@ +package org.example.druid; + +public class DbContextHolder { + //使用ThreadLocal,防止线程安全问题 + private static final ThreadLocal CONTEXT_HOLDER = new ThreadLocal(); + + /** + * 设置数据源 + * + * @param dbTypeEnum 数据库类型 + */ + public static void setDbType(DBTypeEnum dbTypeEnum) { + CONTEXT_HOLDER.set(dbTypeEnum.getValue()); + } + + /** + * 取得当前数据源 + * + * @return dbType + */ + public static String getDbType() { + return (String) CONTEXT_HOLDER.get(); + } + + /** + * 清除上下文数据 + */ + public static void clearDbType() { + CONTEXT_HOLDER.remove(); + } + +} + diff --git a/iot-zhengtai/src/main/java/org/example/druid/DruidProperties.java b/iot-zhengtai/src/main/java/org/example/druid/DruidProperties.java new file mode 100644 index 0000000..b73b6b5 --- /dev/null +++ b/iot-zhengtai/src/main/java/org/example/druid/DruidProperties.java @@ -0,0 +1,49 @@ +package org.example.druid; + +import com.alibaba.druid.pool.DruidDataSource; +import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder; +import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.druid.DruidConfig; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; + +import javax.sql.DataSource; +import java.util.HashMap; +import java.util.Map; + +/** + * druid 配置属性 + */ +@Configuration +public class DruidProperties +{ + + + @Bean + @ConfigurationProperties("spring.datasource.dynamic.datasource.primary") + public DataSource primaryDataSource() + { + return DruidDataSourceBuilder.create().build(); + } + +// @Bean +// @ConfigurationProperties(prefix = "spring.datasource.slave") +// public DataSource slaveDataSource(){ +// return new DruidDataSourceBuilder().build(); +// } + + @Bean + @Primary + public DataSource multipleDataSource(DataSource masterDataSource){ + DynamicDataSource multipleDataSource = new DynamicDataSource(); + Map dataSources = new HashMap<>(); + dataSources.put(DBTypeEnum.MASTER.getValue(), masterDataSource); +// dataSources.put(DBTypeEnum.SLAVE.getValue(), slaveDataSource); + multipleDataSource.setTargetDataSources(dataSources); + multipleDataSource.setDefaultTargetDataSource(masterDataSource); + return multipleDataSource; + } + +} \ No newline at end of file diff --git a/iot-zhengtai/src/main/java/org/example/druid/DynamicDataSource.java b/iot-zhengtai/src/main/java/org/example/druid/DynamicDataSource.java new file mode 100644 index 0000000..7976c79 --- /dev/null +++ b/iot-zhengtai/src/main/java/org/example/druid/DynamicDataSource.java @@ -0,0 +1,10 @@ +package org.example.druid; + +import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; + +public class DynamicDataSource extends AbstractRoutingDataSource { + @Override + protected Object determineCurrentLookupKey() { + return DbContextHolder.getDbType(); + } +} diff --git a/iot-zhengtai/src/main/java/org/example/socket/BootNettySocketChannelInboundHandler.java b/iot-zhengtai/src/main/java/org/example/socket/BootNettySocketChannelInboundHandler.java new file mode 100644 index 0000000..9c9cdfa --- /dev/null +++ b/iot-zhengtai/src/main/java/org/example/socket/BootNettySocketChannelInboundHandler.java @@ -0,0 +1,197 @@ +package org.example.socket; + +import io.netty.channel.*; +import org.example.background.service.MakeInfoService; +import org.example.socket.utils.CommonConfig; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; + +import javax.annotation.Resource; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * @author zjb + * @since 2023-12-11 10:31:26 + */ +@Component +@EnableAsync +@ChannelHandler.Sharable +public class BootNettySocketChannelInboundHandler extends ChannelInboundHandlerAdapter { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Resource + private MakeInfoService makeInfoService; + + private Map ctxMap = new ConcurrentHashMap(16); + + /** + * 从客户端收到新的数据时,这个方法会在收到消息时被调用 + */ + @Override + public void channelRead(ChannelHandlerContext ctx, Object frame) { +// int[] ints = makeInfoService.sendElectricMessage("10.29.16.202", 25); + String result = makeInfoService.convertPlaintext((byte[]) frame); + ChannelFuture channelFuture1; + if(result.equals("-1")){ + logger.info("CLIENT:CRC校验错误,收到的数据不完整或错误"); + + System.out.println("CS校验对错误或者长度不符合预定,收到的数据不完整或错误"); + }else { + logger.info("CLIENT"+getClientIP(ctx)+":"+result); + System.out.println("ip为"+getClientIP(ctx)+"的客户端发送:"+result); + int[] ints = makeInfoService.detectingHeartbeat(result, getClientIP(ctx)); + if(ints.length > 0) { + //确认登录 + channelFuture1 = ctx.channel().writeAndFlush(ints); + channelFuture1.addListener((ChannelFutureListener) future2 -> { + if (future2.isSuccess()) { + sendEnergyMessages(ints, getClientIP(ctx)); + System.out.println("ip为" + getClientIP(ctx) + "确认登录成功"); + } else { + System.out.println("ip为" + getClientIP(ctx) + "确认登录失败"); + } + }); + }else{ + Integer res = makeInfoService.convertTextToData(result, getClientIP(ctx)); + int[] data2; + switch (res) { + case 25: + //发送补充指令 发送第二条指令 + data2 = makeInfoService.sendElectricMessage(getClientIP(ctx), 129); + channelFuture1 = ctx.channel().writeAndFlush(data2); + channelFuture1.addListener((ChannelFutureListener) future2 -> { + if (future2.isSuccess()) { + sendEnergyMessages(data2, getClientIP(ctx)); + } else { + logger.info("SERVER:第二条指令发送失败"); + System.out.println("ip为" + getClientIP(ctx) + "的第二条指令发送失败"); + } + }); + break; + case 129: + //发送补充指令 发送第二条指令 + data2 = makeInfoService.sendElectricMessage(getClientIP(ctx), 131); + channelFuture1 = ctx.channel().writeAndFlush(data2); + channelFuture1.addListener((ChannelFutureListener) future2 -> { + if (future2.isSuccess()) { + sendEnergyMessages(data2, getClientIP(ctx)); + } else { + logger.info("SERVER:第三条指令发送失败"); + System.out.println("ip为" + getClientIP(ctx) + "的第三条指令发送失败"); + } + }); + break; + default: + break; + } + } + } + } + + @Override + public void channelInactive(ChannelHandlerContext ctx) throws Exception { + // 客户端断开连接的处理逻辑 + System.out.println("客户端断开连接"); + ctxMap.remove(getClientIP(ctx)); + super.channelInactive(ctx); + } + + @Override + public void channelActive(ChannelHandlerContext ctx) throws Exception { + System.out.println("客户端(重新)连接:" + ctx.channel().remoteAddress()); + ctxMap.put(getClientIP(ctx),ctx); + super.channelActive(ctx); + } + + + /** + * 客户端与服务端 断连时执行 channelInactive方法之后执行 + */ + @Override + public void channelUnregistered(ChannelHandlerContext ctx) throws Exception { + ctxMap.remove(getClientIP(ctx)); + super.channelUnregistered(ctx); + } + + /** + * 当出现 Throwable 对象才会被调用,即当 Netty 由于 IO 错误或者处理器在处理事件时抛出的异常时 + */ + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { + super.exceptionCaught(ctx, cause); + } + + + @Scheduled(cron = "0 0 */1 * * *") //每小时的第0分钟第0秒 +// @Scheduled(fixedRate = 10000) //10秒 +// @Scheduled(fixedRate = 600000) //600秒 +// @Scheduled(cron = "*/5 * * * * *") //每5秒 + private void sendIntervals() { + int[] data = makeInfoService.sendElectricMessage(CommonConfig.electric1, 25); + ChannelHandlerContext ctx = ctxMap.get(CommonConfig.electric1); + if(!StringUtils.isEmpty(ctx)) { + ChannelFuture channelFuture = ctx.channel().writeAndFlush(data); + // 添加监听器,检查发送是否成功 + channelFuture.addListener((ChannelFutureListener) future1 -> { + if(future1.isSuccess()) { + sendEnergyMessages(data,CommonConfig.electric1); + sendIntervals2(); + }else{ + logger.info("SERVER:第一条指令发送失败"); + System.out.println("第一条指令发送失败"); + } + }); + }else{ + logger.info("SERVER:ip为"+CommonConfig.electric2+"的客户端不在线。无法传递指令"); + System.out.println("ip为"+CommonConfig.electric1+"的客户端不在线。无法传递指令"); + } + } + +// @Scheduled(cron = "0 0 */1 * * *") //每小时的第0分钟第0秒 +// @Scheduled(cron = "*/5 * * * * *") //每5秒 +// @Scheduled(fixedRate = 10000) //10秒 + private void sendIntervals2() { + int[] data = makeInfoService.sendElectricMessage(CommonConfig.electric2, 25); + ChannelHandlerContext ctx = ctxMap.get(CommonConfig.electric2); + if(!StringUtils.isEmpty(ctx)) { + ChannelFuture channelFuture = ctx.channel().writeAndFlush(data); + // 添加监听器,检查发送是否成功 + channelFuture.addListener((ChannelFutureListener) future1 -> { + if(future1.isSuccess()) { + sendEnergyMessages(data,CommonConfig.electric2); + }else{ + logger.info("SERVER:第一条指令发送失败"); + System.out.println("第一条指令发送失败"); + } + }); + }else{ + logger.info("SERVER:ip为"+CommonConfig.electric2+"的客户端不在线。无法传递指令"); + System.out.println("ip为"+CommonConfig.electric2+"的客户端不在线。无法传递指令"); + } + } + + public void sendEnergyMessages(int [] data,String ip){ + StringBuffer stringBuffer = new StringBuffer(); + for(int num = 0; num < data.length; num++){ + if (num == data.length - 1) { + stringBuffer.append(Integer.toHexString(data[num])); + }else { + stringBuffer.append(Integer.toHexString(data[num])+" "); + } + } + System.out.println("成功发送指令:"+stringBuffer); + logger.info("SERVER:成功发送指令:"+stringBuffer); + } + + public String getClientIP(ChannelHandlerContext ctx){ + String ip = ctx.channel().remoteAddress().toString(); + return ip.substring(1, ip.indexOf(":")); + } + +} diff --git a/iot-zhengtai/src/main/java/org/example/socket/BootNettySocketServer.java b/iot-zhengtai/src/main/java/org/example/socket/BootNettySocketServer.java new file mode 100644 index 0000000..6e40ee5 --- /dev/null +++ b/iot-zhengtai/src/main/java/org/example/socket/BootNettySocketServer.java @@ -0,0 +1,78 @@ +package org.example.socket; + +import io.netty.bootstrap.ServerBootstrap; +import io.netty.buffer.PooledByteBufAllocator; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelInitializer; +import io.netty.channel.ChannelOption; +import io.netty.channel.ChannelPipeline; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.SocketChannel; +import io.netty.channel.socket.nio.NioServerSocketChannel; +import io.netty.handler.logging.LoggingHandler; +import org.example.socket.utils.MyDecoder; +import org.example.socket.utils.MyEncoder; +import org.mybatis.logging.Logger; +import org.mybatis.logging.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * @author zjb + * @since 2023-12-11 10:39:00 + */ +@Component +public class BootNettySocketServer { + + private static final Logger logger = LoggerFactory.getLogger(BootNettySocketServer.class); + + private NioEventLoopGroup bossGroup; + + private NioEventLoopGroup workGroup; + + @Autowired + private BootNettySocketChannelInboundHandler bootNettySocketChannelInboundHandler; + + + /** + * 启动服务 + */ + public void startup(int port) { + try { + bossGroup = new NioEventLoopGroup(1); + workGroup = new NioEventLoopGroup(); + ServerBootstrap bootstrap = new ServerBootstrap(); + bootstrap.group(bossGroup, workGroup); + bootstrap.channel(NioServerSocketChannel.class); + + bootstrap.option(ChannelOption.SO_REUSEADDR, true) + .option(ChannelOption.SO_BACKLOG, 1024) + .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) + .option(ChannelOption.SO_RCVBUF, 10485760); + + bootstrap.childOption(ChannelOption.TCP_NODELAY, true) + .childOption(ChannelOption.SO_KEEPALIVE, true) + .childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); + + bootstrap.childHandler(new ChannelInitializer() { + protected void initChannel(SocketChannel ch) { + ChannelPipeline channelPipeline = ch.pipeline(); + channelPipeline.addLast("encoder", new MyEncoder()); + channelPipeline.addLast("decoder", new MyDecoder()); + channelPipeline.addLast(new LoggingHandler()); + channelPipeline.addLast(bootNettySocketChannelInboundHandler); + } + }); + ChannelFuture f = bootstrap.bind(port).sync(); + if(f.isSuccess()){ + System.out.println("成功侦听端口:" + port); + f.channel().closeFuture().sync(); + } else { + System.out.println("侦听端口失败:" + port); + } + } catch (Exception e) { + System.out.println("start exception"+e.toString()); + } + } + +} diff --git a/iot-zhengtai/src/main/java/org/example/socket/BootNettySocketServerThread.java b/iot-zhengtai/src/main/java/org/example/socket/BootNettySocketServerThread.java new file mode 100644 index 0000000..c555ceb --- /dev/null +++ b/iot-zhengtai/src/main/java/org/example/socket/BootNettySocketServerThread.java @@ -0,0 +1,21 @@ +package org.example.socket; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * @author zjb + * @since 2023-12-11 10:35:00 + */ +@Component +public class BootNettySocketServerThread extends Thread { + private final int port = 7779; + + @Autowired + private BootNettySocketServer bootNettySocketServer; + + public void run() { + bootNettySocketServer.startup(this.port); + } + +} diff --git a/iot-zhengtai/src/main/java/org/example/socket/utils/CommonConfig.java b/iot-zhengtai/src/main/java/org/example/socket/utils/CommonConfig.java new file mode 100644 index 0000000..7c3c2ea --- /dev/null +++ b/iot-zhengtai/src/main/java/org/example/socket/utils/CommonConfig.java @@ -0,0 +1,117 @@ +package org.example.socket.utils; + +import org.springframework.stereotype.Component; + +@Component +public class CommonConfig { + + public static final String electric0 = "127.0.0.1"; + + public static final String electric1 = "10.29.16.202"; + + public static final String electric2 = "10.29.16.244"; + + public int [] sendElectricInstruct (String ip,int fn) { + int [] arr = new int[20]; + arr[0] = 0x68; + arr[1] = 0x00; + arr[2] = 0x00; + arr[3] = 0x00; + arr[4] = 0x00; + arr[5] = 0x68; + arr[6] = 0x4B; + arr[7] = 0x22; // 地址域 + arr[8] = 0x20; + arr[9] = 0xFE; + arr[10] = 0x52; + arr[11] = 0x00; + arr[12] = 0x0C; + arr[13] = 0x70; + arr[14] = 0xFF; // Pn + arr[15] = 0x00; + arr[16] = 0x00; //Fn + arr[17] = 0x00; + arr[18] = 0x00; + arr[19] = 0x16; + getAddress(arr,ip,fn); + getCSAndLength(arr); + return arr; + } + + public int [] sendElectricInstruct2 (String ip,int fn) { + int [] arr = new int[20]; + arr[0] = 0x68; + arr[1] = 0x00; + arr[2] = 0x00; + arr[3] = 0x00; + arr[4] = 0x00; + arr[5] = 0x68; + arr[6] = 0x4B; + arr[7] = 0x22; // 地址域 + arr[8] = 0x20; + arr[9] = 0xFE; + arr[10] = 0x52; + arr[11] = 0x00; + arr[12] = 0x00; + arr[13] = 0x70; + arr[14] = 0x00; // Pn + arr[15] = 0x00; + arr[16] = 0x01; //Fn + arr[17] = 0x00; + arr[18] = 0x00; + arr[19] = 0x16; + getAddress(arr,ip,fn); + getCSAndLength(arr); + return arr; + } + + + public void getAddress (int [] arr,String ip,int fn) { + switch (ip) { + case electric1: + arr[7] = 0x22; + arr[8] = 0x20; + arr[9] = 0xFE; + arr[10] = 0x52; + arr[11] = 0x00; + break; + case electric2: + arr[7] = 0x22; + arr[8] = 0x20; + arr[9] = 0xFD; + arr[10] = 0x52; + arr[11] = 0x00; + break; + } + arr[16] = get8421(fn - (fn / 8) * 8); + arr[17] = fn / 8; + } + + public int get8421(int DT1) { + int dt = 00; + switch (DT1) { + case 1 : dt = 0x01; break; + case 2 : dt = 0x02; break; + case 3 : dt = 0x04; break; + case 4 : dt = 0x08; break; + case 5 : dt = 0x10; break; + case 6 : dt = 0x20; break; + case 7 : dt = 0x40; break; + case 8 : dt = 0x80; break; + } + return dt; + } + + public void getCSAndLength (int [] arr) { + arr[1] =Integer.parseInt(Integer.toHexString(Integer.parseInt(Integer.toBinaryString(arr.length - 8) + "10", 2)),16); + arr[3] = arr[1]; + for (int i = 6; i < arr.length - 2; i++) { + arr[arr.length - 2] += arr[i]; + } + if(arr[arr.length - 2] > 255) { + String s = Integer.toHexString(arr[arr.length - 2]); + arr[arr.length - 2] = Integer.parseInt(s.substring(s.length() - 2,s.length()),16); + } + } + +} diff --git a/iot-energy/src/main/java/org/example/background/utils/FieldUtils.java b/iot-zhengtai/src/main/java/org/example/socket/utils/FieldUtils.java similarity index 97% rename from iot-energy/src/main/java/org/example/background/utils/FieldUtils.java rename to iot-zhengtai/src/main/java/org/example/socket/utils/FieldUtils.java index 96caa5c..3d5b0d1 100644 --- a/iot-energy/src/main/java/org/example/background/utils/FieldUtils.java +++ b/iot-zhengtai/src/main/java/org/example/socket/utils/FieldUtils.java @@ -1,4 +1,4 @@ -package org.example.background.utils; +package org.example.socket.utils; import java.util.regex.Matcher; import java.util.regex.Pattern; diff --git a/iot-zhengtai/src/main/java/org/example/socket/utils/IdService.java b/iot-zhengtai/src/main/java/org/example/socket/utils/IdService.java new file mode 100644 index 0000000..0997dad --- /dev/null +++ b/iot-zhengtai/src/main/java/org/example/socket/utils/IdService.java @@ -0,0 +1,16 @@ +package org.example.socket.utils; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class IdService { + + + @Autowired + private SnowflakeIdGenerator generator; + + public String gen() { + return String.valueOf(generator.nextId()); + } +} diff --git a/iot-zhengtai/src/main/java/org/example/socket/utils/MyDecoder.java b/iot-zhengtai/src/main/java/org/example/socket/utils/MyDecoder.java new file mode 100644 index 0000000..fa573a4 --- /dev/null +++ b/iot-zhengtai/src/main/java/org/example/socket/utils/MyDecoder.java @@ -0,0 +1,47 @@ +package org.example.socket.utils; + +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.ByteToMessageDecoder; + +import java.util.List; + +/** + * @author ZJB + * @since 2023-12-11 10:50:00 + */ +public class MyDecoder extends ByteToMessageDecoder { + + @Override + protected void decode(ChannelHandlerContext ctx, ByteBuf buffer, List out) throws Exception { + byte[] b = new byte[buffer.readableBytes()]; + buffer.readBytes(b); + out.add(b); + } + + public String bytesToHexString(byte[] bArray) { + StringBuffer sb = new StringBuffer(bArray.length); + String sTemp; + for (int i = 0; i < bArray.length; i++) { + sTemp = Integer.toHexString(0xFF & bArray[i]); + if (sTemp.length() < 2) + sb.append(0); + if(i < bArray.length - 1){ + sb.append(sTemp.toUpperCase()).append(" "); + }else{ + sb.append(sTemp.toUpperCase()); + } + } + return sb.toString(); + } + + public static String toHexString1(byte b) { + String s = Integer.toHexString(b & 0xFF); + if (s.length() == 1) { + return "0" + s; + } else { + return s; + } + } + +} diff --git a/iot-zhengtai/src/main/java/org/example/socket/utils/MyEncoder.java b/iot-zhengtai/src/main/java/org/example/socket/utils/MyEncoder.java new file mode 100644 index 0000000..276666a --- /dev/null +++ b/iot-zhengtai/src/main/java/org/example/socket/utils/MyEncoder.java @@ -0,0 +1,44 @@ +package org.example.socket.utils; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelOutboundHandlerAdapter; +import io.netty.channel.ChannelPromise; +import org.apache.commons.codec.DecoderException; +import org.apache.commons.codec.binary.Hex; + +/** + * @author zjb + * @since 2023-12-11 10:49:32 + */ +public class MyEncoder extends ChannelOutboundHandlerAdapter { + + @Override + public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { + // 对消息进行编码 + ByteBuf encodedMsg = encode2(msg); + // 将编码后的消息发送到下一个 ChannelHandler + ctx.write(encodedMsg, promise); + } + + // 自定义的编码方法 + private ByteBuf encode(Object msg) throws DecoderException { + // 实现编码逻辑 + ByteBuf buf = Unpooled.buffer(); + buf.writeBytes(Hex.decodeHex(msg.toString().replaceAll(" ", "").toCharArray())); + return buf; + } + + //编码 十进制数组编码 + private ByteBuf encode2(Object msg) throws DecoderException { +// 创建一个新的ByteBuf对象 + ByteBuf byteBuf = Unpooled.buffer(); + // 遍历数组并写入到ByteBuf中 + for (int i : (int [])msg) { + byteBuf.writeByte(i); + } + return byteBuf; + } + +} diff --git a/iot-zhengtai/src/main/java/org/example/socket/utils/SnowflakeIdGenerator.java b/iot-zhengtai/src/main/java/org/example/socket/utils/SnowflakeIdGenerator.java new file mode 100644 index 0000000..40ae64f --- /dev/null +++ b/iot-zhengtai/src/main/java/org/example/socket/utils/SnowflakeIdGenerator.java @@ -0,0 +1,131 @@ +package org.example.socket.utils; + +import org.springframework.stereotype.Component; + +@Component +public class SnowflakeIdGenerator { + + // ==============================Fields=========================================== + /** + * 开始时间截 (2015-01-01) + */ + private final long twepoch = 1420041600000L; + /** + * 机器id所占的位数 + */ + private final long workerIdBits = 5L; + /** + * 数据标识id所占的位数 + */ + private final long datacenterIdBits = 5L; + /** + * 支持的最大机器id,结果是31 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数) + */ + private final long maxWorkerId = -1L ^ (-1L << workerIdBits); + /** + * 支持的最大数据标识id,结果是31 + */ + private final long maxDatacenterId = -1L ^ (-1L << datacenterIdBits); + /** + * 序列在id中占的位数 + */ + private final long sequenceBits = 12L; + /** + * 机器ID向左移12位 + */ + private final long workerIdShift = sequenceBits; + /** + * 数据标识id向左移17位(12+5) + */ + private final long datacenterIdShift = sequenceBits + workerIdBits; + /** + * 时间截向左移22位(5+5+12) + */ + private final long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits; + /** + * 生成序列的掩码,这里为4095 (0b111111111111=0xfff=4095) + */ + private final long sequenceMask = -1L ^ (-1L << sequenceBits); + /** + * 工作机器ID(0~31) + */ + private long workerId; + /** + * 数据中心ID(0~31) + */ + private long datacenterId; + /** + * 毫秒内序列(0~4095) + */ + private long sequence = 0L; + /** + * 上次生成ID的时间截 + */ + private long lastTimestamp = -1L; + //==============================Constructors===================================== + + /** + * 构造函数 * @param workerId 工作ID (0~31) * @param datacenterId 数据中心ID (0~31) + */ + public SnowflakeIdGenerator(long workerId, long datacenterId) { + if (workerId > maxWorkerId || workerId < 0) { + throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId)); + } + if (datacenterId > maxDatacenterId || datacenterId < 0) { + throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId)); + } + this.workerId = workerId; + this.datacenterId = datacenterId; + } // ==============================Methods========================================== + + public SnowflakeIdGenerator() { + + } + + /** + * 获得下一个ID (该方法是线程安全的) * @return SnowflakeId + */ + public synchronized long nextId() { + long timestamp = timeGen(); + //如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常 +// if (timestamp < lastTimestamp) { +// throw new RuntimeException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp)); +// } + //如果是同一时间生成的,则进行毫秒内序列 + if (lastTimestamp == timestamp) { + sequence = (sequence + 1) & sequenceMask; + //毫秒内序列溢出 + if (sequence == 0) { + //阻塞到下一个毫秒,获得新的时间戳 + timestamp = tilNextMillis(lastTimestamp); + } + } + //时间戳改变,毫秒内序列重置 + else { + sequence = 0L; + } + //上次生成ID的时间截 + lastTimestamp = timestamp; + //移位并通过或运算拼到一起组成64位的ID + return ((timestamp - twepoch) << timestampLeftShift) + | (datacenterId << datacenterIdShift) | (workerId << workerIdShift) | sequence; + } + + /** + * 阻塞到下一个毫秒,直到获得新的时间戳 * @param lastTimestamp 上次生成ID的时间截 * @return 当前时间戳 + */ + protected long tilNextMillis(long lastTimestamp) { + long timestamp = timeGen(); + while (timestamp <= lastTimestamp) { + timestamp = timeGen(); + } + return timestamp; + } + + /** + * 返回以毫秒为单位的当前时间 * @return 当前时间(毫秒) + */ + protected long timeGen() { + return System.currentTimeMillis(); + } +} diff --git a/iot-zhengtai/src/main/resources/application.properties b/iot-zhengtai/src/main/resources/application.properties new file mode 100644 index 0000000..2b37f8b --- /dev/null +++ b/iot-zhengtai/src/main/resources/application.properties @@ -0,0 +1,32 @@ +spring.application.name=netty +server.servlet.encoding.force=true +server.port=7782 +lombok.var.flagUsage = ALLOW +# Single file max size +multipart.maxFileSize=50Mb +# All files max size +multipart.maxRequestSize=50Mb + +spring.datasource.dynamic.datasource.primary=primary +spring.datasource.dynamic.datasource.primary.url=jdbc:mysql://10.16.56.3:3308/jcxt?useUnicode=true&characterEncoding=utf-8&useSSL=false +spring.datasource.dynamic.datasource.primary.username=root +spring.datasource.dynamic.datasource.primary.password=Unity3du#d112233 +spring.datasource.dynamic.datasource.primary.driver-class-name=com.mysql.jdbc.Driver +spring.datasource.dynamic.druid.initial-size=10 +spring.datasource.dynamic.druid.max-idle=20 +spring.datasource.dynamic.druid.min-idle=5 +spring.datasource.dynamic.druid.max-active=50 +spring.datasource.dynamic.druid.log-abandoned=true +spring.datasource.dynamic.druid.remove-abandoned=true +spring.datasource.dynamic.druid.remove-abandoned-timeout-millis=120 +spring.datasource.dynamic.druid.max-wait=1000 +spring.datasource.dynamic.druid.test-while-idle=true +spring.datasource.dynamic.druid.validation-query=select 1 from dual +spring.datasource.dynamic.druid.test-on-borrow=true +spring.datasource.dynamic.druid.min-evictable-idle-time-millis=100000 +spring.datasource.dynamic.druid.max-evictable-idle-time-millis=100000 +spring.datasource.dynamic.druid.time-between-eviction-runs-millis=100000 +spring.datasource.dynamic.druid.break-after-acquire-failure=true +spring.datasource.dynamic.druid.connection-error-retry-attempts=5 +spring.datasource.dynamic.druid.fail-fast=true +spring.datasource.dynamic.druid.time-between-connect-error-millis=10000 \ No newline at end of file diff --git a/iot-zhengtai/src/main/resources/logback.xml b/iot-zhengtai/src/main/resources/logback.xml new file mode 100644 index 0000000..13e94cd --- /dev/null +++ b/iot-zhengtai/src/main/resources/logback.xml @@ -0,0 +1,21 @@ + + + + electricLog/electricLog.log + + electricLog/electricLog-%d{yyyy-MM-dd}.log + 180 + + + %d{yyyy-MM-dd HH:mm:ss.SSS} - %msg%n + + + + + + + + + + + \ No newline at end of file diff --git a/iot-zhengtai/target/classes/application.properties b/iot-zhengtai/target/classes/application.properties new file mode 100644 index 0000000..2b37f8b --- /dev/null +++ b/iot-zhengtai/target/classes/application.properties @@ -0,0 +1,32 @@ +spring.application.name=netty +server.servlet.encoding.force=true +server.port=7782 +lombok.var.flagUsage = ALLOW +# Single file max size +multipart.maxFileSize=50Mb +# All files max size +multipart.maxRequestSize=50Mb + +spring.datasource.dynamic.datasource.primary=primary +spring.datasource.dynamic.datasource.primary.url=jdbc:mysql://10.16.56.3:3308/jcxt?useUnicode=true&characterEncoding=utf-8&useSSL=false +spring.datasource.dynamic.datasource.primary.username=root +spring.datasource.dynamic.datasource.primary.password=Unity3du#d112233 +spring.datasource.dynamic.datasource.primary.driver-class-name=com.mysql.jdbc.Driver +spring.datasource.dynamic.druid.initial-size=10 +spring.datasource.dynamic.druid.max-idle=20 +spring.datasource.dynamic.druid.min-idle=5 +spring.datasource.dynamic.druid.max-active=50 +spring.datasource.dynamic.druid.log-abandoned=true +spring.datasource.dynamic.druid.remove-abandoned=true +spring.datasource.dynamic.druid.remove-abandoned-timeout-millis=120 +spring.datasource.dynamic.druid.max-wait=1000 +spring.datasource.dynamic.druid.test-while-idle=true +spring.datasource.dynamic.druid.validation-query=select 1 from dual +spring.datasource.dynamic.druid.test-on-borrow=true +spring.datasource.dynamic.druid.min-evictable-idle-time-millis=100000 +spring.datasource.dynamic.druid.max-evictable-idle-time-millis=100000 +spring.datasource.dynamic.druid.time-between-eviction-runs-millis=100000 +spring.datasource.dynamic.druid.break-after-acquire-failure=true +spring.datasource.dynamic.druid.connection-error-retry-attempts=5 +spring.datasource.dynamic.druid.fail-fast=true +spring.datasource.dynamic.druid.time-between-connect-error-millis=10000 \ No newline at end of file diff --git a/iot-zhengtai/target/classes/logback.xml b/iot-zhengtai/target/classes/logback.xml new file mode 100644 index 0000000..13e94cd --- /dev/null +++ b/iot-zhengtai/target/classes/logback.xml @@ -0,0 +1,21 @@ + + + + electricLog/electricLog.log + + electricLog/electricLog-%d{yyyy-MM-dd}.log + 180 + + + %d{yyyy-MM-dd HH:mm:ss.SSS} - %msg%n + + + + + + + + + + + \ No newline at end of file diff --git a/iot-zhengtai/target/classes/org/example/IotApplication.class b/iot-zhengtai/target/classes/org/example/IotApplication.class new file mode 100644 index 0000000..a163569 Binary files /dev/null and b/iot-zhengtai/target/classes/org/example/IotApplication.class differ diff --git a/iot-zhengtai/target/classes/org/example/background/condition/ElectricityDataCondition.class b/iot-zhengtai/target/classes/org/example/background/condition/ElectricityDataCondition.class new file mode 100644 index 0000000..ed29e00 Binary files /dev/null and b/iot-zhengtai/target/classes/org/example/background/condition/ElectricityDataCondition.class differ diff --git a/iot-zhengtai/target/classes/org/example/background/dao/ElectricityDataDao.class b/iot-zhengtai/target/classes/org/example/background/dao/ElectricityDataDao.class new file mode 100644 index 0000000..dec0ad2 Binary files /dev/null and b/iot-zhengtai/target/classes/org/example/background/dao/ElectricityDataDao.class differ diff --git a/iot-zhengtai/target/classes/org/example/background/entity/ElectricityData.class b/iot-zhengtai/target/classes/org/example/background/entity/ElectricityData.class new file mode 100644 index 0000000..ae459fe Binary files /dev/null and b/iot-zhengtai/target/classes/org/example/background/entity/ElectricityData.class differ diff --git a/iot-zhengtai/target/classes/org/example/background/entity/ElectricityDayData.class b/iot-zhengtai/target/classes/org/example/background/entity/ElectricityDayData.class new file mode 100644 index 0000000..8371d93 Binary files /dev/null and b/iot-zhengtai/target/classes/org/example/background/entity/ElectricityDayData.class differ diff --git a/iot-zhengtai/target/classes/org/example/background/entity/ElectricityMonthData.class b/iot-zhengtai/target/classes/org/example/background/entity/ElectricityMonthData.class new file mode 100644 index 0000000..dde2268 Binary files /dev/null and b/iot-zhengtai/target/classes/org/example/background/entity/ElectricityMonthData.class differ diff --git a/iot-zhengtai/target/classes/org/example/background/service/MakeInfoService.class b/iot-zhengtai/target/classes/org/example/background/service/MakeInfoService.class new file mode 100644 index 0000000..91bbe8d Binary files /dev/null and b/iot-zhengtai/target/classes/org/example/background/service/MakeInfoService.class differ diff --git a/iot-zhengtai/target/classes/org/example/druid/DBTypeEnum.class b/iot-zhengtai/target/classes/org/example/druid/DBTypeEnum.class new file mode 100644 index 0000000..be0f9d1 Binary files /dev/null and b/iot-zhengtai/target/classes/org/example/druid/DBTypeEnum.class differ diff --git a/iot-zhengtai/target/classes/org/example/druid/DbContextHolder.class b/iot-zhengtai/target/classes/org/example/druid/DbContextHolder.class new file mode 100644 index 0000000..1cc6421 Binary files /dev/null and b/iot-zhengtai/target/classes/org/example/druid/DbContextHolder.class differ diff --git a/iot-zhengtai/target/classes/org/example/druid/DruidProperties.class b/iot-zhengtai/target/classes/org/example/druid/DruidProperties.class new file mode 100644 index 0000000..3d6585f Binary files /dev/null and b/iot-zhengtai/target/classes/org/example/druid/DruidProperties.class differ diff --git a/iot-zhengtai/target/classes/org/example/druid/DynamicDataSource.class b/iot-zhengtai/target/classes/org/example/druid/DynamicDataSource.class new file mode 100644 index 0000000..73376cc Binary files /dev/null and b/iot-zhengtai/target/classes/org/example/druid/DynamicDataSource.class differ diff --git a/iot-zhengtai/target/classes/org/example/socket/BootNettySocketChannelInboundHandler.class b/iot-zhengtai/target/classes/org/example/socket/BootNettySocketChannelInboundHandler.class new file mode 100644 index 0000000..b6fe3a9 Binary files /dev/null and b/iot-zhengtai/target/classes/org/example/socket/BootNettySocketChannelInboundHandler.class differ diff --git a/iot-zhengtai/target/classes/org/example/socket/BootNettySocketServer$1.class b/iot-zhengtai/target/classes/org/example/socket/BootNettySocketServer$1.class new file mode 100644 index 0000000..253d708 Binary files /dev/null and b/iot-zhengtai/target/classes/org/example/socket/BootNettySocketServer$1.class differ diff --git a/iot-zhengtai/target/classes/org/example/socket/BootNettySocketServer.class b/iot-zhengtai/target/classes/org/example/socket/BootNettySocketServer.class new file mode 100644 index 0000000..dd186b7 Binary files /dev/null and b/iot-zhengtai/target/classes/org/example/socket/BootNettySocketServer.class differ diff --git a/iot-zhengtai/target/classes/org/example/socket/BootNettySocketServerThread.class b/iot-zhengtai/target/classes/org/example/socket/BootNettySocketServerThread.class new file mode 100644 index 0000000..fe302fe Binary files /dev/null and b/iot-zhengtai/target/classes/org/example/socket/BootNettySocketServerThread.class differ diff --git a/iot-zhengtai/target/classes/org/example/socket/utils/CommonConfig.class b/iot-zhengtai/target/classes/org/example/socket/utils/CommonConfig.class new file mode 100644 index 0000000..16deb04 Binary files /dev/null and b/iot-zhengtai/target/classes/org/example/socket/utils/CommonConfig.class differ diff --git a/iot-zhengtai/target/classes/org/example/socket/utils/FieldUtils.class b/iot-zhengtai/target/classes/org/example/socket/utils/FieldUtils.class new file mode 100644 index 0000000..a630cc5 Binary files /dev/null and b/iot-zhengtai/target/classes/org/example/socket/utils/FieldUtils.class differ diff --git a/iot-zhengtai/target/classes/org/example/socket/utils/IdService.class b/iot-zhengtai/target/classes/org/example/socket/utils/IdService.class new file mode 100644 index 0000000..6b6a748 Binary files /dev/null and b/iot-zhengtai/target/classes/org/example/socket/utils/IdService.class differ diff --git a/iot-zhengtai/target/classes/org/example/socket/utils/MyDecoder.class b/iot-zhengtai/target/classes/org/example/socket/utils/MyDecoder.class new file mode 100644 index 0000000..f65839f Binary files /dev/null and b/iot-zhengtai/target/classes/org/example/socket/utils/MyDecoder.class differ diff --git a/iot-zhengtai/target/classes/org/example/socket/utils/MyEncoder.class b/iot-zhengtai/target/classes/org/example/socket/utils/MyEncoder.class new file mode 100644 index 0000000..6a7b6c3 Binary files /dev/null and b/iot-zhengtai/target/classes/org/example/socket/utils/MyEncoder.class differ diff --git a/iot-zhengtai/target/classes/org/example/socket/utils/SnowflakeIdGenerator.class b/iot-zhengtai/target/classes/org/example/socket/utils/SnowflakeIdGenerator.class new file mode 100644 index 0000000..fa19436 Binary files /dev/null and b/iot-zhengtai/target/classes/org/example/socket/utils/SnowflakeIdGenerator.class differ diff --git a/iot-zhengtai/target/iot-zhengtai-1.0-SNAPSHOT.jar b/iot-zhengtai/target/iot-zhengtai-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..2e42961 Binary files /dev/null and b/iot-zhengtai/target/iot-zhengtai-1.0-SNAPSHOT.jar differ diff --git a/iot-zhengtai/target/iot-zhengtai-1.0-SNAPSHOT.jar.original b/iot-zhengtai/target/iot-zhengtai-1.0-SNAPSHOT.jar.original new file mode 100644 index 0000000..207ff8d Binary files /dev/null and b/iot-zhengtai/target/iot-zhengtai-1.0-SNAPSHOT.jar.original differ diff --git a/iot-zhengtai/target/maven-archiver/pom.properties b/iot-zhengtai/target/maven-archiver/pom.properties new file mode 100644 index 0000000..c2590b4 --- /dev/null +++ b/iot-zhengtai/target/maven-archiver/pom.properties @@ -0,0 +1,4 @@ +#Created by Apache Maven 3.9.5 +groupId=org.example +artifactId=iot-zhengtai +version=1.0-SNAPSHOT diff --git a/iot-zhengtai/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/iot-zhengtai/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..3d9ea1a --- /dev/null +++ b/iot-zhengtai/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,21 @@ +org\example\background\entity\ElectricityData.class +org\example\socket\utils\SnowflakeIdGenerator.class +org\example\background\condition\ElectricityDataCondition.class +org\example\socket\utils\CommonConfig.class +org\example\socket\utils\MyDecoder.class +org\example\background\entity\ElectricityDayData.class +org\example\druid\DynamicDataSource.class +org\example\socket\utils\IdService.class +org\example\socket\BootNettySocketChannelInboundHandler.class +org\example\socket\utils\MyEncoder.class +org\example\socket\BootNettySocketServerThread.class +org\example\druid\DbContextHolder.class +org\example\socket\BootNettySocketServer$1.class +org\example\druid\DBTypeEnum.class +org\example\IotApplication.class +org\example\background\service\MakeInfoService.class +org\example\socket\BootNettySocketServer.class +org\example\socket\utils\FieldUtils.class +org\example\druid\DruidProperties.class +org\example\background\dao\ElectricityDataDao.class +org\example\background\entity\ElectricityMonthData.class diff --git a/iot-zhengtai/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/iot-zhengtai/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..be3d7a7 --- /dev/null +++ b/iot-zhengtai/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,20 @@ +D:\LGZN-p\iot-zhengtai\src\main\java\org\example\socket\BootNettySocketServerThread.java +D:\LGZN-p\iot-zhengtai\src\main\java\org\example\socket\utils\MyDecoder.java +D:\LGZN-p\iot-zhengtai\src\main\java\org\example\socket\BootNettySocketServer.java +D:\LGZN-p\iot-zhengtai\src\main\java\org\example\socket\utils\CommonConfig.java +D:\LGZN-p\iot-zhengtai\src\main\java\org\example\socket\utils\IdService.java +D:\LGZN-p\iot-zhengtai\src\main\java\org\example\IotApplication.java +D:\LGZN-p\iot-zhengtai\src\main\java\org\example\socket\utils\SnowflakeIdGenerator.java +D:\LGZN-p\iot-zhengtai\src\main\java\org\example\socket\utils\MyEncoder.java +D:\LGZN-p\iot-zhengtai\src\main\java\org\example\background\condition\ElectricityDataCondition.java +D:\LGZN-p\iot-zhengtai\src\main\java\org\example\background\entity\ElectricityMonthData.java +D:\LGZN-p\iot-zhengtai\src\main\java\org\example\socket\utils\FieldUtils.java +D:\LGZN-p\iot-zhengtai\src\main\java\org\example\druid\DBTypeEnum.java +D:\LGZN-p\iot-zhengtai\src\main\java\org\example\background\entity\ElectricityData.java +D:\LGZN-p\iot-zhengtai\src\main\java\org\example\background\entity\ElectricityDayData.java +D:\LGZN-p\iot-zhengtai\src\main\java\org\example\druid\DbContextHolder.java +D:\LGZN-p\iot-zhengtai\src\main\java\org\example\druid\DruidProperties.java +D:\LGZN-p\iot-zhengtai\src\main\java\org\example\background\service\MakeInfoService.java +D:\LGZN-p\iot-zhengtai\src\main\java\org\example\druid\DynamicDataSource.java +D:\LGZN-p\iot-zhengtai\src\main\java\org\example\socket\BootNettySocketChannelInboundHandler.java +D:\LGZN-p\iot-zhengtai\src\main\java\org\example\background\dao\ElectricityDataDao.java diff --git a/iot-zhengtai/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/iot-zhengtai/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29