优化pom文件,一些枚举类的增加

This commit is contained in:
wulin 2023-08-03 15:25:40 +08:00
parent 26acc62ae0
commit 75ae0a7a28
17 changed files with 456 additions and 112 deletions

View File

@ -7,18 +7,8 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>iot-annotation</artifactId>
<name>Maven</name>
<url>http://maven.apache.org/</url>
<inceptionYear>2001</inceptionYear>
<distributionManagement>
<site>
<id>website</id>
<url>scp://webhost.company.com/www/website</url>
</site>
</distributionManagement>
<artifactId>iot-base</artifactId>
<name>iot-base</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -34,14 +24,22 @@
<artifactId>spring-context</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<locales>en,fr</locales>
<!--跳过对项目中main方法的查找-->
<skip>true</skip>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -0,0 +1,19 @@
package com.qiuguo.iot.base.enums;
/*
* 闹铃重复次数
* 作者吴林
* */
// 0响铃一次time指定的时间 1每天 2指定星期
public enum AlarmRepeatEnum {
ONE(0, "指定时间响铃一次"),
EVERY_DAY(1, "每天"),
WEEK(2, "指定星期"),
;
AlarmRepeatEnum(Integer c, String n){
code = c;
name = n;
}
private Integer code;
private String name;
}

View File

@ -0,0 +1,47 @@
package com.qiuguo.iot.base.enums;
/*
* 问答枚举
* 作者吴林
* */
// 0 大预言普通问答 1 天气 2 音乐 3 闹钟 4talk_answer_config配置回答
public enum AskTypeEnum {
LANGUAGE_MODEL(0, "大语言模型"),
WEATHER(1, "天气"),
SOUND(2, "音乐"),
ALARM(3, "闹钟"),
SYS_CONFIG(4, "后台配置的"),
;
AskTypeEnum(Integer c, String n){
code = c;
name = n;
}
private Integer code;
private String name;
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
public AskTypeEnum getEnumWithCode(Integer c){
for (AskTypeEnum e:values()
) {
if(e.getCode().compareTo(c) == 0){
return e;
}
}
return null;
}
public AskTypeEnum getEnumWithName(String name){
for (AskTypeEnum e:values()
) {
if(e.getName().compareTo(name) == 0){
return e;
}
}
return null;
}
}

View File

@ -0,0 +1,63 @@
package com.qiuguo.iot.base.enums;
/*
* 设备类型枚举
* 作者吴林
* */
// 0 果Box 1智能插座 2智能大灯 3智能窗帘驱动 4智能窗户关闭 5智能台灯
// 6智能桌子 7智能椅子 8智能风扇 9智能空调遥控器 10智能冰箱 11智能洗碗机
// 12智能电热水器 13温度传感器 14空气质量传感器 15光线传感器 16雨量传感器
//17闭门器
public enum DeviceTypeEnum {
GUO_BOX(0, "果box"),
ELECTRIC_SOCKET(1, "智能插座"),
BIG_LIGHT(2, "智能大灯"),
CURTAIN_DRIVE(3, "智能窗帘驱动"),
WINDOW_DRIVE(4, "智能窗户关闭"),
DESK_LAMP(5, "智能台灯"),
DESK(6, "智能桌子"),
SEAT(7, "智能椅子"),
ELECTRIC_FAN(8, "智能风扇"),
AIR_CONDITIONING_CONTROL(9, "智能空调(遥控器)"),
ICEBOX(10, "智能冰箱"),
DISHWASHER(11, "智能洗碗机"),
ELECTRIC_WATER(12, "智能电热水器"),
TEMPERATURE_SENSOR(13, "温度传感器"),
AIR_QUALITY_SENSOR(14, "空气质量传感器"),
LIGHT_SENSOR(15, "光线传感器"),
RAIN_SENSOR(16, "雨量传感器"),
DOOR_CLOSER(17, "闭门器"),
;
DeviceTypeEnum(Integer c, String n){
code = c;
name = n;
}
private Integer code;
private String name;
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
public DeviceTypeEnum getEnumWithCode(Integer c){
for (DeviceTypeEnum e:values()
) {
if(e.getCode().compareTo(c) == 0){
return e;
}
}
return null;
}
public DeviceTypeEnum getEnumWithName(String name){
for (DeviceTypeEnum e:values()
) {
if(e.getName().compareTo(name) == 0){
return e;
}
}
return null;
}
}

View File

@ -0,0 +1,13 @@
package com.qiuguo.iot.base.enums;
/*
* 是否删除
* 作者吴林
* */
// 0系统内置 1指定声音
public enum IsDeleteEnum {
NOT_DELETE,//未删除
DELETE,//删除
;
}

View File

@ -0,0 +1,44 @@
package com.qiuguo.iot.base.enums;
/*
* 设备运行场景类型
* 作者吴林
* */
// 0 无场景 1营销模式
public enum MarkModeEnum {
NONE(0, "无场景"),
MARKETING(1, "营销模式"),
;
MarkModeEnum(Integer c, String n){
code = c;
name = n;
}
private Integer code;
private String name;
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
public MarkModeEnum getEnumWithCode(Integer c){
for (MarkModeEnum e:values()
) {
if(e.getCode().compareTo(c) == 0){
return e;
}
}
return null;
}
public MarkModeEnum getEnumWithName(String name){
for (MarkModeEnum e:values()
) {
if(e.getName().compareTo(name) == 0){
return e;
}
}
return null;
}
}

View File

@ -0,0 +1,48 @@
package com.qiuguo.iot.base.enums;
/*
* 开放平台类型
* 作者吴林
* */
// 0 语言模型 1音乐 2 有声读物 3 天气 4 导航
public enum OpenTypeEnum {
LANGUAGE_MODEL(0, "大语言模型"),
MUSIC(1, "音乐"),
SOUND(2, "有声读物"),
WEATHER(3, "天气"),
NAVIGATION(4, "导航"),
;
OpenTypeEnum(Integer c, String n){
code = c;
name = n;
}
private Integer code;
private String name;
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
public OpenTypeEnum getEnumWithCode(Integer c){
for (OpenTypeEnum e:values()
) {
if(e.getCode().compareTo(c) == 0){
return e;
}
}
return null;
}
public OpenTypeEnum getEnumWithName(String name){
for (OpenTypeEnum e:values()
) {
if(e.getName().compareTo(name) == 0){
return e;
}
}
return null;
}
}

View File

@ -0,0 +1,45 @@
package com.qiuguo.iot.base.enums;
/*
* OTA模式类型
* 作者吴林
* */
// 0手动升级 1自动升级 2强制升级
public enum OtaModeEnum {
USER_CONTROL(0, "手动升级"),
AUTO(1, "自动"),
FORCE(2, "强制"),
;
OtaModeEnum(Integer c, String n){
code = c;
name = n;
}
private Integer code;
private String name;
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
public OtaModeEnum getEnumWithCode(Integer c){
for (OtaModeEnum e:values()
) {
if(e.getCode().compareTo(c) == 0){
return e;
}
}
return null;
}
public OtaModeEnum getEnumWithName(String name){
for (OtaModeEnum e:values()
) {
if(e.getName().compareTo(name) == 0){
return e;
}
}
return null;
}
}

View File

@ -0,0 +1,45 @@
package com.qiuguo.iot.base.enums;
/*
* 设备运行模式类型
* 作者吴林
* */
// 0 普通模式 1成人模式 2儿童模式
public enum RunModeEnum {
NORMAL(0, "普通模式"),
ADULT(1, "成人模式"),
CHILDREN(1, "儿童模式"),
;
RunModeEnum(Integer c, String n){
code = c;
name = n;
}
private Integer code;
private String name;
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
public RunModeEnum getEnumWithCode(Integer c){
for (RunModeEnum e:values()
) {
if(e.getCode().compareTo(c) == 0){
return e;
}
}
return null;
}
public RunModeEnum getEnumWithName(String name){
for (RunModeEnum e:values()
) {
if(e.getName().compareTo(name) == 0){
return e;
}
}
return null;
}
}

View File

@ -0,0 +1,45 @@
package com.qiuguo.iot.base.enums;
/*
* 声音类型
* 作者吴林
* */
// 0系统内置 1指定声音
public enum SoundTypeEnum {
INNER(0, "系统内置"),
APPOINT(1, "指定的"),
;
SoundTypeEnum(Integer c, String n){
code = c;
name = n;
}
private Integer code;
private String name;
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
public SoundTypeEnum getEnumWithCode(Integer c){
for (SoundTypeEnum e:values()
) {
if(e.getCode().compareTo(c) == 0){
return e;
}
}
return null;
}
public SoundTypeEnum getEnumWithName(String name){
for (SoundTypeEnum e:values()
) {
if(e.getName().compareTo(name) == 0){
return e;
}
}
return null;
}
}

View File

@ -0,0 +1,45 @@
package com.qiuguo.iot.base.enums;
/*
* 反馈意见类型类型
* 作者吴林
* */
// 0设备问题 1 技能服务 2 app问题
public enum SuggestionTypeEnum {
DEVICE(0, "手动升级"),
SKILL(1, "技能"),
APP(2, "强制"),
;
SuggestionTypeEnum(Integer c, String n){
code = c;
name = n;
}
private Integer code;
private String name;
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
public SuggestionTypeEnum getEnumWithCode(Integer c){
for (SuggestionTypeEnum e:values()
) {
if(e.getCode().compareTo(c) == 0){
return e;
}
}
return null;
}
public SuggestionTypeEnum getEnumWithName(String name){
for (SuggestionTypeEnum e:values()
) {
if(e.getName().compareTo(name) == 0){
return e;
}
}
return null;
}
}

View File

@ -0,0 +1,13 @@
package com.qiuguo.iot.base.enums;
/*
* 是否
* 作者吴林
* */
// 0 1
public enum YesNo {
NO,//未删除
YES,//删除
;
}

View File

@ -20,17 +20,6 @@
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!--跳过对项目中main方法的查找-->
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -35,9 +35,10 @@
<artifactId>jetty-util</artifactId>
<version>9.4.9.v20180320</version>
</dependency>
<dependency>
<groupId>com.qiuguo.iot</groupId>
<artifactId>iot-annotation</artifactId>
<artifactId>iot-base</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
@ -48,6 +49,13 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -2,6 +2,7 @@ package com.qiuguo.iot.box.websocket.handler;
import com.google.protobuf.InvalidProtocolBufferException;
import com.qiuguo.iot.base.annotation.WebSocketMapping;
import com.qiuguo.iot.base.enums.IsDeleteEnum;
import com.qiuguo.iot.box.websocket.cmd.UserInfo;
import com.qiuguo.iot.box.websocket.protobuf.MsgProtocol;
import com.qiuguo.iot.box.websocket.runner.FluxBatchRunner;
@ -32,7 +33,6 @@ public class BoxWebSocketHandler implements WebSocketHandler {
/**
* 所有websocket连接管理容器
**/
//CountDownLatch countDownLatch = new CountDownLatch(5);
FluxBatchRunner<MsgProtocol.Msg> batchRunner = new FluxBatchRunner<>(20, data -> {
log.info("begin:: thread={} 大小:{}", Thread.currentThread().getName(), data.size());
for (MsgProtocol.Msg msg:data
@ -43,6 +43,7 @@ public class BoxWebSocketHandler implements WebSocketHandler {
//info.sendData(msg);
}
}
//data.clear();
@ -110,74 +111,6 @@ public class BoxWebSocketHandler implements WebSocketHandler {
*/
return Mono.zip(input, output).then();
/*Flux<WebSocketMessage> output = session.receive()
.concatMap(mapper -> {
try {
log.info("concatMap");
MsgProtocol.Msg reqMsg = getMsg(mapper.getPayload());
MsgProtocol.User user1 = MsgProtocol.User.parseFrom(reqMsg.getData());
UserInfo userInfo = null;
Long id = user1.getUserId();
if(!group.containsKey(user1.getUserId())){
userInfo = new UserInfo(session, Flux.create(sink->{return sink;}, id));
userInfo.setUser(user1);
userInfo.setSession(session);
group.put(user1.getUserId(), userInfo);
}else{
userInfo = group.get(user1.getUserId());
}
if(reqMsg.getCmdId().getNumber() == MsgProtocol.Msg.CmdId.SEND_STATUS_REQ_VALUE){
MsgProtocol.Msg reqMsg1 = reqMsg.toBuilder().setCmdId(MsgProtocol.Msg.CmdId.SYNC_STATUS_RSP).build();
return Flux.just(reqMsg1);
}
} catch (InvalidProtocolBufferException e) {
throw new RuntimeException(e);
}
return Flux.empty();
}).map(value -> {
log.info("map");
CountDownLatch countDownLatch = new CountDownLatch(1);
FluxBatchRunner<UserInfo> batchRunner = new FluxBatchRunner<>(20, data -> {
log.info("begin:: thread={} 大小:{}", Thread.currentThread().getName(), data.size());
ByteBufAllocator allocator = new PooledByteBufAllocator();
DataBufferFactory factory = new NettyDataBufferFactory(allocator);
DataBuffer dataBuffer = factory.wrap(value.toByteArray());
//DataBuffer dataBuffer = factory.allocateBuffer();
WebSocketMessage webSocketMessage = new WebSocketMessage(WebSocketMessage.Type.BINARY, dataBuffer);
FluxProcessor<WebSocketMessage, WebSocketMessage> fluxProcessor = EmitterProcessor.<WebSocketMessage>create().serialize();
FluxSink messageSink = fluxProcessor.sink();
for (UserInfo info:data
) {
messageSink.next(info.getSession().binaryMessage(Flux.just(webSocketMessage)));
Mono<Void> outputClient = info.getSession().send(Flux.create(sink -> {
senderMap.put(info.getUser().getUserId(), new WebSocketSender(info.getSession(), sink));
}));
}
countDownLatch.countDown();
//System.out.printf("begin:: thread=%s; data=%s", Thread.currentThread().getName());
log.info("end:: thread={}", Thread.currentThread().getName());
//System.out.printf("end:: thread=%s; size=%s%n", Thread.currentThread().getName(), data.size());
});
//IntStream.range(0, 100).forEach(batchRunner::add);
group.values().forEach(batchRunner::add);
batchRunner.doFinal();
try {
countDownLatch.await();
}catch (Exception e){
}
//log.info("进来");
//group.forEach(batchRunner::add);
return session.textMessage("");
});
return session.send(output);*/
//return null;
}
public MsgProtocol.Msg getMsg(DataBuffer data) throws InvalidProtocolBufferException {

View File

@ -34,7 +34,8 @@ public class FluxBatchRunner<T> {
//Schedulers.elastic() //无限制的弹性线程池,可以一直创建线程
//Schedulers.boundedElastic() //有界的弹性线程池,它会回收闲置的线程默认是60s;它对创建的线程数做了限制默认值为CPU内核数x 10达到上限后最多可提交10万个任务
//Schedulers.fromExecutorService() 根据我们自定义线程池进行引用
scheduler = Schedulers.single();//可重用单个线程
//scheduler = Schedulers.single();//可重用单个线程
scheduler = Schedulers.newSingle("webSendBox");//新的可重用单个线程
records = new ArrayList<>(batchSize);
}
@ -82,7 +83,7 @@ public class FluxBatchRunner<T> {
//需要多线程执行必须使用parallel+runOn 如下
//Flux.just(records).parallel().runOn(scheduler).subscribe(data ->consumer.accept(data));
}
/*
public static void main(String[] args) {
try {
CountDownLatch countDownLatch = new CountDownLatch(5);
@ -103,7 +104,7 @@ public class FluxBatchRunner<T> {
}catch (Exception e){
}
}
}*/
}

View File

@ -52,16 +52,4 @@
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<configuration>
<locales>en,fr</locales>
</configuration>
</plugin>
</plugins>
</build>
</project>