增加两个方法
This commit is contained in:
@@ -84,7 +84,7 @@ namespace UI.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
public static Logger logger= LogManager.GetCurrentClassLogger();
|
||||
public static Logger logger = LogManager.GetCurrentClassLogger();
|
||||
/// <summary>
|
||||
/// 调用微信升级接口
|
||||
/// </summary>
|
||||
@@ -492,6 +492,89 @@ namespace UI.Controllers
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询设备列表
|
||||
/// </summary>
|
||||
[HttpPost()]
|
||||
public List<RCUDBData> QueryDeviceList(int HotelID, int RoomTypeID)
|
||||
{
|
||||
try
|
||||
{
|
||||
string str = string.Format(@"SELECT `ID`
|
||||
,`UpdateTime`
|
||||
,`HotelID`
|
||||
,`RoomTypeID`
|
||||
,`DevName`
|
||||
,`DevAddr`
|
||||
,`Process`
|
||||
FROM `blv_rcu_db`.`tbl_configured_devlist`
|
||||
where `hoHotelID` ={0} and `RoomTypeID`={1};", HotelID, RoomTypeID);
|
||||
var Data = SqlSugarBase.RcuDb.SqlQueryable<RCUDBData>(str).ToList();
|
||||
return Data;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
return new List<RCUDBData>();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 巡检
|
||||
/// </summary>
|
||||
/// <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);
|
||||
|
||||
// 2. 正确编码JSON字符串
|
||||
string encodedJson = Uri.EscapeDataString(jsonString);
|
||||
|
||||
// 3. 构建完整的GET请求URL
|
||||
string apiUrl = $"{baseUrl}SetRCUService?jsonData={encodedJson}";
|
||||
|
||||
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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public class RCUDBData
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string UpdateTime { get; set; }
|
||||
public string HotelID { get; set; }
|
||||
public string RoomTypeID { get; set; }
|
||||
public string DevName { get; set; }
|
||||
public string DevAddr { get; set; }
|
||||
public string Process { get; set; }
|
||||
}
|
||||
public class RoomAddressStatus
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user