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
0d91348d
Commit
0d91348d
authored
Jun 05, 2026
by
PC-20251223ZVQQ\Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
空调弹窗-控制空调运行
parent
c8dee5c3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
27 deletions
+69
-27
running.ts
src/biz/running.ts
+65
-24
device.ts
src/routers/device.ts
+4
-3
No files found.
src/biz/running.ts
View file @
0d91348d
import
{
fail
}
from
"assert"
;
import
{
TABLENAME
}
from
"../config/dbEnum"
;
import
{
ERRORENUM
}
from
"../config/errorEnum"
;
import
{
selectDataListByParam
}
from
"../data/findData"
;
import
{
select
OneDataByParam
,
select
DataListByParam
}
from
"../data/findData"
;
import
{
BizError
}
from
"../util/bizError"
;
import
{
controlIndoorUnit
}
from
"./feiyiClient"
;
import
{
getRegionList
}
from
"./region"
;
...
...
@@ -75,8 +76,8 @@ export async function getRunAnalysis(regionGroup: string, regionType: string) {
let
currentMonthEnergy
=
await
getTotalEnergy
(
energyDeviceIds
,
currentMonthStart
,
new
Date
());
let
previousMonthEnergy
=
await
getTotalEnergy
(
energyDeviceIds
,
lastMonthStart
,
lastMonthEnd
);
let
dailyYearOnYear
=
yesterdayEnergy
===
0
?
'0%'
:
`
${(((
todayEnergy
-
yesterdayEnergy
)
/
yesterdayEnergy
)
*
100
).
toFixed
(
2
)}
%`
;
let
monthlyYearOnYear
=
previousMonthEnergy
===
0
?
'0%'
:
`
${(((
currentMonthEnergy
-
previousMonthEnergy
)
/
previousMonthEnergy
)
*
100
).
toFixed
(
2
)}
%`
;
let
dailyYearOnYear
=
yesterdayEnergy
===
0
?
0
:
(((
todayEnergy
-
yesterdayEnergy
)
/
yesterdayEnergy
)
*
100
).
toFixed
(
2
)
;
let
monthlyYearOnYear
=
previousMonthEnergy
===
0
?
0
:
(((
currentMonthEnergy
-
previousMonthEnergy
)
/
previousMonthEnergy
)
*
100
).
toFixed
(
2
)
;
// 1.3 用电趋势:过去24小时(按小时)、过去7天、过去30天、过去一年(按月)
let
nowTime
=
new
Date
();
...
...
@@ -91,11 +92,11 @@ export async function getRunAnalysis(regionGroup: string, regionType: string) {
// 1.4. 能耗监控数据和能耗监控趋势图数据
resultAny
.
energyManagement
=
{
todayElectricity
:
`
${
todayEnergy
.
toFixed
(
0
)}
kwh`
,
yesterdayElectricity
:
`
${
yesterdayEnergy
.
toFixed
(
0
)}
kwh`
,
todayElectricity
:
todayEnergy
.
toFixed
(
0
)
,
yesterdayElectricity
:
yesterdayEnergy
.
toFixed
(
0
)
,
dailyYearOnYear
,
currentMonthElectricity
:
`
${
currentMonthEnergy
.
toFixed
(
0
)}
kwh`
,
previousMonthElectricity
:
`
${
previousMonthEnergy
.
toFixed
(
0
)}
kwh`
,
currentMonthElectricity
:
currentMonthEnergy
.
toFixed
(
0
)
,
previousMonthElectricity
:
previousMonthEnergy
.
toFixed
(
0
)
,
monthlyYearOnYear
};
resultAny
.
electricityTrend
=
{
...
...
@@ -194,11 +195,9 @@ export async function getRunAnalysis(regionGroup: string, regionType: string) {
"二级预警": 20,
"三级预警": 18
};
let alertWorkType = {
"设备故障": { count: 25, proportion: '52%' },
"环境异常": { count: 15, proportion: '30%' },
"安全事件": { count: 8, proportion: '18%' }
};
let alertWorkType = [{ count: 25, name: "设备故障", proportion: '52%' },
{ count: 15, name: "环境异常", proportion: '30%' },
{ count: 8, name: "安全事件", proportion: '18%' }];
// 5.2. 预警监控数据
resultAny.alertManagement = {
alertWorkLevel: alertWorkLevel,
...
...
@@ -449,8 +448,8 @@ export async function getRunAnalysis(regionGroup: string, regionType: string) {
// 运行监控总数据(一天)
resultAny.mainRunningManagement = {
totalCustomerNumber: 10000,
totalDeviceOnlineRate:
'99.8%'
,
totalElectricity:
`
360
kwh
`
,
totalDeviceOnlineRate:
99.8
,
totalElectricity:
360
,
};
} else {
// 设备监控总数据
...
...
@@ -579,15 +578,40 @@ export async function getAcRunningPop(regionKey: number, deviceId: string) {
* 设备运行弹框 - 空调启停
* @param deviceId
*/
export async function controlAcRunning(deviceIds?: string[], workerMode?: string) {
export async function controlAcRunning(params: {}) {
let deviceId = params["deviceId"];
let mode = params["mode"];
let power = params["power"];
let setTemp = params["setTemp"];
let maxTemp = params["maxTemp"];
let minTemp = params["minTemp"];
let autoControl = params["autoControl"];
let fanSpeed = params["fanSpeed"];
// 1. 通过设备信息,获取内机地址
let device
s = await selectDataList
ByParam(
let device
= await selectOneData
ByParam(
TABLENAME.设备表,
{ device_id:
{ "%in%": deviceIds }
},
{ device_id:
deviceId
},
["device_id", "region_key", "device_name", "device_ad", "control_params"]
);
// 2. 通过内机地址调用空调控制接口启停空调设备,无需校验环境温度
return await controlAcRunningApi(devices, 0, workerMode);
if (!device.data || !device.data.id) {
throw new BizError(ERRORENUM.未找到数据, `
设备
$
{
deviceId
}
未注册
`);
}
// 2. 接入空调控制API,更新空调设备信息
let acPrarms = {
"indoorUnitAddressFull": [deviceId],
"workMode": acDeviceKeyMap[mode],
"onOff": acDeviceKeyMap[power],
"tempSet": setTemp,
"fanSpeed": acDeviceKeyMap[fanSpeed],
"onOffLock": acDeviceKeyMap[autoControl],
"workModeLock": acDeviceKeyMap[autoControl],
"tempSetLock": acDeviceKeyMap[autoControl],
"tempSetLo": minTemp,
"tempSetHi": maxTemp,
"openApiAction": autoControl === "解除" ? "control" : "lock"
};
return await controlIndoorUnit(acPrarms);
}
// 辅助函数:获取用电趋势(按间隔分组)
...
...
@@ -682,11 +706,6 @@ async function controlAcRunningApi(acDevices?: any, temperature?: number, worker
deviceMinList.push(ac.device_ad);
workModeMap[2] = deviceMinList;
openApiAction = "control";
} else if (!temperature && workerMode) {
// 根据workerMode控制空调设备
console.log(`
根据工作模式控制空调
$
{
ac
.
device_name
}
(
$
{
workerMode
}
)
`);
workModeMap[workerMode] = workModeMap[workerMode] ? [...workModeMap[workerMode], ac.device_ad] : [ac.device_ad];
openApiAction = "lock";
}
});
// 多个设备: 接入空调控制API,传入设备ID和控制指令(如开/关、温度设定等)
...
...
@@ -710,4 +729,25 @@ async function controlAcRunningApi(acDevices?: any, temperature?: number, worker
}
}
return controlResults;
}
/**
* 空调中文到Key的映射
* 1 制冷 2 制热 3 送风 4 除湿
* 0 关-off 1 开-on
* 1 高风-超强 2 中风-强 4 低风-弱
* 0 不锁定-解除 1 锁定-生效
*/
let acDeviceKeyMap: { [key: string]: number } = {
"制冷": 1,
"制热": 2,
"送风": 3,
"除湿": 4,
"on": 1,
"off": 0,
"超强": 1,
"强": 2,
"弱": 4,
"解除": 0,
"生效": 1
}
\ No newline at end of file
src/routers/device.ts
View file @
0d91348d
...
...
@@ -129,10 +129,11 @@ async function getRegionList(req, res) {
* 控制空调开关
*/
async
function
controlAcRunning
(
req
,
res
)
{
let
reqConf
=
{
deviceId
:
'String'
,
workerMode
:
'String'
};
let
reqConf
=
{
deviceId
:
'String'
,
mode
:
'String'
,
power
:
'String'
,
setTemp
:
'Number'
,
maxTemp
:
'Number'
,
minTemp
:
'Number'
,
autoControl
:
'String'
,
fanSpeed
:
'String'
};
const
NotMustHaveKeys
=
[];
let
{
deviceId
,
workerMode
}
=
eccReqParamater
(
reqConf
,
req
.
body
,
NotMustHaveKeys
);
const
result
=
await
runningBiz
.
controlAcRunning
(
deviceId
,
workerMode
);
let
{
deviceId
,
mode
,
power
,
setTemp
,
maxTemp
,
minTemp
,
autoControl
,
fanSpeed
}
=
eccReqParamater
(
reqConf
,
req
.
body
,
NotMustHaveKeys
);
let
params
=
{
deviceId
,
mode
,
power
,
setTemp
,
maxTemp
,
minTemp
,
autoControl
,
fanSpeed
};
const
result
=
await
runningBiz
.
controlAcRunning
(
params
);
res
.
success
(
result
);
}
...
...
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