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
18e87f61
Commit
18e87f61
authored
Jul 06, 2026
by
PC-20251223ZVQQ\Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善预警工单数据接入
parent
b70ae87b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
22 deletions
+30
-22
dataIntegration.ts
src/biz/dataIntegration.ts
+5
-14
device.ts
src/biz/device.ts
+10
-2
mqttClient.ts
src/biz/mqttClient.ts
+12
-3
schedule.ts
src/config/schedule.ts
+3
-3
No files found.
src/biz/dataIntegration.ts
View file @
18e87f61
...
@@ -743,7 +743,7 @@ export async function customerDeviceData() {
...
@@ -743,7 +743,7 @@ export async function customerDeviceData() {
/**
/**
* 数据集成-预警工单数据集成
* 数据集成-预警工单数据集成
* 从飞奕云平台拉取
当天
空调内机故障记录,按 indoorUnitAlarmId 去重后写入 device_fault 表
* 从飞奕云平台拉取
最近 100 条
空调内机故障记录,按 indoorUnitAlarmId 去重后写入 device_fault 表
*/
*/
export
async
function
alertWorkData
()
{
export
async
function
alertWorkData
()
{
console
.
log
(
'[预警工单集成] 开始...'
);
console
.
log
(
'[预警工单集成] 开始...'
);
...
@@ -755,22 +755,13 @@ export async function alertWorkData() {
...
@@ -755,22 +755,13 @@ export async function alertWorkData() {
}
}
try
{
try
{
const
todayDate
=
getTodayDateStr
();
// 1. 拉取最近 100 条故障记录(不再限制当天)
const
result
=
await
getIndoorUnitAlarmErrorHis
({
page
:
1
,
limit
:
100
});
// 1. 分页拉取当天所有故障记录
const
rows
:
any
[]
=
result
?.
rows
||
[];
const
rows
=
await
fetchAllPages
(
(
page
,
limit
,
extraParams
)
=>
getIndoorUnitAlarmErrorHis
({
page
,
limit
,
occurrenceTime
:
extraParams
.
occurrenceTime
,
}),
{
occurrenceTime
:
todayDate
},
200
,
);
console
.
log
(
`[预警工单集成] 获取
${
rows
.
length
}
条故障记录`
);
console
.
log
(
`[预警工单集成] 获取
${
rows
.
length
}
条故障记录`
);
if
(
rows
.
length
===
0
)
{
if
(
rows
.
length
===
0
)
{
console
.
log
(
'[预警工单集成]
当天
无故障记录,跳过'
);
console
.
log
(
'[预警工单集成] 无故障记录,跳过'
);
return
;
return
;
}
}
...
...
src/biz/device.ts
View file @
18e87f61
...
@@ -88,8 +88,16 @@ export async function handleDevicePush(deviceId: string, data: any, deviceTime?:
...
@@ -88,8 +88,16 @@ export async function handleDevicePush(deviceId: string, data: any, deviceTime?:
created_at
:
receivedTime
,
created_at
:
receivedTime
,
});
});
// 根据设备上报的数据,联动控制空调设备
// 根据regionKey查询区域表,若包含文创,则禁用空调控制
await
controlAcByEnvironment
(
deviceId
,
data
);
const
regionRow
=
await
selectOneDataByParam
(
TABLENAME
.
区域表
,
{
id
:
device
.
data
.
region_key
},
[
"name"
]
);
// 调用空调控制(非文创区域才允许自动控温)
if
(
regionRow
?.
data
&&
!
regionRow
.
data
.
name
?.
includes
(
"文创"
))
{
// 根据设备上报的数据,联动控制空调设备
await
controlAcByEnvironment
(
deviceId
,
data
);
}
return
{
success
:
true
};
return
{
success
:
true
};
}
}
...
...
src/biz/mqttClient.ts
View file @
18e87f61
...
@@ -57,7 +57,7 @@ export async function processDeviceData(message) {
...
@@ -57,7 +57,7 @@ export async function processDeviceData(message) {
const
deviceRow
=
await
selectOneDataByParam
(
const
deviceRow
=
await
selectOneDataByParam
(
TABLENAME
.
设备表
,
{
device_id
:
devEUI
}
TABLENAME
.
设备表
,
{
device_id
:
devEUI
}
);
);
if
(
!
deviceRow
)
{
if
(
!
deviceRow
&&
!
deviceRow
.
data
)
{
console
.
warn
(
`设备不存在,跳过入库:
${
devEUI
}
`
);
console
.
warn
(
`设备不存在,跳过入库:
${
devEUI
}
`
);
return
;
return
;
}
}
...
@@ -89,8 +89,17 @@ export async function processDeviceData(message) {
...
@@ -89,8 +89,17 @@ export async function processDeviceData(message) {
console
.
log
(
`数据入库成功: 设备
${
devEUI
}
`
);
console
.
log
(
`数据入库成功: 设备
${
devEUI
}
`
);
// 调用空调控制
// 根据regionKey查询区域表,若包含文创,则禁用空调控制
await
controlAcByEnvironment
(
devEUI
,
data
);
if
(
deviceRow
.
data
&&
deviceRow
.
data
.
region_key
)
{
const
regionRow
=
await
selectOneDataByParam
(
TABLENAME
.
区域表
,
{
id
:
deviceRow
.
data
.
region_key
},
[
"name"
]
);
// 调用空调控制(非文创区域才允许自动控温)
if
(
regionRow
?.
data
&&
!
regionRow
.
data
.
name
?.
includes
(
"文创"
))
{
await
controlAcByEnvironment
(
devEUI
,
data
);
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
'数据处理失败:'
,
error
);
console
.
error
(
'数据处理失败:'
,
error
);
...
...
src/config/schedule.ts
View file @
18e87f61
/**
/**
* 定时任务调度器
* 定时任务调度器
* - 每分钟执行一次数据同步任务
* - 每分钟执行一次数据同步任务
* - 每
10
分钟执行一次预警工单同步任务
* - 每
6
分钟执行一次预警工单同步任务
* - 内置锁机制,防止任务重叠执行
* - 内置锁机制,防止任务重叠执行
* - 任务锁死时(超时未释放),会主动强制释放锁,确保后续任务能正常执行
* - 任务锁死时(超时未释放),会主动强制释放锁,确保后续任务能正常执行
*/
*/
...
@@ -123,10 +123,10 @@ const alertTaskLock: TaskLock = {
...
@@ -123,10 +123,10 @@ const alertTaskLock: TaskLock = {
};
};
/** 预警工单锁超时(毫秒) */
/** 预警工单锁超时(毫秒) */
const
ALERT_LOCK_TIMEOUT_MS
=
9
*
60
*
1000
;
// 9
分钟
const
ALERT_LOCK_TIMEOUT_MS
=
5
*
60
*
1000
;
// 5
分钟
/** 预警工单执行间隔(毫秒) */
/** 预警工单执行间隔(毫秒) */
const
ALERT_TASK_INTERVAL_MS
=
10
*
60
*
1000
;
// 10
分钟
const
ALERT_TASK_INTERVAL_MS
=
6
*
60
*
1000
;
// 6
分钟
/**
/**
* 尝试获取预警工单任务锁
* 尝试获取预警工单任务锁
...
...
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