From 39e5424c8ce474c09ef9939f28e07232dedf3113 Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期四, 03 四月 2025 15:13:15 +0800
Subject: [PATCH] 1. 添加生产履历的报表的界面,并且绑定生产履历的报表管理器

---
 SourceCode/Bond/Servo/AlarmManager.cpp |   18 ++++++------------
 1 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/SourceCode/Bond/Servo/AlarmManager.cpp b/SourceCode/Bond/Servo/AlarmManager.cpp
index 74b1006..6c30cfc 100644
--- a/SourceCode/Bond/Servo/AlarmManager.cpp
+++ b/SourceCode/Bond/Servo/AlarmManager.cpp
@@ -33,12 +33,6 @@
     }
 }
 
-// 设置数据库连接
-void AlarmManager::setDatabase(BL::Database* db) {
-    std::lock_guard<std::mutex> lock(m_mutex);
-    m_pDB = db;
-}
-
 // 初始化报警表
 bool AlarmManager::initAlarmTable() {
     char path[MAX_PATH];
@@ -89,7 +83,7 @@
             unit_id TEXT NOT NULL,
             description TEXT NOT NULL,
             start_time DATETIME NOT NULL,
-            end_time DATETIME NOT NULL,
+            end_time DATETIME,
             FOREIGN KEY (device_id) REFERENCES devices(device_id),
             FOREIGN KEY (unit_id) REFERENCES units(unit_id)
         )
@@ -127,7 +121,7 @@
 
     // 插入单元数据
     for (int i = 1; i <= 3; ++i) {
-        for (int j = 1; j <= 3; ++j) {
+        for (int j = 0; j <= 3; ++j) {
             int unitId = j;
             std::string deviceId = std::to_string(i);
             std::string unitName = "Unit" + std::to_string(j);
@@ -144,6 +138,7 @@
         }
     }
 
+    /*
     // 初始化随机数生成器
     std::random_device rd;
     std::mt19937 gen(rd());
@@ -181,6 +176,7 @@
             std::cerr << "Failed to insert alarm data." << std::endl;
         }
     }
+    */
 }
 
 // 添加报警信息
@@ -717,7 +713,7 @@
 }
 
 // 通过多个属性查找并解除报警(更新结束时间)
-bool AlarmManager::clearAlarmByAttributes(int nId, int nSeverityLevel, int nDeviceId, int nUnitId, const std::string& strDescription, const std::string& endTime) {
+bool AlarmManager::clearAlarmByAttributes(int nId, int nDeviceId, int nUnitId, const std::string& endTime) {
     if (!m_pDB) {
         return false;
     }
@@ -729,10 +725,8 @@
     for (AlarmDataMap::const_iterator it = m_mapCache.begin(); it != m_mapCache.end(); ++it) {
         const AlarmData& alarm = it->second;
         if (alarm.nId == nId &&
-            alarm.nSeverityLevel == nSeverityLevel &&
             alarm.nDeviceId == nDeviceId &&
-            alarm.nUnitId == nUnitId &&
-            alarm.strDescription == strDescription) {
+            alarm.nUnitId == nUnitId) {
 
             alarmEventId = it->first;
             break;

--
Gitblit v1.9.3