initial
This commit is contained in:
10
.idea/.gitignore
generated
vendored
Normal file
10
.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# Ĭ<>Ϻ<EFBFBD><CFBA>Ե<EFBFBD><D4B5>ļ<EFBFBD>
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# <20><><EFBFBD>ڱ༭<DAB1><E0BCAD><EFBFBD><EFBFBD> HTTP <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
/httpRequests/
|
||||||
|
# <20><><EFBFBD><EFBFBD><EFBFBD>ڻ<EFBFBD><DABB><EFBFBD><EFBFBD><EFBFBD> Maven <20><>Ŀ¼·<C2BC><C2B7>
|
||||||
|
/mavenHomeManager.xml
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
14
.idea/misc.xml
generated
Normal file
14
.idea/misc.xml
generated
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="MavenProjectsManager">
|
||||||
|
<option name="originalFiles">
|
||||||
|
<list>
|
||||||
|
<option value="$PROJECT_DIR$/pom.xml" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="liberica-1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
9
.idea/sipaiis_datacollector.iml
generated
Normal file
9
.idea/sipaiis_datacollector.iml
generated
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
55
.trae/documents/在GIS_Job中加入和达流量计计算点位推送.md
Normal file
55
.trae/documents/在GIS_Job中加入和达流量计计算点位推送.md
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
## 变更目标
|
||||||
|
|
||||||
|
* 在 `com.sipai.schedule.GIS_Job.jobGIS` 的 SQL WHERE 过滤中,加入 6 个新计算点位的精确匹配,使其随既有点位一起下发到管网平台。
|
||||||
|
|
||||||
|
* 新增点位:`KCGW_53564_A8`、`KCGW_53564_A7`、`KCGW_53564_P1`、`KCGW_53581_A8`、`KCGW_53581_A7`、`KCGW_53581_P1`。
|
||||||
|
|
||||||
|
## 代码位置
|
||||||
|
|
||||||
|
* 文件:`src/main/java/com/sipai/schedule/GIS_Job.java`
|
||||||
|
|
||||||
|
* 方法:`jobGIS`
|
||||||
|
|
||||||
|
* 现有 SQL 拼接区间:`GIS_Job.java:427-436`
|
||||||
|
|
||||||
|
## 具体改动
|
||||||
|
|
||||||
|
* 在现有两条和达设备前缀过滤之后、分号之前,按既有格式追加以下条件:
|
||||||
|
|
||||||
|
```
|
||||||
|
" OR id = 'KCGW_53564_A8'\n" +
|
||||||
|
" OR id = 'KCGW_53564_A7'\n" +
|
||||||
|
" OR id = 'KCGW_53564_P1'\n" +
|
||||||
|
" OR id = 'KCGW_53581_A8'\n" +
|
||||||
|
" OR id = 'KCGW_53581_A7'\n" +
|
||||||
|
" OR id = 'KCGW_53581_P1'\n" +
|
||||||
|
```
|
||||||
|
|
||||||
|
* 保持原有 `LIKE 'KCGW_22008_53564_%'` 与 `LIKE 'KCGW_22029_53581_%'` 不变,避免影响既有轮询点位推送。
|
||||||
|
|
||||||
|
## 实现步骤
|
||||||
|
|
||||||
|
* 编辑 `sql` 字符串,追加上述 6 行 `OR id = '...'` 条件,保留末尾分号。
|
||||||
|
|
||||||
|
* 不改动其他逻辑(查询、组装 JSON、MQTT 发送)。
|
||||||
|
|
||||||
|
## 校验与验证
|
||||||
|
|
||||||
|
* 在本地运行 `jobGIS` 定时任务或手动触发同路径查询,确认 `mPointService.selectListByWhere(sql)` 返回集合包含新增 6 点位(可在日志或调试中检视)。
|
||||||
|
|
||||||
|
* 观察 MQTT 推送内容(主题 `CommString.Mqtt_Topic_DATA`)是否包含对应 `mpcode` 与最新值/时间。
|
||||||
|
|
||||||
|
* 关注日志输出与异常堆栈,确保无 SQL 拼接格式错误。
|
||||||
|
|
||||||
|
## 兼容性与命名一致性
|
||||||
|
|
||||||
|
* 新增 ID 与 `HD_Job` 中计算点位编码一致:`KCGW_<meterId>_<A8/A7/P1>`。
|
||||||
|
|
||||||
|
* 不影响既有 `SignalTag`、`P1_DAY/HOUR`、`KCGW_15001_A1_*` 等过滤。
|
||||||
|
|
||||||
|
## 风险与回退
|
||||||
|
|
||||||
|
* 若后续计算点位命名规范调整,需同步更新此处精确匹配。
|
||||||
|
|
||||||
|
* 若管网平台不需要这 6 个点位,可直接移除新增的 `OR id = '...'` 条件回退。
|
||||||
|
|
||||||
92
README.md
Normal file
92
README.md
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
# SIPAIIS_DataCollector
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Getting started
|
||||||
|
|
||||||
|
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
||||||
|
|
||||||
|
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
||||||
|
|
||||||
|
## Add your files
|
||||||
|
|
||||||
|
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
||||||
|
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
||||||
|
|
||||||
|
```
|
||||||
|
cd existing_repo
|
||||||
|
git remote add origin http://localhost/backend/sipaiis_datacollector.git
|
||||||
|
git branch -M main
|
||||||
|
git push -uf origin main
|
||||||
|
```
|
||||||
|
|
||||||
|
## Integrate with your tools
|
||||||
|
|
||||||
|
- [ ] [Set up project integrations](http://localhost/backend/sipaiis_datacollector/-/settings/integrations)
|
||||||
|
|
||||||
|
## Collaborate with your team
|
||||||
|
|
||||||
|
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
||||||
|
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
||||||
|
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
||||||
|
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
||||||
|
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
||||||
|
|
||||||
|
## Test and Deploy
|
||||||
|
|
||||||
|
Use the built-in continuous integration in GitLab.
|
||||||
|
|
||||||
|
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
||||||
|
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
||||||
|
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
||||||
|
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
||||||
|
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
# Editing this README
|
||||||
|
|
||||||
|
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
||||||
|
|
||||||
|
## Suggestions for a good README
|
||||||
|
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
||||||
|
|
||||||
|
## Name
|
||||||
|
Choose a self-explaining name for your project.
|
||||||
|
|
||||||
|
## Description
|
||||||
|
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
||||||
|
|
||||||
|
## Badges
|
||||||
|
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
||||||
|
|
||||||
|
## Visuals
|
||||||
|
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
||||||
|
|
||||||
|
## Support
|
||||||
|
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
||||||
|
|
||||||
|
## Roadmap
|
||||||
|
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
State if you are open to contributions and what your requirements are for accepting them.
|
||||||
|
|
||||||
|
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
||||||
|
|
||||||
|
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
||||||
|
|
||||||
|
## Authors and acknowledgment
|
||||||
|
Show your appreciation to those who have contributed to the project.
|
||||||
|
|
||||||
|
## License
|
||||||
|
For open source projects, say how it is licensed.
|
||||||
|
|
||||||
|
## Project status
|
||||||
|
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
||||||
284
pom.xml
Normal file
284
pom.xml
Normal file
@ -0,0 +1,284 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.2.0.RELEASE</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
<groupId>com.sipai</groupId>
|
||||||
|
<artifactId>springboot</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>springboot</name>
|
||||||
|
<description>Demo project for Spring Boot</description>
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<netty.version>4.1.86.Final</netty.version>
|
||||||
|
<spring-kafka.version>2.3.7.RELEASE</spring-kafka.version> <!-- 兼容Spring Boot 2.2.0的版本 -->
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>logback-core</artifactId>
|
||||||
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>logback-classic</artifactId>
|
||||||
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>spring-boot-starter-logging</artifactId>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>log4j-to-slf4j</artifactId>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- mybatis generator-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.generator</groupId>
|
||||||
|
<artifactId>mybatis-generator-core</artifactId>
|
||||||
|
<version>1.3.5</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
<version>2.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>druid-spring-boot-starter</artifactId>
|
||||||
|
<version>1.1.10</version>
|
||||||
|
</dependency>
|
||||||
|
<!--sqlserver-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.microsoft.sqlserver</groupId>
|
||||||
|
<artifactId>mssql-jdbc</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<!--mysql驱动-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<version>8.0.11</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.paho</groupId>
|
||||||
|
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||||
|
<version>1.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.fasterxml.uuid/java-uuid-generator -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.uuid</groupId>
|
||||||
|
<artifactId>java-uuid-generator</artifactId>
|
||||||
|
<version>4.0.1</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>1.2.75</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.aspectj</groupId>
|
||||||
|
<artifactId>aspectjweaver</artifactId>
|
||||||
|
<version>1.9.4</version>
|
||||||
|
</dependency>
|
||||||
|
<!--jdbc-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-jdbc</artifactId>
|
||||||
|
<!-- 移除不兼容的版本声明 -->
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
<version>2.8.5</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- 热部署 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>springloaded</artifactId>
|
||||||
|
<version>1.2.8.RELEASE</version>
|
||||||
|
</dependency>
|
||||||
|
<!--rabbitmq-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- 引入swagger -->
|
||||||
|
<!--springfox的核心jar包 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
|
<version>2.9.2</version>
|
||||||
|
</dependency>
|
||||||
|
<!--springfox-ui的jar包(里面包含了swagger的界面静态文件) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
|
<version>2.9.2</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-collections4 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-collections4</artifactId>
|
||||||
|
<version>4.4</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--redis-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
<!-- 移除不兼容的版本声明 -->
|
||||||
|
</dependency>
|
||||||
|
<!--redisson-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.redisson</groupId>
|
||||||
|
<artifactId>redisson</artifactId>
|
||||||
|
<version>3.13.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.netty</groupId>
|
||||||
|
<artifactId>netty-all</artifactId>
|
||||||
|
<version>${netty.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- OPC UA Milo SDK -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.milo</groupId>
|
||||||
|
<artifactId>sdk-client</artifactId>
|
||||||
|
<version>0.6.10</version> <!-- 或 0.6.10 -->
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<!-- 添加 stack-core 依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.milo</groupId>
|
||||||
|
<artifactId>stack-core</artifactId>
|
||||||
|
<version>0.6.10</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 添加新版本 Guava -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<version>31.1-jre</version> <!-- 或更高版本 -->
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Spring Boot Starter for Kafka -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.kafka</groupId>
|
||||||
|
<artifactId>spring-kafka</artifactId>
|
||||||
|
<version>${spring-kafka.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--用于本地缓存-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.ben-manes.caffeine</groupId>
|
||||||
|
<artifactId>caffeine</artifactId>
|
||||||
|
<version>2.9.3</version> <!-- 最后一个支持Java 8的版本 -->
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.pagehelper</groupId>
|
||||||
|
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||||
|
<version>1.4.6</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 引入log4j2依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Maven -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpclient</artifactId>
|
||||||
|
<version>4.5.13</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpmime</artifactId>
|
||||||
|
<version>4.5.13</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<mainClass>com.sipai.DataApplication</mainClass>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<!--mybatis.generator-->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.mybatis.generator</groupId>
|
||||||
|
<artifactId>mybatis-generator-maven-plugin</artifactId>
|
||||||
|
<version>1.3.2</version>
|
||||||
|
<configuration>
|
||||||
|
<configurationFile>${basedir}/src/main/resources/generatior-config.xml</configurationFile>
|
||||||
|
<verbose>true</verbose>
|
||||||
|
<overwrite>true</overwrite>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/webapp</directory>
|
||||||
|
<targetPath>META-INF/resources</targetPath>
|
||||||
|
<includes>
|
||||||
|
<include>**/**</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<includes>
|
||||||
|
<include>**/**</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
47
src/main/java/com/sipai/DataApplication.java
Normal file
47
src/main/java/com/sipai/DataApplication.java
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
package com.sipai;
|
||||||
|
|
||||||
|
import com.sipai.tools.DataSourceAspect;
|
||||||
|
import com.sipai.tools.DataSourceContextHolder;
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration;
|
||||||
|
import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration;
|
||||||
|
import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration;
|
||||||
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
|
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||||
|
import org.springframework.context.annotation.ImportResource;
|
||||||
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
|
//@SpringBootApplication
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @SpringBootApplication 为
|
||||||
|
* @Configuration、@EnableAutoConfiguration、@ComponentScan 三个注解的组合
|
||||||
|
*/
|
||||||
|
|
||||||
|
@SpringBootApplication(exclude = {
|
||||||
|
DataSourceAutoConfiguration.class
|
||||||
|
})
|
||||||
|
@EnableTransactionManagement //开启事务功能
|
||||||
|
@EnableAsync//开启异步
|
||||||
|
@EnableScheduling
|
||||||
|
@MapperScan("src/main/resources/mybatis/mapper")
|
||||||
|
//@PropertySource("classpath:application-pro.yml")//yml里面指定pro失效,只能在这强制指定
|
||||||
|
public class DataApplication {
|
||||||
|
|
||||||
|
static{
|
||||||
|
System.setProperty("es.set.netty.runtime.available.processors", "false");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication app = new SpringApplication(DataApplication.class);
|
||||||
|
app.setAllowBeanDefinitionOverriding(false); // 检查是否有此设置
|
||||||
|
app.run(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
18
src/main/java/com/sipai/config/AppConfig.java
Normal file
18
src/main/java/com/sipai/config/AppConfig.java
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package com.sipai.config;
|
||||||
|
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@ConfigurationProperties(prefix = "app")
|
||||||
|
public class AppConfig {
|
||||||
|
private int maxPoints;
|
||||||
|
|
||||||
|
public int getMaxPoints() {
|
||||||
|
return maxPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxPoints(int maxPoints) {
|
||||||
|
this.maxPoints = maxPoints;
|
||||||
|
}
|
||||||
|
}
|
||||||
38
src/main/java/com/sipai/config/MockOpcUaClient.java
Normal file
38
src/main/java/com/sipai/config/MockOpcUaClient.java
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package com.sipai.config;
|
||||||
|
|
||||||
|
import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
|
||||||
|
import org.eclipse.milo.opcua.sdk.client.api.config.OpcUaClientConfig;
|
||||||
|
import org.eclipse.milo.opcua.stack.client.UaStackClient;
|
||||||
|
import org.eclipse.milo.opcua.stack.core.types.builtin.*;
|
||||||
|
import org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
public class MockOpcUaClient extends OpcUaClient {
|
||||||
|
public MockOpcUaClient(OpcUaClientConfig config) throws Exception {
|
||||||
|
super(config, (UaStackClient) Executors.newSingleThreadExecutor()); // 提供所有必需的参数
|
||||||
|
}
|
||||||
|
|
||||||
|
private static OpcUaClientConfig createMockConfig() {
|
||||||
|
return OpcUaClientConfig.builder()
|
||||||
|
.setEndpoint(null) // 模拟端点
|
||||||
|
.setApplicationName(LocalizedText.english("Mock OPC UA Client"))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MockOpcUaClient createMockClient() throws Exception {
|
||||||
|
return new MockOpcUaClient(createMockConfig());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<DataValue> readValue(double timeout, TimestampsToReturn timestamps, NodeId nodeId) {
|
||||||
|
DataValue dataValue = new DataValue(
|
||||||
|
new Variant(0), // 模拟值
|
||||||
|
StatusCode.GOOD,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
return CompletableFuture.completedFuture(dataValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
76
src/main/java/com/sipai/config/OpcUaConfig.java
Normal file
76
src/main/java/com/sipai/config/OpcUaConfig.java
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
package com.sipai.config;
|
||||||
|
|
||||||
|
import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
|
||||||
|
import org.eclipse.milo.opcua.sdk.client.api.config.OpcUaClientConfig;
|
||||||
|
import org.eclipse.milo.opcua.sdk.client.api.identity.AnonymousProvider;
|
||||||
|
import org.eclipse.milo.opcua.sdk.client.api.identity.IdentityProvider;
|
||||||
|
import org.eclipse.milo.opcua.sdk.client.api.identity.UsernameProvider;
|
||||||
|
import org.eclipse.milo.opcua.stack.client.DiscoveryClient;
|
||||||
|
import org.eclipse.milo.opcua.stack.core.security.SecurityPolicy;
|
||||||
|
import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger;
|
||||||
|
import org.eclipse.milo.opcua.stack.core.types.structured.EndpointDescription;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class OpcUaConfig {
|
||||||
|
@Autowired
|
||||||
|
private OpcUaProperties properties;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnProperty(prefix = "opcua", name = "enabled", havingValue = "true")
|
||||||
|
public OpcUaClient opcUaClient() throws Exception {
|
||||||
|
return createClient(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@Bean
|
||||||
|
public OpcUaClient opcUaClient(OpcUaProperties properties) throws Exception {
|
||||||
|
if (!properties.isEnabled()) {
|
||||||
|
// 如果 OPC UA 功能未启用,返回 null 或抛出自定义异常
|
||||||
|
return null; // 或者抛出一个自定义异常
|
||||||
|
}
|
||||||
|
return createClient(properties);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
private OpcUaClient createClient(OpcUaProperties properties) throws Exception {
|
||||||
|
// 1. 发现端点
|
||||||
|
List<EndpointDescription> endpoints = DiscoveryClient
|
||||||
|
.getEndpoints(properties.getServerUrl())
|
||||||
|
.get();
|
||||||
|
|
||||||
|
// 2. 根据配置选择端点
|
||||||
|
EndpointDescription endpoint = endpoints.stream()
|
||||||
|
.filter(e -> e.getSecurityPolicyUri().equals(SecurityPolicy.None.getUri()))
|
||||||
|
.findFirst()
|
||||||
|
.orElseThrow(() -> new Exception("未找到匿名访问端点"));
|
||||||
|
|
||||||
|
// 3. 创建身份认证提供者
|
||||||
|
IdentityProvider identityProvider;
|
||||||
|
if (properties.getUsername() != null && !properties.getUsername().isEmpty()) {
|
||||||
|
// 使用用户名/密码认证
|
||||||
|
identityProvider = new UsernameProvider(
|
||||||
|
properties.getUsername(),
|
||||||
|
properties.getPassword()
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// 使用匿名认证
|
||||||
|
identityProvider = new AnonymousProvider();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 创建客户端配置
|
||||||
|
OpcUaClientConfig config = OpcUaClientConfig.builder()
|
||||||
|
.setEndpoint(endpoint)
|
||||||
|
.setRequestTimeout(UInteger.valueOf(5000))
|
||||||
|
.setIdentityProvider(identityProvider)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// 5. 创建并连接客户端
|
||||||
|
OpcUaClient client = OpcUaClient.create(config);
|
||||||
|
client.connect().get();
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
}
|
||||||
66
src/main/java/com/sipai/config/OpcUaProperties.java
Normal file
66
src/main/java/com/sipai/config/OpcUaProperties.java
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
package com.sipai.config;
|
||||||
|
|
||||||
|
import org.eclipse.milo.opcua.stack.core.security.SecurityPolicy;
|
||||||
|
import org.eclipse.milo.opcua.stack.core.types.enumerated.MessageSecurityMode;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@ConfigurationProperties(prefix = "opcua")
|
||||||
|
public class OpcUaProperties {
|
||||||
|
private String serverUrl;
|
||||||
|
private SecurityPolicy securityPolicy = SecurityPolicy.None;
|
||||||
|
private MessageSecurityMode securityMode = MessageSecurityMode.None;
|
||||||
|
private String username;
|
||||||
|
private String password;
|
||||||
|
private boolean enabled = false;//是否启用opc客户端
|
||||||
|
|
||||||
|
// Getters and Setters
|
||||||
|
public String getServerUrl() {
|
||||||
|
return serverUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServerUrl(String serverUrl) {
|
||||||
|
this.serverUrl = serverUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SecurityPolicy getSecurityPolicy() {
|
||||||
|
return securityPolicy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSecurityPolicy(SecurityPolicy securityPolicy) {
|
||||||
|
this.securityPolicy = securityPolicy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageSecurityMode getSecurityMode() {
|
||||||
|
return securityMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSecurityMode(MessageSecurityMode securityMode) {
|
||||||
|
this.securityMode = securityMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
75
src/main/java/com/sipai/config/RedissonConfig.java
Normal file
75
src/main/java/com/sipai/config/RedissonConfig.java
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
package com.sipai.config;
|
||||||
|
|
||||||
|
|
||||||
|
import org.redisson.Redisson;
|
||||||
|
import org.redisson.api.RedissonClient;
|
||||||
|
import org.redisson.client.codec.Codec;
|
||||||
|
import org.redisson.codec.JsonJacksonCodec;
|
||||||
|
import org.redisson.config.Config;
|
||||||
|
import org.redisson.config.SingleServerConfig;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author : YYJ
|
||||||
|
* @CreateTime : 2021/9/13
|
||||||
|
* @Description :
|
||||||
|
**/
|
||||||
|
@Configuration
|
||||||
|
public class RedissonConfig {
|
||||||
|
private static String MODE_SINGLE = "single";
|
||||||
|
private static String MODE_CLUSTER = "cluster";
|
||||||
|
@Value("${spring.redis.mode}")
|
||||||
|
public String mode;
|
||||||
|
|
||||||
|
@Value("${spring.redis.cluster.nodes}")
|
||||||
|
public String cluster;
|
||||||
|
|
||||||
|
@Value("${spring.redis.password}")
|
||||||
|
public String password;
|
||||||
|
|
||||||
|
@Value("${spring.redis.host}")
|
||||||
|
public String host;
|
||||||
|
|
||||||
|
@Value("${spring.redis.port}")
|
||||||
|
public String port;
|
||||||
|
|
||||||
|
@Value("${spring.redis.timeout}")
|
||||||
|
public Integer timeout;
|
||||||
|
|
||||||
|
// @Value("${redis.database}")
|
||||||
|
// public String database;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RedissonClient redissonClient(){
|
||||||
|
RedissonClient redisson = null;
|
||||||
|
Config conf = new Config();
|
||||||
|
|
||||||
|
if(MODE_SINGLE.equals(mode)) {//单机
|
||||||
|
//单节点模式
|
||||||
|
SingleServerConfig singleServerConfig = conf.useSingleServer();
|
||||||
|
//设置连接地址:redis://127.0.0.1:6379
|
||||||
|
singleServerConfig.setAddress("redis://" + host + ":" + port);
|
||||||
|
//设置连接密码
|
||||||
|
singleServerConfig.setPassword(password);
|
||||||
|
// singleServerConfig.setDatabase(Integer.valueOf(database));
|
||||||
|
}else if(MODE_CLUSTER.equals(mode)){//集群
|
||||||
|
String[] nodes = cluster.split(",");
|
||||||
|
for (int i = 0; i < nodes.length; i++) {
|
||||||
|
nodes[i] = "redis://" + nodes[i];
|
||||||
|
}
|
||||||
|
conf.useClusterServers()
|
||||||
|
.setScanInterval(2000)
|
||||||
|
.addNodeAddress(nodes)
|
||||||
|
.setTimeout(timeout)
|
||||||
|
.setPassword(password);
|
||||||
|
}
|
||||||
|
|
||||||
|
//使用json序列化方式
|
||||||
|
Codec codec = new JsonJacksonCodec();
|
||||||
|
conf.setCodec(codec);
|
||||||
|
redisson = Redisson.create(conf);
|
||||||
|
return redisson;
|
||||||
|
}
|
||||||
|
}
|
||||||
20
src/main/java/com/sipai/config/StartupLogger.java
Normal file
20
src/main/java/com/sipai/config/StartupLogger.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package com.sipai.config;
|
||||||
|
|
||||||
|
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||||
|
import org.springframework.context.event.EventListener;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class StartupLogger {
|
||||||
|
|
||||||
|
@EventListener(ApplicationReadyEvent.class)
|
||||||
|
public void onStartup() throws UnknownHostException {
|
||||||
|
String ip = InetAddress.getLocalHost().getHostAddress();
|
||||||
|
String port = System.getProperty("server.port");//bat脚本传过来的端口
|
||||||
|
String url = ip + ":" + port;
|
||||||
|
System.out.println("Spring Boot 服务已启动完成!" + (url != null ? "开发环境" : url));
|
||||||
|
}
|
||||||
|
}
|
||||||
80
src/main/java/com/sipai/config/UDPClient.java
Normal file
80
src/main/java/com/sipai/config/UDPClient.java
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
package com.sipai.config;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.DatagramPacket;
|
||||||
|
import java.net.DatagramSocket;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于测试 - 南昌项目
|
||||||
|
* sj 2025-05-21
|
||||||
|
*/
|
||||||
|
public class UDPClient {
|
||||||
|
|
||||||
|
// @Value("${udp.server.port}")
|
||||||
|
// private static int serverPort;
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
// 管网监测设备采集
|
||||||
|
// 192.168.10.18:5006
|
||||||
|
// 223.84.61.83:5006
|
||||||
|
|
||||||
|
// String serverHost = "116.236.176.248";
|
||||||
|
// String serverHost = "127.0.0.1";
|
||||||
|
String serverHost = "223.84.61.83";
|
||||||
|
int serverPort = 5006;
|
||||||
|
|
||||||
|
//智能井盖
|
||||||
|
String hexString = "AB CD 00 4D 2A FB 25 07 20 12 00 01 A0 01 68 00 02 08 48 4B 33 35 2D 49 49 3B 56 31 2E 31 3B 56 31 2E 30 2E 30 36 00 00 00 00 00 00 00 00 04 01 C2 D2 00 00 04 02 40 E0 00 00 04 03 3F EC 7D AF 04 04 47 C3 50 00 04 05 47 C3 50 00 05 01 00 00 D3 0D 0A";
|
||||||
|
//流量计
|
||||||
|
// String hexString = "AB CD 00 71 56 03 25 07 08 09 15 01 0F 02 D8 00 FD 12 48 38 36 45 3B 31 2E 33 3B 31 2E 30 2E 33 35 20 20 20 20 20 00 00 00 00 00 00 00 00 01 01 DC 02 00 00 25 A8 00 00 01 02 00 00 00 00 03 00 00 00 01 03 DC 02 00 00 22 A8 00 00 04 01 3C A3 D7 0A 04 02 3D A3 D7 0A 04 03 41 A0 00 00 04 04 41 C4 7A E1 04 07 41 2C CC CD 04 08 3E 45 A1 CB 05 01 00 00 A2 0D 0A";
|
||||||
|
//液位计
|
||||||
|
// String hexString = "AB CD 00 B7 59 F7 25 07 08 09 05 03 05 01 6D 00 C0 06 48 4B 31 39 52 3B 33 2E 31 3B 31 2E 30 2E 30 30 00 00 00 00 00 00 00 00 00 00 00 00 04 01 42 E0 00 00 42 E0 00 00 42 E0 00 00 04 02 40 00 00 00 40 00 00 00 40 00 00 00 04 03 43 E8 80 00 43 E8 80 00 43 E8 80 00 04 04 3F C0 6A 32 40 0A 7D B4 3F C0 6A 32 04 05 40 69 D8 88 40 69 D8 88 40 69 D8 88 04 06 00 00 00 00 00 00 00 00 00 00 00 00 04 07 00 00 00 00 00 00 00 00 00 00 00 00 04 08 40 65 E3 55 40 65 D2 F2 40 65 B2 2E 04 09 3D DD 2F 00 3D DF 3B 60 3D E3 53 E0 04 0A 3D DD 2F 00 3D DF 3B 60 3D E3 53 E0 34 0D 0A";
|
||||||
|
//电导
|
||||||
|
// String hexString = "AB CD 00 A3 36 B1 25 06 21 18 15 08 0F 02 DC 00 D2 0D 48 38 36 45 3B 31 2E 33 3B 31 2E 30 2E 33 35 20 20 20 20 20 00 00 00 00 00 00 00 00 04 03 41 40 00 00 41 40 00 00 41 40 00 00 41 40 00 00 41 40 00 00 41 40 00 00 41 40 00 00 41 40 00 00 04 07 00 00 00 00 3A 83 12 6F 3A 83 12 6F 3A 83 12 6F 3A 83 12 6F 3A 83 12 6F 3A 83 12 6F 3A 83 12 6F 04 08 41 C8 CC CD 41 CA 66 66 41 CB 33 33 41 CC CC CD 41 D0 CC CD 41 D3 33 33 41 D4 CC CD 41 D5 99 9A 05 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 A1 0D 0A";
|
||||||
|
//雨量计
|
||||||
|
// String hexString = "AB CD 00 8B 3A 99 25 06 21 13 33 02 01 04 64 00 A5 15 48 38 31 45 2D 3B 31 2E 34 3B 35 2E 30 2E 30 34 20 20 20 20 00 00 00 00 00 00 00 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 01 02 00 00 00 00 00 00 00 00 00 00 00 00 01 04 00 00 00 00 00 00 00 00 00 00 00 00 01 05 00 00 00 00 00 00 00 00 00 00 00 00 04 01 43 37 66 66 43 37 66 66 04 02 00 00 00 00 00 00 00 00 04 04 40 E8 80 00 40 F0 00 00 04 05 00 00 00 00 00 00 00 00 EE 0D 0A";
|
||||||
|
//内涝‘
|
||||||
|
// String hexString = "AB CD 00 6A 3E 81 25 06 21 13 33 01 01 05 6A 00 05 19 56 38 38 20 53 6D 61 72 74 20 20 20 20 20 20 20 20 20 20 20 00 00 00 00 00 00 00 00 01 01 00 00 00 00 00 00 00 00 01 02 00 00 00 00 00 00 00 00 02 03 01 02 04 01 02 09 00 02 0A 00 02 0B 00 04 01 00 00 00 00 04 02 00 00 00 00 04 0D 00 00 00 00 01 0E 00 00 00 00 00 00 00 00 70 0D 0A";
|
||||||
|
|
||||||
|
|
||||||
|
hexString = hexString.replaceAll("\\s+", ""); // Remove all whitespace
|
||||||
|
byte[] data = hexStringToByteArray(hexString);
|
||||||
|
|
||||||
|
try (DatagramSocket socket = new DatagramSocket()) {
|
||||||
|
InetAddress serverAddress = InetAddress.getByName(serverHost);
|
||||||
|
|
||||||
|
// 发送数据包
|
||||||
|
DatagramPacket packet = new DatagramPacket(
|
||||||
|
data, data.length, serverAddress, serverPort);
|
||||||
|
socket.send(packet);
|
||||||
|
System.out.println("已发送数据包到服务器");
|
||||||
|
|
||||||
|
// 接收响应
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
DatagramPacket response = new DatagramPacket(buffer, buffer.length);
|
||||||
|
socket.receive(response);
|
||||||
|
|
||||||
|
String responseStr = new String(
|
||||||
|
response.getData(), 0, response.getLength());
|
||||||
|
System.out.println("服务器响应: " + responseStr);
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 十六进制字符串转字节数组的方法
|
||||||
|
private static byte[] hexStringToByteArray(String s) {
|
||||||
|
int len = s.length();
|
||||||
|
byte[] data = new byte[len / 2];
|
||||||
|
for (int i = 0; i < len; i += 2) {
|
||||||
|
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
|
||||||
|
+ Character.digit(s.charAt(i + 1), 16));
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
135
src/main/java/com/sipai/config/UDPFilePollingClient.java
Normal file
135
src/main/java/com/sipai/config/UDPFilePollingClient.java
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
package com.sipai.config;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.DatagramPacket;
|
||||||
|
import java.net.DatagramSocket;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.nio.file.*;
|
||||||
|
import java.nio.file.attribute.BasicFileAttributes;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于测试 - 南昌项目
|
||||||
|
* 修改为轮询txt文件并发送内容
|
||||||
|
* sj 2025-05-21
|
||||||
|
* 修改为仅轮询一次
|
||||||
|
*/
|
||||||
|
public class UDPFilePollingClient {
|
||||||
|
|
||||||
|
private static final String SERVER_HOST = "223.84.61.83"; // 默认本地
|
||||||
|
private static final int SERVER_PORT = 5006;
|
||||||
|
private static final String WATCH_DIRECTORY = "D:\\data_logs\\yewei"; // 监控当前目录
|
||||||
|
private static final Set<Path> processedFiles = Collections.synchronizedSet(new HashSet<>());
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println("启动UDP文件轮询服务(单次运行),监控目录: " + WATCH_DIRECTORY);
|
||||||
|
pollAndProcessFiles();
|
||||||
|
System.out.println("文件轮询处理完成");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void pollAndProcessFiles() {
|
||||||
|
try {
|
||||||
|
List<Path> txtFiles = new ArrayList<>();
|
||||||
|
|
||||||
|
// 收集所有txt文件
|
||||||
|
Files.walkFileTree(Paths.get(WATCH_DIRECTORY), new SimpleFileVisitor<Path>() {
|
||||||
|
@Override
|
||||||
|
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
|
||||||
|
if (file.toString().toLowerCase().endsWith(".txt")) {
|
||||||
|
txtFiles.add(file);
|
||||||
|
}
|
||||||
|
return FileVisitResult.CONTINUE;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 按修改时间排序(从旧到新)
|
||||||
|
txtFiles.sort(Comparator.comparing(path -> {
|
||||||
|
try {
|
||||||
|
return Files.getLastModifiedTime(path).toMillis();
|
||||||
|
} catch (IOException e) {
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
// 处理未处理过的文件
|
||||||
|
for (Path file : txtFiles) {
|
||||||
|
if (!processedFiles.contains(file)) {
|
||||||
|
processFile(file);
|
||||||
|
processedFiles.add(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("目录轮询错误: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void processFile(Path file) {
|
||||||
|
try {
|
||||||
|
// 正确读取文件内容为字符串
|
||||||
|
String fileContent = new String(Files.readAllBytes(file)).trim();
|
||||||
|
|
||||||
|
if (fileContent.isEmpty()) {
|
||||||
|
System.out.println("文件内容为空,跳过: " + file.getFileName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送UDP请求
|
||||||
|
sendUdpRequest(fileContent);
|
||||||
|
|
||||||
|
// 可选: 发送成功后移动或删除文件
|
||||||
|
Files.delete(file);
|
||||||
|
// 或移动到已处理目录
|
||||||
|
// Files.move(file, Paths.get("processed", file.getFileName()));
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("处理文件错误 " + file.getFileName() + ": " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void sendUdpRequest(String hexString) {
|
||||||
|
hexString = hexString.replaceAll("\\s+", ""); // 移除所有空白字符
|
||||||
|
|
||||||
|
try (DatagramSocket socket = new DatagramSocket()) {
|
||||||
|
InetAddress serverAddress = InetAddress.getByName(SERVER_HOST);
|
||||||
|
byte[] data = hexStringToByteArray(hexString);
|
||||||
|
|
||||||
|
// 发送数据包
|
||||||
|
DatagramPacket packet = new DatagramPacket(
|
||||||
|
data, data.length, serverAddress, SERVER_PORT);
|
||||||
|
socket.send(packet);
|
||||||
|
System.out.println("已发送UDP数据包到 " + SERVER_HOST + ":" + SERVER_PORT);
|
||||||
|
|
||||||
|
// 接收响应(可选)
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
DatagramPacket response = new DatagramPacket(buffer, buffer.length);
|
||||||
|
socket.setSoTimeout(1000); // 3秒超时
|
||||||
|
try {
|
||||||
|
socket.receive(response);
|
||||||
|
String responseStr = new String(
|
||||||
|
response.getData(), 0, response.getLength());
|
||||||
|
System.out.println("服务器响应: " + responseStr);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("未收到服务器响应(超时)");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("UDP通信错误: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 十六进制字符串转字节数组的方法
|
||||||
|
private static byte[] hexStringToByteArray(String s) {
|
||||||
|
int len = s.length();
|
||||||
|
if (len % 2 != 0) {
|
||||||
|
throw new IllegalArgumentException("十六进制字符串长度必须为偶数");
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] data = new byte[len / 2];
|
||||||
|
for (int i = 0; i < len; i += 2) {
|
||||||
|
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
|
||||||
|
+ Character.digit(s.charAt(i + 1), 16));
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
859
src/main/java/com/sipai/config/UDPServer.java
Normal file
859
src/main/java/com/sipai/config/UDPServer.java
Normal file
@ -0,0 +1,859 @@
|
|||||||
|
package com.sipai.config;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONException;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.sipai.entity.data.DeviceData;
|
||||||
|
import com.sipai.entity.data.PipelineEquipment;
|
||||||
|
import com.sipai.entity.data.PipelineEquipmentMpoint;
|
||||||
|
import com.sipai.entity.data.SensorData;
|
||||||
|
import com.sipai.entity.mqtt.MqttConfig;
|
||||||
|
import com.sipai.entity.scada.MPoint;
|
||||||
|
import com.sipai.entity.scada.MPointES;
|
||||||
|
import com.sipai.entity.scada.MPointHistory;
|
||||||
|
import com.sipai.service.data.PipelineEquipmentMpointService;
|
||||||
|
import com.sipai.service.data.PipelineEquipmentService;
|
||||||
|
import com.sipai.service.mqtt.MqttConfigService;
|
||||||
|
import com.sipai.service.scada.MPointHistoryService;
|
||||||
|
import com.sipai.service.scada.MPointService;
|
||||||
|
import com.sipai.tools.AlarmType;
|
||||||
|
import com.sipai.tools.CommString;
|
||||||
|
import com.sipai.tools.CommUtil;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.Unpooled;
|
||||||
|
import org.redisson.api.RBatch;
|
||||||
|
import org.redisson.api.RMapCache;
|
||||||
|
import org.redisson.api.RedissonClient;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.CommandLineRunner;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.net.DatagramPacket;
|
||||||
|
import java.net.DatagramSocket;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 南昌项目upd接收数据处理
|
||||||
|
* sj 2025-05-21
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class UDPServer implements CommandLineRunner {
|
||||||
|
|
||||||
|
@Value("${udp.server.port}") //端口
|
||||||
|
private int port;
|
||||||
|
@Value("${udp.server.enabled:true}") // 默认值为true
|
||||||
|
private boolean enabled;
|
||||||
|
private static final int BUFFER_SIZE = 1024;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PipelineEquipmentService pipelineEquipmentService;
|
||||||
|
@Autowired
|
||||||
|
private PipelineEquipmentMpointService pipelineEquipmentMpointService;
|
||||||
|
@Autowired
|
||||||
|
private MPointService mPointService;
|
||||||
|
@Autowired
|
||||||
|
private MPointHistoryService mPointHistoryService;
|
||||||
|
@Autowired
|
||||||
|
private MqttConfigService mqttConfigService;
|
||||||
|
|
||||||
|
//缓存点位
|
||||||
|
private static final Map<String, String> dataCache = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(String... args) throws Exception {
|
||||||
|
|
||||||
|
if (!enabled) {
|
||||||
|
System.out.println("UDP服务未启用");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try (DatagramSocket socket = new DatagramSocket(port)) {
|
||||||
|
System.out.println("UDP服务端启动,监听端口: " + port);
|
||||||
|
byte[] buffer = new byte[BUFFER_SIZE];
|
||||||
|
DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
|
||||||
|
while (true) {
|
||||||
|
socket.receive(packet);
|
||||||
|
// System.out.println(CommUtil.nowDate() + "======收到来自 " + packet.getAddress() + ":" + packet.getPort() + " 的数据");
|
||||||
|
|
||||||
|
// 发送应答
|
||||||
|
String response = "@222\r\n";
|
||||||
|
byte[] responseData = response.getBytes(StandardCharsets.UTF_8);
|
||||||
|
DatagramPacket responsePacket = new DatagramPacket(
|
||||||
|
responseData, responseData.length,
|
||||||
|
packet.getAddress(), packet.getPort());
|
||||||
|
socket.send(responsePacket);
|
||||||
|
|
||||||
|
// 解析数据包
|
||||||
|
byte[] receivedData = new byte[packet.getLength()];
|
||||||
|
System.arraycopy(packet.getData(), 0, receivedData, 0, packet.getLength());
|
||||||
|
// 打印原始字节数组(十六进制格式)
|
||||||
|
// System.out.println("原始数据包(十六进制): " + bytesToHex(receivedData));
|
||||||
|
|
||||||
|
DeviceData data = parseDeviceData(Unpooled.wrappedBuffer(receivedData));
|
||||||
|
if (data != null) {
|
||||||
|
String jsonData = CommUtil.toJson(data);
|
||||||
|
JSONObject jsonObject = JSON.parseObject(jsonData);
|
||||||
|
System.out.println("站号收到数据:" + jsonObject.get("stationId")+":"+jsonObject.get("startTime"));
|
||||||
|
JSONArray jsonArray = JSONArray.parseArray(jsonObject.get("sensorDataList").toString());
|
||||||
|
if (jsonArray != null && !jsonArray.isEmpty()) {
|
||||||
|
processSensorData(jsonObject, jsonArray, bytesToHex(receivedData));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
Logger logger = LoggerFactory.getLogger(UDPServer.class);
|
||||||
|
logger.error("UDP服务端启动异常", e);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//每次收到的报文存到D盘下 - 用于调试
|
||||||
|
private void logs(String type, String bytes, String path) {
|
||||||
|
try {
|
||||||
|
// 获取当前时间
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
|
||||||
|
// 定义文件名(保持原来的格式)
|
||||||
|
String fileName = DateTimeFormatter
|
||||||
|
.ofPattern("yyyyMMdd_HHmmss")
|
||||||
|
.format(now) + "_" + type + ".txt";
|
||||||
|
|
||||||
|
// 定义文件路径(D:/data_logs/年-月-日/自定义路径/)
|
||||||
|
String dateDir = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(now);
|
||||||
|
Path dirPath = Paths.get("D:/data_logs_new/" + dateDir + "/" + path + "/");
|
||||||
|
|
||||||
|
if (!Files.exists(dirPath)) {
|
||||||
|
Files.createDirectories(dirPath); // 如果目录不存在,则创建
|
||||||
|
}
|
||||||
|
|
||||||
|
Path filePath = dirPath.resolve(fileName); // 完整路径
|
||||||
|
Files.write(filePath, bytes.getBytes()); // 写入内容到文件
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//分发到各个业务处理
|
||||||
|
private void processSensorData(JSONObject jsonObject, JSONArray jsonArray, String bytes) {
|
||||||
|
String stationId = jsonObject.get("stationId").toString();
|
||||||
|
switch (stationId.charAt(1)) {
|
||||||
|
case '1'://井盖
|
||||||
|
logs(stationId, bytes, "jinggai");
|
||||||
|
processManholeCoverData(jsonObject, jsonArray);
|
||||||
|
break;
|
||||||
|
case '2'://流量计
|
||||||
|
logs(stationId, bytes, "liuliang");
|
||||||
|
processFlowMeterData(jsonObject, jsonArray);
|
||||||
|
break;
|
||||||
|
case '3'://液位计
|
||||||
|
logs(stationId, bytes, "yewei");
|
||||||
|
processLevelMeterData(jsonObject, jsonArray);
|
||||||
|
break;
|
||||||
|
case '4'://电导率
|
||||||
|
logs(stationId, bytes, "diandao");
|
||||||
|
processConductivityMeterData(jsonObject, jsonArray);
|
||||||
|
break;
|
||||||
|
case '5'://雨量计
|
||||||
|
logs(stationId, bytes, "yuliang");
|
||||||
|
processRainGaugeData(jsonObject, jsonArray);
|
||||||
|
break;
|
||||||
|
case '6'://内涝监测
|
||||||
|
logs(stationId, bytes, "neilao");
|
||||||
|
processWaterloggingMonitoringData(jsonObject, jsonArray);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
System.out.println("未知设备类型");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 井盖处理逻辑
|
||||||
|
private void processManholeCoverData(JSONObject jsonObject, JSONArray jsonArray) {
|
||||||
|
// System.out.println("开始处理井盖数据==============================================");
|
||||||
|
int dataCount = jsonObject.getIntValue("dataCount");
|
||||||
|
String startTimeStr = jsonObject.getString("startTime");
|
||||||
|
int intervalMinutes = jsonObject.getIntValue("intervalMinutes");
|
||||||
|
String stationId = jsonObject.getString("stationId");
|
||||||
|
double batteryVoltage = jsonObject.getDouble("batteryVoltage"); // 获取电池电压
|
||||||
|
|
||||||
|
// System.out.println("数据个数:" + dataCount);
|
||||||
|
// System.out.println("开始时间:" + startTimeStr);
|
||||||
|
// System.out.println("间隔分钟:" + intervalMinutes);
|
||||||
|
|
||||||
|
//单独处理电压
|
||||||
|
String channelName = stationId + "_V1";
|
||||||
|
String mpcode = getMpcodeFromCacheOrDB(stationId, channelName, "V1");
|
||||||
|
if (!mpcode.equals("未配置")) {
|
||||||
|
//推送kafka
|
||||||
|
mPointService.sendKafka4UDP("",mpcode, batteryVoltage, startTimeStr, 0, 1);
|
||||||
|
//推送mqtt
|
||||||
|
JSONArray jsonArray_mqtt = new JSONArray();
|
||||||
|
JSONObject jsonObject_mqtt = new JSONObject();
|
||||||
|
jsonObject_mqtt.put("mpcode", mpcode);
|
||||||
|
jsonObject_mqtt.put("value", batteryVoltage);
|
||||||
|
jsonObject_mqtt.put("time", startTimeStr);
|
||||||
|
jsonArray_mqtt.add(jsonObject_mqtt);
|
||||||
|
mqttConfigService.doSendView(jsonArray_mqtt,CommString.Mqtt_Topic_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 生成时间点序列
|
||||||
|
List<String> timePoints = generateTimePoints(startTimeStr, dataCount, intervalMinutes);
|
||||||
|
|
||||||
|
// 处理模拟量数据 (type=4)
|
||||||
|
// System.out.println("\n模拟量数据:");
|
||||||
|
Map<Integer, String> analogMappings = new HashMap<>();
|
||||||
|
analogMappings.put(1, "A1"); // 信号强度
|
||||||
|
analogMappings.put(2, "A2"); // 基站序号
|
||||||
|
analogMappings.put(3, "A3"); // 井盖角度
|
||||||
|
analogMappings.put(4, "A4"); // 电阻值1
|
||||||
|
analogMappings.put(5, "A5"); // 电阻值2
|
||||||
|
processSensorData(stationId, jsonArray, 4, analogMappings, "analogValues", timePoints);
|
||||||
|
|
||||||
|
// 创建新的JSONArray来存储处理后的报警数据
|
||||||
|
JSONArray processedAlarmData = new JSONArray();
|
||||||
|
|
||||||
|
// 处理报警量数据 (type=5)
|
||||||
|
// System.out.println("\n报警量数据:");
|
||||||
|
for (Object obj : jsonArray) {
|
||||||
|
JSONObject sensorData = (JSONObject) obj;
|
||||||
|
if (sensorData.getIntValue("type") == 5) {
|
||||||
|
int qValue = sensorData.getIntValue("qValue");
|
||||||
|
|
||||||
|
// 提取各报警位状态(0/1)
|
||||||
|
int voltageAlarm = (qValue & 0x0001) != 0 ? 1 : 0; // Q10
|
||||||
|
int waterAlarm = (qValue & 0x0002) != 0 ? 1 : 0; // Q11
|
||||||
|
int coverAlarm = (qValue & 0x0004) != 0 ? 1 : 0; // Q12
|
||||||
|
|
||||||
|
// 为每个报警位创建单独的数据对象
|
||||||
|
JSONObject voltageAlarmData = new JSONObject();
|
||||||
|
voltageAlarmData.put("type", 5);
|
||||||
|
voltageAlarmData.put("channel", 0); // Q10对应channel 0
|
||||||
|
voltageAlarmData.put("qValues", Collections.nCopies(dataCount, voltageAlarm));
|
||||||
|
|
||||||
|
JSONObject waterAlarmData = new JSONObject();
|
||||||
|
waterAlarmData.put("type", 5);
|
||||||
|
waterAlarmData.put("channel", 1); // Q11对应channel 1
|
||||||
|
waterAlarmData.put("qValues", Collections.nCopies(dataCount, waterAlarm));
|
||||||
|
|
||||||
|
JSONObject coverAlarmData = new JSONObject();
|
||||||
|
coverAlarmData.put("type", 5);
|
||||||
|
coverAlarmData.put("channel", 2); // Q12对应channel 2
|
||||||
|
coverAlarmData.put("qValues", Collections.nCopies(dataCount, coverAlarm));
|
||||||
|
|
||||||
|
// 添加到处理后的报警数据数组
|
||||||
|
processedAlarmData.add(voltageAlarmData);
|
||||||
|
processedAlarmData.add(waterAlarmData);
|
||||||
|
processedAlarmData.add(coverAlarmData);
|
||||||
|
} else {
|
||||||
|
// 非报警数据直接保留
|
||||||
|
processedAlarmData.add(sensorData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理报警数据存储
|
||||||
|
Map<Integer, String> alarmMappings = new HashMap<>();
|
||||||
|
alarmMappings.put(0, "Q10"); // 电压报警
|
||||||
|
alarmMappings.put(1, "Q11"); // 水浸报警
|
||||||
|
alarmMappings.put(2, "Q12"); // 开盖报警
|
||||||
|
processSensorData(stationId, processedAlarmData, 5, alarmMappings, "qValues", timePoints);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 流量计处理逻辑
|
||||||
|
private void processFlowMeterData(JSONObject jsonObject, JSONArray jsonArray) {
|
||||||
|
// System.out.println("开始处理流量计数据==============================================");
|
||||||
|
int dataCount = jsonObject.getIntValue("dataCount");
|
||||||
|
String startTimeStr = jsonObject.getString("startTime");
|
||||||
|
int intervalMinutes = jsonObject.getIntValue("intervalMinutes");
|
||||||
|
String stationId = jsonObject.getString("stationId");
|
||||||
|
|
||||||
|
// System.out.println("数据个数:" + dataCount);
|
||||||
|
// System.out.println("开始时间:" + startTimeStr);
|
||||||
|
// System.out.println("间隔分钟:" + intervalMinutes);
|
||||||
|
|
||||||
|
// 生成时间点序列
|
||||||
|
List<String> timePoints = generateTimePoints(startTimeStr, dataCount, intervalMinutes);
|
||||||
|
|
||||||
|
// 处理脉冲量数据 (type=1)
|
||||||
|
// System.out.println("\n脉冲量数据:");
|
||||||
|
Map<Integer, String> pulseMappings = new HashMap<>();
|
||||||
|
pulseMappings.put(1, "P1");
|
||||||
|
pulseMappings.put(2, "P2");
|
||||||
|
pulseMappings.put(3, "P3");
|
||||||
|
processSensorData(stationId, jsonArray, 1, pulseMappings, "accumulatedFlows", timePoints);
|
||||||
|
|
||||||
|
// 处理模拟量数据 (type=4)
|
||||||
|
// System.out.println("\n模拟量数据:");
|
||||||
|
Map<Integer, String> analogMappings = new HashMap<>();
|
||||||
|
analogMappings.put(1, "A1");
|
||||||
|
analogMappings.put(2, "A2");
|
||||||
|
analogMappings.put(4, "A4");
|
||||||
|
analogMappings.put(7, "A7");
|
||||||
|
analogMappings.put(8, "A8");
|
||||||
|
processSensorData(stationId, jsonArray, 4, analogMappings, "analogValues", timePoints);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 液位计处理逻辑
|
||||||
|
private void processLevelMeterData(JSONObject jsonObject, JSONArray jsonArray) {
|
||||||
|
// System.out.println("开始处理液位计数据==============================================");
|
||||||
|
int dataCount = jsonObject.getIntValue("dataCount");
|
||||||
|
String startTimeStr = jsonObject.getString("startTime");
|
||||||
|
int intervalMinutes = jsonObject.getIntValue("intervalMinutes");
|
||||||
|
String stationId = jsonObject.getString("stationId");
|
||||||
|
|
||||||
|
// System.out.println("数据个数:" + dataCount);
|
||||||
|
// System.out.println("开始时间:" + startTimeStr);
|
||||||
|
// System.out.println("间隔分钟:" + intervalMinutes);
|
||||||
|
|
||||||
|
// 生成时间点序列
|
||||||
|
List<String> timePoints = generateTimePoints(startTimeStr, dataCount, intervalMinutes);
|
||||||
|
|
||||||
|
// 处理模拟量数据 (type=4)
|
||||||
|
// System.out.println("\n液位计模拟量数据:");
|
||||||
|
Map<Integer, String> analogMappings = new HashMap<>();
|
||||||
|
analogMappings.put(1, "A1"); // 信号接收功率(dBm)
|
||||||
|
analogMappings.put(2, "A2"); // 信噪比
|
||||||
|
analogMappings.put(3, "A3"); // 小区ID
|
||||||
|
analogMappings.put(4, "A4"); // 倾斜角度(°)
|
||||||
|
analogMappings.put(5, "A5"); // 电池电压(V)
|
||||||
|
analogMappings.put(6, "A6"); // 投入式液位(m)
|
||||||
|
analogMappings.put(8, "A8"); // 雷达水位(m)
|
||||||
|
analogMappings.put(10, "A10"); // 综合液位(m)
|
||||||
|
|
||||||
|
processSensorData(stationId, jsonArray, 4, analogMappings, "analogValues", timePoints);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 电导率仪处理逻辑
|
||||||
|
private void processConductivityMeterData(JSONObject jsonObject, JSONArray jsonArray) {
|
||||||
|
// System.out.println("开始处理电导率仪数据==============================================");
|
||||||
|
int dataCount = jsonObject.getIntValue("dataCount");
|
||||||
|
String startTimeStr = jsonObject.getString("startTime");
|
||||||
|
int intervalMinutes = jsonObject.getIntValue("intervalMinutes");
|
||||||
|
String stationId = jsonObject.getString("stationId");
|
||||||
|
double batteryVoltage = jsonObject.getDouble("batteryVoltage");
|
||||||
|
// System.out.println("数据个数:" + dataCount);
|
||||||
|
// System.out.println("开始时间:" + startTimeStr);
|
||||||
|
// System.out.println("间隔分钟:" + intervalMinutes);
|
||||||
|
|
||||||
|
//单独处理电压
|
||||||
|
String channelName = stationId + "_V";
|
||||||
|
String mpcode = getMpcodeFromCacheOrDB(stationId, channelName, "V");
|
||||||
|
if (!mpcode.equals("未配置")) {
|
||||||
|
mPointService.sendKafka4UDP("",mpcode, batteryVoltage, startTimeStr, 0, 1);
|
||||||
|
//推送mqtt
|
||||||
|
JSONArray jsonArray_mqtt = new JSONArray();
|
||||||
|
JSONObject jsonObject_mqtt = new JSONObject();
|
||||||
|
jsonObject_mqtt.put("mpcode", mpcode);
|
||||||
|
jsonObject_mqtt.put("value", batteryVoltage);
|
||||||
|
jsonObject_mqtt.put("time", startTimeStr);
|
||||||
|
jsonArray_mqtt.add(jsonObject_mqtt);
|
||||||
|
mqttConfigService.doSendView(jsonArray_mqtt,CommString.Mqtt_Topic_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 生成时间点序列
|
||||||
|
List<String> timePoints = generateTimePoints(startTimeStr, dataCount, intervalMinutes);
|
||||||
|
|
||||||
|
// 处理模拟量数据 (type=4)
|
||||||
|
// System.out.println("\n电导率仪数据:");
|
||||||
|
Map<Integer, String> analogMappings = new HashMap<>();
|
||||||
|
analogMappings.put(7, "A7"); // 电导率值
|
||||||
|
analogMappings.put(8, "A8"); // 温度值
|
||||||
|
processSensorData(stationId, jsonArray, 4, analogMappings, "analogValues", timePoints);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 雨量计处理逻辑
|
||||||
|
private void processRainGaugeData(JSONObject jsonObject, JSONArray jsonArray) {
|
||||||
|
// System.out.println("开始处理雨量计数据==============================================");
|
||||||
|
int dataCount = jsonObject.getIntValue("dataCount");
|
||||||
|
String startTimeStr = jsonObject.getString("startTime");
|
||||||
|
int intervalMinutes = jsonObject.getIntValue("intervalMinutes");
|
||||||
|
String stationId = jsonObject.getString("stationId");
|
||||||
|
|
||||||
|
// System.out.println("数据个数:" + dataCount);
|
||||||
|
// System.out.println("开始时间:" + startTimeStr);
|
||||||
|
// System.out.println("间隔分钟:" + intervalMinutes);
|
||||||
|
|
||||||
|
// 生成时间点序列
|
||||||
|
List<String> timePoints = generateTimePoints(startTimeStr, dataCount, intervalMinutes);
|
||||||
|
|
||||||
|
// 处理模拟量数据 (type=4)
|
||||||
|
// System.out.println("\n雨量计数据:");
|
||||||
|
Map<Integer, String> analogMappings = new HashMap<>();
|
||||||
|
analogMappings.put(1, "A1"); // 雨量值
|
||||||
|
processSensorData(stationId, jsonArray, 4, analogMappings, "analogValues", timePoints);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 内涝监测处理逻辑
|
||||||
|
private void processWaterloggingMonitoringData(JSONObject jsonObject, JSONArray jsonArray) {
|
||||||
|
// System.out.println("开始处理内涝监测数据==============================================");
|
||||||
|
int dataCount = jsonObject.getIntValue("dataCount");
|
||||||
|
String startTimeStr = jsonObject.getString("startTime");
|
||||||
|
int intervalMinutes = jsonObject.getIntValue("intervalMinutes");
|
||||||
|
String stationId = jsonObject.getString("stationId");
|
||||||
|
|
||||||
|
// System.out.println("数据个数:" + dataCount);
|
||||||
|
// System.out.println("开始时间:" + startTimeStr);
|
||||||
|
// System.out.println("间隔分钟:" + intervalMinutes);
|
||||||
|
|
||||||
|
// 生成时间点序列
|
||||||
|
List<String> timePoints = generateTimePoints(startTimeStr, dataCount, intervalMinutes);
|
||||||
|
|
||||||
|
// 处理模拟量数据 (type=4)
|
||||||
|
// System.out.println("\n水位数据:");
|
||||||
|
Map<Integer, String> analogMappings = new HashMap<>();
|
||||||
|
analogMappings.put(13, "A13"); // 水位值(0x0D)
|
||||||
|
// analogMappings.put(14, "A14"); // 状态值(0x0D)
|
||||||
|
processSensorData(stationId, jsonArray, 4, analogMappings, "analogValues", timePoints);
|
||||||
|
|
||||||
|
// 处理脉冲量数据 (type=1)
|
||||||
|
// System.out.println("\n状态数据:");
|
||||||
|
Map<Integer, String> pulseMappings = new HashMap<>();
|
||||||
|
pulseMappings.put(14, "P14"); // 状态值(0x0E)
|
||||||
|
processSensorData(stationId, jsonArray, 1, pulseMappings, "accumulatedFlows", timePoints);
|
||||||
|
}
|
||||||
|
|
||||||
|
private DeviceData parseDeviceData(ByteBuf buf) {
|
||||||
|
// 查找起始符位置
|
||||||
|
int startIndex = -1;
|
||||||
|
for (int i = 0; i < buf.readableBytes() - 1; i++) {
|
||||||
|
if (buf.getByte(i) == (byte) 0xAB && buf.getByte(i + 1) == (byte) 0xCD) {
|
||||||
|
startIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (startIndex == -1) {
|
||||||
|
// 没找到起始符,丢弃所有数据
|
||||||
|
buf.skipBytes(buf.readableBytes());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// 跳过起始符前的所有字节
|
||||||
|
buf.skipBytes(startIndex);
|
||||||
|
// 标记当前位置
|
||||||
|
buf.markReaderIndex();
|
||||||
|
// 验证起始符
|
||||||
|
byte b1 = buf.readByte();
|
||||||
|
byte b2 = buf.readByte();
|
||||||
|
if (b1 != (byte) 0xAB || b2 != (byte) 0xCD) {
|
||||||
|
buf.resetReaderIndex();
|
||||||
|
buf.skipBytes(1);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// 确保有足够数据读取长度
|
||||||
|
if (buf.readableBytes() < 2) {
|
||||||
|
buf.resetReaderIndex();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// 读取长度
|
||||||
|
int dataLength = buf.readUnsignedShort();
|
||||||
|
// 计算完整包长度
|
||||||
|
int totalLength = 2 + 2 + dataLength + 2; // AB CD + len + data + 结束符
|
||||||
|
// 确保有完整数据包
|
||||||
|
if (buf.readableBytes() < dataLength + 2) {
|
||||||
|
buf.resetReaderIndex();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// 读取完整数据包
|
||||||
|
ByteBuf frame = buf.readRetainedSlice(dataLength + 2);
|
||||||
|
DeviceData data = new DeviceData();
|
||||||
|
// 1. 基础信息解析
|
||||||
|
data.setStationId(frame.readUnsignedShort());
|
||||||
|
byte[] timeBytes = new byte[5];
|
||||||
|
frame.readBytes(timeBytes);
|
||||||
|
data.setStartTime(parseBcdTime(timeBytes));
|
||||||
|
data.setDataCount(frame.readUnsignedByte());
|
||||||
|
data.setIntervalMinutes(frame.readUnsignedByte());
|
||||||
|
data.setBatteryVoltage(frame.readUnsignedShort() / 100.0f);
|
||||||
|
data.setUploadCount(frame.readUnsignedShort());
|
||||||
|
//设备信息处理
|
||||||
|
int infoLength = frame.readUnsignedByte();
|
||||||
|
// 读取实际设备信息(固定20字节)
|
||||||
|
byte[] deviceInfo = new byte[20];
|
||||||
|
frame.readBytes(deviceInfo);
|
||||||
|
data.setDeviceInfo(new String(deviceInfo, StandardCharsets.US_ASCII).trim());
|
||||||
|
int bytesToSkip = 8; // 跳过预留的8字节
|
||||||
|
frame.skipBytes(bytesToSkip);
|
||||||
|
//解析传感器数据
|
||||||
|
List<SensorData> sensorDataList = new ArrayList<>();
|
||||||
|
while (frame.readableBytes() >= 2) {
|
||||||
|
int type = frame.readUnsignedByte();
|
||||||
|
int channel = frame.readUnsignedByte();
|
||||||
|
// System.out.printf("Parsing sensor: type=%02X, channel=%02X at pos=%d%n", type, channel, frame.readerIndex() - 2);
|
||||||
|
SensorData sensor = new SensorData();
|
||||||
|
sensor.setType(type);
|
||||||
|
sensor.setChannel(channel);
|
||||||
|
try {
|
||||||
|
switch (type) {
|
||||||
|
case 0x01: // 脉冲量
|
||||||
|
long yesterdayFlow = frame.readUnsignedIntLE();
|
||||||
|
sensor.setYesterdayFlow(yesterdayFlow);
|
||||||
|
List<Long> flows = new ArrayList<>();
|
||||||
|
for (int j = 0; j < data.getDataCount(); j++) {
|
||||||
|
if (frame.readableBytes() < 4) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
flows.add(frame.readUnsignedIntLE());
|
||||||
|
}
|
||||||
|
sensor.setAccumulatedFlows(flows);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x02: // 开关量/报警量
|
||||||
|
// 每个通道只读取1字节状态值
|
||||||
|
if (frame.readableBytes() >= 1) {
|
||||||
|
int status = frame.readUnsignedByte();
|
||||||
|
List<Integer> statusList = new ArrayList<>();
|
||||||
|
statusList.add(status);
|
||||||
|
sensor.setDescription("开关量状态");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0x41: // 不知道啥类型
|
||||||
|
// 不知道啥类型
|
||||||
|
if (frame.readableBytes() >= 1) {
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x42: // 不知道啥类型
|
||||||
|
// 不知道啥类型
|
||||||
|
if (frame.readableBytes() >= 1) {
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x43: // 不知道啥类型
|
||||||
|
// 不知道啥类型
|
||||||
|
if (frame.readableBytes() >= 1) {
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x04: // 模拟量
|
||||||
|
List<Float> analogs = new ArrayList<>();
|
||||||
|
for (int j = 0; j < data.getDataCount(); j++) {
|
||||||
|
if (frame.readableBytes() < 4) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
float value = 0.0f;
|
||||||
|
try {
|
||||||
|
// 智能井盖
|
||||||
|
if (String.valueOf(data.getStationId()).charAt(1) == '1') {
|
||||||
|
// 尝试不同的解析方式,根据通道类型选择合适的解析方法
|
||||||
|
switch (channel) {
|
||||||
|
case 1: // A1 信号强度 (dBm)
|
||||||
|
byte signalByte = frame.readByte();
|
||||||
|
frame.skipBytes(3); // 跳过剩余3字节
|
||||||
|
value = (float) signalByte;
|
||||||
|
break;
|
||||||
|
case 2: // A2 基站序号
|
||||||
|
value = (float) frame.readUnsignedIntLE();
|
||||||
|
break;
|
||||||
|
case 3: // A3 井盖角度
|
||||||
|
int angleInt = frame.readInt(); // 使用readInt()读取大端序
|
||||||
|
value = Float.intBitsToFloat(angleInt);
|
||||||
|
// 验证是否为合理的角度值
|
||||||
|
if (value < 0 || value > 360) {
|
||||||
|
frame.resetReaderIndex();
|
||||||
|
frame.skipBytes(j * 4);
|
||||||
|
int angleFixed = frame.readUnsignedShort();
|
||||||
|
frame.skipBytes(2);
|
||||||
|
value = (float) angleFixed / 100.0f;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 4: // A4 电阻值1
|
||||||
|
case 5: // A5 电阻值2
|
||||||
|
case 7: //
|
||||||
|
case 8: //
|
||||||
|
int resistanceInt1 = frame.readInt(); // 使用readInt()读取大端序
|
||||||
|
value = Float.intBitsToFloat(resistanceInt1);
|
||||||
|
break;
|
||||||
|
default: // 其他模拟量,默认使用浮点数解析
|
||||||
|
int intValue = frame.readIntLE();
|
||||||
|
value = Float.intBitsToFloat(intValue);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 流量计
|
||||||
|
if (String.valueOf(data.getStationId()).charAt(1) == '2') {
|
||||||
|
// 统一使用大端序读取IEEE754浮点数
|
||||||
|
int intValue = frame.readInt(); // 改为readInt()而不是readIntLE()
|
||||||
|
value = Float.intBitsToFloat(intValue);
|
||||||
|
// 保留3位小数
|
||||||
|
value = (float) (Math.round(value * 1000) / 1000.0);
|
||||||
|
// 格式化为3位小数,不足补零
|
||||||
|
String formattedValue = String.format("%.3f", value); // 例如 7.4 → "7.400"
|
||||||
|
value = Float.parseFloat(formattedValue); // 转回float(可选)
|
||||||
|
}
|
||||||
|
// 液位计
|
||||||
|
if (String.valueOf(data.getStationId()).charAt(1) == '3') {
|
||||||
|
// 统一使用大端序读取IEEE754浮点数
|
||||||
|
int intValue = frame.readInt(); // 改为readInt()而不是readIntLE()
|
||||||
|
value = Float.intBitsToFloat(intValue);
|
||||||
|
// 保留3位小数
|
||||||
|
value = (float) (Math.round(value * 1000) / 1000.0);
|
||||||
|
// 格式化为3位小数,不足补零
|
||||||
|
String formattedValue = String.format("%.3f", value); // 例如 7.4 → "7.400"
|
||||||
|
value = Float.parseFloat(formattedValue); // 转回float(可选)
|
||||||
|
}
|
||||||
|
// 电导率
|
||||||
|
/*if (String.valueOf(data.getStationId()).charAt(1) == '4') {
|
||||||
|
int intValue = frame.readIntLE();
|
||||||
|
value = Float.intBitsToFloat(intValue);
|
||||||
|
// 保留2位小数
|
||||||
|
value = (float) (Math.round(value * 100) / 100.0);
|
||||||
|
}*/
|
||||||
|
// 电导率
|
||||||
|
if (String.valueOf(data.getStationId()).charAt(1) == '4') {
|
||||||
|
// 改为使用大端序读取
|
||||||
|
int intValue = frame.readInt(); // 改为readInt()而不是readIntLE()
|
||||||
|
value = Float.intBitsToFloat(intValue);
|
||||||
|
// 保留2位小数
|
||||||
|
value = (float) (Math.round(value * 100) / 100.0);
|
||||||
|
}
|
||||||
|
// 雨量计
|
||||||
|
if (String.valueOf(data.getStationId()).charAt(1) == '5') {
|
||||||
|
// 改为使用大端序读取
|
||||||
|
int intValue = frame.readInt(); // 改为readInt()而不是readIntLE()
|
||||||
|
value = Float.intBitsToFloat(intValue);
|
||||||
|
// 保留2位小数
|
||||||
|
value = (float) (Math.round(value * 100) / 100.0);
|
||||||
|
}
|
||||||
|
// 内涝监测设备
|
||||||
|
if (String.valueOf(data.getStationId()).charAt(1) == '6') {
|
||||||
|
// 改为使用大端序读取
|
||||||
|
int intValue = frame.readInt(); // 改为readInt()而不是readIntLE()
|
||||||
|
value = Float.intBitsToFloat(intValue);
|
||||||
|
// 保留2位小数
|
||||||
|
value = (float) (Math.round(value * 100) / 100.0);
|
||||||
|
}
|
||||||
|
// 过滤异常值
|
||||||
|
if (Float.isNaN(value) || Float.isInfinite(value) || value < -1000000.0f || value > 1000000.0f) {
|
||||||
|
value = 0.0f;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
frame.skipBytes(4);
|
||||||
|
value = 0.0f;
|
||||||
|
}
|
||||||
|
analogs.add(value);
|
||||||
|
}
|
||||||
|
sensor.setAnalogValues(analogs);
|
||||||
|
// 智能井盖特定通道处理
|
||||||
|
if (String.valueOf(data.getStationId()).charAt(1) == '1') {
|
||||||
|
switch (channel) {
|
||||||
|
case 1: // A1信号强度
|
||||||
|
sensor.setDescription("A1信号强度");
|
||||||
|
break;
|
||||||
|
case 2: // A2基站序号
|
||||||
|
sensor.setDescription("A2基站序号");
|
||||||
|
break;
|
||||||
|
case 3: // A3井盖角度
|
||||||
|
sensor.setDescription("A3井盖角度");
|
||||||
|
break;
|
||||||
|
case 4: // A4电阻值1
|
||||||
|
sensor.setDescription("A4电阻值1");
|
||||||
|
break;
|
||||||
|
case 5: // A5电阻值2
|
||||||
|
sensor.setDescription("A5电阻值2");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0x05: // Q通道数据(数字量输出)
|
||||||
|
int qValue = frame.readUnsignedShort();
|
||||||
|
// 校验 qValue 范围(0x0000 ~ 0xFFFF)
|
||||||
|
if (qValue < 0 || qValue > 0xFFFF) {
|
||||||
|
throw new IllegalArgumentException("Invalid Q channel value: " + qValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 解析各报警位状态
|
||||||
|
Map<AlarmType, Boolean> alarmStatus = new EnumMap<>(AlarmType.class);
|
||||||
|
for (AlarmType alarm : AlarmType.values()) {
|
||||||
|
alarmStatus.put(alarm, alarm.isTriggered(qValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建报警描述
|
||||||
|
StringBuilder alarmDesc = new StringBuilder("Q通道状态: ");
|
||||||
|
for (AlarmType alarm : AlarmType.values()) {
|
||||||
|
alarmDesc.append(alarm.getDescription())
|
||||||
|
.append(alarmStatus.get(alarm) ? "触发" : "正常")
|
||||||
|
.append(", ");
|
||||||
|
}
|
||||||
|
sensor.setDescription(alarmDesc.toString().replaceAll(", $", ""));
|
||||||
|
|
||||||
|
// 存储原始报警值(可选)
|
||||||
|
sensor.setqValue(qValue);
|
||||||
|
sensor.setAlarmStatus(alarmStatus);
|
||||||
|
|
||||||
|
// 记录报警日志
|
||||||
|
if (alarmStatus.get(AlarmType.COVER_ALARM)) {
|
||||||
|
LoggerFactory.getLogger(UDPServer.class)
|
||||||
|
.warn("井盖开盖报警触发!站号: {}, Q值: {}", data.getStationId(), qValue);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
int bytesToSkip2 = data.getDataCount() * 4;
|
||||||
|
if (frame.readableBytes() >= bytesToSkip2) {
|
||||||
|
frame.skipBytes(bytesToSkip2);
|
||||||
|
} else {
|
||||||
|
// System.err.printf("Not enough readable bytes to skip %d bytes. Current readable bytes: %d%n",
|
||||||
|
// bytesToSkip2, frame.readableBytes());
|
||||||
|
// 可选择抛出异常、记录日志或者做其他处理
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
sensorDataList.add(sensor);
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Error parsing sensor");
|
||||||
|
e.printStackTrace();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// 检查是否到达结束符
|
||||||
|
if (frame.readableBytes() >= 2 && frame.getByte(frame.readerIndex()) == 0x0D && frame.getByte(frame.readerIndex() + 1) == 0x0A) {
|
||||||
|
// 跳过结束符
|
||||||
|
frame.skipBytes(2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data.setSensorDataList(sensorDataList);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String parseBcdTime(byte[] bytes) {
|
||||||
|
// bytes: 19 05 29 10 47
|
||||||
|
int year = 2000 + ((bytes[0] >> 4) & 0xF) * 10 + (bytes[0] & 0xF);
|
||||||
|
int month = ((bytes[1] >> 4) & 0xF) * 10 + (bytes[1] & 0xF);
|
||||||
|
int day = ((bytes[2] >> 4) & 0xF) * 10 + (bytes[2] & 0xF);
|
||||||
|
int hour = ((bytes[3] >> 4) & 0xF) * 10 + (bytes[3] & 0xF);
|
||||||
|
int minute = ((bytes[4] >> 4) & 0xF) * 10 + (bytes[4] & 0xF);
|
||||||
|
|
||||||
|
return String.format("%04d-%02d-%02d %02d:%02d", year, month, day, hour, minute);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String bytesToHex(byte[] bytes) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (byte b : bytes) {
|
||||||
|
sb.append(String.format("%02X ", b));
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用传感器数据处理方法
|
||||||
|
*
|
||||||
|
* @param stationId 站点id 用于redis组合key
|
||||||
|
* @param jsonArray 传感器数据数组
|
||||||
|
* @param type 要处理的数据类型
|
||||||
|
* @param channelMappings 通道映射
|
||||||
|
* @param valueFieldName 值字段名
|
||||||
|
* @param timePoints 时间点列表
|
||||||
|
*/
|
||||||
|
private void processSensorData(String stationId, JSONArray jsonArray, int type,
|
||||||
|
Map<Integer, String> channelMappings,
|
||||||
|
String valueFieldName,
|
||||||
|
List<String> timePoints) {
|
||||||
|
try {
|
||||||
|
for (Object obj : jsonArray) {
|
||||||
|
JSONObject sensorData = (JSONObject) obj;
|
||||||
|
if (sensorData.getIntValue("type") == type) {
|
||||||
|
int channel = sensorData.getIntValue("channel");
|
||||||
|
if (channelMappings.containsKey(channel)) {
|
||||||
|
String channelName = stationId + "_" + channelMappings.get(channel);
|
||||||
|
JSONArray values = sensorData.getJSONArray(valueFieldName);
|
||||||
|
|
||||||
|
if (values != null && !values.isEmpty()) {
|
||||||
|
//获取mpcode (优先从缓存拿)
|
||||||
|
String mpcode = getMpcodeFromCacheOrDB(stationId, channelName, channelMappings.get(channel));
|
||||||
|
if (!mpcode.equals("未配置")) {
|
||||||
|
JSONObject dataCache = new JSONObject();
|
||||||
|
|
||||||
|
JSONArray jsonArray_mqtt = new JSONArray();
|
||||||
|
for (int i = 0; i < values.size(); i++) {
|
||||||
|
String timePoint = timePoints.get(i);
|
||||||
|
timePoint = timePoint.length() == 16 ? timePoint + ":00" : timePoint;
|
||||||
|
Object value = values.get(i);
|
||||||
|
dataCache.put(timePoint, value);
|
||||||
|
//推送至kafka
|
||||||
|
mPointService.sendKafka4UDP("",mpcode, value, timePoint, i, values.size());
|
||||||
|
|
||||||
|
//添加到mqtt数组
|
||||||
|
JSONObject jsonObject_mqtt = new JSONObject();
|
||||||
|
jsonObject_mqtt.put("mpcode", mpcode);
|
||||||
|
jsonObject_mqtt.put("value", value);
|
||||||
|
jsonObject_mqtt.put("time", timePoint);
|
||||||
|
jsonArray_mqtt.add(jsonObject_mqtt);
|
||||||
|
}
|
||||||
|
|
||||||
|
//批量推送mqtt
|
||||||
|
mqttConfigService.doSendView(jsonArray_mqtt, CommString.Mqtt_Topic_DATA);
|
||||||
|
} else {
|
||||||
|
System.out.println("站点:" + stationId + " 标识:" + channelMappings.get(channel) + " 未配置");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 从缓存或数据库获取mpcode
|
||||||
|
private String getMpcodeFromCacheOrDB(String stationId, String channelName, String tag) {
|
||||||
|
// 先查缓存
|
||||||
|
String mpcode = dataCache.get(channelName);
|
||||||
|
if (mpcode != null) {
|
||||||
|
return mpcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 缓存没有则查询数据库
|
||||||
|
List<PipelineEquipment> equipmentList = pipelineEquipmentService.selectListByWhere(
|
||||||
|
"where station_code = '" + stationId + "'");
|
||||||
|
if (equipmentList != null && !equipmentList.isEmpty()) {
|
||||||
|
List<PipelineEquipmentMpoint> mpointList = pipelineEquipmentMpointService.selectListByWhere(
|
||||||
|
"where pid = '" + equipmentList.get(0).getId() + "' and tag = '" + tag + "'");
|
||||||
|
if (mpointList != null && !mpointList.isEmpty()) {
|
||||||
|
mpcode = mpointList.get(0).getMpcode();
|
||||||
|
// 存入缓存
|
||||||
|
dataCache.put(channelName, mpcode);
|
||||||
|
return mpcode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "未配置"; // 或根据业务需求返回默认值
|
||||||
|
}
|
||||||
|
|
||||||
|
//时间生成方法
|
||||||
|
private List<String> generateTimePoints(String startTimeStr, int count, int intervalMinutes) {
|
||||||
|
List<String> timePoints = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||||
|
Date date = sdf.parse(startTimeStr);
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(date);
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
timePoints.add(sdf.format(calendar.getTime()));
|
||||||
|
calendar.add(Calendar.MINUTE, intervalMinutes);
|
||||||
|
}
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
// 如果解析失败,使用简单的时间格式
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
timePoints.add(startTimeStr + " +" + (i * intervalMinutes) + "分钟");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return timePoints;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,75 @@
|
|||||||
|
package com.sipai.controller.check;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.DatagramPacket;
|
||||||
|
import java.net.DatagramSocket;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 普罗米修斯 监听接口
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/check")
|
||||||
|
public class CheckServerController {
|
||||||
|
|
||||||
|
@RequestMapping("/server.do")
|
||||||
|
public String server() {
|
||||||
|
return "suc";
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/testSendUdp.do")
|
||||||
|
public String testSendUdp() {
|
||||||
|
//修改成服务端的IP
|
||||||
|
// String serverHost = "132.120.132.77";
|
||||||
|
// String serverHost = "116.236.176.248";
|
||||||
|
String serverHost = "192.168.10.18";
|
||||||
|
int serverPort = 5006;
|
||||||
|
|
||||||
|
//智能井盖
|
||||||
|
// String hexString = "ABCD004D00002505121109013C016800001F484B33352D49493B56312E313B56312E302E303600000000000000000401C25000000402000000000403429E293C040447C35000040547C3500005010004A70D0A";
|
||||||
|
//流量仪
|
||||||
|
String hexString = "AB CD 01 C7 00 7B 25 05 19 16 18 0A 01 02 E2 00 00 00 48 38 36 45 3B 31 2E 33 3B 31 2E 30 2E 33 35 20 20 20 20 20 00 00 00 00 00 00 00 00 01 01 00 00 00 00 00 00 00 00 01 00 00 00 03 00 00 00 05 00 00 00 07 00 00 00 09 00 00 00 0B 00 00 00 0D 00 00 00 0E 00 00 00 10 00 00 00 01 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 03 00 00 00 00 00 00 00 00 01 00 00 00 03 00 00 00 05 00 00 00 07 00 00 00 09 00 00 00 0B 00 00 00 0D 00 00 00 0E 00 00 00 10 00 00 00 04 01 40 EC 62 C6 40 EC 62 C6 40 EC 62 C6 40 EC 62 C6 40 EC 62 C6 40 EC D0 CD 40 48 F5 C3 40 48 F5 C3 40 48 F5 C3 40 48 F5 C3 04 02 40 EB 86 B8 40 EB 86 B8 40 EB 86 B8 40 EB 86 B8 40 EB 86 B8 40 EB F4 BF 3D FB E7 6D 3D FB E7 6D 3D FB E7 6D 3D FB E7 6D 04 03 41 F0 00 00 41 B0 00 00 41 F8 00 00 41 B8 00 00 41 B8 00 00 41 F8 00 00 41 F8 00 00 41 F8 00 00 41 F8 00 00 41 F8 00 00 04 04 41 BB 99 9A 41 BB 99 9A 41 BB 99 9A 41 BB 99 9A 41 BB 99 9A 41 BB 99 9A 41 BB 99 9A 41 BB 99 9A 41 BB 99 9A 41 BB 99 9A 04 07 42 ED 99 9A 42 ED 99 9A 42 ED 99 9A 42 ED 99 9A 42 ED 99 9A 42 ED 99 9A 42 B4 00 00 42 B4 00 00 42 B4 00 00 42 B4 00 00 04 08 3E 40 83 12 3E 40 83 12 3E 40 83 12 3E 40 83 12 3E 40 83 12 3E 40 83 12 3E 40 83 12 3E 40 83 12 3E 40 83 12 3E 40 83 12 05 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 6B 0D 0A";
|
||||||
|
//厂家传的异常数据
|
||||||
|
// String hexString = "AA AA B7 56 0E 25 06 03 10 15 08 31 02 E1 30 11 00 00 0B 47 00 00 0F 50 00 03 00 03 00 04 00 04 00 03 00 04 00 03 12 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 00 00 0B 47 00 00 0F 4C 00 03 00 03 00 04 00 04 00 03 00 04 00 03 31 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 32 00 08 00 08 00 08 00 08 00 08 00 08 00 08 00 08 33 04 B0 04 B0 04 B0 04 B0 04 B0 04 B0 04 B0 04 B0 34 07 9E 07 9E 07 9C 07 9D 07 99 07 99 07 9A 07 98 37 00 12 00 0A 00 0E 00 0E 00 0E 00 0E 00 0E 00 0E 38 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0D 0A";
|
||||||
|
|
||||||
|
hexString = hexString.replaceAll("\\s+", ""); // Remove all whitespace
|
||||||
|
byte[] data = hexStringToByteArray(hexString);
|
||||||
|
|
||||||
|
try (DatagramSocket socket = new DatagramSocket()) {
|
||||||
|
InetAddress serverAddress = InetAddress.getByName(serverHost);
|
||||||
|
|
||||||
|
// 发送数据包
|
||||||
|
DatagramPacket packet = new DatagramPacket(
|
||||||
|
data, data.length, serverAddress, serverPort);
|
||||||
|
socket.send(packet);
|
||||||
|
System.out.println("已发送数据包到服务器");
|
||||||
|
|
||||||
|
// 接收响应
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
DatagramPacket response = new DatagramPacket(buffer, buffer.length);
|
||||||
|
socket.receive(response);
|
||||||
|
|
||||||
|
String responseStr = new String(
|
||||||
|
response.getData(), 0, response.getLength());
|
||||||
|
System.out.println("服务器响应: " + responseStr);
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return "suc";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 十六进制字符串转字节数组的方法
|
||||||
|
private static byte[] hexStringToByteArray(String s) {
|
||||||
|
int len = s.length();
|
||||||
|
byte[] data = new byte[len / 2];
|
||||||
|
for (int i = 0; i < len; i += 2) {
|
||||||
|
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
|
||||||
|
+ Character.digit(s.charAt(i + 1), 16));
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,170 @@
|
|||||||
|
package com.sipai.controller.data;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.sipai.entity.base.Result;
|
||||||
|
import com.sipai.entity.common.PageData;
|
||||||
|
import com.sipai.entity.data.PipeTopicMpoint;
|
||||||
|
import com.sipai.entity.data.PipelineEquipmentMpoint;
|
||||||
|
import com.sipai.entity.scada.MPoint;
|
||||||
|
import com.sipai.service.data.PipeTopicMpointService;
|
||||||
|
import com.sipai.service.scada.MPointService;
|
||||||
|
import com.sipai.tools.CommUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管网专题页点位控制器
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/pipeTopicMPoint")
|
||||||
|
public class PipeTopicMPointController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PipeTopicMpointService pipeTopicMpointService;
|
||||||
|
@Autowired
|
||||||
|
private MPointService mPointService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据主键查询点位信息
|
||||||
|
*/
|
||||||
|
@GetMapping("/selectById.do")
|
||||||
|
public Result selectByPrimaryKey(@RequestParam Integer id) {
|
||||||
|
PipeTopicMpoint mpoint = pipeTopicMpointService.selectByPrimaryKey(id);
|
||||||
|
if (mpoint != null) {
|
||||||
|
return Result.success(mpoint);
|
||||||
|
} else {
|
||||||
|
return Result.failed("点位不存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增点位信息
|
||||||
|
*/
|
||||||
|
@PostMapping("/save.do")
|
||||||
|
public String save(@ModelAttribute PipeTopicMpoint mpoint) {
|
||||||
|
int res = pipeTopicMpointService.insert(mpoint);
|
||||||
|
if (res > 0) {
|
||||||
|
return CommUtil.toJson(Result.success(mpoint.getId()));
|
||||||
|
} else {
|
||||||
|
return CommUtil.toJson(Result.failed("新增失败"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新点位信息
|
||||||
|
*/
|
||||||
|
@PostMapping("/update.do")
|
||||||
|
public String update(@ModelAttribute PipeTopicMpoint mpoint) {
|
||||||
|
boolean res = pipeTopicMpointService.update(mpoint);
|
||||||
|
return CommUtil.toJson(res ? Result.success(1) : Result.failed("更新失败"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据主键删除点位
|
||||||
|
*/
|
||||||
|
@PostMapping("/deleteById.do")
|
||||||
|
public String deleteById(@RequestParam Integer id) {
|
||||||
|
boolean res = pipeTopicMpointService.delete(id);
|
||||||
|
return CommUtil.toJson(res ? Result.success(1) : Result.failed("删除失败"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除点位
|
||||||
|
*/
|
||||||
|
@PostMapping("/deleteBatch.do")
|
||||||
|
public String deleteBatch(@RequestBody List<Integer> idList) {
|
||||||
|
boolean res = pipeTopicMpointService.deleteBatch(idList);
|
||||||
|
return CommUtil.toJson(res ? Result.success(1) : Result.failed("批量删除失败"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询点位列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/list.do")
|
||||||
|
public PageData<PipeTopicMpoint> selectList(
|
||||||
|
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||||
|
@RequestParam(defaultValue = "10") Integer pageSize,
|
||||||
|
@RequestParam(required = false) String type) {
|
||||||
|
|
||||||
|
PageHelper.startPage(pageNum, pageSize);
|
||||||
|
String where = "where 1=1";
|
||||||
|
if (type != null && !type.isEmpty()) {
|
||||||
|
where += " AND type = '" + type + "'";
|
||||||
|
}
|
||||||
|
|
||||||
|
List<PipeTopicMpoint> list = pipeTopicMpointService.selectListByWhere(where);
|
||||||
|
PageInfo<PipeTopicMpoint> pageInfo = new PageInfo<>(list);
|
||||||
|
return new PageData<>(pageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 “管网专题页” 数据
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/getData.do")
|
||||||
|
public Result getData(@RequestParam(required = false) String type) {
|
||||||
|
String where = "where 1=1";
|
||||||
|
if (type != null && !type.isEmpty()) {
|
||||||
|
where += " AND type = '" + type + "'";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义 type 含义的映射关系
|
||||||
|
Map<String, String> typeMap = new HashMap<>();
|
||||||
|
typeMap.put("0", "污水厂");
|
||||||
|
typeMap.put("1", "新城南大道污水泵站");
|
||||||
|
typeMap.put("2", "神农西大道雨水泵站");
|
||||||
|
typeMap.put("3", "新祺周大道雨水泵站");
|
||||||
|
|
||||||
|
JSONArray jsonArray = new JSONArray();
|
||||||
|
try {
|
||||||
|
List<PipeTopicMpoint> list = pipeTopicMpointService.selectListByWhere(where);
|
||||||
|
if (list != null && list.size() > 0) {
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
PipeTopicMpoint item = list.get(i);
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
|
||||||
|
// 添加 type 信息(如果 type 存在)
|
||||||
|
if (type != null && !type.isEmpty()) {
|
||||||
|
jsonObject.put("type", type);
|
||||||
|
jsonObject.put("typeName", typeMap.getOrDefault(type, "未知类型"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.getIsConstant() == 1) { // 常量
|
||||||
|
if (item.getPointName().equals("调度模式")) {
|
||||||
|
jsonObject.put("parmvalue", "输送模式-常规输送");
|
||||||
|
} else {
|
||||||
|
jsonObject.put("parmvalue", item.getConstantValue());
|
||||||
|
}
|
||||||
|
jsonObject.put("mpcode", item.getPointCode());
|
||||||
|
jsonObject.put("mpname", item.getPointName());
|
||||||
|
jsonObject.put("measuredt", CommUtil.nowDate());
|
||||||
|
jsonObject.put("unit", "");
|
||||||
|
} else { // 读点位
|
||||||
|
MPoint mPoint = mPointService.selectById("",item.getPointCode());
|
||||||
|
if (mPoint != null) {
|
||||||
|
jsonObject.put("mpcode", mPoint.getMpointcode());
|
||||||
|
jsonObject.put("mpname", mPoint.getParmname());
|
||||||
|
jsonObject.put("parmvalue", mPoint.getParmvalue() != null ? mPoint.getParmvalue() : 0);
|
||||||
|
jsonObject.put("measuredt", mPoint.getMeasuredt());
|
||||||
|
jsonObject.put("unit", mPoint.getUnit() != null ? mPoint.getUnit() : "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jsonArray.add(jsonObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Result.success(jsonArray);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return Result.failed("无数据");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,271 @@
|
|||||||
|
package com.sipai.controller.data;
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.sipai.entity.base.Result;
|
||||||
|
import com.sipai.entity.common.PageData;
|
||||||
|
import com.sipai.entity.data.PipelineEquipment;
|
||||||
|
import com.sipai.entity.data.PipelineEquipmentMpoint;
|
||||||
|
import com.sipai.entity.enums.DeviceTypeEnum;
|
||||||
|
import com.sipai.service.data.PipelineEquipmentMpointService;
|
||||||
|
import com.sipai.service.data.PipelineEquipmentService;
|
||||||
|
import com.sipai.tools.CommUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管网设备列表
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/pipeline-equipment")
|
||||||
|
public class PipelineEquipmentController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PipelineEquipmentService pipelineEquipmentService;
|
||||||
|
@Autowired
|
||||||
|
private PipelineEquipmentMpointService pipelineEquipmentMpointService;
|
||||||
|
|
||||||
|
// 根据主键查询管道设备信息
|
||||||
|
@GetMapping("/selectById.do")
|
||||||
|
public Result selectByPrimaryKey(@RequestParam(value = "id") Integer id) {
|
||||||
|
PipelineEquipment pipelineEquipment = pipelineEquipmentService.selectByPrimaryKey(id);
|
||||||
|
if(pipelineEquipment!=null){
|
||||||
|
return Result.success(pipelineEquipment);
|
||||||
|
}else{
|
||||||
|
return Result.failed("设备不存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除指定主键的管道设备信息
|
||||||
|
@PostMapping("/deleteById.do")
|
||||||
|
public String deleteByPrimaryKey(@RequestParam(value = "id") Integer id) {
|
||||||
|
boolean res = pipelineEquipmentService.delete(id);
|
||||||
|
if(res){
|
||||||
|
Result result = Result.success(1);
|
||||||
|
return CommUtil.toJson(result);
|
||||||
|
}else{
|
||||||
|
Result result = Result.failed("0");
|
||||||
|
return CommUtil.toJson(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除指定主键的管道设备信息
|
||||||
|
@PostMapping("/deleteByIds.do")
|
||||||
|
public String deleteByIds(@RequestParam(value = "id") Integer id) {
|
||||||
|
boolean res = pipelineEquipmentService.delete(id);
|
||||||
|
if(res){
|
||||||
|
Result result = Result.success(1);
|
||||||
|
return CommUtil.toJson(result);
|
||||||
|
}else{
|
||||||
|
Result result = Result.failed("0");
|
||||||
|
return CommUtil.toJson(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//新增
|
||||||
|
@PostMapping("/save.do")
|
||||||
|
public String save(@ModelAttribute PipelineEquipment pipelineEquipment) {
|
||||||
|
int res = pipelineEquipmentService.insert(pipelineEquipment);
|
||||||
|
if (res > 0) {
|
||||||
|
int generatedId = pipelineEquipment.getId();
|
||||||
|
Result result = Result.success(generatedId);
|
||||||
|
return CommUtil.toJson(result);
|
||||||
|
}else{
|
||||||
|
Result result = Result.failed("0");
|
||||||
|
return CommUtil.toJson(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//修改
|
||||||
|
@PostMapping("/update.do")
|
||||||
|
public String update(@ModelAttribute PipelineEquipment pipelineEquipment) {
|
||||||
|
boolean res = pipelineEquipmentService.update(pipelineEquipment);
|
||||||
|
if(res){
|
||||||
|
Result result = Result.success(1);
|
||||||
|
return CommUtil.toJson(result);
|
||||||
|
}else{
|
||||||
|
Result result = Result.failed("0");
|
||||||
|
return CommUtil.toJson(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询管道设备列表
|
||||||
|
* @param pageNum
|
||||||
|
* @param pageSize
|
||||||
|
* @param equipmentTypeId 类型id
|
||||||
|
* @param stationCode 站号
|
||||||
|
* @param status 1在线 0离线 null为未检测
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/list.do")
|
||||||
|
public PageData<PipelineEquipment> selectListByWhere(
|
||||||
|
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||||
|
@RequestParam(defaultValue = "10") Integer pageSize,
|
||||||
|
@RequestParam(required = false) String equipmentTypeId,
|
||||||
|
@RequestParam(required = false) String stationCode,
|
||||||
|
@RequestParam(required = false) String status) {
|
||||||
|
|
||||||
|
// 设置分页参数
|
||||||
|
PageHelper.startPage(pageNum, pageSize);
|
||||||
|
|
||||||
|
// 构建查询条件
|
||||||
|
String where = "where 1=1";
|
||||||
|
//类型筛选
|
||||||
|
if (equipmentTypeId != null && !equipmentTypeId.isEmpty()) {
|
||||||
|
where += " AND equipment_type = '" + equipmentTypeId + "'";
|
||||||
|
}
|
||||||
|
//站号筛选
|
||||||
|
if (stationCode != null && !stationCode.isEmpty()) {
|
||||||
|
where += " AND station_code = '" + stationCode + "'";
|
||||||
|
}
|
||||||
|
//状态筛选
|
||||||
|
if (status != null && !status.isEmpty()) {
|
||||||
|
where += " AND status = '" + status + "'";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行查询
|
||||||
|
List<PipelineEquipment> list = pipelineEquipmentService.selectListByWhere(where);
|
||||||
|
|
||||||
|
// 封装分页信息
|
||||||
|
PageInfo<PipelineEquipment> pageInfo = new PageInfo<>(list);
|
||||||
|
|
||||||
|
// 返回分页数据
|
||||||
|
return new PageData<>(pageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取管网设备类型
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/device-types")
|
||||||
|
public List<Map<String, String>> getDeviceTypes() {
|
||||||
|
List<Map<String, String>> deviceTypes = new ArrayList<>();
|
||||||
|
for (DeviceTypeEnum deviceType : DeviceTypeEnum.values()) {
|
||||||
|
Map<String, String> deviceTypeMap = new HashMap<>();
|
||||||
|
deviceTypeMap.put("typeName", deviceType.getTypeName());
|
||||||
|
deviceTypeMap.put("typeCode", deviceType.getTypeCode());
|
||||||
|
deviceTypes.add(deviceTypeMap);
|
||||||
|
}
|
||||||
|
return deviceTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手动初始化关联 设备-点位 关系
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/hand-save.do")
|
||||||
|
public String handSave() {
|
||||||
|
|
||||||
|
//井盖
|
||||||
|
List<PipelineEquipment> list = pipelineEquipmentService.selectListByWhere("where equipment_type = '1'");
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
//格式:KCGW_21001_A1
|
||||||
|
String[] codes = new String[]{"A1", "A2", "A3", "A4", "A5", "Q10", "Q11", "Q12", "V1"};
|
||||||
|
String[] names = new String[]{"信号强度", "基站序号", "井盖角度", "电阻值1", "电阻值2", "电压报警", "水浸报警", "开盖报警", "电池电压"};
|
||||||
|
for (int j = 0; j < codes.length; j++) {
|
||||||
|
String mpcode = "KCGW_" + list.get(i).getStationCode() + "_" + codes[j];
|
||||||
|
PipelineEquipmentMpoint pipelineEquipmentMpoint = new PipelineEquipmentMpoint();
|
||||||
|
pipelineEquipmentMpoint.setPid(list.get(i).getId());
|
||||||
|
pipelineEquipmentMpoint.setMpcode(mpcode);
|
||||||
|
pipelineEquipmentMpoint.setMpname(names[j]);
|
||||||
|
pipelineEquipmentMpoint.setTag(codes[j]);
|
||||||
|
pipelineEquipmentMpointService.insert(pipelineEquipmentMpoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//流量计
|
||||||
|
List<PipelineEquipment> list2 = pipelineEquipmentService.selectListByWhere("where equipment_type = '2'");
|
||||||
|
for (int i = 0; i < list2.size(); i++) {
|
||||||
|
//格式:KCGW_21001_A1
|
||||||
|
String[] codes = new String[]{"A1", "A2", "A4", "A7", "A8", "P1", "P2", "P3"};
|
||||||
|
String[] names = new String[]{"过水面积","液位","温度","瞬时流量","流速","正向累计","反向累计","实际累计"};
|
||||||
|
for (int j = 0; j < codes.length; j++) {
|
||||||
|
String mpcode = "KCGW_" + list2.get(i).getStationCode() + "_" + codes[j];
|
||||||
|
PipelineEquipmentMpoint pipelineEquipmentMpoint = new PipelineEquipmentMpoint();
|
||||||
|
pipelineEquipmentMpoint.setPid(list2.get(i).getId());
|
||||||
|
pipelineEquipmentMpoint.setMpcode(mpcode);
|
||||||
|
pipelineEquipmentMpoint.setMpname(names[j]);
|
||||||
|
pipelineEquipmentMpoint.setTag(codes[j]);
|
||||||
|
pipelineEquipmentMpointService.insert(pipelineEquipmentMpoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//液位计
|
||||||
|
List<PipelineEquipment> list3 = pipelineEquipmentService.selectListByWhere("where equipment_type = '3'");
|
||||||
|
for (int i = 0; i < list3.size(); i++) {
|
||||||
|
//格式:KCGW_21001_A1
|
||||||
|
String[] codes = new String[]{"A1", "A2", "A3", "A4", "A5", "A6", "A8", "A10"};
|
||||||
|
String[] names = new String[]{"信号接收功率","信噪比","小区ID","倾斜角度","电池电压","投入式液位","雷达水位","综合液位"};
|
||||||
|
for (int j = 0; j < codes.length; j++) {
|
||||||
|
String mpcode = "KCGW_" + list3.get(i).getStationCode() + "_" + codes[j];
|
||||||
|
PipelineEquipmentMpoint pipelineEquipmentMpoint = new PipelineEquipmentMpoint();
|
||||||
|
pipelineEquipmentMpoint.setPid(list3.get(i).getId());
|
||||||
|
pipelineEquipmentMpoint.setMpcode(mpcode);
|
||||||
|
pipelineEquipmentMpoint.setMpname(names[j]);
|
||||||
|
pipelineEquipmentMpoint.setTag(codes[j]);
|
||||||
|
pipelineEquipmentMpointService.insert(pipelineEquipmentMpoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//电导率
|
||||||
|
List<PipelineEquipment> list4 = pipelineEquipmentService.selectListByWhere("where equipment_type = '4'");
|
||||||
|
for (int i = 0; i < list4.size(); i++) {
|
||||||
|
//格式:KCGW_21001_A1
|
||||||
|
String[] codes = new String[]{"A7", "A8", "V"};
|
||||||
|
String[] names = new String[]{"电导率","温度","电池电压"};
|
||||||
|
for (int j = 0; j < codes.length; j++) {
|
||||||
|
String mpcode = "KCGW_" + list4.get(i).getStationCode() + "_" + codes[j];
|
||||||
|
PipelineEquipmentMpoint pipelineEquipmentMpoint = new PipelineEquipmentMpoint();
|
||||||
|
pipelineEquipmentMpoint.setPid(list4.get(i).getId());
|
||||||
|
pipelineEquipmentMpoint.setMpcode(mpcode);
|
||||||
|
pipelineEquipmentMpoint.setMpname(names[j]);
|
||||||
|
pipelineEquipmentMpoint.setTag(codes[j]);
|
||||||
|
pipelineEquipmentMpointService.insert(pipelineEquipmentMpoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//雨量计
|
||||||
|
List<PipelineEquipment> list5 = pipelineEquipmentService.selectListByWhere("where equipment_type = '5'");
|
||||||
|
for (int i = 0; i < list5.size(); i++) {
|
||||||
|
//格式:KCGW_21001_A1
|
||||||
|
String[] codes = new String[]{"A1"};
|
||||||
|
String[] names = new String[]{"雨量值"};
|
||||||
|
for (int j = 0; j < codes.length; j++) {
|
||||||
|
String mpcode = "KCGW_" + list5.get(i).getStationCode() + "_" + codes[j];
|
||||||
|
PipelineEquipmentMpoint pipelineEquipmentMpoint = new PipelineEquipmentMpoint();
|
||||||
|
pipelineEquipmentMpoint.setPid(list5.get(i).getId());
|
||||||
|
pipelineEquipmentMpoint.setMpcode(mpcode);
|
||||||
|
pipelineEquipmentMpoint.setMpname(names[j]);
|
||||||
|
pipelineEquipmentMpoint.setTag(codes[j]);
|
||||||
|
pipelineEquipmentMpointService.insert(pipelineEquipmentMpoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//内涝监测
|
||||||
|
List<PipelineEquipment> list6 = pipelineEquipmentService.selectListByWhere("where equipment_type = '6'");
|
||||||
|
for (int i = 0; i < list6.size(); i++) {
|
||||||
|
//格式:KCGW_21001_A1
|
||||||
|
String[] codes = new String[]{"A13", "P14"};
|
||||||
|
String[] names = new String[]{"水位", "状态(有水/无水)"};
|
||||||
|
for (int j = 0; j < codes.length; j++) {
|
||||||
|
String mpcode = "KCGW_" + list6.get(i).getStationCode() + "_" + codes[j];
|
||||||
|
PipelineEquipmentMpoint pipelineEquipmentMpoint = new PipelineEquipmentMpoint();
|
||||||
|
pipelineEquipmentMpoint.setPid(list6.get(i).getId());
|
||||||
|
pipelineEquipmentMpoint.setMpcode(mpcode);
|
||||||
|
pipelineEquipmentMpoint.setMpname(names[j]);
|
||||||
|
pipelineEquipmentMpoint.setTag(codes[j]);
|
||||||
|
pipelineEquipmentMpointService.insert(pipelineEquipmentMpoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "suc";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,136 @@
|
|||||||
|
package com.sipai.controller.data;
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.sipai.entity.base.Result;
|
||||||
|
import com.sipai.entity.common.PageData;
|
||||||
|
import com.sipai.entity.data.PipelineEquipmentMpoint;
|
||||||
|
import com.sipai.entity.data.PipelineMpointLibrary;
|
||||||
|
import com.sipai.service.data.PipelineEquipmentMpointService;
|
||||||
|
import com.sipai.service.data.PipelineMpointLibraryService;
|
||||||
|
import com.sipai.tools.CommUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管网设备附属点位列表
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/pipeline-equipment-mpoint")
|
||||||
|
public class PipelineEquipmentMpointController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PipelineEquipmentMpointService pipelineEquipmentMpointService;
|
||||||
|
@Autowired
|
||||||
|
private PipelineMpointLibraryService pipelineMpointLibraryService;
|
||||||
|
|
||||||
|
// 根据主键查询管道设备与测点关联信息
|
||||||
|
@GetMapping("/selectById.do")
|
||||||
|
public Result selectByPrimaryKey(@RequestParam(value = "id") Integer id) {
|
||||||
|
PipelineEquipmentMpoint mpoint = pipelineEquipmentMpointService.selectByPrimaryKey(id);
|
||||||
|
if (mpoint != null) {
|
||||||
|
return Result.success(mpoint);
|
||||||
|
} else {
|
||||||
|
return Result.failed("关联信息不存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除指定主键的管道设备与测点关联信息
|
||||||
|
@PostMapping("/deleteById.do")
|
||||||
|
public String deleteByPrimaryKey(@RequestParam(value = "id") Integer id) {
|
||||||
|
boolean res = pipelineEquipmentMpointService.delete(id);
|
||||||
|
if (res) {
|
||||||
|
Result result = Result.success(1);
|
||||||
|
return CommUtil.toJson(result);
|
||||||
|
} else {
|
||||||
|
Result result = Result.failed("0");
|
||||||
|
return CommUtil.toJson(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增管道设备与测点关联信息
|
||||||
|
@PostMapping("/save.do")
|
||||||
|
public String save(@ModelAttribute PipelineEquipmentMpoint mpoint) {
|
||||||
|
boolean res = pipelineEquipmentMpointService.insert(mpoint);
|
||||||
|
if (res) {
|
||||||
|
Result result = Result.success(1);
|
||||||
|
return CommUtil.toJson(result);
|
||||||
|
} else {
|
||||||
|
Result result = Result.failed("0");
|
||||||
|
return CommUtil.toJson(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改管道设备与测点关联信息
|
||||||
|
@PostMapping("/update.do")
|
||||||
|
public String update(@ModelAttribute PipelineEquipmentMpoint mpoint) {
|
||||||
|
boolean res = pipelineEquipmentMpointService.update(mpoint);
|
||||||
|
if (res) {
|
||||||
|
Result result = Result.success(1);
|
||||||
|
return CommUtil.toJson(result);
|
||||||
|
} else {
|
||||||
|
Result result = Result.failed("0");
|
||||||
|
return CommUtil.toJson(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分页查询管道设备与测点关联信息列表
|
||||||
|
@GetMapping("/list.do")
|
||||||
|
public PageData<PipelineEquipmentMpoint> selectListByWhere(
|
||||||
|
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||||
|
@RequestParam(defaultValue = "10") Integer pageSize,
|
||||||
|
@RequestParam(required = false) String pid) {
|
||||||
|
|
||||||
|
// 设置分页参数
|
||||||
|
PageHelper.startPage(pageNum, pageSize);
|
||||||
|
|
||||||
|
// 构建查询条件
|
||||||
|
String where = "where 1=1";
|
||||||
|
if (pid != null && !pid.isEmpty()) {
|
||||||
|
where += " AND pid = '" + pid + "'";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行查询
|
||||||
|
List<PipelineEquipmentMpoint> list = pipelineEquipmentMpointService.selectListByWhere(where);
|
||||||
|
|
||||||
|
// 封装分页信息
|
||||||
|
PageInfo<PipelineEquipmentMpoint> pageInfo = new PageInfo<>(list);
|
||||||
|
|
||||||
|
// 返回分页数据
|
||||||
|
return new PageData<>(pageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据类型一键导入
|
||||||
|
*
|
||||||
|
* @param equipmentTypeId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/import4Type.do")
|
||||||
|
public String import4Type(@RequestParam(required = true) Integer pid,
|
||||||
|
@RequestParam(required = true) String equipmentTypeId) {
|
||||||
|
try{
|
||||||
|
// 构建查询条件
|
||||||
|
String where = "where 1=1 AND equipment_type = '" + equipmentTypeId + "'";
|
||||||
|
// 执行查询
|
||||||
|
List<PipelineMpointLibrary> list = pipelineMpointLibraryService.selectListByWhere(where);
|
||||||
|
if (list != null && list.size() > 0) {
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
PipelineEquipmentMpoint pipelineEquipmentMpoint = new PipelineEquipmentMpoint();
|
||||||
|
pipelineEquipmentMpoint.setPid(pid);
|
||||||
|
pipelineEquipmentMpoint.setTag(list.get(i).getCode());
|
||||||
|
pipelineEquipmentMpoint.setMpname(list.get(i).getName());
|
||||||
|
pipelineEquipmentMpointService.insert(pipelineEquipmentMpoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Result result = Result.success(1);
|
||||||
|
return CommUtil.toJson(result);
|
||||||
|
}catch (Exception e){
|
||||||
|
Result result = Result.failed("0");
|
||||||
|
return CommUtil.toJson(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,106 @@
|
|||||||
|
package com.sipai.controller.data;
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.sipai.entity.base.Result;
|
||||||
|
import com.sipai.entity.common.PageData;
|
||||||
|
import com.sipai.entity.data.PipelineMpointLibrary;
|
||||||
|
import com.sipai.service.data.PipelineMpointLibraryService;
|
||||||
|
import com.sipai.tools.CommUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/pipeline-mpoint-library")
|
||||||
|
public class PipelineMpointLibraryController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PipelineMpointLibraryService pipelineMpointLibraryService;
|
||||||
|
|
||||||
|
// 根据主键查询记录
|
||||||
|
@GetMapping("/selectById.do")
|
||||||
|
public PipelineMpointLibrary selectByPrimaryKey(@RequestParam(value = "id") String id) {
|
||||||
|
return pipelineMpointLibraryService.selectByPrimaryKey(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除指定主键的记录
|
||||||
|
@PostMapping("/deleteById.do")
|
||||||
|
public String deleteByPrimaryKey(@RequestParam(value = "id") String id) {
|
||||||
|
boolean res = pipelineMpointLibraryService.delete(id);
|
||||||
|
if (res) {
|
||||||
|
Result result = Result.success(1);
|
||||||
|
return CommUtil.toJson(result);
|
||||||
|
} else {
|
||||||
|
Result result = Result.failed("0");
|
||||||
|
return CommUtil.toJson(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 多删指定主键的记录
|
||||||
|
@PostMapping("/deleteByIds.do")
|
||||||
|
public String deleteByIds(@RequestParam(value = "ids") List<String> idList) {
|
||||||
|
int count = pipelineMpointLibraryService.deleteBatch(idList);
|
||||||
|
if (count > 0) {
|
||||||
|
Result result = Result.success(count);
|
||||||
|
return CommUtil.toJson(result);
|
||||||
|
} else {
|
||||||
|
Result result = Result.failed("0");
|
||||||
|
return CommUtil.toJson(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 插入记录
|
||||||
|
@PostMapping("/save.do")
|
||||||
|
public String save(@ModelAttribute PipelineMpointLibrary pipelineMpointLibrary) {
|
||||||
|
pipelineMpointLibrary.setId(CommUtil.getUUID());
|
||||||
|
boolean res = pipelineMpointLibraryService.insert(pipelineMpointLibrary);
|
||||||
|
if (res) {
|
||||||
|
Result result = Result.success(1);
|
||||||
|
return CommUtil.toJson(result);
|
||||||
|
} else {
|
||||||
|
Result result = Result.failed("0");
|
||||||
|
return CommUtil.toJson(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据主键选择性更新记录
|
||||||
|
@PostMapping("/update.do")
|
||||||
|
public String update(@ModelAttribute PipelineMpointLibrary pipelineMpointLibrary) {
|
||||||
|
boolean res = pipelineMpointLibraryService.update(pipelineMpointLibrary);
|
||||||
|
if (res) {
|
||||||
|
Result result = Result.success(1);
|
||||||
|
return CommUtil.toJson(result);
|
||||||
|
} else {
|
||||||
|
Result result = Result.failed("0");
|
||||||
|
return CommUtil.toJson(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分页查询列表
|
||||||
|
@GetMapping("/list.do")
|
||||||
|
public PageData<PipelineMpointLibrary> selectListByWhere(
|
||||||
|
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||||
|
@RequestParam(defaultValue = "10") Integer pageSize,
|
||||||
|
@RequestParam(required = false) String equipmentTypeId) {
|
||||||
|
|
||||||
|
// 设置分页参数
|
||||||
|
PageHelper.startPage(pageNum, pageSize);
|
||||||
|
|
||||||
|
// 构建查询条件
|
||||||
|
String where = "where 1=1";
|
||||||
|
if (equipmentTypeId != null && !equipmentTypeId.isEmpty()) {
|
||||||
|
where += " AND equipment_type = '" + equipmentTypeId + "'";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行查询
|
||||||
|
List<PipelineMpointLibrary> list = pipelineMpointLibraryService.selectListByWhere(where);
|
||||||
|
|
||||||
|
// 封装分页信息
|
||||||
|
PageInfo<PipelineMpointLibrary> pageInfo = new PageInfo<>(list);
|
||||||
|
|
||||||
|
// 返回分页数据
|
||||||
|
return new PageData<>(pageInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
package com.sipai.controller.kafka;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.kafka.core.KafkaTemplate;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/kafka")
|
||||||
|
public class KafkaController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private KafkaTemplate<String, String> kafkaTemplate;
|
||||||
|
|
||||||
|
@GetMapping("/testSendMessage")
|
||||||
|
public String readValue() {
|
||||||
|
String topic = "my-topic"; // 替换为你的主题名
|
||||||
|
String message = "Hello, Kafka!";
|
||||||
|
// 发送消息
|
||||||
|
kafkaTemplate.send(topic, message);
|
||||||
|
System.out.println("消息已发送: " + message);
|
||||||
|
return "suc";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,145 @@
|
|||||||
|
package com.sipai.controller.mqtt;
|
||||||
|
|
||||||
|
import com.sipai.entity.mqtt.MqttConfig;
|
||||||
|
import com.sipai.service.mqtt.MqttConfigService;
|
||||||
|
import com.sipai.tools.Result;
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||||
|
import org.eclipse.paho.client.mqttv3.MqttPersistenceException;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with IntelliJ IDEA.
|
||||||
|
*
|
||||||
|
* @Auther: sj
|
||||||
|
* @Date: 2021/04/22/14:30
|
||||||
|
* @Description: mqtt配置主表
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/mqttConfig")
|
||||||
|
public class MqttConfigController {
|
||||||
|
@Autowired
|
||||||
|
private MqttConfigService mqttConfigService;
|
||||||
|
|
||||||
|
@GetMapping("/getById")
|
||||||
|
public String getById() {
|
||||||
|
MqttConfig mqttConfig = mqttConfigService.selectByPrimaryKey("2");
|
||||||
|
if (mqttConfig != null) {
|
||||||
|
System.out.println(mqttConfig.getClientName());
|
||||||
|
} else {
|
||||||
|
System.out.println("无数据");
|
||||||
|
}
|
||||||
|
return "index";
|
||||||
|
}
|
||||||
|
|
||||||
|
//连接代理
|
||||||
|
@RequestMapping("/connectStart.do")
|
||||||
|
@ResponseBody
|
||||||
|
public Result connectStart(HttpServletRequest request, Model model) {
|
||||||
|
String id = request.getParameter("id");
|
||||||
|
mqttConfigService.connect(id);
|
||||||
|
Result res = Result.success(1);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连接 mqtt
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param model
|
||||||
|
*/
|
||||||
|
/*@GetMapping("/connect.do")
|
||||||
|
public void connect(HttpServletRequest request, Model model) {
|
||||||
|
String ids = request.getParameter("ids");
|
||||||
|
if (ids != null && !ids.equals("")) {
|
||||||
|
String[] idstr = ids.split(",");
|
||||||
|
for (int i = 0; i < idstr.length; i++) {
|
||||||
|
MqttConfig mqttConfig = mqttConfigService.selectByPrimaryKey(idstr[i]);
|
||||||
|
if (mqttConfig != null) {
|
||||||
|
String str = "http://" + request.getServerName() + ":" + mqttConfig.getTomcatPort() + "/mqttConfig/connectStart.do?id=" + idstr[i];
|
||||||
|
this.doPost(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
@GetMapping("/connect.do")
|
||||||
|
@ResponseBody
|
||||||
|
public Result connect(HttpServletRequest request, Model model) {
|
||||||
|
String ids = request.getParameter("ids");
|
||||||
|
if (ids != null && !ids.equals("")) {
|
||||||
|
String[] idstr = ids.split(",");
|
||||||
|
for (int i = 0; i < idstr.length; i++) {
|
||||||
|
MqttConfig mqttConfig = mqttConfigService.selectByPrimaryKey(idstr[i]);
|
||||||
|
if (mqttConfig != null) {
|
||||||
|
//String str = "http://" + request.getServerName() + ":" + mqttConfig.getTomcatPort() + "/mqttConfig/connectStart.do?id=" + idstr[i];
|
||||||
|
String str = "http://" + mqttConfig.getTomcatPort() + "/mqttConfig/connectStart.do?id=" + idstr[i];
|
||||||
|
this.doPost(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Result res = Result.success(1);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String doPost(String URL) {
|
||||||
|
OutputStreamWriter out = null;
|
||||||
|
BufferedReader in = null;
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
HttpURLConnection conn = null;
|
||||||
|
try {
|
||||||
|
java.net.URL url = new URL(URL);
|
||||||
|
conn = (HttpURLConnection) url.openConnection();
|
||||||
|
conn.setRequestMethod("POST");
|
||||||
|
//发送POST请求必须设置为true
|
||||||
|
conn.setDoOutput(true);
|
||||||
|
conn.setDoInput(true);
|
||||||
|
//设置连接超时时间和读取超时时间
|
||||||
|
conn.setConnectTimeout(30000);
|
||||||
|
conn.setReadTimeout(10000);
|
||||||
|
conn.setRequestProperty("Content-Type", "application/json");
|
||||||
|
conn.setRequestProperty("Accept", "application/json");
|
||||||
|
//获取输出流
|
||||||
|
out = new OutputStreamWriter(conn.getOutputStream());
|
||||||
|
String jsonStr = "{\"qry_by\":\"name\", \"name\":\"Tim\"}";
|
||||||
|
out.write(jsonStr);
|
||||||
|
out.flush();
|
||||||
|
out.close();
|
||||||
|
//取得输入流,并使用Reader读取
|
||||||
|
if (200 == conn.getResponseCode()) {
|
||||||
|
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
|
||||||
|
String line;
|
||||||
|
while ((line = in.readLine()) != null) {
|
||||||
|
result.append(line);
|
||||||
|
System.out.println(line);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.out.println("ResponseCode is an error code:" + conn.getResponseCode());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (out != null) {
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
if (in != null) {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
ioe.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
package com.sipai.controller.mqtt;
|
||||||
|
|
||||||
|
import com.sipai.entity.mqtt.MqttConfigTopic;
|
||||||
|
import com.sipai.service.mqtt.MqttConfigTopicService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with IntelliJ IDEA.
|
||||||
|
*
|
||||||
|
* @Auther: sj
|
||||||
|
* @Date: 2021/04/22/14:42
|
||||||
|
* @Description: mqtt配置主表
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/mqttConfigTopic")
|
||||||
|
public class MqttConfigTopicController {
|
||||||
|
@Autowired
|
||||||
|
private MqttConfigTopicService mqttConfigTopicService;
|
||||||
|
|
||||||
|
@RequestMapping("/save.do")
|
||||||
|
@ResponseBody
|
||||||
|
public Integer save(HttpServletRequest request, Model model,
|
||||||
|
@ModelAttribute("mqttConfigTopic") MqttConfigTopic mqttConfigTopic) {
|
||||||
|
return mqttConfigTopicService.insert(mqttConfigTopic);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/delete.do")
|
||||||
|
@ResponseBody
|
||||||
|
public int delete(HttpServletRequest request, Model model,
|
||||||
|
@ModelAttribute("id") String id) {
|
||||||
|
return mqttConfigTopicService.deleteByPrimaryKey(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
408
src/main/java/com/sipai/controller/mqtt/MqttController.java
Normal file
408
src/main/java/com/sipai/controller/mqtt/MqttController.java
Normal file
@ -0,0 +1,408 @@
|
|||||||
|
package com.sipai.controller.mqtt;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.sipai.entity.mqtt.MqttConfig;
|
||||||
|
import com.sipai.entity.mqtt.MqttConfigTopic;
|
||||||
|
import com.sipai.entity.scada.MPoint;
|
||||||
|
import com.sipai.entity.scada.MPointES;
|
||||||
|
import com.sipai.entity.user.Company;
|
||||||
|
import com.sipai.service.mqtt.MqttConfigService;
|
||||||
|
import com.sipai.service.mqtt.MqttConfigTopicService;
|
||||||
|
import com.sipai.service.mqtt.MqttService;
|
||||||
|
import com.sipai.service.scada.MPointService;
|
||||||
|
import com.sipai.service.user.CompanyService;
|
||||||
|
import com.sipai.tools.CommUtil;
|
||||||
|
import com.sipai.tools.Result;
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||||
|
import org.eclipse.paho.client.mqttv3.MqttPersistenceException;
|
||||||
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||||
|
import org.elasticsearch.index.query.QueryBuilders;
|
||||||
|
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
|
||||||
|
import org.elasticsearch.search.sort.SortBuilders;
|
||||||
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
|
import org.redisson.api.RMap;
|
||||||
|
import org.redisson.api.RedissonClient;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
|
||||||
|
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
|
||||||
|
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
import springfox.documentation.spring.web.json.Json;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/mqtt")
|
||||||
|
public class MqttController {
|
||||||
|
@Autowired
|
||||||
|
private MqttService mqttService;
|
||||||
|
@Autowired
|
||||||
|
private CompanyService companyService;
|
||||||
|
@Autowired
|
||||||
|
private MPointService mPointService;
|
||||||
|
@Autowired
|
||||||
|
private MqttConfigService mqttConfigService;
|
||||||
|
@Autowired
|
||||||
|
private MqttConfigTopicService mqttConfigTopicService;
|
||||||
|
@Autowired
|
||||||
|
private ElasticsearchTemplate elasticsearchTemplate;
|
||||||
|
@Autowired
|
||||||
|
private RedissonClient redissonClient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于提供云平台 查询指定网关是否在线 (单个网关)
|
||||||
|
* sj 2021-05-25
|
||||||
|
*/
|
||||||
|
@RequestMapping("/getClientStatus.do")
|
||||||
|
@ResponseBody
|
||||||
|
public String getClientStatus(HttpServletRequest request, Model model) {
|
||||||
|
String unitId = request.getParameter("unitId");//厂id
|
||||||
|
String line = null;
|
||||||
|
try {
|
||||||
|
URL url = new URL("http://172.16.242.16:28083/api/v4/clients/" + unitId + "_01");
|
||||||
|
Base64 b = new Base64();
|
||||||
|
String encoding = b.encodeAsString(new String("admin:public").getBytes());
|
||||||
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
|
connection.setRequestMethod("GET");
|
||||||
|
connection.setDoOutput(true);
|
||||||
|
connection.setRequestProperty("Content-Type", "application/json");
|
||||||
|
connection.setRequestProperty("Authorization", "Basic " + encoding);
|
||||||
|
InputStream content = (InputStream) connection.getInputStream();
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(content));
|
||||||
|
while ((line = in.readLine()) != null) {
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于提供云平台 返回所有在线的网关 (所有网关)
|
||||||
|
* sj 2021-05-25
|
||||||
|
*/
|
||||||
|
@RequestMapping("/getClientListStatus.do")
|
||||||
|
@ResponseBody
|
||||||
|
public String getClientListStatus() {
|
||||||
|
String line = null;
|
||||||
|
try {
|
||||||
|
URL url = new URL("http://172.16.242.16:28083/api/v4/clients/");
|
||||||
|
Base64 b = new Base64();
|
||||||
|
String encoding = b.encodeAsString(new String("admin:public").getBytes());
|
||||||
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
|
connection.setRequestMethod("GET");
|
||||||
|
connection.setDoOutput(true);
|
||||||
|
connection.setRequestProperty("Content-Type", "application/json");
|
||||||
|
connection.setRequestProperty("Authorization", "Basic " + encoding);
|
||||||
|
InputStream content = (InputStream) connection.getInputStream();
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(content));
|
||||||
|
while ((line = in.readLine()) != null) {
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
System.out.println(line);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据厂id,返回该厂所有的网关在线状态 (必须配置了_COM点)
|
||||||
|
* sj 2021-08-12
|
||||||
|
*/
|
||||||
|
@RequestMapping("/getClientListStatus4UnitId.do")
|
||||||
|
@ResponseBody
|
||||||
|
public String getClientListStatus4UnitId(HttpServletRequest request, Model model,
|
||||||
|
@ModelAttribute("unitId") String unitId) {
|
||||||
|
|
||||||
|
NativeSearchQueryBuilder nativeSearchQueryBuilder = new NativeSearchQueryBuilder();
|
||||||
|
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||||
|
BoolQueryBuilder childBoolQueryBuilder = QueryBuilders.boolQuery();
|
||||||
|
childBoolQueryBuilder.must(QueryBuilders.matchQuery("bizid", unitId));
|
||||||
|
childBoolQueryBuilder.must(QueryBuilders.matchQuery("signaltag", "COMMU"));
|
||||||
|
boolQueryBuilder.should(childBoolQueryBuilder);
|
||||||
|
nativeSearchQueryBuilder.withQuery(boolQueryBuilder);
|
||||||
|
nativeSearchQueryBuilder.withPageable(PageRequest.of(0, 300));
|
||||||
|
//先根据es找到改厂所有的通讯点,然后获取mpointId去网关中查询在线状态
|
||||||
|
List<MPoint> runMPoint = this.mPointService.selectListByWhere4Es(nativeSearchQueryBuilder);
|
||||||
|
String str = "";
|
||||||
|
String line = null;
|
||||||
|
JSONArray jsonArray = new JSONArray();
|
||||||
|
if (runMPoint.size() > 0) {
|
||||||
|
//循环所有网关
|
||||||
|
for (int i = 0; i < runMPoint.size(); i++) {
|
||||||
|
String mpointid = runMPoint.get(i).getMpointid();
|
||||||
|
String parmname = runMPoint.get(i).getParmname();
|
||||||
|
//网关id
|
||||||
|
mpointid = mpointid.replace("_COM", "");
|
||||||
|
|
||||||
|
try {
|
||||||
|
URL url = new URL("http://172.16.242.16:28083/api/v4/clients/" + mpointid);
|
||||||
|
Base64 b = new Base64();
|
||||||
|
String encoding = b.encodeAsString(new String("admin:public").getBytes());
|
||||||
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
|
connection.setRequestMethod("GET");
|
||||||
|
connection.setDoOutput(true);
|
||||||
|
connection.setRequestProperty("Content-Type", "application/json");
|
||||||
|
connection.setRequestProperty("Authorization", "Basic " + encoding);
|
||||||
|
InputStream content = (InputStream) connection.getInputStream();
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(content));
|
||||||
|
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(in.readLine());
|
||||||
|
String data = jsonObject.get("data").toString();
|
||||||
|
JSONArray jsonArrayStr = JSONArray.parseArray(data);
|
||||||
|
if (jsonArrayStr.size() > 0) {
|
||||||
|
//获取第一个网关对象
|
||||||
|
JSONObject jsonObjectStr = (JSONObject) jsonArrayStr.get(0);
|
||||||
|
|
||||||
|
JSONObject jsonData = new JSONObject();
|
||||||
|
jsonData.put("clientid", jsonObjectStr.get("clientid"));
|
||||||
|
jsonData.put("parmname", parmname);
|
||||||
|
jsonData.put("connected", true);//在线
|
||||||
|
jsonArray.add(jsonData);
|
||||||
|
} else {
|
||||||
|
JSONObject jsonData = new JSONObject();
|
||||||
|
jsonData.put("clientid", mpointid);
|
||||||
|
jsonData.put("parmname", parmname);
|
||||||
|
jsonData.put("connected", false);//不在线
|
||||||
|
jsonArray.add(jsonData);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return jsonArray.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于提供云平台 给plc发布指令接口
|
||||||
|
* sj 2021-05-25
|
||||||
|
*/
|
||||||
|
@RequestMapping("/doPublish4Vue.do")
|
||||||
|
@ResponseBody
|
||||||
|
public String doPublish4Vue(HttpServletRequest request, Model model) {
|
||||||
|
String mpid = request.getParameter("mpid");//测量点Id
|
||||||
|
String bizType = request.getParameter("bizType");//网关编号
|
||||||
|
String value = request.getParameter("value");//指令下发的值
|
||||||
|
String userId = request.getParameter("userId");//操作人员id
|
||||||
|
String rate = request.getParameter("rate");//倍率
|
||||||
|
String directtype = request.getParameter("directtype");//取反类型 1为取反 其余为正常
|
||||||
|
|
||||||
|
String topic = bizType + "_DOWN";
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
|
||||||
|
String bizId = bizType.substring(0, 7);
|
||||||
|
Company company = companyService.selectByPrimaryKey(bizId);
|
||||||
|
if (company != null) {
|
||||||
|
bizId = company.getPid();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
取反操作
|
||||||
|
*/
|
||||||
|
if (directtype != null && directtype.equals("1")) {
|
||||||
|
//取反
|
||||||
|
if (value.equals("0")) {
|
||||||
|
value = "1";
|
||||||
|
} else if (value.equals("1")) {
|
||||||
|
value = "0";
|
||||||
|
} else {
|
||||||
|
//正常
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//正常
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal val = null;
|
||||||
|
if (rate != null && !rate.equals("0")) {
|
||||||
|
BigDecimal num1 = new BigDecimal(value);
|
||||||
|
BigDecimal num2 = new BigDecimal(rate);
|
||||||
|
|
||||||
|
// MPoint mPoint = mPointService.selectById(bizId, mpid);
|
||||||
|
MPoint mPoint = mPointService.selectById(bizId,mpid);
|
||||||
|
//AO根据写入的小数位赋值
|
||||||
|
if (mPoint != null && mPoint.getSignaltype().equals("AO")) {
|
||||||
|
BigDecimal bd = new BigDecimal(String.valueOf(value));
|
||||||
|
// bd.scale() 为小数位
|
||||||
|
val = num1.divide(num2, bd.scale(), BigDecimal.ROUND_HALF_UP);
|
||||||
|
}
|
||||||
|
//DO截取0位
|
||||||
|
if (mPoint != null && mPoint.getSignaltype().equals("DO")) {
|
||||||
|
val = num1.divide(num2, 0, BigDecimal.ROUND_HALF_UP);
|
||||||
|
}
|
||||||
|
jsonObject.put("TagValue", val);
|
||||||
|
} else {
|
||||||
|
String str = String.valueOf(value);//浮点变量a转换为字符串str
|
||||||
|
int idx = str.lastIndexOf(".");//查找小数点的位置
|
||||||
|
if (idx == -1) {
|
||||||
|
jsonObject.put("TagValue", value);
|
||||||
|
} else {
|
||||||
|
String strNum = str.substring(0, idx);//截取从字符串开始到小数点位置的字符串,就是整数部分
|
||||||
|
int num = Integer.valueOf(strNum);//把整数部分通过Integer.valueof方法转换为数字
|
||||||
|
jsonObject.put("TagValue", num);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonObject.put("method", "setValue");
|
||||||
|
jsonObject.put("TagName", mpid);
|
||||||
|
|
||||||
|
int res = this.mqttService.doPublish(jsonObject, topic, userId, bizId);
|
||||||
|
String json = null;
|
||||||
|
if (res == 0) {
|
||||||
|
Result result = Result.success(res);
|
||||||
|
json = CommUtil.toJson(result);
|
||||||
|
} else {
|
||||||
|
Result result = Result.failed("指令下发失败");
|
||||||
|
json = CommUtil.toJson(result);
|
||||||
|
}
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网关数据全部召回(Recall) 传bizid召回该厂该网关的所有数据
|
||||||
|
* sj 2021-06-25
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param model
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping("/doRecall.do")
|
||||||
|
@ResponseBody
|
||||||
|
public String doRecall(HttpServletRequest request, Model model) {
|
||||||
|
String unitId = request.getParameter("unitId");//厂id
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("command", "Upload immediately");
|
||||||
|
mqttService.doRecall(unitId, jsonObject);
|
||||||
|
Result result = Result.success("");
|
||||||
|
String json = null;
|
||||||
|
json = CommUtil.toJson(result);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前端传主题,根据配置,查询属于哪个代理
|
||||||
|
* sj 2021-09-15
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param model
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping("/getEmqx4Topic.do")
|
||||||
|
@ResponseBody
|
||||||
|
public String getEmqx4Topic(HttpServletRequest request, Model model) {
|
||||||
|
String topic = request.getParameter("topic");//厂id
|
||||||
|
|
||||||
|
if (topic != null && topic.contains("_VUE")) {
|
||||||
|
topic = topic.replace("_VUE", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject jsonObject = mqttConfigService.getEmqxHost4WS(topic);
|
||||||
|
|
||||||
|
Result result = null;
|
||||||
|
if (jsonObject != null && jsonObject.size() > 0) {
|
||||||
|
result = Result.success(jsonObject);
|
||||||
|
} else {
|
||||||
|
result = Result.failed("无法查询该代理地址");
|
||||||
|
}
|
||||||
|
String json = null;
|
||||||
|
json = CommUtil.toJson(result);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 演示推送开始
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param model
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping("/startSend.do")
|
||||||
|
@ResponseBody
|
||||||
|
public String startSend(HttpServletRequest request, Model model) {
|
||||||
|
String mp1 = "SPF_XFJZ1_FV2"; //15-50 1秒加1
|
||||||
|
String mp2 = "SPF_XFJZ1_FV2_test1"; //15-50 1秒加1
|
||||||
|
String mp3 = "SPF_XFJZ1_FV2_test2"; //15-50 1秒加1
|
||||||
|
String mp4 = "SPF_XFJZ1_FL2"; //3000-8000 随机
|
||||||
|
String mp5 = "SPF_XFJZ1_FL2_test1"; //3000-8000 随机
|
||||||
|
String mp6 = "SPF_XFJZ1_FL2_test2"; //3000-8000 随机
|
||||||
|
String mp7 = "SPF_XFJZ1_RUN1_test";
|
||||||
|
|
||||||
|
RMap<String, Integer> map_list = redissonClient.getMap("test_mpoint");
|
||||||
|
map_list.fastPutAsync(mp1, 15);
|
||||||
|
map_list.fastPutAsync(mp2, 15);
|
||||||
|
map_list.fastPutAsync(mp3, 15);
|
||||||
|
map_list.fastPutAsync(mp4, 3000);
|
||||||
|
map_list.fastPutAsync(mp5, 3000);
|
||||||
|
map_list.fastPutAsync(mp6, 3000);
|
||||||
|
map_list.fastPutAsync(mp7, 1);
|
||||||
|
|
||||||
|
//将推送状态设置为no
|
||||||
|
RMap<String, String> map_status = redissonClient.getMap("test_mpoint_status");
|
||||||
|
map_status.fastPutAsync("status", "yes");
|
||||||
|
|
||||||
|
return "开始推送" + CommUtil.nowDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 演示推送开始
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param model
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping("/stopSend.do")
|
||||||
|
@ResponseBody
|
||||||
|
public String stopSend(HttpServletRequest request, Model model) {
|
||||||
|
|
||||||
|
String mp1 = "SPF_XFJZ1_FV2"; //15-50 1秒加1
|
||||||
|
String mp2 = "SPF_XFJZ1_FV2_test1"; //15-50 1秒加1
|
||||||
|
String mp3 = "SPF_XFJZ1_FV2_test2"; //15-50 1秒加1
|
||||||
|
String mp4 = "SPF_XFJZ1_FL2"; //3000-8000 随机
|
||||||
|
String mp5 = "SPF_XFJZ1_FL2_test1"; //3000-8000 随机
|
||||||
|
String mp6 = "SPF_XFJZ1_FL2_test2"; //3000-8000 随机
|
||||||
|
String mp7 = "SPF_XFJZ1_RUN1_test";
|
||||||
|
|
||||||
|
//数据置0
|
||||||
|
RMap<String, Integer> map_list = redissonClient.getMap("test_mpoint");
|
||||||
|
map_list.fastPutAsync(mp1, 0);
|
||||||
|
map_list.fastPutAsync(mp2, 0);
|
||||||
|
map_list.fastPutAsync(mp3, 0);
|
||||||
|
map_list.fastPutAsync(mp4, 0);
|
||||||
|
map_list.fastPutAsync(mp5, 0);
|
||||||
|
map_list.fastPutAsync(mp6, 0);
|
||||||
|
map_list.fastPutAsync(mp7, 0);
|
||||||
|
|
||||||
|
//推送数据
|
||||||
|
// mPointService.sendDataTest(map_list);
|
||||||
|
|
||||||
|
//将推送状态设置为no
|
||||||
|
RMap<String, String> map_status = redissonClient.getMap("test_mpoint_status");
|
||||||
|
map_status.fastPutAsync("status", "no");
|
||||||
|
|
||||||
|
return "关闭推送" + CommUtil.nowDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
108
src/main/java/com/sipai/controller/mqtt/WebHookController.java
Normal file
108
src/main/java/com/sipai/controller/mqtt/WebHookController.java
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
package com.sipai.controller.mqtt;
|
||||||
|
|
||||||
|
import com.alibaba.druid.util.StringUtils;
|
||||||
|
import com.sipai.entity.scada.MPoint;
|
||||||
|
import com.sipai.entity.scada.MPointHistory;
|
||||||
|
import com.sipai.entity.user.Company;
|
||||||
|
import com.sipai.service.mqtt.MqttService;
|
||||||
|
import com.sipai.service.scada.MPointHistoryService;
|
||||||
|
import com.sipai.service.scada.MPointService;
|
||||||
|
import com.sipai.service.user.CompanyService;
|
||||||
|
import com.sipai.tools.CommUtil;
|
||||||
|
import com.sipai.tools.ConstantString;
|
||||||
|
import com.sipai.tools.SpringContextUtil;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.MapUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过emqx webHook 获取所有设备的上下线消息 并存生产库 _COM点 如水口:MZ_SK11_C_01_COM
|
||||||
|
* sj 2021-05-24
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@AllArgsConstructor
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/webHook")
|
||||||
|
public class WebHookController {
|
||||||
|
@Autowired
|
||||||
|
private MqttService mqttService;
|
||||||
|
|
||||||
|
@PostMapping("/onJkWebHook")
|
||||||
|
public void onWebHook(@RequestBody Map<String, String> param) {
|
||||||
|
MPointService mPointService = (MPointService) SpringContextUtil.getBean("mPointService");
|
||||||
|
MPointHistoryService mPointHistoryService = (MPointHistoryService) SpringContextUtil.getBean("mPointHistoryService");
|
||||||
|
CompanyService companyService = (CompanyService) SpringContextUtil.getBean("companyService");
|
||||||
|
|
||||||
|
String action = MapUtils.getString(param, "action", "");
|
||||||
|
try {
|
||||||
|
String dt = "";//时间戳(秒)
|
||||||
|
String cid = "";//cid截取9位 为厂id
|
||||||
|
String dtime = "";//时间 (yyyy-MM-dd HH:mm:ss)
|
||||||
|
int st = 0;
|
||||||
|
//连接
|
||||||
|
if ("client_connected".equals(action)) {
|
||||||
|
cid = MapUtils.getString(param, "client_id", "");
|
||||||
|
if (StringUtils.isEmpty(cid)) {
|
||||||
|
cid = MapUtils.getString(param, "clientid", "");
|
||||||
|
}
|
||||||
|
dt = MapUtils.getString(param, "connected_at", "");
|
||||||
|
st = 1;
|
||||||
|
dtime = CommUtil.stampToDate(dt);
|
||||||
|
|
||||||
|
System.out.println("连接:cid=" + cid);
|
||||||
|
}
|
||||||
|
//断开连接
|
||||||
|
if ("client_disconnected".equals(action)) {
|
||||||
|
cid = MapUtils.getString(param, "client_id", "");
|
||||||
|
if (StringUtils.isEmpty(cid)) {
|
||||||
|
cid = MapUtils.getString(param, "clientid", "");
|
||||||
|
}
|
||||||
|
dt = MapUtils.getString(param, "disconnected_at", "");
|
||||||
|
st = 0;
|
||||||
|
dtime = CommUtil.stampToDate(dt);
|
||||||
|
|
||||||
|
System.out.println("断开:cid=" + cid);
|
||||||
|
}
|
||||||
|
String mpId = cid + "_COM";//测量点id
|
||||||
|
String bizId = cid.substring(0, 9);//厂id
|
||||||
|
Company company = companyService.selectByPrimaryKey(bizId);
|
||||||
|
if (company != null) {
|
||||||
|
bizId = company.getPid();
|
||||||
|
// MPoint mPoint = mPointService.selectById(bizId, mpId);
|
||||||
|
MPoint mPoint = mPointService.selectById(bizId,mpId);
|
||||||
|
if (mPoint != null) {
|
||||||
|
MPointHistory mPointHistory = new MPointHistory();
|
||||||
|
//修改主表
|
||||||
|
mPoint.setId(mPoint.getId());
|
||||||
|
mPoint.setMeasuredt(dtime);
|
||||||
|
mPoint.setParmvalue(new BigDecimal(st));
|
||||||
|
mPointService.update(mPoint);
|
||||||
|
//插入子表
|
||||||
|
mPointHistory.setMeasuredt(dtime);
|
||||||
|
mPointHistory.setParmvalue(new BigDecimal(st));
|
||||||
|
mPointHistory.setTbName("[tb_mp_" + mpId + "]");
|
||||||
|
mPointHistoryService.save(bizId, mPointHistory);
|
||||||
|
//System.out.println(mpId + "执行时间戳:" + CommUtil.stampToDate(dt));
|
||||||
|
|
||||||
|
//网关掉线发送至报警服务
|
||||||
|
System.out.println("设备掉线已推给报警服务(" + mpId + ")" + "----" + st);
|
||||||
|
mqttService.sentRabbitmq(ConstantString.MQ_ALARM_MQTT, mpId, st + "", dtime);
|
||||||
|
} else {
|
||||||
|
System.out.println("点不存在");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.out.println("厂不存在");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("通讯接口执行失败:" + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
96
src/main/java/com/sipai/controller/opc/OpcUaController.java
Normal file
96
src/main/java/com/sipai/controller/opc/OpcUaController.java
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
package com.sipai.controller.opc;
|
||||||
|
|
||||||
|
import com.sipai.service.opc.InitOpcUaService;
|
||||||
|
import com.sipai.service.opc.OpcUaService;
|
||||||
|
import org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/opcua")
|
||||||
|
public class OpcUaController {
|
||||||
|
|
||||||
|
private final OpcUaService opcUaService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InitOpcUaService initOpcUaService;
|
||||||
|
|
||||||
|
public OpcUaController(@Autowired(required = false) OpcUaService opcUaService) {
|
||||||
|
this.opcUaService = opcUaService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取单个OPC UA节点的值
|
||||||
|
*
|
||||||
|
* @param nodeId 节点ID,格式为:ns=2;s=通道 1.设备 1.标记3
|
||||||
|
* @return 节点值或错误信息
|
||||||
|
*/
|
||||||
|
@GetMapping("/read")
|
||||||
|
public Object readValue(@RequestParam String nodeId) {
|
||||||
|
if (opcUaService == null) {
|
||||||
|
return "OPC UA 未启动,请检查yml配置文件钟:opc: enabled: true";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return opcUaService.readNodeValue(nodeId);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "读取值错误: " + e.getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 写入单个OPC UA节点的值
|
||||||
|
*
|
||||||
|
* @param nodeId 节点ID,格式为:ns=2;s=通道 1.设备 1.标记3
|
||||||
|
* @param value 要写入的值
|
||||||
|
* @return 写入是否成功或错误信息
|
||||||
|
*/
|
||||||
|
@PostMapping("/write")
|
||||||
|
public String writeValue(@RequestParam String nodeId, @RequestParam Object value) {
|
||||||
|
if (opcUaService == null) {
|
||||||
|
return "OPC UA 未启动,请检查yml配置文件钟:opc: enabled: true";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
boolean success = opcUaService.writeNodeValue(nodeId, value);
|
||||||
|
return success ? "写入成功" : "写入失败";
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "写入错误: " + e.getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消订阅
|
||||||
|
*
|
||||||
|
* @param nodeId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/unsubscribeFromNode")
|
||||||
|
public String unsubscribeFromNode(@RequestParam String nodeId) {
|
||||||
|
if (opcUaService == null) {
|
||||||
|
return "OPC UA 未启动,请检查yml配置文件钟:opc: enabled: true";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
boolean success = opcUaService.unsubscribeFromNode(nodeId);
|
||||||
|
return success ? "取消成功" : "取消失败";
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "取消错误: " + e.getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步opcua订阅点位(查询es中opcua的采集点位,将不需要的点位取消订阅)-一般默认1小时会进行一次同步,有些点位修改总表或es后可手动调用一次立即同步
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/sysSub")
|
||||||
|
public String sysSub() {
|
||||||
|
if (opcUaService == null) {
|
||||||
|
return "OPC UA 未启动,请检查yml配置文件钟:opc: enabled: true";
|
||||||
|
}
|
||||||
|
initOpcUaService.manualSyncSubscriptions();
|
||||||
|
return "suc";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package com.sipai.controller.rabbitmq;
|
||||||
|
|
||||||
|
import com.sipai.service.rabbitmq.MQService;
|
||||||
|
import com.sipai.tools.ConstantString;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/mq")
|
||||||
|
@Api(value = "/mq", tags = "发送RabbitMQ消息")
|
||||||
|
public class MQController {
|
||||||
|
@Autowired
|
||||||
|
private MQService mQService;
|
||||||
|
|
||||||
|
@RequestMapping("sendMQ")
|
||||||
|
@ApiOperation(value = "发送消息", notes = "发送消息", httpMethod = "POST")
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求参数没填好")})
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "msg", value = "msg", dataType = "String", paramType = "query", example = "YES! PPG", required = true),
|
||||||
|
})
|
||||||
|
public String sendMQ(@RequestParam(value = "msg", required = false, defaultValue = "YES! PPG") String msg) {
|
||||||
|
this.mQService.sendMQ(ConstantString.MQ_ALARM_MQTT, msg);
|
||||||
|
return "success";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
114
src/main/java/com/sipai/controller/scada/MPointController.java
Normal file
114
src/main/java/com/sipai/controller/scada/MPointController.java
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
package com.sipai.controller.scada;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.sipai.config.AppConfig;
|
||||||
|
import com.sipai.entity.scada.MPoint;
|
||||||
|
import com.sipai.entity.user.Company;
|
||||||
|
import com.sipai.entity.user.User;
|
||||||
|
import com.sipai.service.scada.MPointService;
|
||||||
|
import com.sipai.tools.CommString;
|
||||||
|
import com.sipai.tools.Result;
|
||||||
|
import org.redisson.api.RMapCache;
|
||||||
|
import org.redisson.api.RedissonClient;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with IntelliJ IDEA.
|
||||||
|
*
|
||||||
|
* @Auther: 你的名字
|
||||||
|
* @Date: 2021/04/25/21:42
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/mPoint")
|
||||||
|
public class MPointController {
|
||||||
|
@Autowired
|
||||||
|
private MPointService mPointService;
|
||||||
|
@Autowired
|
||||||
|
private RedissonClient redissonClient;
|
||||||
|
@Autowired
|
||||||
|
private AppConfig appConfig;
|
||||||
|
|
||||||
|
@RequestMapping("/update.do")
|
||||||
|
@ResponseBody
|
||||||
|
public Integer update(HttpServletRequest request, Model model,
|
||||||
|
@ModelAttribute("mPoint") MPoint mPoint,
|
||||||
|
@ModelAttribute("bizid") String bizid) {
|
||||||
|
return mPointService.update(mPoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/selectById.do")
|
||||||
|
@ResponseBody
|
||||||
|
public MPoint selectById(HttpServletRequest request, Model model,
|
||||||
|
@ModelAttribute(value = "id") String id) {
|
||||||
|
MPoint mPoint = mPointService.selectById4Es(id);
|
||||||
|
return mPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管网平台获取实时数据接口
|
||||||
|
* @param request
|
||||||
|
* @param model
|
||||||
|
* @param mpcode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping("/getDataByMpCode.do")
|
||||||
|
@ResponseBody
|
||||||
|
public Result getDataByMpCode(HttpServletRequest request, Model model,
|
||||||
|
@ModelAttribute(value = "mpcode") String mpcode) {
|
||||||
|
JSONArray jsonArray = new JSONArray();
|
||||||
|
|
||||||
|
String[] mpcodes = mpcode.split(",");
|
||||||
|
if (mpcodes != null && mpcodes.length > 0) {
|
||||||
|
if (mpcodes.length > appConfig.getMaxPoints()) {
|
||||||
|
Result res = Result.failed("一次最多处理" + appConfig.getMaxPoints() + "个点位");
|
||||||
|
return res;
|
||||||
|
} else {
|
||||||
|
System.out.println("收到点位(" + mpcodes.length + "个):");
|
||||||
|
}
|
||||||
|
|
||||||
|
String ids = "";
|
||||||
|
for (int i = 0; i < mpcodes.length; i++) {
|
||||||
|
ids += "'" + mpcodes[i] + "',";
|
||||||
|
}
|
||||||
|
ids = ids.substring(0, ids.length() - 1);
|
||||||
|
|
||||||
|
Map<String, String> map = new HashMap<>();
|
||||||
|
List<MPoint> list = mPointService.selectListByWhere("where 1=1 and id in (" + ids + ")");
|
||||||
|
for (MPoint mPoint : list) {
|
||||||
|
if (mPoint.getParmvalue() != null && mPoint.getMeasuredt() != null) {
|
||||||
|
map.put(mPoint.getId(), mPoint.getParmvalue() + ";" + mPoint.getMeasuredt());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < mpcodes.length; i++) {
|
||||||
|
if (map.get(mpcodes[i]) != null) {
|
||||||
|
String[] val = map.get(mpcodes[i]).split(";");
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("mpcode", mpcodes[i]);
|
||||||
|
jsonObject.put("parmvalue", val[0]);
|
||||||
|
jsonObject.put("measuredt", val[1].length() > 19 ? val[1].substring(0, 19) : val[1]);
|
||||||
|
jsonArray.add(jsonObject);
|
||||||
|
} else {
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("mpcode", mpcodes[i]);
|
||||||
|
jsonObject.put("parmvalue", "");
|
||||||
|
jsonObject.put("measuredt", "");
|
||||||
|
jsonArray.add(jsonObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Result res = Result.success(jsonArray);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
package com.sipai.controller.user;
|
||||||
|
|
||||||
|
import com.sipai.entity.user.Company;
|
||||||
|
import com.sipai.service.user.CompanyService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with IntelliJ IDEA.
|
||||||
|
*
|
||||||
|
* @Auther: 你的名字
|
||||||
|
* @Date: 2021/04/25/21:15
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/company")
|
||||||
|
public class CompanyController {
|
||||||
|
@Autowired
|
||||||
|
private CompanyService companyService;
|
||||||
|
|
||||||
|
@RequestMapping("/save.do")
|
||||||
|
@ResponseBody
|
||||||
|
public Integer save(HttpServletRequest request, Model model,
|
||||||
|
@ModelAttribute("company") Company company) {
|
||||||
|
return companyService.insert(company);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/delete.do")
|
||||||
|
@ResponseBody
|
||||||
|
public int delete(HttpServletRequest request, Model model,
|
||||||
|
@ModelAttribute("id") String id) {
|
||||||
|
return companyService.deleteByPrimaryKey(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
35
src/main/java/com/sipai/controller/user/UserController.java
Normal file
35
src/main/java/com/sipai/controller/user/UserController.java
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package com.sipai.controller.user;
|
||||||
|
|
||||||
|
import com.sipai.entity.user.User;
|
||||||
|
import com.sipai.service.user.UserService;
|
||||||
|
import com.sipai.tools.Result;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/user")
|
||||||
|
public class UserController {
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
|
@RequestMapping(value = "/test1")
|
||||||
|
@ResponseBody
|
||||||
|
public Result index(HttpServletRequest request) {
|
||||||
|
Result result = Result.success(1);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/test2")
|
||||||
|
@ResponseBody
|
||||||
|
public Result index2(HttpServletRequest request) {
|
||||||
|
Result result = Result.failed("");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
24
src/main/java/com/sipai/dao/Listener/ListenerHisDao.java
Normal file
24
src/main/java/com/sipai/dao/Listener/ListenerHisDao.java
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package com.sipai.dao.Listener;
|
||||||
|
|
||||||
|
import com.sipai.dao.base.CommDaoImpl;
|
||||||
|
import com.sipai.entity.Listener.ListenerHis;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class ListenerHisDao extends CommDaoImpl<ListenerHis> {
|
||||||
|
|
||||||
|
public ListenerHisDao() {
|
||||||
|
super();
|
||||||
|
this.setMappernamespace("Listener.ListenerHisMapper");
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ListenerHis> selectTopByWhere(String where) {
|
||||||
|
ListenerHis listenerHis = new ListenerHis();
|
||||||
|
listenerHis.setWhere(where);
|
||||||
|
List<ListenerHis> list = this.getSqlSession().selectList("Listener.ListenerHisMapper.selectTopByWhere", listenerHis);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package com.sipai.dao.Listener;
|
||||||
|
|
||||||
|
import com.sipai.dao.base.CommDaoImpl;
|
||||||
|
import com.sipai.entity.Listener.ListenerInterface;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class ListenerInterfaceDao extends CommDaoImpl<ListenerInterface> {
|
||||||
|
|
||||||
|
public ListenerInterfaceDao() {
|
||||||
|
super();
|
||||||
|
this.setMappernamespace("Listener.ListenerInterfaceMapper");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
15
src/main/java/com/sipai/dao/Listener/ListenerMessageDao.java
Normal file
15
src/main/java/com/sipai/dao/Listener/ListenerMessageDao.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package com.sipai.dao.Listener;
|
||||||
|
|
||||||
|
import com.sipai.dao.base.CommDaoImpl;
|
||||||
|
import com.sipai.entity.Listener.ListenerMessage;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class ListenerMessageDao extends CommDaoImpl<ListenerMessage> {
|
||||||
|
|
||||||
|
public ListenerMessageDao() {
|
||||||
|
super();
|
||||||
|
this.setMappernamespace("Listener.ListenerMessageMapper");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
15
src/main/java/com/sipai/dao/Listener/ListenerPointDao.java
Normal file
15
src/main/java/com/sipai/dao/Listener/ListenerPointDao.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package com.sipai.dao.Listener;
|
||||||
|
|
||||||
|
import com.sipai.dao.base.CommDaoImpl;
|
||||||
|
import com.sipai.entity.Listener.ListenerPoint;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class ListenerPointDao extends CommDaoImpl<ListenerPoint> {
|
||||||
|
|
||||||
|
public ListenerPointDao() {
|
||||||
|
super();
|
||||||
|
this.setMappernamespace("Listener.ListenerPointMapper");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
125
src/main/java/com/sipai/dao/base/CommDao.java
Normal file
125
src/main/java/com/sipai/dao/base/CommDao.java
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
package com.sipai.dao.base;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
public interface CommDao<T>{
|
||||||
|
/**====基础的CURD操作====**/
|
||||||
|
/**
|
||||||
|
* 根据id查找唯一对象
|
||||||
|
* @param
|
||||||
|
* @param t
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public T selectByPrimaryKey(String t);
|
||||||
|
/**
|
||||||
|
* 根据id删除唯一对象
|
||||||
|
* @param
|
||||||
|
* @param t
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int deleteByPrimaryKey(String t);
|
||||||
|
/**
|
||||||
|
* 根据对象信息插入数据
|
||||||
|
* @param
|
||||||
|
* @param t
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int insert(T t);
|
||||||
|
/**
|
||||||
|
* 根据对象信息插入数据,只插入不为null的字段,不会影响有默认值的字段
|
||||||
|
* @param
|
||||||
|
* @param t
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
// public int insertSelective(T t);
|
||||||
|
/**
|
||||||
|
* 根据对象信息更新数据,只跟新不为null的字段
|
||||||
|
* @param
|
||||||
|
* @param t
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int updateByPrimaryKeySelective(T t);
|
||||||
|
/**
|
||||||
|
* 根据对象id信息更新数据,只跟新不为null的字段
|
||||||
|
* @param
|
||||||
|
* @param t
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
// public int updateByPrimaryKey(T t);
|
||||||
|
|
||||||
|
/**=====扩展的查询=====**/
|
||||||
|
/**
|
||||||
|
* 根据where条件查找唯一对象
|
||||||
|
* @param
|
||||||
|
* @param t
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public T selectByWhere(T t);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据where条件查找对象列表
|
||||||
|
* @param
|
||||||
|
* @param t
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<T> selectList(T t);
|
||||||
|
/**
|
||||||
|
* 查找和t某些值相等的对象列表
|
||||||
|
* @param
|
||||||
|
* @param t
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据where条件查找对象列表
|
||||||
|
* @param
|
||||||
|
* @param t
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<T> selectListByWhere(T t);
|
||||||
|
/**
|
||||||
|
* 查找和t某些值相等的对象列表
|
||||||
|
* @param
|
||||||
|
* @param t
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<T> selectListByObj(T t);
|
||||||
|
/**
|
||||||
|
* 根据sql语句查找对象列表
|
||||||
|
* @param
|
||||||
|
* @param t
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<T> selectListBySql(T t);
|
||||||
|
/**
|
||||||
|
* 根据sql语句查询唯一字段值
|
||||||
|
* @param
|
||||||
|
* @param t
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Object selectValueBySql(T t);
|
||||||
|
/**
|
||||||
|
* 根据where条件删除
|
||||||
|
* @param
|
||||||
|
* @param t
|
||||||
|
*/
|
||||||
|
public int deleteByWhere(T t);
|
||||||
|
/**
|
||||||
|
* 根据where条件更新
|
||||||
|
* @param
|
||||||
|
* @param t
|
||||||
|
*/
|
||||||
|
public int updateByWhere(T t);
|
||||||
|
/**
|
||||||
|
* 执行sql语句 :增,删,改
|
||||||
|
* @param
|
||||||
|
* @param t
|
||||||
|
*/
|
||||||
|
public int executeSql(T t);
|
||||||
|
public void commit();
|
||||||
|
public void close();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
151
src/main/java/com/sipai/dao/base/CommDaoImpl.java
Normal file
151
src/main/java/com/sipai/dao/base/CommDaoImpl.java
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
package com.sipai.dao.base;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class CommDaoImpl<T> implements CommDao<T> {
|
||||||
|
@Resource
|
||||||
|
private SqlSessionFactory sqlSessionFactory;
|
||||||
|
@Resource
|
||||||
|
private SqlSession sqlSession;
|
||||||
|
private String mappernamespace; // 需要操作的mappernamespace名(也是数据库表名)
|
||||||
|
private boolean isAuto = true;// 默认自动提交
|
||||||
|
|
||||||
|
public CommDaoImpl() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SqlSessionFactory getSqlSessionFactory() {
|
||||||
|
return sqlSessionFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
|
||||||
|
this.sqlSessionFactory = sqlSessionFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAuto() {
|
||||||
|
return isAuto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuto(boolean isAuto) {
|
||||||
|
this.isAuto = isAuto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMappernamespace() {
|
||||||
|
return mappernamespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMappernamespace(String mappernamespace) {
|
||||||
|
this.mappernamespace = mappernamespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T selectByPrimaryKey(String t){
|
||||||
|
T o = getSqlSession().selectOne(mappernamespace+"."+Thread.currentThread().getStackTrace()[1].getMethodName(), t);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* wxp为activiti测试修改
|
||||||
|
* @param t
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public T selectByID(BigDecimal t){
|
||||||
|
T o = getSqlSession().selectOne(mappernamespace+"."+Thread.currentThread().getStackTrace()[1].getMethodName(), t);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
public int deleteByPrimaryKey(String t) {
|
||||||
|
return getSqlSession().delete(mappernamespace+"."+Thread.currentThread().getStackTrace()[1].getMethodName(), t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int insert(T t){
|
||||||
|
return getSqlSession().insert(mappernamespace+"."+Thread.currentThread().getStackTrace()[1].getMethodName(), t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int insertSelective(T t){
|
||||||
|
return getSqlSession().insert(mappernamespace+"."+Thread.currentThread().getStackTrace()[1].getMethodName(), t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int updateByPrimaryKeySelective(T t){
|
||||||
|
return getSqlSession().update(mappernamespace+"."+Thread.currentThread().getStackTrace()[1].getMethodName(), t);
|
||||||
|
}
|
||||||
|
|
||||||
|
// public int updateByPrimaryKey(T t){
|
||||||
|
// return getSqlSession().update(mappernamespace+"."+Thread.currentThread().getStackTrace()[1].getMethodName(), t);
|
||||||
|
// }
|
||||||
|
|
||||||
|
public T selectByWhere( T t) {
|
||||||
|
List<T> list = getSqlSession().selectList(mappernamespace+"."+Thread.currentThread().getStackTrace()[1].getMethodName(), t);
|
||||||
|
if (list != null && list.size() > 0) {
|
||||||
|
return list.get(0);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<T> selectList(T t) {
|
||||||
|
List<T> list = getSqlSession().selectList(mappernamespace+"."+Thread.currentThread().getStackTrace()[1].getMethodName(), t);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<T> selectListByWhere( T t) {
|
||||||
|
List<T> list = getSqlSession().selectList(mappernamespace+"."+Thread.currentThread().getStackTrace()[1].getMethodName(), t);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<T> selectListByObj(T t) {
|
||||||
|
List<T> list = getSqlSession().selectList(mappernamespace+"."+Thread.currentThread().getStackTrace()[1].getMethodName(), t);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
public List<T> selectListByt( T t) {
|
||||||
|
List<T> list = getSqlSession().selectList(mappernamespace+"."+Thread.currentThread().getStackTrace()[1].getMethodName(), t);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<T> selectListBySql( T t) {
|
||||||
|
List<T> list = getSqlSession().selectList(mappernamespace+"."+Thread.currentThread().getStackTrace()[1].getMethodName(), t);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T selectValueBySql( T t) {
|
||||||
|
List<T> list = getSqlSession().selectList(mappernamespace+"."+Thread.currentThread().getStackTrace()[1].getMethodName(), t);
|
||||||
|
if (list != null && list.size() > 0) {
|
||||||
|
return list.get(0);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int deleteByWhere( T t) {
|
||||||
|
return this.getSqlSession().delete(mappernamespace+"."+Thread.currentThread().getStackTrace()[1].getMethodName(), t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int updateByWhere( T t) {
|
||||||
|
return this.getSqlSession().update(mappernamespace+"."+Thread.currentThread().getStackTrace()[1].getMethodName(), t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int executeSql( T t) {
|
||||||
|
return this.getSqlSession().update(mappernamespace+"."+Thread.currentThread().getStackTrace()[1].getMethodName(), t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void commit() {
|
||||||
|
if (sqlSession != null)
|
||||||
|
sqlSession.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SqlSession getSqlSession() {
|
||||||
|
sqlSession = sqlSession == null ? sqlSessionFactory.openSession(isAuto) : sqlSession;
|
||||||
|
return sqlSession;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
if (sqlSession != null)
|
||||||
|
sqlSession.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
43
src/main/java/com/sipai/dao/data/PipeTopicMpointDao.java
Normal file
43
src/main/java/com/sipai/dao/data/PipeTopicMpointDao.java
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package com.sipai.dao.data;
|
||||||
|
|
||||||
|
import com.sipai.entity.data.PipeTopicMpoint;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
@Repository
|
||||||
|
public interface PipeTopicMpointDao {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加管网专题页点位信息
|
||||||
|
*/
|
||||||
|
int insert(PipeTopicMpoint pipeTopicMpoint);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据主键删除点位信息
|
||||||
|
*/
|
||||||
|
boolean deleteByPrimaryKey(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除点位信息
|
||||||
|
*/
|
||||||
|
int deleteBatchByIds(@Param("list") List<Integer> idList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新点位信息
|
||||||
|
*/
|
||||||
|
boolean updateByPrimaryKeySelective(PipeTopicMpoint pipeTopicMpoint);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据主键获取点位详情
|
||||||
|
*/
|
||||||
|
PipeTopicMpoint selectByPrimaryKey(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据条件查询点位列表
|
||||||
|
*/
|
||||||
|
List<PipeTopicMpoint> selectListByWhere(PipeTopicMpoint pipeTopicMpoint);
|
||||||
|
}
|
||||||
47
src/main/java/com/sipai/dao/data/PipelineEquipmentDao.java
Normal file
47
src/main/java/com/sipai/dao/data/PipelineEquipmentDao.java
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
package com.sipai.dao.data;
|
||||||
|
|
||||||
|
import com.sipai.dao.base.CommDaoImpl;
|
||||||
|
import com.sipai.entity.data.PipelineEquipment;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
@Repository
|
||||||
|
public interface PipelineEquipmentDao{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加设备
|
||||||
|
*/
|
||||||
|
int insert(PipelineEquipment pipelineEquipment);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除设备
|
||||||
|
*/
|
||||||
|
boolean deleteByPrimaryKey(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多删设备
|
||||||
|
* @param idList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int deleteBatchByIds(@Param("list") List<Integer> idList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新设备信息
|
||||||
|
*/
|
||||||
|
boolean updateByPrimaryKeySelective(PipelineEquipment equipment);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备详情
|
||||||
|
*/
|
||||||
|
PipelineEquipment selectByPrimaryKey(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有设备列表
|
||||||
|
*/
|
||||||
|
List<PipelineEquipment> selectListByWhere(PipelineEquipment equipment);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
package com.sipai.dao.data;
|
||||||
|
|
||||||
|
import com.sipai.entity.data.PipelineEquipmentMpoint;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
@Repository
|
||||||
|
public interface PipelineEquipmentMpointDao {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加关联信息
|
||||||
|
*/
|
||||||
|
boolean insert(PipelineEquipmentMpoint mpoint);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除关联信息
|
||||||
|
*/
|
||||||
|
boolean deleteByPrimaryKey(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新关联信息
|
||||||
|
*/
|
||||||
|
boolean updateByPrimaryKeySelective(PipelineEquipmentMpoint mpoint);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取关联信息详情
|
||||||
|
*/
|
||||||
|
PipelineEquipmentMpoint selectByPrimaryKey(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有关联信息列表
|
||||||
|
*/
|
||||||
|
List<PipelineEquipmentMpoint> selectListByWhere(PipelineEquipmentMpoint mpoint);
|
||||||
|
}
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
package com.sipai.dao.data;
|
||||||
|
|
||||||
|
import com.sipai.entity.data.PipelineMpointLibrary;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
@Repository
|
||||||
|
public interface PipelineMpointLibraryDao {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加测点库信息
|
||||||
|
*/
|
||||||
|
boolean insert(PipelineMpointLibrary mpointLibrary);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除测点库信息
|
||||||
|
*/
|
||||||
|
boolean deleteByPrimaryKey(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多删测点库信息
|
||||||
|
* @param idList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int deleteBatchByIds(@Param("list") List<String> idList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新测点库信息
|
||||||
|
*/
|
||||||
|
boolean updateByPrimaryKeySelective(PipelineMpointLibrary mpointLibrary);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取测点库详情
|
||||||
|
*/
|
||||||
|
PipelineMpointLibrary selectByPrimaryKey(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有测点库列表
|
||||||
|
*/
|
||||||
|
List<PipelineMpointLibrary> selectListByWhere(PipelineMpointLibrary mpointLibrary);
|
||||||
|
}
|
||||||
32
src/main/java/com/sipai/dao/mqtt/MqttConfigDao.java
Normal file
32
src/main/java/com/sipai/dao/mqtt/MqttConfigDao.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package com.sipai.dao.mqtt;
|
||||||
|
|
||||||
|
import com.sipai.entity.mqtt.MqttConfig;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with IntelliJ IDEA.
|
||||||
|
*
|
||||||
|
* @Auther: 你的名字
|
||||||
|
* @Date: 2021/03/24/17:14
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
@Repository
|
||||||
|
public interface MqttConfigDao {
|
||||||
|
|
||||||
|
public abstract MqttConfig selectByPrimaryKey(String id);
|
||||||
|
|
||||||
|
public abstract Integer deleteByPrimaryKey(String id);
|
||||||
|
|
||||||
|
public abstract Integer insert(MqttConfig entity);
|
||||||
|
|
||||||
|
public abstract Integer updateByPrimaryKeySelective(MqttConfig entity);
|
||||||
|
|
||||||
|
public abstract List<MqttConfig> selectListByWhere(MqttConfig entity);
|
||||||
|
|
||||||
|
public abstract Integer deleteByWhere(String where);
|
||||||
|
|
||||||
|
}
|
||||||
34
src/main/java/com/sipai/dao/mqtt/MqttConfigTopicDao.java
Normal file
34
src/main/java/com/sipai/dao/mqtt/MqttConfigTopicDao.java
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package com.sipai.dao.mqtt;
|
||||||
|
|
||||||
|
import com.sipai.entity.mqtt.MqttConfigTopic;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with IntelliJ IDEA.
|
||||||
|
*
|
||||||
|
* @Auther: 你的名字
|
||||||
|
* @Date: 2021/03/24/17:55
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
@Repository
|
||||||
|
public interface MqttConfigTopicDao {
|
||||||
|
|
||||||
|
public abstract MqttConfigTopic selectByPrimaryKey(String id);
|
||||||
|
|
||||||
|
public abstract Integer deleteByPrimaryKey(String id);
|
||||||
|
|
||||||
|
public abstract Integer insert(MqttConfigTopic entity);
|
||||||
|
|
||||||
|
public abstract Integer updateByPrimaryKeySelective(MqttConfigTopic entity);
|
||||||
|
|
||||||
|
public abstract List<MqttConfigTopic> selectListByWhere(MqttConfigTopic entity);
|
||||||
|
|
||||||
|
public abstract Integer deleteByWhere(String wherestr);
|
||||||
|
|
||||||
|
public abstract List<MqttConfigTopic> selectListByPid(String pid);
|
||||||
|
|
||||||
|
}
|
||||||
25
src/main/java/com/sipai/dao/scada/MPointBzwDao.java
Normal file
25
src/main/java/com/sipai/dao/scada/MPointBzwDao.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package com.sipai.dao.scada;
|
||||||
|
|
||||||
|
import com.sipai.entity.scada.MPointBzw;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
@Repository
|
||||||
|
public interface MPointBzwDao {
|
||||||
|
|
||||||
|
public abstract MPointBzw selectByPrimaryKey(String id);
|
||||||
|
|
||||||
|
public abstract int deleteByPrimaryKey(String id);
|
||||||
|
|
||||||
|
public abstract int insert(MPointBzw entity);
|
||||||
|
|
||||||
|
public abstract int updateByPrimaryKeySelective(MPointBzw entity);
|
||||||
|
|
||||||
|
public abstract List<MPointBzw> selectListByWhere(MPointBzw entity);
|
||||||
|
|
||||||
|
public abstract int deleteByWhere(String where);
|
||||||
|
|
||||||
|
}
|
||||||
19
src/main/java/com/sipai/dao/scada/MPointDao.java
Normal file
19
src/main/java/com/sipai/dao/scada/MPointDao.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package com.sipai.dao.scada;
|
||||||
|
|
||||||
|
|
||||||
|
import com.sipai.dao.base.CommDaoImpl;
|
||||||
|
import com.sipai.entity.scada.MPoint;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class MPointDao extends CommDaoImpl<MPoint> {
|
||||||
|
public MPointDao() {
|
||||||
|
super();
|
||||||
|
this.setMappernamespace("scada.MPointMapper");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int updateValueByKey(MPoint t) {
|
||||||
|
return getSqlSession().update("scada.MPointMapper."+Thread.currentThread().getStackTrace()[1].getMethodName(), t);
|
||||||
|
}
|
||||||
|
}
|
||||||
64
src/main/java/com/sipai/dao/scada/MPointHistoryDao.java
Normal file
64
src/main/java/com/sipai/dao/scada/MPointHistoryDao.java
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
package com.sipai.dao.scada;
|
||||||
|
|
||||||
|
import com.sipai.dao.base.CommDaoImpl;
|
||||||
|
import com.sipai.entity.scada.MPointHistory;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class MPointHistoryDao extends CommDaoImpl<MPointHistory> {
|
||||||
|
public MPointHistoryDao() {
|
||||||
|
super();
|
||||||
|
this.setMappernamespace("scada.MPointHistoryMapper");
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MPointHistory> selectListByTableAWhere(String tablename, String wherestr) {
|
||||||
|
Map<String,String> paramMap=new HashMap<>();
|
||||||
|
paramMap.put("table",tablename);
|
||||||
|
paramMap.put("where",wherestr);
|
||||||
|
List<MPointHistory> list = getSqlSession().selectList("scada.MPointHistoryMapper."+Thread.currentThread().getStackTrace()[1].getMethodName(), paramMap);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int deleteByTableAWhere(String tablename, String wherestr) {
|
||||||
|
Map<String,String> paramMap=new HashMap<>();
|
||||||
|
paramMap.put("table",tablename);
|
||||||
|
paramMap.put("where",wherestr);
|
||||||
|
return this.getSqlSession().delete("scada.MPointHistoryMapper."+Thread.currentThread().getStackTrace()[1].getMethodName(), paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int createTable(String tablename){
|
||||||
|
Map<String,String> paramMap=new HashMap<>(1);
|
||||||
|
paramMap.put("table",tablename);
|
||||||
|
return getSqlSession().update("scada.MPointHistoryMapper."+Thread.currentThread().getStackTrace()[1].getMethodName(), paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer checkTableExist(String tablename){
|
||||||
|
Map<String,String> paramMap = new HashMap<>(1);
|
||||||
|
paramMap.put("table",tablename);
|
||||||
|
return getSqlSession().selectOne("scada.MPointHistoryMapper.checkTableExist", paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer selectCount(MPointHistory t){
|
||||||
|
return getSqlSession().selectOne("scada.MPointHistoryMapper."+Thread.currentThread().getStackTrace()[1].getMethodName(), t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int updateByMeasureDt(MPointHistory t) {
|
||||||
|
return getSqlSession().update("scada.MPointHistoryMapper."+Thread.currentThread().getStackTrace()[1].getMethodName(), t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MPointHistory> selectIndustrialLibrary(String IP,String MPointID, String intv, String sdt,String edt) {
|
||||||
|
Map<String,String> paramMap=new HashMap<>();
|
||||||
|
paramMap.put("IP",IP);
|
||||||
|
paramMap.put("MPointID",MPointID);
|
||||||
|
paramMap.put("intv",intv);
|
||||||
|
paramMap.put("sdt",sdt);
|
||||||
|
paramMap.put("edt",edt);
|
||||||
|
List<MPointHistory> list = getSqlSession().selectList("scada.MPointHistoryMapper."+Thread.currentThread().getStackTrace()[1].getMethodName(), paramMap);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
8
src/main/java/com/sipai/dao/scada/MPointRepo.java
Normal file
8
src/main/java/com/sipai/dao/scada/MPointRepo.java
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package com.sipai.dao.scada;
|
||||||
|
|
||||||
|
import com.sipai.entity.scada.MPoint;
|
||||||
|
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
||||||
|
|
||||||
|
public interface MPointRepo extends ElasticsearchRepository<MPoint, String>, MPointRepository {
|
||||||
|
|
||||||
|
}
|
||||||
13
src/main/java/com/sipai/dao/scada/MPointRepository.java
Normal file
13
src/main/java/com/sipai/dao/scada/MPointRepository.java
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package com.sipai.dao.scada;
|
||||||
|
|
||||||
|
import com.sipai.entity.scada.MPoint;
|
||||||
|
import com.sipai.entity.scada.MPointES;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface MPointRepository {
|
||||||
|
// int updateSelective(MPoint mpoint);
|
||||||
|
// int updateValue(MPoint mpoint);
|
||||||
|
void batchInsert(List<MPointES> mPointES);
|
||||||
|
void batchUpdate(List<MPointES> mPointES);
|
||||||
|
}
|
||||||
105
src/main/java/com/sipai/dao/scada/MPointRepositoryImpl.java
Normal file
105
src/main/java/com/sipai/dao/scada/MPointRepositoryImpl.java
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
package com.sipai.dao.scada;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.sipai.entity.scada.MPoint;
|
||||||
|
import com.sipai.entity.scada.MPointES;
|
||||||
|
import com.sipai.tools.CommUtil;
|
||||||
|
import org.elasticsearch.action.index.IndexRequest;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
|
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
|
||||||
|
import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
||||||
|
import org.springframework.data.elasticsearch.core.query.UpdateQuery;
|
||||||
|
import org.springframework.data.elasticsearch.core.query.UpdateQueryBuilder;
|
||||||
|
|
||||||
|
import java.beans.PropertyDescriptor;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MPointRepositoryImpl implements MPointRepository {
|
||||||
|
@Autowired
|
||||||
|
private ElasticsearchTemplate elasticsearchTemplate;
|
||||||
|
|
||||||
|
public void batchInsert(List<MPointES> mPointES){
|
||||||
|
|
||||||
|
int counter = 0;
|
||||||
|
|
||||||
|
//判断index 是否存在
|
||||||
|
if (!elasticsearchTemplate.indexExists("es_measurepoint")) {
|
||||||
|
elasticsearchTemplate.createIndex("es_measurepoint");
|
||||||
|
}
|
||||||
|
|
||||||
|
Gson gson = new Gson();
|
||||||
|
List<IndexQuery> queries = new ArrayList<IndexQuery>();
|
||||||
|
if(mPointES != null && mPointES.size()>0){
|
||||||
|
for (MPointES item : mPointES) {
|
||||||
|
IndexQuery indexQuery = new IndexQuery();
|
||||||
|
indexQuery.setId(item.getId().toString());
|
||||||
|
indexQuery.setSource(gson.toJson(item));
|
||||||
|
indexQuery.setIndexName("es_measurepoint");
|
||||||
|
indexQuery.setType("esmeasurepoint");
|
||||||
|
queries.add(indexQuery);
|
||||||
|
//分批提交索引
|
||||||
|
if (counter % 500 == 0) {
|
||||||
|
elasticsearchTemplate.bulkIndex(queries);
|
||||||
|
queries.clear();
|
||||||
|
//System.out.println("bulkIndex counter : " + counter);
|
||||||
|
}
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//不足批的索引最后不要忘记提交
|
||||||
|
if (queries.size() > 0) {
|
||||||
|
elasticsearchTemplate.bulkIndex(queries);
|
||||||
|
}
|
||||||
|
// elasticsearchTemplate.refresh("es_measurepoint");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void batchUpdate(List<MPointES> mPointES) {
|
||||||
|
|
||||||
|
int counter = 0;
|
||||||
|
|
||||||
|
//判断index 是否存在
|
||||||
|
if (!elasticsearchTemplate.indexExists("es_measurepoint")) {
|
||||||
|
elasticsearchTemplate.createIndex("es_measurepoint");
|
||||||
|
}
|
||||||
|
|
||||||
|
Gson gson = new Gson();
|
||||||
|
|
||||||
|
List<UpdateQuery> queries = new ArrayList<>();
|
||||||
|
if (mPointES != null && mPointES.size() > 0) {
|
||||||
|
for (MPointES item : mPointES) {
|
||||||
|
if (item.getMeasuredt() != null) {
|
||||||
|
IndexRequest indexRequest = new IndexRequest();
|
||||||
|
indexRequest.source("measuredt", item.getMeasuredt());
|
||||||
|
UpdateQuery updateQuery = new UpdateQueryBuilder().withId(item.getId()).withClass(MPoint.class).withIndexRequest(indexRequest).build();
|
||||||
|
queries.add(updateQuery);
|
||||||
|
}
|
||||||
|
if (item.getParmvalue() != null) {
|
||||||
|
IndexRequest indexRequest = new IndexRequest();
|
||||||
|
indexRequest.source("parmvalue", item.getParmvalue());
|
||||||
|
UpdateQuery updateQuery = new UpdateQueryBuilder().withId(item.getId()).withClass(MPoint.class).withIndexRequest(indexRequest).build();
|
||||||
|
queries.add(updateQuery);
|
||||||
|
}
|
||||||
|
//分批提交索引
|
||||||
|
if (counter % 500 == 0) {
|
||||||
|
elasticsearchTemplate.bulkUpdate(queries);
|
||||||
|
queries.clear();
|
||||||
|
}
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//不足批的索引最后不要忘记提交
|
||||||
|
if (queries.size() > 0) {
|
||||||
|
elasticsearchTemplate.bulkUpdate(queries);
|
||||||
|
}
|
||||||
|
// elasticsearchTemplate.refresh("es_measurepoint");
|
||||||
|
}
|
||||||
|
}
|
||||||
25
src/main/java/com/sipai/dao/user/CompanyDao.java
Normal file
25
src/main/java/com/sipai/dao/user/CompanyDao.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package com.sipai.dao.user;
|
||||||
|
|
||||||
|
import com.sipai.entity.user.Company;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
@Repository
|
||||||
|
public interface CompanyDao {
|
||||||
|
|
||||||
|
public abstract Company selectByPrimaryKey(String id);
|
||||||
|
|
||||||
|
public abstract Integer deleteByPrimaryKey(String id);
|
||||||
|
|
||||||
|
public abstract Integer insert(Company entity);
|
||||||
|
|
||||||
|
public abstract Integer updateByPrimaryKeySelective(Company entity);
|
||||||
|
|
||||||
|
public abstract List<Company> selectListByWhere(Company entity);
|
||||||
|
|
||||||
|
public abstract Integer deleteByWhere(String where);
|
||||||
|
|
||||||
|
}
|
||||||
13
src/main/java/com/sipai/dao/user/UserDao.java
Normal file
13
src/main/java/com/sipai/dao/user/UserDao.java
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package com.sipai.dao.user;
|
||||||
|
|
||||||
|
import com.sipai.entity.user.User;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
@Repository
|
||||||
|
public interface UserDao {
|
||||||
|
public abstract List<User> listuser2();
|
||||||
|
}
|
||||||
56
src/main/java/com/sipai/entity/Listener/ListenerHis.java
Normal file
56
src/main/java/com/sipai/entity/Listener/ListenerHis.java
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
package com.sipai.entity.Listener;
|
||||||
|
|
||||||
|
import com.sipai.entity.base.SQLAdapter;
|
||||||
|
|
||||||
|
public class ListenerHis extends SQLAdapter {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String pointid;
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
private String insdt;
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPointid() {
|
||||||
|
return pointid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPointid(String pointid) {
|
||||||
|
this.pointid = pointid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInsdt() {
|
||||||
|
return insdt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInsdt(String insdt) {
|
||||||
|
this.insdt = insdt;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
package com.sipai.entity.Listener;
|
||||||
|
|
||||||
|
import com.sipai.entity.base.SQLAdapter;
|
||||||
|
|
||||||
|
public class ListenerInterface extends SQLAdapter {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
private String port;
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPort() {
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPort(String port) {
|
||||||
|
this.port = port;
|
||||||
|
}
|
||||||
|
}
|
||||||
86
src/main/java/com/sipai/entity/Listener/ListenerMessage.java
Normal file
86
src/main/java/com/sipai/entity/Listener/ListenerMessage.java
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
package com.sipai.entity.Listener;
|
||||||
|
|
||||||
|
import com.sipai.entity.base.SQLAdapter;
|
||||||
|
import com.sipai.entity.scada.MPoint;
|
||||||
|
import com.sipai.entity.user.Company;
|
||||||
|
|
||||||
|
public class ListenerMessage extends SQLAdapter {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String Cmdtype;
|
||||||
|
|
||||||
|
private String Objid;
|
||||||
|
|
||||||
|
private String Action;
|
||||||
|
|
||||||
|
private String insdt;
|
||||||
|
|
||||||
|
private MPoint mPoint;
|
||||||
|
// private ProcessSection processSection;
|
||||||
|
private Company company;
|
||||||
|
|
||||||
|
public MPoint getmPoint() {
|
||||||
|
return mPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setmPoint(MPoint mPoint) {
|
||||||
|
this.mPoint = mPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
// public ProcessSection getProcessSection() {
|
||||||
|
// return processSection;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void setProcessSection(ProcessSection processSection) {
|
||||||
|
// this.processSection = processSection;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public Company getCompany() {
|
||||||
|
return company;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCompany(Company company) {
|
||||||
|
this.company = company;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCmdtype() {
|
||||||
|
return Cmdtype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCmdtype(String cmdtype) {
|
||||||
|
Cmdtype = cmdtype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getObjid() {
|
||||||
|
return Objid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setObjid(String objid) {
|
||||||
|
Objid = objid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAction() {
|
||||||
|
return Action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAction(String action) {
|
||||||
|
Action = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInsdt() {
|
||||||
|
return insdt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInsdt(String insdt) {
|
||||||
|
this.insdt = insdt;
|
||||||
|
}
|
||||||
|
}
|
||||||
123
src/main/java/com/sipai/entity/Listener/ListenerPoint.java
Normal file
123
src/main/java/com/sipai/entity/Listener/ListenerPoint.java
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
package com.sipai.entity.Listener;
|
||||||
|
|
||||||
|
import com.sipai.entity.base.SQLAdapter;
|
||||||
|
|
||||||
|
public class ListenerPoint extends SQLAdapter {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String intid;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
private String mpcode;
|
||||||
|
|
||||||
|
private String datatype;
|
||||||
|
|
||||||
|
private String unitid;
|
||||||
|
|
||||||
|
//逻辑条件
|
||||||
|
//= 等于
|
||||||
|
//> 大于
|
||||||
|
//< 小于
|
||||||
|
//change 变化
|
||||||
|
private String logi;
|
||||||
|
|
||||||
|
//逻辑条件对应的值
|
||||||
|
private String logiVal;
|
||||||
|
|
||||||
|
//动作 如等于reset 为置0
|
||||||
|
private String action;
|
||||||
|
|
||||||
|
public String getLogiVal() {
|
||||||
|
return logiVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLogiVal(String logiVal) {
|
||||||
|
this.logiVal = logiVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLogi() {
|
||||||
|
return logi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLogi(String logi) {
|
||||||
|
this.logi = logi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAction() {
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAction(String action) {
|
||||||
|
this.action = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIntid() {
|
||||||
|
return intid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIntid(String intid) {
|
||||||
|
this.intid = intid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAddress() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddress(String address) {
|
||||||
|
this.address = address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMpcode() {
|
||||||
|
return mpcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMpcode(String mpcode) {
|
||||||
|
this.mpcode = mpcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDatatype() {
|
||||||
|
return datatype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDatatype(String datatype) {
|
||||||
|
this.datatype = datatype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnitid() {
|
||||||
|
return unitid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnitid(String unitid) {
|
||||||
|
this.unitid = unitid;
|
||||||
|
}
|
||||||
|
}
|
||||||
65
src/main/java/com/sipai/entity/base/Result.java
Normal file
65
src/main/java/com/sipai/entity/base/Result.java
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
package com.sipai.entity.base;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author WXP
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Result {
|
||||||
|
public static final int SUCCESS = 1;
|
||||||
|
public static final int FAILED = 0;
|
||||||
|
public static final int REPEATED = 2;//重复添加
|
||||||
|
|
||||||
|
public Result(){
|
||||||
|
|
||||||
|
}
|
||||||
|
public Result(int code, String message, Object result) {
|
||||||
|
this.code = code;
|
||||||
|
this.msg = message;
|
||||||
|
if (result instanceof String) {
|
||||||
|
this.result = JSON.parse(result.toString());
|
||||||
|
}else{
|
||||||
|
this.result =result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public static Result success(Object result,String msg) {
|
||||||
|
return new Result(SUCCESS, msg, result);
|
||||||
|
}
|
||||||
|
public static Result success(Object result) {
|
||||||
|
return new Result(SUCCESS, "", result);
|
||||||
|
}
|
||||||
|
public static Result success() {
|
||||||
|
return new Result(SUCCESS, "", null);
|
||||||
|
}
|
||||||
|
public static Result failed(String msg) {
|
||||||
|
return new Result(FAILED, msg, null);
|
||||||
|
}
|
||||||
|
public int code;
|
||||||
|
public String msg;
|
||||||
|
public Object result;
|
||||||
|
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
public void setCode(int code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
public String getMsg() {
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
public void setMsg(String msg) {
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
public Object getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public void setResult(Object result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
22
src/main/java/com/sipai/entity/base/SQLAdapter.java
Normal file
22
src/main/java/com/sipai/entity/base/SQLAdapter.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package com.sipai.entity.base;
|
||||||
|
|
||||||
|
public class SQLAdapter {
|
||||||
|
private String sql;
|
||||||
|
private String where;
|
||||||
|
|
||||||
|
public String getSql() {
|
||||||
|
return sql;
|
||||||
|
}
|
||||||
|
public void setSql(String sql) {
|
||||||
|
this.sql = sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWhere() {
|
||||||
|
return where;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWhere(String where) {
|
||||||
|
this.where = where;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
37
src/main/java/com/sipai/entity/common/PageData.java
Normal file
37
src/main/java/com/sipai/entity/common/PageData.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package com.sipai.entity.common;
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页数据封装类
|
||||||
|
*/
|
||||||
|
public class PageData<T> {
|
||||||
|
private long total; // 总记录数
|
||||||
|
private int pageSize; // 每页大小
|
||||||
|
private int pageNum; // 当前页码
|
||||||
|
private int pages; // 总页数
|
||||||
|
private List<T> list; // 数据列表
|
||||||
|
|
||||||
|
public PageData() {}
|
||||||
|
|
||||||
|
public PageData(PageInfo<T> pageInfo) {
|
||||||
|
this.total = pageInfo.getTotal();
|
||||||
|
this.pageSize = pageInfo.getPageSize();
|
||||||
|
this.pageNum = pageInfo.getPageNum();
|
||||||
|
this.pages = pageInfo.getPages();
|
||||||
|
this.list = pageInfo.getList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// getters and setters
|
||||||
|
public long getTotal() { return total; }
|
||||||
|
public void setTotal(long total) { this.total = total; }
|
||||||
|
public int getPageSize() { return pageSize; }
|
||||||
|
public void setPageSize(int pageSize) { this.pageSize = pageSize; }
|
||||||
|
public int getPageNum() { return pageNum; }
|
||||||
|
public void setPageNum(int pageNum) { this.pageNum = pageNum; }
|
||||||
|
public int getPages() { return pages; }
|
||||||
|
public void setPages(int pages) { this.pages = pages; }
|
||||||
|
public List<T> getList() { return list; }
|
||||||
|
public void setList(List<T> list) { this.list = list; }
|
||||||
|
}
|
||||||
82
src/main/java/com/sipai/entity/data/ChannelData.java
Normal file
82
src/main/java/com/sipai/entity/data/ChannelData.java
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
package com.sipai.entity.data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报文实体类
|
||||||
|
* 频道数据
|
||||||
|
*/
|
||||||
|
public class ChannelData {
|
||||||
|
private int type; // 类型 1-6
|
||||||
|
private int channelNumber; // 通道号
|
||||||
|
private String channelName; // 通道名称 P1, P2等
|
||||||
|
private int yesterdayFlow; // 昨日流量
|
||||||
|
private List<Integer> cumulativeFlows; // 累计流量列表
|
||||||
|
private List<Float> analogValues; // 模拟量数据(类型4)
|
||||||
|
private Integer qChannelData; // Q通道数据(类型5)
|
||||||
|
private Integer mChannelData; // M通道数据(类型6)
|
||||||
|
|
||||||
|
public int getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(int type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getChannelNumber() {
|
||||||
|
return channelNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChannelNumber(int channelNumber) {
|
||||||
|
this.channelNumber = channelNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChannelName() {
|
||||||
|
return channelName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChannelName(String channelName) {
|
||||||
|
this.channelName = channelName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getYesterdayFlow() {
|
||||||
|
return yesterdayFlow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setYesterdayFlow(int yesterdayFlow) {
|
||||||
|
this.yesterdayFlow = yesterdayFlow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Integer> getCumulativeFlows() {
|
||||||
|
return cumulativeFlows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCumulativeFlows(List<Integer> cumulativeFlows) {
|
||||||
|
this.cumulativeFlows = cumulativeFlows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Float> getAnalogValues() {
|
||||||
|
return analogValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnalogValues(List<Float> analogValues) {
|
||||||
|
this.analogValues = analogValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getqChannelData() {
|
||||||
|
return qChannelData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setqChannelData(Integer qChannelData) {
|
||||||
|
this.qChannelData = qChannelData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getmChannelData() {
|
||||||
|
return mChannelData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setmChannelData(Integer mChannelData) {
|
||||||
|
this.mChannelData = mChannelData;
|
||||||
|
}
|
||||||
|
}
|
||||||
88
src/main/java/com/sipai/entity/data/DeviceData.java
Normal file
88
src/main/java/com/sipai/entity/data/DeviceData.java
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
package com.sipai.entity.data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class DeviceData {
|
||||||
|
private int stationId;
|
||||||
|
private String startTime;
|
||||||
|
private int dataCount;
|
||||||
|
private int length;
|
||||||
|
private int intervalMinutes;
|
||||||
|
private float batteryVoltage;
|
||||||
|
private String deviceInfo;
|
||||||
|
|
||||||
|
private int uploadCount;
|
||||||
|
private List<SensorData> sensorDataList;
|
||||||
|
|
||||||
|
public int getUploadCount() {
|
||||||
|
return uploadCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUploadCount(int uploadCount) {
|
||||||
|
this.uploadCount = uploadCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLength() {
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLength(int length) {
|
||||||
|
this.length = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStationId() {
|
||||||
|
return stationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStationId(int stationId) {
|
||||||
|
this.stationId = stationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartTime(String startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDataCount() {
|
||||||
|
return dataCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDataCount(int dataCount) {
|
||||||
|
this.dataCount = dataCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIntervalMinutes() {
|
||||||
|
return intervalMinutes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIntervalMinutes(int intervalMinutes) {
|
||||||
|
this.intervalMinutes = intervalMinutes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getBatteryVoltage() {
|
||||||
|
return batteryVoltage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBatteryVoltage(float batteryVoltage) {
|
||||||
|
this.batteryVoltage = batteryVoltage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceInfo() {
|
||||||
|
return deviceInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceInfo(String deviceInfo) {
|
||||||
|
this.deviceInfo = deviceInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SensorData> getSensorDataList() {
|
||||||
|
return sensorDataList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSensorDataList(List<SensorData> sensorDataList) {
|
||||||
|
this.sensorDataList = sensorDataList;
|
||||||
|
}
|
||||||
|
}
|
||||||
131
src/main/java/com/sipai/entity/data/DeviceDataPacket.java
Normal file
131
src/main/java/com/sipai/entity/data/DeviceDataPacket.java
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
package com.sipai.entity.data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报文实体类
|
||||||
|
* 设备数据分组
|
||||||
|
*/
|
||||||
|
public class DeviceDataPacket {
|
||||||
|
private String startCode; // 起始符 AB CD
|
||||||
|
private int length; // 长度 0x007D
|
||||||
|
private int stationId; // 站号 0x0066
|
||||||
|
private LocalDateTime timestamp; // 年月日时分 11 05 24 16 15
|
||||||
|
private int dataCount; // 数据个数 0x03
|
||||||
|
private int interval; // 数据间隔(分钟) 0x15
|
||||||
|
private float batteryVoltage; // 电池电压 7.18V
|
||||||
|
private int uploadCount; // 上发次数 5
|
||||||
|
private int signalStrength; // 信号强度 0x1E
|
||||||
|
private String deviceInfo; // 设备信息 "D115 1.4 1.0.11"
|
||||||
|
private List<ChannelData> channelDataList; // 通道数据列表
|
||||||
|
private int checksum; // 校验和
|
||||||
|
private String endCode; // 结束符 0D 0A
|
||||||
|
|
||||||
|
public String getStartCode() {
|
||||||
|
return startCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartCode(String startCode) {
|
||||||
|
this.startCode = startCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLength() {
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLength(int length) {
|
||||||
|
this.length = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStationId() {
|
||||||
|
return stationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStationId(int stationId) {
|
||||||
|
this.stationId = stationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getTimestamp() {
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimestamp(LocalDateTime timestamp) {
|
||||||
|
this.timestamp = timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDataCount() {
|
||||||
|
return dataCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDataCount(int dataCount) {
|
||||||
|
this.dataCount = dataCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getInterval() {
|
||||||
|
return interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInterval(int interval) {
|
||||||
|
this.interval = interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getBatteryVoltage() {
|
||||||
|
return batteryVoltage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBatteryVoltage(float batteryVoltage) {
|
||||||
|
this.batteryVoltage = batteryVoltage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUploadCount() {
|
||||||
|
return uploadCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUploadCount(int uploadCount) {
|
||||||
|
this.uploadCount = uploadCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSignalStrength() {
|
||||||
|
return signalStrength;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSignalStrength(int signalStrength) {
|
||||||
|
this.signalStrength = signalStrength;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceInfo() {
|
||||||
|
return deviceInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceInfo(String deviceInfo) {
|
||||||
|
this.deviceInfo = deviceInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ChannelData> getChannelDataList() {
|
||||||
|
return channelDataList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChannelDataList(List<ChannelData> channelDataList) {
|
||||||
|
this.channelDataList = channelDataList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getChecksum() {
|
||||||
|
return checksum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChecksum(int checksum) {
|
||||||
|
this.checksum = checksum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEndCode() {
|
||||||
|
return endCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndCode(String endCode) {
|
||||||
|
this.endCode = endCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
28
src/main/java/com/sipai/entity/data/PipeTopicMpoint.java
Normal file
28
src/main/java/com/sipai/entity/data/PipeTopicMpoint.java
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package com.sipai.entity.data;
|
||||||
|
|
||||||
|
import com.sipai.entity.base.SQLAdapter;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管网专题页点位信息实体类
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PipeTopicMpoint extends SQLAdapter implements Serializable {
|
||||||
|
private Integer id; // 自增主键
|
||||||
|
private String pointName; // 点位名称
|
||||||
|
private String pointCode; // 点位编号
|
||||||
|
private String type; // 所属类型
|
||||||
|
private Integer isConstant; // 是否常量(0-否,1-是)
|
||||||
|
private String constantValue; // 常量值
|
||||||
|
private Integer sortOrder; // 排序序号
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
private String sql;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
private String where;
|
||||||
|
}
|
||||||
32
src/main/java/com/sipai/entity/data/PipelineEquipment.java
Normal file
32
src/main/java/com/sipai/entity/data/PipelineEquipment.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package com.sipai.entity.data;
|
||||||
|
|
||||||
|
import com.sipai.entity.base.SQLAdapter;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管道设备实体类
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PipelineEquipment extends SQLAdapter implements Serializable {
|
||||||
|
private Integer id;
|
||||||
|
private String stationCode;//站点编号
|
||||||
|
private String equipmentType;//设备类型:井盖、流量计、液位计、电导率、雨量计、内涝监测
|
||||||
|
private String productModel;//产品型号
|
||||||
|
private Integer uploadCycle;//上传周期
|
||||||
|
private String uploadCycleUnit;//上传周期 单位
|
||||||
|
private String lastUploadTime;//最近一次上传数据时间
|
||||||
|
private String status; //1在线 0离线 null为未检测
|
||||||
|
|
||||||
|
//用于查询对应的name
|
||||||
|
private String equipmentTypeName;//设备类型:井盖、流量计、液位计、电导率、雨量计、内涝监测
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
private String sql;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
private String where;
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
package com.sipai.entity.data;
|
||||||
|
|
||||||
|
import com.sipai.entity.base.SQLAdapter;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管道设备与测点关联实体类
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PipelineEquipmentMpoint extends SQLAdapter implements Serializable {
|
||||||
|
private Integer id;
|
||||||
|
private Integer pid; // 关联 PipelineEquipment 的 id
|
||||||
|
private String mpcode; // 测点
|
||||||
|
private String mpname; // 名称
|
||||||
|
private String tag; // 编码
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
private String sql;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
private String where;
|
||||||
|
}
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
package com.sipai.entity.data;
|
||||||
|
|
||||||
|
import com.sipai.entity.base.SQLAdapter;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管道测点 库(这边维护好,设备那边可以直接导入)
|
||||||
|
* sj 2025-06-18
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PipelineMpointLibrary extends SQLAdapter implements Serializable {
|
||||||
|
private String id;
|
||||||
|
private String equipmentType;
|
||||||
|
private String code;
|
||||||
|
private String name;
|
||||||
|
private Integer morder;
|
||||||
|
|
||||||
|
// 用于查询对应的name
|
||||||
|
@JsonIgnore
|
||||||
|
private String sql;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
private String where;
|
||||||
|
}
|
||||||
120
src/main/java/com/sipai/entity/data/SensorData.java
Normal file
120
src/main/java/com/sipai/entity/data/SensorData.java
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
package com.sipai.entity.data;
|
||||||
|
|
||||||
|
import com.sipai.tools.AlarmType;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class SensorData {
|
||||||
|
private int type; // 1-脉冲量, 2-开关量, 3-报警量, 4-模拟量, 5-Q通道, 6-M通道
|
||||||
|
private int channel;
|
||||||
|
|
||||||
|
// 脉冲量特有
|
||||||
|
private long yesterdayFlow;
|
||||||
|
private List<Long> accumulatedFlows;
|
||||||
|
|
||||||
|
private int qValue; // 原始Q通道值
|
||||||
|
private Map<AlarmType, Boolean> alarmStatus; // 报警状态映射
|
||||||
|
|
||||||
|
// 开关量/报警量
|
||||||
|
private List<Integer> statusList;
|
||||||
|
|
||||||
|
// 模拟量
|
||||||
|
private List<Float> analogValues;
|
||||||
|
|
||||||
|
// Q通道
|
||||||
|
private List<String> qValues;
|
||||||
|
|
||||||
|
// M通道
|
||||||
|
private List<Integer> mValues;
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(int type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getChannel() {
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChannel(int channel) {
|
||||||
|
this.channel = channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getYesterdayFlow() {
|
||||||
|
return yesterdayFlow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setYesterdayFlow(long yesterdayFlow) {
|
||||||
|
this.yesterdayFlow = yesterdayFlow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Long> getAccumulatedFlows() {
|
||||||
|
return accumulatedFlows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccumulatedFlows(List<Long> accumulatedFlows) {
|
||||||
|
this.accumulatedFlows = accumulatedFlows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Integer> getStatusList() {
|
||||||
|
return statusList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatusList(List<Integer> statusList) {
|
||||||
|
this.statusList = statusList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Float> getAnalogValues() {
|
||||||
|
return analogValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnalogValues(List<Float> analogValues) {
|
||||||
|
this.analogValues = analogValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getqValues() {
|
||||||
|
return qValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setqValues(List<String> qValues) {
|
||||||
|
this.qValues = qValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Integer> getmValues() {
|
||||||
|
return mValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setmValues(List<Integer> mValues) {
|
||||||
|
this.mValues = mValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getqValue() {
|
||||||
|
return qValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setqValue(int qValue) {
|
||||||
|
this.qValue = qValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<AlarmType, Boolean> getAlarmStatus() {
|
||||||
|
return alarmStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAlarmStatus(Map<AlarmType, Boolean> alarmStatus) {
|
||||||
|
this.alarmStatus = alarmStatus;
|
||||||
|
}
|
||||||
|
}
|
||||||
71
src/main/java/com/sipai/entity/enums/DeviceTypeEnum.java
Normal file
71
src/main/java/com/sipai/entity/enums/DeviceTypeEnum.java
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
package com.sipai.entity.enums;
|
||||||
|
|
||||||
|
public enum DeviceTypeEnum {
|
||||||
|
// 枚举常量,对应下拉框中的类型
|
||||||
|
MANHOLE_COVER("井盖", "1"),
|
||||||
|
FLOW_METER("流量计", "2"),
|
||||||
|
LIQUID_LEVEL_METER("液位计", "3"),
|
||||||
|
CONDUCTIVITY("电导率", "4"),
|
||||||
|
RAIN_GAUGE("雨量计", "5"),
|
||||||
|
WATERLOGGING_DETECTION("内涝检测", "6");
|
||||||
|
|
||||||
|
// 类型名称
|
||||||
|
private final String typeName;
|
||||||
|
// 类型编码
|
||||||
|
private final String typeCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造方法
|
||||||
|
* @param typeName 类型名称
|
||||||
|
* @param typeCode 类型编码
|
||||||
|
*/
|
||||||
|
DeviceTypeEnum(String typeName, String typeCode) {
|
||||||
|
this.typeName = typeName;
|
||||||
|
this.typeCode = typeCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取类型名称
|
||||||
|
* @return 类型名称
|
||||||
|
*/
|
||||||
|
public String getTypeName() {
|
||||||
|
return typeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取类型编码
|
||||||
|
* @return 类型编码
|
||||||
|
*/
|
||||||
|
public String getTypeCode() {
|
||||||
|
return typeCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 也可根据需求添加根据名称或编码获取枚举常量的方法,示例如下:
|
||||||
|
/**
|
||||||
|
* 根据类型名称获取枚举常量
|
||||||
|
* @param typeName 类型名称
|
||||||
|
* @return 对应的枚举常量,若未找到返回 null
|
||||||
|
*/
|
||||||
|
public static DeviceTypeEnum getByTypeName(String typeName) {
|
||||||
|
for (DeviceTypeEnum enumConstant : DeviceTypeEnum.values()) {
|
||||||
|
if (enumConstant.getTypeName().equals(typeName)) {
|
||||||
|
return enumConstant;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据类型编码获取枚举常量
|
||||||
|
* @param typeCode 类型编码
|
||||||
|
* @return 对应的枚举常量,若未找到返回 null
|
||||||
|
*/
|
||||||
|
public static DeviceTypeEnum getByTypeCode(String typeCode) {
|
||||||
|
for (DeviceTypeEnum enumConstant : DeviceTypeEnum.values()) {
|
||||||
|
if (enumConstant.getTypeCode().equals(typeCode)) {
|
||||||
|
return enumConstant;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
16
src/main/java/com/sipai/entity/mqtt/Mqtt.java
Normal file
16
src/main/java/com/sipai/entity/mqtt/Mqtt.java
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package com.sipai.entity.mqtt;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于配置emqx的常量 和 提供云平台的一些接口 如指令下发,获取网关在线状态等
|
||||||
|
* sj 2021-05-27
|
||||||
|
*/
|
||||||
|
public class Mqtt {
|
||||||
|
|
||||||
|
/*public static String BrokerAddress = "tcp://192.168.10.17:1883";
|
||||||
|
public static String Dashboard_01 = "http://192.168.10.17:18083";
|
||||||
|
|
||||||
|
public static String Username = "admin";
|
||||||
|
public static String Password = "sipai@64368180";*/
|
||||||
|
}
|
||||||
102
src/main/java/com/sipai/entity/mqtt/MqttConfig.java
Normal file
102
src/main/java/com/sipai/entity/mqtt/MqttConfig.java
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
package com.sipai.entity.mqtt;
|
||||||
|
|
||||||
|
import com.sipai.entity.base.SQLAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with IntelliJ IDEA.
|
||||||
|
*
|
||||||
|
* @Auther: sj
|
||||||
|
* @Date: 2021/03/24/16:26
|
||||||
|
* @Description: mqtt配置主表
|
||||||
|
*/
|
||||||
|
public class MqttConfig extends SQLAdapter {
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String insdt;
|
||||||
|
|
||||||
|
private String clientId;
|
||||||
|
|
||||||
|
private String clientName;
|
||||||
|
|
||||||
|
private String brokerIp;
|
||||||
|
|
||||||
|
private String tomcatPort;
|
||||||
|
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
private Integer morder;
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInsdt() {
|
||||||
|
return insdt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInsdt(String insdt) {
|
||||||
|
this.insdt = insdt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClientId() {
|
||||||
|
return clientId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClientId(String clientId) {
|
||||||
|
this.clientId = clientId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClientName() {
|
||||||
|
return clientName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClientName(String clientName) {
|
||||||
|
this.clientName = clientName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBrokerIp() {
|
||||||
|
return brokerIp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBrokerIp(String brokerIp) {
|
||||||
|
this.brokerIp = brokerIp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTomcatPort() {
|
||||||
|
return tomcatPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTomcatPort(String tomcatPort) {
|
||||||
|
this.tomcatPort = tomcatPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getMorder() {
|
||||||
|
return morder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMorder(Integer morder) {
|
||||||
|
this.morder = morder;
|
||||||
|
}
|
||||||
|
}
|
||||||
72
src/main/java/com/sipai/entity/mqtt/MqttConfigTopic.java
Normal file
72
src/main/java/com/sipai/entity/mqtt/MqttConfigTopic.java
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
package com.sipai.entity.mqtt;
|
||||||
|
|
||||||
|
import com.sipai.entity.base.SQLAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with IntelliJ IDEA.
|
||||||
|
*
|
||||||
|
* @Auther: sj
|
||||||
|
* @Date: 2021/03/24/16:26
|
||||||
|
* @Description: mqtt配置副表
|
||||||
|
*/
|
||||||
|
public class MqttConfigTopic extends SQLAdapter {
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String topic;
|
||||||
|
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
private String pid;
|
||||||
|
|
||||||
|
private Integer morder;
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id == null ? null : id.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name == null ? null : name.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTopic() {
|
||||||
|
return topic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTopic(String topic) {
|
||||||
|
this.topic = topic == null ? null : topic.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status == null ? null : status.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPid() {
|
||||||
|
return pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPid(String pid) {
|
||||||
|
this.pid = pid == null ? null : pid.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getMorder() {
|
||||||
|
return morder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMorder(Integer morder) {
|
||||||
|
this.morder = morder;
|
||||||
|
}
|
||||||
|
}
|
||||||
45
src/main/java/com/sipai/entity/mqtt/MqttProperties.java
Normal file
45
src/main/java/com/sipai/entity/mqtt/MqttProperties.java
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package com.sipai.entity.mqtt;
|
||||||
|
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties(prefix = "mqtt")
|
||||||
|
public class MqttProperties {
|
||||||
|
private String brokerAddress; // 对应原 BrokerAddress
|
||||||
|
private String dashboard01; // 对应原 Dashboard_01
|
||||||
|
private String username; // 对应原 Username
|
||||||
|
private String password; // 对应原 Password
|
||||||
|
|
||||||
|
public String getBrokerAddress() {
|
||||||
|
return brokerAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBrokerAddress(String brokerAddress) {
|
||||||
|
this.brokerAddress = brokerAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDashboard01() {
|
||||||
|
return dashboard01;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDashboard01(String dashboard01) {
|
||||||
|
this.dashboard01 = dashboard01;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
}
|
||||||
608
src/main/java/com/sipai/entity/scada/MPoint.java
Normal file
608
src/main/java/com/sipai/entity/scada/MPoint.java
Normal file
@ -0,0 +1,608 @@
|
|||||||
|
package com.sipai.entity.scada;
|
||||||
|
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.sipai.entity.base.SQLAdapter;
|
||||||
|
import org.springframework.data.annotation.Id;
|
||||||
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
|
import org.springframework.data.elasticsearch.annotations.Mapping;
|
||||||
|
import org.springframework.data.elasticsearch.annotations.Setting;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
|
||||||
|
@Mapping(mappingPath = "mpoint_search_mapping.json")
|
||||||
|
@Setting(settingPath = "mpoint_search_setting.json")
|
||||||
|
@Document(indexName = "es_measurepoint", type = "esmeasurepoint")
|
||||||
|
@Component
|
||||||
|
public class MPoint extends SQLAdapter implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -7579438089469008076L;
|
||||||
|
public static String Flag_Enable = "1";
|
||||||
|
public static String Flag_Disable = "0";
|
||||||
|
|
||||||
|
public static String Flag_Sql = "sql";
|
||||||
|
public static String Flag_Modbus = "modbus";
|
||||||
|
public static String Flag_LinkData = "link";
|
||||||
|
|
||||||
|
public static String Flag_Type_CAL = "CAL";//单元格计算测量点
|
||||||
|
public static String Flag_Type_KPI = "KPI";//KPI测量<E6B58B>?
|
||||||
|
public static String Flag_Type_Data = "data";
|
||||||
|
public static String Flag_Type_Hand = "hand";//手动测量<E6B58B>?
|
||||||
|
public static String Flag_Type_Auto = "auto";//自动转发测量<E6B58B>?
|
||||||
|
|
||||||
|
public static String Flag_BizType_Hand = "Manual";
|
||||||
|
public static String Flag_BizType_Auto = "auto";//自动转发
|
||||||
|
|
||||||
|
private String chineseValue;//测量点<E9878F>? valuemeaning对应的中文<E4B8AD>?
|
||||||
|
|
||||||
|
@Id
|
||||||
|
private String id;
|
||||||
|
private String mpointid;
|
||||||
|
private String mpointcode;
|
||||||
|
private String parmname;
|
||||||
|
private String unit;
|
||||||
|
private BigDecimal alarmmax;
|
||||||
|
private BigDecimal alarmmin;
|
||||||
|
private BigDecimal parmvalue;
|
||||||
|
//@Field(type = FieldType.Date)
|
||||||
|
private String measuredt;
|
||||||
|
private BigDecimal rate;
|
||||||
|
private Integer freq;
|
||||||
|
private String frequnit;
|
||||||
|
private String signaltype;
|
||||||
|
@JsonProperty("signaltag")
|
||||||
|
private String signaltag;
|
||||||
|
private String ledtype;
|
||||||
|
private String ledcolor;
|
||||||
|
private String directtype;
|
||||||
|
private String bizid;
|
||||||
|
private String biztype;
|
||||||
|
private String numtail;
|
||||||
|
private String prochour;
|
||||||
|
private String procday;
|
||||||
|
private String procmonth;
|
||||||
|
private String showname;
|
||||||
|
private String exp;
|
||||||
|
private BigDecimal forcemin;
|
||||||
|
private BigDecimal forcemax;
|
||||||
|
private BigDecimal avgmax;
|
||||||
|
private BigDecimal avgmin;
|
||||||
|
private String remoteup;
|
||||||
|
private Integer morder;
|
||||||
|
private String triggeralarm;
|
||||||
|
private String confirmalarm;
|
||||||
|
private BigDecimal flowset;
|
||||||
|
private String triggercycle;
|
||||||
|
private BigDecimal cyclemax;
|
||||||
|
private BigDecimal cyclemin;
|
||||||
|
private String triggermutation;
|
||||||
|
private BigDecimal mutationset;
|
||||||
|
private BigDecimal causeset;
|
||||||
|
private BigDecimal operateset;
|
||||||
|
private BigDecimal resultset;
|
||||||
|
private String triggerequoff;
|
||||||
|
private String mathop;
|
||||||
|
private String valuetype;
|
||||||
|
private String valuemeaning;
|
||||||
|
private String active;
|
||||||
|
private String soundalarm;
|
||||||
|
private String scdtype;
|
||||||
|
private BigDecimal spanrange;
|
||||||
|
private String modbusfigid;
|
||||||
|
private String register;
|
||||||
|
private String processsectioncode;
|
||||||
|
private String equipmentid;
|
||||||
|
@JsonProperty("source_type")
|
||||||
|
private String sourceType;
|
||||||
|
@JsonProperty("patrol_type")
|
||||||
|
private String patrolType;
|
||||||
|
private String remark;
|
||||||
|
private Integer alarmLevel;
|
||||||
|
|
||||||
|
private String bizname;
|
||||||
|
private String disname;
|
||||||
|
|
||||||
|
private int subscriptionStatus;
|
||||||
|
|
||||||
|
public String getChineseValue() {
|
||||||
|
return chineseValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChineseValue(String chineseValue) {
|
||||||
|
this.chineseValue = chineseValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMpointid() {
|
||||||
|
return mpointid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMpointid(String mpointid) {
|
||||||
|
this.mpointid = mpointid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMpointcode() {
|
||||||
|
return mpointcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMpointcode(String mpointcode) {
|
||||||
|
this.mpointcode = mpointcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParmname() {
|
||||||
|
return parmname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParmname(String parmname) {
|
||||||
|
this.parmname = parmname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnit() {
|
||||||
|
return unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnit(String unit) {
|
||||||
|
this.unit = unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getAlarmmax() {
|
||||||
|
return alarmmax;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAlarmmax(BigDecimal alarmmax) {
|
||||||
|
this.alarmmax = alarmmax;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getAlarmmin() {
|
||||||
|
return alarmmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAlarmmin(BigDecimal alarmmin) {
|
||||||
|
this.alarmmin = alarmmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getParmvalue() {
|
||||||
|
return parmvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParmvalue(BigDecimal parmvalue) {
|
||||||
|
this.parmvalue = parmvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMeasuredt() {
|
||||||
|
return measuredt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMeasuredt(String measuredt) {
|
||||||
|
this.measuredt = measuredt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getRate() {
|
||||||
|
return rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRate(BigDecimal rate) {
|
||||||
|
this.rate = rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getFreq() {
|
||||||
|
return freq;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFreq(Integer freq) {
|
||||||
|
this.freq = freq;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFrequnit() {
|
||||||
|
return frequnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFrequnit(String frequnit) {
|
||||||
|
this.frequnit = frequnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSignaltype() {
|
||||||
|
return signaltype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSignaltype(String signaltype) {
|
||||||
|
this.signaltype = signaltype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSignaltag() {
|
||||||
|
return signaltag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSignaltag(String signaltag) {
|
||||||
|
this.signaltag = signaltag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLedtype() {
|
||||||
|
return ledtype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLedtype(String ledtype) {
|
||||||
|
this.ledtype = ledtype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLedcolor() {
|
||||||
|
return ledcolor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLedcolor(String ledcolor) {
|
||||||
|
this.ledcolor = ledcolor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDirecttype() {
|
||||||
|
return directtype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDirecttype(String directtype) {
|
||||||
|
this.directtype = directtype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBizid() {
|
||||||
|
return bizid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBizid(String bizid) {
|
||||||
|
this.bizid = bizid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBiztype() {
|
||||||
|
return biztype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBiztype(String biztype) {
|
||||||
|
this.biztype = biztype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNumtail() {
|
||||||
|
return numtail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumtail(String numtail) {
|
||||||
|
this.numtail = numtail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProchour() {
|
||||||
|
return prochour;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProchour(String prochour) {
|
||||||
|
this.prochour = prochour;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProcday() {
|
||||||
|
return procday;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProcday(String procday) {
|
||||||
|
this.procday = procday;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProcmonth() {
|
||||||
|
return procmonth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProcmonth(String procmonth) {
|
||||||
|
this.procmonth = procmonth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getShowname() {
|
||||||
|
return showname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowname(String showname) {
|
||||||
|
this.showname = showname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getExp() {
|
||||||
|
return exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExp(String exp) {
|
||||||
|
this.exp = exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getForcemin() {
|
||||||
|
return forcemin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setForcemin(BigDecimal forcemin) {
|
||||||
|
this.forcemin = forcemin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getForcemax() {
|
||||||
|
return forcemax;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setForcemax(BigDecimal forcemax) {
|
||||||
|
this.forcemax = forcemax;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getAvgmax() {
|
||||||
|
return avgmax;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvgmax(BigDecimal avgmax) {
|
||||||
|
this.avgmax = avgmax;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getAvgmin() {
|
||||||
|
return avgmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvgmin(BigDecimal avgmin) {
|
||||||
|
this.avgmin = avgmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRemoteup() {
|
||||||
|
return remoteup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemoteup(String remoteup) {
|
||||||
|
this.remoteup = remoteup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getMorder() {
|
||||||
|
return morder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMorder(Integer morder) {
|
||||||
|
this.morder = morder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTriggeralarm() {
|
||||||
|
return triggeralarm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTriggeralarm(String triggeralarm) {
|
||||||
|
this.triggeralarm = triggeralarm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConfirmalarm() {
|
||||||
|
return confirmalarm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfirmalarm(String confirmalarm) {
|
||||||
|
this.confirmalarm = confirmalarm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getFlowset() {
|
||||||
|
return flowset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFlowset(BigDecimal flowset) {
|
||||||
|
this.flowset = flowset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTriggercycle() {
|
||||||
|
return triggercycle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTriggercycle(String triggercycle) {
|
||||||
|
this.triggercycle = triggercycle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getCyclemax() {
|
||||||
|
return cyclemax;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCyclemax(BigDecimal cyclemax) {
|
||||||
|
this.cyclemax = cyclemax;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getCyclemin() {
|
||||||
|
return cyclemin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCyclemin(BigDecimal cyclemin) {
|
||||||
|
this.cyclemin = cyclemin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTriggermutation() {
|
||||||
|
return triggermutation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTriggermutation(String triggermutation) {
|
||||||
|
this.triggermutation = triggermutation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getMutationset() {
|
||||||
|
return mutationset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMutationset(BigDecimal mutationset) {
|
||||||
|
this.mutationset = mutationset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getCauseset() {
|
||||||
|
return causeset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCauseset(BigDecimal causeset) {
|
||||||
|
this.causeset = causeset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getOperateset() {
|
||||||
|
return operateset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOperateset(BigDecimal operateset) {
|
||||||
|
this.operateset = operateset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getResultset() {
|
||||||
|
return resultset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResultset(BigDecimal resultset) {
|
||||||
|
this.resultset = resultset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTriggerequoff() {
|
||||||
|
return triggerequoff;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTriggerequoff(String triggerequoff) {
|
||||||
|
this.triggerequoff = triggerequoff;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMathop() {
|
||||||
|
return mathop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMathop(String mathop) {
|
||||||
|
this.mathop = mathop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValuetype() {
|
||||||
|
return valuetype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValuetype(String valuetype) {
|
||||||
|
this.valuetype = valuetype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValuemeaning() {
|
||||||
|
return valuemeaning;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValuemeaning(String valuemeaning) {
|
||||||
|
this.valuemeaning = valuemeaning;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getActive() {
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActive(String active) {
|
||||||
|
this.active = active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSoundalarm() {
|
||||||
|
return soundalarm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSoundalarm(String soundalarm) {
|
||||||
|
this.soundalarm = soundalarm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getScdtype() {
|
||||||
|
return scdtype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScdtype(String scdtype) {
|
||||||
|
this.scdtype = scdtype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getSpanrange() {
|
||||||
|
return spanrange;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpanrange(BigDecimal spanrange) {
|
||||||
|
this.spanrange = spanrange;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModbusfigid() {
|
||||||
|
return modbusfigid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModbusfigid(String modbusfigid) {
|
||||||
|
this.modbusfigid = modbusfigid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRegister() {
|
||||||
|
return register;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegister(String register) {
|
||||||
|
this.register = register;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProcesssectioncode() {
|
||||||
|
return processsectioncode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProcesssectioncode(String processsectioncode) {
|
||||||
|
this.processsectioncode = processsectioncode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEquipmentid() {
|
||||||
|
return equipmentid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEquipmentid(String equipmentid) {
|
||||||
|
this.equipmentid = equipmentid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSourceType() {
|
||||||
|
return sourceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSourceType(String sourceType) {
|
||||||
|
this.sourceType = sourceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPatrolType() {
|
||||||
|
return patrolType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPatrolType(String patrolType) {
|
||||||
|
this.patrolType = patrolType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRemark() {
|
||||||
|
return remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemark(String remark) {
|
||||||
|
this.remark = remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getAlarmLevel() {
|
||||||
|
return alarmLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAlarmLevel(Integer alarmLevel) {
|
||||||
|
this.alarmLevel = alarmLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBizname() {
|
||||||
|
return bizname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBizname(String bizname) {
|
||||||
|
this.bizname = bizname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDisname() {
|
||||||
|
return disname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisname(String disname) {
|
||||||
|
this.disname = disname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSubscriptionStatus() {
|
||||||
|
return subscriptionStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubscriptionStatus(int subscriptionStatus) {
|
||||||
|
this.subscriptionStatus = subscriptionStatus;
|
||||||
|
}
|
||||||
|
}
|
||||||
57
src/main/java/com/sipai/entity/scada/MPointBzw.java
Normal file
57
src/main/java/com/sipai/entity/scada/MPointBzw.java
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
package com.sipai.entity.scada;
|
||||||
|
|
||||||
|
import com.sipai.entity.base.SQLAdapter;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测点标识对照表实体类
|
||||||
|
*/
|
||||||
|
public class MPointBzw extends SQLAdapter implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测点ID
|
||||||
|
*/
|
||||||
|
private String mpointId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测点标识ID
|
||||||
|
*/
|
||||||
|
private String mpointbzwId;
|
||||||
|
|
||||||
|
// 无参构造器
|
||||||
|
public MPointBzw() {
|
||||||
|
}
|
||||||
|
|
||||||
|
// 全参构造器
|
||||||
|
public MPointBzw(String mpointId, String mpointbzwId) {
|
||||||
|
this.mpointId = mpointId;
|
||||||
|
this.mpointbzwId = mpointbzwId;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getters and Setters
|
||||||
|
public String getMpointId() {
|
||||||
|
return mpointId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMpointId(String mpointId) {
|
||||||
|
this.mpointId = mpointId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMpointbzwId() {
|
||||||
|
return mpointbzwId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMpointbzwId(String mpointbzwId) {
|
||||||
|
this.mpointbzwId = mpointbzwId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "MPointBzw{" +
|
||||||
|
"mpointId='" + mpointId + '\'' +
|
||||||
|
", mpointbzwId='" + mpointbzwId + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
42
src/main/java/com/sipai/entity/scada/MPointES.java
Normal file
42
src/main/java/com/sipai/entity/scada/MPointES.java
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
package com.sipai.entity.scada;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
|
||||||
|
public class MPointES extends MPoint {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -4222932639259909065L;
|
||||||
|
private String source_type;
|
||||||
|
|
||||||
|
public String getSource_type() {
|
||||||
|
return source_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSource_type(String source_type) {
|
||||||
|
this.source_type = source_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static MPointES format(MPoint mPoint) {
|
||||||
|
String str = JSON.toJSONString(mPoint);
|
||||||
|
MPointES mPointES = JSON.parseObject(str, MPointES.class);
|
||||||
|
mPointES.setSource_type(mPoint.getSourceType());
|
||||||
|
//时间格式处理
|
||||||
|
DateTimeFormatter dfES = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||||
|
DateTimeFormatter dfSQL = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
|
if (mPoint.getMeasuredt() != null) {
|
||||||
|
try {
|
||||||
|
LocalDateTime confirmTime = LocalDateTime.parse(mPoint.getMeasuredt().substring(0, 19), dfSQL);
|
||||||
|
String confirmTimeStr = dfES.format(confirmTime);
|
||||||
|
mPointES.setMeasuredt(confirmTimeStr);
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mPointES;
|
||||||
|
}
|
||||||
|
}
|
||||||
154
src/main/java/com/sipai/entity/scada/MPointHistory.java
Normal file
154
src/main/java/com/sipai/entity/scada/MPointHistory.java
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
package com.sipai.entity.scada;
|
||||||
|
|
||||||
|
import com.sipai.entity.base.SQLAdapter;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
public class MPointHistory extends SQLAdapter implements Serializable{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 4552977217414444717L;
|
||||||
|
|
||||||
|
private Long itemid;
|
||||||
|
|
||||||
|
private BigDecimal parmvalue;
|
||||||
|
|
||||||
|
private String measuredt;
|
||||||
|
|
||||||
|
private String memotype;
|
||||||
|
|
||||||
|
private String memo;
|
||||||
|
|
||||||
|
private String userid;
|
||||||
|
|
||||||
|
private String insdt;
|
||||||
|
|
||||||
|
private String tbName;
|
||||||
|
|
||||||
|
private short tag;//标志位值
|
||||||
|
|
||||||
|
//为报表展示使用 CPELM
|
||||||
|
private String year;
|
||||||
|
private String month;
|
||||||
|
private String day;
|
||||||
|
private String hour;
|
||||||
|
private String min;
|
||||||
|
|
||||||
|
public short getTag() {
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTag(short tag) {
|
||||||
|
this.tag = tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getItemid() {
|
||||||
|
return itemid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemid(Long itemid) {
|
||||||
|
this.itemid = itemid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getParmvalue() {
|
||||||
|
return parmvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParmvalue(BigDecimal parmvalue) {
|
||||||
|
this.parmvalue = parmvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMeasuredt() {
|
||||||
|
return measuredt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMeasuredt(String measuredt) {
|
||||||
|
this.measuredt = measuredt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMemotype() {
|
||||||
|
return memotype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemotype(String memotype) {
|
||||||
|
this.memotype = memotype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMemo() {
|
||||||
|
return memo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemo(String memo) {
|
||||||
|
this.memo = memo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserid() {
|
||||||
|
return userid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserid(String userid) {
|
||||||
|
this.userid = userid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInsdt() {
|
||||||
|
return insdt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInsdt(String insdt) {
|
||||||
|
this.insdt = insdt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTbName() {
|
||||||
|
return tbName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTbName(String tbName) {
|
||||||
|
this.tbName = tbName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getYear() {
|
||||||
|
return year;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setYear(String year) {
|
||||||
|
this.year = year;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMonth() {
|
||||||
|
return month;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMonth(String month) {
|
||||||
|
this.month = month;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDay() {
|
||||||
|
return day;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDay(String day) {
|
||||||
|
this.day = day;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHour() {
|
||||||
|
return hour;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHour(String hour) {
|
||||||
|
this.hour = hour;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMin() {
|
||||||
|
return min;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMin(String min) {
|
||||||
|
this.min = min;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long getSerialversionuid() {
|
||||||
|
return serialVersionUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
201
src/main/java/com/sipai/entity/user/Company.java
Normal file
201
src/main/java/com/sipai/entity/user/Company.java
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
package com.sipai.entity.user;
|
||||||
|
|
||||||
|
import com.sipai.entity.base.SQLAdapter;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公司表
|
||||||
|
*/
|
||||||
|
public class Company extends SQLAdapter {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String pid;
|
||||||
|
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
private String tel;
|
||||||
|
|
||||||
|
private String website;
|
||||||
|
|
||||||
|
private String taskid;
|
||||||
|
|
||||||
|
private String post;
|
||||||
|
|
||||||
|
private String insdt;
|
||||||
|
|
||||||
|
private String insuser;
|
||||||
|
|
||||||
|
private Integer version;
|
||||||
|
|
||||||
|
private Integer morder;
|
||||||
|
|
||||||
|
private String sname;
|
||||||
|
|
||||||
|
private String active;
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
private String ename;
|
||||||
|
|
||||||
|
private BigDecimal longitude;
|
||||||
|
|
||||||
|
private BigDecimal latitude;
|
||||||
|
|
||||||
|
private String isCount;
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPid() {
|
||||||
|
return pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPid(String pid) {
|
||||||
|
this.pid = pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAddress() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddress(String address) {
|
||||||
|
this.address = address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTel() {
|
||||||
|
return tel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTel(String tel) {
|
||||||
|
this.tel = tel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWebsite() {
|
||||||
|
return website;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWebsite(String website) {
|
||||||
|
this.website = website;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTaskid() {
|
||||||
|
return taskid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaskid(String taskid) {
|
||||||
|
this.taskid = taskid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPost() {
|
||||||
|
return post;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPost(String post) {
|
||||||
|
this.post = post;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInsdt() {
|
||||||
|
return insdt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInsdt(String insdt) {
|
||||||
|
this.insdt = insdt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInsuser() {
|
||||||
|
return insuser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInsuser(String insuser) {
|
||||||
|
this.insuser = insuser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVersion(Integer version) {
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getMorder() {
|
||||||
|
return morder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMorder(Integer morder) {
|
||||||
|
this.morder = morder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSname() {
|
||||||
|
return sname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSname(String sname) {
|
||||||
|
this.sname = sname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getActive() {
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActive(String active) {
|
||||||
|
this.active = active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEname() {
|
||||||
|
return ename;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEname(String ename) {
|
||||||
|
this.ename = ename;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getLongitude() {
|
||||||
|
return longitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLongitude(BigDecimal longitude) {
|
||||||
|
this.longitude = longitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getLatitude() {
|
||||||
|
return latitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLatitude(BigDecimal latitude) {
|
||||||
|
this.latitude = latitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIsCount() {
|
||||||
|
return isCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsCount(String isCount) {
|
||||||
|
this.isCount = isCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
36
src/main/java/com/sipai/entity/user/User.java
Normal file
36
src/main/java/com/sipai/entity/user/User.java
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package com.sipai.entity.user;
|
||||||
|
|
||||||
|
import com.sipai.entity.base.SQLAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 人员表
|
||||||
|
*/
|
||||||
|
public class User extends SQLAdapter {
|
||||||
|
private String id;
|
||||||
|
private String userName;
|
||||||
|
private String passWord;
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserName() {
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserName(String userName) {
|
||||||
|
this.userName = userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassWord() {
|
||||||
|
return passWord;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassWord(String passWord) {
|
||||||
|
this.passWord = passWord;
|
||||||
|
}
|
||||||
|
}
|
||||||
73
src/main/java/com/sipai/schedule/DataSynJob.java
Normal file
73
src/main/java/com/sipai/schedule/DataSynJob.java
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package com.sipai.schedule;
|
||||||
|
|
||||||
|
import com.sipai.entity.scada.MPoint;
|
||||||
|
import com.sipai.entity.scada.MPointHistory;
|
||||||
|
import com.sipai.service.mqtt.MqttConfigService;
|
||||||
|
import com.sipai.service.opc.InitOpcUaService;
|
||||||
|
import com.sipai.service.scada.MPointHistoryService;
|
||||||
|
import com.sipai.service.scada.MPointService;
|
||||||
|
import com.sipai.tools.CommUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时将总表数据插入到子表
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class DataSynJob {
|
||||||
|
@Autowired
|
||||||
|
private MPointService mPointService;
|
||||||
|
@Autowired
|
||||||
|
private MPointHistoryService mPointHistoryService;
|
||||||
|
@Autowired
|
||||||
|
private MqttConfigService mqttConfigService;
|
||||||
|
@Autowired
|
||||||
|
private InitOpcUaService initOpcUaService;
|
||||||
|
|
||||||
|
//定时器yml配置是否启动
|
||||||
|
@Value("${scheduled.enabled:true}")
|
||||||
|
private boolean scheduledEnabled;
|
||||||
|
|
||||||
|
// @Scheduled(fixedRate = 3600000) // 同步一次opcua的订阅
|
||||||
|
public void syncSubscriptions() {
|
||||||
|
initOpcUaService.manualSyncSubscriptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Async
|
||||||
|
@Scheduled(initialDelay = 10000, fixedRate = 600000)//自动订阅mqtt
|
||||||
|
public void job1() {
|
||||||
|
if (!scheduledEnabled) return; // 手动拦截
|
||||||
|
System.out.println("自动订阅========" + CommUtil.nowDate());
|
||||||
|
mqttConfigService.connect("1");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Async
|
||||||
|
// @Scheduled(cron = "0 0/3 * * * ?")//数据转发
|
||||||
|
public void job2() {
|
||||||
|
if (!scheduledEnabled) return; // 手动拦截
|
||||||
|
String addstr = "zhuanfa";
|
||||||
|
System.out.println("开始定时器-----------------" + CommUtil.nowDate() + "-----------------" + addstr);
|
||||||
|
List<MPoint> list2 = this.mPointService.selectListByWhere("where bizid = '0791CNWS' and SignalType='AI' and MeasureDT>DATE_SUB(NOW(), INTERVAL 5 MINUTE) and source_type='auto' ");
|
||||||
|
if (list2 != null && list2.size() > 0) {
|
||||||
|
for (int j = 0; j < list2.size(); ++j) {
|
||||||
|
MPointHistory mPointHistory = new MPointHistory();
|
||||||
|
mPointHistory.setParmvalue(list2.get(j).getParmvalue());
|
||||||
|
mPointHistory.setMeasuredt(list2.get(j).getMeasuredt());
|
||||||
|
mPointHistory.setTbName(list2.get(j).getMpointcode());
|
||||||
|
mPointHistory.setUserid("data_job");
|
||||||
|
mPointHistory.setInsdt(CommUtil.nowDate());
|
||||||
|
mPointHistoryService.saveByCreate(list2.get(j).getBizid(), mPointHistory);
|
||||||
|
}
|
||||||
|
System.out.println("完成一次(有数据)转发,执行了" + list2.size() + "次点");
|
||||||
|
} else {
|
||||||
|
System.out.println("完成一次(无数据)转发,执行了" + 0 + "次点");
|
||||||
|
}
|
||||||
|
System.out.println("结束定时器-----------------" + CommUtil.nowDate());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package com.sipai.service.Listener;
|
||||||
|
|
||||||
|
import com.sipai.entity.Listener.ListenerHis;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ListenerHisService {
|
||||||
|
|
||||||
|
public abstract ListenerHis selectById(String id);
|
||||||
|
|
||||||
|
public abstract int deleteById(String id);
|
||||||
|
|
||||||
|
public abstract int save(ListenerHis entity);
|
||||||
|
|
||||||
|
public abstract int update(ListenerHis entity);
|
||||||
|
|
||||||
|
public abstract List<ListenerHis> selectListByWhere(String wherestr);
|
||||||
|
|
||||||
|
public abstract int deleteByWhere(String wherestr);
|
||||||
|
|
||||||
|
public abstract List<ListenerHis> selectTopByWhere(String wherestr);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package com.sipai.service.Listener;
|
||||||
|
|
||||||
|
|
||||||
|
import com.sipai.entity.Listener.ListenerInterface;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ListenerInterfaceService {
|
||||||
|
|
||||||
|
public abstract ListenerInterface selectById(String id);
|
||||||
|
|
||||||
|
public abstract int deleteById(String id);
|
||||||
|
|
||||||
|
public abstract int save(ListenerInterface entity);
|
||||||
|
|
||||||
|
public abstract int update(ListenerInterface entity);
|
||||||
|
|
||||||
|
public abstract List<ListenerInterface> selectListByWhere(String wherestr);
|
||||||
|
|
||||||
|
public abstract int deleteByWhere(String wherestr);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package com.sipai.service.Listener;
|
||||||
|
|
||||||
|
import com.sipai.entity.Listener.ListenerMessage;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ListenerMessageService {
|
||||||
|
|
||||||
|
public abstract ListenerMessage selectById(String id);
|
||||||
|
|
||||||
|
public abstract int deleteById(String id);
|
||||||
|
|
||||||
|
public abstract int save(ListenerMessage entity);
|
||||||
|
|
||||||
|
public abstract int update(ListenerMessage entity);
|
||||||
|
|
||||||
|
public abstract List<ListenerMessage> selectListByWhere(String wherestr);
|
||||||
|
|
||||||
|
//带入设备编号查询
|
||||||
|
public abstract List<ListenerMessage> selectListByWhere4Equ(String wherestr, String equipmentId);
|
||||||
|
|
||||||
|
public abstract int deleteByWhere(String wherestr);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package com.sipai.service.Listener;
|
||||||
|
|
||||||
|
|
||||||
|
import com.sipai.entity.Listener.ListenerPoint;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ListenerPointService {
|
||||||
|
|
||||||
|
public abstract ListenerPoint selectById(String id);
|
||||||
|
|
||||||
|
public abstract int deleteById(String id);
|
||||||
|
|
||||||
|
public abstract int save(ListenerPoint entity);
|
||||||
|
|
||||||
|
public abstract int update(ListenerPoint entity);
|
||||||
|
|
||||||
|
public abstract List<ListenerPoint> selectListByWhere(String wherestr);
|
||||||
|
|
||||||
|
public abstract int deleteByWhere(String wherestr);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,62 @@
|
|||||||
|
package com.sipai.service.Listener.impl;
|
||||||
|
|
||||||
|
import com.sipai.dao.Listener.ListenerHisDao;
|
||||||
|
import com.sipai.entity.Listener.ListenerHis;
|
||||||
|
import com.sipai.service.Listener.ListenerHisService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service("listenerHisService")
|
||||||
|
public class ListenerHisServiceImpl implements ListenerHisService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
public ListenerHisDao listenerHisDao;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ListenerHis selectById(String id) {
|
||||||
|
ListenerHis listenerHis = listenerHisDao.selectByPrimaryKey(id);
|
||||||
|
return listenerHis;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteById(String id) {
|
||||||
|
int i = listenerHisDao.deleteByPrimaryKey(id);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int save(ListenerHis entity) {
|
||||||
|
int insert = listenerHisDao.insert(entity);
|
||||||
|
return insert;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int update(ListenerHis entity) {
|
||||||
|
int i = listenerHisDao.updateByPrimaryKeySelective(entity);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ListenerHis> selectListByWhere(String wherestr) {
|
||||||
|
ListenerHis listenerHis = new ListenerHis();
|
||||||
|
listenerHis.setWhere(wherestr);
|
||||||
|
List<ListenerHis> listenerHiss = listenerHisDao.selectListByWhere(listenerHis);
|
||||||
|
return listenerHiss;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteByWhere(String wherestr) {
|
||||||
|
ListenerHis listenerHis = new ListenerHis();
|
||||||
|
listenerHis.setWhere(wherestr);
|
||||||
|
int i = listenerHisDao.deleteByWhere(listenerHis);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ListenerHis> selectTopByWhere(String wherestr) {
|
||||||
|
List<ListenerHis> listenerHis = listenerHisDao.selectTopByWhere(wherestr);
|
||||||
|
return listenerHis;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
package com.sipai.service.Listener.impl;
|
||||||
|
|
||||||
|
import com.sipai.dao.Listener.ListenerInterfaceDao;
|
||||||
|
import com.sipai.entity.Listener.ListenerInterface;
|
||||||
|
import com.sipai.service.Listener.ListenerInterfaceService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service("listenerInterfaceService")
|
||||||
|
public class ListenerInterfaceServiceImpl implements ListenerInterfaceService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
public ListenerInterfaceDao listenerInterfaceDao;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ListenerInterface selectById(String id) {
|
||||||
|
ListenerInterface listenerInterface = listenerInterfaceDao.selectByPrimaryKey(id);
|
||||||
|
return listenerInterface;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteById(String id) {
|
||||||
|
int i = listenerInterfaceDao.deleteByPrimaryKey(id);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int save(ListenerInterface entity) {
|
||||||
|
int insert = listenerInterfaceDao.insert(entity);
|
||||||
|
return insert;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int update(ListenerInterface entity) {
|
||||||
|
int i = listenerInterfaceDao.updateByPrimaryKeySelective(entity);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ListenerInterface> selectListByWhere(String wherestr) {
|
||||||
|
ListenerInterface listenerInterface = new ListenerInterface();
|
||||||
|
listenerInterface.setWhere(wherestr);
|
||||||
|
List<ListenerInterface> listenerInterfaces = listenerInterfaceDao.selectListByWhere(listenerInterface);
|
||||||
|
return listenerInterfaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteByWhere(String wherestr) {
|
||||||
|
ListenerInterface listenerInterface = new ListenerInterface();
|
||||||
|
listenerInterface.setWhere(wherestr);
|
||||||
|
int i = listenerInterfaceDao.deleteByWhere(listenerInterface);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,96 @@
|
|||||||
|
package com.sipai.service.Listener.impl;
|
||||||
|
|
||||||
|
import com.sipai.dao.Listener.ListenerMessageDao;
|
||||||
|
import com.sipai.entity.Listener.ListenerMessage;
|
||||||
|
import com.sipai.service.Listener.ListenerMessageService;
|
||||||
|
import com.sipai.service.scada.MPointService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service("listenerMessageService")
|
||||||
|
public class ListenerMessageServiceImpl implements ListenerMessageService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ListenerMessageDao listenerMessageDao;
|
||||||
|
// @Resource
|
||||||
|
// private CompanyService companyService;
|
||||||
|
// @Resource
|
||||||
|
// private ProcessSectionService processSectionService;
|
||||||
|
@Resource
|
||||||
|
private MPointService mPointService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ListenerMessage selectById(String id) {
|
||||||
|
ListenerMessage listenerMessage = listenerMessageDao.selectByPrimaryKey(id);
|
||||||
|
return listenerMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteById(String id) {
|
||||||
|
int i = listenerMessageDao.deleteByPrimaryKey(id);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int save(ListenerMessage entity) {
|
||||||
|
int insert = listenerMessageDao.insert(entity);
|
||||||
|
return insert;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int update(ListenerMessage entity) {
|
||||||
|
int i = listenerMessageDao.updateByPrimaryKeySelective(entity);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ListenerMessage> selectListByWhere(String wherestr) {
|
||||||
|
ListenerMessage listenerMessage = new ListenerMessage();
|
||||||
|
listenerMessage.setWhere(wherestr);
|
||||||
|
List<ListenerMessage> listenerMessages = listenerMessageDao.selectListByWhere(listenerMessage);
|
||||||
|
for (ListenerMessage entity : listenerMessages) {
|
||||||
|
|
||||||
|
// MPoint mPoint = mPointService.selectById(entity.getObjid());
|
||||||
|
// if (mPoint != null) {
|
||||||
|
// entity.setmPoint(mPoint);
|
||||||
|
// Company company = companyService.selectByPrimaryKey(mPoint.getBizid());
|
||||||
|
// entity.setCompany(company);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
return listenerMessages;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ListenerMessage> selectListByWhere4Equ(String wherestr, String equipmentId) {
|
||||||
|
ListenerMessage listenerMessage = new ListenerMessage();
|
||||||
|
listenerMessage.setWhere(wherestr);
|
||||||
|
List<ListenerMessage> listenerMessages = listenerMessageDao.selectListByWhere(listenerMessage);
|
||||||
|
List<ListenerMessage> listenerMessages2 = new ArrayList<>();
|
||||||
|
for (int i = 0; i < listenerMessages.size(); i++) {
|
||||||
|
// MPoint mPoint = mPointService.selectById(listenerMessages.get(i).getObjid());
|
||||||
|
// if (mPoint != null && mPoint.getEquipmentid().equals(equipmentId)) {
|
||||||
|
// listenerMessages2.add(listenerMessages.get(i));
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
for (ListenerMessage entity : listenerMessages2) {
|
||||||
|
// MPoint mPoint = mPointService.selectById(entity.getObjid());
|
||||||
|
// if (mPoint != null) {
|
||||||
|
// entity.setmPoint(mPoint);
|
||||||
|
// Company company = companyService.selectByPrimaryKey(mPoint.getBizid());
|
||||||
|
// entity.setCompany(company);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
return listenerMessages2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteByWhere(String wherestr) {
|
||||||
|
ListenerMessage listenerMessage = new ListenerMessage();
|
||||||
|
listenerMessage.setWhere(wherestr);
|
||||||
|
int i = listenerMessageDao.deleteByWhere(listenerMessage);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,57 @@
|
|||||||
|
package com.sipai.service.Listener.impl;
|
||||||
|
|
||||||
|
import com.sipai.dao.Listener.ListenerPointDao;
|
||||||
|
import com.sipai.entity.Listener.ListenerPoint;
|
||||||
|
import com.sipai.service.Listener.ListenerPointService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service("listenerPointService")
|
||||||
|
public class ListenerPointServiceImpl implements ListenerPointService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ListenerPointDao listenerPointDao;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ListenerPoint selectById(String id) {
|
||||||
|
ListenerPoint listenerPoint = listenerPointDao.selectByPrimaryKey(id);
|
||||||
|
return listenerPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteById(String id) {
|
||||||
|
int i = listenerPointDao.deleteByPrimaryKey(id);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int save(ListenerPoint entity) {
|
||||||
|
int insert = listenerPointDao.insert(entity);
|
||||||
|
return insert;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int update(ListenerPoint entity) {
|
||||||
|
int i = listenerPointDao.updateByPrimaryKeySelective(entity);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ListenerPoint> selectListByWhere(String wherestr) {
|
||||||
|
ListenerPoint listenerPoint = new ListenerPoint();
|
||||||
|
listenerPoint.setWhere(wherestr);
|
||||||
|
List<ListenerPoint> listenerPoints = listenerPointDao.selectListByWhere(listenerPoint);
|
||||||
|
return listenerPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteByWhere(String wherestr) {
|
||||||
|
ListenerPoint listenerPoint = new ListenerPoint();
|
||||||
|
listenerPoint.setWhere(wherestr);
|
||||||
|
int i = listenerPointDao.deleteByWhere(listenerPoint);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
126
src/main/java/com/sipai/service/data/DeviceDataParser.java
Normal file
126
src/main/java/com/sipai/service/data/DeviceDataParser.java
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
package com.sipai.service.data;
|
||||||
|
|
||||||
|
import com.sipai.entity.data.ChannelData;
|
||||||
|
import com.sipai.entity.data.DeviceDataPacket;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.ByteOrder;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class DeviceDataParser {
|
||||||
|
|
||||||
|
public static DeviceDataPacket parse(byte[] data) {
|
||||||
|
ByteBuffer buffer = ByteBuffer.wrap(data);
|
||||||
|
buffer.order(ByteOrder.LITTLE_ENDIAN); // 设置为低位在前
|
||||||
|
|
||||||
|
// 1. 验证起始符
|
||||||
|
if (buffer.get() != (byte) 0xAB || buffer.get() != (byte) 0xCD) {
|
||||||
|
throw new IllegalArgumentException("Invalid start code (expected AB CD)");
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceDataPacket packet = new DeviceDataPacket();
|
||||||
|
packet.setStartCode("ABCD");
|
||||||
|
|
||||||
|
// 2. 解析固定字段
|
||||||
|
packet.setLength(buffer.getShort() & 0xFFFF); // 长度
|
||||||
|
packet.setStationId(buffer.getShort() & 0xFFFF); // 站号
|
||||||
|
|
||||||
|
// 3. 解析时间戳(BCD码:年(1)月(1)日(1)时(1)分(1))
|
||||||
|
byte[] timeBytes = new byte[5];
|
||||||
|
buffer.get(timeBytes);
|
||||||
|
packet.setTimestamp(LocalDateTime.of(
|
||||||
|
2000 + bcdToInt(timeBytes[0]), // 年
|
||||||
|
bcdToInt(timeBytes[1]), // 月
|
||||||
|
bcdToInt(timeBytes[2]), // 日
|
||||||
|
bcdToInt(timeBytes[3]), // 时
|
||||||
|
bcdToInt(timeBytes[4]) // 分
|
||||||
|
));
|
||||||
|
|
||||||
|
// 4. 解析其他字段
|
||||||
|
packet.setDataCount(buffer.get() & 0xFF); // 数据个数
|
||||||
|
packet.setInterval(buffer.get() & 0xFF); // 间隔(分钟)
|
||||||
|
packet.setBatteryVoltage((buffer.getShort() & 0xFFFF) / 100.0f); // 电池电压
|
||||||
|
packet.setUploadCount(buffer.getShort() & 0xFFFF); // 上发次数
|
||||||
|
packet.setSignalStrength(buffer.get() & 0xFF); // 信号强度
|
||||||
|
|
||||||
|
// 5. 解析设备信息(20字节ASCII)
|
||||||
|
byte[] deviceInfoBytes = new byte[20];
|
||||||
|
buffer.get(deviceInfoBytes);
|
||||||
|
packet.setDeviceInfo(new String(deviceInfoBytes).trim());
|
||||||
|
|
||||||
|
// 跳过保留字段(8字节)
|
||||||
|
buffer.position(buffer.position() + 8);
|
||||||
|
|
||||||
|
// 6. 解析通道数据
|
||||||
|
List<ChannelData> channelDataList = new ArrayList<>();
|
||||||
|
while (buffer.remaining() > 3) { // 至少需要3字节(校验和+结束符)
|
||||||
|
ChannelData channelData = parseChannelData(buffer, packet.getDataCount());
|
||||||
|
channelDataList.add(channelData);
|
||||||
|
}
|
||||||
|
|
||||||
|
packet.setChannelDataList(channelDataList);
|
||||||
|
|
||||||
|
// 7. 校验和与结束符
|
||||||
|
if (buffer.remaining() >= 1) {
|
||||||
|
packet.setChecksum(buffer.get() & 0xFF);
|
||||||
|
}
|
||||||
|
if (buffer.remaining() >= 2) {
|
||||||
|
packet.setEndCode(String.format("%02X%02X", buffer.get(), buffer.get()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return packet;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ChannelData parseChannelData(ByteBuffer buffer, int dataCount) {
|
||||||
|
ChannelData channelData = new ChannelData();
|
||||||
|
channelData.setType(buffer.get() & 0xFF); // 类型
|
||||||
|
channelData.setChannelNumber(buffer.get() & 0xFF); // 通道号
|
||||||
|
|
||||||
|
// 修复channelName乱码:直接转为HEX字符串
|
||||||
|
byte[] nameBytes = new byte[]{buffer.get(), buffer.get()};
|
||||||
|
channelData.setChannelName(String.format("%02X%02X", nameBytes[0], nameBytes[1]));
|
||||||
|
|
||||||
|
// 根据类型解析数据
|
||||||
|
switch (channelData.getType()) {
|
||||||
|
case 1: // 脉冲量
|
||||||
|
case 2: // 开关量
|
||||||
|
case 3: // 报警量
|
||||||
|
channelData.setYesterdayFlow(buffer.getInt());
|
||||||
|
channelData.setCumulativeFlows(parseIntList(buffer, dataCount));
|
||||||
|
break;
|
||||||
|
case 4: // 模拟量
|
||||||
|
channelData.setYesterdayFlow(buffer.getInt());
|
||||||
|
channelData.setAnalogValues(parseFloatList(buffer, dataCount));
|
||||||
|
break;
|
||||||
|
case 5: // 虚拟Q通道
|
||||||
|
channelData.setqChannelData(buffer.getShort() & 0xFFFF);
|
||||||
|
break;
|
||||||
|
case 6: // 虚拟M通道
|
||||||
|
channelData.setmChannelData(buffer.getInt());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return channelData;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<Integer> parseIntList(ByteBuffer buffer, int count) {
|
||||||
|
List<Integer> list = new ArrayList<>();
|
||||||
|
for (int i = 0; i < count && buffer.remaining() >= 4; i++) {
|
||||||
|
list.add(buffer.getInt());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<Float> parseFloatList(ByteBuffer buffer, int count) {
|
||||||
|
List<Float> list = new ArrayList<>();
|
||||||
|
for (int i = 0; i < count && buffer.remaining() >= 4; i++) {
|
||||||
|
list.add(buffer.getFloat());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int bcdToInt(byte b) {
|
||||||
|
return ((b >> 4) & 0xF) * 10 + (b & 0xF);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
package com.sipai.service.data;
|
||||||
|
|
||||||
|
import com.sipai.entity.data.PipeTopicMpoint;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管网专题页点位服务接口
|
||||||
|
*/
|
||||||
|
public interface PipeTopicMpointService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加点位信息
|
||||||
|
*/
|
||||||
|
int insert(PipeTopicMpoint pipeTopicMpoint);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据主键删除点位
|
||||||
|
*/
|
||||||
|
boolean delete(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除点位
|
||||||
|
*/
|
||||||
|
boolean deleteBatch(List<Integer> idList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新点位信息
|
||||||
|
*/
|
||||||
|
boolean update(PipeTopicMpoint pipeTopicMpoint);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据主键获取点位详情
|
||||||
|
*/
|
||||||
|
PipeTopicMpoint selectByPrimaryKey(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据条件查询点位列表
|
||||||
|
*/
|
||||||
|
List<PipeTopicMpoint> selectListByWhere(String where);
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
package com.sipai.service.data;
|
||||||
|
|
||||||
|
import com.sipai.entity.data.PipelineEquipmentMpoint;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管道设备与测点关联服务接口
|
||||||
|
*/
|
||||||
|
public interface PipelineEquipmentMpointService {
|
||||||
|
/**
|
||||||
|
* 添加关联信息
|
||||||
|
*/
|
||||||
|
boolean insert(PipelineEquipmentMpoint mpoint);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除关联信息
|
||||||
|
*/
|
||||||
|
boolean delete(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新关联信息
|
||||||
|
*/
|
||||||
|
boolean update(PipelineEquipmentMpoint mpoint);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取关联信息详情
|
||||||
|
*/
|
||||||
|
PipelineEquipmentMpoint selectByPrimaryKey(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有关联信息列表
|
||||||
|
*/
|
||||||
|
List<PipelineEquipmentMpoint> selectListByWhere(String where);
|
||||||
|
}
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
package com.sipai.service.data;
|
||||||
|
|
||||||
|
import com.sipai.entity.data.PipelineEquipment;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管道设备服务接口
|
||||||
|
*/
|
||||||
|
public interface PipelineEquipmentService {
|
||||||
|
/**
|
||||||
|
* 添加设备
|
||||||
|
*/
|
||||||
|
int insert(PipelineEquipment pipelineEquipment);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除设备
|
||||||
|
*/
|
||||||
|
boolean delete(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新设备信息
|
||||||
|
*/
|
||||||
|
boolean update(PipelineEquipment equipment);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备详情
|
||||||
|
*/
|
||||||
|
PipelineEquipment selectByPrimaryKey(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有设备列表
|
||||||
|
*/
|
||||||
|
List<PipelineEquipment> selectListByWhere(String where);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据站点编号查询设备
|
||||||
|
*/
|
||||||
|
/*List<PipelineEquipment> getEquipmentByStation(String stationCode);
|
||||||
|
|
||||||
|
*//**
|
||||||
|
* 根据设备类型查询设备
|
||||||
|
*//*
|
||||||
|
List<PipelineEquipment> getEquipmentByType(String equipmentType);
|
||||||
|
|
||||||
|
*//**
|
||||||
|
* 根据状态查询设备
|
||||||
|
*//*
|
||||||
|
List<PipelineEquipment> getEquipmentByStatus(String status);*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新设备状态
|
||||||
|
*/
|
||||||
|
// boolean updateEquipmentStatus(String id, String status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新设备最后上传时间
|
||||||
|
*/
|
||||||
|
// boolean updateLastUploadTime(String id);
|
||||||
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
package com.sipai.service.data;
|
||||||
|
|
||||||
|
import com.sipai.entity.data.PipelineMpointLibrary;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管道测点库服务接口
|
||||||
|
*/
|
||||||
|
public interface PipelineMpointLibraryService {
|
||||||
|
/**
|
||||||
|
* 添加测点库信息
|
||||||
|
*/
|
||||||
|
boolean insert(PipelineMpointLibrary mpointLibrary);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除测点库信息
|
||||||
|
*/
|
||||||
|
boolean delete(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多删测点库信息
|
||||||
|
* @param idList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int deleteBatch(List<String> idList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新测点库信息
|
||||||
|
*/
|
||||||
|
boolean update(PipelineMpointLibrary mpointLibrary);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取测点库详情
|
||||||
|
*/
|
||||||
|
PipelineMpointLibrary selectByPrimaryKey(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有测点库列表
|
||||||
|
*/
|
||||||
|
List<PipelineMpointLibrary> selectListByWhere(String where);
|
||||||
|
}
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
package com.sipai.service.data.impl;
|
||||||
|
|
||||||
|
import com.sipai.dao.data.PipeTopicMpointDao;
|
||||||
|
import com.sipai.entity.data.PipeTopicMpoint;
|
||||||
|
import com.sipai.service.data.PipeTopicMpointService;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Transactional
|
||||||
|
public class PipeTopicMpointServiceImpl implements PipeTopicMpointService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PipeTopicMpointDao pipeTopicMpointDao;
|
||||||
|
|
||||||
|
public PipeTopicMpointServiceImpl(PipeTopicMpointDao pipeTopicMpointDao) {
|
||||||
|
this.pipeTopicMpointDao = pipeTopicMpointDao;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insert(PipeTopicMpoint pipeTopicMpoint) {
|
||||||
|
return pipeTopicMpointDao.insert(pipeTopicMpoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean delete(Integer id) {
|
||||||
|
return pipeTopicMpointDao.deleteByPrimaryKey(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteBatch(List<Integer> idList) {
|
||||||
|
if (CollectionUtils.isEmpty(idList)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int count = pipeTopicMpointDao.deleteBatchByIds(idList);
|
||||||
|
return count > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(PipeTopicMpoint pipeTopicMpoint) {
|
||||||
|
return pipeTopicMpointDao.updateByPrimaryKeySelective(pipeTopicMpoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PipeTopicMpoint selectByPrimaryKey(Integer id) {
|
||||||
|
return pipeTopicMpointDao.selectByPrimaryKey(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PipeTopicMpoint> selectListByWhere(String where) {
|
||||||
|
PipeTopicMpoint pipeTopicMpoint = new PipeTopicMpoint();
|
||||||
|
pipeTopicMpoint.setWhere(where);
|
||||||
|
return pipeTopicMpointDao.selectListByWhere(pipeTopicMpoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
package com.sipai.service.data.impl;
|
||||||
|
|
||||||
|
import com.sipai.dao.data.PipelineEquipmentMpointDao;
|
||||||
|
import com.sipai.entity.data.PipelineEquipmentMpoint;
|
||||||
|
import com.sipai.service.data.PipelineEquipmentMpointService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Transactional
|
||||||
|
public class PipelineEquipmentMpointServiceImpl implements PipelineEquipmentMpointService {
|
||||||
|
@Autowired
|
||||||
|
private PipelineEquipmentMpointDao pipelineEquipmentMpointDao;
|
||||||
|
|
||||||
|
public PipelineEquipmentMpointServiceImpl(PipelineEquipmentMpointDao mpointDao) {
|
||||||
|
this.pipelineEquipmentMpointDao = mpointDao;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean insert(PipelineEquipmentMpoint mpoint) {
|
||||||
|
return pipelineEquipmentMpointDao.insert(mpoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean delete(Integer id) {
|
||||||
|
return pipelineEquipmentMpointDao.deleteByPrimaryKey(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(PipelineEquipmentMpoint mpoint) {
|
||||||
|
return pipelineEquipmentMpointDao.updateByPrimaryKeySelective(mpoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PipelineEquipmentMpoint selectByPrimaryKey(Integer id) {
|
||||||
|
return pipelineEquipmentMpointDao.selectByPrimaryKey(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PipelineEquipmentMpoint> selectListByWhere(String where) {
|
||||||
|
PipelineEquipmentMpoint mpoint = new PipelineEquipmentMpoint();
|
||||||
|
mpoint.setWhere(where);
|
||||||
|
return pipelineEquipmentMpointDao.selectListByWhere(mpoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,126 @@
|
|||||||
|
package com.sipai.service.data.impl;
|
||||||
|
|
||||||
|
import com.sipai.dao.data.PipelineEquipmentDao;
|
||||||
|
import com.sipai.dao.scada.MPointDao;
|
||||||
|
import com.sipai.entity.data.PipelineEquipment;
|
||||||
|
import com.sipai.entity.enums.DeviceTypeEnum;
|
||||||
|
import com.sipai.service.data.PipelineEquipmentService;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Transactional
|
||||||
|
public class PipelineEquipmentServiceImpl implements PipelineEquipmentService {
|
||||||
|
@Autowired
|
||||||
|
private PipelineEquipmentDao pipelineEquipmentDao;
|
||||||
|
|
||||||
|
public PipelineEquipmentServiceImpl(PipelineEquipmentDao equipmentDao) {
|
||||||
|
this.pipelineEquipmentDao = equipmentDao;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insert(PipelineEquipment equipment) {
|
||||||
|
int result = pipelineEquipmentDao.insert(equipment);
|
||||||
|
if (result > 0) {
|
||||||
|
// 插入成功,获取自增的ID
|
||||||
|
int generatedId = equipment.getId();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean delete(Integer id) {
|
||||||
|
return pipelineEquipmentDao.deleteByPrimaryKey(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@Override
|
||||||
|
public boolean deleteBatch(List<Integer> idList) {
|
||||||
|
// 参数校验
|
||||||
|
if (CollectionUtils.isEmpty(idList)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行批量删除
|
||||||
|
int count = pipelineEquipmentDao.deleteBatchByIds(idList);
|
||||||
|
|
||||||
|
return count > 0;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(PipelineEquipment equipment) {
|
||||||
|
return pipelineEquipmentDao.updateByPrimaryKeySelective(equipment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PipelineEquipment selectByPrimaryKey(Integer id) {
|
||||||
|
PipelineEquipment pipelineEquipment = pipelineEquipmentDao.selectByPrimaryKey(id);
|
||||||
|
if (pipelineEquipment != null) {
|
||||||
|
|
||||||
|
//查询对应的设备名称
|
||||||
|
String typeCode = pipelineEquipment.getEquipmentType();
|
||||||
|
DeviceTypeEnum deviceType = DeviceTypeEnum.getByTypeCode(typeCode);
|
||||||
|
if (deviceType != null) {
|
||||||
|
pipelineEquipment.setEquipmentTypeName(deviceType.getTypeName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return pipelineEquipment;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PipelineEquipment> selectListByWhere(String where) {
|
||||||
|
PipelineEquipment pipelineEquipment = new PipelineEquipment();
|
||||||
|
pipelineEquipment.setWhere(where);
|
||||||
|
|
||||||
|
List<PipelineEquipment> list = pipelineEquipmentDao.selectListByWhere(pipelineEquipment);
|
||||||
|
for (PipelineEquipment equipment : list) {
|
||||||
|
String typeCode = equipment.getEquipmentType();
|
||||||
|
DeviceTypeEnum deviceType = DeviceTypeEnum.getByTypeCode(typeCode);
|
||||||
|
if (deviceType != null) {
|
||||||
|
equipment.setEquipmentTypeName(deviceType.getTypeName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@Override
|
||||||
|
public List<PipelineEquipment> getEquipmentByStation(String stationCode) {
|
||||||
|
return equipmentDao.selectByStationCode(stationCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PipelineEquipment> getEquipmentByType(String equipmentType) {
|
||||||
|
return equipmentDao.selectByEquipmentType(equipmentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PipelineEquipment> getEquipmentByStatus(String status) {
|
||||||
|
return equipmentDao.selectByStatus(status);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/*@Override
|
||||||
|
public boolean updateEquipmentStatus(String id, String status) {
|
||||||
|
PipelineEquipment equipment = pipelineEquipmentDao.selectByPrimaryKey(id);
|
||||||
|
if (equipment == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
equipment.setStatus(status);
|
||||||
|
return pipelineEquipmentDao.updateByPrimaryKeySelective(equipment) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateLastUploadTime(String id) {
|
||||||
|
PipelineEquipment equipment = pipelineEquipmentDao.selectByPrimaryKey(id);
|
||||||
|
if (equipment == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
equipment.setLastUploadTime(new Date());
|
||||||
|
return pipelineEquipmentDao.updateByPrimaryKeySelective(equipment) > 0;
|
||||||
|
}*/
|
||||||
|
}
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
package com.sipai.service.data.impl;
|
||||||
|
|
||||||
|
import com.sipai.dao.data.PipelineMpointLibraryDao;
|
||||||
|
import com.sipai.entity.data.PipelineMpointLibrary;
|
||||||
|
import com.sipai.service.data.PipelineMpointLibraryService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Transactional
|
||||||
|
public class PipelineMpointLibraryServiceImpl implements PipelineMpointLibraryService {
|
||||||
|
@Autowired
|
||||||
|
private PipelineMpointLibraryDao pipelineMpointLibraryDao;
|
||||||
|
|
||||||
|
public PipelineMpointLibraryServiceImpl(PipelineMpointLibraryDao mpointLibraryDao) {
|
||||||
|
this.pipelineMpointLibraryDao = mpointLibraryDao;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean insert(PipelineMpointLibrary mpointLibrary) {
|
||||||
|
return pipelineMpointLibraryDao.insert(mpointLibrary);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean delete(String id) {
|
||||||
|
return pipelineMpointLibraryDao.deleteByPrimaryKey(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteBatch(List<String> idList) {
|
||||||
|
return pipelineMpointLibraryDao.deleteBatchByIds(idList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(PipelineMpointLibrary mpointLibrary) {
|
||||||
|
return pipelineMpointLibraryDao.updateByPrimaryKeySelective(mpointLibrary);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PipelineMpointLibrary selectByPrimaryKey(String id) {
|
||||||
|
return pipelineMpointLibraryDao.selectByPrimaryKey(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PipelineMpointLibrary> selectListByWhere(String where) {
|
||||||
|
PipelineMpointLibrary pipelineMpointLibrary = new PipelineMpointLibrary();
|
||||||
|
pipelineMpointLibrary.setWhere(where);
|
||||||
|
|
||||||
|
return pipelineMpointLibraryDao.selectListByWhere(pipelineMpointLibrary);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package com.sipai.service.kafka;
|
||||||
|
|
||||||
|
import org.springframework.kafka.annotation.KafkaListener;
|
||||||
|
import org.springframework.kafka.support.Acknowledgment;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消费者服务
|
||||||
|
*/
|
||||||
|
/*@Service
|
||||||
|
public class KafkaConsumerService {
|
||||||
|
|
||||||
|
@KafkaListener(topics = "topic_data", groupId = "my-group-2.2.0")
|
||||||
|
public void listen(String message, Acknowledgment ack) {
|
||||||
|
try {
|
||||||
|
// System.out.println("topic_data收到数据: " + message);
|
||||||
|
// 手动提交offset
|
||||||
|
ack.acknowledge();
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 处理异常
|
||||||
|
System.err.println("Error processing message: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
package com.sipai.service.kafka;
|
||||||
|
|
||||||
|
import org.springframework.kafka.core.KafkaTemplate;
|
||||||
|
import org.springframework.kafka.support.SendResult;
|
||||||
|
import org.springframework.util.concurrent.ListenableFuture;
|
||||||
|
import org.springframework.util.concurrent.ListenableFutureCallback;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生产者服务
|
||||||
|
*/
|
||||||
|
/*@Service
|
||||||
|
public class KafkaProducerService {
|
||||||
|
|
||||||
|
private final KafkaTemplate<String, String> kafkaTemplate;
|
||||||
|
|
||||||
|
public KafkaProducerService(KafkaTemplate<String, String> kafkaTemplate) {
|
||||||
|
this.kafkaTemplate = kafkaTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendMessage(String topic, String message) {
|
||||||
|
ListenableFuture<SendResult<String, String>> future = kafkaTemplate.send(topic, message);
|
||||||
|
|
||||||
|
future.addCallback(new ListenableFutureCallback<SendResult<String, String>>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(SendResult<String, String> result) {
|
||||||
|
System.out.println("Sent message=[" + message +
|
||||||
|
"] with offset=[" + result.getRecordMetadata().offset() + "]");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable ex) {
|
||||||
|
System.err.println("Unable to send message=[" +
|
||||||
|
message + "] due to : " + ex.getMessage());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}*/
|
||||||
62
src/main/java/com/sipai/service/mqtt/MqttConfigService.java
Normal file
62
src/main/java/com/sipai/service/mqtt/MqttConfigService.java
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
package com.sipai.service.mqtt;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.sipai.entity.mqtt.MqttConfig;
|
||||||
|
import com.sipai.entity.scada.MPoint;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with IntelliJ IDEA.
|
||||||
|
*
|
||||||
|
* @Auther: sj
|
||||||
|
* @Date: 2021/03/24/16:44
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
public interface MqttConfigService {
|
||||||
|
|
||||||
|
public abstract MqttConfig selectByPrimaryKey(String id);
|
||||||
|
|
||||||
|
public abstract Integer deleteByPrimaryKey(String id);
|
||||||
|
|
||||||
|
public abstract Integer insert(MqttConfig entity);
|
||||||
|
|
||||||
|
public abstract Integer updateByPrimaryKeySelective(MqttConfig entity);
|
||||||
|
|
||||||
|
public abstract List<MqttConfig> selectListByWhere(String wherestr);
|
||||||
|
|
||||||
|
public abstract Integer deleteByWhere(String wherestr);
|
||||||
|
|
||||||
|
public String connect(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据主题返回emqx代理地址 websocket方式
|
||||||
|
* sj 2021-09-15
|
||||||
|
* @param topic
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public JSONObject getEmqxHost4WS(String topic);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据主题返回emqx代理地址 tcp方式
|
||||||
|
* sj 2021-09-15
|
||||||
|
* @param topic
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getEmqxHost4TCP(String topic);
|
||||||
|
|
||||||
|
public void doSendMqttVue(List<MPoint> list, String topic);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param jsonArray 需要推送的数据
|
||||||
|
* @param topic 推送的主题
|
||||||
|
*/
|
||||||
|
public void doSendView(JSONArray jsonArray, String topic);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param jsonObject 需要推送的数据
|
||||||
|
* @param topic 推送的主题
|
||||||
|
*/
|
||||||
|
public void doSendJson(JSONObject jsonObject, String topic);
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package com.sipai.service.mqtt;
|
||||||
|
|
||||||
|
import com.sipai.entity.mqtt.MqttConfigTopic;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with IntelliJ IDEA.
|
||||||
|
*
|
||||||
|
* @Auther: sj
|
||||||
|
* @Date: 2021/03/24/17:56
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
public interface MqttConfigTopicService {
|
||||||
|
public abstract MqttConfigTopic selectByPrimaryKey(String id);
|
||||||
|
|
||||||
|
public abstract Integer deleteByPrimaryKey(String id);
|
||||||
|
|
||||||
|
public abstract Integer insert(MqttConfigTopic entity);
|
||||||
|
|
||||||
|
public abstract Integer updateByPrimaryKeySelective(MqttConfigTopic entity);
|
||||||
|
|
||||||
|
public abstract List<MqttConfigTopic> selectListByWhere(String wherestr);
|
||||||
|
|
||||||
|
public abstract Integer deleteByWhere(String wherestr);
|
||||||
|
|
||||||
|
public abstract List<MqttConfigTopic> selectListByPid(String pid);
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user