Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
qingdaoMuseumPlatform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
node_server
qingdaoMuseumPlatform
Commits
3c2bef4f
Commit
3c2bef4f
authored
Jun 26, 2026
by
PC-20251223ZVQQ\Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
通过环境监测控制空调并存日志
parent
37602267
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
6 deletions
+67
-6
dataIntegration.ts
src/biz/dataIntegration.ts
+12
-4
mqttClient.ts
src/biz/mqttClient.ts
+5
-1
running.ts
src/biz/running.ts
+0
-0
dbEnum.ts
src/config/dbEnum.ts
+2
-1
mysqlTableConfig.ts
src/config/mysqlTableConfig.ts
+48
-0
No files found.
src/biz/dataIntegration.ts
View file @
3c2bef4f
...
...
@@ -390,6 +390,9 @@ async function integrateAcDevices() {
continue
;
}
let
deviceType
=
'空调'
;
let
deviceName
=
'空调内机'
;
// 查找对应的 region_key
let
regionKey
=
0
;
if
(
item
.
roomId
)
{
...
...
@@ -398,6 +401,11 @@ async function integrateAcDevices() {
const
region
=
await
regionModel
.
findOne
({
where
:
{
room_id
:
item
.
roomId
}
});
if
(
region
)
{
regionKey
=
region
.
id
;
// 如果区域地址包含新风,则空调视为新风机
if
(
region
.
name
&&
region
.
name
.
includes
(
'新风'
))
{
deviceType
=
'新风'
;
deviceName
=
'新风机'
;
}
}
}
}
...
...
@@ -407,8 +415,8 @@ async function integrateAcDevices() {
device_id
:
deviceId
,
device_ad
:
item
.
indoorUnitId
||
''
,
region_key
:
regionKey
,
device_type
:
'空调'
,
device_name
:
`
空调内机
-
${
deviceId
}
`
,
device_type
:
deviceType
,
device_name
:
`
${
deviceName
}
-
${
deviceId
}
`
,
control_params
:
AC_CONTROL_PARAMS
,
});
insertCount
++
;
...
...
@@ -715,14 +723,14 @@ async function integrateMeterDeviceData() {
* 数据集成-九合一环境设备数据集成
*/
export
async
function
airDeviceData
()
{
//
TODO: 暂无对应接口
//
暂无对应接口 -> MQTT
}
/**
* 数据集成-客流监测设备数据集成
*/
export
async
function
customerDeviceData
()
{
//
TODO: 暂无对应接口
//
暂无对应接口 -> MQTT
}
/**
...
...
src/biz/mqttClient.ts
View file @
3c2bef4f
import
{
TABLENAME
}
from
"../config/dbEnum"
;
import
{
addData
}
from
"../data/addData"
;
import
{
selectOneDataByParam
}
from
"../data/findData"
;
import
{
controlAcByEnvironment
}
from
"./running"
;
/**
* 处理接收到的
单条
设备数据,并存入数据库
* 处理接收到的
环境
设备数据,并存入数据库
*
* 消息示例:
* {
...
...
@@ -87,6 +88,9 @@ export async function processDeviceData(message) {
);
console
.
log
(
`数据入库成功: 设备
${
devEUI
}
`
);
// 调用空调控制
await
controlAcByEnvironment
(
devEUI
,
data
);
}
catch
(
error
)
{
console
.
error
(
'数据处理失败:'
,
error
);
...
...
src/biz/running.ts
View file @
3c2bef4f
This diff is collapsed.
Click to expand it.
src/config/dbEnum.ts
View file @
3c2bef4f
...
...
@@ -7,7 +7,8 @@ export enum TABLENAME {
设备数据表
=
'device_data'
,
区域表
=
'region'
,
设备故障表
=
'device_fault'
,
用户信息表
=
'user_info'
用户信息表
=
'user_info'
,
设备日志表
=
'device_logs'
};
/**
...
...
src/config/mysqlTableConfig.ts
View file @
3c2bef4f
...
...
@@ -278,5 +278,53 @@ export const TablesConfig = [
{
type
:
"hasMany"
,
target
:
"device"
,
foreignKey
:
"region_key"
}
]
},
// 设备日志表
{
tableNameCn
:
'设备日志表'
,
tableName
:
'device_logs'
,
schema
:
{
id
:
{
type
:
DataTypes
.
BIGINT
,
allowNull
:
false
,
primaryKey
:
true
,
autoIncrement
:
true
,
comment
:
'自增主键'
},
device_id
:
{
type
:
DataTypes
.
STRING
(
50
),
allowNull
:
false
,
comment
:
'设备标识'
},
device_type
:
{
type
:
DataTypes
.
STRING
(
50
),
allowNull
:
false
,
comment
:
'设备类型,如“空调”“出风口”'
},
operation_content
:
{
type
:
DataTypes
.
JSON
,
allowNull
:
true
,
comment
:
'操作内容{"option":"on","time":"2026-06-26 12:00:00"}'
},
status
:
{
type
:
DataTypes
.
INTEGER
,
allowNull
:
false
,
comment
:
'操作状态,0否1是'
},
created_at
:
{
type
:
DataTypes
.
DATE
,
allowNull
:
false
,
defaultValue
:
DataTypes
.
NOW
,
comment
:
'创建时间'
},
updated_at
:
{
type
:
DataTypes
.
DATE
,
allowNull
:
false
,
defaultValue
:
DataTypes
.
NOW
,
comment
:
'更新时间'
}
},
association
:
[
]
},
];
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment