运行分析修改

parent 2eb4581a
...@@ -94,10 +94,11 @@ export async function handleDevicePush(deviceId: string, data: any, deviceTime?: ...@@ -94,10 +94,11 @@ export async function handleDevicePush(deviceId: string, data: any, deviceTime?:
["name"] ["name"]
); );
// 调用空调控制(非文创区域才允许自动控温) // 调用空调控制(非文创区域才允许自动控温)
if (regionRow?.data && !regionRow.data.name?.includes("文创")) { // if (regionRow?.data && !regionRow.data.name?.includes("文创")) {
// 根据设备上报的数据,联动控制空调设备 // 根据设备上报的数据,联动控制空调设备
await controlAcByEnvironment(deviceId, data); let regionName = regionRow?.data && !regionRow.data.name ? regionRow.data.name : "";
} await controlAcByEnvironment(deviceId, data, regionName);
// }
return { success: true }; return { success: true };
} }
......
...@@ -107,7 +107,8 @@ export async function processDeviceData(message) { ...@@ -107,7 +107,8 @@ export async function processDeviceData(message) {
// && !regionRow.data.name?.includes("社会责任厅") // && !regionRow.data.name?.includes("社会责任厅")
// && !regionRow.data.name?.includes("新包装") // && !regionRow.data.name?.includes("新包装")
// ) { // ) {
await controlAcByEnvironment(devEUI, data); let regionName = regionRow?.data && !regionRow.data.name? regionRow.data.name : "";
await controlAcByEnvironment(devEUI, data, regionName);
// } // }
} }
......
...@@ -11,7 +11,7 @@ import { selectDataListByParam } from "../data/findData"; ...@@ -11,7 +11,7 @@ import { selectDataListByParam } from "../data/findData";
const HALL_NAMES = ["A馆", "B馆", "C馆"]; const HALL_NAMES = ["A馆", "B馆", "C馆"];
const HALL_KEYS = ["total_a", "total_b", "total_c"]; const HALL_KEYS = ["total_a", "total_b", "total_c"];
const TABLE_TITLE_LIST = ["时间", "运行时长", "温度℃", "客流量", "能耗kWh"]; const TABLE_TITLE_LIST = ["时间", "运行时长", "温度℃", "客流量", "总耗电量"];
// ======================= 工具函数 ======================= // ======================= 工具函数 =======================
...@@ -67,10 +67,10 @@ function fmtNum(val: number | null): string { ...@@ -67,10 +67,10 @@ function fmtNum(val: number | null): string {
return String(Math.round(val * 10) / 10); return String(Math.round(val * 10) / 10);
} }
/** 格式化能耗,为 0 时返回 "——" */ /** 格式化能耗,保留两位小数,为 0 时返回 "——" */
function fmtEnergy(val: number): string { function fmtEnergy(val: number): string {
if (val <= 0) return "——"; if (val <= 0) return "——";
return Math.round(val).toLocaleString() + "kwh"; return String(Math.round(val * 100) / 100) + "kwh";
} }
/** 按周七天生成日期数组 */ /** 按周七天生成日期数组 */
...@@ -318,19 +318,19 @@ export async function getWeeklyReportData(weekOffset: number = 0): Promise<any> ...@@ -318,19 +318,19 @@ export async function getWeeklyReportData(weekOffset: number = 0): Promise<any>
dayRunHours > 0 ? fmtNum(dayRunHours) + "h" : "——", dayRunHours > 0 ? fmtNum(dayRunHours) + "h" : "——",
dayTempCount > 0 ? fmtNum(dayTempSum / dayTempCount) : "——", dayTempCount > 0 ? fmtNum(dayTempSum / dayTempCount) : "——",
dayVisitor > 0 ? String(dayVisitor) : "——", dayVisitor > 0 ? String(dayVisitor) : "——",
dayEnergy > 0 ? String(Math.round(dayEnergy / 24 * 100) / 100) : "——", dayEnergy > 0 ? String(Math.round(dayEnergy * 100) / 100) : "——",
]); ]);
} }
// ===== 第四步:汇总各馆 ===== // ===== 第四步:汇总各馆 =====
const hallAvgTemp = hallTempCount > 0 ? hallTempSum / hallTempCount : null; const hallAvgTemp = hallTempCount > 0 ? hallTempSum / hallTempCount : null;
const hallTempStr = hallAvgTemp != null ? fmtNum(hallAvgTemp) + "°C" : "——"; const hallTempStr = hallAvgTemp != null ? fmtNum(hallAvgTemp) + "°C" : "——";
const hallEnergyStr = fmtEnergy(hallTotalEnergy / 7); const hallEnergyStr = fmtEnergy(hallTotalEnergy);
const kllStr = hallTotalVisitor > 0 ? String(Math.round(hallTotalVisitor / 7)) : "——"; const kllStr = hallTotalVisitor > 0 ? String(Math.round(hallTotalVisitor)) : "——";
dataTotal[hallKey] = { nh: hallEnergyStr, kll: kllStr, jw: hallTempStr }; dataTotal[hallKey] = { nh: hallEnergyStr, kll: kllStr, jw: hallTempStr };
runDatas[hallName] = { runDatas[hallName] = {
rjnh: hallTotalEnergy > 0 ? fmtNum(hallTotalEnergy / 7) + " kWh" : "——", rjnh: hallTotalEnergy > 0 ? String(Math.round(hallTotalEnergy * 100) / 100) + " kWh" : "——",
tableData: [{ titleList: TABLE_TITLE_LIST, tableList }], tableData: [{ titleList: TABLE_TITLE_LIST, tableList }],
totalData: [ totalData: [
"周累计", "周累计",
...@@ -355,8 +355,8 @@ export async function getWeeklyReportData(weekOffset: number = 0): Promise<any> ...@@ -355,8 +355,8 @@ export async function getWeeklyReportData(weekOffset: number = 0): Promise<any>
// ===== 第五步:整体汇总 + 评价 ===== // ===== 第五步:整体汇总 + 评价 =====
dataTotal.ztyx = { dataTotal.ztyx = {
nh: fmtEnergy(overallEnergy / 7), nh: fmtEnergy(overallEnergy),
kll: overallVisitor > 0 ? String(Math.round(overallVisitor / 7)) : "——", kll: overallVisitor > 0 ? String(Math.round(overallVisitor)) : "——",
jw: overallTempCount > 0 jw: overallTempCount > 0
? fmtNum(overallTempSum / overallTempCount) + "°C" ? fmtNum(overallTempSum / overallTempCount) + "°C"
: "——", : "——",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment