Compare commits

...

5 Commits

View File

@@ -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,42 +526,42 @@ 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>
/// 设备信息类