Skip to content

Commit

Permalink
feat:influxdb and glm support
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanrongman committed Mar 5, 2024
1 parent b17ccb6 commit 1aa5ef0
Show file tree
Hide file tree
Showing 55 changed files with 2,161 additions and 141 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
architecture: x64

- name: Build with Maven
run: mvn clean install
run: mvn clean install -Dmaven.test.skip=true

- name: Run style checks
run: mvn spotless:check
Empty file added docs/.nojekyll
Empty file.
35 changes: 35 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# IntelliConnect

> 一个智慧的物联网平台.
## 概述
* 本项目基于springboot2.7开发,使用spring security作为安全框架
* 配备物模型和完善的监控模块
* 原生支持promptulate大模型框架(开发中)
* 支持多种iot协议,使用emqx exhook作为mqtt通讯,可扩展性强
* 支持微信小程序和微信服务号
* 使用常见的mysql和redis数据库,上手简单
* 支持时序数据库influxdb

## 安装运行
* 安装mysql和redis数据库,高性能运行推荐安装时序数据库influxdb
* 安装java17环境
* 修改配置文件application.yaml
* java -jar demo-0.0.1-SNAPSHOT.jar

## 项目特色
* 极简主义,层次分明,符合mvc分层结构
* 完善的物模型抽象,使得iot开发者可以专注于业务本身

## 交流群

欢迎加入群聊一起交流讨论有关Aiot相关的话题,链接过期了可以issue或email提醒一下作者。

<div style="width: 250px;margin: 0 auto;">
<img src="https://www.rslly.top/data/User/wonder/home/pictures/bf9be251bf2b7b3e2daabdc6055869d.jpg"/>
</div>


## 贡献

本人正在尝试一些更加完善的抽象模式,支持更多的物联网协议和数据存储形式,如果你有更好的建议,欢迎一起讨论交流。
46 changes: 46 additions & 0 deletions docs/_coverpage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!-- _coverpage.md -->

<style>
.title {
font-weight: bold;
font-size: 50px;
background-size: 400% 400%;
background-image: linear-gradient(to right, #ff0000, #ff8000, #d83b01, #000000, #00d0ff, #9000ff,#ff008c);
-webkit-background-clip: text;
animation: text-color-gradient 10s ease infinite;
color: transparent;
}
@keyframes text-color-gradient {
0%{background-position:0% 50%}
50%{background-position:100% 50%}
100%{background-position:0% 50%}
}
</style>


<div class="title">InteliConnect</div>

> A Powerful iot platform.

<p align="center">
<a target="_blank" href="">
<img src="https://img.shields.io/badge/license-apache2.0-yellow?style=flat-square"/>
</a>
<a target="_blank" href=''>
<img src="https://img.shields.io/badge/release-v0.1-blue?style=flat-square"/>
</a>
<a target="_blank" href="">
<img src="https://img.shields.io/badge/cwl-project1.8-green?style=flat-square&link=https://wordpress.rslly.top"/>
</a>
</p>


<p align="center">
<img src="images/logo.png">
</p>



[GitHub](https://github.com/ruanrongman/IntelliConnect.git)
[Getting Started](/README.md)
Binary file added docs/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="Description">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css">
</head>
<nav>
<a href="#/">文档 v1.8</a>
<a href="#/">示例</a>
</nav>
<body>
<div id="app"></div>
<script>
window.$docsify = {
name: 'IntelliConnect',
repo: 'https://github.com/ruanrongman/IntelliConnect.git',
loadNavbar: true,
loadSidebar: true,
subMaxLevel: 3,
coverpage: true,
}
</script>
<!-- Docsify v4 -->
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
</body>
</html>
20 changes: 18 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
<version>5.1.49</version>
<scope>runtime</scope>
</dependency>
<!--influxdb依赖-->
<dependency>
<groupId>org.influxdb</groupId>
<artifactId>influxdb-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
Expand Down Expand Up @@ -57,11 +62,11 @@
<version>1.1.23</version>
</dependency>
<!--okhttp3-->
<dependency>
<!--dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.6.0</version>
</dependency>
</dependency-->
<!--swagger3 依赖-->
<dependency>
<groupId>io.springfox</groupId>
Expand All @@ -79,6 +84,12 @@
<artifactId>fastjson</artifactId>
<version>1.2.83</version>
</dependency>
<!--工具类-->
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutz</artifactId>
<version>1.r.66</version>
</dependency>
<!-- jjwt -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
Expand Down Expand Up @@ -151,6 +162,11 @@
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cn.bigmodel.openapi</groupId>
<artifactId>oapi-java-sdk</artifactId>
<version>release-V4-2.0.0</version>
</dependency>
</dependencies>

<build>
Expand Down
15 changes: 10 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,21 @@
</a>
</p>

<p align="center">
<img src="https://www.rslly.top/data/User/wonder/home/pictures/logo.png"/>
</p>

## 概述
* 本项目基于springboot2.7开发,使用spring security作为安全框架
* 配备物模型和完善的监控模块
* 原生支持promptulate大模型框架
* 原生支持promptulate大模型框架(开发中)
* 支持多种iot协议,使用emqx exhook作为mqtt通讯,可扩展性强
* 支持微信小程序和微信服务号
* 使用常见的mysql和redis数据库,上手简单
* 支持时序数据库influxdb

## 安装运行
* 安装mysql和redis数据库
* 安装mysql和redis数据库,高性能运行推荐安装时序数据库influxdb
* 安装java17环境
* 修改配置文件application.yaml
* java -jar demo-0.0.1-SNAPSHOT.jar
Expand All @@ -34,13 +39,13 @@

## 交流群

欢迎加入群聊一起交流讨论有关aiot相关的话题,链接过期了可以issue或email提醒一下作者。
欢迎加入群聊一起交流讨论有关Aiot相关的话题,链接过期了可以issue或email提醒一下作者。

<div style="width: 250px;margin: 0 auto;">
<img src="https://zeeland-bucket.oss-cn-beijing.aliyuncs.com/images/20240123213645.png"/>
<img src="https://www.rslly.top/data/User/wonder/home/pictures/bf9be251bf2b7b3e2daabdc6055869d.jpg"/>
</div>


## 贡献

本人正在尝试一些更加完善的抽象模式,以更好地兼容该框架,以及外部工具的扩展使用,如果你有更好的建议,欢迎一起讨论交流。
本人正在尝试一些更加完善的抽象模式,支持更多的物联网协议和数据存储形式,如果你有更好的建议,欢迎一起讨论交流。
17 changes: 16 additions & 1 deletion src/main/java/top/rslly/iot/controllers/Tool.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@
import io.swagger.v3.oas.annotations.Operation;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import top.rslly.iot.param.request.ControlParam;
import top.rslly.iot.param.request.ReadData;
import top.rslly.iot.services.DataServiceImpl;
import top.rslly.iot.services.HardWareServiceImpl;
import top.rslly.iot.utility.RedisUtil;
import top.rslly.iot.utility.RuntimeMessage;
import top.rslly.iot.utility.ai.tools.ControlTool;
import top.rslly.iot.utility.result.JsonResult;
import top.rslly.iot.utility.result.ResultTool;

Expand All @@ -41,6 +45,8 @@ public class Tool {
private DataServiceImpl dataService;
@Autowired
private HardWareServiceImpl hardWareService;
@Autowired
private ControlTool controlTool;

@Operation(summary = "用于获取平台运行环境信息", description = "单位为百分比")
@RequestMapping(value = "/machineMessage", method = RequestMethod.GET)
Expand All @@ -60,4 +66,13 @@ public JsonResult<?> readData(@RequestBody ReadData readData) {
return dataService.findAllByTimeBetweenAndDeviceName(readData.getTime1(), readData.getTime2(),
readData.getName());
}

@Operation(summary = "使用大模型控制设备", description = "响应速度取决于大模型速度")
@RequestMapping(value = "/aiControl", method = RequestMethod.POST)
public JsonResult<?> aiControl(@RequestBody String content) {
//Glm glm = new Glm();
//glm.jsonChat(content);
var answer=controlTool.run(content);
return ResultTool.success(answer);
}
}
23 changes: 13 additions & 10 deletions src/main/java/top/rslly/iot/dao/DataRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.data.repository.query.QueryByExampleExecutor;
import org.springframework.transaction.annotation.Transactional;
import top.rslly.iot.models.DataEntity;
Expand All @@ -40,15 +38,20 @@ List<DataEntity> findAllByTimeBetweenAndDeviceIdAndJsonKey(long time, long time2

List<DataEntity> findAllByTimeBetweenAndDeviceId(long time, long time2, int deviceId);

@Query(value = "SELECT * FROM data WHERE device_id =?1 ORDER BY time DESC LIMIT 1",
@Query(value = "SELECT * FROM data WHERE device_id =?1 And jsonkey=?2 ORDER BY time DESC LIMIT 1",
nativeQuery = true)
List<DataEntity> findAllBySort(int deviceId);
List<DataEntity> findAllBySort(int deviceId, String jsonKey);

@Transactional
List<DataEntity> deleteById(int id);

@Transactional
@Modifying
@Query(value = "DELETE from data WHERE id IN ?1", nativeQuery = true)
void deleteByList(List<Integer> idList);
List<DataEntity> deleteAllByTimeBeforeAndDeviceIdAndJsonKey(long time, int deviceId, String jsonKey);
/*
* @Transactional List<DataEntity> deleteById(int id);
*
* @Transactional
*
* @Modifying
*
* @Query(value = "DELETE from data WHERE id IN ?1", nativeQuery = true) void
* deleteByList(List<Integer> idList);
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public interface ProductModelRepository extends JpaRepository<ProductModelEntity, Long> {
List<ProductModelEntity> findAllByProductId(int productId);

List<ProductModelEntity> findAllByType(String type);
List<ProductModelEntity> findAllByName(String name);

List<ProductModelEntity> findAllById(int id);

Expand Down
50 changes: 50 additions & 0 deletions src/main/java/top/rslly/iot/dao/TimeDataRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* Copyright © 2023-2030 The ruanrongman Authors
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 top.rslly.iot.dao;

import top.rslly.iot.models.DataEntity;
import top.rslly.iot.utility.influxdb.InfluxDBBaseMapper;
import top.rslly.iot.utility.influxdb.ano.Delete;
import top.rslly.iot.utility.influxdb.ano.Param;
import top.rslly.iot.utility.influxdb.ano.Select;

import java.util.List;

public interface TimeDataRepository extends InfluxDBBaseMapper<DataEntity> {
@Select(value = "SELECT * FROM \"data\" where time >=#{time1}ms and time <=#{time2}ms",
resultType = DataEntity.class)
List<DataEntity> findAllByTimeBetween(@Param("time1") Long time1, @Param("time2") Long time2);

@Select(
value = "SELECT * FROM \"data\" where time >=#{time}ms and time <=#{time2}ms and deviceId='#{deviceId}'",
resultType = DataEntity.class)
List<DataEntity> findAllByTimeBetweenAndDeviceId(@Param("time") long time,
@Param("time2") long time2, @Param("deviceId") int deviceId);

@Select(
value = "SELECT * FROM \"data\" where time >=#{time}ms and time <=#{time2}ms and deviceId='#{deviceId}' and jsonKey=#{jsonKey}",
resultType = DataEntity.class)
List<DataEntity> findAllByTimeBetweenAndDeviceIdAndJsonKey(@Param("time") long time,
@Param("time2") long time2, @Param("deviceId") int deviceId,
@Param("jsonKey") String jsonKey);
@Delete(value = "DELETE FROM \"data\" where time <=#{time}ms and deviceId='#{deviceId}' and jsonKey=#{jsonKey}")
void deleteAllByTimeBeforeAndDeviceIdAndJsonKey(long time, int deviceId,
String jsonKey);
}
Loading

0 comments on commit 1aa5ef0

Please sign in to comment.