diff --git a/UI/Controllers/UpgradeController.cs b/UI/Controllers/UpgradeController.cs
index 661a345..ea1fcd0 100644
--- a/UI/Controllers/UpgradeController.cs
+++ b/UI/Controllers/UpgradeController.cs
@@ -642,28 +642,33 @@ namespace UI.Controllers
/// 查询房间设备访问日志
///
/// 酒店ID
- /// 房号
+ /// 房号(可选,为空时查询酒店所有故障记录)
/// 开始时间(格式:yyyy-MM-dd HH:mm:ss)
/// 结束时间(格式:yyyy-MM-dd HH:mm:ss)
/// 返回查询结果
[HttpPost]
- public ActionResult QueryRoomVisitLog(string HotelID, string RoomNumber, string StartTime = null, string EndTime = null)
+ public ActionResult QueryRoomVisitLog(string HotelID, string RoomNumber = null, string StartTime = null, string EndTime = null)
{
try
{
- if (string.IsNullOrWhiteSpace(HotelID) || string.IsNullOrWhiteSpace(RoomNumber))
+ if (string.IsNullOrWhiteSpace(HotelID))
{
- return Json(new { Status = 0, Message = "酒店ID和房号不能为空" }, JsonRequestBehavior.AllowGet);
+ return Json(new { Status = 0, Message = "酒店ID不能为空" }, JsonRequestBehavior.AllowGet);
}
// 构建查询条件
- string whereClause = "WHERE HotelID = @HotelID AND RoomNumber = @RoomNumber";
+ string whereClause = "WHERE HotelID = @HotelID AND EquipmentStatus = '故障'";
var parameters = new Dictionary
{
- { "HotelID", HotelID },
- { "RoomNumber", RoomNumber }
+ { "HotelID", HotelID }
};
+ if (!string.IsNullOrWhiteSpace(RoomNumber))
+ {
+ whereClause += " AND RoomNumber = @RoomNumber";
+ parameters["RoomNumber"] = RoomNumber;
+ }
+
DateTime startDateTime = default(DateTime);
DateTime endDateTime = default(DateTime);
bool hasStart = !string.IsNullOrWhiteSpace(StartTime);
diff --git a/更新日志.md b/更新日志.md
index 59c4c08..d64c83f 100644
--- a/更新日志.md
+++ b/更新日志.md
@@ -94,7 +94,7 @@ fetch('/Upgrade/WriteRoomVisitLog', {
**备注**:
该接口用于记录房间设备的访问和状态信息,方便后续查询和分析。
-#### 2. 房间设备访问日志查询接口
+#### 2. 房间设备访问日志查询接口(故障记录查询)
**接口地址**:
`/Upgrade/QueryRoomVisitLog`
@@ -106,10 +106,13 @@ fetch('/Upgrade/WriteRoomVisitLog', {
| 参数名 | 类型 | 必填 | 描述 |
| --- | --- | --- | --- |
| HotelID | string | 是 | 酒店ID |
-| RoomNumber | string | 是 | 房号 |
+| RoomNumber | string | 否 | 房号(为空时查询酒店所有故障记录) |
| StartTime | string | 否 | 开始时间(格式:yyyy-MM-dd HH:mm:ss) |
| EndTime | string | 否 | 结束时间(格式:yyyy-MM-dd HH:mm:ss) |
+**功能描述**:
+该接口用于查询房间设备故障日志,根据酒店ID进行筛选,房号可选,为空时查询酒店所有故障记录。支持按时间范围筛选。
+
**返回结果**:
```json
{
@@ -120,30 +123,51 @@ fetch('/Upgrade/WriteRoomVisitLog', {
"ID": 1,
"HotelID": "123",
"RoomNumber": "101",
- "EquipmentStatus": "正常",
- "FaultDescription": null,
- "UpdateDate": "2025-12-24 10:30:00",
- "DevName": "灯光设备"
- },
- {
- "ID": 2,
- "HotelID": "123",
- "RoomNumber": "101",
"EquipmentStatus": "故障",
"FaultDescription": "无法正常开关",
- "UpdateDate": "2025-12-24 10:31:00",
- "DevName": "空调设备"
+ "UpdateDate": "2025-12-24 10:30:00",
+ "DevName": "空调设备",
+ "EquipmentStatusType": "温控器故障",
+ "EquipmentOnlineStatus": "在线"
}
]
}
```
-**功能描述**:
-该接口用于查询房间设备访问日志,根据酒店ID、房号和时间范围进行筛选。如果开始时间和结束时间为空,则查询该房间的所有记录。
-
**使用示例**:
```javascript
-// 查询指定时间范围内的记录
+// 查询酒店所有故障记录
+fetch('/Upgrade/QueryRoomVisitLog', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/x-www-form-urlencoded'
+ },
+ body: JSON.stringify({
+ HotelID: '123'
+ })
+})
+.then(response => response.json())
+.then(data => {
+ console.log(data);
+});
+
+// 查询指定房间故障记录
+fetch('/Upgrade/QueryRoomVisitLog', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/x-www-form-urlencoded'
+ },
+ body: JSON.stringify({
+ HotelID: '123',
+ RoomNumber: '101'
+ })
+})
+.then(response => response.json())
+.then(data => {
+ console.log(data);
+});
+
+// 查询指定时间范围内的故障记录
fetch('/Upgrade/QueryRoomVisitLog', {
method: 'POST',
headers: {
@@ -159,24 +183,6 @@ fetch('/Upgrade/QueryRoomVisitLog', {
.then(response => response.json())
.then(data => {
console.log(data);
- // 输出查询结果
-});
-
-// 查询所有记录
-fetch('/Upgrade/QueryRoomVisitLog', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded'
- },
- body: JSON.stringify({
- HotelID: '123',
- RoomNumber: '101'
- })
-})
-.then(response => response.json())
-.then(data => {
- console.log(data);
- // 输出查询结果
});
```
@@ -184,7 +190,7 @@ fetch('/Upgrade/QueryRoomVisitLog', {
系统开发团队
**备注**:
-该接口用于查询房间设备的访问和状态信息,支持按时间范围筛选,方便进行历史记录查询和分析。
+该接口仅查询设备状态为"故障"的记录,支持按酒店ID和房号筛选,方便进行故障查询和分析。
#### 3. 设备状态类型和在线状态字段更新