1 Star 1 Fork 1

sihongwang / 物联网通用后台模型-基于BladeX

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

[TOC]

前言

对于物联网的后端架构设计也是在不断地摸索中,业务划分的可能还不是很清晰,大家可根据实际情况进行取舍。

目录
《DDD领域驱动设计》

一、概述

提示:这里可以添加本文要记录的大概内容

1.1 功能需求

  1. 实体设备接入及控制
  2. 服务治理及监控
  3. 业务权限控制
  4. 高阶治理-机器学习数据预测、告警业务流处理等

1.2 业务流程

我们从大致的三个方面去进行分析

  • 对于数据的提供者
  • 对于数据的获取者及实际的业务操作用户
  • 从业务安全角度出发

数据提供者

从南向业务出发,不谈接口技术,只谈业务情况,大致分为两个类别

  1. 检测型设备
  2. 控制型设备

对于检测型设备来说,是只提供数据传输功能而没有控制效果(或者说它的控制效果对于实际业务情况的帮助不大,例如单纯的开关控制),例如光照传感器设备、客流统计设备、温湿度检测设备。

而对于控制型设备,它传输的数据主要是来源于设备的实时状态,例如灯光、窗帘等,并且从数据传输来说,它是双向的,控制方传输控制指令,设备方返回状态值。

对于上述的两种情况,其实从业务处理中,可以浅划分成两种处理方式:

  1. 实时性处理
  2. 异步处理

这一举措的目的主要是两块

  • 依赖解耦 - 大量的feign调用是需要提前引入各方的API-JAR,数量及业务过多且复杂的情况下稍不留神将导致依赖循环等恶行问题;
  • 功能分离

业务操作人

对于实际业务操作人,也就是用户,需要考虑几个问题

  1. 权限分离

    对于权限分离,例如管理人员、普通用户,是否可操作某个区域的设备?是否可查看某个区域的数据?此时我们就需要做到几个方面:

    • 用户操作记录保存
    • 操作业务的区分,控制 or 查询 ?
    • 权限划分数据表
  2. 请求内容合法性

  3. 请求来源端

    从Unity客户端,抑或是小程序等方向进行请求,在操作同一设备的相反功能情况下,势必会“打架”,是否需要做短延时/同步锁处理(某功能操作后延时2秒后才可以继续操作)?

业务安全

也还是从两个方面去说明

  • 对外安全

    代码漏洞、0day攻击等;

  • 对内安全

    业务所能承受的最大负载、人员误操作等方面;

1.3 中间件分析

针对各中间件对应实际的业务效果

数据存储

MySQL

Apache IOT DB - 时序性数据库的选型

MongoDB

缓存

Redis

消息队列

MQTT

RabbitMQ

RocketMQ

负载均衡

LVS

Nginx

分布式应用协调

Zookeeper

1.4 整体架构设计

根据上述的内容总结后,大致的架构图如下

针对架构区域进行分区剖析

  • 北向对接数据请求客户端(如Unity模型、小程序等),单向反馈数据与控制状态;
  • 南向对接底层数据源,如部分中控厂家、单设备厂家(如施耐德、西门子)、MQTT、Modbus设备及云平台等,实时获取到设备数据与控制接口;
  • 在服务治理上,根据实际需要补充如定时任务框架、线程池监控等第三方服务运维治理组件,保障系统运行稳定性及线上排障有效化;
  • 同时东向对接数据存储源,本地MySQL、Redis缓存,或者云端虚拟化产品;
  • 业务模块中,根据业务情况进行划分,考虑到划分的越细也同时会导致微服务架构的复杂化,要根据实际情况进行取舍;

二、实践落地

提示:这里可以添加本文要记录的大概内容

2.1 包目录设计

源码在最后一个章节,已开源

├─.idea
├─blade-auth-------------------认证服务
├─blade-common--------------公共组件
├─blade-gateway---------------网关Gateway
├─blade-ops--------------------运维中心
│  ├─blade-develop-----------------------------------代码生成器
│  ├─blade-log-----------------------------------日志收集服务
│  ├─blade-report-----------------------------------报表管理
│  ├─blade-resource-----------------------------------资源管理
│  ├─blade-swagger-----------------------------------接口管理
│  └─blade-task------------------------------------------定时任务服务
├─blade-service----------------业务中心
│  ├─blade-advanced------------------------------------高级业务
│  ├─blade-basics------------------------------------------基础服务
│  │  ├─blade-desk------------------------------------------公告管理
│  │  ├─blade-office------------------------------------------办公管理
│  │  ├─blade-system------------------------------------------系统管理
│  │  └─blade-user------------------------------------------用户管理
│  ├─blade-device--------------设备运维
│  │  ├─blade-energy------------------------------------------能耗服务
│  │  ├─blade-environment-----------------------------------环境检测
│  │  └─blade-lamp------------------------------------------灯管理
│  └─blade-external--------------外部接口
│      ├─blade-benyuan-server----------------------------本原私定Socket协议服务
│      └─blade-modbus-client----------------------------Modbus客户端
├─blade-service-api
│  ├─blade-advanced-api
│  ├─blade-basics-api
│  │  ├─blade-desk-api
│  │  ├─blade-dict-api
│  │  ├─blade-office-api
│  │  ├─blade-scope-api
│  │  ├─blade-system-api
│  │  └─blade-user-api
│  ├─blade-device-api
│  │  ├─blade-energy-api
│  │  ├─blade-environment-api
│  │  └─blade-lamp-api
│  └─blade-external-api
├─doc--------------文档说明
├─my-config--------------配置文件目录
├─pic--------------图片
└─script

2.2 系统模块组设计

XMind确实是挺好用的,我种草了。

最后大家可根据实际业务及功能需要进行扩展,目前设计的只针对与物联网行业,但实际上不管怎么变化,架构内核是不变的。

2.3 部署说明

相关的中间件及一些配置都在my-config目录中,例如nacos及MySQL的基础配置,导入即可。

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

基于开源版BladeX所搭建的通用物联网平台服务端 展开 收起
Java
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/wangsihongsh/miot-server.git
git@gitee.com:wangsihongsh/miot-server.git
wangsihongsh
miot-server
物联网通用后台模型-基于BladeX
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891