Compare commits
7 Commits
a1c97ea5bc
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a8419a7ae4 | ||
|
|
1f35e8fc81 | ||
| e3225a88e4 | |||
| 8371543cf7 | |||
| dcb232029c | |||
| 65256167dc | |||
| cd728738fe |
@@ -497,7 +497,7 @@ namespace UI.Controllers
|
||||
/// 查询设备列表
|
||||
/// </summary>
|
||||
[HttpPost()]
|
||||
public List<RCUDBData> QueryDeviceList(int HotelID, int RoomTypeID)
|
||||
public ActionResult QueryDeviceList(int HotelID, int RoomTypeID)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -509,15 +509,14 @@ namespace UI.Controllers
|
||||
,`DevAddr`
|
||||
,`Process`
|
||||
FROM `blv_rcu_db`.`tbl_configured_devlist`
|
||||
where `hoHotelID` ={0} and `RoomTypeID`={1};", HotelID, RoomTypeID);
|
||||
where `HotelID` ={0} and `RoomTypeID`={1};", HotelID, RoomTypeID);
|
||||
var Data = SqlSugarBase.RcuDb.SqlQueryable<RCUDBData>(str).ToList();
|
||||
return Data;
|
||||
return Json(new { Status=1,Data=Data},JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
return Json(new { Status = -1, Message = "服务器错误", Detail = ex.Message } ,JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
return new List<RCUDBData>();
|
||||
}
|
||||
|
||||
|
||||
@@ -527,51 +526,53 @@ namespace UI.Controllers
|
||||
/// <param name="requestData"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
[HttpPost]
|
||||
public async Task<string> SetRCUService(RCUCurtainRequest requestData)
|
||||
{
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
// 1. 序列化请求对象为JSON
|
||||
string jsonString = JsonConvert.SerializeObject(requestData);
|
||||
//[HttpPost]
|
||||
//public async Task<string> SetRCUService(RCUCurtainRequest requestData)
|
||||
//{
|
||||
// using (var client = new HttpClient())
|
||||
// {
|
||||
// // 1. 序列化请求对象为JSON
|
||||
// string jsonString = JsonConvert.SerializeObject(requestData);
|
||||
|
||||
// 2. 正确编码JSON字符串
|
||||
string encodedJson = Uri.EscapeDataString(jsonString);
|
||||
// // 2. 正确编码JSON字符串
|
||||
// string encodedJson = Uri.EscapeDataString(jsonString);
|
||||
|
||||
// 3. 构建完整的GET请求URL
|
||||
string apiUrl = $"{baseUrl}SetRCUService?jsonData={encodedJson}";
|
||||
// // 3. 构建完整的GET请求URL
|
||||
// string apiUrl = $"{baseUrl}SetRCUService?jsonData={encodedJson}";
|
||||
|
||||
try
|
||||
{
|
||||
// 4. 发送GET请求
|
||||
var response = await client.GetAsync(apiUrl);
|
||||
// try
|
||||
// {
|
||||
// // 4. 发送GET请求
|
||||
// var response = await client.GetAsync(apiUrl);
|
||||
|
||||
// 5. 处理响应
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
var errorContent = await response.Content.ReadAsStringAsync();
|
||||
throw new Exception($"服务信息控制失败: HTTP {response.StatusCode} - {errorContent}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"请求发送失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
// // 5. 处理响应
|
||||
// if (response.IsSuccessStatusCode)
|
||||
// {
|
||||
// return await response.Content.ReadAsStringAsync();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var errorContent = await response.Content.ReadAsStringAsync();
|
||||
// throw new Exception($"服务信息控制失败: HTTP {response.StatusCode} - {errorContent}");
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// throw new Exception($"请求发送失败: {ex.Message}");
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 设备信息类
|
||||
/// </summary>
|
||||
public class EquipmentInfo
|
||||
{
|
||||
public string EquipmentStatus { get; set; } // 设备状态
|
||||
public string FaultDescription { get; set; } // 故障描述
|
||||
public string DevName { get; set; } // 设备名称
|
||||
public string EquipmentStatus { get; set; }
|
||||
public string FaultDescription { get; set; }
|
||||
public string DevName { get; set; }
|
||||
public string EquipmentStatusType { get; set; }
|
||||
public string EquipmentOnlineStatus { get; set; }
|
||||
}
|
||||
|
||||
private class RoomVisitLogFormRow
|
||||
@@ -582,6 +583,8 @@ namespace UI.Controllers
|
||||
public string FaultDescription { get; set; }
|
||||
public string UpdateDate { get; set; }
|
||||
public string DevName { get; set; }
|
||||
public string EquipmentStatusType { get; set; }
|
||||
public string EquipmentOnlineStatus { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -616,7 +619,9 @@ namespace UI.Controllers
|
||||
EquipmentStatus = equipment.EquipmentStatus,
|
||||
FaultDescription = equipment.FaultDescription,
|
||||
UpdateDate = updateDate,
|
||||
DevName = equipment.DevName
|
||||
DevName = equipment.DevName,
|
||||
EquipmentStatusType = equipment.EquipmentStatusType,
|
||||
EquipmentOnlineStatus = equipment.EquipmentOnlineStatus
|
||||
}).ToList();
|
||||
|
||||
// 批量写入数据库
|
||||
@@ -693,7 +698,7 @@ namespace UI.Controllers
|
||||
}
|
||||
|
||||
// 构建完整的SQL查询语句
|
||||
string sql = $"SELECT ID, HotelID, RoomNumber, EquipmentStatus, FaultDescription, UpdateDate, DevName FROM tbl_roomvisitlogform {whereClause} ORDER BY UpdateDate DESC";
|
||||
string sql = $"SELECT ID, HotelID, RoomNumber, EquipmentStatus, FaultDescription, UpdateDate, DevName, EquipmentStatusType, EquipmentOnlineStatus FROM tbl_roomvisitlogform {whereClause} ORDER BY UpdateDate DESC";
|
||||
|
||||
// 执行查询
|
||||
var result = SqlSugarBase.RcuDb.Ado.SqlQuery<dynamic>(sql, parameters);
|
||||
|
||||
82
更新日志.md
82
更新日志.md
@@ -25,23 +25,37 @@
|
||||
| EquipmentStatus | string | 否 | 设备状态 |
|
||||
| FaultDescription | string | 否 | 故障描述 |
|
||||
| DevName | string | 否 | 设备名称 |
|
||||
| EquipmentStatusType | string | 否 | 设备状态类型 |
|
||||
| EquipmentOnlineStatus | string | 否 | 设备在线状态 |
|
||||
|
||||
**返回结果**:
|
||||
```json
|
||||
{
|
||||
"Status": 1, // 1成功,0失败,-1异常
|
||||
"Message": "写入成功", // 操作结果描述
|
||||
"Count": 2 // 成功插入的记录数
|
||||
"Count": 3 // 写入记录数量
|
||||
}
|
||||
```
|
||||
|
||||
**功能描述**:
|
||||
该接口用于向数据库表 `tbl_roomvisitlogform` 写入房间设备访问日志,支持批量写入多个设备的信息。UpdateDate 由服务器自动生成,格式为 `yyyy-MM-dd HH:mm:ss`。
|
||||
该接口用于向数据库表 `tbl_roomvisitlogform` 写入房间设备访问日志,支持批量写入多个设备的信息。
|
||||
|
||||
**实现说明 / 变更**:
|
||||
- 修复说明:修复了 Controller 中原先使用匿名对象列表通过 Ado.ExecuteCommand 插入导致的不稳定/编译隐患,改为使用 SqlSugar 的 `Insertable` 批量插入 POCO(写入到 `tbl_roomvisitlogform`),返回实际插入的行数(Count)。
|
||||
- 校验:当 `HotelID` 或 `RoomNumber` 为空,或 `EquipmentList` 为空时,接口返回 `Status=0` 并给出相应错误消息。
|
||||
- 时间字段:`UpdateDate` 由服务器生成,客户端无需提供。
|
||||
**数据库表结构**:
|
||||
```sql
|
||||
CREATE TABLE `tbl_roomvisitlogform` (
|
||||
`ID` int NOT NULL AUTO_INCREMENT,
|
||||
`HotelID` varchar(254) DEFAULT NULLCOMMENT '酒店id',
|
||||
`RoomNumber` varchar(254)DEFAULT NULL COMMENT '房号',
|
||||
`EquipmentStatus` varchar(254)DEFAULT NULL COMMENT '设备状态',
|
||||
`FaultDescription` varchar(254)DEFAULT NULL COMMENT '故障描述',
|
||||
`UpdateDate` varchar(254)DEFAULT NULL COMMENT '更新时间',
|
||||
`DevName` varchar(254)DEFAULT NULL COMMENT '设备名称',
|
||||
`EquipmentStatusType` varchar(254)DEFAULT NULL COMMENT '设备状态类型',
|
||||
`EquipmentOnlineStatus` varchar(254)DEFAULT NULL COMMENT '设备在线状态',
|
||||
PRIMARY KEY (`ID`),
|
||||
KEY `idx_hotel_room` (`HotelID`,`RoomNumber`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3
|
||||
```
|
||||
|
||||
**使用示例**:
|
||||
```javascript
|
||||
@@ -55,15 +69,22 @@ fetch('/Upgrade/WriteRoomVisitLog', {
|
||||
HotelID: '123',
|
||||
RoomNumber: '101',
|
||||
EquipmentList: [
|
||||
{ EquipmentStatus: '正常', DevName: '灯光设备' },
|
||||
{ EquipmentStatus: '故障', FaultDescription: '无法正常开关', DevName: '空调设备' }
|
||||
{
|
||||
EquipmentStatus: '正常',
|
||||
DevName: '灯光设备'
|
||||
},
|
||||
{
|
||||
EquipmentStatus: '故障',
|
||||
FaultDescription: '无法正常开关',
|
||||
DevName: '空调设备'
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
console.log(data);
|
||||
// 输出示例:{"Status":1,"Message":"写入成功","Count":2}
|
||||
// 输出:{"Status":1,"Message":"写入成功","Count":2}
|
||||
});
|
||||
```
|
||||
|
||||
@@ -71,8 +92,7 @@ fetch('/Upgrade/WriteRoomVisitLog', {
|
||||
系统开发团队
|
||||
|
||||
**备注**:
|
||||
- 本次更新修复了导致编译或插入异常的实现方式,现已使用稳定的批量插入方案。
|
||||
- `Count` 字段表示成功写入数据库的行数。
|
||||
该接口用于记录房间设备的访问和状态信息,方便后续查询和分析。
|
||||
|
||||
#### 2. 房间设备访问日志查询接口
|
||||
|
||||
@@ -119,13 +139,7 @@ fetch('/Upgrade/WriteRoomVisitLog', {
|
||||
```
|
||||
|
||||
**功能描述**:
|
||||
该接口用于查询房间设备访问日志,根据酒店ID、房号和时间范围进行筛选。若 `StartTime`/`EndTime` 未提供,则返回该房间全部记录;若提供则按时间过滤并按 `UpdateDate` 降序返回。
|
||||
|
||||
**实现说明 / 变更**:
|
||||
- 修复说明:解决了原实现中使用匿名类型在不同条件下重新赋值导致的编译错误(CS0029),改为使用可变参数集合并对时间参数做格式校验。
|
||||
- 时间参数行为:
|
||||
- `StartTime` / `EndTime` 必须为 `yyyy-MM-dd HH:mm:ss` 格式;格式错误时接口返回 `Status=0` 并带提示信息(例如:`StartTime 格式错误,应为 yyyy-MM-dd HH:mm:ss`)。
|
||||
- 支持单边过滤:仅传 `StartTime` 表示 `UpdateDate >= StartTime`;仅传 `EndTime` 表示 `UpdateDate <= EndTime`;同时传则表示 `StartTime <= UpdateDate <= EndTime`。
|
||||
该接口用于查询房间设备访问日志,根据酒店ID、房号和时间范围进行筛选。如果开始时间和结束时间为空,则查询该房间的所有记录。
|
||||
|
||||
**使用示例**:
|
||||
```javascript
|
||||
@@ -170,4 +184,34 @@ fetch('/Upgrade/QueryRoomVisitLog', {
|
||||
系统开发团队
|
||||
|
||||
**备注**:
|
||||
该接口用于查询房间设备的访问和状态信息,支持按时间范围筛选,方便进行历史记录查询和分析。
|
||||
该接口用于查询房间设备的访问和状态信息,支持按时间范围筛选,方便进行历史记录查询和分析。
|
||||
|
||||
#### 3. 设备状态类型和在线状态字段更新
|
||||
|
||||
**更新时间**:2025-12-26
|
||||
|
||||
**更新内容**:
|
||||
`tbl_roomvisitlogform` 表新增两个字段,接口同步支持:
|
||||
|
||||
| 字段名|类型|描述|
|
||||
|---|---|---|
|
||||
|EquipmentStatusType|varchar(254)|设备状态类型|
|
||||
|EquipmentOnlineStatus|varchar(254)|设备在线状态|
|
||||
|
||||
**修改文件**:
|
||||
`UI/Controllers/UpgradeController.cs`
|
||||
|
||||
**修改内容**:
|
||||
- `EquipmentInfo`类新增 `EquipmentStatusType`和 `EquipmentOnlineStatus`属性
|
||||
- `RoomVisitLogFormRow`类新增对应字段
|
||||
- `WriteRoomVisitLog`接口支持写入新字段数据
|
||||
- `QueryRoomVisitLog`接口查询结果包含新字段
|
||||
|
||||
**数据库更新**:
|
||||
```sql
|
||||
ALTER TABLE `tbl_roomvisitlogform` ADD COLUMN `EquipmentStatusType` varchar(254) DEFAULT NULL COMMENT '设备状态类型';
|
||||
ALTER TABLE `tbl_roomvisitlogform` ADD COLUMN `EquipmentOnlineStatus` varchar(254) DEFAULT NULL COMMENT '设备在线状态';
|
||||
```
|
||||
|
||||
**开发人员**:
|
||||
技术团队
|
||||
|
||||
Reference in New Issue
Block a user