fix:合并dev-v0.4.6调整
parent
6c8dc8af9f
commit
99ce49f4c5
|
@ -1,53 +0,0 @@
|
|||
version: '1.0'
|
||||
name: branch-pipeline
|
||||
displayName: BranchPipeline
|
||||
stages:
|
||||
- stage:
|
||||
name: compile
|
||||
displayName: 编译
|
||||
steps:
|
||||
- step: build@maven
|
||||
name: build_maven
|
||||
displayName: Maven 构建
|
||||
# 支持6、7、8、9、10、11六个版本
|
||||
jdkVersion: 8
|
||||
# 支持2.2.1、3.2.5、3.3.9、3.5.2、3.5.3、3.5.4、3.6.1、3.6.3八个版本
|
||||
mavenVersion: 3.3.9
|
||||
# 构建命令
|
||||
commands:
|
||||
- mvn -B clean package -Dmaven.test.skip=true
|
||||
# 非必填字段,开启后表示将构建产物暂存,但不会上传到制品库中,7天后自动清除
|
||||
artifacts:
|
||||
# 构建产物名字,作为产物的唯一标识可向下传递,支持自定义,默认为BUILD_ARTIFACT。在下游可以通过${BUILD_ARTIFACT}方式引用来获取构建物地址
|
||||
- name: BUILD_ARTIFACT
|
||||
# 构建产物获取路径,是指代码编译完毕之后构建物的所在路径,如通常jar包在target目录下。当前目录为代码库根目录
|
||||
path:
|
||||
- ./target
|
||||
- step: publish@general_artifacts
|
||||
name: publish_general_artifacts
|
||||
displayName: 上传制品
|
||||
# 上游构建任务定义的产物名,默认BUILD_ARTIFACT
|
||||
dependArtifact: BUILD_ARTIFACT
|
||||
# 上传到制品库时的制品命名,默认output
|
||||
artifactName: output
|
||||
dependsOn: build_maven
|
||||
- stage:
|
||||
name: release
|
||||
displayName: 发布
|
||||
steps:
|
||||
- step: publish@release_artifacts
|
||||
name: publish_release_artifacts
|
||||
displayName: '发布'
|
||||
# 上游上传制品任务的产出
|
||||
dependArtifact: output
|
||||
# 发布制品版本号
|
||||
version: '1.0.0.0'
|
||||
# 是否开启版本号自增,默认开启
|
||||
autoIncrement: true
|
||||
triggers:
|
||||
push:
|
||||
branches:
|
||||
exclude:
|
||||
- master
|
||||
include:
|
||||
- .*
|
|
@ -1,51 +0,0 @@
|
|||
version: '1.0'
|
||||
name: master-pipeline
|
||||
displayName: MasterPipeline
|
||||
stages:
|
||||
- stage:
|
||||
name: compile
|
||||
displayName: 编译
|
||||
steps:
|
||||
- step: build@maven
|
||||
name: build_maven
|
||||
displayName: Maven 构建
|
||||
# 支持6、7、8、9、10、11六个版本
|
||||
jdkVersion: 8
|
||||
# 支持2.2.1、3.2.5、3.3.9、3.5.2、3.5.3、3.5.4、3.6.1、3.6.3八个版本
|
||||
mavenVersion: 3.3.9
|
||||
# 构建命令
|
||||
commands:
|
||||
- mvn -B clean package -Dmaven.test.skip=true
|
||||
# 非必填字段,开启后表示将构建产物暂存,但不会上传到制品库中,7天后自动清除
|
||||
artifacts:
|
||||
# 构建产物名字,作为产物的唯一标识可向下传递,支持自定义,默认为BUILD_ARTIFACT。在下游可以通过${BUILD_ARTIFACT}方式引用来获取构建物地址
|
||||
- name: BUILD_ARTIFACT
|
||||
# 构建产物获取路径,是指代码编译完毕之后构建物的所在路径,如通常jar包在target目录下。当前目录为代码库根目录
|
||||
path:
|
||||
- ./target
|
||||
- step: publish@general_artifacts
|
||||
name: publish_general_artifacts
|
||||
displayName: 上传制品
|
||||
# 上游构建任务定义的产物名,默认BUILD_ARTIFACT
|
||||
dependArtifact: BUILD_ARTIFACT
|
||||
# 上传到制品库时的制品命名,默认output
|
||||
artifactName: output
|
||||
dependsOn: build_maven
|
||||
- stage:
|
||||
name: release
|
||||
displayName: 发布
|
||||
steps:
|
||||
- step: publish@release_artifacts
|
||||
name: publish_release_artifacts
|
||||
displayName: '发布'
|
||||
# 上游上传制品任务的产出
|
||||
dependArtifact: output
|
||||
# 发布制品版本号
|
||||
version: '1.0.0.0'
|
||||
# 是否开启版本号自增,默认开启
|
||||
autoIncrement: true
|
||||
triggers:
|
||||
push:
|
||||
branches:
|
||||
include:
|
||||
- master
|
|
@ -1,40 +0,0 @@
|
|||
version: '1.0'
|
||||
name: pr-pipeline
|
||||
displayName: PRPipeline
|
||||
stages:
|
||||
- stage:
|
||||
name: compile
|
||||
displayName: 编译
|
||||
steps:
|
||||
- step: build@maven
|
||||
name: build_maven
|
||||
displayName: Maven 构建
|
||||
# 支持6、7、8、9、10、11六个版本
|
||||
jdkVersion: 8
|
||||
# 支持2.2.1、3.2.5、3.3.9、3.5.2、3.5.3、3.5.4、3.6.1、3.6.3八个版本
|
||||
mavenVersion: 3.3.9
|
||||
# 构建命令
|
||||
commands:
|
||||
- mvn -B clean package -Dmaven.test.skip=true
|
||||
# 非必填字段,开启后表示将构建产物暂存,但不会上传到制品库中,7天后自动清除
|
||||
artifacts:
|
||||
# 构建产物名字,作为产物的唯一标识可向下传递,支持自定义,默认为BUILD_ARTIFACT。在下游可以通过${BUILD_ARTIFACT}方式引用来获取构建物地址
|
||||
- name: BUILD_ARTIFACT
|
||||
# 构建产物获取路径,是指代码编译完毕之后构建物的所在路径,如通常jar包在target目录下。当前目录为代码库根目录
|
||||
path:
|
||||
- ./target
|
||||
- step: publish@general_artifacts
|
||||
name: publish_general_artifacts
|
||||
displayName: 上传制品
|
||||
# 上游构建任务定义的产物名,默认BUILD_ARTIFACT
|
||||
dependArtifact: BUILD_ARTIFACT
|
||||
# 构建产物制品库,默认default,系统默认创建
|
||||
artifactRepository: default
|
||||
# 上传到制品库时的制品命名,默认output
|
||||
artifactName: output
|
||||
dependsOn: build_maven
|
||||
triggers:
|
||||
pr:
|
||||
branches:
|
||||
include:
|
||||
- master
|
|
@ -1,8 +0,0 @@
|
|||
FROM openjdk:11-jre-slim
|
||||
RUN apt update && apt install -y libfreetype6 fontconfig
|
||||
WORKDIR /app
|
||||
ADD data/init /app/data/init
|
||||
ADD data/converters /app/data/converters
|
||||
ADD data/components /app/data/components
|
||||
ADD iot-starter/target/iot-starter-0.5.0-SNAPSHOT.jar /app/app.jar
|
||||
|
16
README.md
16
README.md
|
@ -1,7 +1,7 @@
|
|||
|
||||
|
||||
<p align="center">
|
||||
<img alt="logo" src="https://xiwasong.github.io/img/logo.png" width="100">
|
||||
<img alt="logo" src="http://www.openiita.com/logo.png">
|
||||
</p>
|
||||
<p align="center"><img src="https://img.shields.io/badge/JDK-11+-important.svg"> <img src="https://img.shields.io/badge/Redis-5.0-important.svg"> <img src="https://img.shields.io/badge/SpringBoot-2.6.2-blue.svg"> <img src="https://img.shields.io/badge/Elasticsearch-7.15.2-red.svg"> <img src="https://img.shields.io/badge/Satoken-1.30.0-yellow.svg">
|
||||
</p>
|
||||
|
@ -73,17 +73,19 @@ Vertx event-bus(内置)、RocketMQ,通过扩展模块可接入其它任意
|
|||
|
||||
**注:** es版本为7.15.2,mysql版本为8.0+
|
||||
|
||||
##### 关系数据库切换为mysql方法(其它数据库同理)
|
||||
##### H2数据库切换为mysql方法(其它数据库同理)
|
||||
1、删掉.init、iotkit.mv.db、iotkit.trace.db文件
|
||||
|
||||
1、将iot-data-serviceImpl-rdb/pom.xml中的mysql驱动注释放开
|
||||
2、将iot-data-serviceImpl-rdb/pom.xml中的mysql驱动注释放开
|
||||
|
||||
2、启动时指定active: --spring.profiles.active=mysql
|
||||
3、application.yml 注释掉内置H2数据库,打开mysql配置注释
|
||||
|
||||
##### 时序数据库切换为TDengin(版本:2.6x)方法
|
||||
##### es切换为TDengine(版本:3.x)方法
|
||||
1、删掉.init和关系数据库数据
|
||||
|
||||
1、注释掉iot-starter/pom.xml中的 iot-temporal-serviceImpl-es,并打开iot-td-temporal-service的注释
|
||||
2、注释掉iot-starter/pom.xml中的 iot-temporal-serviceImpl-es,并打开iot-td-temporal-service的注释
|
||||
|
||||
2、application.xml中注释掉elasticsearch配置,并打开td-datasource配置
|
||||
3、注解掉iot-starter下application.xml中的elasticsearch配置,并打开td-datasource配置
|
||||
|
||||
##### 消息总线切换为RocketMq方法
|
||||
|
||||
|
|
Binary file not shown.
|
@ -1,110 +0,0 @@
|
|||
var mid=1;
|
||||
|
||||
function getMid(){
|
||||
mid++;
|
||||
if(mid>10000){
|
||||
mid=1;
|
||||
}
|
||||
return mid;
|
||||
};
|
||||
function getPkDn(deviceKey){
|
||||
var arr=deviceKey.split("_");
|
||||
return {
|
||||
pk:arr[1],
|
||||
dn:deviceKey
|
||||
};
|
||||
}
|
||||
function register(data){
|
||||
var device=getPkDn(data.data.deviceName)
|
||||
var subDevicesList=data.data.subDevices
|
||||
var subDevices=[]
|
||||
if(subDevicesList!=undefined&&subDevicesList.length>0){
|
||||
apiTool.log("device:"+subDevicesList);
|
||||
for (var i = 0; i < subDevicesList.length; i++) {
|
||||
var deviceKey=subDevicesList[i]
|
||||
var subDevice=getPkDn(deviceKey)
|
||||
subDevices.push({
|
||||
productKey:subDevice.pk,
|
||||
deviceName:subDevice.dn,
|
||||
model:''
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var reply=
|
||||
{
|
||||
productKey:device.pk,
|
||||
deviceName:device.dn,
|
||||
mid:"0",
|
||||
content:{
|
||||
id:data.id,
|
||||
type:data.type,
|
||||
result:'success'
|
||||
}
|
||||
};
|
||||
var data={
|
||||
productKey:device.pk,
|
||||
deviceName:device.dn
|
||||
}
|
||||
if(subDevices.length>0){
|
||||
data['subDevices']=subDevices
|
||||
}
|
||||
apiTool.log("subDevices:"+JSON.stringify(data));
|
||||
return {
|
||||
type:"register",
|
||||
data:data,
|
||||
action:{
|
||||
type:"ack",
|
||||
content:JSON.stringify(reply)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function online(data){
|
||||
apiTool.log("data:"+JSON.stringify(data));
|
||||
var device=getPkDn(data.data.deviceName)
|
||||
return {
|
||||
type:"state",
|
||||
data:{
|
||||
productKey:device.pk,
|
||||
deviceName:device.dn,
|
||||
state:data.type
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function offline(data){
|
||||
var device=getPkDn(data.deviceKey)
|
||||
return {
|
||||
type:"state",
|
||||
data:{
|
||||
productKey:device.pk,
|
||||
deviceName:device.dn,
|
||||
state:data.type
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
//必须提供onReceive方法
|
||||
this.onReceive=function(head,type,payload){
|
||||
var data=JSON.parse(payload)
|
||||
if(data.type=="register"){
|
||||
apiTool.log("data:"+payload);
|
||||
return register(data)
|
||||
}else if(data.type=="online"){
|
||||
return online(data);
|
||||
}else if(data.type=="offline"){
|
||||
return offline(data);
|
||||
}
|
||||
return {
|
||||
productKey:"",
|
||||
deviceName:"",
|
||||
mid:0,
|
||||
content:{
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.onRegistered=function (data,status) {
|
||||
apiTool.log("onRegistered调用");
|
||||
}
|
Binary file not shown.
|
@ -1,74 +0,0 @@
|
|||
var mid=1;
|
||||
|
||||
var gatewayPk="BRD3x4fkKxkaxXFt"
|
||||
var smartMeterPk="PwMfpXmp4ZWkGahn"
|
||||
|
||||
function getMid(){
|
||||
mid++;
|
||||
if(mid>10000){
|
||||
mid=1;
|
||||
}
|
||||
return mid;
|
||||
};
|
||||
function register(head){
|
||||
var mac= head.mac;
|
||||
return {
|
||||
type:"register",
|
||||
data:{
|
||||
productKey:gatewayPk,
|
||||
deviceName:mac,
|
||||
model:""
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function deviceStateChange(head,type){
|
||||
var mac=head.mac;
|
||||
return {
|
||||
type:"state",
|
||||
data:{
|
||||
productKey:gatewayPk,
|
||||
deviceName:mac,
|
||||
state:type
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function dltHandle(payload){
|
||||
var dltData= JSON.parse(payload);
|
||||
var identify= dltData.identify;
|
||||
var content={};
|
||||
content[identify]=dltData.data;
|
||||
return {
|
||||
type:"report",
|
||||
data:{
|
||||
productKey:smartMeterPk,
|
||||
deviceName:dltData.deviceAddress,
|
||||
mid:getMid(),
|
||||
content:{
|
||||
type:"property",
|
||||
identifier: "report", //属性上报
|
||||
occur: new Date().getTime(), //时间戳,设备上的事件或数据产生的本地时间
|
||||
time: new Date().getTime(), //时间戳,消息上报时间
|
||||
data: content
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
//必须提供onReceive方法
|
||||
this.onReceive=function(head,type,payload){
|
||||
if("register"==type){
|
||||
return register(head);
|
||||
}else if("online"==type){
|
||||
return deviceStateChange(head,type);
|
||||
}else if("offline"==type){
|
||||
return deviceStateChange(head,type);
|
||||
}else if("dlt"==type){
|
||||
return dltHandle(payload);
|
||||
}
|
||||
};
|
||||
|
||||
this.onRegistered=function (data,status) {
|
||||
apiTool.log("onRegistered调用");
|
||||
}
|
Binary file not shown.
|
@ -1,238 +0,0 @@
|
|||
//api配置
|
||||
apiTool.config("127.0.0.1",8085,3000);
|
||||
|
||||
this.onReceive=function(method,path,header,params,body){
|
||||
//method:post、get、delete...
|
||||
//path:请求路径
|
||||
//header:http请求头数据,结构:{xx:xx,yy:yy}
|
||||
//params:请求参数,结构:{xx:[...],yy:[...]}
|
||||
//body:请求体,当提交的数据为json格式时使用,结构:{xx:xx,yy:yy}
|
||||
apiTool.log("onReceive body:"+body);
|
||||
var duHeader=body.header;
|
||||
var namespace=duHeader.namespace;
|
||||
var requestName=duHeader.name;
|
||||
var messageId=duHeader.messageId;
|
||||
var duPayload=body.payload;
|
||||
var token=duPayload.accessToken;
|
||||
var openUid=duPayload.openUid;
|
||||
|
||||
//设备发现
|
||||
if(namespace=="DuerOS.ConnectedHome.Discovery" && requestName=="DiscoverAppliancesRequest"){
|
||||
var deviceIds=[];
|
||||
var discoveredDevices=[];
|
||||
var content={
|
||||
header:{
|
||||
namespace:"DuerOS.ConnectedHome.Discovery",
|
||||
name:"DiscoverAppliancesResponse",
|
||||
messageId:messageId,
|
||||
payloadVersion:1
|
||||
},
|
||||
payload:{
|
||||
discoveredAppliances:discoveredDevices,
|
||||
discoveredGroups:[{
|
||||
groupName:"客厅",
|
||||
applianceIds:deviceIds,
|
||||
groupNotes:"客厅分组控制",
|
||||
additionalGroupDetails:{}
|
||||
}]
|
||||
}
|
||||
};
|
||||
var rst=apiTool.getSpaceDevices(token);
|
||||
apiTool.log(JSON.stringify(rst));
|
||||
if(rst && rst.status==200 && rst.data){
|
||||
var devices=rst.data;
|
||||
for(var i in devices){
|
||||
var device=devices[i];
|
||||
var did=device.deviceId;
|
||||
var pk=device.productKey;
|
||||
var dn=device.deviceName;
|
||||
|
||||
//更新设备openUid
|
||||
rst=apiTool.setOpenUid(token,did,"dueros",openUid);
|
||||
if(!rst || rst.status!=200){
|
||||
continue;
|
||||
}
|
||||
|
||||
//插座
|
||||
if(pk=="cGCrkK7Ex4FESAwe"){
|
||||
var powerstate=device.property.powerstate;
|
||||
discoveredDevices.push({
|
||||
actions:["turnOn","turnOff"],
|
||||
applianceTypes:["SOCKET"],
|
||||
additionalApplianceDetails:{},
|
||||
applianceId:device.deviceId,
|
||||
friendlyDescription:"智能插座",
|
||||
friendlyName:device.name,
|
||||
isReachable:device.online,
|
||||
manufacturerName:"海曼",
|
||||
modelName:"S1",
|
||||
version:"v1.0",
|
||||
attributes:[
|
||||
{
|
||||
name:"客厅的插座",
|
||||
scale:"",
|
||||
timestampOfSample:0,
|
||||
uncertaintyInMilliseconds:10
|
||||
},
|
||||
{
|
||||
name:"connectivity",
|
||||
value:"REACHABLE",
|
||||
scale:"",
|
||||
timestampOfSample:0,
|
||||
uncertaintyInMilliseconds:10
|
||||
},
|
||||
{
|
||||
name:"turnOnState",
|
||||
value:powerstate==1?"ON":"OFF",
|
||||
scale:"",
|
||||
timestampOfSample:0,
|
||||
uncertaintyInMilliseconds:10,
|
||||
legalValue:"(ON, OFF)"
|
||||
}
|
||||
]
|
||||
});
|
||||
}else if(pk=="Rf4QSjbm65X45753"){
|
||||
//开关
|
||||
var powerstate=device.property.powerstate;
|
||||
discoveredDevices.push({
|
||||
actions:["turnOn","turnOff"],
|
||||
applianceTypes:["SWITCH"],
|
||||
additionalApplianceDetails:{},
|
||||
applianceId:device.deviceId,
|
||||
friendlyDescription:"智能开关",
|
||||
friendlyName:device.name,
|
||||
isReachable:device.online,
|
||||
manufacturerName:"海曼",
|
||||
modelName:"S1",
|
||||
version:"v1.0",
|
||||
attributes:[
|
||||
{
|
||||
name:"客厅的开关",
|
||||
scale:"",
|
||||
timestampOfSample:0,
|
||||
uncertaintyInMilliseconds:10
|
||||
},
|
||||
{
|
||||
name:"connectivity",
|
||||
value:"REACHABLE",
|
||||
scale:"",
|
||||
timestampOfSample:0,
|
||||
uncertaintyInMilliseconds:10
|
||||
},
|
||||
{
|
||||
name:"turnOnState",
|
||||
value:powerstate==1?"ON":"OFF",
|
||||
scale:"",
|
||||
timestampOfSample:0,
|
||||
uncertaintyInMilliseconds:10,
|
||||
legalValue:"(ON, OFF)"
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
url:"",//不指定直接作为响应返回
|
||||
header:{
|
||||
contentType:"application/json"
|
||||
},
|
||||
content:JSON.stringify(content)
|
||||
}
|
||||
}else if(namespace=="DuerOS.ConnectedHome.Control"){
|
||||
//设备控制
|
||||
var appliance=duPayload.appliance;
|
||||
var deviceId=appliance.applianceId;
|
||||
var confirmName="UnsupportedOperationError";
|
||||
var rst={status:500};
|
||||
|
||||
//开关
|
||||
if(requestName=="TurnOnRequest"){
|
||||
//开
|
||||
confirmName="TurnOnConfirmation";
|
||||
rst=apiTool.setProperties(token,deviceId,{powerstate:1});
|
||||
}else if(requestName=="TurnOffRequest"){
|
||||
//关
|
||||
confirmName="TurnOffConfirmation";
|
||||
rst=apiTool.setProperties(token,deviceId,{powerstate:0});
|
||||
}
|
||||
|
||||
if(rst.status!=200){
|
||||
confirmName="UnsupportedOperationError";
|
||||
apiTool.log("device control failed:"+JSON.stringify(rst));
|
||||
}
|
||||
|
||||
var content={
|
||||
header: {
|
||||
namespace: "DuerOS.ConnectedHome.Control",
|
||||
name: confirmName,
|
||||
messageId: messageId,
|
||||
payloadVersion: "1"
|
||||
},
|
||||
payload: {
|
||||
"attributes": []
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
url:"",
|
||||
header:{
|
||||
contentType:"application/json"
|
||||
},
|
||||
content:JSON.stringify(content)
|
||||
}
|
||||
}else if(namespace=="DuerOS.ConnectedHome.Query"){
|
||||
//属性查询
|
||||
if(requestName=="ReportStateRequest"){
|
||||
var appliance=duPayload.appliance;
|
||||
var deviceId=appliance.applianceId;
|
||||
var property=appliance.attributeName;
|
||||
var propertyVal="";
|
||||
var success=false;
|
||||
if(property=="turnOnState"){
|
||||
//开关状态查询
|
||||
var rst= apiTool.getSpaceDeviceDetail(token,deviceId);
|
||||
if(rst && rst.status==200 && rst.data.property){
|
||||
propertyVal=rst.data.property.powerstate==1?"ON":"OFF";
|
||||
success=true;
|
||||
}
|
||||
}
|
||||
var content=success?{
|
||||
"header": {
|
||||
"namespace": "DuerOS.ConnectedHome.Query",
|
||||
"name": "ReportStateResponse",
|
||||
"messageId": new Date().getTime()+"",
|
||||
"payloadVersion": "1"
|
||||
},
|
||||
"payload": {
|
||||
"attributes": [
|
||||
{
|
||||
"name": property,
|
||||
"value": propertyVal,
|
||||
"scale": "",
|
||||
"timestampOfSample": new Date().getTime()/1000,
|
||||
"uncertaintyInMilliseconds": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
}:{};
|
||||
|
||||
return {
|
||||
url:"",
|
||||
header:{
|
||||
contentType:"application/json"
|
||||
},
|
||||
content:JSON.stringify(content)
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
url:"",//不指定直接作为响应返回
|
||||
header:{
|
||||
contentType:"application/json"
|
||||
},
|
||||
content:""
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -1,390 +0,0 @@
|
|||
!function (n) {
|
||||
"use strict";
|
||||
|
||||
function d(n, t) {
|
||||
var r = (65535 & n) + (65535 & t);
|
||||
return (n >> 16) + (t >> 16) + (r >> 16) << 16 | 65535 & r
|
||||
}
|
||||
|
||||
function f(n, t, r, e, o, u) {
|
||||
return d((u = d(d(t, n), d(e, u))) << o | u >>> 32 - o, r)
|
||||
}
|
||||
|
||||
function l(n, t, r, e, o, u, c) {
|
||||
return f(t & r | ~t & e, n, t, o, u, c)
|
||||
}
|
||||
|
||||
function g(n, t, r, e, o, u, c) {
|
||||
return f(t & e | r & ~e, n, t, o, u, c)
|
||||
}
|
||||
|
||||
function v(n, t, r, e, o, u, c) {
|
||||
return f(t ^ r ^ e, n, t, o, u, c)
|
||||
}
|
||||
|
||||
function m(n, t, r, e, o, u, c) {
|
||||
return f(r ^ (t | ~e), n, t, o, u, c)
|
||||
}
|
||||
|
||||
function c(n, t) {
|
||||
var r, e, o, u;
|
||||
n[t >> 5] |= 128 << t % 32, n[14 + (t + 64 >>> 9 << 4)] = t;
|
||||
for (var c = 1732584193, f = -271733879, i = -1732584194, a = 271733878, h = 0; h < n.length; h += 16) c = l(r = c, e = f, o = i, u = a, n[h], 7, -680876936), a = l(a, c, f, i, n[h + 1], 12, -389564586), i = l(i, a, c, f, n[h + 2], 17, 606105819), f = l(f, i, a, c, n[h + 3], 22, -1044525330), c = l(c, f, i, a, n[h + 4], 7, -176418897), a = l(a, c, f, i, n[h + 5], 12, 1200080426), i = l(i, a, c, f, n[h + 6], 17, -1473231341), f = l(f, i, a, c, n[h + 7], 22, -45705983), c = l(c, f, i, a, n[h + 8], 7, 1770035416), a = l(a, c, f, i, n[h + 9], 12, -1958414417), i = l(i, a, c, f, n[h + 10], 17, -42063), f = l(f, i, a, c, n[h + 11], 22, -1990404162), c = l(c, f, i, a, n[h + 12], 7, 1804603682), a = l(a, c, f, i, n[h + 13], 12, -40341101), i = l(i, a, c, f, n[h + 14], 17, -1502002290), c = g(c, f = l(f, i, a, c, n[h + 15], 22, 1236535329), i, a, n[h + 1], 5, -165796510), a = g(a, c, f, i, n[h + 6], 9, -1069501632), i = g(i, a, c, f, n[h + 11], 14, 643717713), f = g(f, i, a, c, n[h], 20, -373897302), c = g(c, f, i, a, n[h + 5], 5, -701558691), a = g(a, c, f, i, n[h + 10], 9, 38016083), i = g(i, a, c, f, n[h + 15], 14, -660478335), f = g(f, i, a, c, n[h + 4], 20, -405537848), c = g(c, f, i, a, n[h + 9], 5, 568446438), a = g(a, c, f, i, n[h + 14], 9, -1019803690), i = g(i, a, c, f, n[h + 3], 14, -187363961), f = g(f, i, a, c, n[h + 8], 20, 1163531501), c = g(c, f, i, a, n[h + 13], 5, -1444681467), a = g(a, c, f, i, n[h + 2], 9, -51403784), i = g(i, a, c, f, n[h + 7], 14, 1735328473), c = v(c, f = g(f, i, a, c, n[h + 12], 20, -1926607734), i, a, n[h + 5], 4, -378558), a = v(a, c, f, i, n[h + 8], 11, -2022574463), i = v(i, a, c, f, n[h + 11], 16, 1839030562), f = v(f, i, a, c, n[h + 14], 23, -35309556), c = v(c, f, i, a, n[h + 1], 4, -1530992060), a = v(a, c, f, i, n[h + 4], 11, 1272893353), i = v(i, a, c, f, n[h + 7], 16, -155497632), f = v(f, i, a, c, n[h + 10], 23, -1094730640), c = v(c, f, i, a, n[h + 13], 4, 681279174), a = v(a, c, f, i, n[h], 11, -358537222), i = v(i, a, c, f, n[h + 3], 16, -722521979), f = v(f, i, a, c, n[h + 6], 23, 76029189), c = v(c, f, i, a, n[h + 9], 4, -640364487), a = v(a, c, f, i, n[h + 12], 11, -421815835), i = v(i, a, c, f, n[h + 15], 16, 530742520), c = m(c, f = v(f, i, a, c, n[h + 2], 23, -995338651), i, a, n[h], 6, -198630844), a = m(a, c, f, i, n[h + 7], 10, 1126891415), i = m(i, a, c, f, n[h + 14], 15, -1416354905), f = m(f, i, a, c, n[h + 5], 21, -57434055), c = m(c, f, i, a, n[h + 12], 6, 1700485571), a = m(a, c, f, i, n[h + 3], 10, -1894986606), i = m(i, a, c, f, n[h + 10], 15, -1051523), f = m(f, i, a, c, n[h + 1], 21, -2054922799), c = m(c, f, i, a, n[h + 8], 6, 1873313359), a = m(a, c, f, i, n[h + 15], 10, -30611744), i = m(i, a, c, f, n[h + 6], 15, -1560198380), f = m(f, i, a, c, n[h + 13], 21, 1309151649), c = m(c, f, i, a, n[h + 4], 6, -145523070), a = m(a, c, f, i, n[h + 11], 10, -1120210379), i = m(i, a, c, f, n[h + 2], 15, 718787259), f = m(f, i, a, c, n[h + 9], 21, -343485551), c = d(c, r), f = d(f, e), i = d(i, o), a = d(a, u);
|
||||
return [c, f, i, a]
|
||||
}
|
||||
|
||||
function i(n) {
|
||||
for (var t = "", r = 32 * n.length, e = 0; e < r; e += 8) t += String.fromCharCode(n[e >> 5] >>> e % 32 & 255);
|
||||
return t
|
||||
}
|
||||
|
||||
function a(n) {
|
||||
var t = [];
|
||||
for (t[(n.length >> 2) - 1] = void 0, e = 0; e < t.length; e += 1) t[e] = 0;
|
||||
for (var r = 8 * n.length, e = 0; e < r; e += 8) t[e >> 5] |= (255 & n.charCodeAt(e / 8)) << e % 32;
|
||||
return t
|
||||
}
|
||||
|
||||
function e(n) {
|
||||
for (var t, r = "0123456789abcdef", e = "", o = 0; o < n.length; o += 1) t = n.charCodeAt(o), e += r.charAt(t >>> 4 & 15) + r.charAt(15 & t);
|
||||
return e
|
||||
}
|
||||
|
||||
function r(n) {
|
||||
return unescape(encodeURIComponent(n))
|
||||
}
|
||||
|
||||
function o(n) {
|
||||
return i(c(a(n = r(n)), 8 * n.length))
|
||||
}
|
||||
|
||||
function u(n, t) {
|
||||
return function (n, t) {
|
||||
var r, e = a(n), o = [], u = [];
|
||||
for (o[15] = u[15] = void 0, 16 < e.length && (e = c(e, 8 * n.length)), r = 0; r < 16; r += 1) o[r] = 909522486 ^ e[r], u[r] = 1549556828 ^ e[r];
|
||||
return t = c(o.concat(a(t)), 512 + 8 * t.length), i(c(u.concat(t), 640))
|
||||
}(r(n), r(t))
|
||||
}
|
||||
|
||||
function t(n, t, r) {
|
||||
return t ? r ? u(t, n) : e(u(t, n)) : r ? o(n) : e(o(n))
|
||||
}
|
||||
|
||||
"function" == typeof define && define.amd ? define(function () {
|
||||
return t
|
||||
}) : "object" == typeof module && module.exports ? module.exports = t : n.md5 = t
|
||||
}(this);
|
||||
var md5 = this.md5;
|
||||
|
||||
function isServerId(clientId) {
|
||||
return JSON.parse(component.getCompMqttClientIdList()).indexOf(clientId) > -1
|
||||
}
|
||||
|
||||
function getPkDn(clientId) {
|
||||
var arr = clientId.split("_");
|
||||
return {
|
||||
pk: arr[0],
|
||||
dn: arr[1]
|
||||
};
|
||||
}
|
||||
|
||||
function auth(head, type, payload) {
|
||||
if (isServerId(payload.clientid)) {
|
||||
return {
|
||||
type: "serverAuth",
|
||||
data: {
|
||||
productKey: "pd",
|
||||
deviceName: "dn",
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
var arr = payload.clientid.split("_");
|
||||
if (arr.length < 3) {
|
||||
throw new Error("incorrect clientid:" + payload.clientid);
|
||||
}
|
||||
|
||||
var pk = arr[0];
|
||||
var dn = arr[1];
|
||||
var model = arr[2];
|
||||
var product = deviceBehaviour.getProductKey(pk)
|
||||
var pwd = md5(product.getProductSecret() + payload.clientid);
|
||||
|
||||
if (pwd.toLocaleLowerCase() != payload.password.toLocaleLowerCase()) {
|
||||
throw new Error("incorrect password");
|
||||
}
|
||||
return {
|
||||
type: "register",
|
||||
data: {
|
||||
productKey: pk,
|
||||
deviceName: dn,
|
||||
model: model
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function acl(head, type, payload) {
|
||||
var _topic = payload.topic;
|
||||
|
||||
if (isServerId(payload.clientid)) {
|
||||
return {
|
||||
type: "acl",
|
||||
data: {
|
||||
productKey: "pd",
|
||||
deviceName: "dn",
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// 客户端订阅处理
|
||||
if (/^\/sys\/.+\/.+\/c\/#/i.test(_topic)) {
|
||||
return subscribe(head, type, payload);
|
||||
}
|
||||
|
||||
// 服务端订阅处理
|
||||
if (/^\/sys\/.+\/.+\/s\/.*/i.test(_topic)) {
|
||||
return subscribe(head, type, payload);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function register(head, type, payload) {
|
||||
var auth = payload;
|
||||
var arr = auth.clientid.split("_");
|
||||
if (arr.length < 3) {
|
||||
throw new Error("incorrect clientid:" + auth.clientid);
|
||||
}
|
||||
|
||||
var pk = arr[0];
|
||||
var dn = arr[1];
|
||||
var model = arr[2];
|
||||
var product = deviceBehaviour.getProductKey(pk)
|
||||
var pwd = md5(product.getProductSecret() + auth.clientid);
|
||||
|
||||
if (pwd.toLocaleLowerCase() != auth.password.toLocaleLowerCase()) {
|
||||
throw new Error("incorrect password");
|
||||
}
|
||||
return {
|
||||
type: "register",
|
||||
data: {
|
||||
productKey: pk,
|
||||
deviceName: dn,
|
||||
model: model
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function subRegister(topic, parent, payload) {
|
||||
if (!topic) {
|
||||
throw new Error("topic is blank")
|
||||
}
|
||||
|
||||
|
||||
var params = payload.params;
|
||||
|
||||
var reply =
|
||||
{
|
||||
productKey: parent.productKey,
|
||||
deviceName: parent.deviceName,
|
||||
mid: "0",
|
||||
content: {
|
||||
topic: topic.replace("/s/", "/c/") + "_reply",
|
||||
payload: JSON.stringify({
|
||||
id: payload.id,
|
||||
code: 0,
|
||||
data: {
|
||||
"productKey": params.productKey,
|
||||
"deviceName": params.deviceName
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
type: "register",
|
||||
data: {
|
||||
productKey: parent.productKey,
|
||||
deviceName: parent.deviceName,
|
||||
subDevices: [{
|
||||
productKey: params.productKey,
|
||||
deviceName: params.deviceName,
|
||||
model: params.model
|
||||
}]
|
||||
},
|
||||
action: {
|
||||
type: "ack",
|
||||
content: JSON.stringify(reply)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function disconnect(head, type, payload) {
|
||||
var clientId = payload.clientid
|
||||
var device = getPkDn(clientId);
|
||||
return {
|
||||
type: "state",
|
||||
data: {
|
||||
productKey: device.pk,
|
||||
deviceName: device.dn,
|
||||
state: "offline"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function connect(head, type, payload) {
|
||||
var clientId = payload.clientid
|
||||
var device = getPkDn(clientId);
|
||||
return {
|
||||
type: "state",
|
||||
data: {
|
||||
productKey: device.pk,
|
||||
deviceName: device.dn,
|
||||
state: "online"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function unsubscribe(head, type, payload) {
|
||||
var topic = payload.topic;
|
||||
|
||||
if (isServerId(payload.clientid)) {
|
||||
return {
|
||||
type: "acl",
|
||||
data: {
|
||||
productKey: "pd",
|
||||
deviceName: "dn",
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var arr = topic.split('/');
|
||||
if (arr.length < 6) {
|
||||
throw new Error("incorrect topic: " + topic)
|
||||
}
|
||||
|
||||
var pk = arr[2];
|
||||
var dn = arr[3];
|
||||
|
||||
return {
|
||||
type: "state",
|
||||
data: {
|
||||
productKey: pk,
|
||||
deviceName: dn,
|
||||
state: "offline"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function subscribe(head, type, payload) {
|
||||
var topic = payload.topic;
|
||||
|
||||
if (isServerId(payload.clientid)) {
|
||||
return {
|
||||
type: "acl",
|
||||
data: {
|
||||
productKey: "pd",
|
||||
deviceName: "dn",
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var arr = topic.split('/');
|
||||
if (arr.length < 6) {
|
||||
throw new Error("incorrect topic: " + topic)
|
||||
}
|
||||
var pk = arr[2];
|
||||
var dn = arr[3];
|
||||
|
||||
return {
|
||||
type: "state",
|
||||
data: {
|
||||
productKey: pk,
|
||||
deviceName: dn,
|
||||
state: "online"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var messageHandler = {
|
||||
"/sys/client/connected": connect,
|
||||
"/sys/client/disconnected": disconnect,
|
||||
"/mqtt/auth": auth,
|
||||
"/mqtt/acl": acl,
|
||||
"/sys/session/subscribed": subscribe,
|
||||
"/sys/session/unsubscribed": unsubscribe
|
||||
}
|
||||
|
||||
//必须提供onReceive方法
|
||||
this.onReceive = function (head, type, payload) {
|
||||
payload = JSON.parse(payload);
|
||||
|
||||
var result = {};
|
||||
var topic = head.topic;
|
||||
if (!topic) {
|
||||
return result;
|
||||
}
|
||||
|
||||
var fun = messageHandler[topic];
|
||||
|
||||
if (fun) {
|
||||
return fun(head, type, payload)
|
||||
} else {
|
||||
var arr = topic.split('/');
|
||||
if (arr.length < 6) {
|
||||
throw new Error("incorrect topic: " + topic)
|
||||
}
|
||||
var pk = arr[2];
|
||||
var dn = arr[3];
|
||||
|
||||
//子设备注册
|
||||
if (topic.endsWith('/register')) {
|
||||
return subRegister(topic, {productKey: pk, deviceName: dn}, payload);
|
||||
}
|
||||
|
||||
//数据上报
|
||||
var reply =
|
||||
{
|
||||
productKey: pk,
|
||||
deviceName: dn,
|
||||
mid: payload.id,
|
||||
content: {
|
||||
topic: topic.replace("/s/", "/c/") + "_reply",
|
||||
payload: JSON.stringify({
|
||||
id: payload.id,
|
||||
method: payload.method + "_reply",
|
||||
code: 0,
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
var action = {};
|
||||
if (!topic.endsWith("_reply")) {
|
||||
//需要回复的消息
|
||||
action = {
|
||||
type: "ack",
|
||||
content: JSON.stringify(reply)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
type: "report",
|
||||
data: {
|
||||
productKey: pk,
|
||||
deviceName: dn,
|
||||
mid: payload.id,
|
||||
content: {
|
||||
topic: topic,
|
||||
payload: payload
|
||||
}
|
||||
},
|
||||
action: action
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
this.onRegistered = function (regInfo, result) {
|
||||
}
|
Binary file not shown.
|
@ -1,339 +0,0 @@
|
|||
!function (n) {
|
||||
"use strict";
|
||||
|
||||
function d(n, t) {
|
||||
var r = (65535 & n) + (65535 & t);
|
||||
return (n >> 16) + (t >> 16) + (r >> 16) << 16 | 65535 & r
|
||||
}
|
||||
|
||||
function f(n, t, r, e, o, u) {
|
||||
return d((u = d(d(t, n), d(e, u))) << o | u >>> 32 - o, r)
|
||||
}
|
||||
|
||||
function l(n, t, r, e, o, u, c) {
|
||||
return f(t & r | ~t & e, n, t, o, u, c)
|
||||
}
|
||||
|
||||
function g(n, t, r, e, o, u, c) {
|
||||
return f(t & e | r & ~e, n, t, o, u, c)
|
||||
}
|
||||
|
||||
function v(n, t, r, e, o, u, c) {
|
||||
return f(t ^ r ^ e, n, t, o, u, c)
|
||||
}
|
||||
|
||||
function m(n, t, r, e, o, u, c) {
|
||||
return f(r ^ (t | ~e), n, t, o, u, c)
|
||||
}
|
||||
|
||||
function c(n, t) {
|
||||
var r, e, o, u;
|
||||
n[t >> 5] |= 128 << t % 32, n[14 + (t + 64 >>> 9 << 4)] = t;
|
||||
for (var c = 1732584193, f = -271733879, i = -1732584194, a = 271733878, h = 0; h < n.length; h += 16) c = l(r = c, e = f, o = i, u = a, n[h], 7, -680876936), a = l(a, c, f, i, n[h + 1], 12, -389564586), i = l(i, a, c, f, n[h + 2], 17, 606105819), f = l(f, i, a, c, n[h + 3], 22, -1044525330), c = l(c, f, i, a, n[h + 4], 7, -176418897), a = l(a, c, f, i, n[h + 5], 12, 1200080426), i = l(i, a, c, f, n[h + 6], 17, -1473231341), f = l(f, i, a, c, n[h + 7], 22, -45705983), c = l(c, f, i, a, n[h + 8], 7, 1770035416), a = l(a, c, f, i, n[h + 9], 12, -1958414417), i = l(i, a, c, f, n[h + 10], 17, -42063), f = l(f, i, a, c, n[h + 11], 22, -1990404162), c = l(c, f, i, a, n[h + 12], 7, 1804603682), a = l(a, c, f, i, n[h + 13], 12, -40341101), i = l(i, a, c, f, n[h + 14], 17, -1502002290), c = g(c, f = l(f, i, a, c, n[h + 15], 22, 1236535329), i, a, n[h + 1], 5, -165796510), a = g(a, c, f, i, n[h + 6], 9, -1069501632), i = g(i, a, c, f, n[h + 11], 14, 643717713), f = g(f, i, a, c, n[h], 20, -373897302), c = g(c, f, i, a, n[h + 5], 5, -701558691), a = g(a, c, f, i, n[h + 10], 9, 38016083), i = g(i, a, c, f, n[h + 15], 14, -660478335), f = g(f, i, a, c, n[h + 4], 20, -405537848), c = g(c, f, i, a, n[h + 9], 5, 568446438), a = g(a, c, f, i, n[h + 14], 9, -1019803690), i = g(i, a, c, f, n[h + 3], 14, -187363961), f = g(f, i, a, c, n[h + 8], 20, 1163531501), c = g(c, f, i, a, n[h + 13], 5, -1444681467), a = g(a, c, f, i, n[h + 2], 9, -51403784), i = g(i, a, c, f, n[h + 7], 14, 1735328473), c = v(c, f = g(f, i, a, c, n[h + 12], 20, -1926607734), i, a, n[h + 5], 4, -378558), a = v(a, c, f, i, n[h + 8], 11, -2022574463), i = v(i, a, c, f, n[h + 11], 16, 1839030562), f = v(f, i, a, c, n[h + 14], 23, -35309556), c = v(c, f, i, a, n[h + 1], 4, -1530992060), a = v(a, c, f, i, n[h + 4], 11, 1272893353), i = v(i, a, c, f, n[h + 7], 16, -155497632), f = v(f, i, a, c, n[h + 10], 23, -1094730640), c = v(c, f, i, a, n[h + 13], 4, 681279174), a = v(a, c, f, i, n[h], 11, -358537222), i = v(i, a, c, f, n[h + 3], 16, -722521979), f = v(f, i, a, c, n[h + 6], 23, 76029189), c = v(c, f, i, a, n[h + 9], 4, -640364487), a = v(a, c, f, i, n[h + 12], 11, -421815835), i = v(i, a, c, f, n[h + 15], 16, 530742520), c = m(c, f = v(f, i, a, c, n[h + 2], 23, -995338651), i, a, n[h], 6, -198630844), a = m(a, c, f, i, n[h + 7], 10, 1126891415), i = m(i, a, c, f, n[h + 14], 15, -1416354905), f = m(f, i, a, c, n[h + 5], 21, -57434055), c = m(c, f, i, a, n[h + 12], 6, 1700485571), a = m(a, c, f, i, n[h + 3], 10, -1894986606), i = m(i, a, c, f, n[h + 10], 15, -1051523), f = m(f, i, a, c, n[h + 1], 21, -2054922799), c = m(c, f, i, a, n[h + 8], 6, 1873313359), a = m(a, c, f, i, n[h + 15], 10, -30611744), i = m(i, a, c, f, n[h + 6], 15, -1560198380), f = m(f, i, a, c, n[h + 13], 21, 1309151649), c = m(c, f, i, a, n[h + 4], 6, -145523070), a = m(a, c, f, i, n[h + 11], 10, -1120210379), i = m(i, a, c, f, n[h + 2], 15, 718787259), f = m(f, i, a, c, n[h + 9], 21, -343485551), c = d(c, r), f = d(f, e), i = d(i, o), a = d(a, u);
|
||||
return [c, f, i, a]
|
||||
}
|
||||
|
||||
function i(n) {
|
||||
for (var t = "", r = 32 * n.length, e = 0; e < r; e += 8) t += String.fromCharCode(n[e >> 5] >>> e % 32 & 255);
|
||||
return t
|
||||
}
|
||||
|
||||
function a(n) {
|
||||
var t = [];
|
||||
for (t[(n.length >> 2) - 1] = void 0, e = 0; e < t.length; e += 1) t[e] = 0;
|
||||
for (var r = 8 * n.length, e = 0; e < r; e += 8) t[e >> 5] |= (255 & n.charCodeAt(e / 8)) << e % 32;
|
||||
return t
|
||||
}
|
||||
|
||||
function e(n) {
|
||||
for (var t, r = "0123456789abcdef", e = "", o = 0; o < n.length; o += 1) t = n.charCodeAt(o), e += r.charAt(t >>> 4 & 15) + r.charAt(15 & t);
|
||||
return e
|
||||
}
|
||||
|
||||
function r(n) {
|
||||
return unescape(encodeURIComponent(n))
|
||||
}
|
||||
|
||||
function o(n) {
|
||||
return i(c(a(n = r(n)), 8 * n.length))
|
||||
}
|
||||
|
||||
function u(n, t) {
|
||||
return function (n, t) {
|
||||
var r, e = a(n), o = [], u = [];
|
||||
for (o[15] = u[15] = void 0, 16 < e.length && (e = c(e, 8 * n.length)), r = 0; r < 16; r += 1) o[r] = 909522486 ^ e[r], u[r] = 1549556828 ^ e[r];
|
||||
return t = c(o.concat(a(t)), 512 + 8 * t.length), i(c(u.concat(t), 640))
|
||||
}(r(n), r(t))
|
||||
}
|
||||
|
||||
function t(n, t, r) {
|
||||
return t ? r ? u(t, n) : e(u(t, n)) : r ? o(n) : e(o(n))
|
||||
}
|
||||
|
||||
"function" == typeof define && define.amd ? define(function () {
|
||||
return t
|
||||
}) : "object" == typeof module && module.exports ? module.exports = t : n.md5 = t
|
||||
}(this);
|
||||
var md5 = this.md5;
|
||||
/**
|
||||
网关上线
|
||||
订阅:/sys/hbtgIA0SuVw9lxjB/AA:BB:CC:DD:10/c/#
|
||||
|
||||
子设备注册:
|
||||
/sys/hbtgIA0SuVw9lxjB/AA:BB:CC:DD:10/s/register
|
||||
{
|
||||
"id": "6",
|
||||
"params":{
|
||||
"productKey":"Rf4QSjbm65X45753",
|
||||
"deviceName":"ABC12400001",
|
||||
"model":"S1"
|
||||
}
|
||||
}
|
||||
子设备上线
|
||||
订阅:/sys/Rf4QSjbm65X45753/ABC12400001/c/#
|
||||
|
||||
数据上报:
|
||||
/sys/Rf4QSjbm65X45753/ABC12400001/s/event/property/post
|
||||
{
|
||||
"id": "6",
|
||||
"params":{
|
||||
"powerstate": 1
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
var registered = {};
|
||||
|
||||
function getPkDn(clientId) {
|
||||
var arr = clientId.split("_");
|
||||
return {
|
||||
pk: arr[0],
|
||||
dn: arr[1]
|
||||
};
|
||||
}
|
||||
|
||||
function register(payload) {
|
||||
var auth = JSON.parse(payload);
|
||||
var arr = auth.clientid.split("_");
|
||||
if (arr.length < 3) {
|
||||
throw new Error("incorrect clientid");
|
||||
}
|
||||
|
||||
var pk = arr[0];
|
||||
var dn = arr[1];
|
||||
var model = arr[2];
|
||||
|
||||
var product = deviceBehaviour.getProductKey(pk)
|
||||
var pwd = md5(product.getProductSecret() + auth.clientid);
|
||||
|
||||
if (pwd.toLocaleLowerCase() != auth.password.toLocaleLowerCase()) {
|
||||
throw new Error("incorrect password" + "pwd->" + pwd + " productSecret->" + product.getProductSecret());
|
||||
}
|
||||
return {
|
||||
type: "register",
|
||||
data: {
|
||||
productKey: pk,
|
||||
deviceName: dn,
|
||||
model: model
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function subRegister(topic, parent, payload) {
|
||||
var params = payload.params;
|
||||
var reply =
|
||||
{
|
||||
productKey: parent.productKey,
|
||||
deviceName: parent.deviceName,
|
||||
mid: "0",
|
||||
content: {
|
||||
topic: topic.replace("/s/", "/c/") + "_reply",
|
||||
payload: JSON.stringify({
|
||||
id: "0",
|
||||
code: 0,
|
||||
data: {
|
||||
"productKey": params.productKey,
|
||||
"deviceName": params.deviceName
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
type: "register",
|
||||
data: {
|
||||
productKey: parent.productKey,
|
||||
deviceName: parent.deviceName,
|
||||
subDevices: [{
|
||||
productKey: params.productKey,
|
||||
deviceName: params.deviceName,
|
||||
model: params.model
|
||||
}]
|
||||
},
|
||||
action: {
|
||||
type: "ack",
|
||||
content: JSON.stringify(reply)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function deviceStateChangeByClientId(head, clientId, state) {
|
||||
|
||||
var device = getPkDn(clientId);
|
||||
|
||||
return {
|
||||
type: "state",
|
||||
data: {
|
||||
productKey: device.pk,
|
||||
deviceName: device.dn,
|
||||
state: state
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function deviceStateChange(head, clientId, state) {
|
||||
var topic = head.topic;
|
||||
var device = getPkDn(clientId);
|
||||
|
||||
var arr = topic.split('/');
|
||||
if (arr.length < 6) {
|
||||
throw new Error("incorrect topic")
|
||||
}
|
||||
|
||||
var pk = arr[2];
|
||||
var dn = arr[3];
|
||||
return {
|
||||
type: "state",
|
||||
data: {
|
||||
productKey: pk,
|
||||
deviceName: dn,
|
||||
state: state,
|
||||
parent: {
|
||||
productKey: device.pk,
|
||||
deviceName: device.dn,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function disconnect(clientId) {
|
||||
var device = getPkDn(clientId);
|
||||
return {
|
||||
type: "state",
|
||||
data: {
|
||||
productKey: device.pk,
|
||||
deviceName: device.dn,
|
||||
state: "offline"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ota(head, payload) {
|
||||
payload = JSON.parse(payload);
|
||||
var topic = head.topic;
|
||||
var arr = topic.split('/');
|
||||
if (arr.length < 6) {
|
||||
throw new Error("incorrect topic")
|
||||
}
|
||||
|
||||
var pk = arr[2];
|
||||
var dn = arr[3];
|
||||
return {
|
||||
type: "ota",
|
||||
data: {
|
||||
productKey: pk,
|
||||
deviceName: dn,
|
||||
mid: payload.id,
|
||||
content: {
|
||||
topic: topic,
|
||||
payload: payload
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//必须提供onReceive方法
|
||||
this.onReceive = function (head, type, payload) {
|
||||
if (type == 'auth') {
|
||||
return register(payload);
|
||||
}
|
||||
else if (type == 'online') {
|
||||
return deviceStateChangeByClientId(head, payload, 'online');
|
||||
}
|
||||
else if (type == 'subscribe') {
|
||||
// 此产品无需通过订阅来确认是否上线
|
||||
return {};
|
||||
}
|
||||
|
||||
else if (type == 'unsubscribe') {
|
||||
// 此产品无需通过订阅来确认是否下线
|
||||
return {};
|
||||
}
|
||||
|
||||
else if (type == 'disconnect') {
|
||||
return disconnect(payload);
|
||||
}
|
||||
|
||||
else if (type == 'ota') {
|
||||
return ota(head, payload);
|
||||
}
|
||||
|
||||
var topic = head['topic'];
|
||||
if (!topic) {
|
||||
throw new Error("topic is blank")
|
||||
}
|
||||
|
||||
var arr = topic.split('/');
|
||||
if (arr.length < 6) {
|
||||
throw new Error("incorrect topic")
|
||||
}
|
||||
var pk = arr[2];
|
||||
var dn = arr[3];
|
||||
|
||||
//子设备注册
|
||||
if (topic.endsWith('/register')) {
|
||||
return subRegister(topic, {productKey: pk, deviceName: dn}, payload);
|
||||
}
|
||||
|
||||
//数据上报
|
||||
var reply =
|
||||
{
|
||||
productKey: pk,
|
||||
deviceName: dn,
|
||||
// mid: payload.id,
|
||||
content: {
|
||||
topic: topic.replace("/s/", "/c/") + "_reply",
|
||||
payload: JSON.stringify({
|
||||
// id: payload.id,
|
||||
method: "thing.event.property.post",
|
||||
code: 0,
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
var action = {};
|
||||
if (!topic.endsWith("_reply")) {
|
||||
//需要回复的消息
|
||||
action = {
|
||||
type: "ack",
|
||||
content: JSON.stringify(reply)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
type: "report",
|
||||
data: {
|
||||
productKey: pk,
|
||||
deviceName: dn,
|
||||
mid: "3",
|
||||
content: {
|
||||
topic: topic,
|
||||
payload: payload
|
||||
}
|
||||
},
|
||||
action: action
|
||||
}
|
||||
}
|
||||
|
||||
this.onRegistered = function (regInfo, result) {
|
||||
}
|
Binary file not shown.
|
@ -1,322 +0,0 @@
|
|||
!function (n) {
|
||||
"use strict";
|
||||
|
||||
function d(n, t) {
|
||||
var r = (65535 & n) + (65535 & t);
|
||||
return (n >> 16) + (t >> 16) + (r >> 16) << 16 | 65535 & r
|
||||
}
|
||||
|
||||
function f(n, t, r, e, o, u) {
|
||||
return d((u = d(d(t, n), d(e, u))) << o | u >>> 32 - o, r)
|
||||
}
|
||||
|
||||
function l(n, t, r, e, o, u, c) {
|
||||
return f(t & r | ~t & e, n, t, o, u, c)
|
||||
}
|
||||
|
||||
function g(n, t, r, e, o, u, c) {
|
||||
return f(t & e | r & ~e, n, t, o, u, c)
|
||||
}
|
||||
|
||||
function v(n, t, r, e, o, u, c) {
|
||||
return f(t ^ r ^ e, n, t, o, u, c)
|
||||
}
|
||||
|
||||
function m(n, t, r, e, o, u, c) {
|
||||
return f(r ^ (t | ~e), n, t, o, u, c)
|
||||
}
|
||||
|
||||
function c(n, t) {
|
||||
var r, e, o, u;
|
||||
n[t >> 5] |= 128 << t % 32, n[14 + (t + 64 >>> 9 << 4)] = t;
|
||||
for (var c = 1732584193, f = -271733879, i = -1732584194, a = 271733878, h = 0; h < n.length; h += 16) c = l(r = c, e = f, o = i, u = a, n[h], 7, -680876936), a = l(a, c, f, i, n[h + 1], 12, -389564586), i = l(i, a, c, f, n[h + 2], 17, 606105819), f = l(f, i, a, c, n[h + 3], 22, -1044525330), c = l(c, f, i, a, n[h + 4], 7, -176418897), a = l(a, c, f, i, n[h + 5], 12, 1200080426), i = l(i, a, c, f, n[h + 6], 17, -1473231341), f = l(f, i, a, c, n[h + 7], 22, -45705983), c = l(c, f, i, a, n[h + 8], 7, 1770035416), a = l(a, c, f, i, n[h + 9], 12, -1958414417), i = l(i, a, c, f, n[h + 10], 17, -42063), f = l(f, i, a, c, n[h + 11], 22, -1990404162), c = l(c, f, i, a, n[h + 12], 7, 1804603682), a = l(a, c, f, i, n[h + 13], 12, -40341101), i = l(i, a, c, f, n[h + 14], 17, -1502002290), c = g(c, f = l(f, i, a, c, n[h + 15], 22, 1236535329), i, a, n[h + 1], 5, -165796510), a = g(a, c, f, i, n[h + 6], 9, -1069501632), i = g(i, a, c, f, n[h + 11], 14, 643717713), f = g(f, i, a, c, n[h], 20, -373897302), c = g(c, f, i, a, n[h + 5], 5, -701558691), a = g(a, c, f, i, n[h + 10], 9, 38016083), i = g(i, a, c, f, n[h + 15], 14, -660478335), f = g(f, i, a, c, n[h + 4], 20, -405537848), c = g(c, f, i, a, n[h + 9], 5, 568446438), a = g(a, c, f, i, n[h + 14], 9, -1019803690), i = g(i, a, c, f, n[h + 3], 14, -187363961), f = g(f, i, a, c, n[h + 8], 20, 1163531501), c = g(c, f, i, a, n[h + 13], 5, -1444681467), a = g(a, c, f, i, n[h + 2], 9, -51403784), i = g(i, a, c, f, n[h + 7], 14, 1735328473), c = v(c, f = g(f, i, a, c, n[h + 12], 20, -1926607734), i, a, n[h + 5], 4, -378558), a = v(a, c, f, i, n[h + 8], 11, -2022574463), i = v(i, a, c, f, n[h + 11], 16, 1839030562), f = v(f, i, a, c, n[h + 14], 23, -35309556), c = v(c, f, i, a, n[h + 1], 4, -1530992060), a = v(a, c, f, i, n[h + 4], 11, 1272893353), i = v(i, a, c, f, n[h + 7], 16, -155497632), f = v(f, i, a, c, n[h + 10], 23, -1094730640), c = v(c, f, i, a, n[h + 13], 4, 681279174), a = v(a, c, f, i, n[h], 11, -358537222), i = v(i, a, c, f, n[h + 3], 16, -722521979), f = v(f, i, a, c, n[h + 6], 23, 76029189), c = v(c, f, i, a, n[h + 9], 4, -640364487), a = v(a, c, f, i, n[h + 12], 11, -421815835), i = v(i, a, c, f, n[h + 15], 16, 530742520), c = m(c, f = v(f, i, a, c, n[h + 2], 23, -995338651), i, a, n[h], 6, -198630844), a = m(a, c, f, i, n[h + 7], 10, 1126891415), i = m(i, a, c, f, n[h + 14], 15, -1416354905), f = m(f, i, a, c, n[h + 5], 21, -57434055), c = m(c, f, i, a, n[h + 12], 6, 1700485571), a = m(a, c, f, i, n[h + 3], 10, -1894986606), i = m(i, a, c, f, n[h + 10], 15, -1051523), f = m(f, i, a, c, n[h + 1], 21, -2054922799), c = m(c, f, i, a, n[h + 8], 6, 1873313359), a = m(a, c, f, i, n[h + 15], 10, -30611744), i = m(i, a, c, f, n[h + 6], 15, -1560198380), f = m(f, i, a, c, n[h + 13], 21, 1309151649), c = m(c, f, i, a, n[h + 4], 6, -145523070), a = m(a, c, f, i, n[h + 11], 10, -1120210379), i = m(i, a, c, f, n[h + 2], 15, 718787259), f = m(f, i, a, c, n[h + 9], 21, -343485551), c = d(c, r), f = d(f, e), i = d(i, o), a = d(a, u);
|
||||
return [c, f, i, a]
|
||||
}
|
||||
|
||||
function i(n) {
|
||||
for (var t = "", r = 32 * n.length, e = 0; e < r; e += 8) t += String.fromCharCode(n[e >> 5] >>> e % 32 & 255);
|
||||
return t
|
||||
}
|
||||
|
||||
function a(n) {
|
||||
var t = [];
|
||||
for (t[(n.length >> 2) - 1] = void 0, e = 0; e < t.length; e += 1) t[e] = 0;
|
||||
for (var r = 8 * n.length, e = 0; e < r; e += 8) t[e >> 5] |= (255 & n.charCodeAt(e / 8)) << e % 32;
|
||||
return t
|
||||
}
|
||||
|
||||
function e(n) {
|
||||
for (var t, r = "0123456789abcdef", e = "", o = 0; o < n.length; o += 1) t = n.charCodeAt(o), e += r.charAt(t >>> 4 & 15) + r.charAt(15 & t);
|
||||
return e
|
||||
}
|
||||
|
||||
function r(n) {
|
||||
return unescape(encodeURIComponent(n))
|
||||
}
|
||||
|
||||
function o(n) {
|
||||
return i(c(a(n = r(n)), 8 * n.length))
|
||||
}
|
||||
|
||||
function u(n, t) {
|
||||
return function (n, t) {
|
||||
var r, e = a(n), o = [], u = [];
|
||||
for (o[15] = u[15] = void 0, 16 < e.length && (e = c(e, 8 * n.length)), r = 0; r < 16; r += 1) o[r] = 909522486 ^ e[r], u[r] = 1549556828 ^ e[r];
|
||||
return t = c(o.concat(a(t)), 512 + 8 * t.length), i(c(u.concat(t), 640))
|
||||
}(r(n), r(t))
|
||||
}
|
||||
|
||||
function t(n, t, r) {
|
||||
return t ? r ? u(t, n) : e(u(t, n)) : r ? o(n) : e(o(n))
|
||||
}
|
||||
|
||||
"function" == typeof define && define.amd ? define(function () {
|
||||
return t
|
||||
}) : "object" == typeof module && module.exports ? module.exports = t : n.md5 = t
|
||||
}(this);
|
||||
var md5 = this.md5;
|
||||
/**
|
||||
网关上线
|
||||
订阅:/sys/hbtgIA0SuVw9lxjB/AA:BB:CC:DD:10/c/#
|
||||
|
||||
子设备注册:
|
||||
/sys/hbtgIA0SuVw9lxjB/AA:BB:CC:DD:10/s/register
|
||||
{
|
||||
"id": "6",
|
||||
"params":{
|
||||
"productKey":"Rf4QSjbm65X45753",
|
||||
"deviceName":"ABC12400001",
|
||||
"model":"S1"
|
||||
}
|
||||
}
|
||||
子设备上线
|
||||
订阅:/sys/Rf4QSjbm65X45753/ABC12400001/c/#
|
||||
|
||||
数据上报:
|
||||
/sys/Rf4QSjbm65X45753/ABC12400001/s/event/property/post
|
||||
{
|
||||
"id": "6",
|
||||
"params":{
|
||||
"powerstate": 1
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
var registered = {};
|
||||
|
||||
function getPkDn(clientId) {
|
||||
var arr = clientId.split("_");
|
||||
return {
|
||||
pk: arr[0],
|
||||
dn: arr[1]
|
||||
};
|
||||
}
|
||||
|
||||
function register(payload) {
|
||||
var auth = JSON.parse(payload);
|
||||
var arr = auth.clientid.split("_");
|
||||
if (arr.length < 3) {
|
||||
throw new Error("incorrect clientid");
|
||||
}
|
||||
|
||||
var pk = arr[0];
|
||||
var dn = arr[1];
|
||||
var model = arr[2];
|
||||
var product = deviceBehaviour.getProductKey(pk)
|
||||
var pwd = md5(product.getProductSecret() + auth.clientid);
|
||||
|
||||
if (pwd.toLocaleLowerCase() != auth.password.toLocaleLowerCase()) {
|
||||
throw new Error("incorrect password");
|
||||
}
|
||||
|
||||
return {
|
||||
type: "register",
|
||||
data: {
|
||||
productKey: pk,
|
||||
deviceName: dn,
|
||||
model: model
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function subRegister(topic, parent, payload) {
|
||||
var params = payload.params;
|
||||
var reply =
|
||||
{
|
||||
productKey: parent.productKey,
|
||||
deviceName: parent.deviceName,
|
||||
mid: "0",
|
||||
content: {
|
||||
topic: topic.replace("/s/", "/c/") + "_reply",
|
||||
payload: JSON.stringify({
|
||||
id: "0",
|
||||
code: 0,
|
||||
data: {
|
||||
"productKey": params.productKey,
|
||||
"deviceName": params.deviceName
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
type: "register",
|
||||
data: {
|
||||
productKey: parent.productKey,
|
||||
deviceName: parent.deviceName,
|
||||
subDevices: [{
|
||||
productKey: params.productKey,
|
||||
deviceName: params.deviceName,
|
||||
model: params.model
|
||||
}]
|
||||
},
|
||||
action: {
|
||||
type: "ack",
|
||||
content: JSON.stringify(reply)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function deviceStateChange(head, clientId, state) {
|
||||
var topic = head.topic;
|
||||
var device = getPkDn(clientId);
|
||||
|
||||
var arr = topic.split('/');
|
||||
if (arr.length < 6) {
|
||||
throw new Error("incorrect topic")
|
||||
}
|
||||
|
||||
var pk = arr[2];
|
||||
var dn = arr[3];
|
||||
return {
|
||||
type: "state",
|
||||
data: {
|
||||
productKey: pk,
|
||||
deviceName: dn,
|
||||
state: state,
|
||||
parent: {
|
||||
productKey: device.pk,
|
||||
deviceName: device.dn,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function disconnect(clientId) {
|
||||
var device = getPkDn(clientId);
|
||||
return {
|
||||
type: "state",
|
||||
data: {
|
||||
productKey: device.pk,
|
||||
deviceName: device.dn,
|
||||
state: "offline"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ota(head, payload) {
|
||||
payload = JSON.parse(payload);
|
||||
var topic = head.topic;
|
||||
var arr = topic.split('/');
|
||||
if (arr.length < 6) {
|
||||
throw new Error("incorrect topic")
|
||||
}
|
||||
|
||||
var pk = arr[2];
|
||||
var dn = arr[3];
|
||||
return {
|
||||
type: "ota",
|
||||
data: {
|
||||
productKey: pk,
|
||||
deviceName: dn,
|
||||
mid: payload.id,
|
||||
content: {
|
||||
topic: topic,
|
||||
payload: payload
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//必须提供onReceive方法
|
||||
this.onReceive = function (head, type, payload) {
|
||||
if (type == 'auth') {
|
||||
return register(payload);
|
||||
}
|
||||
|
||||
if (type == 'subscribe') {
|
||||
return deviceStateChange(head, payload, 'online');
|
||||
}
|
||||
|
||||
if (type == 'unsubscribe') {
|
||||
return deviceStateChange(head, payload, 'offline');
|
||||
}
|
||||
|
||||
if (type == 'disconnect') {
|
||||
return disconnect(payload);
|
||||
}
|
||||
|
||||
if (type == 'ota') {
|
||||
return ota(head, payload);
|
||||
}
|
||||
|
||||
var topic = head['topic'];
|
||||
if (!topic) {
|
||||
throw new Error("topic is blank")
|
||||
}
|
||||
|
||||
var arr = topic.split('/');
|
||||
if (arr.length < 6) {
|
||||
throw new Error("incorrect topic")
|
||||
}
|
||||
var pk = arr[2];
|
||||
var dn = arr[3];
|
||||
payload = JSON.parse(payload);
|
||||
|
||||
//子设备注册
|
||||
if (topic.endsWith('/register')) {
|
||||
return subRegister(topic, {productKey: pk, deviceName: dn}, payload);
|
||||
}
|
||||
|
||||
//数据上报
|
||||
var reply =
|
||||
{
|
||||
productKey: pk,
|
||||
deviceName: dn,
|
||||
mid: payload.id,
|
||||
content: {
|
||||
topic: topic.replace("/s/", "/c/") + "_reply",
|
||||
payload: JSON.stringify({
|
||||
id: payload.id,
|
||||
method: payload.method + "_reply",
|
||||
code: 0,
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
var action = {};
|
||||
if (!topic.endsWith("_reply")) {
|
||||
//需要回复的消息
|
||||
action = {
|
||||
type: "ack",
|
||||
content: JSON.stringify(reply)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
type: "report",
|
||||
data: {
|
||||
productKey: pk,
|
||||
deviceName: dn,
|
||||
mid: payload.id,
|
||||
content: {
|
||||
topic: topic,
|
||||
payload: payload
|
||||
}
|
||||
},
|
||||
action: action
|
||||
}
|
||||
}
|
||||
|
||||
this.onRegistered = function (regInfo, result) {
|
||||
}
|
Binary file not shown.
|
@ -1,595 +0,0 @@
|
|||
var mid = 1;
|
||||
var COMMAD_UNKOWN = 0xff; //未知的命令
|
||||
function getMid() {
|
||||
mid++;
|
||||
if (mid > 10000) {
|
||||
mid = 1;
|
||||
}
|
||||
return mid + "";
|
||||
}
|
||||
//上行数据
|
||||
this.decode = function (msg) {
|
||||
var content = msg.content;
|
||||
var topic = content.topic;
|
||||
var bytes = arrayGroup(content.payload,2);
|
||||
var byteData=content.payload;
|
||||
if (topic.endsWith("/thing/model/up_raw")) {
|
||||
var data = arrayGroup(byteData, 2);
|
||||
var params = {};
|
||||
var uint8Array = new Uint8Array(bytes.length);
|
||||
for (var i = 0; i < bytes.length; i++) {
|
||||
uint8Array[i] = bytes[i] & 0xff;
|
||||
}
|
||||
if (data[1] == '03') {
|
||||
if (byteData.length == 22 ) {
|
||||
params['Switch'] = Number(parseInt(data[3] + data[4], 16))
|
||||
params['HandMode'] = Number(parseInt(data[5] + data[6], 16))+1
|
||||
params['TempGear'] = Number(data[7].slice(1,2))+1
|
||||
params['RatioGear'] = Number(data[7].slice(0,1))+1
|
||||
params['PressureGear'] = data[8].slice(0,1) != 'f' ? Number(data[8].slice(0,1))+1 : 0
|
||||
params['SpeedGear'] = data[8].slice(1,2) != 'f' ? Number(data[8].slice(1,2))+1 : 0
|
||||
|
||||
} else if (byteData.length == 126) {
|
||||
params['Pressure'] = Number((parseInt(data[3] + data[4], 16) / 100).toFixed(1))
|
||||
params['EmtyRunPressure'] = Number((parseInt(data[5] + data[6], 16) / 100).toFixed(1))
|
||||
params['StartPressure'] = Number((parseInt(data[7] + data[8], 16) / 100).toFixed(1))
|
||||
params['WorkMode'] = Number((parseInt(data[9] + data[10], 16)).toFixed(0))
|
||||
params['ClearIceEn'] = Number((parseInt(data[11] + data[12], 16)).toFixed(0))
|
||||
params['WaterT'] = Number((parseInt(data[13] + data[14], 16)).toFixed(0))
|
||||
params['WaterTReset'] = Number((parseInt(data[15] + data[16], 16)).toFixed(0))
|
||||
params['SensorMode'] = Number((parseInt(data[17] + data[18], 16)).toFixed(0))
|
||||
params['SensorGroup'] = Number((parseInt(data[19] + data[20], 16)).toFixed(0))
|
||||
params['ElectronicTMax'] = Number(parseInt(data[59], 16))
|
||||
params['ElectronicTMaxReset'] = Number(parseInt(data[60], 16))
|
||||
} else if (byteData.length == 26) {
|
||||
params['ActiveTime'] = String(parseInt(data[3], 16))+'-'+String(parseInt(data[4], 16))+'-'+String(parseInt(data[5], 16))
|
||||
} else if (byteData.length == 190) {
|
||||
params['Pressure'] = Number((parseInt(data[3] + data[4], 16) / 100).toFixed(1))
|
||||
params['EmtyRunPressure'] = Number((parseInt(data[5] + data[6], 16) / 100).toFixed(1))
|
||||
params['StartPressure'] = Number((parseInt(data[7] + data[8], 16) / 100).toFixed(1))
|
||||
params['WorkMode'] = Number((parseInt(data[9] + data[10], 16)).toFixed(0))
|
||||
params['ClearIceEn'] = Number((parseInt(data[11] + data[12], 16)).toFixed(0))
|
||||
params['WaterT'] = Number((parseInt(data[13] + data[14], 16)).toFixed(0))
|
||||
params['WaterTReset'] = Number((parseInt(data[15] + data[16], 16)).toFixed(0))
|
||||
params['SensorMode'] = Number((parseInt(data[17] + data[18], 16)).toFixed(0))
|
||||
params['SensorGroup'] = Number((parseInt(data[19] + data[20], 16)).toFixed(0))
|
||||
params['ElectronicTMax'] = Number(parseInt(data[59], 16))
|
||||
params['ElectronicTMaxReset'] = Number(parseInt(data[60], 16))
|
||||
params['SceneMode'] = Number((parseInt(data[63] + data[64], 16)).toFixed(0))
|
||||
params['EnergyModeTime'] = Number((parseInt(data[65] + data[66], 16)).toFixed(0))
|
||||
params['WaterTime'] = String(Number((parseInt(data[68].substring(0, 1), 16)).toFixed(0))) + ',' + String(Number((parseInt(data[68].substring(1), 16)).toFixed(0)))
|
||||
params['HotWaterTime'] = Number((parseInt(data[69] + data[70], 16)).toFixed(0))
|
||||
params['TempSet'] = String(Number((parseInt(data[71], 16)).toFixed(0)))+','+ String(Number((parseInt(data[72], 16)).toFixed(0)))
|
||||
params['TimeModeSet'] = parseInt(data[73] + data[74], 16)+'-'+parseInt(data[75] + data[76], 16)+','+ parseInt(data[77] + data[78], 16)+'-'+parseInt(data[79] + data[80], 16)+','+ parseInt(data[81] + data[82], 16)+'-'+parseInt(data[83] + data[84], 16)+','+ parseInt(data[85] + data[86], 16)+'-'+parseInt(data[87] + data[88], 16)+','+ parseInt(data[89] + data[90], 16)+'-'+parseInt(data[91] + data[92], 16)
|
||||
|
||||
} else if (byteData.length == 94) {
|
||||
let timeStamp = parseInt(String(data[41])+String(data[42])+String(data[43])+String(data[44]),16)
|
||||
let time = timestampToTime(timeStamp)
|
||||
params['ActiveTime'] = String(parseInt(data[3], 16))+'-'+String(parseInt(data[4], 16))+'-'+String(parseInt(data[5], 16))
|
||||
params['Time'] = time + '-'+ timeStamp
|
||||
|
||||
}
|
||||
} else if (data[1] == '04') {
|
||||
if (byteData.length == 54) {
|
||||
params['ErrorMsg'] = Number(parseInt(data[3]+data[4], 16))
|
||||
params['Voltage'] = Number(parseInt(data[5]+data[6], 16))
|
||||
params['Electric'] = Number(parseInt(data[7]+data[8], 16))/10
|
||||
params['Power'] = Number(parseInt(data[9]+data[10], 16))
|
||||
params['Speed'] = Number(parseInt(data[11]+data[12], 16))
|
||||
params['CurrentPressure1'] = data[13] != 'ff' ? Number((parseInt(data[13]+data[14], 16)/100).toFixed(1)) : 0
|
||||
params['CurrentPressure2'] = data[15] != 'ff' ? Number((parseInt(data[15]+data[16], 16)/100).toFixed(1)) : 0
|
||||
params['IpmTemperature'] = Number(parseInt(data[17]+data[18], 16))-55
|
||||
params['MotorTemperature'] = Number(parseInt(data[19]+data[20], 16))-55
|
||||
params['WaterTemperature'] = Number(parseInt(data[21]+data[22], 16))-55
|
||||
let warnArray = reverseStr(hex2bin(data[23] + data[24]))
|
||||
let warnInfo = ""
|
||||
for (let i = 0; i < warnArray.length; i++) {
|
||||
if (warnArray[i] === "1") {
|
||||
if (warnInfo === "") {
|
||||
warnInfo = DEVICE_ERROR[i]
|
||||
} else {
|
||||
warnInfo += `、${DEVICE_ERROR[i]}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
params['WarnInfo'] = warnInfo
|
||||
|
||||
} else if (byteData.length == 18) {
|
||||
if (String(byteData) == '130404000800004847') {
|
||||
params['query'] = String(byteData)
|
||||
} else if (String(byteData).slice(9,10) == 3) {
|
||||
params['query'] = String(byteData)
|
||||
} else if (String(byteData).slice(9,10) == 4) {
|
||||
params['query'] = String(byteData)
|
||||
}
|
||||
} else if (byteData.length == 30) {
|
||||
params['McuVersion'] = String(Number(parseInt(data[3].slice(1,2), 16)))+'.'+String(Number(parseInt(data[4].slice(0,1), 16)))+'.'+String(Number(parseInt(data[4].slice(1,2), 16)))
|
||||
params['McuStatus'] = Number(parseInt(data[3].slice(0,1), 16))
|
||||
params['Scene'] = Number(parseInt(data[9]+data[10], 16))
|
||||
params['Model'] = String(Number(parseInt(data[11]+data[12], 16)))+'W'
|
||||
|
||||
} else if (byteData.length == 66) {
|
||||
params['ErrorMsg'] = Number(parseInt(data[3]+data[4], 16))
|
||||
params['Voltage'] = Number(parseInt(data[5]+data[6], 16))
|
||||
params['Electric'] = Number(parseInt(data[7]+data[8], 16))/10
|
||||
params['Power'] = Number(parseInt(data[9]+data[10], 16))
|
||||
params['Speed'] = Number(parseInt(data[11]+data[12], 16))
|
||||
params['CurrentPressure1'] = data[13] != 'ff' ? Number((parseInt(data[13]+data[14], 16)/100).toFixed(1)) : 0
|
||||
params['CurrentPressure2'] = data[15] != 'ff' ? Number((parseInt(data[15]+data[16], 16)/100).toFixed(1)) : 0
|
||||
params['IpmTemperature'] = Number(parseInt(data[17]+data[18], 16))-55
|
||||
params['MotorTemperature'] = Number(parseInt(data[19]+data[20], 16))-55
|
||||
params['WaterTemperature'] = Number(parseInt(data[21]+data[22], 16))-55
|
||||
let warnArray = reverseStr(hex2bin(data[23] + data[24]))
|
||||
let warnInfo = ""
|
||||
for (let i = 0; i < warnArray.length; i++) {
|
||||
if (warnArray[i] === "1") {
|
||||
if (warnInfo === "") {
|
||||
warnInfo = DEVICE_ERROR[i]
|
||||
} else {
|
||||
warnInfo += `、${DEVICE_ERROR[i]}`
|
||||
}
|
||||
}
|
||||
}
|
||||
params['CountDown'] = Number(parseInt(data[25]+data[26], 16))
|
||||
params['WarnInfo'] = warnInfo
|
||||
params['Enabled'] = Number(parseInt(data[29]+data[30], 16))
|
||||
|
||||
}
|
||||
}
|
||||
params['History'] = byteData
|
||||
//属性上报
|
||||
return {
|
||||
mid: msg.mid,
|
||||
productKey: msg.productKey,
|
||||
deviceName: msg.deviceName,
|
||||
type: "property",
|
||||
identifier: "report", //属性上报
|
||||
occur: new Date().getTime(), //时间戳,设备上的事件或数据产生的本地时间
|
||||
time: new Date().getTime(), //时间戳,消息上报时间
|
||||
data: params,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
//下行数据
|
||||
this.encode = function (service, device) {
|
||||
var deviceMid = getMid();
|
||||
var method = "thing.service.";
|
||||
var topic = "/sys/" + service.productKey + "/" + service.deviceName + "/thing/model/down_raw";
|
||||
var params = {};
|
||||
var payloadArray = [];
|
||||
var deviceArray = [];;
|
||||
var totalArray =[];
|
||||
var totalItemArray = [];
|
||||
var itemArray = [];
|
||||
var outFFIndex = ''
|
||||
var type = service.type;
|
||||
var identifier = service.identifier;
|
||||
if (type == "property" && identifier == "get") {
|
||||
var listParams = []
|
||||
for (var p in service.params) {
|
||||
listParams.push(service.params[p]);
|
||||
}
|
||||
return {
|
||||
productKey: service.productKey,
|
||||
deviceName: service.deviceName,
|
||||
mid: deviceMid,
|
||||
content: {
|
||||
topic: topic,
|
||||
payload: JSON.stringify({
|
||||
id: deviceMid,
|
||||
method: method += "property." + identifier,
|
||||
params: listParams
|
||||
})
|
||||
}
|
||||
}
|
||||
} else if (type == "property" && identifier == "set") {
|
||||
for (var p in service.params) {
|
||||
params[p] = service.params[p];
|
||||
}
|
||||
var paramsArr = Object.keys(params)
|
||||
//站地址
|
||||
if (paramsArr.includes('query')) {
|
||||
let queryHexData = arrayGroup(params['query'],2)
|
||||
let queryData = []
|
||||
queryHexData.map(function(value) {
|
||||
queryData.push(parseInt(value,16))
|
||||
})
|
||||
payloadArray = queryData
|
||||
} else {
|
||||
const stationAddress = "49";
|
||||
totalArray.push(stationAddress)
|
||||
//功能码
|
||||
var functionCode = "";
|
||||
// 寄存器数量
|
||||
var register = ''
|
||||
var baseVal = ''
|
||||
//起始地址
|
||||
var startAddressCode = '';
|
||||
if (paramsArr.length == 1) {
|
||||
functionCode = '06'
|
||||
totalArray.push(functionCode)
|
||||
} else {
|
||||
functionCode = '10'
|
||||
paramsArr = ['Pressure', 'EmtyRunPressure', 'StartPressure', 'WorkMode', 'ClearIceEn', 'WaterT', 'WaterTReset']
|
||||
totalArray.push(parseInt(Number(functionCode),16))
|
||||
}
|
||||
if (paramsArr.includes('Switch')) {
|
||||
startAddressCode = 300
|
||||
totalArray.push('01','44')
|
||||
} else if (paramsArr.includes('Pressure')) {
|
||||
startAddressCode = 400
|
||||
totalArray.push('01','144')
|
||||
register = '00' + add0(String(paramsArr.length),2) + add0(String((paramsArr.length*2).toString(16)),2)
|
||||
totalArray.push('00', add0(paramsArr.length,2), add0(String((paramsArr.length)*2),2))
|
||||
}
|
||||
if (functionCode == 6) {
|
||||
paramsArr.forEach(function(value){
|
||||
totalArray.push('00',params[value])
|
||||
itemArray = pad(params[value].toString(16),4)
|
||||
deviceArray.push(itemArray[0],itemArray[1])
|
||||
})
|
||||
} else if (functionCode == 10) {
|
||||
paramsArr.forEach(function(value, index){
|
||||
if (index < 3) {
|
||||
// if (params[value]*100 < 256) {
|
||||
// totalItemArray = ['00', String((params[value]*100).toFixed(0))]
|
||||
// itemArray = pad(String((params[value]*100).toString(16)),4)
|
||||
// totalItemArray = pad(String((params[value]*100).toFixed(0)),4)
|
||||
// } else {
|
||||
// outFFIndex = ((Number(params[value]*100))/256).toFixed(0)
|
||||
// totalItemArray = [outFFIndex, params[value]*100-outFFIndex*256]
|
||||
// }
|
||||
|
||||
itemArray = pad(Number((params[value]*100).toFixed(0)).toString(16),4)
|
||||
totalItemArray = pad(String((params[value]*100).toFixed(0)),4)
|
||||
} else {
|
||||
itemArray = pad(String(params[value].toString(16)),4)
|
||||
totalItemArray = pad(String(params[value]),4)
|
||||
}
|
||||
// totalArray.push(params[value])
|
||||
// totalArray.push(totalItemArray[0],totalItemArray[1])
|
||||
totalArray.push(parseInt(itemArray[0],16),parseInt(itemArray[1],16))
|
||||
// deviceArray.push(parseInt(itemArray[0],16),parseInt(itemArray[1],16))
|
||||
deviceArray.push(itemArray[0],itemArray[1])
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
var startAddressHex = pad(startAddressCode.toString(16), 4);
|
||||
baseVal = String(stationAddress) + String(functionCode) + String(startAddressHex[0]) + String(startAddressHex[1])
|
||||
if (functionCode != 6) {
|
||||
baseVal += register
|
||||
}
|
||||
deviceArray.forEach(function(item) {
|
||||
baseVal += item
|
||||
})
|
||||
// baseVal += '00070e0064000a00640001000100370037'
|
||||
var Crc = CRC.ToModbusCRC16(baseVal)
|
||||
var crcArray = arrayGroup(Crc,2)
|
||||
totalArray.push(parseInt(crcArray[0],16),parseInt(crcArray[1],16))
|
||||
payloadArray = totalArray;
|
||||
}
|
||||
// var params = json['params'];
|
||||
// var prop_float = params['prop_float'];
|
||||
// var prop_int16 = params['prop_int16'];
|
||||
// var prop_bool = params['prop_bool'];
|
||||
// //按照自定义协议格式拼接 rawData。
|
||||
// payloadArray = payloadArray.concat(buffer_uint8(COMMAND_SET)); //command字段。
|
||||
// payloadArray = payloadArray.concat(buffer_int32(parseInt(id))); //ALink JSON格式 'id'。
|
||||
// payloadArray = payloadArray.concat(buffer_int16(prop_int16)); //属性'prop_int16'的值。
|
||||
// payloadArray = payloadArray.concat(buffer_uint8(prop_bool)); //属性'prop_bool'的值。
|
||||
// payloadArray = payloadArray.concat(buffer_float32(prop_float)); //属性'prop_float'的值。
|
||||
|
||||
}else if (method == 'thing.event.property.post') { //设备上报数据返回结果,如果不需要回复,可以去除该内容
|
||||
// var code = json['code'];
|
||||
// payloadArray = payloadArray.concat(buffer_uint8(COMMAND_REPORT_REPLY)); //command字段
|
||||
// payloadArray = payloadArray.concat(buffer_int32(parseInt(id))); // ALink JSON格式 'id'
|
||||
// payloadArray = payloadArray.concat(buffer_uint8(code));
|
||||
} else { //未知命令,对于有些命令不做处理
|
||||
var code = "FF";
|
||||
payloadArray = payloadArray.concat(buffer_uint8(COMMAD_UNKOWN)); //command字段
|
||||
payloadArray = payloadArray.concat(buffer_int32(parseInt(id))); // ALink JSON格式 'id'
|
||||
payloadArray = payloadArray.concat(buffer_uint8(code));
|
||||
}
|
||||
var hexstr = ab2hex(payloadArray);
|
||||
console.log("hexstr:" + hexstr);
|
||||
|
||||
return {
|
||||
productKey: service.productKey,
|
||||
deviceName: service.deviceName,
|
||||
mid: deviceMid,
|
||||
content: {
|
||||
topic: topic,
|
||||
payload: hexstr
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const DEVICE_ERROR = [
|
||||
"压力传感器故障", //0
|
||||
"高温限功率", //1
|
||||
"渗漏", // 2
|
||||
"电机温度传感器故障", //3
|
||||
"水温传感器故障", //4
|
||||
"保留", //5
|
||||
"保留", //6
|
||||
"保留", //7
|
||||
"保留", //8
|
||||
"保留", //9
|
||||
"保留", //10
|
||||
"保留", //11
|
||||
"保留", //12
|
||||
"保留", //13
|
||||
"保留", //14
|
||||
"保留", // 15
|
||||
"保留", //16
|
||||
]
|
||||
function buffer_uint8(value) {
|
||||
var uint8Array = new Uint8Array(1);
|
||||
var dv = new DataView(uint8Array.buffer, 0);
|
||||
dv.setUint8(0, value);
|
||||
return [].slice.call(uint8Array);
|
||||
}
|
||||
function buffer_int16(value) {
|
||||
var uint8Array = new Uint8Array(2);
|
||||
var dv = new DataView(uint8Array.buffer, 0);
|
||||
dv.setInt16(0, value);
|
||||
return [].slice.call(uint8Array);
|
||||
}
|
||||
function buffer_int32(value) {
|
||||
var uint8Array = new Uint8Array(4);
|
||||
var dv = new DataView(uint8Array.buffer, 0);
|
||||
dv.setInt32(0, value);
|
||||
return [].slice.call(uint8Array);
|
||||
}
|
||||
function buffer_float32(value) {
|
||||
var uint8Array = new Uint8Array(4);
|
||||
var dv = new DataView(uint8Array.buffer, 0);
|
||||
dv.setFloat32(0, value);
|
||||
return [].slice.call(uint8Array);
|
||||
}
|
||||
|
||||
function ab2hex(buffer) {
|
||||
var hexArr = Array.prototype.map.call(
|
||||
new Uint8Array(buffer),
|
||||
function (bit) {
|
||||
return ('00' + bit.toString(16)).slice(-2)
|
||||
}
|
||||
)
|
||||
return hexArr.join('');
|
||||
}
|
||||
|
||||
function arrayGroup(ss, step) {
|
||||
var r = [];
|
||||
|
||||
function doGroup(s) {
|
||||
if (!s) return;
|
||||
r.push(s.substr(0, step));
|
||||
s = s.substr(step);
|
||||
doGroup(s);
|
||||
}
|
||||
doGroup(ss);
|
||||
return r;
|
||||
}
|
||||
|
||||
var CRC = {};
|
||||
|
||||
CRC._auchCRCHi = [
|
||||
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
|
||||
0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
|
||||
0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
|
||||
0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
|
||||
0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
|
||||
0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,
|
||||
0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
|
||||
0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
|
||||
0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,
|
||||
0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
|
||||
0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
|
||||
0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
|
||||
0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
|
||||
0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
|
||||
0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,
|
||||
0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
|
||||
0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
|
||||
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
|
||||
0x80, 0x41, 0x00, 0xC1, 0x81, 0x40
|
||||
];
|
||||
CRC._auchCRCLo = [
|
||||
0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06,
|
||||
0x07, 0xC7, 0x05, 0xC5, 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD,
|
||||
0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09,
|
||||
0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A,
|
||||
0x1E, 0xDE, 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC, 0x14, 0xD4,
|
||||
0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3,
|
||||
0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3,
|
||||
0xF2, 0x32, 0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35, 0x34, 0xF4,
|
||||
0x3C, 0xFC, 0xFD, 0x3D, 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A,
|
||||
0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38, 0x28, 0xE8, 0xE9, 0x29,
|
||||
0xEB, 0x2B, 0x2A, 0xEA, 0xEE, 0x2E, 0x2F, 0xEF, 0x2D, 0xED,
|
||||
0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26,
|
||||
0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60,
|
||||
0x61, 0xA1, 0x63, 0xA3, 0xA2, 0x62, 0x66, 0xA6, 0xA7, 0x67,
|
||||
0xA5, 0x65, 0x64, 0xA4, 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F,
|
||||
0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68,
|
||||
0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA, 0xBE, 0x7E,
|
||||
0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5,
|
||||
0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71,
|
||||
0x70, 0xB0, 0x50, 0x90, 0x91, 0x51, 0x93, 0x53, 0x52, 0x92,
|
||||
0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C,
|
||||
0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, 0x5A, 0x9A, 0x9B, 0x5B,
|
||||
0x99, 0x59, 0x58, 0x98, 0x88, 0x48, 0x49, 0x89, 0x4B, 0x8B,
|
||||
0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C,
|
||||
0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42,
|
||||
0x43, 0x83, 0x41, 0x81, 0x80, 0x40
|
||||
];
|
||||
|
||||
CRC.CRC16 = function (buffer) {
|
||||
var hi = 0xff;
|
||||
var lo = 0xff;
|
||||
for (var i = 0; i < buffer.length; i++) {
|
||||
var idx = hi ^ buffer[i];
|
||||
hi = (lo ^ CRC._auchCRCHi[idx]);
|
||||
lo = CRC._auchCRCLo[idx];
|
||||
}
|
||||
return CRC.padLeft((hi << 8 | lo).toString(16).toUpperCase(), 4, '0');
|
||||
};
|
||||
|
||||
CRC.isArray = function (arr) {
|
||||
return Object.prototype.toString.call(arr) === '[object Array]';
|
||||
};
|
||||
|
||||
CRC.ToCRC16 = function (str) {
|
||||
return CRC.CRC16(CRC.isArray(str) ? str : CRC.strToByte(str));
|
||||
};
|
||||
|
||||
CRC.ToModbusCRC16 = function (str) {
|
||||
return CRC.CRC16(CRC.isArray(str) ? str : CRC.strToHex(str));
|
||||
};
|
||||
|
||||
CRC.strToByte = function (str) {
|
||||
var tmp = str.split(""),
|
||||
arr = [];
|
||||
for (var i = 0, c = tmp.length; i < c; i++) {
|
||||
var j = encodeURI(tmp[i]);
|
||||
if (j.length == 1) {
|
||||
arr.push(j.charCodeAt());
|
||||
} else {
|
||||
var b = j.split("%");
|
||||
for (var m = 1; m < b.length; m++) {
|
||||
arr.push(parseInt('0x' + b[m]));
|
||||
}
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
};
|
||||
|
||||
CRC.convertChinese = function (str) {
|
||||
var tmp = str.split(""),
|
||||
arr = [];
|
||||
for (var i = 0, c = tmp.length; i < c; i++) {
|
||||
var s = tmp[i].charCodeAt();
|
||||
if (s <= 0 || s >= 127) {
|
||||
arr.push(s.toString(16));
|
||||
} else {
|
||||
arr.push(tmp[i]);
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
};
|
||||
|
||||
CRC.filterChinese = function (str) {
|
||||
var tmp = str.split(""),
|
||||
arr = [];
|
||||
for (var i = 0, c = tmp.length; i < c; i++) {
|
||||
var s = tmp[i].charCodeAt();
|
||||
if (s > 0 && s < 127) {
|
||||
arr.push(tmp[i]);
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
};
|
||||
|
||||
CRC.strToHex = function (hex, isFilterChinese) {
|
||||
hex = isFilterChinese ? CRC.filterChinese(hex).join('') : CRC.convertChinese(hex).join('');
|
||||
|
||||
//清除所有空格
|
||||
hex = hex.replace(/\s/g, "");
|
||||
//若字符个数为奇数,补一个空格
|
||||
hex += hex.length % 2 != 0 ? " " : "";
|
||||
|
||||
var c = hex.length / 2,
|
||||
arr = [];
|
||||
for (var i = 0; i < c; i++) {
|
||||
arr.push(parseInt(hex.substr(i * 2, 2), 16));
|
||||
}
|
||||
return arr;
|
||||
};
|
||||
|
||||
CRC.padLeft = function (s, w, pc) {
|
||||
if (pc == undefined) {
|
||||
pc = '0';
|
||||
}
|
||||
for (var i = 0, c = w - s.length; i < c; i++) {
|
||||
s = pc + s;
|
||||
}
|
||||
return s;
|
||||
};
|
||||
|
||||
function str2ab(str) {
|
||||
var buffer = new ArrayBuffer(str.length / 2); // 2 bytes for each char
|
||||
var dataView = new DataView(buffer);
|
||||
var str = str.split("")
|
||||
var n = 0;
|
||||
for (var i = 0; i < str.length; i = i + 2) {
|
||||
dataView.setUint8(n, `0x${str[i]}${str[i+1]}`)
|
||||
n++;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
function pad(num, n, flag = false) {
|
||||
var len = num.toString().length;
|
||||
while (len < n) {
|
||||
num = "0" + num;
|
||||
len++;
|
||||
}
|
||||
|
||||
const arr = arrayGroup(num, 2)
|
||||
//高低位互换
|
||||
if (arr[1] == '00') {
|
||||
flag = true
|
||||
}
|
||||
return flag ? [arr[1], arr[0]] : [arr[0], arr[1]];
|
||||
}
|
||||
|
||||
function add0(num,n) {
|
||||
let len = num.length
|
||||
while(len < n){
|
||||
num = '0'+num
|
||||
len++
|
||||
}
|
||||
if (len > n) {
|
||||
num = String(num).slice(1)
|
||||
}
|
||||
//console.log(num)
|
||||
return num
|
||||
}
|
||||
|
||||
function hex2bin(hex, len) {
|
||||
var bin = parseInt(hex, 16).toString(2);
|
||||
var l = bin.length;
|
||||
for (var i = 0; i < len - l; i++) {
|
||||
bin = "0" + bin;
|
||||
}
|
||||
return bin;
|
||||
}
|
||||
|
||||
//翻转字符串并切割成数组
|
||||
function reverseStr(str) {
|
||||
var arr = str.split("");
|
||||
arr.reverse();
|
||||
return arr;
|
||||
}
|
||||
|
||||
function timestampToTime(timestamp) {
|
||||
var date = new Date(timestamp * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
|
||||
var Y = date.getFullYear() + '-';
|
||||
var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
|
||||
var D = date.getDate() + ' ';
|
||||
var h = date.getHours() + ':';
|
||||
var m = date.getMinutes() + ':';
|
||||
var s = date.getSeconds();
|
||||
return Y+M+D+h+m+s;
|
||||
}
|
|
@ -1,208 +0,0 @@
|
|||
var mid = 1;
|
||||
|
||||
function getMid() {
|
||||
mid++;
|
||||
if (mid > 10000) {
|
||||
mid = 1;
|
||||
}
|
||||
return mid + "";
|
||||
}
|
||||
|
||||
this.decode = function (msg) {
|
||||
//对msg进行解析,并返回物模型数据
|
||||
var content = msg.content;
|
||||
var topic = content.topic;
|
||||
var payload = content.payload;
|
||||
var identifier = topic.substring(topic.lastIndexOf("/") + 1);
|
||||
|
||||
//透传上报
|
||||
if (topic.endsWith("/event/rawReport")) {
|
||||
var rst = component.transparentDecode(payload.params);
|
||||
if (!rst) {
|
||||
return null;
|
||||
}
|
||||
rst.occur = new Date().getTime();
|
||||
rst.time = new Date().getTime();
|
||||
return rst;
|
||||
}
|
||||
|
||||
if (topic.endsWith("/property/post")) {
|
||||
//属性上报
|
||||
return {
|
||||
mid: msg.mid,
|
||||
productKey: msg.productKey,
|
||||
deviceName: msg.deviceName,
|
||||
type: "property",
|
||||
identifier: "report", //属性上报
|
||||
occur: new Date().getTime(), //时间戳,设备上的事件或数据产生的本地时间
|
||||
time: new Date().getTime(), //时间戳,消息上报时间
|
||||
data: payload.params,
|
||||
};
|
||||
} else if (topic.indexOf("/ota/") >= 0) {
|
||||
//事件上报
|
||||
return {
|
||||
mid: msg.mid,
|
||||
productKey: msg.productKey,
|
||||
deviceName: msg.deviceName,
|
||||
type: "ota",
|
||||
identifier: "ota",
|
||||
occur: new Date().getTime(),
|
||||
time: new Date().getTime(),
|
||||
data: payload.params,
|
||||
};
|
||||
} else if (topic.indexOf("/event/") > 0) {
|
||||
//事件上报
|
||||
return {
|
||||
mid: msg.mid,
|
||||
productKey: msg.productKey,
|
||||
deviceName: msg.deviceName,
|
||||
type: "event",
|
||||
identifier: identifier,
|
||||
occur: new Date().getTime(),
|
||||
time: new Date().getTime(),
|
||||
data: payload.params,
|
||||
};
|
||||
} else if (topic.endsWith("/service/property/set_reply")) {
|
||||
//属性设置回复
|
||||
return {
|
||||
mid: msg.mid,
|
||||
productKey: msg.productKey,
|
||||
deviceName: msg.deviceName,
|
||||
type: "property",
|
||||
identifier: identifier,
|
||||
occur: new Date().getTime(),
|
||||
time: new Date().getTime(),
|
||||
code: payload.code
|
||||
};
|
||||
} else if (topic.endsWith("/config/set_reply")) {
|
||||
//设备配置设置回复
|
||||
return {
|
||||
mid: msg.mid,
|
||||
productKey: msg.productKey,
|
||||
deviceName: msg.deviceName,
|
||||
type: "config",
|
||||
identifier: "set_reply",
|
||||
occur: new Date().getTime(),
|
||||
time: new Date().getTime(),
|
||||
code: payload.code
|
||||
};
|
||||
} else if (topic.endsWith("/config/get")) {
|
||||
//设备配置获取
|
||||
return {
|
||||
mid: msg.mid,
|
||||
productKey: msg.productKey,
|
||||
deviceName: msg.deviceName,
|
||||
type: "config",
|
||||
identifier: "get",
|
||||
occur: new Date().getTime(),
|
||||
time: new Date().getTime(),
|
||||
data: {},
|
||||
};
|
||||
} else if (topic.endsWith("_reply")) {
|
||||
//服务回复
|
||||
return {
|
||||
mid: msg.mid,
|
||||
productKey: msg.productKey,
|
||||
deviceName: msg.deviceName,
|
||||
type: "service",
|
||||
identifier: identifier,
|
||||
occur: new Date().getTime(),
|
||||
time: new Date().getTime(),
|
||||
code: payload.code,
|
||||
data: payload.data,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
this.encode = function (service, device) {
|
||||
var deviceMid = getMid();
|
||||
var method = "thing.service.";
|
||||
var topic = "/sys/" + service.productKey + "/" + service.deviceName + "/c/service/";
|
||||
var params = {};
|
||||
|
||||
//透传下发
|
||||
if (device.transparent) {
|
||||
var rst = component.transparentEncode(service, device);
|
||||
topic = "/sys/" + rst.productKey + "/" + rst.deviceName + "/c/service/rawSend";
|
||||
params.model = rst.content.model;
|
||||
params.deviceName = rst.content.deviceName;
|
||||
params.data = rst.content.data;
|
||||
|
||||
return {
|
||||
productKey: rst.productKey,
|
||||
deviceName: rst.deviceName,
|
||||
mid: rst.mid,
|
||||
content: {
|
||||
topic: topic,
|
||||
payload: JSON.stringify({
|
||||
id: rst.mid,
|
||||
method: method + "rawSend",
|
||||
params: params
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var type = service.type;
|
||||
var identifier = service.identifier;
|
||||
|
||||
if (type == "property") {
|
||||
method += "property." + identifier;
|
||||
topic += "property/" + identifier;
|
||||
} else if (type == "service") {
|
||||
method += identifier;
|
||||
topic += identifier;
|
||||
} else if (type == "ota") {
|
||||
method += identifier;
|
||||
topic = "/ota/device/upgrade/" + service.productKey + "/" + service.deviceName;
|
||||
} else if (type == "config") {
|
||||
//设备配置下发
|
||||
method += identifier;
|
||||
topic = "/sys/" + service.productKey + "/" + service.deviceName + "/c/config/" + identifier;
|
||||
} else if (type = "lifetime") {
|
||||
//子设备注销下发
|
||||
method += identifier;
|
||||
topic = "/sys/" + service.productKey + "/" + service.deviceName + "/c/deregister";
|
||||
}
|
||||
if (type == "property" && identifier == "get") {
|
||||
var listParams = []
|
||||
for (var p in service.params) {
|
||||
listParams.push(service.params[p]);
|
||||
}
|
||||
return {
|
||||
productKey: service.productKey,
|
||||
deviceName: service.deviceName,
|
||||
mid: deviceMid,
|
||||
content: {
|
||||
topic: topic,
|
||||
payload: JSON.stringify({
|
||||
id: deviceMid,
|
||||
method: method,
|
||||
params: listParams
|
||||
})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (var p in service.params) {
|
||||
params[p] = service.params[p];
|
||||
}
|
||||
return {
|
||||
productKey: service.productKey,
|
||||
deviceName: service.deviceName,
|
||||
mid: deviceMid,
|
||||
content: {
|
||||
topic: topic,
|
||||
payload: JSON.stringify({
|
||||
id: deviceMid,
|
||||
method: method,
|
||||
params: params
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
|
@ -1,55 +0,0 @@
|
|||
|
||||
var mid=1;
|
||||
|
||||
function getMid(){
|
||||
mid++;
|
||||
if(mid>10000){
|
||||
mid=1;
|
||||
}
|
||||
return mid+"";
|
||||
}
|
||||
|
||||
this.decode = function (msg) {
|
||||
//对msg进行解析,并返回物模型数据
|
||||
var content=msg.content;
|
||||
var type = content.type;
|
||||
|
||||
if (type=="report") {
|
||||
//属性上报
|
||||
return {
|
||||
mid: msg.mid,
|
||||
productKey: msg.productKey,
|
||||
deviceName: msg.deviceName,
|
||||
type:"property",
|
||||
identifier: "report", //属性上报
|
||||
occur: new Date().getTime(), //时间戳,设备上的事件或数据产生的本地时间
|
||||
time: new Date().getTime(), //时间戳,消息上报时间
|
||||
data: content.params,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
this.encode = function (service,device) {
|
||||
var type=service.type;
|
||||
var identifier=service.identifier;
|
||||
var entityId=service.deviceName;
|
||||
var deviceMid=getMid();
|
||||
var params={};
|
||||
var target={};
|
||||
if("property"==type&&"set"==identifier){
|
||||
var domain=entityId.split(".")[0];
|
||||
var powerstate=service.params.powerstate==1?"turn_on":"turn_off";
|
||||
params.type="call_service";
|
||||
params.domain=domain;
|
||||
params.service=powerstate;
|
||||
target.entity_id=entityId;
|
||||
params.target=target;
|
||||
}
|
||||
return {
|
||||
productKey:service.productKey,
|
||||
deviceName:service.deviceName,
|
||||
mid:deviceMid,
|
||||
content:params
|
||||
}
|
||||
};
|
|
@ -1,54 +1,54 @@
|
|||
[
|
||||
{
|
||||
"id": "629e1d80a176d816952f1e82",
|
||||
"id": 1,
|
||||
"name": "我的家庭",
|
||||
"address": "",
|
||||
"uid": "629e1d7fa176d816952f1e81",
|
||||
"userId": 1,
|
||||
"spaceNum": 0,
|
||||
"deviceNum": 0,
|
||||
"current": true
|
||||
},
|
||||
{
|
||||
"id": "629e18e96b16ad6a3e158645",
|
||||
"id": 2,
|
||||
"name": "我的家",
|
||||
"uid": "629daa3de5a005209d182876",
|
||||
"userId": 3,
|
||||
"current": true
|
||||
},
|
||||
{
|
||||
"id": "6238a49fecf37861bed7ad11",
|
||||
"id": 3,
|
||||
"name": "我深圳的家",
|
||||
"address": "广东省深圳市南山区西丽镇",
|
||||
"uid": "04c6722f-9a6d-40f3-ac9b-cd791b4c8933",
|
||||
"userId": 1,
|
||||
"current": true
|
||||
},
|
||||
{
|
||||
"id":"6238a485ecf37861bed7ad10",
|
||||
"id":4,
|
||||
"name": "我深圳的家",
|
||||
"address": "广东省深圳市南山区西丽镇",
|
||||
"uid": "232f506f-76c0-46eb-890b-15edd1022ba1"
|
||||
"userId": 1
|
||||
},
|
||||
{
|
||||
"id": "6238a2caecf37861bed7ad0f",
|
||||
"id": 5,
|
||||
"name": "我深圳的家",
|
||||
"address": "广东省深圳市南山区西丽镇",
|
||||
"uid": "232f506f-76c0-46eb-890b-15edd1022ba1"
|
||||
"userId": 1
|
||||
},
|
||||
{
|
||||
"id": "6238a2adecf37861bed7ad0e",
|
||||
"id": 6,
|
||||
"name": "我深圳的家",
|
||||
"address": "广东省深圳市南山区西丽镇",
|
||||
"uid": "232f506f-76c0-46eb-890b-15edd1022ba1"
|
||||
"userId": 1
|
||||
},
|
||||
{
|
||||
"id": "61bafc1e16cb60612ab95f98",
|
||||
"id": 7,
|
||||
"name": "myhome",
|
||||
"address": "shengzhen nanshan",
|
||||
"uid": "183b4732-ce7f-4e4c-9c18-7e49fbf45579"
|
||||
"userId": 1
|
||||
},
|
||||
{
|
||||
"id": "61bafb6fb8477d132da69513",
|
||||
"id": 8,
|
||||
"name": "myhome",
|
||||
"address": "shengzhen nanshan",
|
||||
"uid": "183b4732-ce7f-4e4c-9c18-7e49fbf45579"
|
||||
"userId": 1
|
||||
}
|
||||
]
|
|
@ -1,65 +1,47 @@
|
|||
[
|
||||
{
|
||||
"id": "62a6a897f60ef7500d1a916b",
|
||||
"homeId": "6238a49fecf37861bed7ad11",
|
||||
"uid": "04c6722f-9a6d-40f3-ac9b-cd791b4c8933",
|
||||
"name": "123",
|
||||
"createAt": 1655089303228
|
||||
"id": 1,
|
||||
"homeId": 1,
|
||||
"name": "123"
|
||||
},
|
||||
{
|
||||
"id": "62a6a894f60ef7500d1a916a",
|
||||
"homeId": "6238a49fecf37861bed7ad11",
|
||||
"uid": "04c6722f-9a6d-40f3-ac9b-cd791b4c8933",
|
||||
"name": "123",
|
||||
"createAt": 1655089300741
|
||||
"id": 2,
|
||||
"homeId": 1,
|
||||
"name": "123"
|
||||
},
|
||||
{
|
||||
"id": "629e233be0dc6d4171e1a023",
|
||||
"homeId": "629e1d80a176d816952f1e82",
|
||||
"uid": "629e1d7fa176d816952f1e81",
|
||||
"name": "客厅",
|
||||
"createAt": 1654530875839
|
||||
"id": 3,
|
||||
"homeId": 1,
|
||||
"name": "客厅"
|
||||
},
|
||||
{
|
||||
"id": "629e18fee0dc6d4171e1a021",
|
||||
"homeId": "629e18e96b16ad6a3e158645",
|
||||
"uid": "629daa3de5a005209d182876",
|
||||
"name": "卧室",
|
||||
"createAt": 1654528254438
|
||||
"id": 4,
|
||||
"homeId": 1,
|
||||
"name": "卧室"
|
||||
},
|
||||
{
|
||||
"id": "629e18f3e0dc6d4171e1a020",
|
||||
"homeId": "629e18e96b16ad6a3e158645",
|
||||
"uid": "629daa3de5a005209d182876",
|
||||
"name": "客厅",
|
||||
"createAt": 1654528243058
|
||||
"id": 5,
|
||||
"homeId": 1,
|
||||
"name": "客厅"
|
||||
},
|
||||
{
|
||||
"id": "62794a820b0776663635e636",
|
||||
"homeId": "6238a49fecf37861bed7ad11",
|
||||
"uid": "04c6722f-9a6d-40f3-ac9b-cd791b4c8933",
|
||||
"name": "阳台",
|
||||
"createAt": 1652116098020
|
||||
"id": 6,
|
||||
"homeId": 1,
|
||||
"name": "阳台"
|
||||
},
|
||||
{
|
||||
"id": "62794a7d0b0776663635e635",
|
||||
"homeId": "6238a49fecf37861bed7ad11",
|
||||
"uid": "04c6722f-9a6d-40f3-ac9b-cd791b4c8933",
|
||||
"name": "厨房",
|
||||
"createAt": 1652116093323
|
||||
"id": 7,
|
||||
"homeId": 1,
|
||||
"name": "厨房"
|
||||
},
|
||||
{
|
||||
"id": "62794a740b0776663635e634",
|
||||
"homeId": "6238a49fecf37861bed7ad11",
|
||||
"uid": "04c6722f-9a6d-40f3-ac9b-cd791b4c8933",
|
||||
"name": "卧室",
|
||||
"createAt": 1652116084721
|
||||
"id": 8,
|
||||
"homeId": 1,
|
||||
"name": "卧室"
|
||||
},
|
||||
{
|
||||
"id": "62794a5c0b0776663635e633",
|
||||
"homeId": "6238a49fecf37861bed7ad11",
|
||||
"uid": "04c6722f-9a6d-40f3-ac9b-cd791b4c8933",
|
||||
"name": "客厅",
|
||||
"createAt": 1652116060926
|
||||
"id": 9,
|
||||
"homeId": 1,
|
||||
"name": "客厅"
|
||||
}
|
||||
]
|
|
@ -1,111 +1,82 @@
|
|||
[
|
||||
{
|
||||
"id": "629f5821e0dc6d4171e1a029",
|
||||
"uid": "629daa3de5a005209d182876",
|
||||
"id": 1,
|
||||
"deviceId": "164785263238900cefafcfeeab0000125",
|
||||
"name": "卧室的ZGW01",
|
||||
"homeId": "629e18e96b16ad6a3e158645",
|
||||
"spaceId": "629e18fee0dc6d4171e1a021",
|
||||
"addAt": 1654609953349,
|
||||
"homeId": 1,
|
||||
"spaceId": 1,
|
||||
"collect":true
|
||||
},
|
||||
{
|
||||
"id": "629f581ee0dc6d4171e1a028",
|
||||
"uid": "629daa3de5a005209d182876",
|
||||
"id": 2,
|
||||
"deviceId": "164776322117404acb9f03008d1500168",
|
||||
"name": "卧室的插座",
|
||||
"homeId": "629e18e96b16ad6a3e158645",
|
||||
"spaceId": "629e18fee0dc6d4171e1a021",
|
||||
"addAt": 1654609950464,
|
||||
"useAt": 1655653227177,
|
||||
"homeId": 1,
|
||||
"spaceId": 1,
|
||||
"collect":true
|
||||
},
|
||||
{
|
||||
"id": "629f581ce0dc6d4171e1a027",
|
||||
"uid": "629daa3de5a005209d182876",
|
||||
"id": 3,
|
||||
"deviceId": "1647763221972019a89f03008d1500163",
|
||||
"name": "卧室的插座",
|
||||
"homeId": "629e18e96b16ad6a3e158645",
|
||||
"spaceId": "629e18fee0dc6d4171e1a021",
|
||||
"addAt": 1654609948550,
|
||||
"useAt": 1655653294372,
|
||||
"homeId": 1,
|
||||
"spaceId": 1,
|
||||
"collect":false
|
||||
},
|
||||
{
|
||||
"id": "629f581ae0dc6d4171e1a026",
|
||||
"uid": "629daa3de5a005209d182876",
|
||||
"id": 4,
|
||||
"deviceId": "164776322227201472a803008d150016e",
|
||||
"name": "卧室的插座",
|
||||
"homeId": "629e18e96b16ad6a3e158645",
|
||||
"spaceId": "629e18fee0dc6d4171e1a021",
|
||||
"addAt": 1654609946750,
|
||||
"useAt": 1655653552172,
|
||||
"homeId": 1,
|
||||
"spaceId": 1,
|
||||
"collect":false
|
||||
},
|
||||
{
|
||||
"id": "629f5818e0dc6d4171e1a025",
|
||||
"uid": "629daa3de5a005209d182876",
|
||||
"id": 5,
|
||||
"deviceId": "16477632226720c2cc9f03008d1500166",
|
||||
"name": "卧室的插座",
|
||||
"homeId": "629e18e96b16ad6a3e158645",
|
||||
"spaceId": "629e18fee0dc6d4171e1a021",
|
||||
"addAt": 1654609944061,
|
||||
"useAt": 1655653548172,
|
||||
"homeId": 1,
|
||||
"spaceId": 1,
|
||||
"collect":false
|
||||
},
|
||||
{
|
||||
"id": "629f5734e0dc6d4171e1a024",
|
||||
"uid": "629daa3de5a005209d182876",
|
||||
"id": 6,
|
||||
"deviceId": "16477632215720c11b1602008d1500160",
|
||||
"name": "卧室的插座",
|
||||
"homeId": "629e18e96b16ad6a3e158645",
|
||||
"spaceId": "629e18fee0dc6d4171e1a021",
|
||||
"addAt": 1654609716856,
|
||||
"useAt": 1655653590474,
|
||||
"homeId": 1,
|
||||
"spaceId": 1,
|
||||
"collect":false
|
||||
},
|
||||
{
|
||||
"id": "629e1a1de0dc6d4171e1a022",
|
||||
"uid": "629daa3de5a005209d182876",
|
||||
"id": 7,
|
||||
"deviceId": "1647690908735019dd9f03008d1500163",
|
||||
"name": "卧室的插座",
|
||||
"homeId": "629e18e96b16ad6a3e158645",
|
||||
"spaceId": "629e18fee0dc6d4171e1a021",
|
||||
"addAt": 1654528541149,
|
||||
"useAt": 1655653255089,
|
||||
"homeId": 1,
|
||||
"spaceId": 1,
|
||||
"collect":false
|
||||
},
|
||||
{
|
||||
"id": "629db2e1e5a005209d182877",
|
||||
"uid": "04c6722f-9a6d-40f3-ac9b-cd791b4c8933",
|
||||
"id": 8,
|
||||
"deviceId": "16538390924670pulg0a001006000012a",
|
||||
"name": "阳台的插座",
|
||||
"homeId": "6238a49fecf37861bed7ad11",
|
||||
"spaceId": "62794a820b0776663635e636",
|
||||
"addAt": 1654502113734,
|
||||
"useAt": 1655653724374,
|
||||
"homeId": 1,
|
||||
"spaceId": 1,
|
||||
"collect":false
|
||||
},
|
||||
{
|
||||
"id": "6280d7cd7e234141ee9d1fd2",
|
||||
"uid": "04c6722f-9a6d-40f3-ac9b-cd791b4c8933",
|
||||
"id": 9,
|
||||
"deviceId": "16501806313260000833feffac33bc16c",
|
||||
"name": "灯的插座",
|
||||
"homeId": "6238a49fecf37861bed7ad11",
|
||||
"spaceId": "62794a5c0b0776663635e633",
|
||||
"addAt": 1652611021619,
|
||||
"useAt": 1655181137254,
|
||||
"homeId": 1,
|
||||
"spaceId": 1,
|
||||
"collect":false
|
||||
},
|
||||
{
|
||||
"id": "6280b17d7e234141ee9d1fcf",
|
||||
"uid": "04c6722f-9a6d-40f3-ac9b-cd791b4c8933",
|
||||
"id": 10,
|
||||
"deviceId": "165017126122400cefafcfee61000012b",
|
||||
"name": "客厅网关",
|
||||
"homeId": "6238a49fecf37861bed7ad11",
|
||||
"spaceId": "62794a5c0b0776663635e633",
|
||||
"addAt": 1652601213676,
|
||||
"useAt": 1655189186348,
|
||||
"homeId": 1,
|
||||
"spaceId": 1,
|
||||
"collect":false
|
||||
}
|
||||
]
|
|
@ -0,0 +1,11 @@
|
|||
[
|
||||
{
|
||||
"id": 453554819821637,
|
||||
"appName": "微信小程序",
|
||||
"appId": "wx5eebdd2bab2d805c",
|
||||
"appSecret": "cd8096ac1d6a901fe98d5f745d2bfc2b",
|
||||
"appType": "1",
|
||||
"remark": "微信小程序",
|
||||
"tenantId": "452748015218757"
|
||||
}
|
||||
]
|
|
@ -1,72 +1,112 @@
|
|||
[
|
||||
{
|
||||
"id": 1,
|
||||
"tenantId": "000000",
|
||||
"configName": "主框架页-默认皮肤样式名称",
|
||||
"configKey": "sys.index.skinName",
|
||||
"configValue": "skin-blue",
|
||||
"configType": "Y",
|
||||
"createDept": 103,
|
||||
"createBy": 1,
|
||||
|
||||
"updateBy": null,
|
||||
"updateTime": null,
|
||||
"remark": "蓝色 skin-blue、绿色 skin-green、紫色 skin-purple、红色 skin-red、黄色 skin-yellow"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"tenantId": "000000",
|
||||
"configName": "用户管理-账号初始密码",
|
||||
"configKey": "sys.user.initPassword",
|
||||
"configValue": "123456",
|
||||
"configType": "Y",
|
||||
"createDept": 103,
|
||||
"createBy": 1,
|
||||
|
||||
"updateBy": null,
|
||||
"updateTime": null,
|
||||
"remark": "初始化密码 123456"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"tenantId": "000000",
|
||||
"configName": "主框架页-侧边栏主题",
|
||||
"configKey": "sys.index.sideTheme",
|
||||
"configValue": "theme-dark",
|
||||
"configType": "Y",
|
||||
"createDept": 103,
|
||||
"createBy": 1,
|
||||
|
||||
"updateBy": null,
|
||||
"updateTime": null,
|
||||
"remark": "深色主题theme-dark,浅色主题theme-light"
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"tenantId": "000000",
|
||||
"configName": "账号自助-是否开启用户注册功能",
|
||||
"configKey": "sys.account.registerUser",
|
||||
"configValue": "false",
|
||||
"configType": "Y",
|
||||
"createDept": 103,
|
||||
"createBy": 1,
|
||||
|
||||
"updateBy": null,
|
||||
"updateTime": null,
|
||||
"remark": "是否开启注册用户功能(true开启,false关闭)"
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"tenantId": "000000",
|
||||
"configName": "OSS预览列表资源开关",
|
||||
"configKey": "sys.oss.previewListResource",
|
||||
"configValue": "true",
|
||||
"configType": "Y",
|
||||
"createDept": 103,
|
||||
"createBy": 1,
|
||||
|
||||
"updateBy": null,
|
||||
"updateTime": null,
|
||||
"remark": "true:开启, false:关闭"
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"tenantId": "000000",
|
||||
"configName": "主框架页-默认皮肤样式名称",
|
||||
"configKey": "sys.index.skinName",
|
||||
"configValue": "skin-blue",
|
||||
"configType": "Y",
|
||||
"createDept": 103,
|
||||
"createBy": 1,
|
||||
"updateBy": null,
|
||||
"updateTime": null,
|
||||
"remark": "蓝色 skin-blue、绿色 skin-green、紫色 skin-purple、红色 skin-red、黄色 skin-yellow"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"tenantId": "000000",
|
||||
"configName": "用户管理-账号初始密码",
|
||||
"configKey": "sys.user.initPassword",
|
||||
"configValue": "123456",
|
||||
"configType": "Y",
|
||||
"createDept": 103,
|
||||
"createBy": 1,
|
||||
"updateBy": null,
|
||||
"updateTime": null,
|
||||
"remark": "初始化密码 123456"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"tenantId": "000000",
|
||||
"configName": "主框架页-侧边栏主题",
|
||||
"configKey": "sys.index.sideTheme",
|
||||
"configValue": "theme-dark",
|
||||
"configType": "Y",
|
||||
"createDept": 103,
|
||||
"createBy": 1,
|
||||
"updateBy": null,
|
||||
"updateTime": null,
|
||||
"remark": "深色主题theme-dark,浅色主题theme-light"
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"tenantId": "000000",
|
||||
"configName": "账号自助-是否开启用户注册功能",
|
||||
"configKey": "sys.account.registerUser",
|
||||
"configValue": "false",
|
||||
"configType": "Y",
|
||||
"createDept": 103,
|
||||
"createBy": 1,
|
||||
"updateBy": null,
|
||||
"updateTime": null,
|
||||
"remark": "是否开启注册用户功能(true开启,false关闭)"
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"tenantId": "000000",
|
||||
"configName": "OSS预览列表资源开关",
|
||||
"configKey": "sys.oss.previewListResource",
|
||||
"configValue": "true",
|
||||
"configType": "Y",
|
||||
"createDept": 103,
|
||||
"createBy": 1,
|
||||
"updateBy": null,
|
||||
"updateTime": null,
|
||||
"remark": "true:开启, false:关闭"
|
||||
},
|
||||
{
|
||||
"id": 452767972696133,
|
||||
"configKey": "sys.index.skinName",
|
||||
"configName": "主框架页-默认皮肤样式名称",
|
||||
"configType": "Y",
|
||||
"configValue": "skin-blue",
|
||||
"remark": "蓝色 skin-blue、绿色 skin-green、紫色 skin-purple、红色 skin-red、黄色 skin-yellow",
|
||||
"tenantId": "452748015218757"
|
||||
},
|
||||
{
|
||||
"id": 452767972700229,
|
||||
"configKey": "sys.user.initPassword",
|
||||
"configName": "用户管理-账号初始密码",
|
||||
"configType": "Y",
|
||||
"configValue": "123456",
|
||||
"remark": "初始化密码 123456",
|
||||
"tenantId": "452748015218757"
|
||||
},
|
||||
{
|
||||
"id": 452767972704325,
|
||||
"configKey": "sys.index.sideTheme",
|
||||
"configName": "主框架页-侧边栏主题",
|
||||
"configType": "Y",
|
||||
"configValue": "theme-dark",
|
||||
"remark": "深色主题theme-dark,浅色主题theme-light",
|
||||
"tenantId": "452748015218757"
|
||||
},
|
||||
{
|
||||
"id": 452767972708421,
|
||||
"configKey": "sys.account.registerUser",
|
||||
"configName": "账号自助-是否开启用户注册功能",
|
||||
"configType": "Y",
|
||||
"configValue": "false",
|
||||
"remark": "是否开启注册用户功能(true开启,false关闭)",
|
||||
"tenantId": "452748015218757"
|
||||
},
|
||||
{
|
||||
"id": 452767972708422,
|
||||
"configKey": "sys.oss.previewListResource",
|
||||
"configName": "OSS预览列表资源开关",
|
||||
"configType": "Y",
|
||||
"configValue": "true",
|
||||
"remark": "true:开启, false:关闭",
|
||||
"tenantId": "452748015218757"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -178,5 +178,18 @@
|
|||
|
||||
"updateBy": null,
|
||||
"updateTime": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 452767971254341,
|
||||
"tenantId": "452748015218757",
|
||||
"parentId": 0,
|
||||
"ancestors": "0",
|
||||
"deptName": "测试租户有限公司",
|
||||
"orderNum": null,
|
||||
"leader": "test",
|
||||
"phone": "18888888888",
|
||||
"email": null,
|
||||
"status": "0",
|
||||
"delFlag": "0"
|
||||
}
|
||||
]
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -102,5 +102,69 @@
|
|||
"updateBy": null,
|
||||
"updateTime": null,
|
||||
"remark": "登录状态列表"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 452767972294725,
|
||||
"tenantId": "452748015218757",
|
||||
"dictName": "用户性别",
|
||||
"dictType": "sys_user_sex",
|
||||
"status": "0",
|
||||
"remark": "用户性别列表"
|
||||
},
|
||||
{
|
||||
"id": 452767972298821,
|
||||
"tenantId": "452748015218757",
|
||||
"dictName": "菜单状态",
|
||||
"dictType": "sys_show_hide",
|
||||
"status": "0",
|
||||
"remark": "菜单状态列表"
|
||||
},
|
||||
{
|
||||
"id": 452767972298822,
|
||||
"tenantId": "452748015218757",
|
||||
"dictName": "系统开关",
|
||||
"dictType": "sys_normal_disable",
|
||||
"status": "0",
|
||||
"remark": "系统开关列表"
|
||||
},
|
||||
{
|
||||
"id": 452767972298823,
|
||||
"tenantId": "452748015218757",
|
||||
"dictName": "系统是否",
|
||||
"dictType": "sys_yes_no",
|
||||
"status": "0",
|
||||
"remark": "系统是否列表"
|
||||
},
|
||||
{
|
||||
"id": 452767972298824,
|
||||
"tenantId": "452748015218757",
|
||||
"dictName": "通知类型",
|
||||
"dictType": "sys_notice_type",
|
||||
"status": "0",
|
||||
"remark": "通知类型列表"
|
||||
},
|
||||
{
|
||||
"id": 452767972298825,
|
||||
"tenantId": "452748015218757",
|
||||
"dictName": "通知状态",
|
||||
"dictType": "sys_notice_status",
|
||||
"status": "0",
|
||||
"remark": "通知状态列表"
|
||||
},
|
||||
{
|
||||
"id": 452767972302917,
|
||||
"tenantId": "452748015218757",
|
||||
"dictName": "操作类型",
|
||||
"dictType": "sys_oper_type",
|
||||
"status": "0",
|
||||
"remark": "操作类型列表"
|
||||
},
|
||||
{
|
||||
"id": 452767972302918,
|
||||
"tenantId": "452748015218757",
|
||||
"dictName": "登录状态",
|
||||
"dictType": "sys_common_status",
|
||||
"status": "0",
|
||||
"remark": "登录状态列表"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -422,6 +422,155 @@
|
|||
"remark":"文件管理菜单",
|
||||
"children":[
|
||||
|
||||
]
|
||||
},{
|
||||
"createDept":103,
|
||||
"createBy":1,
|
||||
"createTime":null,
|
||||
"updateBy":null,
|
||||
"updateTime":null,
|
||||
"id":502,
|
||||
"menuName":"应用管理",
|
||||
"parentId":1,
|
||||
"orderNum":11,
|
||||
"path":"app",
|
||||
"component":"system/app/index",
|
||||
"queryParam":"",
|
||||
"isFrame":"1",
|
||||
"isCache":"0",
|
||||
"menuType":"C",
|
||||
"visible":"0",
|
||||
"status":"0",
|
||||
"perms":"system:app:list",
|
||||
"icon":"phone",
|
||||
"remark":"应用管理菜单",
|
||||
"children":[
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
"createDept":null,
|
||||
"createBy":null,
|
||||
"createTime":null,
|
||||
"updateBy":null,
|
||||
"updateTime":null,
|
||||
"id":442129,
|
||||
"menuName":"应用查询",
|
||||
"parentId":502,
|
||||
"orderNum":1,
|
||||
"path":"",
|
||||
"component":null,
|
||||
"queryParam":null,
|
||||
"isFrame":"1",
|
||||
"isCache":"0",
|
||||
"menuType":"F",
|
||||
"visible":"0",
|
||||
"status":"0",
|
||||
"perms":"system:app:query",
|
||||
"icon":"",
|
||||
"remark":null,
|
||||
"children":[
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
"createDept":null,
|
||||
"createBy":null,
|
||||
"createTime":null,
|
||||
"updateBy":null,
|
||||
"updateTime":null,
|
||||
"id":44212332,
|
||||
"menuName":"应用添加",
|
||||
"parentId":502,
|
||||
"orderNum":2,
|
||||
"path":"",
|
||||
"component":null,
|
||||
"queryParam":null,
|
||||
"isFrame":"1",
|
||||
"isCache":"0",
|
||||
"menuType":"F",
|
||||
"visible":"0",
|
||||
"status":"0",
|
||||
"perms":"system:app:add",
|
||||
"icon":"",
|
||||
"remark":null,
|
||||
"children":[
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
"createDept":null,
|
||||
"createBy":null,
|
||||
"createTime":null,
|
||||
"updateBy":null,
|
||||
"updateTime":null,
|
||||
"id":442123323123,
|
||||
"menuName":"应用删除",
|
||||
"parentId":502,
|
||||
"orderNum":3,
|
||||
"path":"",
|
||||
"component":null,
|
||||
"queryParam":null,
|
||||
"isFrame":"1",
|
||||
"isCache":"0",
|
||||
"menuType":"F",
|
||||
"visible":"0",
|
||||
"status":"0",
|
||||
"perms":"system:app:remove",
|
||||
"icon":"",
|
||||
"remark":null,
|
||||
"children":[
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
"createDept":null,
|
||||
"createBy":null,
|
||||
"createTime":null,
|
||||
"updateBy":null,
|
||||
"updateTime":null,
|
||||
"id":423,
|
||||
"menuName":"应用修改",
|
||||
"parentId":502,
|
||||
"orderNum":4,
|
||||
"path":"",
|
||||
"component":null,
|
||||
"queryParam":null,
|
||||
"isFrame":"1",
|
||||
"isCache":"0",
|
||||
"menuType":"F",
|
||||
"visible":"0",
|
||||
"status":"0",
|
||||
"perms":"system:app:edit",
|
||||
"icon":"",
|
||||
"remark":null,
|
||||
"children":[
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
"createDept":null,
|
||||
"createBy":null,
|
||||
"createTime":null,
|
||||
"updateBy":null,
|
||||
"updateTime":null,
|
||||
"id":4234553537,
|
||||
"menuName":"应用导出",
|
||||
"parentId":502,
|
||||
"orderNum":5,
|
||||
"path":"",
|
||||
"component":null,
|
||||
"queryParam":null,
|
||||
"isFrame":"1",
|
||||
"isCache":"0",
|
||||
"menuType":"F",
|
||||
"visible":"0",
|
||||
"status":"0",
|
||||
"perms":"system:app:export",
|
||||
"icon":"",
|
||||
"remark":null,
|
||||
"children":[
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
@ -34,5 +34,18 @@
|
|||
"updateBy": null,
|
||||
"updateTime": null,
|
||||
"remark": "普通角色"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 452767970971717,
|
||||
"tenantId": "452748015218757",
|
||||
"roleName": "管理员",
|
||||
"roleKey": "admin",
|
||||
"roleSort": 1,
|
||||
"data_scope": null,
|
||||
"menuCheck_strictly": null,
|
||||
"deptCheck_strictly": null,
|
||||
"status": "0",
|
||||
"delFlag": "0",
|
||||
"remark": "管理员"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -10,5 +10,9 @@
|
|||
{
|
||||
"roleId": 2,
|
||||
"deptId": 105
|
||||
}
|
||||
},
|
||||
{
|
||||
"roleId": 452767970971717,
|
||||
"deptId": 452767971254341
|
||||
}
|
||||
]
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -19,5 +19,21 @@
|
|||
"createBy": 1,
|
||||
"updateBy": null,
|
||||
"updateTime": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 452748015235141,
|
||||
"tenantId": "452748015218757",
|
||||
"contactUserName": "测试人员",
|
||||
"contactPhone": "18888888888",
|
||||
"companyName": "测试租户有限公司",
|
||||
"licenseNumber": "12312312312",
|
||||
"address": "13123123",
|
||||
"intro": "测试租户有限公司管理系统",
|
||||
"domain": null,
|
||||
"remark": "租户管理员账密:test/test123",
|
||||
"packageId": 450389924483141,
|
||||
"accountCount": -1,
|
||||
"status": "0",
|
||||
"delFlag": "0"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -1 +1,11 @@
|
|||
[]
|
||||
[
|
||||
{
|
||||
"id": 450389924483141,
|
||||
"packageName": "测试套餐",
|
||||
"delFlag": "0",
|
||||
"menuCheckStrictly": true,
|
||||
"menuIds":"1,100,1001,1002,1003,1004,1005,1006,1007,101,1008,1009,1010,1011,1012,102,1013,1014,1015,1016,103,1017,1018,1019,1020,104,1021,1022,1023,1024,1025,105,1026,1027,1028,1029,1030,106,1031,1032,1033,1034,1035,107,1036,1037,1038,1039,108,500,1040,1041,1042,501,1043,1044,1045,1050,118,1600,1601,1602,1603,1604,1605,502,442129,44212332,442123323123,423,4234553537,2200,2201,441851175424069,441851310268485,441851485323333,2214,2205,441853056651333,441853220675653,441853285179461,441862726639685,441862877970501,441862978281541,441863058096197,2206,441869217525829,441869327724613,441869398310981,441869530075205,441869649666117,441869802405957,441870007808069,441870091001925,441870227968069,441870309814341,2207,441870607315013,441870717771845,441870780928069,441870881378373,2215,2225,442149490409541,442149580529733,442149650423877,442149811572805,2208,2209,442127879118917,442127985041477,442128064598085,442128163270725,2210,442127357415493,442127532781637,442127596064837,442127705182277,2211,2212,442128593006661,442128733950021,442128795189317,2213,442129175347269,442129320091717,442129388187717,2216,2217,2218,2219,442130419388485,442130475098181,442130534805573,442143693541445,2220,2221,2222,442131294584901,2223,442130860195909,442130932109381,442131029889093,442131115253829",
|
||||
"status": "0",
|
||||
"remark": "测试套餐"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
"tenantId": "000000",
|
||||
"deptId": 103,
|
||||
"userName": "admin",
|
||||
"nickName": "疯狂的狮子Li",
|
||||
"nickName": "admin",
|
||||
"userType": "sys_user",
|
||||
"email": "crazyLionLi@163.com",
|
||||
"email": "xw2sy@163.com",
|
||||
"phonenumber": "15888888888",
|
||||
"sex": "1",
|
||||
"avatar": null,
|
||||
|
@ -63,5 +63,22 @@
|
|||
"tenantId": "000000",
|
||||
"userName": "openiita",
|
||||
"userType": "sys_user"
|
||||
},
|
||||
{
|
||||
"id": 452767971950661,
|
||||
"avatar": null,
|
||||
"delFlag": "0",
|
||||
"deptId": 452767971254341,
|
||||
"email": null,
|
||||
"loginIp": null,
|
||||
"nickName": "test",
|
||||
"password": "$2a$10$4Myxy0yK7OUh.y65DNcnKuG9lf3L934CJteU8mx5.Al5PsrIvTnuW",
|
||||
"phonenumber": "18888888888",
|
||||
"remark": "管理员",
|
||||
"sex": null,
|
||||
"status": "0",
|
||||
"tenantId": "452748015218757",
|
||||
"userName": "test",
|
||||
"userType": "sys_user"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -10,5 +10,9 @@
|
|||
{
|
||||
"userId": 3,
|
||||
"roleId": 2
|
||||
},
|
||||
{
|
||||
"userId": 452767971950661,
|
||||
"roleId": 452767970971717
|
||||
}
|
||||
]
|
||||
|
|
|
@ -1562,7 +1562,17 @@
|
|||
"name": "水温度",
|
||||
"accessMode": "r"
|
||||
},
|
||||
|
||||
{
|
||||
"identifier": "query",
|
||||
"dataType": {
|
||||
"type": "text",
|
||||
"specs": {
|
||||
"length": "255"
|
||||
}
|
||||
},
|
||||
"name": "查询",
|
||||
"accessMode": "rw"
|
||||
},
|
||||
{
|
||||
"identifier": "McuStatus",
|
||||
"dataType": {
|
||||
|
@ -1828,7 +1838,17 @@
|
|||
"name": "实时运行状态",
|
||||
"accessMode": "rw"
|
||||
},
|
||||
|
||||
{
|
||||
"identifier": "Time",
|
||||
"dataType": {
|
||||
"type": "text",
|
||||
"specs": {
|
||||
"length": "255"
|
||||
}
|
||||
},
|
||||
"name": "时间戳",
|
||||
"accessMode": "rw"
|
||||
},
|
||||
{
|
||||
"identifier": "TimeModeSet",
|
||||
"dataType": {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
{
|
||||
"id": 13123123123213,
|
||||
"uid": "13480802157",
|
||||
"ownerId": "1",
|
||||
"tenantId": "000000",
|
||||
"secret": "483752384B473759556E685768796B6F644E48634F76486C51646A41576B545A2B396C34474244414F334F78574F4778613764564338594E666770595A376177",
|
||||
"nickName": "song2",
|
||||
"type": 1,
|
||||
|
@ -13,12 +13,12 @@
|
|||
"usePlatforms": [
|
||||
"dueros"
|
||||
],
|
||||
"createAt": 1654529407977
|
||||
"createTime": 1654529407977
|
||||
},
|
||||
{
|
||||
"id": 141231312312,
|
||||
"uid": "guest1",
|
||||
"ownerId": "1",
|
||||
"tenantId": "000000",
|
||||
"nickName": "演示账户",
|
||||
"secret": "48774861346645676F51324A4D6E6639306E6474437741634C4333746C4575666C316F76503455542B5836763065315A2F676244695056557356704D49513569",
|
||||
"type": 0,
|
||||
|
@ -28,12 +28,12 @@
|
|||
],
|
||||
"permissions": [],
|
||||
"usePlatforms": [],
|
||||
"createAt": 1647592821770
|
||||
"createTime": 1647592821770
|
||||
},
|
||||
{
|
||||
"id": 13123123,
|
||||
"uid": "iotkit",
|
||||
"ownerId": "1",
|
||||
"tenantId": "000000",
|
||||
"nickName": "管理员",
|
||||
"secret": "6E49354D37437030564370666E48486150524B3134743258735059354D75324F6532594478654C47767535614C6C6E767139625170774E576477785A34513369",
|
||||
"type": 0,
|
||||
|
@ -45,12 +45,12 @@
|
|||
"write"
|
||||
],
|
||||
"usePlatforms": [],
|
||||
"createAt": 1647592821770
|
||||
"createTime": 1647592821770
|
||||
},
|
||||
{
|
||||
"id": 12312312312,
|
||||
"uid": "du2",
|
||||
"ownerId": "1",
|
||||
"tenantId": "000000",
|
||||
"nickName": "小度接入2",
|
||||
"type": 1,
|
||||
"roles": [
|
||||
|
@ -59,12 +59,12 @@
|
|||
"usePlatforms": [
|
||||
"dueros"
|
||||
],
|
||||
"createAt": 1651230139460
|
||||
"createTime": 1651230139460
|
||||
},
|
||||
{
|
||||
"id": 23423423,
|
||||
"uid": "tm3",
|
||||
"ownerId": "1",
|
||||
"tenantId": "000000",
|
||||
"nickName": "天猫精灵test3",
|
||||
"type": 1,
|
||||
"roles": [
|
||||
|
@ -73,12 +73,12 @@
|
|||
"usePlatforms": [
|
||||
"aligenie"
|
||||
],
|
||||
"createAt": 1647982036151
|
||||
"createTime": 1647982036151
|
||||
},
|
||||
{
|
||||
"id": 45234345,
|
||||
"uid": "du1",
|
||||
"ownerId": "1",
|
||||
"tenantId": "000000",
|
||||
"nickName": "小度接入1",
|
||||
"secret": "483752384B473759556E685768796B6F644E48634F76486C51646A41576B545A2B396C34474244414F334F517674507547437A72627A7154302B724441734C5A",
|
||||
"type": 1,
|
||||
|
@ -89,12 +89,12 @@
|
|||
"dueros",
|
||||
"aligenie"
|
||||
],
|
||||
"createAt": 1651226639006
|
||||
"createTime": 1651226639006
|
||||
},
|
||||
{
|
||||
"id": 3454543,
|
||||
"uid": "tm1",
|
||||
"ownerId": "1",
|
||||
"tenantId": "000000",
|
||||
"nickName": "天猫精灵1",
|
||||
"type": 1,
|
||||
"roles": [
|
||||
|
@ -103,12 +103,12 @@
|
|||
"usePlatforms": [
|
||||
"aligenie"
|
||||
],
|
||||
"createAt": 1648486563107
|
||||
"createTime": 1648486563107
|
||||
},
|
||||
{
|
||||
"id": 432323,
|
||||
"uid": "18126045687",
|
||||
"ownerId": "1",
|
||||
"tenantId": "000000",
|
||||
"nickName": "song",
|
||||
"secret": "483752384B473759556E685768796B6F644E48634F76486C51646A41576B545A2B396C34474244414F334F517674507547437A72627A7154302B724441734C5A",
|
||||
"type": 1,
|
||||
|
@ -119,6 +119,6 @@
|
|||
"aligenie",
|
||||
"dueros"
|
||||
],
|
||||
"createAt": 1652115298592
|
||||
"createTime": 1652115298592
|
||||
}
|
||||
]
|
|
@ -1,52 +1,75 @@
|
|||
version: '3'
|
||||
version: "3.4"
|
||||
|
||||
services:
|
||||
mysql:
|
||||
container_name: iot-mysql
|
||||
image: mysql:8
|
||||
restart: unless-stopped
|
||||
tty: true
|
||||
ports:
|
||||
- "3306:3306"
|
||||
environment:
|
||||
MYSQL_DATABASE: ${MYSQL_DATABASE:-iotkit}
|
||||
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-123456}
|
||||
volumes:
|
||||
- mysql:/var/lib/mysql/
|
||||
|
||||
|
||||
redis:
|
||||
image: redis:5.0.8
|
||||
container_name: iotkit-ce-redis
|
||||
container_name: iot-redis
|
||||
image: redis:6-alpine
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- 6379:6379
|
||||
- "6379:6379"
|
||||
volumes:
|
||||
- "redis-volume:/data"
|
||||
command: redis-server --appendonly yes
|
||||
- redis:/data
|
||||
|
||||
server:
|
||||
container_name: iot-server
|
||||
build:
|
||||
context: ./
|
||||
image: iot-server
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8086:8086"
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
elasticsearch:
|
||||
image: elasticsearch:7.12.0
|
||||
container_name: iotkit-ce-elasticsearch
|
||||
environment:
|
||||
ES_JAVA_OPTS: -Djava.net.preferIPv4Stack=true -Xms1g -Xmx1g
|
||||
transport.host: 0.0.0.0
|
||||
discovery.type: single-node
|
||||
bootstrap.memory_lock: "true"
|
||||
ports:
|
||||
- 9200:9200
|
||||
- 9300:9300
|
||||
volumes:
|
||||
- "elasticsearch-volume:/usr/share/elasticsearch/data"
|
||||
ui:
|
||||
image: uncleregan/iotkit-ui:0.3.4
|
||||
container_name: iotkit-ce-ui
|
||||
ports:
|
||||
- 80:80
|
||||
links:
|
||||
- iotkit:iotkit
|
||||
volumes:
|
||||
- "iotkit-volume:/usr/share/nginx/html/upload"
|
||||
iotkit:
|
||||
image: uncleregan/iotkit:0.3.4
|
||||
container_name: iotkit-ce
|
||||
restart: on-failure
|
||||
ports:
|
||||
- 8086:8086 # API端口
|
||||
- 1883-1890:1883-1890 # 预留
|
||||
- 8000-8010:8000-8010 # 预留
|
||||
links:
|
||||
- redis:redis
|
||||
- elasticsearch:elasticsearch
|
||||
# https://github.com/polovyivan/docker-pass-configs-to-container
|
||||
SPRING_PROFILES_ACTIVE: local
|
||||
JAVA_OPTS:
|
||||
${JAVA_OPTS:-
|
||||
-Xms512m
|
||||
-Xmx512m
|
||||
-Djava.security.egd=file:/dev/./urandom
|
||||
}
|
||||
ARGS:
|
||||
--spring.datasource.dynamic.datasource.master.url=${MASTER_DATASOURCE_URL:-jdbc:mysql://iot-mysql:3306/iotkit?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true}
|
||||
--spring.datasource.dynamic.datasource.master.username=${MASTER_DATASOURCE_USERNAME:-root}
|
||||
--spring.datasource.dynamic.datasource.master.password=${MASTER_DATASOURCE_PASSWORD:-123456}
|
||||
--spring.datasource.dynamic.datasource.slave.url=${SLAVE_DATASOURCE_URL:-jdbc:mysql://iot-mysql:3306/iotkit?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true}
|
||||
--spring.datasource.dynamic.datasource.slave.username=${SLAVE_DATASOURCE_USERNAME:-root}
|
||||
--spring.datasource.dynamic.datasource.slave.password=${SLAVE_DATASOURCE_PASSWORD:-123456}
|
||||
--spring.redis.host=${REDIS_HOST:-iot-redis}
|
||||
depends_on:
|
||||
- elasticsearch
|
||||
- redis
|
||||
|
||||
admin:
|
||||
container_name: iot-admin
|
||||
build:
|
||||
context: ./iot-ui-admin
|
||||
args:
|
||||
NODE_ENV:
|
||||
ENV=${NODE_ENV:-production}
|
||||
PUBLIC_PATH=${PUBLIC_PATH:-/}
|
||||
VUE_APP_TITLE=${VUE_APP_TITLE:-openiita管理系统}
|
||||
image: iot-admin
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8080:80"
|
||||
depends_on:
|
||||
- server
|
||||
|
||||
volumes:
|
||||
redis-volume:
|
||||
elasticsearch-volume:
|
||||
iotkit-volume:
|
||||
mysql:
|
||||
driver: local
|
||||
redis:
|
||||
driver: local
|
|
@ -0,0 +1,19 @@
|
|||
## mysql
|
||||
MYSQL_DATABASE=iotkit
|
||||
MYSQL_ROOT_PASSWORD=123456
|
||||
|
||||
## server
|
||||
JAVA_OPTS=-Xms512m -Xmx512m -Djava.security.egd=file:/dev/./urandom
|
||||
|
||||
MASTER_DATASOURCE_URL=jdbc:mysql://iot-mysql:3306/${MYSQL_DATABASE}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
||||
MASTER_DATASOURCE_USERNAME=root
|
||||
MASTER_DATASOURCE_PASSWORD=${MYSQL_ROOT_PASSWORD}
|
||||
SLAVE_DATASOURCE_URL=${MASTER_DATASOURCE_URL}
|
||||
SLAVE_DATASOURCE_USERNAME=${MASTER_DATASOURCE_USERNAME}
|
||||
SLAVE_DATASOURCE_PASSWORD=${MASTER_DATASOURCE_PASSWORD}
|
||||
REDIS_HOST=iot-redis
|
||||
|
||||
## admin
|
||||
NODE_ENV=production
|
||||
PUBLIC_PATH=/
|
||||
VUE_APP_TITLE=iot管理系统
|
|
@ -15,6 +15,7 @@ import lombok.Builder;
|
|||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -23,7 +24,7 @@ import java.util.List;
|
|||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UserInfo implements Id<Long> {
|
||||
public class UserInfo extends TenantModel implements Id<Long>, Serializable {
|
||||
|
||||
public static final int USER_TYPE_PLATFORM = 0;
|
||||
public static final int USER_TYPE_CLIENT = 1;
|
||||
|
@ -35,11 +36,6 @@ public class UserInfo implements Id<Long> {
|
|||
*/
|
||||
private String uid;
|
||||
|
||||
/**
|
||||
* 归属账号
|
||||
*/
|
||||
private String ownerId;
|
||||
|
||||
/**
|
||||
* 密钥(密码加密后的内容)
|
||||
*/
|
||||
|
@ -92,6 +88,4 @@ public class UserInfo implements Id<Long> {
|
|||
*/
|
||||
private List<String> usePlatforms = new ArrayList<>();
|
||||
|
||||
private Long createAt;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 奇特物联 2021-2022 All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed 未经许可不能去掉「奇特物联」相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: xw2sy@163.com
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
package cc.iotkit.model.device.message;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 物模型消息
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class ThingModelMessage {
|
||||
|
||||
public static final String TYPE_LIFETIME = "lifetime";
|
||||
public static final String TYPE_STATE = "state";
|
||||
public static final String TYPE_PROPERTY = "property";
|
||||
|
||||
public static final String TYPE_EVENT = "event";
|
||||
public static final String TYPE_SERVICE = "service";
|
||||
|
||||
public static final String TYPE_OTA = "ota";
|
||||
public static final String TYPE_CONFIG = "config";
|
||||
public static final String ID_PROPERTY_GET = "get";
|
||||
public static final String ID_PROPERTY_SET = "set";
|
||||
public static final String ID_PROPERTY_REPORT = "report";
|
||||
public static final String ID_CONFIG_GET = "get";
|
||||
public static final String ID_CONFIG_SET = "set";
|
||||
public static final String ID_DEREGISTER = "deregister";
|
||||
|
||||
private String id;
|
||||
|
||||
private String mid;
|
||||
|
||||
private String deviceId;
|
||||
|
||||
private String productKey;
|
||||
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* 所属用户ID
|
||||
*/
|
||||
private String uid;
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
* lifetime:生命周期
|
||||
* state:状态
|
||||
* property:属性
|
||||
* event:事件
|
||||
* service:服务
|
||||
*/
|
||||
private String type;
|
||||
|
||||
private String identifier;
|
||||
|
||||
/**
|
||||
* 消息状态码
|
||||
*/
|
||||
private int code;
|
||||
|
||||
private Object data;
|
||||
|
||||
/**
|
||||
* 时间戳,设备上的事件或数据产生的本地时间
|
||||
*/
|
||||
private Long occurred;
|
||||
|
||||
/**
|
||||
* 消息上报时间
|
||||
*/
|
||||
private Long time;
|
||||
|
||||
public Map<String, Object> dataToMap() {
|
||||
Map<String, Object> mapData = new HashMap<>();
|
||||
if (data instanceof Map) {
|
||||
((Map<?, ?>) data).forEach((key, value) -> mapData.put(key.toString(), value));
|
||||
}
|
||||
return mapData;
|
||||
}
|
||||
}
|
|
@ -9,19 +9,23 @@
|
|||
*/
|
||||
package cc.iotkit.model.space;
|
||||
|
||||
import cc.iotkit.model.Owned;
|
||||
import cc.iotkit.model.Id;
|
||||
import cc.iotkit.model.TenantModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Home implements Owned<String> {
|
||||
public class Home extends TenantModel implements Id<Long>, Serializable {
|
||||
|
||||
private String id;
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 家庭名称
|
||||
|
@ -36,7 +40,7 @@ public class Home implements Owned<String> {
|
|||
/**
|
||||
* 关联用户id
|
||||
*/
|
||||
private String uid;
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 空间数量
|
||||
|
@ -52,4 +56,9 @@ public class Home implements Owned<String> {
|
|||
* 是否为用户当前使用的家庭
|
||||
*/
|
||||
private Boolean current;
|
||||
|
||||
/**
|
||||
* 空间对象
|
||||
*/
|
||||
private List<Space> spaces;
|
||||
}
|
||||
|
|
|
@ -9,29 +9,27 @@
|
|||
*/
|
||||
package cc.iotkit.model.space;
|
||||
|
||||
import cc.iotkit.model.Owned;
|
||||
import cc.iotkit.model.Id;
|
||||
import cc.iotkit.model.TenantModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Space implements Owned<String> {
|
||||
public class Space extends TenantModel implements Id<Long>, Serializable {
|
||||
|
||||
private String id;
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 关联家庭id
|
||||
*/
|
||||
private String homeId;
|
||||
|
||||
/**
|
||||
* 关联用户id
|
||||
*/
|
||||
private String uid;
|
||||
private Long homeId;
|
||||
|
||||
/**
|
||||
* 空间名称
|
||||
|
@ -42,6 +40,4 @@ public class Space implements Owned<String> {
|
|||
* 设备数量
|
||||
*/
|
||||
private Integer deviceNum;
|
||||
|
||||
private Long createAt;
|
||||
}
|
||||
|
|
|
@ -9,29 +9,22 @@
|
|||
*/
|
||||
package cc.iotkit.model.space;
|
||||
|
||||
import cc.iotkit.model.Owned;
|
||||
import cc.iotkit.model.Id;
|
||||
import cc.iotkit.model.TenantModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SpaceDevice implements Owned<String> {
|
||||
public class SpaceDevice extends TenantModel implements Id<Long>, Serializable {
|
||||
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 关联用户id
|
||||
*/
|
||||
private String uid;
|
||||
|
||||
/**
|
||||
* 分享的用户id
|
||||
*/
|
||||
private String sharedUid;
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 空间中的设备id
|
||||
|
@ -46,22 +39,12 @@ public class SpaceDevice implements Owned<String> {
|
|||
/**
|
||||
* 所属家庭Id
|
||||
*/
|
||||
private String homeId;
|
||||
private Long homeId;
|
||||
|
||||
/**
|
||||
* 空间id
|
||||
*/
|
||||
private String spaceId;
|
||||
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
private Long addAt;
|
||||
|
||||
/**
|
||||
* 使用时间
|
||||
*/
|
||||
private Long useAt;
|
||||
private Long spaceId;
|
||||
|
||||
/**
|
||||
* 是否收藏
|
||||
|
|
|
@ -25,6 +25,11 @@ public class SysApp extends TenantModel implements Id<Long>, Serializable{
|
|||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 应用名称
|
||||
*/
|
||||
private String appName;
|
||||
|
||||
/**
|
||||
* appId
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package cc.iotkit.model.wx;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 小程序登录对象
|
||||
*
|
||||
* @author tfd
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class XcxLoginBody {
|
||||
|
||||
/**
|
||||
* appId
|
||||
*/
|
||||
@NotBlank(message = "appId不能为空")
|
||||
private String appId;
|
||||
|
||||
/**
|
||||
* 授权码
|
||||
*/
|
||||
@NotBlank(message = "code不能为空")
|
||||
private String code;
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package cc.iotkit.model.wx;
|
||||
|
||||
import cc.iotkit.common.model.LoginUser;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
/**
|
||||
* 小程序登录用户身份权限
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
public class XcxLoginUser extends LoginUser {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* openid
|
||||
*/
|
||||
private String openid;
|
||||
|
||||
}
|
|
@ -9,20 +9,18 @@
|
|||
*/
|
||||
package cc.iotkit.data.manager;
|
||||
|
||||
import cc.iotkit.data.IOwnedData;
|
||||
import cc.iotkit.data.ICommonData;
|
||||
import cc.iotkit.model.space.Home;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IHomeData extends IOwnedData<Home, String> {
|
||||
|
||||
default Home findByUidAndCurrent(String uid, boolean current) {
|
||||
return null;
|
||||
public interface IHomeData extends ICommonData<Home, Long> {
|
||||
|
||||
}
|
||||
Home findByUserIdAndCurrent(Long userId, boolean current);
|
||||
|
||||
default Home findByUidAndId(String uid, String id) {
|
||||
return null;
|
||||
List<Home> findByUserId(Long userId);
|
||||
|
||||
}
|
||||
boolean checkHomeNameUnique(Home home);
|
||||
|
||||
}
|
||||
|
|
|
@ -9,17 +9,13 @@
|
|||
*/
|
||||
package cc.iotkit.data.manager;
|
||||
|
||||
import cc.iotkit.data.IOwnedData;
|
||||
import cc.iotkit.data.ICommonData;
|
||||
import cc.iotkit.model.space.Space;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ISpaceData extends IOwnedData<Space,String> {
|
||||
public interface ISpaceData extends ICommonData<Space,Long> {
|
||||
|
||||
List<Space> findByUidOrderByCreateAtDesc(String uid);
|
||||
|
||||
List<Space> findByUidAndHomeIdOrderByCreateAtDesc(String uid, String homeId);
|
||||
|
||||
List<Space> findByHomeId(String homeId);
|
||||
List<Space> findByHomeId(Long homeId);
|
||||
|
||||
}
|
||||
|
|
|
@ -9,24 +9,20 @@
|
|||
*/
|
||||
package cc.iotkit.data.manager;
|
||||
|
||||
import cc.iotkit.data.IOwnedData;
|
||||
import cc.iotkit.data.ICommonData;
|
||||
import cc.iotkit.model.space.SpaceDevice;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ISpaceDeviceData extends IOwnedData<SpaceDevice, String> {
|
||||
public interface ISpaceDeviceData extends ICommonData<SpaceDevice, Long> {
|
||||
|
||||
List<SpaceDevice> findByUidOrderByUseAtDesc(String uid);
|
||||
List<SpaceDevice> findByHomeIdAndCollect(Long homeId,boolean collect);
|
||||
|
||||
List<SpaceDevice> findByHomeIdAndCollect(String homeId,boolean collect);
|
||||
List<SpaceDevice> findByHomeId(Long homeId);
|
||||
|
||||
List<SpaceDevice> findByUidOrderByAddAtDesc(String uid);
|
||||
|
||||
List<SpaceDevice> findBySpaceIdOrderByAddAtDesc(String spaceId);
|
||||
|
||||
List<SpaceDevice> findByUidAndSpaceIdOrderByAddAtDesc(String uid, String spaceId);
|
||||
List<SpaceDevice> findBySpaceId(Long spaceId);
|
||||
|
||||
SpaceDevice findByDeviceId(String deviceId);
|
||||
|
||||
SpaceDevice findByDeviceIdAndUid(String deviceId, String uid);
|
||||
void deleteAllBySpaceId(Long spaceId);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,4 @@ public interface IUserInfoData extends ICommonData<UserInfo, Long> {
|
|||
UserInfo findByUid(String uid);
|
||||
|
||||
List<UserInfo> findByType(int type);
|
||||
|
||||
List<UserInfo> findByTypeAndOwnerId(int type, String ownerId);
|
||||
}
|
||||
|
|
|
@ -11,5 +11,6 @@ import cc.iotkit.model.system.SysApp;
|
|||
*/
|
||||
public interface ISysAppData extends ICommonData<SysApp, Long> {
|
||||
|
||||
SysApp findByAppId(String appId);
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,6 @@ import cc.iotkit.model.system.SysTenant;
|
|||
*/
|
||||
public interface ISysTenantData extends ICommonData<SysTenant, Long> {
|
||||
|
||||
void updateTenant(SysTenant tenant);
|
||||
boolean checkCompanyNameUnique(SysTenant to);
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.springframework.stereotype.Component;
|
|||
public class SpaceCacheEvict {
|
||||
|
||||
@CacheEvict(value = Constants.CACHE_SPACE, key = "#root.method.name+#s")
|
||||
public void findById(String s) {
|
||||
public void findById(Long s) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package cc.iotkit.data.service;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.constant.Constants;
|
||||
import cc.iotkit.data.manager.ISpaceData;
|
||||
import cc.iotkit.data.cache.SpaceCacheEvict;
|
||||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.common.constant.Constants;
|
||||
import cc.iotkit.data.cache.SpaceCacheEvict;
|
||||
import cc.iotkit.data.manager.ISpaceData;
|
||||
import cc.iotkit.model.space.Space;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
|
@ -24,43 +24,18 @@ public class SpaceDataCache implements ISpaceData {
|
|||
private SpaceCacheEvict spaceCacheEvict;
|
||||
|
||||
@Override
|
||||
public List<Space> findByUidOrderByCreateAtDesc(String uid) {
|
||||
return spaceData.findByUidOrderByCreateAtDesc(uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Space> findByUidAndHomeIdOrderByCreateAtDesc(String uid, String homeId) {
|
||||
return spaceData.findByUidAndHomeIdOrderByCreateAtDesc(uid, homeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Space> findByHomeId(String homeId) {
|
||||
public List<Space> findByHomeId(Long homeId) {
|
||||
return spaceData.findByHomeId(homeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Space> findByUid(String uid) {
|
||||
return spaceData.findByUid(uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<Space> findByUid(String uid, int page, int size) {
|
||||
return spaceData.findByUid(uid, page, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countByUid(String uid) {
|
||||
return spaceData.countByUid(uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = Constants.CACHE_SPACE, key = "#root.method.name+#s", unless = "#result == null")
|
||||
public Space findById(String s) {
|
||||
public Space findById(Long s) {
|
||||
return spaceData.findById(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Space> findByIds(Collection<String> id) {
|
||||
public List<Space> findByIds(Collection<Long> id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -77,12 +52,12 @@ public class SpaceDataCache implements ISpaceData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deleteById(String s) {
|
||||
public void deleteById(Long s) {
|
||||
spaceData.deleteById(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByIds(Collection<String> strings) {
|
||||
public void deleteByIds(Collection<Long> strings) {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -34,11 +34,6 @@ public class UserInfoDataCache implements IUserInfoData {
|
|||
return userInfoData.findByType(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserInfo> findByTypeAndOwnerId(int type, String ownerId) {
|
||||
return userInfoData.findByTypeAndOwnerId(type, ownerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserInfo findById(Long s) {
|
||||
return userInfoData.findById(s);
|
||||
|
|
|
@ -58,11 +58,17 @@
|
|||
<artifactId>h2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>mysql</groupId>-->
|
||||
<!-- <artifactId>mysql-connector-java</artifactId>-->
|
||||
<!-- <version>8.0.32</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>mysql</groupId>-->
|
||||
<!-- <artifactId>mysql-connector-java</artifactId>-->
|
||||
<!-- <version>8.0.32</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.postgresql</groupId>-->
|
||||
<!-- <artifactId>postgresql</artifactId>-->
|
||||
<!-- <version>42.2.9</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
|
@ -85,8 +91,8 @@
|
|||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<groupId>com.github.biyanwen</groupId>
|
||||
<artifactId>jpa-comment-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
|
|
@ -16,19 +16,17 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public interface HomeRepository extends JpaRepository<TbHome, String> {
|
||||
public interface HomeRepository extends JpaRepository<TbHome, Long> {
|
||||
|
||||
TbHome findByUidAndCurrent(String uid, boolean current);
|
||||
TbHome findByUserIdAndCurrent(Long userId, boolean current);
|
||||
|
||||
TbHome findByUidAndId(String uid, String id);
|
||||
List<TbHome> findByUserId(Long userId);
|
||||
|
||||
List<TbHome> findByUid(String uid);
|
||||
Page<TbHome> findByUserId(Long userId, Pageable pageable);
|
||||
|
||||
Page<TbHome> findByUid(String uid, Pageable pageable);
|
||||
long countByUserId(Long userId);
|
||||
|
||||
long countByUid(String uid);
|
||||
|
||||
void deleteById(String s);
|
||||
void deleteById(Long s);
|
||||
|
||||
long count();
|
||||
|
||||
|
|
|
@ -10,29 +10,19 @@
|
|||
package cc.iotkit.data.dao;
|
||||
|
||||
import cc.iotkit.data.model.TbSpaceDevice;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SpaceDeviceRepository extends JpaRepository<TbSpaceDevice, String> {
|
||||
public interface SpaceDeviceRepository extends JpaRepository<TbSpaceDevice, Long> {
|
||||
|
||||
List<TbSpaceDevice> findByUid(String uid);
|
||||
|
||||
Page<TbSpaceDevice> findByUid(String uid, Pageable pageable);
|
||||
|
||||
List<TbSpaceDevice> findByUidOrderByUseAtDesc(String uid);
|
||||
|
||||
List<TbSpaceDevice> findByHomeIdAndCollect(String homeId,boolean collect);
|
||||
|
||||
List<TbSpaceDevice> findByUidOrderByAddAtDesc(String uid);
|
||||
|
||||
List<TbSpaceDevice> findBySpaceIdOrderByAddAtDesc(String spaceId);
|
||||
|
||||
List<TbSpaceDevice> findByUidAndSpaceIdOrderByAddAtDesc(String uid, String spaceId);
|
||||
List<TbSpaceDevice> findByHomeIdAndCollect(Long homeId,boolean collect);
|
||||
|
||||
TbSpaceDevice findByDeviceId(String deviceId);
|
||||
|
||||
TbSpaceDevice findByDeviceIdAndUid(String deviceId, String uid);
|
||||
List<TbSpaceDevice> findByHomeId(Long homeId);
|
||||
|
||||
List<TbSpaceDevice> findBySpaceId(Long spaceId);
|
||||
|
||||
void deleteAllBySpaceId(Long spaceId);
|
||||
}
|
||||
|
|
|
@ -10,22 +10,12 @@
|
|||
package cc.iotkit.data.dao;
|
||||
|
||||
import cc.iotkit.data.model.TbSpace;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SpaceRepository extends JpaRepository<TbSpace, String> {
|
||||
public interface SpaceRepository extends JpaRepository<TbSpace, Long> {
|
||||
|
||||
List<TbSpace> findByUidOrderByCreateAtDesc(String uid);
|
||||
|
||||
List<TbSpace> findByUidAndHomeIdOrderByCreateAtDesc(String uid, String homeId);
|
||||
|
||||
List<TbSpace> findByHomeId(String homeId);
|
||||
|
||||
List<TbSpace> findByUid(String uid);
|
||||
|
||||
Page<TbSpace> findByUid(String uid, Pageable pageable);
|
||||
List<TbSpace> findByHomeId(Long homeId);
|
||||
|
||||
}
|
||||
|
|
|
@ -11,5 +11,5 @@ import org.springframework.data.querydsl.QuerydslPredicateExecutor;
|
|||
* @date 2023-08-10
|
||||
*/
|
||||
public interface SysAppRepository extends JpaRepository<TbSysApp, Long>, QuerydslPredicateExecutor<TbSysApp> {
|
||||
|
||||
TbSysApp findByAppId(String appId);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,4 @@ public interface UserInfoRepository extends JpaRepository<TbUserInfo, String> {
|
|||
|
||||
List<TbUserInfo> findByType(int type);
|
||||
|
||||
List<TbUserInfo> findByTypeAndOwnerId(int type, String ownerId);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,29 +1,36 @@
|
|||
package cc.iotkit.data.model;
|
||||
|
||||
import cc.iotkit.common.tenant.dao.TenantAware;
|
||||
import cc.iotkit.common.tenant.listener.TenantListener;
|
||||
import cc.iotkit.model.space.Home;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.annotations.Filter;
|
||||
import org.hibernate.annotations.FilterDef;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.ParamDef;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.*;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@NoArgsConstructor
|
||||
@Table(name = "home")
|
||||
@ApiModel(value = "家庭信息")
|
||||
@AutoMapper(target = Home.class)
|
||||
public class TbHome {
|
||||
@FilterDef(name = "tenantFilter", parameters = {@ParamDef(name = "tenantId", type = "string")})
|
||||
@Filter(name = "tenantFilter", condition = "tenant_id = :tenantId")
|
||||
@EntityListeners(TenantListener.class)
|
||||
public class TbHome extends BaseEntity implements TenantAware {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(generator = "SnowflakeIdGenerator")
|
||||
@GenericGenerator(name = "SnowflakeIdGenerator", strategy = "cc.iotkit.data.config.id.SnowflakeIdGenerator")
|
||||
@ApiModelProperty(value = "家庭id")
|
||||
private String id;
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 家庭名称
|
||||
|
@ -41,7 +48,7 @@ public class TbHome {
|
|||
* 关联用户id
|
||||
*/
|
||||
@ApiModelProperty(value = "关联用户id")
|
||||
private String uid;
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 空间数量
|
||||
|
@ -61,4 +68,10 @@ public class TbHome {
|
|||
@ApiModelProperty(value = "是否为用户当前使用的家庭")
|
||||
private Boolean current;
|
||||
|
||||
/**
|
||||
* 租户编号
|
||||
*/
|
||||
@ApiModelProperty(value = "租户编号")
|
||||
private String tenantId;
|
||||
|
||||
}
|
||||
|
|
|
@ -9,42 +9,43 @@
|
|||
*/
|
||||
package cc.iotkit.data.model;
|
||||
|
||||
import cc.iotkit.common.tenant.dao.TenantAware;
|
||||
import cc.iotkit.common.tenant.listener.TenantListener;
|
||||
import cc.iotkit.model.space.Space;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.annotations.Filter;
|
||||
import org.hibernate.annotations.FilterDef;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.ParamDef;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.*;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@NoArgsConstructor
|
||||
@ApiModel(value = "空间")
|
||||
@Table(name = "space")
|
||||
@AutoMapper(target = Space.class)
|
||||
public class TbSpace {
|
||||
@FilterDef(name = "tenantFilter", parameters = {@ParamDef(name = "tenantId", type = "string")})
|
||||
@Filter(name = "tenantFilter", condition = "tenant_id = :tenantId")
|
||||
@EntityListeners(TenantListener.class)
|
||||
public class TbSpace extends BaseEntity implements TenantAware {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(generator = "SnowflakeIdGenerator")
|
||||
@GenericGenerator(name = "SnowflakeIdGenerator", strategy = "cc.iotkit.data.config.id.SnowflakeIdGenerator")
|
||||
@ApiModelProperty(value = "空间id")
|
||||
private String id;
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 关联家庭id
|
||||
*/
|
||||
@ApiModelProperty(value = "关联家庭id")
|
||||
private String homeId;
|
||||
|
||||
/**
|
||||
* 关联用户id
|
||||
*/
|
||||
@ApiModelProperty(value = "关联用户id")
|
||||
private String uid;
|
||||
private Long homeId;
|
||||
|
||||
/**
|
||||
* 空间名称
|
||||
|
@ -58,7 +59,10 @@ public class TbSpace {
|
|||
@ApiModelProperty(value = "设备数量")
|
||||
private Integer deviceNum;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Long createAt;
|
||||
/**
|
||||
* 租户编号
|
||||
*/
|
||||
@ApiModelProperty(value = "租户编号")
|
||||
private String tenantId;
|
||||
|
||||
}
|
||||
|
|
|
@ -9,41 +9,34 @@
|
|||
*/
|
||||
package cc.iotkit.data.model;
|
||||
|
||||
import cc.iotkit.common.tenant.dao.TenantAware;
|
||||
import cc.iotkit.common.tenant.listener.TenantListener;
|
||||
import cc.iotkit.model.space.SpaceDevice;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Filter;
|
||||
import org.hibernate.annotations.FilterDef;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.ParamDef;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.*;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "space_device")
|
||||
@ApiModel(value = "空间设备")
|
||||
@AutoMapper(target = SpaceDevice.class)
|
||||
public class TbSpaceDevice {
|
||||
@FilterDef(name = "tenantFilter", parameters = {@ParamDef(name = "tenantId", type = "string")})
|
||||
@Filter(name = "tenantFilter", condition = "tenant_id = :tenantId")
|
||||
@EntityListeners(TenantListener.class)
|
||||
public class TbSpaceDevice extends BaseEntity implements TenantAware {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(generator = "SnowflakeIdGenerator")
|
||||
@GenericGenerator(name = "SnowflakeIdGenerator", strategy = "cc.iotkit.data.config.id.SnowflakeIdGenerator")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 关联用户id
|
||||
*/
|
||||
@ApiModelProperty(value = "关联用户id")
|
||||
private String uid;
|
||||
|
||||
/**
|
||||
* 分享的用户id
|
||||
*/
|
||||
@ApiModelProperty(value = "分享的用户id")
|
||||
private String sharedUid;
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 空间中的设备id
|
||||
|
@ -61,25 +54,13 @@ public class TbSpaceDevice {
|
|||
* 所属家庭Id
|
||||
*/
|
||||
@ApiModelProperty(value = "所属家庭Id")
|
||||
private String homeId;
|
||||
private Long homeId;
|
||||
|
||||
/**
|
||||
* 空间id
|
||||
*/
|
||||
@ApiModelProperty(value = "空间id")
|
||||
private String spaceId;
|
||||
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private Long addAt;
|
||||
|
||||
/**
|
||||
* 使用时间
|
||||
*/
|
||||
@ApiModelProperty(value = "使用时间")
|
||||
private Long useAt;
|
||||
private Long spaceId;
|
||||
|
||||
/**
|
||||
* 是否收藏
|
||||
|
@ -87,4 +68,10 @@ public class TbSpaceDevice {
|
|||
@ApiModelProperty(value = "是否收藏")
|
||||
private Boolean collect;
|
||||
|
||||
/**
|
||||
* 租户编号
|
||||
*/
|
||||
@ApiModelProperty(value = "租户编号")
|
||||
private String tenantId;
|
||||
|
||||
}
|
||||
|
|
|
@ -2,13 +2,13 @@ package cc.iotkit.data.model;
|
|||
|
||||
import cc.iotkit.common.tenant.dao.TenantAware;
|
||||
import cc.iotkit.common.tenant.listener.TenantListener;
|
||||
import cc.iotkit.model.TenantModel;
|
||||
import cc.iotkit.model.system.SysApp;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.annotations.Filter;
|
||||
import org.hibernate.annotations.FilterDef;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
|
@ -25,15 +25,14 @@ import javax.persistence.*;
|
|||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Entity
|
||||
@NoArgsConstructor
|
||||
@Table(name = "SYS_APP")
|
||||
@AutoMapper(target = SysApp.class)
|
||||
@ApiModel(value = "应用信息表")
|
||||
@FilterDef(name = "tenantFilter", parameters = {@ParamDef(name = "tenantId", type = "string")})
|
||||
@Filter(name = "tenantFilter", condition = "tenant_id = :tenantId")
|
||||
@EntityListeners(TenantListener.class)
|
||||
public class TbSysApp extends TenantModel implements TenantAware {
|
||||
|
||||
|
||||
public class TbSysApp extends BaseEntity implements TenantAware {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
|
@ -44,6 +43,18 @@ public class TbSysApp extends TenantModel implements TenantAware {
|
|||
@ApiModelProperty(value = "主键id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 租户编号
|
||||
*/
|
||||
@ApiModelProperty(value = "租户编号")
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 应用名称
|
||||
*/
|
||||
@ApiModelProperty(value = "应用名称")
|
||||
private String appName;
|
||||
|
||||
/**
|
||||
* appId
|
||||
*/
|
||||
|
@ -57,7 +68,7 @@ public class TbSysApp extends TenantModel implements TenantAware {
|
|||
private String appSecret;
|
||||
|
||||
/**
|
||||
* 应用类型
|
||||
* 应用类型,0:app,1:小程序
|
||||
*/
|
||||
@ApiModelProperty(value = "应用类型")
|
||||
private String appType;
|
||||
|
@ -66,7 +77,7 @@ public class TbSysApp extends TenantModel implements TenantAware {
|
|||
* 备注
|
||||
*/
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String REMARK;
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ public class TbSysTenant extends BaseEntity implements TenantAware {
|
|||
* 租户状态(0正常 1停用)
|
||||
*/
|
||||
@ApiModelProperty(value = "租户状态(0正常 1停用)")
|
||||
private String status;
|
||||
private String status=UserConstants.DICT_ABNORMAL;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表存在 2代表删除)
|
||||
|
|
|
@ -8,10 +8,7 @@ import lombok.Data;
|
|||
import lombok.EqualsAndHashCode;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* 租户套餐对象 sys_tenant_package
|
||||
|
@ -42,6 +39,7 @@ public class TbSysTenantPackage extends BaseEntity {
|
|||
/**
|
||||
* 关联菜单id
|
||||
*/
|
||||
@Column(columnDefinition = "text")
|
||||
@ApiModelProperty(value = "关联菜单id")
|
||||
private String menuIds;
|
||||
/**
|
||||
|
|
|
@ -1,23 +1,34 @@
|
|||
package cc.iotkit.data.model;
|
||||
|
||||
import cc.iotkit.common.tenant.dao.TenantAware;
|
||||
import cc.iotkit.common.tenant.listener.TenantListener;
|
||||
import cc.iotkit.model.UserInfo;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import io.github.linpeilie.annotations.AutoMapping;
|
||||
import io.github.linpeilie.annotations.ReverseAutoMapping;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.annotations.Filter;
|
||||
import org.hibernate.annotations.FilterDef;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.ParamDef;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.*;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Entity
|
||||
@NoArgsConstructor
|
||||
@Table(name = "user_info")
|
||||
@AutoMapper(target = UserInfo.class)
|
||||
public class TbUserInfo {
|
||||
@ApiModel(value = "用户信息表")
|
||||
@FilterDef(name = "tenantFilter", parameters = {@ParamDef(name = "tenantId", type = "string")})
|
||||
@Filter(name = "tenantFilter", condition = "tenant_id = :tenantId")
|
||||
@EntityListeners(TenantListener.class)
|
||||
public class TbUserInfo extends BaseEntity implements TenantAware {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(generator = "SnowflakeIdGenerator")
|
||||
|
@ -31,10 +42,10 @@ public class TbUserInfo {
|
|||
private String uid;
|
||||
|
||||
/**
|
||||
* 归属账号
|
||||
* 租户编号
|
||||
*/
|
||||
@ApiModelProperty(value = "归属账号")
|
||||
private String ownerId;
|
||||
@ApiModelProperty(value = "租户编号")
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 密钥(密码加密后的内容)
|
||||
|
@ -106,7 +117,4 @@ public class TbUserInfo {
|
|||
@AutoMapping(ignore = true)
|
||||
private String usePlatforms;
|
||||
|
||||
@ApiModelProperty(value="创建时间")
|
||||
private Long createAt;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,27 +1,34 @@
|
|||
package cc.iotkit.data.service;
|
||||
|
||||
import cc.iotkit.common.satoken.utils.LoginHelper;
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.data.dao.HomeRepository;
|
||||
import cc.iotkit.data.dao.IJPACommData;
|
||||
import cc.iotkit.data.manager.IHomeData;
|
||||
import cc.iotkit.data.model.TbHome;
|
||||
import cc.iotkit.data.util.PredicateBuilder;
|
||||
import cc.iotkit.model.space.Home;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cc.iotkit.data.model.QTbHome.tbHome;
|
||||
|
||||
@Primary
|
||||
@Service
|
||||
public class HomeDataImpl implements IHomeData, IJPACommData<Home, String> {
|
||||
@RequiredArgsConstructor
|
||||
public class HomeDataImpl implements IHomeData, IJPACommData<Home, Long> {
|
||||
|
||||
@Autowired
|
||||
private HomeRepository homeRepository;
|
||||
|
||||
private final JPAQueryFactory jpaQueryFactory;
|
||||
|
||||
@Override
|
||||
public JpaRepository getBaseRepository() {
|
||||
|
@ -39,42 +46,24 @@ public class HomeDataImpl implements IHomeData, IJPACommData<Home, String> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Home findByUidAndCurrent(String uid, boolean current) {
|
||||
return MapstructUtils.convert(homeRepository.findByUidAndCurrent(uid, current), Home.class);
|
||||
public Home findByUserIdAndCurrent(Long userId, boolean current) {
|
||||
return MapstructUtils.convert(homeRepository.findByUserIdAndCurrent(userId, current), Home.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Home findByUidAndId(String uid, String id) {
|
||||
return MapstructUtils.convert(homeRepository.findByUidAndId(uid, id), Home.class);
|
||||
public List<Home> findByUserId(Long userId) {
|
||||
return MapstructUtils.convert(homeRepository.findByUserId(userId), Home.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Home> findByUid(String uid) {
|
||||
return MapstructUtils.convert(homeRepository.findByUid(uid), Home.class);
|
||||
public boolean checkHomeNameUnique(Home home) {
|
||||
final TbHome ret = jpaQueryFactory.select(tbHome).from(tbHome)
|
||||
.where(PredicateBuilder.instance()
|
||||
.and(tbHome.name.eq(home.getName()))
|
||||
.and(tbHome.userId.eq(LoginHelper.getUserId()))
|
||||
.build()).fetchOne();
|
||||
return Objects.isNull(ret);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long countByUid(String uid) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Home findById(String s) {
|
||||
return MapstructUtils.convert(homeRepository.findById(s).orElse(null), Home.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Home save(Home data) {
|
||||
if (StringUtils.isBlank(data.getId())) {
|
||||
data.setId(UUID.randomUUID().toString());
|
||||
}
|
||||
homeRepository.save(MapstructUtils.convert(data, TbHome.class));
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,26 +1,21 @@
|
|||
package cc.iotkit.data.service;
|
||||
|
||||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.data.dao.IJPACommData;
|
||||
import cc.iotkit.data.dao.SpaceRepository;
|
||||
import cc.iotkit.data.manager.ISpaceData;
|
||||
import cc.iotkit.data.model.TbSpace;
|
||||
import cc.iotkit.model.space.Space;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Primary
|
||||
@Service
|
||||
public class SpaceDataImpl implements ISpaceData, IJPACommData<Space, String> {
|
||||
public class SpaceDataImpl implements ISpaceData, IJPACommData<Space, Long> {
|
||||
|
||||
@Autowired
|
||||
private SpaceRepository spaceRepository;
|
||||
|
@ -42,55 +37,7 @@ public class SpaceDataImpl implements ISpaceData, IJPACommData<Space, String> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Space> findByUidOrderByCreateAtDesc(String uid) {
|
||||
return MapstructUtils.convert(spaceRepository.findByUidOrderByCreateAtDesc(uid), Space.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Space> findByUidAndHomeIdOrderByCreateAtDesc(String uid, String homeId) {
|
||||
return MapstructUtils.convert(spaceRepository.findByUidAndHomeIdOrderByCreateAtDesc(uid, homeId), Space.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Space> findByHomeId(String homeId) {
|
||||
public List<Space> findByHomeId(Long homeId) {
|
||||
return MapstructUtils.convert(spaceRepository.findByHomeId(homeId), Space.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Space> findByUid(String uid) {
|
||||
return MapstructUtils.convert(spaceRepository.findByUid(uid), Space.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<Space> findByUid(String uid, int page, int size) {
|
||||
Page<TbSpace> paged = spaceRepository.findByUid(uid,
|
||||
Pageable.ofSize(size).withPage(page - 1));
|
||||
return new Paging<>(paged.getTotalElements(),
|
||||
MapstructUtils.convert(paged.getContent(), Space.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countByUid(String uid) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Space findById(String s) {
|
||||
return MapstructUtils.convert(spaceRepository.findById(s).orElse(null), Space.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Space save(Space data) {
|
||||
if (StringUtils.isBlank(data.getId())) {
|
||||
data.setId(UUID.randomUUID().toString());
|
||||
}
|
||||
spaceRepository.save(MapstructUtils.convert(data, TbSpace.class));
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -9,25 +9,22 @@
|
|||
*/
|
||||
package cc.iotkit.data.service;
|
||||
|
||||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.data.dao.IJPACommData;
|
||||
import cc.iotkit.data.dao.SpaceDeviceRepository;
|
||||
import cc.iotkit.data.manager.ISpaceDeviceData;
|
||||
import cc.iotkit.data.model.TbSpaceDevice;
|
||||
import cc.iotkit.model.space.SpaceDevice;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Primary
|
||||
@Service
|
||||
public class SpaceDeviceDataImpl implements ISpaceDeviceData, IJPACommData<SpaceDevice, String> {
|
||||
public class SpaceDeviceDataImpl implements ISpaceDeviceData, IJPACommData<SpaceDevice, Long> {
|
||||
|
||||
@Autowired
|
||||
private SpaceDeviceRepository spaceDeviceRepository;
|
||||
|
@ -48,29 +45,20 @@ public class SpaceDeviceDataImpl implements ISpaceDeviceData, IJPACommData<Space
|
|||
return SpaceDevice.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SpaceDevice> findByUidOrderByUseAtDesc(String uid) {
|
||||
return MapstructUtils.convert(spaceDeviceRepository.findByUidOrderByUseAtDesc(uid), SpaceDevice.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SpaceDevice> findByHomeIdAndCollect(String homeId, boolean collect) {
|
||||
public List<SpaceDevice> findByHomeIdAndCollect(Long homeId, boolean collect) {
|
||||
return MapstructUtils.convert(spaceDeviceRepository.findByHomeIdAndCollect(homeId, collect), SpaceDevice.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SpaceDevice> findByUidOrderByAddAtDesc(String uid) {
|
||||
return MapstructUtils.convert(spaceDeviceRepository.findByUidOrderByAddAtDesc(uid), SpaceDevice.class);
|
||||
public List<SpaceDevice> findByHomeId(Long homeId) {
|
||||
return MapstructUtils.convert(spaceDeviceRepository.findByHomeId(homeId), SpaceDevice.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SpaceDevice> findBySpaceIdOrderByAddAtDesc(String spaceId) {
|
||||
return MapstructUtils.convert(spaceDeviceRepository.findBySpaceIdOrderByAddAtDesc(spaceId), SpaceDevice.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SpaceDevice> findByUidAndSpaceIdOrderByAddAtDesc(String uid, String spaceId) {
|
||||
return MapstructUtils.convert(spaceDeviceRepository.findByUidAndSpaceIdOrderByAddAtDesc(uid, spaceId), SpaceDevice.class);
|
||||
public List<SpaceDevice> findBySpaceId(Long spaceId) {
|
||||
return MapstructUtils.convert(spaceDeviceRepository.findBySpaceId(spaceId), SpaceDevice.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -79,51 +67,8 @@ public class SpaceDeviceDataImpl implements ISpaceDeviceData, IJPACommData<Space
|
|||
}
|
||||
|
||||
@Override
|
||||
public SpaceDevice findByDeviceIdAndUid(String deviceId, String uid) {
|
||||
return MapstructUtils.convert(spaceDeviceRepository.findByDeviceIdAndUid(deviceId, uid), SpaceDevice.class);
|
||||
public void deleteAllBySpaceId(Long spaceId) {
|
||||
spaceDeviceRepository.deleteAllBySpaceId(spaceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SpaceDevice> findByUid(String uid) {
|
||||
return MapstructUtils.convert(spaceDeviceRepository.findByUid(uid), SpaceDevice.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<SpaceDevice> findByUid(String uid, int page, int size) {
|
||||
return new Paging<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countByUid(String uid) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public SpaceDevice findById(String s) {
|
||||
return MapstructUtils.convert(spaceDeviceRepository.findById(s).orElse(null), SpaceDevice.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public SpaceDevice save(SpaceDevice data) {
|
||||
if (StringUtils.isBlank(data.getId())) {
|
||||
data.setId(UUID.randomUUID().toString());
|
||||
data.setAddAt(System.currentTimeMillis());
|
||||
}
|
||||
spaceDeviceRepository.save(MapstructUtils.convert(data, TbSpaceDevice.class));
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<SpaceDevice> findAll() {
|
||||
return MapstructUtils.convert(spaceDeviceRepository.findAll(), SpaceDevice.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package cc.iotkit.data.service;
|
||||
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.data.dao.IJPACommData;
|
||||
import cc.iotkit.data.dao.SysAppRepository;
|
||||
import cc.iotkit.data.model.TbSysApp;
|
||||
import cc.iotkit.data.system.ISysAppData;
|
||||
import cc.iotkit.model.system.SysApp;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
|
@ -59,4 +61,14 @@ public class SysAppDataImpl implements ISysAppData, IJPACommData<SysApp, Long> {
|
|||
public Class getTClass() {
|
||||
return SysApp.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysApp findByAppId(String appId) {
|
||||
TbSysApp ret=baseRepository.findByAppId(appId);
|
||||
if(ObjectUtil.isNotNull(ret)){
|
||||
return MapstructUtils.convert(ret,SysApp.class);
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,6 +96,7 @@ public class SysConfigDataImpl implements ISysConfigData, IJPACommData<SysConfig
|
|||
public List<SysConfig> findAllByCondition(SysConfig data) {
|
||||
Predicate predicate = PredicateBuilder.instance()
|
||||
.and(StringUtils.isNotEmpty(data.getConfigKey()), () -> tbSysConfig.configKey.eq(data.getConfigKey()))
|
||||
.and(StringUtils.isNotEmpty(data.getTenantId()), () -> tbSysConfig.tenantId.eq(data.getTenantId()))
|
||||
.build();
|
||||
Iterator<TbSysConfig> iterator = baseRepository.findAll(predicate).iterator();
|
||||
return MapstructUtils.convert(IteratorUtils.toList(iterator), SysConfig.class);
|
||||
|
|
|
@ -94,6 +94,7 @@ public class SysDictDataImpl implements ISysDictData, IJPACommData<SysDictData,
|
|||
.and(dictData.getDictSort() != null, () -> tbSysDictData.dictSort.eq(dictData.getDictSort()))
|
||||
.and(StringUtils.isNotEmpty(dictData.getDictLabel()), () -> tbSysDictData.dictLabel.like(dictData.getDictLabel()))
|
||||
.and(StringUtils.isNotEmpty(dictData.getDictType()), () -> tbSysDictData.dictType.eq(dictData.getDictType()))
|
||||
.and(StringUtils.isNotEmpty(dictData.getStatus()), () -> tbSysDictData.status.eq(dictData.getStatus())).build();
|
||||
.and(StringUtils.isNotEmpty(dictData.getStatus()), () -> tbSysDictData.status.eq(dictData.getStatus()))
|
||||
.and(StringUtils.isNotEmpty(dictData.getTenantId()), () -> tbSysDictData.tenantId.eq(dictData.getTenantId())).build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,8 @@ public class SysDictTypeDataImpl implements ISysDictTypeData, IJPACommData<SysDi
|
|||
return PredicateBuilder.instance()
|
||||
.and(StringUtils.isNotEmpty(dictType.getDictName()), () -> tbSysDictType.dictName.like(dictType.getDictName()))
|
||||
.and(StringUtils.isNotEmpty(dictType.getDictType()), () -> tbSysDictType.dictType.like(dictType.getDictType()))
|
||||
.and(StringUtils.isNotEmpty(dictType.getStatus()), () -> tbSysDictType.status.eq(dictType.getStatus())).build();
|
||||
.and(StringUtils.isNotEmpty(dictType.getStatus()), () -> tbSysDictType.status.eq(dictType.getStatus()))
|
||||
.and(StringUtils.isNotEmpty(dictType.getTenantId()), () -> tbSysDictType.tenantId.eq(dictType.getTenantId())).build();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -182,6 +182,7 @@ public class SysRoleDataImpl implements ISysRoleData, IJPACommData<SysRole, Long
|
|||
.and(StringUtils.isNotBlank(role.getRoleName()), () -> tbSysRole.roleName.like(role.getRoleName()))
|
||||
.and(StringUtils.isNotBlank(role.getStatus()), () -> tbSysRole.roleName.eq(role.getStatus()))
|
||||
.and(StringUtils.isNotBlank(role.getRoleKey()), () -> tbSysRole.roleKey.like(role.getRoleKey()))
|
||||
.and(StringUtils.isNotBlank(role.getTenantId()), () -> tbSysRole.tenantId.eq(role.getTenantId()))
|
||||
.build();
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cc.iotkit.data.model.QTbSysTenant.tbSysTenant;
|
||||
|
||||
|
@ -47,12 +47,6 @@ public class SysTenantDataImpl implements ISysTenantData, IJPACommData<SysTenant
|
|||
return SysTenant.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysTenant findById(Long aLong) {
|
||||
Optional<TbSysTenant> tenantOptional = sysTenantRepository.findById(aLong);
|
||||
return tenantOptional.map(sysTenant -> MapstructUtils.convert(sysTenant, SysTenant.class)).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<SysTenant> findAllByCondition(SysTenant data) {
|
||||
|
@ -74,9 +68,12 @@ public class SysTenantDataImpl implements ISysTenantData, IJPACommData<SysTenant
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateTenant(SysTenant tenant) {
|
||||
TbSysTenant tbSysTenant = MapstructUtils.convert(tenant, TbSysTenant.class);
|
||||
assert tbSysTenant != null;
|
||||
sysTenantRepository.save(tbSysTenant);
|
||||
public boolean checkCompanyNameUnique(SysTenant tenant) {
|
||||
final TbSysTenant ret = jpaQueryFactory.select(tbSysTenant).from(tbSysTenant)
|
||||
.where(PredicateBuilder.instance()
|
||||
.and(tbSysTenant.companyName.eq(tenant.getCompanyName()))
|
||||
.and(Objects.nonNull(tenant.getId()), () -> tbSysTenant.id.ne(tenant.getId()))
|
||||
.build()).fetchOne();
|
||||
return Objects.isNull(ret);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package cc.iotkit.data.service;
|
||||
|
||||
import cc.iotkit.data.dao.IJPACommData;
|
||||
import cc.iotkit.data.dao.SysOssRepository;
|
||||
import cc.iotkit.data.dao.SysTenantPackageRepository;
|
||||
import cc.iotkit.data.model.TbSysTenantPackage;
|
||||
import cc.iotkit.data.system.ISysTenantPackageData;
|
||||
import cc.iotkit.model.system.SysTenantPackage;
|
||||
|
@ -22,7 +22,7 @@ import org.springframework.stereotype.Service;
|
|||
public class SysTenantPackageDataImpl implements ISysTenantPackageData, IJPACommData<SysTenantPackage, Long> {
|
||||
|
||||
@Autowired
|
||||
private SysOssRepository baseRepository;
|
||||
private SysTenantPackageRepository baseRepository;
|
||||
|
||||
private final JPAQueryFactory jpaQueryFactory;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package cc.iotkit.data.service;
|
|||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.common.constant.UserConstants;
|
||||
import cc.iotkit.common.tenant.helper.TenantHelper;
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.common.utils.StreamUtils;
|
||||
import cc.iotkit.common.utils.StringUtils;
|
||||
|
@ -172,9 +173,25 @@ public class SysUserDataImpl implements ISysUserData, IJPACommData<SysUser, Long
|
|||
TbSysUser ret = jpaQueryFactory.select(tbSysUser).from(tbSysUser)
|
||||
.where(PredicateBuilder.instance()
|
||||
.and(tbSysUser.userName.eq(username))
|
||||
.and(tbSysUser.tenantId.eq(tenantId))
|
||||
.and(TenantHelper.isEnable(),() -> tbSysUser.tenantId.eq(tenantId))
|
||||
.build()).fetchOne();
|
||||
return MapstructUtils.convert(ret, SysUser.class);
|
||||
if(Objects.nonNull(ret)){
|
||||
SysUser convert = MapstructUtils.convert(ret, SysUser.class);
|
||||
Long deptId = ret.getDeptId();
|
||||
if (Objects.nonNull(deptId)) {
|
||||
// 获取部门信息
|
||||
SysDept sysDept = sysDeptData.findById(deptId);
|
||||
convert.setDept(sysDept);
|
||||
// 获取角色信息
|
||||
List<SysRole> sysRoles = sysRoleData.findByUserId(ret.getId());
|
||||
|
||||
convert.setRoles(sysRoles);
|
||||
}
|
||||
return MapstructUtils.convert(ret, SysUser.class);
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -41,11 +41,6 @@ public class UserInfoDataImpl implements IUserInfoData, IJPACommData<UserInfo, L
|
|||
return MapstructUtils.convert(userInfoRepository.findByType(type), UserInfo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserInfo> findByTypeAndOwnerId(int type, String ownerId) {
|
||||
return MapstructUtils.convert(userInfoRepository.findByTypeAndOwnerId(type, ownerId), UserInfo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JpaRepository getBaseRepository() {
|
||||
return userInfoRepository;
|
||||
|
|
|
@ -54,7 +54,7 @@ public class PageBuilder {
|
|||
Map<String,String> sortMap = pageRequest.getSortMap();
|
||||
if (CollUtil.isNotEmpty(sortMap)){
|
||||
sortMap.forEach((k,v) -> {
|
||||
orders.add(new Order(Direction.ASC, k));
|
||||
orders.add(new Order(Direction.fromString("desc"), k));
|
||||
});
|
||||
}
|
||||
return orders;
|
||||
|
|
|
@ -13,6 +13,11 @@
|
|||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<artifactId>iot-common-thing</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<artifactId>iot-data-model</artifactId>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
package cc.iotkit.temporal;
|
||||
|
||||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.model.device.message.ThingModelMessage;
|
||||
import cc.iotkit.common.thing.ThingModelMessage;
|
||||
import cc.iotkit.model.stats.TimeData;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -8,9 +8,10 @@
|
|||
<version>0.5.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>0.5.0-SNAPSHOT</version>
|
||||
|
||||
<artifactId>iot-temporal-serviceImpl-es</artifactId>
|
||||
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
|
@ -58,21 +59,21 @@
|
|||
<source>${java.version}</source> <!-- depending on your project -->
|
||||
<target>${java.version}</target> <!-- depending on your project -->
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>io.github.linpeilie</groupId>
|
||||
<artifactId>mapstruct-plus-processor</artifactId>
|
||||
<version>${mapstruct-plus.version}</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-mapstruct-binding</artifactId>
|
||||
<version>0.2.0</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>io.github.linpeilie</groupId>
|
||||
<artifactId>mapstruct-plus-processor</artifactId>
|
||||
<version>${mapstruct-plus.version}</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-mapstruct-binding</artifactId>
|
||||
<version>0.2.0</version>
|
||||
</path>
|
||||
<!-- other annotation processors -->
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
*/
|
||||
package cc.iotkit.temporal.es.document;
|
||||
|
||||
import cc.iotkit.model.device.message.ThingModelMessage;
|
||||
import cc.iotkit.common.thing.ThingModelMessage;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
|
|
|
@ -21,7 +21,6 @@ import org.elasticsearch.search.sort.FieldSortBuilder;
|
|||
import org.elasticsearch.search.sort.SortOrder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
|
||||
import org.springframework.data.elasticsearch.core.SearchHits;
|
||||
import org.springframework.data.elasticsearch.core.document.Document;
|
||||
|
@ -56,7 +55,6 @@ public class DevicePropertyDataImpl implements IDevicePropertyData {
|
|||
.from(start, true).to(end, true))
|
||||
)
|
||||
.withSorts(new FieldSortBuilder("time").order(SortOrder.ASC))
|
||||
.withPageable(Pageable.ofSize(size))
|
||||
.build();
|
||||
SearchHits<DocDeviceProperty> result = template.search(query, DocDeviceProperty.class, IndexCoordinates.of(index));
|
||||
return result.getSearchHits().stream()
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
package cc.iotkit.temporal.es.service;
|
||||
|
||||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.common.thing.ThingModelMessage;
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.model.device.message.ThingModelMessage;
|
||||
import cc.iotkit.model.stats.TimeData;
|
||||
import cc.iotkit.temporal.IThingModelMessageData;
|
||||
import cc.iotkit.temporal.es.dao.ThingModelMessageRepository;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>0.5.0-SNAPSHOT</version>
|
||||
<artifactId>iot-temproal-serviceImpl-td</artifactId>
|
||||
<artifactId>iot-temporal-serviceImpl-td</artifactId>
|
||||
|
||||
<description>
|
||||
时序数据库服务接口的TDengine实现
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue